pax_global_header00006660000000000000000000000064145575107450014527gustar00rootroot0000000000000052 comment=59756fdd4c4d8845e71205afe557ede86605b23f gogglesmm-gogglesmm-0b8cb53/000077500000000000000000000000001455751074500160775ustar00rootroot00000000000000gogglesmm-gogglesmm-0b8cb53/.gitignore000066400000000000000000000004041455751074500200650ustar00rootroot00000000000000*.o *.d *.so *.so.* *.a CMakeCache.txt CMakeFiles Makefile cmake_install.cmake install_manifest.txt src/gmconfig.h gap/ap_config.h gap/test/gap_* src/gogglesmm_xml.h src/mpris1_xml.h src/mpris2_xml.h src/appstatus_xml.h src/icons.cpp src/icons.h src/gogglesmm gogglesmm-gogglesmm-0b8cb53/AUTHORS000066400000000000000000000024141455751074500171500ustar00rootroot00000000000000Goggles Music Manager Copyright (C) 2002-2023 by Sander Jansen. All Rights Reserved. Various code snippets from FOX-Toolkit Copyright (c) 1998-2011 by Jeroen van der Zijp. All Rights Reserved. Translations ------------ Hendrik Rittich (German) Víctor Pérez Masegosa (Spanish) Erwan Inyzant (French) Sándor Sipos (Hungarian) L Lawliet (Russian) Other Contributions ------------------- - Ratings patch by Julien Desgats. - Original "Goggles" logo designed by Gyurka Jansen. (http://gyurka.nl) - Contains icons from Tango and Gnome icon themes. - MD5 implementation see: gap/lib/md5 - ALAC implementation see: gap/lib/alac Thanks for all the Fish! ------------------------ - Thanks to Charles Warren and Jeroen van der Zijp for testing and many useful suggestions. - Thanks to Oktay Cetinkaya for feedback and bugreports. - Thanks to Gyurka Jansen for the Goggles Logo!. - Thanks to Jason Donenfeld for the many useful suggestions and bug reports. - Thanks to Oliver Duclos for the first tray icon implementation and the usefull bug reports. - Thanks to Sascha Klauder for FreeBSD porting. - Thanks to Chadi El Ahmad for the SliTaz package. - Thanks to John Tyree for feedback and bugreports. - Thanks to Julien Desgats for patches and contributions. gogglesmm-gogglesmm-0b8cb53/CMakeLists.txt000066400000000000000000000110021455751074500206310ustar00rootroot00000000000000# Using cmake 3.2 cmake_minimum_required(VERSION 3.3.1 FATAL_ERROR) project(gogglesmm_dist) # Honor CMAKE_EXE_LINKER_FLAGS during tests cmake_policy(SET CMP0056 NEW) # Need FeaureSummary include(FeatureSummary) # Enable for cmake debugging # set(CMAKE_VERBOSE_MAKEFILE TRUE) # libdir name to allow overriding to lib32 / lib64 # set(CMAKE_INSTALL_LIBDIR "lib" CACHE STRING "Specify the name of the directory where libraries are meant to be installed") # Build with internal FOX library, the OFF setting is not supported option(WITH_CFOX "Enable Internal FOX" ON) # Override default install to /usr if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX /usr CACHE STRING "Installation prefix used by install." FORCE) endif() # Override default build type if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "Specify the desired build type." FORCE) endif() # Status so far message(STATUS "Using build type: ${CMAKE_BUILD_TYPE}") message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}") #------------------------------------------------------------------------------- include(CheckCXXCompilerFlag) check_cxx_compiler_flag(-Wall HAS_CXX_WALL) check_cxx_compiler_flag(-Wextra HAS_CXX_WEXTRA) check_cxx_compiler_flag(-Wno-format HAS_CXX_WFORMAT) check_cxx_compiler_flag(-Wno-format-security HAS_CXX_WFORMAT_SECURITY) check_cxx_compiler_flag(-Wfatal-errors HAS_CXX_WFATAL) check_cxx_compiler_flag(-Og HAS_CXX_OPTIMIZE_DEBUG) # Additional compiler flags we like if(HAS_CXX_WALL) add_compile_options(-Wall) endif() if(HAS_CXX_WEXTRA) add_compile_options(-Wextra) endif() if (HAS_CXX_WFORMAT) add_compile_options(-Wno-format) endif() if (HAS_CXX_WFORMAT_SECURITY) add_compile_options(-Wno-format-security) endif() if(HAS_CXX_WFATAL) add_compile_options(-Wfatal-errors) endif() if(HAS_CXX_OPTIMIZE_DEBUG AND CMAKE_BUILD_TYPE MATCHES Debug) add_compile_options(-Og) endif() # FIXME Doesn't work on all platforms. #CHECK_CXX_COMPILER_FLAG(-flto HAS_CXX_OPTIMIZE_LINKTIME) if(HAS_CXX_OPTIMIZE_LINKTIME AND NOT CMAKE_BUILD_TYPE MATCHES Debug) add_compile_options(-flto) link_libraries(-flto) endif() if(CMAKE_BUILD_TYPE MATCHES Debug) add_definitions(-DDEBUG) endif() # Suppress FXASSERT if(CMAKE_BUILD_TYPE MATCHES None) add_definitions(-DNDEBUG) endif() #------------------------------------------------------------------------------- # Internal FOX Library if(WITH_CFOX) add_subdirectory(cfox) endif() # Add Goggles Audio Player add_subdirectory(gap) # Add Goggles Music Manager add_subdirectory(src) #------------------------------------------------------------------------------- install(FILES icons/gogglesmm_16.png DESTINATION share/icons/hicolor/16x16/apps RENAME gogglesmm.png) install(FILES extra/gogglesmm_22.png DESTINATION share/icons/hicolor/22x22/apps RENAME gogglesmm.png) install(FILES extra/gogglesmm_24.png DESTINATION share/icons/hicolor/24x24/apps RENAME gogglesmm.png) install(FILES icons/gogglesmm_32.png DESTINATION share/icons/hicolor/32x32/apps RENAME gogglesmm.png) install(FILES extra/gogglesmm_48.png DESTINATION share/icons/hicolor/48x48/apps RENAME gogglesmm.png) install(FILES extra/gogglesmm_64.png DESTINATION share/icons/hicolor/64x64/apps RENAME gogglesmm.png) install(FILES extra/gogglesmm.svg DESTINATION share/icons/hicolor/scalable/apps RENAME gogglesmm.svg) install(FILES extra/gogglesmm.appdata.xml DESTINATION share/metainfo) install(FILES extra/gogglesmm.desktop DESTINATION share/applications) install(FILES extra/gogglesmm.1 DESTINATION share/man/man1) # Install translations when native language support has been enabled if(WITH_NLS) set(LINGUAS "All" CACHE STRING "A space-seperated list of translations to compile in to gogglesmm, or \"None\".") if (LINGUAS STREQUAL "All") file(GLOB pofiles po/*.po) foreach(pofile ${pofiles}) get_filename_component(lang ${pofile} NAME_WE) list(APPEND LANGUAGES ${lang}) endforeach() else() if(NOT LINGUAS OR LINGUAS STREQUAL "None") set(LANGUAGES "") else() string(REGEX MATCHALL [a-zA-Z_@]+ LANGUAGES ${LINGUAS}) endif() endif() foreach(lang ${LANGUAGES}) install(FILES po/${lang}.mo DESTINATION share/locale/${lang}/LC_MESSAGES RENAME gogglesmm.mo) endforeach() endif() # Update the icon cache upon installation if needed install(SCRIPT build/update_icons.cmake) # Display Feature Summary feature_summary(WHAT ENABLED_FEATURES DESCRIPTION "Features:\n") gogglesmm-gogglesmm-0b8cb53/CONTRIBUTING000066400000000000000000000017751455751074500177430ustar00rootroot00000000000000Getting Started See the INSTALL file on how to build gogglesmm. You can skip the install part and run gogglesmm directly from the source directory. For development or diagnosing an issue, you want to build gogglesmm with debug symbols. To do so, run cmake with the appropriate build type: > cmake -DCMAKE_BUILD_TYPE=Debug . To run gogglesmm directly from the source directory, you need tell gogglesmm where to find the output plugins. By default it will try to find them in /lib/gogglesmm, but you can set the GOGGLESMM_PLUGIN_PATH environment variable to specify an alternate location: > export GOGGLESMM_PLUGIN_PATH=gap > src/gogglesmm With the debug build enabled, it should print out the filename of the output plugin when gogglesmm starts playing: [output] loading plugin: gap/libgap_pulse.so Contributing Bug Fixes Bugfix branches should be forked off the "stable" branch Contributing New Features New feature branches should be forked off the "develop" branchgogglesmm-gogglesmm-0b8cb53/COPYING000066400000000000000000001045131455751074500171360ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . gogglesmm-gogglesmm-0b8cb53/ChangeLog000066400000000000000000001167621455751074500176660ustar00rootroot000000000000001.2.5: - taglib: add support for taglib 2.0 - ui: Update FOX to 1.7.83 - ui: remove workaround for buggy window behaviour under wayland gnome introduced in 1.2.4 1.2.4: - gap: fix pulse output to work better with pipewire server - ui: fix broken color theme saving with FOX >= 1.7.81 - ui: workaround for buggy window behaviour under wayland gnome - fix build with FOX < 1.7.80 1.2.3: - flac: add support for 32 bit samples introduced in FLAC 1.4 - taglib: remove use of deprecated methods - gap: allow https connections to ports other than 443 - ui: Update FOX to 1.7.82 - ui: Fix button rendering - ui: Fix rectangle rendering on certain platforms - remove support for long gone LyricWikia. - remove python scripts from extra 1.2.2 - gap: added sndio output plugin - gap: added crossfader - ui: Updated FOX to 1.7.74 - ui: Updated German translation thanks to Martin Wagner - ui: New Korean translation by JungHee Lee - ui: make it easier to adjust cover size in the miniplayer for hdpi screens 1.2.1 - Update to latest appstream spec. - Fix play/pause issue #83 1.2.0 - Support for non-16bit alac files. - Support for aacPlus streams. - A copy of FOX is now included to make it easier to distribute gogglesmm - Preserve clipboard (copy/paste) when closing track editor. - Updated spanish translation - Fix buffer overflow in audioscrobbler (issue 77). - Fix prevent consecutive spaces when renaming audio files. 1.1.9 - Fix aac fatal decoder error - Fix llvm build with latest sqlite library - Fix unused openssl 1.1 api calls - Fix various newly gcc7 warnings 1.1.8 - Fix: resize (if needed) icons from external icon themes on start up - Fix: set default sort column for podcasts to date. - Fix: typo in ifdef 1.1.7 - Sort albums by album-artists when displaying covers - Add commandline option to refresh podcast feeds - Add the ability to build with static FOX library - Fix covercache loading with FOX-1.7.57 - Regenerate covercache if supported file format has changed in FOX library. - gap: refactor input plugins using new iocontext - gap: remove unimplemented smb plugin 1.1.6 - https support with OpenSSL or GnuTLS. - http(s) gzip support. - Local Source: only list playback supported formats - New import option to exclude any files that cannot be played back. - Moved exclude import filters to its own tab. - cmake: added more options to enable/disable plugins during compilation - gap: refactor decoder and reader plugins - Fix: refresh path lut if needed. - Fix: reset scroll position when loading new lyrics - Fix: show audio device options when using mousewheel or keys to change driver - Fix: tiptext for album list items in case when information is missing - Fix: incorrect access check in socket. - Fix: volume icon in miniplayer didn't get updated on icon theme change - Fix: init directory in open dialog for Play File or Stream 1.1.5 - Fix lyrics column not being created on first run. - Fix import writing lyrics to the wrong column. 1.1.4 - Lyrics support - Matroska playback (only) support - Refactor Vorbis / Opus / AAC decoders to support matroska - Optimizations to Ogg based decoders should use less memory - Refactor text converter and renamer - Refactor socket io for improved win32 support - FOX 1.7.57 compatibility - fix: minor changes to api for text compose/decompose which broke filename formatter. - fix: Renaming filename preview dialog now correctly converts non-Ascii/UTF-8 back to UTF-8. - fix: Don't substitute & for && when displaying track in title bar 1.1.3 - Fix deadlock in get_decoder_packet and replace pop_if/wait with wait_for - Fix missing config option for tremor. 1.1.2 - Fix missing option No Resample in alsa output plugin 1.1.1 - Fix detection of newer kde desktop sessions. - Replace gogglesmm native dbus interface with mpris v2. - Implement missing functionality in mpris v2. - gap: fix file input to handle file:// uri scheme - rss: check for updated cover art image - http: force mimetype to be lower case. - http: reset dir on IO after reading last header in chunked response. - Remove remaining lirc functionality. - Remove (broken) AppStatus notification implementation. - Remove unused settings. 1.1.0 - flac: use new reader to parse flac files. - gap: use more portable signal and semaphore primitives in engine. - gap: refactor input_plugin. - gap: add proper interface class to OutputThread. - gap: simplify includes. - gap: fix build issue with mp4/m4a support. - remove old 'configure' based buildsystem. - lirc: remove unused/unsupported lirc support - c++11: NULL -> nullptr. - replace glew with epoxy. - fix crash editing radio station. (issue 56) 1.0.18 - ALAC codec support. - add hashbang to installed python scripts - fix vorbis comment parsing - fix opus filetype detection during import. - remove debug statements during release builds. - cmake: fix reverse check for DESTDIR - cmake: build mp4 reader when faad is enabled 1.0.17 - cmake: fix libgcrypt detection and link to internal md5 if no gcrypt is available 1.0.16 - cmake: fix gogglesmm not using BUILD_GAP_SHARED_LIB variable 1.0.15 - fix: remove FXURL::decode when using FXURL::fileFromURL since the latter already does the decode - cmake: drop version requirement to 3.3.1 - cmake: add status output - cmake: allow CMAKE_INSTALL_LIBDIR to be relative or absolute path. - cmake: fix shared library build of libgap. - cmake: disable lto build for now. 1.0.14 - Fix filters not properly escaping single quotes. - Add cmake 3.4 build system. 'configure' is now deprecated and will be removed in a future release. - Remove various unimplemented and/or unsupported plugins. - Various c++11 improvements 1.0.13 - Sync now remove files from the database that match exclude filter. - Removed 'Remove Folder' functionality from Sync Folder. Now available as separate functionality under Music Library. - Support for new taglib 1.11 xiph cover art api. - Refresh filters after import or sync. - Update icon cache on make install 1.0.12 - Fix infinite loop in directory filter during sync. 1.0.11 - Fix incorrect parameter passing to sqlite (braking scanner in certain cases) - Fix sync incorrectly updating/removing files. 1.0.10 - During import symlinks to directories are now followed. - Removed default field input from import options. This is now automatically substituted with Unknown Artist, Unknown Album and the name of the filename in case of a missing title. - New import option for detection of compilation albums for files without albumartist or compilation tags. - New import option to disable grouping albums by audio format. Useful in case taglib fails to read the audioproperties correctly. - Exclude filters are now also used by all Sync operations (previously only used during import) - Add year field option to filename parser. - Add path to filters. - Fix menus not resizing when font was changed. - Fix infinite loop updating podcasts when auto-update was turned off and a manual refresh was actived. 1.0.9 - Fix reading title from flac/ogg/opus files that contain id3 tags and an empty xiph comment. 1.0.8 - wav: a-law / μ-law decoding - pulse: signed 32-bit format support - wav_out: large file and float support - mp4: fix track length for large files. - Fix position tracking for large files. - Fix crash when opengl fails to initialize. - Fix scrobbler flags not fitting in datatype. - Fix incorrect bitshifting in flac reader. - Use fxstrlcpy instead of strncpy in font handling. - Use cpp11 member initializers. - Podcasts: update url in database for permanent redirects - Fix xspf playlists: don't double encode urls and add workaround to read back faulty urls. 1.0.7 - Add support for ratings and tags to filters. - Change default color scheme to Clearlooks. - Read duration from downloaded podcasts if feed didn't contain this information - Close connection for http 1.0 connections if keep-alive is not specified. - Fix repeating same track when stop after track has been used. - Disable shuffle/repeat menu items when play queue is active. - Do not auto-select current playing artist/album when using search (issue #20). 1.0.6 - Implement vbri seeking - Fix loading replaygain settings on startup - Pathnames may not be valid utf-8 so prevent dbus library from crashing by only passing valid utf8 encoded pathnames - mp4: fix potential buffer overflow when reading decoder specific configuration - mp4/aac: implement gapless playback (mostly tested with FAAC encoded files) - id3v2: fix parsing comment string 1.0.5 - Fix gapless playback for mp3 audio. (Applies decoder delay and fix reading encoder settings) - Support iTunes specific gapless playback tags for mp3 audio (iTuneSMPB). - Fix toolbar to be on top of statusbar when docked on the bottom. - Fix rating display after editing track. - Show available parameters for Window Title Format. 1.0.4 - Improvements to the taglib interface - Fix build issue when forcing faad - Fix compilation with sqlite < 3.8.3 - Fix missing space in sql statement - Support audio/aac mimetype used on certain streams 1.0.3 - opus: implement multichannel playback support and correctly apply output gain. 1.0.2 - Fix: don't crash when loading invalid or empty covers from taglib 1.0.1 - Fix: mpris v2 dbus properties interface 1.0.0 - Added support for filters. Similar to automatic/smart playlists found in other music players - During import albums now get automatically grouped by samplerate/channels/samplesize. - Added file type and format information to tracklist, combining all audio properties. Lossless files should now be better distinguished from lossy files. Also removes the now redundant bit rate column. - Removed "merge albums" option from album list. The artist name is now automatically added when multiple albums with same name are displayed. - Increase italic font size used in the album list a bit. - Increase fallback cover image to 128x128 pixels. - Added audio format indicator to album list. - Switch to c++11 - Fix: scale down icons if needed if only larger ones are available. - Fix: force redraw of cover list when switching from list view - Fix: force update covers if size has been changed - Fix: prevent crash when cover image fails to load 0.14.2 - Fix: support older ogg vorbis files whose file headers may exceed the gap buffer size. - Fix: mp4 playback. - Fix: allow sort keywords to be unset - Fix: playback position for mpris and implemented Seeked signal for mpris v2. - alsa: Remove mixer setting and store missing flags in settings - aiff playback support. 0.14.1 - FOX-1.7.50 compatibility fixes. Also previous versions are no longer supported. - Fix building without dbus - Fix crash when updating podcasts with empty guids. 0.14.0 - Added playqueue mode. - Support multichannel playback. - Configurable cover display size in album list. - Improvements to the podcast manager: o Support for rss feeds not encoded in UTF-8 or UTF-16. o Configurable update interval for podcasts. o Automatically download podcasts when feeds get updated. o Download status icons in podcastmanager show which podcasts are local, queued or failed. o Added cover support to podcastmanager. o Add DND support to podcastmanager. o Add played status to podcastmanager and add option to mark podcasts as new or played. - Improved memory consumption for cover cache. - Added appdata file to distribution - Removed libxml2 support. Only expat is supported now. - Added version info to output plugins to allow checking version during runtime. - Compiler warning cleanups. - Fix: if pulse stream becomes unready write() should return false - Fix: use correct line separator for x-special/gnome-copied-files - Fix: don't parse empty timestamp strings in rss feeds 0.13.3 - Fix various bsd porting issues. - Fix crash on playlist export. 0.13.2 - Fix overflow/truncation of timer calculation on 32 bit systems. - Fix potential null pointer dereference. - Fix incorrect syncs in mp3. - FOX-1.7.48 compatibility fixes. 0.13.1 - Add sample accurate seeking to most formats (flac,vorbis,opus,mp4). - Add menu option to schedule stop after track finishes. - Add import option to override default text encoding for id3v1 tags. - Add meta data parsing to mp4 reader - Add indexes in the database for all foreign keys. - Use meta from audioplayer if available rather than using taglib. - Fix UI issue to correctly indicate when the last track has finished playing. - Fix cross search capability that was present in 0.12.x but didn't make it to 0.13.0 - Fix importing podcast whose mimetype are set to application/xml - Fix drain behaviour in alsa output. - Fix incorrect date parsing in the RSS parser. - Fix tag saving to correctly handle multiple tag types. - Fix UI track display by escaping special characters. - Fix homepage and report issue buttons in about dialog. - Add bitrate check to mp3 reader to avoid incorrect syncs. - Disable minimize to tray on systems that don't support a tray icon (gnome 3) - General cleanups to remove some unused code. 0.13.0 - New playback engine - Podcast Manager - Long running operations (import/sync) are now performed in the background. - Album list view with album covers in a grid. - File browser view. - MPRIS v2 Interface. - Fullscreen Presentation mode. - New minimalist UI. - Music Library Improvements: o Support composer and conductor tags. o Support tagging tracks instead of genre. o Ratings Support. - Support the XDG spec (http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html). o Config files have moved to $XDG_CONFIG_HOME/gogglesmm. o The database has been moved to $XDG_DATA_HOME/gogglesmm. o Temporary files are saved to $XDG_CACHE_HOME/gogglesmm. 0.12.7 - Support WAV files. - Minor optimizatons - Add disc number support in filename parser - Support NetworkManager 0.9 notifications. - Fixes to audioscrobbler. 0.12.6 - Fix xine 1.2 detection in configure. 0.12.5 - Fix memory leak. - Fix libre.fm support. - New authentication method for last.fm. - Improved compatibility/detection for m3u/pls urls when playing Internet Radio. - Removed libcurl dependency. 0.12.4 - Added Portuguese Translation by Sérgio Marques - Improved notification daemon compatibility - Support for latest FOX 1.7.29. - Added genre and location to mpris information. 0.12.3 - Do not pass unsupported GL_LINEAR_MIPMAP_LINEAR to GL_TEXTURE_MAG_FILTER. - Enable support for non-power-of-two textures now that Mesa 7.11-rc4 fixes the issue. - Fix incorrect usage of FXAutoPtr. - Fix parallel build. 0.12.2 - Gnome 3 compatibility updates - Fix infinite last.fm warnings when the system time is out of sync with the last.fm server time. - Merge title that were split into multiple entries in vorbiscomments. 0.12.1 - fix crash when right-clicking tray icon (issue 230) - timer fix in audioscrobbler for fox-1.7 0.12.0 - Updated Look and Feel. - Updated Czech Translation. - Allow relative paths when exporting playlists. - Support for taglib 1.7 - Remove support for old miniplayer - Fix audioscrobbler on FOX 1.7 0.11.6 - Updated Spanish Translation - Improved opengl compatibility in cover display. 0.11.5 - Fix ignored icon theme (issue 222) - Initial svg icon support through use of rsvg-convert (part of librsvg) utility. 0.11.4 - Link explicitly to X11, GL and GLU (issue 212). - Improved icon theme specification support. Now also load from ~/.icons, $XDG_DATA_DIRS/icons and /usr/share/pixmaps. - Properly initialize libgcrypt to avoid warnings. - Added button to get out of miniplayer mode and make the miniplayer behave the same as the regular browser window. (issue 196). - New additional shortcut to toggle between miniplayer mode and browser mode (Ctrl-M). - Miniplayer is resizeable and remember its size and position. It will no longer automatically resize itself. - Fix crash when importing with specific icon themes selected. (issue 218) - Add big-endian support to flac album art loading. (issue 218) 0.11.3 - Icon name in desktop file shouldn't have file extension - Fix disabled mp4 support. - Translation Updates 0.11.2 - Support for .oga files. - Allow scrobbling to last.fm or libre.fm. - Fix some threading issues in the audio scrobbler. 0.11.1 - Updated Hungarian Translation - Fixed MANDIR and LOCALEDIR not being defined by configure, resulting in locale data and manpages to be installed in root. 0.11.0 - Drop support for taglib 0.5.x, taglib-extras and internal asf/mp4 support. - Remove internal icon theme and depend only on external ones. - Depend optionally on gcrypt for md5 calculation. - Partial MPRIS v1 interface. 0.10.27 - configure cleanups - Use proper uri (file:// instead of file:) (issue 203). - Added man page. 0.10.26 - Backport new font dialog. - Use posix sh instead of bash for configure script. 0.10.25 - Fix build issue with older taglib releases (1.5.x). - Updated Czech translation. 0.10.24 - Support mp4 and ogg vorbis embedded album art. - New opengl based cover viewer which allows for smooth scaling of the album cover. If opengl is not available or slow, the old x11 cover viewer can be used instead, which now has an option to choose the displayed cover size. - Import Playlists (xspf, m3u and pls) (issue 123) - Export playlist title for xspf playlists. - Changed Open MRL -> Play File or Stream and improved the dialog to make it easier choosing a local file from disk. - Add conditional support to filename format. Window title may now also be customized. - Show import options when dragging or copy/pasting files. - Added Tooltip to trayicon showing the current playing track information. - Open directory of track with right click (issue 146) - Fix active track in playlist when reordering (issue 194). 0.10.23 - Unify package, application and executable name. - Don't grab keys we're not going to use (issue 189). 0.10.22 - Added Czech translation by David Vachulka. 0.10.21 - Fix build script issue. 0.10.20 - Tray icon background color may now be customized to improve look of the tray icon. - Don't try to install mo files we don't have when LINGUAS environment variable is set (issue 165) - Replace libfetch with libcurl. - Load album art from tag in the album browser as well. (issue 176) - Fix main library listing genres from the Radio Streams. 0.10.19 - Support media keys through the Gnome Settings Daemon. - Don't show import dialog when radio streams are in the database. (issue 154) - Use ewmh icon hint to specify application icon which should result in a nicer looking icon in the taskbar. - Fix various dbus event handling to prevent crashes (issue 159) 0.10.18 - Make some functions static that don't need global scope. - Be more flexible about the http return code (issue 147). - Fix crash when pressing delete on "All Arists/Genres/Albums" 0.10.17 - Russian Translation. 0.10.16 - Hungarian Translation. - Compilation fix for older taglib in combination with mp4. 0.10.15 - Add additional signal handler(s) to correctly save state on exit. - Fix focus getting stuck in Edit Track dialog. - Year field in edit track dialog should be empty if multiple tracks with different years are selected. - Support bmp and gif embedded album art. - Fix memory leak in embedded album art loader. 0.10.14 - Support for .m4b files. - Minor fixes. 0.10.13 - Take disc number into account when sorting. 0.10.12 - Updated German Translation 0.10.11 - Prevent crash when settting input focus on widgets when a FOX version with xim support is being used. - Fix timeout type mixup with FOX-1.6 vs FOX-1.7 0.10.10 - Fix crash when removing tracks from the library via a playlist. 0.10.9 - Fix segfault in certain cases when no track information is yet available. - Removed support for libdownload. - Fixed segfault when using libfetch. - Improved error checking when downloading m3u and pls files. 0.10.8 - New command line option (--tray) to start gmm minimized in tray. - Album Artist tag support for MP4 files. - Fix shortcut to toggle playback (issue 121) - Use buildin mp4/asf support from taglib 1.6 if available. - Rely on default genre list from taglib. - Build fixes. 0.10.7 - Fix compilation --without-new-remote (issue 113) - Fix duplicate hotkeys in preferences dialog (issue 112) 0.10.6 - Fix time/duration display to account for hours. - Fix critical bug when sending album art to notification daemon. - Support for fox-1.7.20. - Optionally use taglib-extras for MP4 and ASF support. - Allow other scrobbler compatible servers to be used. - Added French translation. 0.10.5 - Override all compiler flags if CFLAGS has been set. 0.10.4 - Minor translation fixes - Fix duplicate hotkey in new radio station dialog. - Fix exporting playlist. 0.10.3 - Translation fixes and updates. - Warn user when a incompatible (future) version of the database is encountered. - Fix compilation with taglib-1.4. 0.10.2 - Added Spanish translation. - Fix translations not working with FOX 1.7 (issue 100) 0.10.1 - Fix tray icon issues. - Added German translation. - Properly encode special characters in audio scrobbler now playing submitter. - Fix sorting of album list by year in playlists. - Do not grab "AnyKey" by checking return value of XKeysymToKeycode. 0.10.0 - Database Improvements: o Improved performance when modifying the database (importing & removing tracks) o Added fields for per track artist (issue 72) - Import Improvements: o Added "Sync Folder" capability, which can also update or remove tracks in the database if needed. o Added import exclusion filter for file and folders. (issue 84) o Redesigned import dialog. It now contains the import options that were previously in the preferences dialog. o Added a filename template input to grab track information from a filename. This replaces the less flexible "title from filename","album from directory" and "artist from directory". o Added option to choose where to read the track information from: filename, tag or both. o Replaced "Default Title", "Default Album", "Default Artist" and "Default Genre" with a single "Default Field" since most of time you would likely use the same text anyway. o Removed the Import File(s) option. I don't think it's needed that much, and it reduces the number of choices a user has to make. Importing single files can still be accomplished through drag-and-drop. o Remove wizard. Just show import dialog first time. - Other Improvements: o Added Localization Capability. (issue 3) o Added disc column to track view. o Allow multiple genre selection in browser. o Double click in artist and album list will start playing. o Added button to enable or disable last.fm scrobbler. o Equalizer with configurable presets. o Take into account the disc number when sorting albums. o Send cover art through dbus to notify daemon directly instead of saving it to disk. o allow to write tags when editing even if tracks have not been modified. o more flexible input to select which fields need to be searched (issue 51). o allow quoted strings in search field. o Support for Multimedia Keys. o Optionally display playing track in title bar. o The album list may now also be sorted by album year. - Audio Improvements: o The audio driver can now be changed. (issue 87) o Replay Gain (Only Ogg Vorbis, native FLAC and mp3 with APE tags). - Filename Renamer o The excluded character set may now be changed for the filename renamer. o Added year and disc parameters. - Tray Icon Improvements: o tray icon is now integrated within gmm. gmm-tray has been removed. o tray icon show/hide miniplayer as well. o volume may be controlled using the mousewheel. o middle mouse click will toggle between playing and pausing. - Fixes: o crash when sorting in Internet Radio view. o remember "Update Filename" setting in edit dialogs. o actually try alternative urls in PLS or m3u before failing completely. o correctly display playing track in playlists. o do not run event loop in dbus message callback. 0.9.18 - Fix: Add support for fox-1.7.18. - Fix: more url handling fixes. - Misc: code cleanups. 0.9.17 - Fix: fix crash showing dialogbox when audio device open fails on startup. 0.9.16 - Fix: Track-less songs should not be 0 (#62) - Fix: disable default key press processing in tracklist. - Fix: Update GUI when done playing. - Fix: incorrect tracklist state when using search filter. - Fix: workaround for older notification daemons that don't show '&'. - Fix: improved url handling. - New: add additional shortcut '/' for search filter. - New: When pressing the search hotkeys, existing search text will be selected. - New: New shortcuts for Repeat Off, Track and All. Added shortcut for Shuffle as well. - New: Made repeat radio buttons instead of checkbuttons. - New: Play file from the commandline. 0.9.15 - Fix: Prevent crash by checking if session and system bus are available. - Fix: don't show tray icon option if gmm-tray is not in $PATH. - Fix: compile issue when building with old remote. 0.9.14 - New: Threaded scrobbler submitter which should prevent locking the GUI during DNS lookups. - New: Tray Icon. (contributed by Olivier Duclos). - New: More complete dbus interface (required by the tray icon) - New: NetworkManager support to wakeup scrobbler if network connection becomes available. - New: Font and colors may now be updated from within GMM and require no application restart. - Misc: The filename template settings has been moved from the preferences panel to the tag editing dialogs. - Misc: Support for mugshot was removed. - Misc: Nicer application and tray icon by Olivier Duclos. - Fix: Incorrect track number was used when renaming files - Misc: build/installation improvements: xdg-icon-resource/xdg-desktop-menu are not used anymore. * All icons are installed in (prefix)/share/icons/hicolor/* * gmm.desktop is installed in (prefix)/share/applications * `make install` will run gtk-update-icon-cache (prefix)/share/icons/hicolor Support DESTDIR variable when running make instal: make DESTDIR=/some/package install This will install gmm in /some/package/(prefix)/bin/gmm 0.9.13 - Fix: Crash in miniplayer. 0.9.12 - Fix: Cover wasn't shown when switching to mini player. - Fix: Update highlighted track if tracks are dragged around. 0.9.11 - New: Support embedded cover art in flac files (jpg and png only). - New: Support last-fm 'now playing' notification. - New: Support album art in notification to notify-daemon. - New: DBus enabled version now also support the ability to control a running gmm from the command line. - New: Use "ALBUMARTIST" tag in Ogg / FLAC files and TPE2 for id3v2 tags for artist. 0.9.10 - New: Experimental support for libfetch on FreeBSD (untested). - New: Embedded cover art (id3v2 tags) now also supported in remote. - New: Make covers in remote slightly larger. - Fix: Compilation issue on FreeBSD. - Fix: Scrobbler only submitted one track at a time. - Fix: Scrobbler connection timeout was too large. 0.9.9 - Fix: Track play count and display were not always properly updated (in combination with gapless playback), This affected last-fm submission as well... - Fix: Crash in Edit Track dialog if mp4 file doesn't exist. - Fix: Current item in tracklist need to be updated when stop is pressed to be able to continue playing from the last played track. - Fix: Restore maximized/fullscreen state on start up. - Fix: Using the mouse wheel in the remote now also changes the volume. - Fix: Remote now also has a window icon. - New: Ctrl-Q now also works in the remote. - New: Experimental support for embedded cover art support in mp3 / flac with ID3v2 tags. 0.9.8 - Fix: files with '#' couldn't be opened anymore due to change in xine-1.1.9. - Fix: Improved Album Art search. Now looks for jpg,gif,png and bmp files in the directory of the music file. Gives higher priority to files found with the following names: cover,album, albumart,.folder,folder. - New: Added some webbrowser links to last-fm sign-up and Goggles Music Manager user group. 0.9.7 - Fix: Really fix Compilation issue on 32 bit systems. 0.9.6 - Fix: Compilation issue on 32 bit systems. 0.9.5 - Fix: fix url encoding to handle more unsafe characters 0.9.4 - New: Last-FM audio scrobbler support. - Fix: include instead of 0.9.3 - Fix: Fix configure columns dialog for FOX-1.7. Draw function wasn't properly overloaded. - Fix: Support new FXFontDesc api in FOX-1.7.17 0.9.2 - New: Configure Columns dialog can now also show/hide columns. (backport) - New: Turn on audio playback engine on startup is now a option. - New: Added Volume Control to Mini Player. - New: Show year column in track list. - New: Disc Number Support. - New: Improved Edit Track Dialog. - New: Ctrl-W now also closes the window (either quits the application, or toggles the remote). - Fix: Reflect column order in right click menu. - Fix: Use new dbus-1.2 api if available. Also show DBus version if available in about panel. - Fix: Remove Compiler Warnings (gcc 4.3). - Fix: Improved check if files are local or not which affects updating the GUI. 0.9.1 - Fix: Compilation issue with older xine. - Fix: Compilation issue with debug build. - Fix: Check for proper SQLite version during runtime. - Fix: Prevent the application from disappearing when using the old remote. - Fix: Added extra hint for new remote to show window title for certain window managers. - Fix: Some fixes to configure. 0.9.0 - New: Search Filter. - New: Change order of columns in track list. - New: Alternative Mini Player (old one still available through configure option). - New: Context menu for track list header. - New: Selection state in browser for each source. - New: Try raising existing music manager when starting without commandline arguments. - New: Support for Internet Radio Streams. - New: Support for ASF files. - New: Support for MP4 through TagLib. Removed old libmp4v2 support. - New: now uses the c++ taglib library instead of the c-bindings. - New: use bold italic font for playing track in tracklist. - New: Shuffle mode: play tracks in random order. - New: Repeat A-B mode: repeat section of a track. - New: Editing improvements. - New: When clearing the database, playlist entries may be optionally kept. - New: When removing tracks from database may be optionally deleted from disk as well. - New: Keyboard shortcuts for editing and deleting tracks. - New: Show audio/file properties in track edit dialog. - Fix: better path caching when inserting tracks (should increase speed). - Fix: Do not allocate icons before they're actually used (about and remote dialogs). - Fix: fix memory leak in browse sort. - Fix: Support modified fox-config on Gentoo. - Fix: Use [[ in build scripts instead of [. - Fix: Paste from gtk applications failed if it contained line feeds. - Fix: Only enable next/previous if more than 1 track is available. - Misc: Changed Full Screen shortcut to F12. Ctrl-F is now used for the search filter. - Misc: Build system is now more like autoconf/automake. - Misc: Disable default title/album/artist if options above are selected. 0.8.5 (svn) - Fix: Paste from gtk applications failed if it contained line feeds. 0.8.4 - Fix: Support modified fox-config on Gentoo which prevented GMM from building. - Fix: Close all fd on fork in order to keep playing while opening the webbrowser. 0.8.3 - Fix: Buffer overflow in track list sorting. 0.8.2 - New: genre, artist and album may now also be horizontally resized. - Fix: Typo in edit artist dialog. - Fix: define MPEG4IP_VERSION in case it's not defined. - Fix: chase api changes in FOX 1.7.12. - Fix: Removed some warnings. - Fix: Removed some dirty coding. 0.8.1 - New: Each source now remembers scroll position of the tracklist. - New: Added option to close audio device when paused. - Fix: Bug in filename renaming feature was fixed. - Fix: Don't show filename renaming confirmation dialog if not required. - Fix: Improved shuffle. Also added keyboard shortcut Ctrl-R. - Fix: Compilation bug with FOX-1.7.11. - Fix: Disable volume button when xine is not opened. - Fix: Workaround for older SQLite versions regarding index creation. 0.8.0 - New: Support creating custom playlists. - New: Don't show duplicate albums names when multiple artists are selected. - New: Added "All" entry to artist and album lists. - New: Export database and playlists to XSPF, PLS, Extended M3U, M3U and CSV. - New: Clipboard and drag-and-drop support for moving tracks to playlists and importing and exporting files. - New: Configurable toolbar docked on top or bottom, showing big or small icons with optional text. - New: Customizable Icon Theme. Either use buildin icons, or load from disk. - New: Animated icon in scan progress dialog. - New: Support year tag. - New: Support volume normalization plugin. - New: Database now also stores for each track: year, rating, import date, play date and play count. - New: Option to close audio device when playback is stopped. - New: Upgraded to more advanced build system. - New: Include Desktop Application Entry and Icon in distribution - New: New About Dialog. - New: Report An Issue link in Help Menu. - New: Changed License to GPL-3. - New: Warning dialog when FOX without PNG support is used. - New: Fullscreen mode (requires FOX-1.7.11). - Fix: Ctrl-A selection now works in all lists. - Fix: Do not import MP4 files that contain video. - Fix: Track titles are also now sorted using the leading keyword filter. - Fix: Editing Dialogs retain proper sorting order of genres,artists and albums. - Fix: Allow up to 4 digits in track number input in edit dialogs. - Fix: issue preventing filenames with '#' characters from playing. - Fix: compilation fix for older xine libraries. - Fix: status line now shows correct song in repeat mode. - Fix: sleeptimer now works properly in FOX 1.6. - Fix: Write xine configuration file on exit. - Fix: Don't recurse into directories that are symbolic links. 0.7.6 (svn) - Fix: resolved issue preventing filenames with '#' characters from playing. - Fix: sleep timer with FOX 1.6 didn't work. 0.7.5 - Fix: Possible crash in empty track list due uninitialized variables. 0.7.4 - New: Added Sleep Timer. Stops playback after specified amount of time. - New: Implement command line options to control an already running music manager. - Fix: Reset Display after end playlist. - Fix: Remember import files directory as well. - Fix: Even more error handling in xine. 0.7.3 - Better playback error handling. - Only use path title (filename without extension) for track title in case of files without tags. - Track list now has multiple selection capability for easier tag editing. - Assign track numbers automatically based on the selection order in the track list. - Added Sorting Arrows on Genre,Artist and Album lists. - Added Genre Column in tracklist. - Better alignment for track numbers and times. - Playing track has now different background color. - Improved sorting. 0.7.2 - File naming options were not taking into account. 0.7.1 - Now supports renaming audio files during tag editing. - Add Statistics Information Dialog. - Speed up multiple selection in artist list. - Cleanup dead and unused code. - Minor Fixes. 0.7.0 - gapless playback support. - mp4 support is now optional. - Tag Editing Support. - Repeat Track Support. - Speed improvements in SQL database. - Minimize jumping of slider control when seeking. - Background color for every other row. - Import of single files now also possible. - Columns in tracklist are also now configurable in browse mode. - Fix Crash when clearing database and reimporting in List Mode. - Set default value for saving tag changes to file to false. - Manage own taglib string memory because taglib is leaking. - Also search for .m4p files. 0.6.2 - Ability to show directory contents in filemanager of selected song. - Added "repeat all" option which determines whether to restart playing from the beginning of the play list or not - FOX 1.7.x support. - Fixed Relative Path display in scan/search dialog. - Fixed Typos in welcome dialog. - Statusbar by default off now. - MP4 Tag Support [Read Only] 0.6.1 - New Progress Dialog during file scanning, which also includes the ability to cancel the scanning at any time. - Added support for flac and musepack. - Now depend on taglib for reading and writing tags. - Ability to hide status bar. - Support playing file from the command line arguments - Only allow one gmm to be started and send play request to already running gmm. 0.6.0 - Added some more icons. - Added userfriendly dialog at startup when database is empty. - Use more advanced sorting routine that can interpret numbers in strings. - Allow genre,artist and album list to be sorted in reverse. - Fixed bug with setting current category on startup. - Removed unused font which caused a crash. - Tracklist was not properly sorted at startup - FOX 1.5 -> FOX 1.6 0.5.3 - Ability to remove certain artist from the database. - FOX 1.4 -> FOX 1.5 0.5.2 - Add Multiple Selection in Artist and Album List. - Keep better track of last played track. - Columns in songlist can be configured by the user. 0.5.1 - More error checking in database handling. - Removed fastforward/fastbackward. - Fixed bug that prevented sorting on time in normal list mode when clicking header. - Columns in song list now remember their size. - Songlist remembers its sorting column and order. - Smart Sorting for lists. Skips common words like "the","a","an". This is a configurable option... - Change remote mouse click functionality: one click skips to next song, double click opens manager. - Remote Volume control changes volume immediately on first wheel mouse move. - Check for old database on startup and remove it if users wants it. We aks only once. - Remembers which displaymode it is in. - Added random "sort" mode. 0.5.0 - New Database backend. We're now using SQLite. Database file has changed from goggles.database to goggles.db. - While playing, if the volume is turned down to zero, playback will automatically pause. - Add Category/Genre List to GUI. - Fixed bug that prevented using Goggles Music Manager if FOX version was updated. - Xine is really slow at reading in tags. I put the old ogg vorbis tag reading back. MP3 is still done by Xine. - Added remote control window. - Added preferences panel. 0.2.6 - FOX 1.4 support. 0.2.5 - Added MP3 file support. - Removed editing capability of tag names for now. Hopefully we can add this back soon. - We now use xine to retrieve all tags from ogg and mp3 files. It might be slower than before. We might change that in the future again. 0.2.4 - You can now either import files into a existing database or create a new database. - While importing files, we now skip files that are already in the database. - Now has four GUI modes: Full, Compact, Slim and List. 0.2.3 - Initial Release. gogglesmm-gogglesmm-0b8cb53/INSTALL000066400000000000000000000107101455751074500171270ustar00rootroot00000000000000Installation Instructions ------------------------- 1. Install all required dependencies: * sqlite >= 3.6.19 * taglib >= 1.9.0 * expat * cmake 3.3.1 2. Install optional dependencies: * dbus 1.0.x * flac * mad * vorbis (or tremor) * ogg * opus * faad2 * pulse * a52 * zlib * openssl or gnutls 3. Run cmake: > cmake . The following options are available: CMAKE_INSTALL_PREFIX => Installation Directory (default: /usr) CMAKE_BUILD_TYPE => Set the build type. Available types: Release, Debug, RelWithDebInfo and MinSizeRel (default) CMAKE_INSTALL_LIBDIR => Name of directory where libraries are meant to be installed (default: lib) WITH_OSS => Enables building the OSS Output plugin (default: OFF on Linux, ON on UNIX) WITH_ALSA => Enables building the ALSA Ouput plugin (default: ON on Linux, OFF on UNIX) WITH_PULSE => Enables building the PulseAudio Output Plugin WITH_WAVOUT => Enables building the Wav File Output Plugin WITH_MATROSKA => Enables building the Matroska Input Plugin WITH_MP4 => Enables building the MP4 Input Plugin WITH_OGG => Enables building with Ogg Library (required for Vorbis and Opus) WITH_VORBIS => Enables building with Vorbis Library WITH_TREMOR => Enables building with Tremor Library (Vorbis Alternative) (default: OFF) WITH_FLAC => Enables building with FLAC library WITH_MAD => Enables building with MAD library WITH_ALAC => Enables building with (buildin) ALAC library WITH_FAAD => Enables building with FAAD2 library WITH_OPUS => Enables building with Opus Library WITH_A52 => Enables building with A52 Library (default: OFF) WITH_OPENSSL => Enables building with OpenSSL WITH_GNUTLS => Enables building with GnuTLS if OpenSSL is not found WITH_GCRYPT => Enables building with libgcrypt if neither OpenSSL or GnuTLS is included. WITH_ZLIB => Enables building with zlib WITH_OPENGL => Enables OpenGL based features WITH_DBUS => Enables DBUS based features WITH_NLS => Enables Native Language Support WITH_SESSION => Enabled X Session Support Options are enabled by default unless otherwise noted. These can be passed on the command line using: > cmake -Doption=value . 4. Compile > make 5. Install > sudo make install 6. Run the software > gogglesmm Building Goggles Music Manager on Ubuntu 14.04 LTS -------------------------------------------------- 1. Install build tools and header files for FOX > sudo apt-get install build-essential > sudo apt-get install libxrandr-dev libxfixes-dev libxft-dev libxrender-dev libxcursor-dev libxi-dev libglu-dev libice-dev libsm-dev > sudo apt-get install libtiff-dev > sudo apt-get install libjpeg-dev > sudo apt-get install libpng-dev > sudo apt-get install libbz2-dev > sudo apt-get install libwebp-dev > sudo apt-get install libopenjpeg-dev 2. Install build dependencies for gogglesmm > sudo apt-get install libasound2-dev > sudo apt-get install libpulse-dev > sudo apt-get install libogg-dev > sudo apt-get install libvorbis-dev > sudo apt-get install libopus-dev > sudo apt-get install libflac-dev > sudo apt-get install libmad0-dev > sudo apt-get install libfaad-dev > sudo apt-get install libsqlite3-dev > sudo apt-get install libtag1-dev > sudo apt-get install libglew-dev > sudo apt-get install libgcrypt11-dev 4. Download, Build and Install gogglesmm (adjust version if necessary) > wget https://github.com/gogglesmm/gogglesmm/archive/1.0.12.tar.gz > tar xvf gogglesmm-1.0.12.tar.gz > cd gogglesmm-1.0.12 for 32 bit: > ./configure --with-faad --without-oss --libdir=/usr/lib/i386-linux-gnu for 64 bit: > ./configure --with-faad --without-oss --libdir=/usr/lib/x86_64-linux-gnu > make > sudo make install 5. Run > gogglesmm gogglesmm-gogglesmm-0b8cb53/README000066400000000000000000000023521455751074500167610ustar00rootroot00000000000000Support and Feedback -------------------- For support or feedback, feel free to email at s.jansen@gmail.com or file an issue at http://gogglesmm.github.io Installation ------------ Read the INSTALL file on how to build and install Goggles Music Manager on your machine. Contributing ------------ See the CONTRIBUTING file on how to start contributing to the project. Keyboard Shortcuts ------------------ Ctrl-N Reset default sorting order in current view. Ctrl-R Shuffle track list. Ctrl-B Toggles browse mode on or off. Ctrl-T Toggles Tag list in browse mode. Ctrl-Q Quit Goggles Music Manager. Ctrl-O Import files from given directory. Ctrl-J Jump to playing song in track list. Ctrl-F Find / Find Ctrl-S Show source browser Ctrl-P Start playback. Ctrl-\ Stop playback. Ctrl-[ Play previous track. Ctrl-] Play next track. Ctrl-, Repeat Off Ctrl-. Repeat Track Ctrl-/ Repeat All Alt-R Shuffle Play Ctrl-A Select All in lists. Ctrl-W Close Main Window F11 Ctrl-M Show Mini Player. F12 Show Full Screen. F2 Edit selected track, album, artist or genre. Del Delete selected track, album, artist or genre. gogglesmm-gogglesmm-0b8cb53/build/000077500000000000000000000000001455751074500171765ustar00rootroot00000000000000gogglesmm-gogglesmm-0b8cb53/build/makepot000066400000000000000000000024461455751074500205670ustar00rootroot00000000000000#------------------------------------------------------------------------------- # Make template #------------------------------------------------------------------------------- FOXDIR=cfox INPUT="src/*.cpp src/*.h" xgettext -C --from-code=UTF-8 --msgid-bugs-address=s.jansen@gmail.com --package-name=gogglesmm --package-version=1.0.0 --copyright-holder="Sander Jansen" --keyword=tr:1 --keyword=fxtr:1 --keyword=notr:1 --keyword=fxtrformat:1 --flag=fxtrformat:1:c-format -o po/gogglesmm.pot $INPUT # FOX files INPUT="$FOXDIR/lib/FXMessageBox.cpp \ $FOXDIR/lib/FXColorSelector.cpp \ $FOXDIR/lib/FXDirSelector.cpp \ $FOXDIR/lib/FXFileList.cpp \ $FOXDIR/lib/FXFileSelector.cpp \ $FOXDIR/lib/FXReplaceDialog.cpp \ $FOXDIR/lib/FXSearchDialog.cpp \ $FOXDIR/lib/FXStatusLine.cpp" xgettext -C -j --from-code=UTF-8 --msgid-bugs-address=s.jansen@gmail.com --package-name=gogglesmm --package-version=1.0.0 --copyright-holder="Sander Jansen" --keyword=tr:1 -o po/gogglesmm.pot $INPUT # Additional non tr ones #INPUT="$FOXDIR/src/FXColorNames.cpp" #xgettext -C -j -a --from-code=UTF-8 --msgid-bugs-address=s.jansen@gmail.com --package-name=gogglesmm --package-version=1.0.0 --copyright-holder="Sander Jansen" -o po/gogglesmm.pot $INPUT for i in po/*.po do echo "Updating $i ..." msgmerge -U $i po/gogglesmm.pot done gogglesmm-gogglesmm-0b8cb53/build/update_icons.cmake000066400000000000000000000006521455751074500226600ustar00rootroot00000000000000if(NOT DEFINED ENV{DESTDIR}) find_program(XDG_ICON_RESOURCE xdg-icon-resource) if (XDG_ICON_RESOURCE) message(STATUS "Updating icon cache") execute_process(COMMAND ${XDG_ICON_RESOURCE} forceupdate --theme hicolor) else() message(WARNING "Cannot update icon cache: xdg-icon-resource not found") endif() else() message(STATUS "make install run with DESTDIR=$ENV{DESTDIR}, skip updating icon cache") endif()gogglesmm-gogglesmm-0b8cb53/cfox/000077500000000000000000000000001455751074500170365ustar00rootroot00000000000000gogglesmm-gogglesmm-0b8cb53/cfox/ADDITIONS000066400000000000000000000056621455751074500203100ustar00rootroot00000000000000 API Additions to Widgets ======================== When designing Widgets, the idea is to provide a full set of API's to allow developers to manipulate it. Sometimes, new API's may need to be added if the initial implementation of some Widget didn't implement a complete set. Everybody always wants their favorite function implemented in the library, because it would make *their* job easier. Thus, the temptation exists to keep adding ``useful'' little functions, just to satisfy everybody. There are several reasons why this is a bad idea: - Lots of small ad-hoc functions will make a Widget much harder for everybody to learn. - Since a Widget implements a certain abstraction, adding lots of functions will make it harder to maintain the simplicity of the abstraction. - Lots of functions will also make it more difficult to keep the software implementation consistent. - It will make it harder to reach a point of ``closure'' i.e. one keeps adding things, instead of attaining completeness. To curb wild-growth in API's, we prefer to add API's judiciously. In order for a function to be added to the library, one should demonstrate: - That the utility of this new function appeals to a large audience. - The function fills a real gap in functionality. - The function adds functionality that existing API's are unable to provide. - The new function does not break the abstraction that the Widget provides. - Appropriate rationale for its inclusion can be given. [This has to be a better argument than: ``Because I need it!'']. Goals for Widget API's should be: 1) Orthogonality. This augments transferability of knowledge from one situation to the next. 2) Predictability. Naming should strongly reflect function. Functions should have no side-effects not reflected in the name; preferably, one function should do one thing only. 3) Symmetry. This means for example every ``set'' function should have a corresponding ``get,'' every ``open'' should have a ``close'' and so on. 4) Completeness. All parameters can be accessed, and all features of the Widget can be used, without any need for backdoors etc. 5) Minimality. A set of API's is minimal if one can not take away anything without making the API incomplete. Minimality makes it much easier to maintain consistent state in the Widget. 6) Philosophical fit. The FOX library has been developed with certain underlying paradigms, both in concept as well as in implementation; API's should adhere to these, as deviation from them will make things less easy to understand, or less easy to extend. 7) Wide Appeal. When convenience API's are added, it must be true that these functions have broad appeal, i.e. expected to be used by a large fraction of the library's users. gogglesmm-gogglesmm-0b8cb53/cfox/AUTHORS000066400000000000000000000040741455751074500201130ustar00rootroot00000000000000 List of contributors, in alphabetical order: ============================================ Johnathan Bush: Progress Bar Widget contributor. Pierre Cyr Contributions to FXTable widget. Janusz Ganczarski : PCX, ICO, TGA Image/Icon format contributor. Daniel Gehriger : FXGIFCursor, Multi-lingual keyboard support, and much more. Eric Gillet : TIFF Image support. Freddy Golos: Freddy [Fyodor] was one of the first adopters of FOX, back when everybody still had to take my word for it how nice it was; Freddy made it clear there was real potential here. Angel-Ventura Mendo Gomez : OpenGL Shape Objects. Sean Hubbell: Initial version of FXFile API's. Sander Jansen : New web pages, new web layout, many useful suggestions and code. Code for the round progress dial, and lots of Windows specific nitty-gritties. CUR cursor. Lyle Johnson : Windows Port of FOX, Python, Ruby bindings; FXSpinner widget. The Spinner Widget. Lyle is also largely responsible for the Window NT port of FOX. Torsten Landschoff FOX automake, and reswrap man page files. René van Paassen : FOX RPM spec file. Guoqing Tian: Dial Widget contributor. David Tyree : JPEG Image support. Charles W. Warren charles@moontown.org: Shutter Widgets contributor. The concept of the Data Targets. Charles has also been my principal sounding board for exploring the philosophical underpinnings of the FOX Library. David Tyree: JPEG Image and JPEG Icon support. Jeroen van der Zijp : Main FOX Library author. The true list should probably be much larger; if you feel I have inadvertantly omitted you, please email me jeroen@fox-toolkit.net and I'll add you immediately. gogglesmm-gogglesmm-0b8cb53/cfox/CMakeLists.txt000066400000000000000000000073141455751074500216030ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.3.1) set(CMAKE_VERBOSE_MAKEFILE TRUE) project(cfox VERSION 1.7.83) option(WITH_NATIVE "Compile for native architecture" OFF) include(CheckCXXCompilerFlag) check_cxx_compiler_flag(-Wall HAS_CXX_WALL) check_cxx_compiler_flag(-Wextra HAS_CXX_WEXTRA) check_cxx_compiler_flag(-Wno-format HAS_CXX_WFORMAT) check_cxx_compiler_flag(-Wno-format-security HAS_CXX_WFORMAT_SECURITY) check_cxx_compiler_flag(-Woverloaded-virtual HAS_CXX_WOVERLOADED_VIRTUAL) check_cxx_compiler_flag(-Wshadow HAS_CXX_WSHADOW) check_cxx_compiler_flag(-Wstrict-aliasing HAS_CXX_WSTRICT_ALIASING) check_cxx_compiler_flag(-Wstrict-overflow HAS_CXX_WSTRICT_OVERFLOW) check_cxx_compiler_flag(-Wcast-qual HAS_CXX_WCAST_QUAL) check_cxx_compiler_flag(-Wcast-align HAS_CXX_WCAST_ALIGN) check_cxx_compiler_flag(-Wdouble-promotion HAS_CXX_WDOUBLE_PROMOTION) check_cxx_compiler_flag(-Wno-implicit-fallthrough HAX_CXX_IMPLICIT_FALLTHROUGH) check_cxx_compiler_flag(-Wfatal-errors HAS_CXX_WFATAL) check_cxx_compiler_flag(-Og HAS_CXX_OPTIMIZE_DEBUG) check_cxx_compiler_flag(-ffast-math HAS_CXX_FASTMATH) check_cxx_compiler_flag(-fstrict-aliasing HAS_CXX_STRICTALIASING) check_cxx_compiler_flag(-finline-functions HAS_CXX_INLINEFUNCTIONS) check_cxx_compiler_flag(-fomit-frame-pointer HAS_CXX_OMITFRAMEPOINTER) check_cxx_compiler_flag(-fstrict-overflow HAS_CXX_STRICT_OVERFLOW) check_cxx_compiler_flag(-fstrict-aliasing HAS_CXX_STRICT_ALIASING) check_cxx_compiler_flag(-fcf-protection=none HAS_CXX_CF_PROTECTION) check_cxx_compiler_flag(-fno-stack-protector HAS_CXX_STACK_PROTECTOR) if(HAS_CXX_FASTMATH) add_compile_options("$<$:-ffast-math>") endif() if(HAS_CXX_STRICTALIASING) add_compile_options("$<$:-fstrict-aliasing>") endif() if(HAS_CXX_INLINEFUNCTIONS) add_compile_options("$<$:-finline-functions>") endif() if(HAS_CXX_OMITFRAMEPOINTER) add_compile_options("$<$:-fomit-frame-pointer>") endif() if(HAS_CXX_STRICT_OVERFLOW) add_compile_options("$<$:-fstrict-overflow>") endif() if(HAS_CXX_STRICT_ALIASING) add_compile_options("$<$:-fstrict-aliasing>") endif() if(HAS_CXX_CF_PROTECTION) add_compile_options("$<$:-fcf-protection=none>") endif() if(HAS_CXX_STACK_PROTECTOR) add_compile_options("$<$:-fno-stack-protector>") endif() if(HAS_CXX_WALL) add_compile_options(-Wall) endif() if(HAS_CXX_WEXTRA) add_compile_options(-Wextra) endif() # Disable any -Wformat as FXString::format is incompatible if(HAS_CXX_WFORMAT) add_compile_options(-Wno-format) endif() # Disable -Wformat-security as this flag won't work with passing -Wno-format if(HAS_CXX_WFORMAT) add_compile_options(-Wno-format-security) endif() if(HAS_CXX_WFATAL) add_compile_options(-Wfatal-errors) endif() if(HAS_CXX_WSHADOW) add_compile_options(-Wshadow) endif() if(HAS_CXX_WOVERLOADED_VIRTUAL) add_compile_options(-Woverloaded-virtual) endif() if(HAX_CXX_IMPLICIT_FALLTHROUGH) add_compile_options(-Wno-implicit-fallthrough) endif() if(HAS_CXX_WSTRICT_ALIASING) add_compile_options(-Wstrict-aliasing) endif() if(HAS_CXX_WSTRICT_OVERFLOW) add_compile_options(-Wstrict-overflow) endif() if(HAS_CXX_WCAST_QUAL) add_compile_options(-Wcast-qual) endif() if(HAS_CXX_WCAST_ALIGN) add_compile_options(-Wcast-align) endif() if(HAS_CXX_WDOUBLE_PROMOTION) add_compile_options(-Wdouble-promotion) endif() if(WITH_NATIVE) check_cxx_compiler_flag(-march=native HAS_CXX_OPTIMIZE_NATIVE) if(HAS_CXX_OPTIMIZE_NATIVE) add_compile_options(-march=native) endif() endif() # Libraries add_subdirectory(utils) add_subdirectory(lib) gogglesmm-gogglesmm-0b8cb53/cfox/INSTALL000066400000000000000000000514261455751074500200770ustar00rootroot00000000000000 The FOX GUI Library Installation ================================ Systems Which are Supported or Known to work: ============================================= o Linux (gcc, INTEL C++), x86, IA64 (Itanium), x86-64 (Opteron). o Windows XP, 2K, NT, Windows 9x, (VC++, Cygwin, MinGW, Borland C++, Digital Mars C++, OpenWatcom C++, ... ) o Digital Unix/COMPAQ Tru64 OSF1 3.2, 4.0x, 5.0x (gcc and DEC cxx). o SGI IRIX 5.3, 6.1, 6.2, 6.4, 6.5 (gcc and MIPS Pro C++) o SUN Solaris, SunOS (gcc, SUN WorkShop Compiler, SUN Forte C++) o HP-UX PA-RISC 9.x, 10.x and B.11.00, (gcc and aCC). o HP-UX B.11.22 Intel Itanium (IA64) using aCC. o AIX 4.2, 4.3 o FreeBSD o Sequent DYNIX/ptx 4.4.7 o IBM VisualAge C++ 3.5 (Windows) o Apple MAC OS-X. You will need an X-Server, either Apple's or XFree. Building Documentation. ======================= You will need the "doxygen" documentation extraction tool. You can get it from: http://www.stack.nl/~dimitri/doxygen/index.html Many current linux distributions already include this tool as an optional package. To generate documentation, unpack the FOX tarball and go to directory "doc." Then issue the command: make docs If doxygen is installed properly, it will churn for a while and then generate hyperlinked documentation from the header files' document comments. You will find this reference documentation in the "doc/ref" directory. For most UNIX systems. ====================== For most unix systems you can configure simply as: ./configure You can disable OpenGL support by configuring as: ./configure --with-opengl=no After configure runs its course, simply type ``make'' to build the library, and ``make install'' to install it. FOX should compile on most UNIX platforms; we have tested the following: SGI, IBM, HP, SUN, DEC, LINUX, all with gcc; however, FOX uses a fairly conservative subset of C++, and should be no problem to port to other, more primitive, C++ compilers. On some machines, the X11 header files are still K&R C, instead of ANSI-C. You might try define add "-fpermissive" to the CXXFLAGS environment variable prior to running configure (this is the flag for GCC; other compilers may have similar option for old K&R C). When programming against FOX, you should only have to include "fx.h", and for 3D programs, "fx3d.h". To use keyboard symbols, include "fxkeys.h" also. Specifically, to remain portable application programs should NOT include any X window header files. You may of course need other system headers ("stdio.h", "gl.h", etc). Enabling XFT Support. ===================== On Linux systems, you can turn off XFT anti-aliased font support. ./configure --with-xft=no For portability reasons, the default of this settings is off. XCursor Support. ================ FOX supports Xcursor support where available. This is normally turned on, allowing full alpha-blended cursor support. However, you can disable if desired: ./configure --with-xcursor=no This will cause to revert to vanilla black/white cursor support only; note that your color cursors will still work: they will be thresholded to black and white depending on brightness. Building for Debug or Release. ============================== Normal builds [w/o any special arguments to configure] will include assert and trace statements into the library, but no debug symbols. This mode compiles the fastest and allows for tracing of the FOX library. This mode is the recommended way to develop FOX applications, as it allows for resource tracing and internal consistency checks. Building for debug will add debug symbols as needed by your debugger. It also includes assert and tracing into the library. This setting is recommended if you need to debug the FOX library itself. Full debug executables are build by configuring with: ./configure --enable-debug Release builds strip all debug information, asserts, and tracing, and generates optimized code. The resulting library is the smallest/fastest, and this is the recommended setting for production code. To build for release, use: ./configure --enable-release Building Shared or Non-Shared Libraries. ======================================== You can build FOX either as shared library, static library, or both. The default is both. To build static library only [this may be necessary on certain systems where shared library support is lacking]: ./configure --disable-shared to build shared library only: ./configure --disable-static Thread-safe support. ==================== It is highly recommended to build FOX with thread-safe API's wherever possible; this is accomplished using: ./configure --enable-threadsafe Enabling thread-safe will cause FOX to use the thread-safe equivalent API's for some common C library functions like getpwuid(), readdir() and so on. Image File Format Support. ========================== FOX needs external libraries for JPEG, TIFF, and PNG image format. On some systems, such as Linux, *BSD, these are likely already installed on your system. On Windows or older UNIX systems, they need to be compiled and installed first. See below on how to override default locations on UNIX systems. The JPEG support is provided by jpegsrc.v6b.tar.gz, the PNG support by libpng-1.2.5.tar.gz (or a newer version). The TIFF support is in tiff-v3.5.7.tar.gz (or later). All these files are available on ftp.fox-toolkit.org. After these libraries have been compiled and installed, compile FOX with HAVE_TIFF_H=1, HAVE_PNG_H=1, HAVE_JPEG_H=1. The TIFF library may also need the JPEG library (JPEG is one of the tags supported in the TIFF format), so compile the JPEG library first. TIFF also needs the GNU compression library zlib (available as zlib-1.1.4.tar.gz (or later) on ftp.fox-toolkit.org). Compression Library Support. ============================ Compressed FXStream support is enabled by installing zlib-1.1.4.tar.gz and bzip2-1.0.2.tar.gz (or later), then compiling FOX with HAVE_ZLIB_H=1 and HAVE_BZ2LIB_H=1, respectively. You do not need to install them on Linux, *BSD, but you probably do on Windows and older UNIX systems. Overriding Libraries. ===================== The default libraries determined by configurations are not always the ones you want to use; therefore, there is a mechanism to override the default choices of the configuration system. The override is done simply by setting environment variables prior to running configure; make sure config.cache is removed if you've ran configure before. Configure allows for the following overrides: Environment Variable Default value if not set ==================== ======================== LIBJPEG -ljpeg LIBPNG -lpng LIBTIFF -ltiff LIBZ -lz LIBBZ2 -lbz2 LIBGL -lopengl32 (win32) LIBGLU -lglu32 (win32) LIBGL -lGL (unix) LIBGLU -lGLU (unix) On SGI IRIX 6.x =============== On SGI Systems where MIPS Pro C++ compiler is used instead of GCC, you will need to set the environment variable CXX to: CC -n32 and then run: ./configure --x-libraries=/usr/lib32 or, you can also build FOX for the 64 bit model, and set CXX to: CC -64 and run configure with: ./configure --x-libraries=/usr/lib64 The first argument is only needed if you also have MESA on your system. FOX searches for the png library [for Portable Network Graphics, the successor of GIF], but the library it finds, even though it has the same name, is not the right one. You will need to disable this feature, or download the PNG library from http://www.graphicswiz.com/png/ and compile it, and pass the appropriate flags for your compiler to find the new version. If compiling without PNG, pass the flag: --disable-png; likewise, you can disable JPEG with the flag: --disable-jpeg. SGI Altix ========= Using Intel C++ compiler on IA64-based Altix system, drop optimization level to -O1: setenv CXX "icpc -O1" setenv CC "icc -O1" Full optimization with icc compiler appears to generate incorrect code. Using gcc 2.95.2 on IRIX 6.x (Thanks to Theo Venker) ==================================================== You won`t believe the solution: rename FXApp.cpp to FXApp.C and everything is fine. The manual page of g++ says that it accepts C++ suffixes .C, .cc, .cxx, .cpp, and .c++, and it does, but for .cpp and .c++ it compiles with -D__LANGUAGE_C -D_LANGUAGE_C -DLANGUAGE_C whereas the others suffixes use -D__LANGUAGE_C_PLUS_PLUS -D_LANGUAGE_C_PLUS_PLUS. This is clearly a bug in g++. I decided to wait for the next g++ release, so I didn`t report this to the g++ maintainers. May be you will. The work-arround is: export CC="g++ -D__LANGUAGE_C_PLUS_PLUS -D_LANGUAGE_C_PLUS_PLUS" and then run configure. Building 64-bit code on Linux for x86-64 (AMD Opteron, Athlon64) ================================================================ Linux for AMD Opteron supports execution of both 32 and 64 bit code on the same system; consequenly, two sets of libraries are installed. To configure properly, you will need to let ld search the right set of directories. Here's how: export LDFLAGS="-L/usr/lib64 -L/usr/X11R6/lib64 -L/lib64" ./configure No other issues are known at this time. On Alpha Processor based Workstations (COMPAQ/DEC OSF1) ======================================================= If you use DEC's "cxx" instead of GNU gcc, you will need to make sure the you add the flag option -D_XOPEN_SOURCE_EXTENDED to the compiler; this will allow usage of a wider set of POSIX functions; GCC seems to have this flag on by default, but the standard C++ compiler on OSF1 does not; thanks to thomas.goessler@avl.com for pointing this out. When compiling with gcc on Digital Unix, you may want to enable gradual underflow support for IEEE754 conformant floating point operations: export CXX="gcc -mieee" ./configure .... If this flag is NOT set, floating point operations which yield underflows will cause a floating point exception (SIGFPE). Many perfectly correct programs may generate underflows when working with small numbers (~1e-38 single precision, ~1e-308 double precision); working with these numbers may involve so-called denormalized floating point numbers, i.e. numbers where the mantissa can no longer be shifted to be within [0.5,1.0> range due to the exponent becoming 0. The ALPHA CPU does not include hardware do manipulate these numbers and will generate a trap when trying to manipulate these numbers; passing the "-mieee" flag will incorporate a software handler to ensure IEEE754 conformant floating arithmetic. Compiling FOX on the SUN ============================================ To use the SUN WorkShop Compiler compilers, simply configure FOX as follows: > cd fox > env CC=cc CXX=CC LD=CC ./configure Explanation: The SUN compilers require 'CC' to be used instead of 'ld' for creating the shared object library. This is to ensure that template instances will be included in the library. To build a static library 'CC -xar' should be used instead of 'ar' but there is no simple way to do this, due to limitations in 'libtool'. To get around this problem, the configure script invokes 'CC' with the argument '-instances=global', thus including template instances in the object file instead of using a template repository. This works fine and 'ar' can be used to build a static object library. Thanks to: Daniel Gehriger Compiling FOX using the HP/UX C++ Compiler ========================================== You may want to use GNU make instead of HP's make (/usr/bin/make). The default version of make doesn't seem to process the dependencies for PathFinder correctly and thus doesn't generate the reswrapped icon header files. Since PathFinder is built after the library and all the test programs, this isn't a huge problem -- it just means that the build will stop at that point with an error message. Configure the build by typing: env CC="cc +DA2.0W" CXX="aCC +DA2.0W +W740,749,863" ./configure The "+DA2.0W" flag tells it to compile as 64 bit. The "+W740,749,863" option suppresses a few warning messages that we believe are safe to ignore ;) Compiling FOX using the HP/UX Itanium^2 aCC C++ Compiler ======================================================== Assuming the aCC is installed in the recommended place: export CXX="aCC -fast -mt +DD64 -DHAVE_VSSCANF=1 -DHPOGL_SUPPRESS_FAST_API=1 -I/opt/aCC/include -I/opt/graphics/OpenGL/include -L/lib/hpux64 -L/usr/lib/hpux64 -L/opt/graphics/OpenGL/lib/hpux64" You may want to build the image support libraries also if you need them. Windows 95/98/ME/NT/XP Builds ============================= We currently build FOX on a regular basis using Microsoft Visual C++ 6.0. There is also support for Mingw32, the latest net release of Cygwin (v1.1) and Borland C++. We have heard of mixed success with building under Symantec's C++ 7.5 compiler. A few things to keep in mind: 1. If you want to include OpenGL support be sure to define the HAVE_OPENGL symbol on the compiler's command line, and to link your executables to the opengl32.lib and glu32.lib libraries. 2. The native Windows version of FOX relies on an undocumented API called _TrackMouseEvent() which is found in comctl32.dll. You should be sure to link your FOX applications with the comctl32.lib import library. Note that for this function is only available for comctl32.dll versions 4.70 or later; the latest version of this DLL can be downloaded from Microsoft's web site: http://www.microsoft.com/msdownload/ieplatform/ie/comctrlx86.asp If you are running Windows 98, Windows NT 4.0 SP3, or have installed Internet Explorer 4.0 or later, you *probably* already have the latest version of this DLL already. 3. The FOX registry mechanism uses the regular Windows registry under the hood; those functions are found in advapi32.lib which is not always a standard library. If you get some unresolved symbols at link time (esp. with names beginning with "Reg") try adding advapi32.lib to the list of libraries. 4. To build or use FOX as a DLL, the symbol FOXDLL must be defined; for building the core FOX library, FOXDLL_EXPORTS must also be defined. If FOXDLL_EXPORTS must NOT be not defined when you are just using FOX as a DLL. 5. It is recommended that extension DLL's are compiled with FOXDLL but that you define your own symbol to signify export; for example, the CHART library is build with CHARTDLL_EXPORTS; since the CHART library USES FOX, it must import the core FOX library, yet export its own functions. Building with Microsoft Visual C++ ================================== We now have a project workspace and project files set up for Win32 builds under Visual C++ 6.0. To use these, perform the following steps: 1. Download the latest fox.tar.gz from the web site; 2. Unzip & untar in your favorite place; 3. Start Visual C++ and open the fox/windows/vcpp/win32.dsw workspace; 4. Choose a project and build it. The project corresponding to the library itself is named "fox", and all of the other projects list it as a dependency. So if you choose, say, "glviewer" to build, it should first build the library and then build the glviewer test program. Building with Borland C++ Compilers =================================== The Borland makefiles are now tested semi-regularly against the free command-line compiler tools (compiler version 5.5) distributed by Borland/Inprise. We believe that they should also be usable for any recent Borland C++ compilers (e.g. Borland C++ Builder 3 or later). To build the FOX library, utility programs and example programs, change to the fox-0.99.xxx\windows\borland subdirectory and type "make". It should compile without a hitch, with the possible exception of building the OpenGL test programs in the "tests" subdirectory: + If you're using the free command-line compiler tools, you want to be sure that the %BCCDIR%\Lib\PSDK directory appears in the linker configuration file (%BCCDIR%\Bin\ilink32.cfg). If it isn't there, the linker won't know where to find the opengl32.lib and glu32.lib import libraries. + If you're using an older Borland compiler, you similarly want to be sure to have the updated OpenGL SDK for Win32 (including the OpenGL 1.2 header files and import libraries). If for some reason you don't have the correct header files and import libraries for OpenGL, and if OpenGL support isn't important for your project anyways, just modify the "Makefile.bc" in the fox-0.99.xxx\tests subdirectory so that it doesn't try to build the "glviewer.exe" or "gltest.exe" examples. Building FOX as a DLL ===================== The FOX library can also be built as a DLL for Windows; this is done by selecting the "foxdll" project and building it. Building this project causes the import libraries and DLLs to be placed in fox/lib. The filenames are foxdll.lib and foxdll.dll for the Release build, or foxdlld.lib and foxdlld.dll for the Debug build. To compile your own FOX applications so that they use the FOX DLL instead of the static FOX library, be sure to define the FOXDLL symbol in your compiler flags. Also note that the DLL must be in your search path for the program to run! Building FOX using OpenWatcom C++ ================================= The OpenWatcom C++ compiler can be downloaded free of charge from: http://www.openwatcom.org. To use the OpenWatcom "patch" with a fresh copy of FOX vx.y.zz, please make sure you've installed OpenWatcom C++ v1.0 and executed the SETVARS.BAT file found in the OpenWatcom installation directory. The Makefile.wc files rely on a Watcom environment variable, %WATCOM%, to determine the location of the COMCTL32.LIB file. Use the Makefile provided in windows/watcom/Makefile. Thanks to mikael@lyngvig.org for this port. Building FOX using MinGW ======================== Please see the standard FOX documentation file, "Developing Win32 GUI Applications Using FOX", available in this distribution as the file "doc/win32.html". Building FOX using Cygwin 1.1 ============================= FOX can also be built against the latest net release of Cygwin, available for download from here: http://sourceware.cygnus.com/cygwin/mirrors It absolutely will not compile with previous releases of Cygwin (i.e. Cygwin B20.1 or earlier), at least not without a lot of headaches. The win32api header files distributed with earlier versions of Cygwin were not up-to-date enough for FOX. It should compile out-of-the-box by typing: ./configure --disable-shared make Building FOX on QNX =================== For those interested in using FOX with QNX, before running configure for FOX on QNX it might be a good idea to run: automake --add-missing libtoolize -f Doing so will ensure that the configuration files needed to detect QNX are present. Also, for now it is probably best to disable shared libraries when building FOX on QNX. Programs linked with the FOX shared library will not run, but instead will segfault. I plan on looking into a fix for this eventually. Dustin Graves Building on MAC OS-X ==================== When building on Mac OS-X, the following might help: CXX="c++ -I/sw/include -L/sw/lib ./configure This might help; no guarantees, I can not test this myself.... For more information, see: http://freeride.rubyforge.org/wiki/wiki.pl?MacOSXInstall Image Formats in File Browser ============================= By default, all available image formats are supported in the File and Directory Browsers. Some of these image formats require external library support and consequently the size of your application executables may be reduced by limiting the supported formats to those supported in the core library; the image formats supported in the core library do not require external libraries and therefore supporting them does not incur any additional "code bloat". To support only the core image formats, pass the compiler flag: -DCORE_IMAGE_FORMATS=1 Another flag is the default icon search path, i.e. where the file browser will normally look to find and load icons bound to file extensions. The path below will cause the system to look in three different directories: -DDEFAULICONPATH="~/.foxicons:/usr/local/share/icons:/usr/share/icons" This would be a common setting for LINUX. Note that this is only the default; the actual search path can by set at any time by means of the FOX registry setting: [SETTINGS] iconpath="/home/extraicondir:/usr/share/icons" gogglesmm-gogglesmm-0b8cb53/cfox/LICENSE000066400000000000000000000167271455751074500200600ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. gogglesmm-gogglesmm-0b8cb53/cfox/LICENSE_ADDENDUM000066400000000000000000000044051455751074500213070ustar00rootroot00000000000000 ADDENDUM TO LICENSE March 2003 Revised July 2007 Copyright (C) 2002,2021 Jeroen van der Zijp. Everyone is permitted to copy and distribute verbatim copies of this license addendum document, but changing it is not allowed. FOX Toolkit Library License Addendum. 1. License. The FOX Toolkit Library ("The Library") is licensed under GNU Lesser General Public License as published by the Free Software Foundation, version 3 of the License, or (at your option) any later version. 2. Relinking Exemption. You may distribute a combined work using a statically linked, unmodified copy of the FOX Library under terms of your choice, without the relinking requirement stipulated under the GNU Lesser Public License, subject to the following conditions: a. This static relinking exemption covers only the FOX Toolkit Library. Other libraries which the FOX Library may need are covered by their own respective licenses. b. Modification of the configure scripts, makefiles, or installation tools of the FOX Library to support a specific platform does not constitute creating a modified copy based on the FOX Library. c. Programs or binaries statically linked with the FOX Library must be identified as such by including, in the Documentation or by other means (for example in the About Box or Online Help), the following statement: "This software uses the FOX Toolkit Library (http://www.fox-toolkit.org)." d. Subclassing from Objects or Widgets supplied by the Library involves no modifications to the source code of the Library itself, and does not constitute creating a modified copy based on the Library. 3. This FOX Toolkit Library License Addendum is NOT propagated to derivative works. When making derivative works based on the FOX Library, this license addendum ceases to apply, and code will revert to the simple GNU Lesser General Public License. The Relinking Exemption only applies to unmodified versions of the FOX Library. 4. If you do not accept or are unable to meet the conditions under (2), you may continue to distribute the combined work under the original GNU Lesser General Public License. END OF ADDENDUM gogglesmm-gogglesmm-0b8cb53/cfox/README000066400000000000000000000003261455751074500177170ustar00rootroot00000000000000This version of FOX is optimized to be directly included in other CMake based projects with the goal of statically linking in FOX. It adds the cmake based build system and removes unneeded example / test programs. gogglesmm-gogglesmm-0b8cb53/cfox/README.FOX000066400000000000000000000114721455751074500203560ustar00rootroot00000000000000 The FOX GUI Library =================== Jeroen van der Zijp What Is FOX? ============ FOX is a C++ based Toolkit for developing Graphical User Interfaces easily and effectively. It offers a wide, and growing, collection of Controls, and provides state of the art facilities such as drag and drop, selection, as well as OpenGL widgets for 3D graphical manipulation. FOX also implements icons, images, and user-convenience features such as status line help, and tooltips. Tooltips may even be used for 3D objects! Considerable importance has been placed on making FOX one of the fastest toolkits around, and to minimize memory use:- FOX uses a number of techniques to speed up drawing and spatial layout of the GUI. Memory is conserved by allowing programmers to create and destroy GUI elements on the fly. Even though FOX offers a large collection of Controls already, FOX leverages C++ to allow programmers to easily build additional Controls and GUI elements, simply by taking existing controls, and creating a derived class which simply adds or redefines the desired behavior. One of the prime design goals of FOX is the ease of programming; thus, most controls can be created using a single line of C++ code; most parameters have sensible default values, so that they may be omitted, and layout managers ensure that designers of GUI's do not have to worry about precise alignments. Another nice feature of FOX which significantly reduces the number of lines of code which have to be written is FOX's ability to have widgets connect to each other, and passing certain commands between them; for example, a menu entry Hide Toolbar can be directly connected to the Toolbar, and cause it to hide. Finally, FOX makes it easy to maintain the state of the GUI in an application by having the GUI elements automatically updating themselves by interrogating the application's state. This feature eliminates the large amount of effort that may go into sensitizing, graying out, checking/unchecking etc. depending on the application state. Where to get it? ================ You can FTP the complete FOX GUI toolkit from our FTP site: ftp://ftp.fox-toolkit.org/pub/ The distribution includes this on-line (HTML) documentation you see here. Mailing List. ============= To stay informed, we now have a mailing list for FOX. To subscribe, send mail to foxgui-users-request@lists.sourceforge.net with the word subscribe in the message body. Messages to the list can be sent to foxgui-users@lists.sourceforge.net. FOX announcements will be made through the foxgui-announce@lists.sourceforge.net list; you can subscribe to this list by sending a message "subscribe" to the list server at foxgui-announce-request@lists.sourceforge.net. Installation. ============= Please refer to the file INSTALL. FOX should compile on a large number of UNIX systems. The current "configure" scripts are however still somewhat primitive; if you need to make specific alterations to the configure system, feel free to send them to me so that I may merge them into the main distribution. The current FOX distribution compiles on Windows NT using the eXceed system; we expect however to get some core functionality to become available under the native Windows environment fairly soon. Getting started. ================ To get started programming with FOX, take a look at the tests directory, which contains some example programs. The best one to look at is probably the "glviewer" application. Note that you need OpenGL or Mesa on your machine in order to compile it. Finding FOX using GNU configure. ================================ GNU auto configure has features to detect the whereabouts of a library (AC_CHECK_LIB). Unfortunately, it assumes that you're looking for a C library, not a C++ library, and thus name mangling prevents it from finding FOX as all of FOX's API are C++. A special "dummy" C-linkage function was created to allow GNU auto configure to find the FOX library; you can use it in your configure.in as follows: AC_CHECK_LIB(FOX, fxfindfox) Bugs. ===== Please file bugs and questions to the list foxgui-users@lists.sourceforge.net. Before filing a bug, please take a moment to download the latest version of FOX, and make sure the problem still persists:- FOX is being developed fairly rapidly, and it is possible that some of the problems you may have experienced have already been fixed. License. ======== The FOX Library proper is licensed under GNU Lesser GPL; all the examples and demo programs are licensed under GPL. If you write software based on the FOX library, please include the following in your About Box, or some other place where a user may be able to see it: This software uses the FOX Toolkit (http://www.fox-toolkit.org). Thanks! gogglesmm-gogglesmm-0b8cb53/cfox/TRACING000066400000000000000000000063521455751074500200560ustar00rootroot00000000000000 About Tracing using FXTRACE =========================== The basic idea is similar to FXASSERT:- you will add lots FXTRACE commands, but you probably never want to remove them. Just like FXASSERT, FXTRACE commands can be left in the code, as they're automatically compiled out when the library is build for release mode, i.e. with -DNDEBUG on the command line of your compiler. If this isn't reason enough to forego old printf() statements for FXTRACE, I remind you that under MSWindows, no stdout/stderr is opened up for non-console applications, and one has to use the Debug API calls instead of printf() calls. Using FXTRACE is therefore pretty convenient, as the MSWindows implementation of FOX will automatically use those Debug API's if your program is not compiled as a console application, and will revert to stderr under console mode [and of course under UNIX]. You use FXTRACE with DOUBLE PARENTHESES, as in: FXTRACE((200,"%s::onFocusIn %08x\n",getClassName(),this)); This is done so the C preprocessor can expand: FXTRACE((200,"%s::onFocusIn %08x\n",getClassName(),this)) into: fxtrace (200,"%s::onFocusIn %08x\n",getClassName(),this) or, in case of -DNDEBUG or release builds: ((void)0) Which any self-respecting compiler completely ignores and generates no object code for. BTW, this is what everybody does for asserts also. The number `200' in the above example is the tracelevel at which the statement will produce actual outputs on your screen. Starting your FOX program with: -tracelevel 300 will cause all FXTRACE statements with levels 300 and up to be BLOCKED from producing any outputs. Since you don't want to see reams of outputs, the most frequently occuring types of events should be given the highest trace level. For now, tracelevels 0 through 99 are reserved for application use, with FOX itself using levels 100 and upwards. Note that as tracing is controlled by a simple global variable fxTraceLevel, your program can simply set a higher tracelevel at a point in its execution where things are starting to get a little bit hairy..... Another way to set the tracelevel is to set the environment variable FOX_TRACE_LEVEL. The tracelevel takes effect when the FXApp is initialized. Setting the tracelevel from the command-line takes precedence over the FOX_TRACE_LEVEL tracelevel value. Tentative assignments of tracelevels in FOX: 100: Important, high-level info, such as ctors and dtors for Icons, Images, Bitmaps, Fonts, and Cursors. Since you may easily leak those resources if your program does not track these properly, setting tracelevel to 101 (or higher) will allow you to see easily what's being created and destroyed. 200: Infrequent events such as mapping/unmapping of windows, selection requests, and such stuff. 250: More frequent stuff such as DND events. 300: Button clicks. 350: Mouse movements. 400: GUI Updates, when GUI Updates are allowed. I have not been overzealous sticking to these conventions, but now that it's written down for me to re-read, there's a higher chance that I'll stick to it in the future. Further assignments will probably follow some day.... - Jeroen gogglesmm-gogglesmm-0b8cb53/cfox/include/000077500000000000000000000000001455751074500204615ustar00rootroot00000000000000gogglesmm-gogglesmm-0b8cb53/cfox/include/FX4Splitter.h000066400000000000000000000173561455751074500227760ustar00rootroot00000000000000/******************************************************************************** * * * F o u r - W a y S p l i t t e r * * * ********************************************************************************* * Copyright (C) 1999,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FX4SPLITTER_H #define FX4SPLITTER_H #ifndef FXCOMPOSITE_H #include "FXComposite.h" #endif namespace FX { // Splitter options enum { FOURSPLITTER_TRACKING = 0x00008000, // Track continuously during split FOURSPLITTER_VERTICAL = 0x00010000, // Prefer vertial expansion of panels FOURSPLITTER_HORIZONTAL = 0, // Prefer horizontal expansion of panels (default) FOURSPLITTER_NORMAL = 0 }; /** * The four-way splitter is a layout manager which manages * four children like four panes in a window. * You can use a four-way splitter for example in a CAD program * where you may want to maintain three orthographic views, and * one oblique view of a model. * The four-way splitter allows interactive repartitioning of the * panes by means of moving the central splitter bars. * When the four-way splitter is itself resized, each child is * proportionally resized, maintaining the same split-percentage. * The four-way splitter widget sends a SEL_CHANGED to its target * during the resizing of the panes; at the end of the resize interaction, * it sends a SEL_COMMAND to signify that the resize operation is complete. * It is possible to expand or collapse one or more of the sub-panes of the * four-way splitter; by default, all four panes are expanded. * When a pane is collapsed, the remaining panes will fill the space left. * If the FOURSPLITTER_HORIZONTAL flag is in effect (default), the remaining * panels expand horizontally to fill the space; conversely, if FOURSPLITTER_VERTICAL * is passed then the remaining panels will expand vertically to accomodate the extra * space. * The flag FOURSPLITTER_TRACKING causes the contents to be redrawn interactively as * the split-division is adjusted; otherwise the contents will be redrawn only after * the resizing is finished. */ class FXAPI FX4Splitter : public FXComposite { FXDECLARE(FX4Splitter) private: FXint splitx; // Current x split FXint splity; // Current y split FXint barsize; // Size of the splitter bar FXint fhor; // Horizontal split fraction FXint fver; // Vertical split fraction FXint offx; FXint offy; FXuchar mode; protected: FX4Splitter(); FXuchar getMode(FXint x,FXint y); void moveSplit(FXint x,FXint y); void drawSplit(FXint x,FXint y,FXuint m); void adjustLayout(); private: FX4Splitter(const FX4Splitter&); FX4Splitter &operator=(const FX4Splitter&); public: long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onFocusUp(FXObject*,FXSelector,void*); long onFocusDown(FXObject*,FXSelector,void*); long onFocusLeft(FXObject*,FXSelector,void*); long onFocusRight(FXObject*,FXSelector,void*); long onCmdExpand(FXObject*,FXSelector,void*); long onUpdExpand(FXObject*,FXSelector,void*); public: enum { ExpandNone = 0, /// None expanded ExpandTopLeft = 1, /// Expand top left child ExpandTopRight = 2, /// Expand top right child ExpandBottomLeft = 4, /// Expand bottom left child ExpandBottomRight = 8, /// Expand bottom right child ExpandTop = ExpandTopLeft|ExpandTopRight, /// Expand top children ExpandBottom = ExpandBottomLeft|ExpandBottomRight, /// Expand bottom children ExpandLeft = ExpandTopLeft|ExpandBottomLeft, /// Expand left children ExpandRight = ExpandTopRight|ExpandBottomRight, /// Expand right children ExpandCriss = ExpandTopRight|ExpandBottomLeft, /// Expand diagonally opposing children ExpandCross = ExpandTopLeft|ExpandBottomRight, /// Expand diagonally opposing children ExpandAll = ExpandLeft|ExpandRight /// Expand all children }; public: enum { ID_EXPAND_NONE=FXComposite::ID_LAST+ExpandNone, ID_EXPAND_TOP=ID_EXPAND_NONE+ExpandTop, ID_EXPAND_BOTTOM=ID_EXPAND_NONE+ExpandBottom, ID_EXPAND_LEFT=ID_EXPAND_NONE+ExpandLeft, ID_EXPAND_RIGHT=ID_EXPAND_NONE+ExpandRight, ID_EXPAND_TOPLEFT=ID_EXPAND_NONE+ExpandTopLeft, ID_EXPAND_TOPRIGHT=ID_EXPAND_NONE+ExpandTopRight, ID_EXPAND_BOTTOMLEFT=ID_EXPAND_NONE+ExpandBottomLeft, ID_EXPAND_BOTTOMRIGHT=ID_EXPAND_NONE+ExpandBottomRight, ID_EXPAND_ALL=ID_EXPAND_NONE+ExpandAll, ID_LAST }; public: /// Create 4-way splitter, initially shown as four unexpanded panes FX4Splitter(FXComposite* p,FXuint opts=FOURSPLITTER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Create 4-way splitter, initially shown as four unexpanded panes; notifies target about size changes FX4Splitter(FXComposite* p,FXObject* tgt,FXSelector sel,FXuint opts=FOURSPLITTER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Get top left child, if any FXWindow *getTopLeft() const; /// Get top right child, if any FXWindow *getTopRight() const; /// Get bottom left child, if any FXWindow *getBottomLeft() const; /// Get bottom right child, if any FXWindow *getBottomRight() const; /// Get horizontal split fraction FXint getHSplit() const { return fhor; } /// Get vertical split fraction FXint getVSplit() const { return fver; } /// Change horizontal split fraction void setHSplit(FXint s); /// Change vertical split fraction void setVSplit(FXint s); /// Perform layout virtual void layout(); /// Get default width virtual FXint getDefaultWidth(); /// Get default height virtual FXint getDefaultHeight(); /// Return current splitter style FXuint getSplitterStyle() const; /// Change splitter style void setSplitterStyle(FXuint style); /// Change splitter bar width void setBarSize(FXint bs); /// Get splitter bar width FXint getBarSize() const { return barsize; } /// Change set of expanded children void setExpanded(FXuint set=FX4Splitter::ExpandAll); /// Get set of expanded children FXuint getExpanded() const; /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FX7Segment.h000066400000000000000000000124661455751074500225720ustar00rootroot00000000000000/******************************************************************************** * * * 7 - S e g m e n t D i s p l a y W i d g e t * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FX7SEGMENT_H #define FX7SEGMENT_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { /// 7 Segment styles enum { SEVENSEGMENT_NORMAL = 0, /// Draw segments normally SEVENSEGMENT_SHADOW = 0x00080000 /// Draw shadow under the segments }; /** * Seven-segment (eg LCD/watch style) widget, useful for making * indicators and timers. Besides numbers, the seven-segment * display widget can also display some letters and punctuations. */ class FXAPI FX7Segment : public FXFrame { FXDECLARE(FX7Segment) protected: FXString label; // Text being shown FXString tip; // Tooltip FXString help; // Help message FXColor textColor; // Text color FXint thickness; // Segment thickness FXint cellwidth; // Width of cell FXint cellheight; // height of cell protected: FX7Segment(); private: FX7Segment(const FX7Segment&); FX7Segment &operator=(const FX7Segment&); void drawCells(FXDCWindow &dc,FXint x,FXint y,FXint cw,FXint ch); void drawSegments(FXDCWindow &dc,FXint x,FXint y,FXint w,FXint h,FXuint segments); public: long onPaint(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdSetLongValue(FXObject*,FXSelector,void*); long onCmdGetLongValue(FXObject*,FXSelector,void*); long onCmdSetRealValue(FXObject*,FXSelector,void*); long onCmdGetRealValue(FXObject*,FXSelector,void*); long onCmdSetStringValue(FXObject*,FXSelector,void*); long onCmdGetStringValue(FXObject*,FXSelector,void*); long onCmdSetHelp(FXObject*,FXSelector,void*); long onCmdGetHelp(FXObject*,FXSelector,void*); long onCmdSetTip(FXObject*,FXSelector,void*); long onCmdGetTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); public: /// Create a seven segment display FX7Segment(FXComposite* p,const FXString& text,FXuint opts=SEVENSEGMENT_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Set the text for this label void setText(const FXString& text); /// Get the text for this label FXString getText() const { return label; } /// Change text color void setTextColor(FXColor clr); /// Return text color FXColor getTextColor() const { return textColor; } /// Get/set cell width void setCellWidth(FXint w); FXint getCellWidth() const { return cellwidth; } /// Get/set cell height void setCellHeight(FXint h); FXint getCellHeight() const { return cellheight; } /// Get/set segment thickness void setThickness(FXint t); FXint getThickness() const { return thickness; } /// Change 7 segment style void set7SegmentStyle(FXuint style); /// Get current 7 segment style FXuint get7SegmentStyle() const; /// Set the current text-justification mode. void setJustify(FXuint mode); /// Get the current text-justification mode. FXuint getJustify() const; /// Set the status line help text void setHelpText(const FXString& text){ help=text; } /// Get the status line help text const FXString& getHelpText() const { return help; } /// Set the tool tip message void setTipText(const FXString& text){ tip=text; } /// Get the tool tip message const FXString& getTipText() const { return tip; } /// Save to a stream virtual void save(FXStream &store) const; /// Load from a stream virtual void load(FXStream &store); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FX885910Codec.h000066400000000000000000000011131455751074500226000ustar00rootroot00000000000000#ifndef FX885910CODEC_H #define FX885910CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// ISO-8859-10 Codec class FXAPI FX885910Codec : public FXTextCodec { FXDECLARE(FX885910Codec) public: FX885910Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FX885910Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FX885911Codec.h000066400000000000000000000011131455751074500226010ustar00rootroot00000000000000#ifndef FX885911CODEC_H #define FX885911CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// ISO-8859-11 Codec class FXAPI FX885911Codec : public FXTextCodec { FXDECLARE(FX885911Codec) public: FX885911Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FX885911Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FX885913Codec.h000066400000000000000000000011131455751074500226030ustar00rootroot00000000000000#ifndef FX885913CODEC_H #define FX885913CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// ISO-8859-13 Codec class FXAPI FX885913Codec : public FXTextCodec { FXDECLARE(FX885913Codec) public: FX885913Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FX885913Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FX885914Codec.h000066400000000000000000000011131455751074500226040ustar00rootroot00000000000000#ifndef FX885914CODEC_H #define FX885914CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// ISO-8859-14 Codec class FXAPI FX885914Codec : public FXTextCodec { FXDECLARE(FX885914Codec) public: FX885914Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FX885914Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FX885915Codec.h000066400000000000000000000011131455751074500226050ustar00rootroot00000000000000#ifndef FX885915CODEC_H #define FX885915CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// ISO-8859-15 Codec class FXAPI FX885915Codec : public FXTextCodec { FXDECLARE(FX885915Codec) public: FX885915Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FX885915Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FX885916Codec.h000066400000000000000000000011131455751074500226060ustar00rootroot00000000000000#ifndef FX885916CODEC_H #define FX885916CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// ISO-8859-16 Codec class FXAPI FX885916Codec : public FXTextCodec { FXDECLARE(FX885916Codec) public: FX885916Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FX885916Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FX88591Codec.h000066400000000000000000000011041455751074500225200ustar00rootroot00000000000000#ifndef FX88591CODEC_H #define FX88591CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// ISO-8859-1 Codec class FXAPI FX88591Codec : public FXTextCodec { FXDECLARE(FX88591Codec) public: FX88591Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FX88591Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FX88592Codec.h000066400000000000000000000011041455751074500225210ustar00rootroot00000000000000#ifndef FX88592CODEC_H #define FX88592CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// ISO-8859-2 Codec class FXAPI FX88592Codec : public FXTextCodec { FXDECLARE(FX88592Codec) public: FX88592Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FX88592Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FX88593Codec.h000066400000000000000000000011041455751074500225220ustar00rootroot00000000000000#ifndef FX88593CODEC_H #define FX88593CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// ISO-8859-3 Codec class FXAPI FX88593Codec : public FXTextCodec { FXDECLARE(FX88593Codec) public: FX88593Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FX88593Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FX88594Codec.h000066400000000000000000000011041455751074500225230ustar00rootroot00000000000000#ifndef FX88594CODEC_H #define FX88594CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// ISO-8859-4 Codec class FXAPI FX88594Codec : public FXTextCodec { FXDECLARE(FX88594Codec) public: FX88594Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FX88594Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FX88595Codec.h000066400000000000000000000011041455751074500225240ustar00rootroot00000000000000#ifndef FX88595CODEC_H #define FX88595CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// ISO-8859-5 Codec class FXAPI FX88595Codec : public FXTextCodec { FXDECLARE(FX88595Codec) public: FX88595Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FX88595Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FX88596Codec.h000066400000000000000000000011041455751074500225250ustar00rootroot00000000000000#ifndef FX88596CODEC_H #define FX88596CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// ISO-8859-6 Codec class FXAPI FX88596Codec : public FXTextCodec { FXDECLARE(FX88596Codec) public: FX88596Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FX88596Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FX88597Codec.h000066400000000000000000000011041455751074500225260ustar00rootroot00000000000000#ifndef FX88597CODEC_H #define FX88597CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// ISO-8859-7 Codec class FXAPI FX88597Codec : public FXTextCodec { FXDECLARE(FX88597Codec) public: FX88597Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FX88597Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FX88598Codec.h000066400000000000000000000011041455751074500225270ustar00rootroot00000000000000#ifndef FX88598CODEC_H #define FX88598CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// ISO-8859-8 Codec class FXAPI FX88598Codec : public FXTextCodec { FXDECLARE(FX88598Codec) public: FX88598Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FX88598Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FX88599Codec.h000066400000000000000000000011041455751074500225300ustar00rootroot00000000000000#ifndef FX88599CODEC_H #define FX88599CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// ISO-8859-9 Codec class FXAPI FX88599Codec : public FXTextCodec { FXDECLARE(FX88599Codec) public: FX88599Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FX88599Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXAccelTable.h000066400000000000000000000142401455751074500230500ustar00rootroot00000000000000/******************************************************************************** * * * A c c e l e r a t o r T a b l e C l a s s * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXACCELTABLE_H #define FXACCELTABLE_H #ifndef FXOBJECT_H #include "FXObject.h" #endif namespace FX { /** * The accelerator table sends a message to a specific * target object when the indicated key and modifier combination * is pressed. */ class FXAPI FXAccelTable : public FXObject { FXDECLARE(FXAccelTable) protected: struct FXAccelKey { FXObject *target; // Target object of message FXSelector messagedn; // Message being sent FXSelector messageup; // Message being sent FXHotKey code; // Keysym and modifier mask to match }; private: FXAccelKey *key; // Accelerator table FXuint max; // Largest table index FXuint num; // Number of entries private: void resize(FXuint m); private: FXAccelTable(const FXAccelTable&); FXAccelTable &operator=(const FXAccelTable&); public: long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); public: /** * Construct empty accelerator table. */ FXAccelTable(); /** * Add accelerator key-combination into the accelerator table. */ void addAccel(FXHotKey hotkey,FXObject* target=nullptr,FXSelector seldn=0,FXSelector selup=0); /** * Parse key-combination description and add it into the accelerator table. */ void addAccel(const FXchar* string,FXObject* target=nullptr,FXSelector seldn=0,FXSelector selup=0); void addAccel(const FXString& string,FXObject* target=nullptr,FXSelector seldn=0,FXSelector selup=0); /** * Remove accelerator key combination from the accelerator table. */ void removeAccel(FXHotKey hotkey); /** * Parse key-combination description and remove it from the accelerator table. */ void removeAccel(const FXchar* string); void removeAccel(const FXString& string); /** * Return true if accelerator accelerator key-combination is in accelerator table. */ FXbool hasAccel(FXHotKey hotkey) const; /** * Parse key-combination description and return true if it is in the accelerator table. */ FXbool hasAccel(const FXchar* string) const; FXbool hasAccel(const FXString& string) const; /** * Return target object of the given accelerator key-combination. */ FXObject* targetOfAccel(FXHotKey hotkey) const; /** * Parse key-combination description and return its target. */ FXObject* targetOfAccel(const FXchar* string) const; FXObject* targetOfAccel(const FXString& string) const; /** * Parse accelerator from string, yielding modifier and key code. * The syntax of the string is: * * ::= ( ('-' | '+'))* * * where: * * ::= 'Ctl' | 'Ctrl' | 'Alt' | 'Meta' | 'Shift' * * ::= 'Home' | 'End' | 'PgUp' | 'PgDn' | 'Left' | 'Right' | * 'Up' | 'Down' | 'Ins' | 'Del' | 'Esc' | 'Tab' | 'Return' | * 'Enter' | 'Back' | 'Spc' | 'Space' | * 'F'? | * '#'+ | * * * ::= '0' ... '1' * ::= 'A' ... 'Z' * ::= '0' ... '9', 'A' ... 'F' * * Case is not significant, but uppercase is preferred. * For example, parseAccel("Ctl+Shift+X") yields the same value as: * MKUINT(KEY_X,CONTROLMASK|SHIFTMASK). */ static FXHotKey parseAccel(const FXchar* string); static FXHotKey parseAccel(const FXString& string); /** * Unparse hot key comprising modifier and key code back * into a string suitable for parsing with fxparseHotKey. * For example, an input of MKUINT(KEY_X,CONTROLMASK|SHIFTMASK) * will return the string "Ctl+Shift+X". */ static FXString unparseAccel(FXHotKey key); /// Save table to a stream virtual void save(FXStream& store) const; /// Load table from a stream virtual void load(FXStream& store); /** * Destroy accelerator table. */ virtual ~FXAccelTable(); }; /** * Parse hot key from string of the form "&Hotkey", yielding modifier and * key code. If a '&' is to be just plain text, it should be doubled. * For example, parseHotKey(""Salt && &Pepper!"") yields the same value as * MKUINT(KEY_p,ALTMASK). */ extern FXAPI FXHotKey parseHotKey(const FXString& string); /** * Obtain hot key offset in string, or -1 if not found. * For example, findHotKey("Salt && &Pepper!") yields 7. * Note that this is the byte-offset, not the character * index! */ extern FXAPI FXint findHotKey(const FXString& string); /** * Strip hot key combination from the string. * For example, stripHotKey("Salt && &Pepper") should * yield "Salt & Pepper". */ extern FXAPI FXString stripHotKey(const FXString& string); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXApp.h000066400000000000000000001100301455751074500216030ustar00rootroot00000000000000/******************************************************************************** * * * A p p l i c a t i o n O b j e c t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXAPP_H #define FXAPP_H #ifndef FXOBJECT_H #include "FXObject.h" #endif namespace FX { // Forward declarations class FXApp; class FXWindow; class FXIcon; class FXBitmap; class FXCursor; class FXRootWindow; class FXMainWindow; class FXPopup; class FXFont; class FXDC; class FXDCWindow; class FXVisual; class FXGLVisual; class FXGLContext; class FXTranslator; class FXComposeContext; // Opaque FOX objects struct FXTimer; struct FXChore; struct FXSignal; struct FXRepaint; struct FXInput; struct FXHandles; struct FXInvocation; /// File input modes for addInput enum FXInputMode { INPUT_NONE = 0, /// Inactive INPUT_READ = 1, /// Read input fd INPUT_WRITE = 2, /// Write input fd INPUT_EXCEPT = 4 /// Except input fd }; /// All ways of being modal enum FXModality { MODAL_FOR_NONE, /// Non modal event loop (dispatch normally) MODAL_FOR_WINDOW, /// Modal dialog (beep if outside of modal dialog) MODAL_FOR_POPUP /// Modal for popup (always dispatch to popup) }; /// Default cursors provided by the application enum FXDefaultCursor { DEF_ARROW_CURSOR, /// Arrow cursor DEF_RARROW_CURSOR, /// Reverse arrow cursor DEF_TEXT_CURSOR, /// Text cursor DEF_HSPLIT_CURSOR, /// Horizontal split cursor DEF_VSPLIT_CURSOR, /// Vertical split cursor DEF_XSPLIT_CURSOR, /// Cross split cursor DEF_SWATCH_CURSOR, /// Color swatch drag cursor DEF_MOVE_CURSOR, /// Move cursor DEF_DRAGH_CURSOR, /// Resize horizontal edge DEF_DRAGV_CURSOR, /// Resize vertical edge DEF_DRAGTL_CURSOR, /// Resize upper-leftcorner DEF_DRAGBR_CURSOR=DEF_DRAGTL_CURSOR, /// Resize bottom-right corner DEF_DRAGTR_CURSOR, /// Resize upper-right corner DEF_DRAGBL_CURSOR=DEF_DRAGTR_CURSOR, /// Resize bottom-left corner DEF_DNDSTOP_CURSOR, /// Drag and drop stop DEF_DNDASK_CURSOR, /// Drag and drop ask DEF_DNDCOPY_CURSOR, /// Drag and drop copy DEF_DNDMOVE_CURSOR, /// Drag and drop move DEF_DNDLINK_CURSOR, /// Drag and drop link DEF_CROSSHAIR_CURSOR, /// Cross hair cursor DEF_CORNERNE_CURSOR, /// North-east cursor DEF_CORNERNW_CURSOR, /// North-west cursor DEF_CORNERSE_CURSOR, /// South-east cursor DEF_CORNERSW_CURSOR, /// South-west cursor DEF_HELP_CURSOR, /// Help arrow cursor DEF_HAND_CURSOR, /// Hand cursor DEF_ROTATE_CURSOR, /// Rotate cursor DEF_BLANK_CURSOR, /// Blank cursor DEF_WAIT_CURSOR /// Wait cursor }; /** * The Application object is the central point of a FOX user-interface. * It manages the event queue, timers, signals, chores, and input sources. * Each FOX application should have exactly one Application object, which * is the ultimate owner of the entire widget tree; when the application * object is deleted, all the widgets and other reachable resources of * the widget tree are also deleted. * When the Application is initialized using init(), it parses the * command line arguments meant for it, and opens the display. * The run() function is used to run the application; this function * does not return until the user is ready to quit the application. * During run(), the application processes events from the various * windows and dispatches them to the appropriate handlers. * Finally, a call to exit() terminates the application. * The Application object also manages a registry of configuration * data, which is read during init() and written back at the exit(); * thus, all configurations changed by the user normally persist to * the next invocation of the application. * Since different organizations and different applications each need * to keep their own set of configuration data, an application name * and vendor name can be passed in the Application object's constructor * to identify a particular application's configuration data. */ class FXAPI FXApp : public FXObject { FXDECLARE(FXApp) // We've got many friends friend class FXId; friend class FXBitmap; friend class FXImage; friend class FXIcon; friend class FXCursor; friend class FXDrawable; friend class FXWindow; friend class FXShell; friend class FXRootWindow; friend class FXTopWindow; friend class FXMainWindow; friend class FXPopup; friend class FXFont; friend class FXVisual; friend class FXGLVisual; friend class FXGLContext; friend class FXDC; friend class FXDCWindow; friend class FXDragCorner; friend class FXDockHandler; friend class FXComposeContext; private: // Platform independent private data void *display; // Display we're talking to FXHash hash; // Window handle hash table FXRegistry registry; // Application setting registry FXWindow *activeWindow; // Active toplevel window FXWindow *cursorWindow; // Window under the cursor FXWindow *mouseGrabWindow; // Window which grabbed the mouse FXWindow *keyboardGrabWindow; // Window which grabbed the keyboard FXWindow *keyWindow; // Window in which keyboard key was pressed FXWindow *selectionWindow; // Selection window FXWindow *clipboardWindow; // Clipboard window FXWindow *dropWindow; // Drop target window FXWindow *dragWindow; // Drag source window FXWindow *refresher; // GUI refresher pointer FXWindow *refresherstop; // GUI refresher end pointer FXPopup *popupWindow; // Current popup window FXRootWindow *root; // Root window FXVisual *monoVisual; // Monochrome visual FXVisual *defaultVisual; // Default [color] visual FXTimer *timers; // List of timers, sorted by time FXChore *chores; // List of chores FXRepaint *repaints; // Unhandled repaint rectangles FXTimer *timerrecs; // List of recycled timer records FXChore *chorerecs; // List of recycled chore records FXRepaint *repaintrecs; // List of recycled repaint records FXInvocation *invocation; // Modal loop invocation FXSignal *signals; // Array of signal records FXint signalreceived; // Latest signal received FXFont *normalFont; // Normal font FXFont *stockFont; // Stock font FXMutex appMutex; // Application wide mutex FXEvent event; // Event FXuint stickyMods; // Sticky modifier state FXInput *inputs; // Input file descriptors being watched FXint ninputs; // Number of inputs FXHandles *handles; // Input handles FXint maxhandle; // Maximum handle number FXuchar *ddeData; // DDE array FXuint ddeSize; // DDE array size FXuint maxcolors; // Maximum number of colors to allocate FXTime typingSpeed; // Typing speed FXTime clickSpeed; // Double click speed FXTime scrollSpeed; // Scroll speed FXTime scrollDelay; // Scroll delay FXTime blinkSpeed; // Cursor blink speed FXTime animSpeed; // Animation speed FXTime menuPause; // Menu popup delay FXTime toolTipPause; // Tooltip popup delay FXTime toolTipTime; // Tooltip display time FXTime autoHideDelay; // Cursor autohide delay time FXint dragDelta; // Minimum distance considered a move FXint wheelLines; // Scroll by this many lines FXint scrollBarSize; // Scrollbar size FXColor borderColor; // Border color FXColor baseColor; // Background color of GUI controls FXColor hiliteColor; // Highlight color of GUI controls FXColor shadowColor; // Shadow color of GUI controls FXColor backColor; // Background color FXColor foreColor; // Foreground color FXColor selforeColor; // Select foreground color FXColor selbackColor; // Select background color FXColor tipforeColor; // Tooltip foreground color FXColor tipbackColor; // Tooltip background color FXColor selMenuTextColor; // Select foreground color in menus FXColor selMenuBackColor; // Select background color in menus FXCursor *waitCursor; // Current wait cursor FXuint waitCount; // Number of times wait cursor was called FXuint windowCount; // Number of windows FXCursor *cursor[DEF_WAIT_CURSOR+1]; FXTranslator *translator; // Message translator FXint appArgc; // Argument count const FXchar *const *appArgv; // Argument vector const FXchar *inputmethod; // Input method name const FXchar *inputstyle; // Input method style FXbool initialized; // Has been initialized private: static FXApp *app; // Application pointer // Platform dependent private stuff #ifdef WIN32 FXushort ddeTargets; // DDE targets atom FXushort ddeAtom; // DDE Exchange Atom FXDragType ddeDelete; // DDE Delete Target Atom FXDragType *ddeTypeList; // DDE drop type list FXuint ddeNumTypes; // DDE number of drop types FXDragAction ddeAction; // DDE action FXDragAction ansAction; // Reply action FXDragType *xselTypeList; // Selection type list FXuint xselNumTypes; // Selection number of types on list void* xdndTypes; // Handle to file mapping object for types list FXushort xdndAware; // XDND awareness atom FXID xdndSource; // XDND drag source window FXID xdndTarget; // XDND drop target window FXbool xdndStatusPending; // XDND waiting for status feedback FXbool xdndFinishPending; // XDND waiting for drop-confirmation FXbool xdndStatusReceived; // XDND received at least one status FXbool xdndFinishSent; // XDND finish sent FXRectangle xdndRect; // XDND rectangle bounding target FXID stipples[17]; // Standard stipple bitmaps #else private: FXID wmDeleteWindow; // Catch delete window FXID wmSaveYourself; // Catch shutdown FXID wmQuitApp; // Catch quit application FXID wmProtocols; // Window manager protocols FXID wmMotifHints; // Motif hints FXID wmTakeFocus; // Focus explicitly set by app FXID wmClientMachine; // Client machine FXID wmState; // Window state FXID wmNetState; // Extended Window Manager window state FXID wmNetIconName; // Extended Window Manager icon name FXID wmNetWindowName; // Extended Window Manager window name FXID wmNetSupported; // Extended Window Manager states list FXID wmNetHidden; // Extended Window Manager hidden FXID wmNetShaded; // Extended Window Manager shaded FXID wmNetHMaximized; // Extended Window Manager horizontally maximized FXID wmNetVMaximized; // Extended Window Manager vertically maximized FXID wmNetFullScreen; // Extended Window Manager full screen FXID wmNetBelowOthers; // Extended Window Manager below others FXID wmNetAboveOthers; // Extended Window Manager above others FXID wmNetNeedAttention; // Extended Window Manager need attention FXID wmNetMoveResize; // Extended Window Manager drag corner FXID wmNetRestack; // Extended Window Manager change stacking order FXID wmNetPing; // Extended Window Manager ping FXID wmNetProcessId; // Extended Window Manager process id FXID wmNetWindowType; // Extended Window Manager window type FXID wmWindowTypes[14]; // Window types FXID wmWindowRole; // Window Role FXID wmClientLeader; // Client leader FXID wmClientId; // Client id FXID embedAtom; // XEMBED support FXID embedInfoAtom; // XEMBED info support FXID timestampAtom; // Server time FXID ddeTargets; // DDE targets atom FXID ddeAtom; // DDE exchange atom FXID ddeDelete; // DDE delete target atom FXID ddeIncr; // DDE incremental data exchange atom FXDragType *ddeTypeList; // DDE drop type list FXuint ddeNumTypes; // DDE number of drop types FXDragAction ddeAction; // DDE action FXDragAction ansAction; // Reply action FXID xcbSelection; // Clipboard selection FXDragType *xcbTypeList; // Clipboard type list FXuint xcbNumTypes; // Clipboard number of types on list FXDragType *xselTypeList; // Selection type list FXuint xselNumTypes; // Selection number of types on list FXDragType *xdndTypeList; // XDND type list FXuint xdndNumTypes; // XDND number of types FXID xdndProxy; // XDND proxy atom FXID xdndAware; // XDND awareness atom FXID xdndEnter; // XDND enter window message FXID xdndLeave; // XDND leave window message FXID xdndPosition; // XDND position update message FXID xdndStatus; // XDND status feedback message FXID xdndDrop; // XDND drop message FXID xdndFinished; // XDND finished message FXID xdndSelection; // XDND selection atom FXID xdndTypes; // XDND type list atom FXID xdndActions; // XDND action list atom FXID xdndActionList[6]; // XDND actions FXID xdndSource; // XDND drag source window FXID xdndTarget; // XDND drop target window FXID xdndProxyTarget; // XDND window to set messages to FXbool xdndStatusPending; // XDND waiting for status feedback FXbool xdndStatusReceived; // XDND received at least one status FXbool xdndWantUpdates; // XDND target wants new positions while in rect FXbool xdndFinishSent; // XDND finish sent FXRectangle xdndRect; // XDND rectangle bounding target FXint xrrScreenChange; // Xrandr ScreenChange event FXint xfxFixesSelection; // Xfixes selection event FXint xInputOpcode; // XInput2 opcode FXint xsbDevice; // Space ball input device id FXID stipples[23]; // Standard stipple patterns void *xim; // Input method FXbool shmi; // Use XSHM Image possible FXbool shmp; // Use XSHM Pixmap possible FXbool xrender; // XRender available FXbool synchronize; // Synchronized #endif private: // Internal helper functions FXApp(const FXApp&); FXApp &operator=(const FXApp&); static void CDECL signalhandler(int sig); static void CDECL immediatesignalhandler(int sig); void leaveWindow(FXWindow *window,FXWindow *ancestor); void enterWindow(FXWindow *window,FXWindow *ancestor); void selectionSetData(const FXWindow* window,FXDragType type,FXuchar* data,FXuint size); void selectionGetData(const FXWindow* window,FXDragType type,FXuchar*& data,FXuint& size); void selectionGetTypes(const FXWindow* window,FXDragType*& types,FXuint& numtypes); void clipboardSetData(const FXWindow* window,FXDragType type,FXuchar* data,FXuint size); void clipboardGetData(const FXWindow* window,FXDragType type,FXuchar*& data,FXuint& size); void clipboardGetTypes(const FXWindow* window,FXDragType*& types,FXuint& numtypes); void dragdropSetData(const FXWindow* window,FXDragType type,FXuchar* data,FXuint size); void dragdropGetData(const FXWindow* window,FXDragType type,FXuchar*& data,FXuint& size); void dragdropGetTypes(const FXWindow* window,FXDragType*& types,FXuint& numtypes); void openInputDevices(); void closeInputDevices(); #ifdef WIN32 static FXival CALLBACK wndproc(FXID hwnd,FXuint iMsg,FXuval wParam,FXival lParam); protected: virtual FXival dispatchEvent(FXID hwnd,FXuint iMsg,FXuval wParam,FXival lParam); #else void addRepaint(FXID win,FXint x,FXint y,FXint w,FXint h,FXbool synth=false); void removeRepaints(FXID win,FXint x,FXint y,FXint w,FXint h); void scrollRepaints(FXID win,FXint dx,FXint dy); static void imcreatecallback(void*,FXApp*,void*); static void imdestroycallback(void*,FXApp*,void*); #endif protected: /// Return true if an event arrives within blocking nanoseconds virtual FXbool getNextEvent(FXRawEvent& ev,FXTime blocking=forever); /// Dispatch raw event virtual FXbool dispatchEvent(FXRawEvent& ev); public: long onCmdQuit(FXObject*,FXSelector,void*); long onCmdDump(FXObject*,FXSelector,void*); long onCmdHover(FXObject*,FXSelector,void*); public: /// Messages applications understand enum { ID_QUIT=1, /// Terminate the application normally ID_DUMP, /// Dump the current widget tree ID_HOVER, ID_LAST }; public: /// Copyright information static const FXuchar copyright[]; public: /** * Construct application object; the name and vendor strings are used * as keys into the registry database for this application's settings. * Only one single application object can be constructed. */ FXApp(const FXString& name="Application",const FXString& vendor=FXString::null); /// Change application name void setAppName(const FXString& name); /// Get application name const FXString& getAppName() const; /// Change vendor name void setVendorName(const FXString& name); /// Get vendor name const FXString& getVendorName() const; /// Return true if input method support FXbool hasInputMethod() const; /// Change default visual void setDefaultVisual(FXVisual* vis); /// Get default visual FXVisual* getDefaultVisual() const { return defaultVisual; } /// Get monochrome visual FXVisual* getMonoVisual() const { return monoVisual; } /// Set root Window void setRootWindow(FXRootWindow* rt); /// Get root Window FXRootWindow* getRootWindow() const { return root; } /// Return window at the end of the focus chain FXWindow *getFocusWindow() const; /// Get the window under the cursor, if any FXWindow *getCursorWindow() const { return cursorWindow; } /// Get the active toplevel window, if any FXWindow *getActiveWindow() const { return activeWindow; } /// Get current popup window, if any FXPopup* getPopupWindow() const { return popupWindow; } /// Return window currently owning primary selection FXWindow* getSelectionWindow() const { return selectionWindow; } /// Return window currently owning the clipboard FXWindow* getClipboardWindow() const { return clipboardWindow; } /// Return drag window if a drag operation is in progress FXWindow* getDragWindow() const { return dragWindow; } /// Find window from id FXWindow* findWindowWithId(FXID xid) const; /// Find window from root x,y, starting from given window FXWindow* findWindowAt(FXint rx,FXint ry,FXID window=0) const; /// Change default font void setNormalFont(FXFont* font); /// Return default font FXFont* getNormalFont() const { return normalFont; } /// Begin of wait-cursor block; wait-cursor blocks may be nested. void beginWaitCursor(); /// End of wait-cursor block void endWaitCursor(); /// Change to a new wait cursor void setWaitCursor(FXCursor *cur); /// Return current wait cursor FXCursor* getWaitCursor() const { return waitCursor; } /// Change default cursor void setDefaultCursor(FXDefaultCursor which,FXCursor* cur); /// Obtain a default cursor FXCursor* getDefaultCursor(FXDefaultCursor which) const { return cursor[which]; } /// Register new DND type FXDragType registerDragType(const FXString& name) const; /// Get drag type name FXString getDragTypeName(FXDragType type) const; /** * Change message translator. * The new translator will be owned by FXApp. */ void setTranslator(FXTranslator* trans); /** * Return message translator. */ FXTranslator* getTranslator() const { return translator; } /// Return pointer void* getDisplay() const { return display; } /// Connection to display; this is called by init() virtual FXbool openDisplay(const FXchar* dpy=nullptr); /// Close connection to the display virtual FXbool closeDisplay(); /** * Add timeout message sel to be sent to target object tgt after an interval of ns * nanoseconds; the timer fires only once after the interval expires. * The void* ptr is user data which will be passed into the void* ptr of the message * handler. * If a timer with the same target and message already exists, it will be rescheduled. * Note: the smallest interval that one can wait is actually much larger * than a nanosecond; on Unix systems, the smallest interval is about 1000 ns, * whereas on Windows, it is about 1000000 ns. * Return data pointer from original timeout, if any. */ FXptr addTimeout(FXObject* tgt,FXSelector sel,FXTime ns=1000000000,FXptr ptr=nullptr); /** * Add deadline timeout message sel to be sent to target object tgt when the due time, * expressed in nanoseconds since Epoch (Jan 1, 1970), is reached. * This is the preferred way to schedule regularly occuring events, as the exact time of issue will * not suffer accumulating errors as with the addTimeout() method. However, it is important to ensure * that the due time is sufficiently far into the future, as otherwise the system may be swamped * executing nothing but timeout messages. * Return data pointer from original timeout, if any. */ FXptr addDeadline(FXObject* tgt,FXSelector sel,FXTime due=forever,FXptr ptr=nullptr); /** * Remove timeout identified by target object tgt and message sel; if sel=0, remove all timeouts which * reference object tgt. * Return data pointer from original timeout, if any. */ FXptr removeTimeout(FXObject* tgt,FXSelector sel=0); /** * Return true if a timeout with target object tgt and message sel has been set; * if sel=0, return true if any timeout has been set with target object tgt. */ FXbool hasTimeout(FXObject *tgt,FXSelector sel=0) const; /** * Return the time (in nanoseconds) remaining until the timer identified by target object * tgt and message sel will fire. * If the timer is past due, 0 is returned. If there is no such timer, the constant * forever (LLONG_MAX) is returned. If sel=0, return the earliest timeout that will be * received by target object tgt. */ FXTime remainingTimeout(FXObject *tgt,FXSelector sel=0) const; /** * Add a chore message sel to be sent to target object tgt when * the system becomes idle, i.e. there are no events to be processed. * The void* ptr is user data which will be passed into the void* ptr * of the message handler. If a chore with the same target and message * already exists, it will be rescheduled. * Returns the data pointer from the original chore, if any. */ FXptr addChore(FXObject* tgt,FXSelector sel,FXptr ptr=nullptr); /** * Remove chore identified by target object tgt and message sel; if sel=0, * remove all idle processing messages which reference object tgt. * Returns the data pointer from the original chore, if any. */ FXptr removeChore(FXObject* tgt,FXSelector sel=0); /** * Return true if a chore with target object tgt and message sel has been set; * if sel=0, return true if any chore has been set with target object tgt. */ FXbool hasChore(FXObject *tgt,FXSelector sel=0) const; /** * Add signal processing message to be sent to target object when * the signal sig is raised; flags are to be set as per POSIX definitions. * When immediate is true, the message will be sent to the target right away; * this should be used with extreme care as the application is interrupted * at an unknown point in its execution. */ void addSignal(FXint sig,FXObject* tgt,FXSelector sel,FXbool immediate=false,FXuint flags=0); /// Remove signal message for signal sig void removeSignal(FXint sig); /** * Add a file descriptor fd to be watched for activity as determined by * mode, where mode is a bitwise OR of (INPUT_READ, INPUT_WRITE, INPUT_EXCEPT). * A message of type SEL_IO_READ, SEL_IO_WRITE, or SEL_IO_EXCEPT will be sent * to the target when the specified activity is detected on the file descriptor; * the void* ptr is user data which will be passed into the void* ptr of the * mesage handler; often you will want to pass the file descriptor fd itself * as the value for ptr so that the message handler knows which file descriptor * is involved. */ FXbool addInput(FXObject *tgt,FXSelector sel,FXInputHandle fd,FXuint mode=INPUT_READ,FXptr ptr=nullptr); /** * Remove input message and target object for the specified file descriptor * and mode, which is a bitwise OR of (INPUT_READ, INPUT_WRITE, INPUT_EXCEPT). * Omitting the last parameter will delete all the handlers associated with the * file descriptor. */ FXbool removeInput(FXInputHandle fd,FXuint mode=INPUT_READ); /// Return key state of given key FXbool getKeyState(FXuint keysym) const; /// Peek to determine if there's an event FXbool peekEvent(); /// Perform one event dispatch; return true if event was dispatched FXbool runOneEvent(FXTime blocking=forever); /** * Run the main application event loop until stop() is called, * and return the exit code passed as argument to stop(). */ FXint run(); /** * Run an event loop till some flag becomes non-zero, and * then return. */ FXint runUntil(FXuint& condition); /** * Run non-modal event loop while events arrive within blocking nanoseconds. * Returns when no new events arrive in this time, and no timers, or chores * are outstanding. */ FXint runWhileEvents(FXTime blocking=0); /** * Run modal event loop while events arrive within blocking nanoseconds. * Returns 1 when all events in the queue have been handled, and 0 when * the event loop was terminated due to stop() or stopModal(). * Except for the modal window and its children, user input to all windows * is blocked; if the modal window is NULL, all user input is blocked. */ FXint runModalWhileEvents(FXWindow* window=nullptr,FXTime blocking=0); /** * Run modal event loop, blocking keyboard and mouse events to all windows * until stopModal is called. */ FXint runModal(); /** * Run a modal event loop for the given window, until stop() or stopModal() is * called. Except for the modal window and its children, user input to all * windows is blocked; if the modal window is NULL all user input is blocked. */ FXint runModalFor(FXWindow* window); /** * Run modal while window is shown, or until stop() or stopModal() is called. * Except for the modal window and its children, user input to all windows * is blocked; if the modal window is NULL all user input is blocked. */ FXint runModalWhileShown(FXWindow* window); /** * Run popup menu while shown, until stop() or stopModal() is called. * Also returns when entering previous cascading popup menu. */ FXint runPopup(FXWindow* window); /// True if the window is modal FXbool isModal(FXWindow* window) const; /// Return window of current modal loop FXWindow* getModalWindow() const; /// Return mode of current modal loop FXModality getModality() const; /** * Terminate the outermost event loop, and all inner modal loops; * All more deeper nested event loops will be terminated with code equal * to 0, while the outermost event loop will return code equal to value. */ void stop(FXint value=0); /** * Break out of the matching modal loop, returning code equal to value. * All deeper nested event loops are terminated with code equal to 0. */ void stopModal(FXWindow* window,FXint value=0); /** * Break out of the innermost modal loop, returning code equal to value. */ void stopModal(FXint value=0); /** * Schedule SEL_UPDATE refreshes on the entire widget tree, to be * performed at some future time. */ void refresh(); /** * Perform SEL_UPDATE refreshes on the entire widget tree immediately. */ void forceRefresh(); /** * Flush drawing commands to display; if sync then wait till drawing commands * have been performed. */ void flush(FXbool sync=false); /** * Paint all windows marked for repainting. * On return all the applications windows have been painted. */ void repaint(); /// Get argument count FXint getArgc() const { return appArgc; } /// Get argument vector const FXchar *const *getArgv() const { return appArgv; } /// Has application been initialized FXbool isInitialized() const { return initialized; } /** * Initialize application. * Parses and removes common command line arguments, reads the registry. * Finally, if connect is true, it opens the display. */ virtual void init(int& argc,char** argv,FXbool connect=true); /** * Exit application. * Closes the display and writes the registry. */ virtual void exit(FXint code=0); /** * Return a reference to the registry. The registry keeps * settings and configuration information for an application, * which are automatically loaded when the application starts * up, and saved when the application terminates. */ FXRegistry& reg(){ return registry; } /** * Return a reference to the application-wide mutex. * Normally, the main user interface thread holds this mutex, * insuring that no other threads are modifying data during the * processing of user interface messages. However, whenever the * main user interface thread blocks for messages, it releases * this mutex, to allow other threads to modify the same data. * When a new message becomes available, the main user interface * thread regains the mutex prior to dispatching the message. * Other threads should hold this mutex only for short durations, * so as to not starve the main user interface thread. */ FXMutex& mutex(){ return appMutex; } /// Beep the speaker void beep(); /// Obtain application-wide timing constants, in nanoseconds FXTime getTypingSpeed() const { return typingSpeed; } FXTime getClickSpeed() const { return clickSpeed; } FXTime getScrollSpeed() const { return scrollSpeed; } FXTime getScrollDelay() const { return scrollDelay; } FXTime getBlinkSpeed() const { return blinkSpeed; } FXTime getAnimSpeed() const { return animSpeed; } FXTime getMenuPause() const { return menuPause; } FXTime getToolTipPause() const { return toolTipPause; } FXTime getToolTipTime() const { return toolTipTime; } FXTime getAutoHideDelay() const { return autoHideDelay; } /// Change application-wide timing constants, in nanoseconds void setTypingSpeed(FXTime speed); void setClickSpeed(FXTime speed); void setScrollSpeed(FXTime speed); void setScrollDelay(FXTime delay); void setBlinkSpeed(FXTime speed); void setAnimSpeed(FXTime speed); void setMenuPause(FXTime pause); void setToolTipPause(FXTime pause); void setToolTipTime(FXTime time); void setAutoHideDelay(FXTime time); /// Access drag hysteresis void setDragDelta(FXint delta); FXint getDragDelta() const { return dragDelta; } /// Access mouse wheel scroll lines void setWheelLines(FXint lines); FXint getWheelLines() const { return wheelLines; } /// Access scroll bar slot size void setScrollBarSize(FXint size); FXint getScrollBarSize() const { return scrollBarSize; } /// Obtain default colors FXColor getBorderColor() const { return borderColor; } FXColor getBaseColor() const { return baseColor; } FXColor getHiliteColor() const { return hiliteColor; } FXColor getShadowColor() const { return shadowColor; } FXColor getBackColor() const { return backColor; } FXColor getForeColor() const { return foreColor; } FXColor getSelforeColor() const { return selforeColor; } FXColor getSelbackColor() const { return selbackColor; } FXColor getTipforeColor() const { return tipforeColor; } FXColor getTipbackColor() const { return tipbackColor; } FXColor getSelMenuTextColor() const { return selMenuTextColor; } FXColor getSelMenuBackColor() const { return selMenuBackColor; } /// Change default colors void setBorderColor(FXColor color); void setBaseColor(FXColor color); void setHiliteColor(FXColor color); void setShadowColor(FXColor color); void setBackColor(FXColor color); void setForeColor(FXColor color); void setSelforeColor(FXColor color); void setSelbackColor(FXColor color); void setTipforeColor(FXColor color); void setTipbackColor(FXColor color); void setSelMenuTextColor(FXColor color); void setSelMenuBackColor(FXColor color); /// Get number of existing windows FXuint getWindowCount() const { return windowCount; } /// Create application's windows virtual void create(); /// Destroy application's windows virtual void destroy(); /// Detach application's windows virtual void detach(); /// Save virtual void save(FXStream& store) const; /// Load virtual void load(FXStream& store); /// Dump widget information void dumpWidgets() const; /// Return application instance static inline FXApp* instance(){ return app; } /// Destroy the application and all reachable resources virtual ~FXApp(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXArray.h000066400000000000000000000203111455751074500221430ustar00rootroot00000000000000/******************************************************************************** * * * G e n e r i c A r r a y * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXARRAY_H #define FXARRAY_H #ifndef FXELEMENT_H #include "FXElement.h" #endif namespace FX { /// ArrayBase manages a memory buffer class FXAPI FXArrayBase { protected: FXptr ptr; protected: FXArrayBase(); FXbool resize(FXival num,FXival sz); ~FXArrayBase(); }; /// Array of some generic type template class FXArray : public FXArrayBase { public: /// Allocate initially empty array FXArray(){ } /// Allocate array of n elements FXArray(FXival n){ no(n); } /// Allocate array copied from another FXArray(const FXArray& src){ if(no(src.no())){ copyElms(data(),src.data(),src.no()); } } /// Allocate initialized with n copies of object FXArray(const EType& src,FXival n){ if(no(n)){ fillElms(data(),src,n); } } /// Allocate initialized with array of n objects FXArray(const EType* src,FXival n){ if(no(n)){ copyElms(data(),src,n); } } /// Return number of items FXival no() const { return *(((FXival*)ptr)-1); } /// Change number of elements in array to n FXbool no(FXival n){ FXival m=no(); if((n-m)>0){ if(!resize(n,sizeof(EType))) return false; constructElms(&at(m),n-m); } else if((m-n)>0){ destructElms(&at(n),m-n); if(!resize(n,sizeof(EType))) return false; } return true; } /// Assign from another array FXArray& operator=(const FXArray& src){ if(data()!=src.data() && no(src.no())){ copyElms(data(),src.data(),src.no()); } return *this; } /// Return pointer to array EType* data(){ return reinterpret_cast(ptr); } const EType* data() const { return reinterpret_cast(ptr); } /// Index into array EType& operator[](FXival i){ return data()[i]; } const EType& operator[](FXival i) const { return data()[i]; } /// Index into array EType& at(FXival i){ return data()[i]; } const EType& at(FXival i) const { return data()[i]; } /// First element in array EType& head(){ return data()[0]; } const EType& head() const { return data()[0]; } /// Last element in array EType& tail(){ return data()[no()-1]; } const EType& tail() const { return data()[no()-1]; } /// Adopt array from another one; the other array becomes empty FXArray& adopt(FXArray& src){ if(ptr!=src.ptr && no(0)){ swap(ptr,src.ptr); } return *this; } /// Assign object p to array FXbool assign(const EType& src){ if(no(1)){ head()=src; return true; } return false; } /// Assign n copies of object to array FXbool assign(const EType& src,FXival n){ if(no(n)){ fillElms(data(),src,n); return true; } return false; } /// Assign n objects to list FXbool assign(const EType* src,FXival n){ if(no(n)){ copyElms(data(),src,n); return true; } return false; } /// Assign n objects to list FXbool assign(const FXArray& src){ return assign(src.data(),src.no()); } /// Insert an object FXbool insert(FXival pos,const EType& src){ if(no(no()+1)){ moveElms(data()+pos+1,data()+pos,no()-pos-1); at(pos)=src; return true; } return false; } /// Insert n copies of object at specified position FXbool insert(FXival pos,const EType& src,FXival n){ if(no(no()+n)){ moveElms(data()+pos+n,data()+pos,no()-pos-n); fillElms(data()+pos,src,n); return true; } return false; } /// Insert n objects at specified position FXbool insert(FXival pos,const EType* src,FXival n){ if(no(no()+n)){ moveElms(data()+pos+n,data()+pos,no()-pos-n); copyElms(data()+pos,src,n); return true; } return false; } /// Insert n objects at specified position FXbool insert(FXival pos,const FXArray& src){ return insert(pos,src.data(),src.no()); } /// Prepend object FXbool prepend(const EType& src){ if(no(no()+1)){ moveElms(data()+1,data(),no()-1); head()=src; return true; } return false; } /// Prepend n copies of object FXbool prepend(const EType& src,FXival n){ if(no(no()+n)){ moveElms(data()+n,data(),no()-n); fillElms(data(),src,n); return true; } return false; } /// Prepend n objects FXbool prepend(const EType* src,FXival n){ if(no(no()+n)){ moveElms(data()+n,data(),no()-n); copyElms(data(),src,n); return true; } return false; } /// Prepend n objects FXbool prepend(const FXArray& src){ return prepend(src.data(),src.no()); } /// Append object FXbool append(const EType& src){ if(no(no()+1)){ tail()=src; return true; } return false; } /// Append n copies of object FXbool append(const EType& src,FXival n){ if(no(no()+n)){ fillElms(data()+no()-n,src,n); return true; } return false; } /// Append n objects FXbool append(const EType* src,FXival n){ if(no(no()+n)){ copyElms(data()+no()-n,src,n); return true; } return false; } /// Append n objects FXbool append(const FXArray& src){ return append(src.data(),src.no()); } /// Replace an object by other object FXbool replace(FXival pos,const EType& src){ at(pos)=src; return true; } /// Replace the m objects at pos with n copies of other object FXbool replace(FXival pos,FXival m,const EType& src,FXival n){ if(mn){ moveElms(data()+pos+n,data()+pos+m,no()-pos-m); if(!no(no()-m+n)) return false; } fillElms(data()+pos,src,n); return true; } /// Replace m objects at pos by n other objects FXbool replace(FXival pos,FXival m,const EType* src,FXival n){ if(mn){ moveElms(data()+pos+n,data()+pos+m,no()-pos-m); if(!no(no()-m+n)) return false; } copyElms(data()+pos,src,n); return true; } /// Replace m objects at pos by other objects FXbool replace(FXival pos,FXival m,const FXArray& src){ return replace(pos,m,src.data(),src.no()); } /// Remove object at pos FXbool erase(FXival pos){ moveElms(data()+pos,data()+pos+1,no()-pos-1); return no(no()-1); } /// Remove n objects starting at pos FXbool erase(FXival pos,FXival n){ moveElms(data()+pos,data()+pos+n,no()-pos-n); return no(no()-n); } /// Push object to end FXbool push(const EType& src){ if(no(no()+1)){ tail()=src; return true; } return false; } /// Pop object from end FXbool pop(){ return no(no()-1); } /// Remove all objects FXbool clear(){ return no(0); } /// Delete data ~FXArray(){ clear(); } }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXArrowButton.h000066400000000000000000000142321455751074500233600ustar00rootroot00000000000000/******************************************************************************** * * * A r r o w B u t t o n W i d g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXARROWBUTTON_H #define FXARROWBUTTON_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { // Arrow style options enum { ARROW_NONE = 0, // No arrow ARROW_UP = 0x00080000, // Arrow points up ARROW_DOWN = 0x00100000, // Arrow points down ARROW_LEFT = 0x00200000, // Arrow points left ARROW_RIGHT = 0x00400000, // Arrow points right ARROW_AUTO = 0x00800000, // Automatically fire when hovering mouse over button ARROW_REPEAT = 0x01000000, // Button repeats if held down ARROW_AUTOGRAY = 0x02000000, // Automatically gray out when not updated ARROW_AUTOHIDE = 0x04000000, // Automatically hide when not updated ARROW_TOOLBAR = 0x08000000, // Button is toolbar-style ARROW_NORMAL = FRAME_RAISED|FRAME_THICK|ARROW_UP }; /** * Button with an arrow; the arrow can point in any direction. * When clicked, the arrow button sends a SEL_COMMAND to its target. * When ARROW_REPEAT is passed, the arrow button sends a SEL_COMMAND * repeatedly while the button is pressed. * The option ARROW_AUTO together with ARROW_REPEAT makes the arrow * button work in repeat mode simply by hovering the cursor over it. */ class FXAPI FXArrowButton : public FXFrame { FXDECLARE(FXArrowButton) protected: FXColor arrowColor; // Arrow color FXint arrowSize; // Arrow size FXString tip; // Tooltip value FXString help; // Help value FXbool state; // State of button FXbool fired; // Timer has fired protected: FXArrowButton(); private: FXArrowButton(const FXArrowButton&); FXArrowButton &operator=(const FXArrowButton&); public: long onPaint(FXObject*,FXSelector,void*); long onUpdate(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onRepeat(FXObject*,FXSelector,void*); long onAuto(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onHotKeyPress(FXObject*,FXSelector,void*); long onHotKeyRelease(FXObject*,FXSelector,void*); long onCmdSetHelp(FXObject*,FXSelector,void*); long onCmdGetHelp(FXObject*,FXSelector,void*); long onCmdSetTip(FXObject*,FXSelector,void*); long onCmdGetTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); public: enum { ID_REPEAT=FXFrame::ID_LAST, ID_AUTO, ID_LAST }; public: /// Construct arrow button FXArrowButton(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=ARROW_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Get default width virtual FXint getDefaultWidth(); /// Get default height virtual FXint getDefaultHeight(); /// Enable the button virtual void enable(); /// Disable the button virtual void disable(); /// Returns true because a button can receive focus virtual FXbool canFocus() const; /// Set the button state (where true means the button is down) void setState(FXbool s); /// Get the button state (where true means the button is down) FXbool getState() const { return state; } /// Set status line help text for this arrow button void setHelpText(const FXString& text){ help=text; } /// Get status line help text for this arrow button const FXString& getHelpText() const { return help; } /// Set tool tip message for this arrow button void setTipText(const FXString& text){ tip=text; } /// Get tool tip message for this arrow button const FXString& getTipText() const { return tip; } /// Set the arrow style flags void setArrowStyle(FXuint style); /// Get the arrow style flags FXuint getArrowStyle() const; /// Set the default arrow size void setArrowSize(FXint size); /// Get the default arrow size FXint getArrowSize() const { return arrowSize; } /// Set the current justification mode. void setJustify(FXuint mode); /// Get the current justification mode. FXuint getJustify() const; /// Get the fill color for the arrow FXColor getArrowColor() const { return arrowColor; } /// Set the fill color for the arrow void setArrowColor(FXColor clr); /// Save label to a stream virtual void save(FXStream& store) const; /// Load label from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXArrowButton(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXAtomic.h000066400000000000000000000167451455751074500223210ustar00rootroot00000000000000/******************************************************************************** * * * A t o m i c O p e r a t i o n s * * * ********************************************************************************* * Copyright (C) 2006,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXATOMIC_H #define FXATOMIC_H namespace FX { /** * Atomics are available . * Only single-threaded code works properly if this returns false. */ extern FXAPI FXbool atomicsAvailable(); ///// Memory fence /** * Load/store fence. * Memory load and stores are executed before returning from this * function. */ extern FXAPI void atomicThreadFence(); ///// Atomic integers /// Atomic read extern FXAPI FXint atomicRead(volatile FXint* ptr); /// Atomic write, ensure visibility of written variable extern FXAPI void atomicWrite(volatile FXint* ptr,FXint v); /// Atomically set variable at ptr to v, and return its old contents extern FXAPI FXint atomicSet(volatile FXint* ptr,FXint v); /// Atomically add v to variable at ptr, and return its old contents extern FXAPI FXint atomicAdd(volatile FXint* ptr,FXint v); /// Atomically compare variable at ptr against expect, setting it to v if equal; returns the old value at ptr extern FXAPI FXint atomicCas(volatile FXint* ptr,FXint expect,FXint v); /// Atomically compare variable at ptr against expect, setting it to v if equal and return true, or false otherwise extern FXAPI FXbool atomicBoolCas(volatile FXint* ptr,FXint expect,FXint v); ///// Atomic unsigned integers /// Atomic read extern FXAPI FXuint atomicRead(volatile FXuint* ptr); /// Atomic write, ensure visibility of written variable extern FXAPI void atomicWrite(volatile FXuint* ptr,FXuint v); /// Atomically set variable at ptr to v, and return its old contents extern FXAPI FXuint atomicSet(volatile FXuint* ptr,FXuint v); /// Atomically add v to variable at ptr, and return its old contents extern FXAPI FXuint atomicAdd(volatile FXuint* ptr,FXuint v); /// Atomically compare variable at ptr against expect, setting it to v if equal; returns the old value at ptr extern FXAPI FXuint atomicCas(volatile FXuint* ptr,FXuint expect,FXuint v); /// Atomically compare variable at ptr against expect, setting it to v if equal and return true, or false otherwise extern FXAPI FXbool atomicBoolCas(volatile FXuint* ptr,FXuint expect,FXuint v); ///// Atomic longs /// Atomically set variable at ptr to v, and return its old contents extern FXAPI FXlong atomicSet(volatile FXlong* ptr,FXlong v); /// Atomically add v to variable at ptr, and return its old contents extern FXAPI FXlong atomicAdd(volatile FXlong* ptr,FXlong v); /// Atomically compare variable at ptr against expect, setting it to v if equal; returns the old value at ptr extern FXAPI FXlong atomicCas(volatile FXlong* ptr,FXlong expect,FXlong v); /// Atomically compare variable at ptr against expect, setting it to v if equal and return true, or false otherwise extern FXAPI FXbool atomicBoolCas(volatile FXlong* ptr,FXlong expect,FXlong v); ///// Atomic unsigned longs /// Atomically set variable at ptr to v, and return its old contents extern FXAPI FXulong atomicSet(volatile FXulong* ptr,FXulong v); /// Atomically add v to variable at ptr, and return its old contents extern FXAPI FXulong atomicAdd(volatile FXulong* ptr,FXulong v); /// Atomically compare variable at ptr against expect, setting it to v if equal; returns the old value at ptr extern FXAPI FXulong atomicCas(volatile FXulong* ptr,FXulong expect,FXulong v); /// Atomically compare variable at ptr against expect, setting it to v if equal and return true, or false otherwise extern FXAPI FXbool atomicBoolCas(volatile FXulong* ptr,FXulong expect,FXulong v); ///// Atomic void pointers /// Atomic read extern FXAPI FXptr atomicRead(volatile FXptr* ptr); /// Atomic write, ensure visibility of written variable extern FXAPI void atomicWrite(volatile FXptr* ptr,FXptr v); /// Atomically set pointer variable at ptr to v, and return its old contents extern FXAPI FXptr atomicSet(volatile FXptr* ptr,FXptr v); /// Atomically add v to pointer variable at ptr, and return its old contents extern FXAPI FXptr atomicAdd(volatile FXptr* ptr,FXival v); /// Atomically compare pointer variable at ptr against expect, setting it to v if equal; returns the old value at ptr extern FXAPI FXptr atomicCas(volatile FXptr* ptr,FXptr expect,FXptr v); /// Atomically compare pointer variable at ptr against expect, setting it to v if equal and return true, or false otherwise extern FXAPI FXbool atomicBoolCas(volatile FXptr* ptr,FXptr expect,FXptr v); /// Atomically compare pair of variables at ptr against (cmpa,cmpb), setting them to (a,b) if equal and return true, or false otherwise extern FXAPI FXbool atomicBoolDCas(volatile FXptr* ptr,FXptr cmpa,FXptr cmpb,FXptr a,FXptr b); ///// Atomic pointers to something else /// Atomically set pointer variable at ptr to v, and return its old contents template inline EType* atomicSet(EType *volatile *ptr,EType* v){ return (EType*)atomicSet((volatile FXptr*)ptr,(FXptr)v); } /// Atomically add v to pointer variable at ptr, and return its old contents template inline EType* atomicAdd(EType *volatile *ptr,FXival v){ return (EType*)atomicAdd((volatile FXptr*)ptr,v*((FXival)sizeof(EType))); } /// Atomically compare pointer variable at ptr against expect, setting it to v if equal; returns the old value at ptr template inline EType* atomicCas(EType *volatile *ptr,EType* expect,EType* v){ return (EType*)atomicCas((volatile FXptr*)ptr,(FXptr)expect,(FXptr)v); } /// Atomically compare pointer variable at ptr against expect, setting it to v if equal and return true, or false otherwise template inline FXbool atomicBoolCas(EType *volatile *ptr,EType* expect,EType* v){ return atomicBoolCas((volatile FXptr*)ptr,(FXptr)expect,(FXptr)v); } /// Atomically compare pair of variables at ptr against (cmpa,cmpb), setting them to (a,b) if equal and return true, or false otherwise template inline FXbool atomicBoolDCas(EType *volatile *ptr,EType* cmpa,EType* cmpb,EType* a,EType* b){ return atomicBoolDCas((volatile FXptr*)ptr,(FXptr)cmpa,(FXptr)cmpb,(FXptr)a,(FXptr)b); } } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXAutoPtr.h000066400000000000000000000102711455751074500224670ustar00rootroot00000000000000/******************************************************************************** * * * A u t o m a t i c P o i n t e r * * * ********************************************************************************* * Copyright (C) 2007,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXAUTOPTR_H #define FXAUTOPTR_H namespace FX { /// Implicitly used FXAutoPtrRef to hand FXAutoPtr through implicitly called /// constructors and conversion operators. Probably not used directly. template struct FXAutoPtrRef { EType* ptr; explicit FXAutoPtrRef(EType* src):ptr(src){ } }; /// Automatic pointer template class FXAutoPtr { private: EType* ptr; public: /// Construct from optional pointer explicit FXAutoPtr(EType* src=nullptr):ptr(src){ } /// Construct from another automatic pointer FXAutoPtr(FXAutoPtr& src):ptr(src.release()){ } /// Construct from FXAutoPtrRef FXAutoPtr(FXAutoPtrRef src):ptr(src.ptr){ } /// Construct from another automatic pointer of compatible type template explicit FXAutoPtr(FXAutoPtr& src):ptr(src.release()){ } /// Assign from pointer FXAutoPtr& operator=(EType *src){ return reset(src); } /// Assign from an another automatic pointer FXAutoPtr& operator=(FXAutoPtr& src){ return reset(src.release()); } /// Assign from FXAutoPtrRef FXAutoPtr& operator=(FXAutoPtrRef src){ if(src.ptr!=ptr){ delete ptr; ptr=src.ptr; } return *this; } /// Assign from an automatic pointer with compatible type template FXAutoPtr& operator=(FXAutoPtr& src){ return reset(src.release()); } /// Conversion operators operator EType*() const { return ptr; } /// Conversion to FXAutoPtr of another type T template operator FXAutoPtr() throw() { return FXAutoPtr(this->release()); } /// Conversion to FXAutoPtrRef of another type T template operator FXAutoPtrRef() throw() { return FXAutoPtrRef(this->release()); } /// Dereference operator EType& operator*() const { return *ptr; } /// Follow pointer operator EType* operator->() const { return ptr; } /// Array indexing EType& operator[](FXint i) const { return ptr[i]; } /// Release hold on the pointer EType* release(){ EType* tmp=ptr; ptr=nullptr; return tmp; } /// Delete old object, replace by new, if any FXAutoPtr& reset(EType* p=nullptr){ if(p!=ptr){ delete ptr; ptr=p; } return *this; } /// Destruction deletes pointer ~FXAutoPtr(){ delete ptr; } }; /// Serialize of automatic pointer template FXStream& operator<<(FXStream& store,const FXAutoPtr& obj){ EType *temp=obj; store << temp; return store; } /// Deserialize of automatic pointer template FXStream& operator>>(FXStream& store,FXAutoPtr& obj){ EType *temp; store >> temp; obj=temp; return store; } } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXAutoThreadStorageKey.h000066400000000000000000000055551455751074500251400ustar00rootroot00000000000000/******************************************************************************** * * * T h r e a d - L o c a l S t o r a g e C l a s s * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXAUTOTHREADSTORAGEKEY_H #define FXAUTOTHREADSTORAGEKEY_H namespace FX { /** * Automatically generated thread-local storage key. * * This class manages a thread-local storage key, generating * a new one when constructed, and deleting the storage key when * destroyed; FXAutoThreadStorageKey is typically used to declare * global variables to be used as thread-local storage keys. * These keys can be used just like FXThreadStorageKey itself by * virtue of the conversion operator. Note that no assignment * or copy-constructors have been defined; thus each instance of * this class represents a unique thread-local storage key. */ class FXAPI FXAutoThreadStorageKey { private: FXThreadStorageKey value; private: FXAutoThreadStorageKey(const FXAutoThreadStorageKey&); FXAutoThreadStorageKey &operator=(const FXAutoThreadStorageKey&); public: /// Acquire a unique thread-local storage key FXAutoThreadStorageKey(); /// Return the thread-local storage key operator FXThreadStorageKey() const { return value; } /// Set thread local storage associated with this key void set(FXptr ptr) const; /// Get thread local storage associated with this key FXptr get() const; /// Release thread-local storage key ~FXAutoThreadStorageKey(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXBMPIcon.h000066400000000000000000000074421455751074500223260ustar00rootroot00000000000000/******************************************************************************** * * * B M P I c o n O b j e c t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXBMPICON_H #define FXBMPICON_H #ifndef FXICON_H #include "FXIcon.h" #endif namespace FX { /** * The BMP Icon class is a convenience class for working with icons in the * Microsoft Bitmap (.bmp) graphics file format. This makes it possible to * use resources created with Windows development tools inside FOX without * need for graphics file format translators. The bitmap loaded handles * 1, 4, and 8 bit paletted bitmaps, 16 and 24 bit RGB bitmaps, and * 32 bit RGBA bitmaps. */ class FXAPI FXBMPIcon : public FXIcon { FXDECLARE(FXBMPIcon) protected: FXBMPIcon(){} private: FXBMPIcon(const FXBMPIcon&); FXBMPIcon &operator=(const FXBMPIcon&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct icon from memory stream formatted in Microsoft BMP format FXBMPIcon(FXApp* a,const FXuchar *pix=nullptr,FXColor clr=FXRGB(192,192,192),FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in Microsoft bitmap format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in Microsoft bitmap format virtual FXbool loadPixels(FXStream& store); /// Destroy icon virtual ~FXBMPIcon(); }; #ifndef FXLOADBMP #define FXLOADBMP /** * Check if stream contains a bitmap, return true if so. */ extern FXAPI FXbool fxcheckBMP(FXStream& store); /** * Load an BMP (Microsoft Bitmap) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadBMP(FXStream& store,FXColor*& data,FXint& width,FXint& height); /** * Save an BMP (Microsoft Bitmap) file to a stream. */ extern FXAPI FXbool fxsaveBMP(FXStream& store,const FXColor *data,FXint width,FXint height); /** * Load DIB (Device Independent Bitmap) file from stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadDIB(FXStream& store,FXColor*& data,FXint& width,FXint& height); /** * Save an DIB (Device Independent Bitmap) file to a stream. */ extern FXAPI FXbool fxsaveDIB(FXStream& store,const FXColor *data,FXint width,FXint height); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXBMPImage.h000066400000000000000000000074241455751074500224600ustar00rootroot00000000000000/******************************************************************************** * * * B M P I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXBMPIMAGE_H #define FXBMPIMAGE_H #ifndef FXIMAGE_H #include "FXImage.h" #endif namespace FX { /** * The BMP Image class is a convenience class for working with images in the * Microsoft Bitmap (.bmp) graphics file format. This makes it possible to * use resources created with Windows development tools inside FOX without * need for graphics file format translators. The bitmap loaded handles * 1, 4, and 8 bit paletted bitmaps, 16 and 24 bit RGB bitmaps, and * 32 bit RGBA bitmaps. */ class FXAPI FXBMPImage : public FXImage { FXDECLARE(FXBMPImage) protected: FXBMPImage(){} private: FXBMPImage(const FXBMPImage&); FXBMPImage &operator=(const FXBMPImage&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct image from memory stream formatted in Microsoft BMP format FXBMPImage(FXApp* a,const FXuchar *pix=nullptr,FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in Microsoft bitmap format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in Microsoft bitmap format virtual FXbool loadPixels(FXStream& store); /// Destroy icon virtual ~FXBMPImage(); }; #ifndef FXLOADBMP #define FXLOADBMP /** * Check if stream contains a bitmap, return true if so. */ extern FXAPI FXbool fxcheckBMP(FXStream& store); /** * Load an BMP (Microsoft Bitmap) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadBMP(FXStream& store,FXColor*& data,FXint& width,FXint& height); /** * Save an BMP (Microsoft Bitmap) file to a stream. */ extern FXAPI FXbool fxsaveBMP(FXStream& store,const FXColor *data,FXint width,FXint height); /** * Load DIB (Device Independent Bitmap) file from stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadDIB(FXStream& store,FXColor*& data,FXint& width,FXint& height); /** * Save an DIB (Device Independent Bitmap) file to a stream. */ extern FXAPI FXbool fxsaveDIB(FXStream& store,const FXColor *data,FXint width,FXint height); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXBZFileStream.h000066400000000000000000000160751455751074500233700ustar00rootroot00000000000000/******************************************************************************** * * * B Z F i l e S t r e a m C l a s s e s * * * ********************************************************************************* * Copyright (C) 1999,2022 by Lyle Johnson. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifdef HAVE_BZ2LIB_H #ifndef FXBZFILESTREAM_H #define FXBZFILESTREAM_H #ifndef FXFILESTREAM_H #include "FXFileStream.h" #endif namespace FX { struct BZBlock; /// BZIP2 compressed file stream class FXAPI FXBZFileStream : public FXFileStream { private: BZBlock *bz; int ac; protected: virtual FXuval writeBuffer(FXuval count); virtual FXuval readBuffer(FXuval count); private: FXBZFileStream(const FXBZFileStream&); FXBZFileStream& operator=(const FXBZFileStream&); public: /// Create BZIP2 file stream FXBZFileStream(const FXObject* cont=nullptr); /// Create and open BZIP2 file stream FXBZFileStream(const FXString& filename,FXStreamDirection save_or_load=FXStreamLoad,FXuval size=8192UL); /// Open file stream FXbool open(const FXString& filename,FXStreamDirection save_or_load=FXStreamLoad,FXuval size=8192UL); /// Flush buffer virtual FXbool flush(); /// Close file stream virtual FXbool close(); /// Get position FXlong position() const { return FXStream::position(); } /// Move to position virtual FXbool position(FXlong,FXWhence){ return false; } /// Save single items to stream FXBZFileStream& operator<<(const FXuchar& v){ FXStream::operator<<(v); return *this; } FXBZFileStream& operator<<(const FXchar& v){ FXStream::operator<<(v); return *this; } FXBZFileStream& operator<<(const FXbool& v){ FXStream::operator<<(v); return *this; } FXBZFileStream& operator<<(const FXushort& v){ FXStream::operator<<(v); return *this; } FXBZFileStream& operator<<(const FXshort& v){ FXStream::operator<<(v); return *this; } FXBZFileStream& operator<<(const FXuint& v){ FXStream::operator<<(v); return *this; } FXBZFileStream& operator<<(const FXint& v){ FXStream::operator<<(v); return *this; } FXBZFileStream& operator<<(const FXfloat& v){ FXStream::operator<<(v); return *this; } FXBZFileStream& operator<<(const FXdouble& v){ FXStream::operator<<(v); return *this; } FXBZFileStream& operator<<(const FXlong& v){ FXStream::operator<<(v); return *this; } FXBZFileStream& operator<<(const FXulong& v){ FXStream::operator<<(v); return *this; } /// Save arrays of items to stream FXBZFileStream& save(const FXuchar* p,FXuval n){ FXStream::save(p,n); return *this; } FXBZFileStream& save(const FXchar* p,FXuval n){ FXStream::save(p,n); return *this; } FXBZFileStream& save(const FXbool* p,FXuval n){ FXStream::save(p,n); return *this; } FXBZFileStream& save(const FXushort* p,FXuval n){ FXStream::save(p,n); return *this; } FXBZFileStream& save(const FXshort* p,FXuval n){ FXStream::save(p,n); return *this; } FXBZFileStream& save(const FXuint* p,FXuval n){ FXStream::save(p,n); return *this; } FXBZFileStream& save(const FXint* p,FXuval n){ FXStream::save(p,n); return *this; } FXBZFileStream& save(const FXfloat* p,FXuval n){ FXStream::save(p,n); return *this; } FXBZFileStream& save(const FXdouble* p,FXuval n){ FXStream::save(p,n); return *this; } FXBZFileStream& save(const FXlong* p,FXuval n){ FXStream::save(p,n); return *this; } FXBZFileStream& save(const FXulong* p,FXuval n){ FXStream::save(p,n); return *this; } /// Load single items from stream FXBZFileStream& operator>>(FXuchar& v){ FXStream::operator>>(v); return *this; } FXBZFileStream& operator>>(FXchar& v){ FXStream::operator>>(v); return *this; } FXBZFileStream& operator>>(FXbool& v){ FXStream::operator>>(v); return *this; } FXBZFileStream& operator>>(FXushort& v){ FXStream::operator>>(v); return *this; } FXBZFileStream& operator>>(FXshort& v){ FXStream::operator>>(v); return *this; } FXBZFileStream& operator>>(FXuint& v){ FXStream::operator>>(v); return *this; } FXBZFileStream& operator>>(FXint& v){ FXStream::operator>>(v); return *this; } FXBZFileStream& operator>>(FXfloat& v){ FXStream::operator>>(v); return *this; } FXBZFileStream& operator>>(FXdouble& v){ FXStream::operator>>(v); return *this; } FXBZFileStream& operator>>(FXlong& v){ FXStream::operator>>(v); return *this; } FXBZFileStream& operator>>(FXulong& v){ FXStream::operator>>(v); return *this; } /// Load arrays of items from stream FXBZFileStream& load(FXuchar* p,FXuval n){ FXStream::load(p,n); return *this; } FXBZFileStream& load(FXchar* p,FXuval n){ FXStream::load(p,n); return *this; } FXBZFileStream& load(FXbool* p,FXuval n){ FXStream::load(p,n); return *this; } FXBZFileStream& load(FXushort* p,FXuval n){ FXStream::load(p,n); return *this; } FXBZFileStream& load(FXshort* p,FXuval n){ FXStream::load(p,n); return *this; } FXBZFileStream& load(FXuint* p,FXuval n){ FXStream::load(p,n); return *this; } FXBZFileStream& load(FXint* p,FXuval n){ FXStream::load(p,n); return *this; } FXBZFileStream& load(FXfloat* p,FXuval n){ FXStream::load(p,n); return *this; } FXBZFileStream& load(FXdouble* p,FXuval n){ FXStream::load(p,n); return *this; } FXBZFileStream& load(FXlong* p,FXuval n){ FXStream::load(p,n); return *this; } FXBZFileStream& load(FXulong* p,FXuval n){ FXStream::load(p,n); return *this; } /// Save object FXBZFileStream& saveObject(const FXObject* v){ FXStream::saveObject(v); return *this; } /// Load object FXBZFileStream& loadObject(FXObject*& v){ FXStream::loadObject(v); return *this; } /// Load object template FXBZFileStream& operator>>(TYPE*& obj){ loadObject(reinterpret_cast(obj)); return *this; } /// Save object template FXBZFileStream& operator<<(const TYPE* obj){ saveObject(static_cast(obj)); return *this; } /// Clean up virtual ~FXBZFileStream(); }; } #endif #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXBarrier.h000066400000000000000000000065011455751074500224600ustar00rootroot00000000000000/******************************************************************************** * * * B a r r i e r C l a s s * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXBARRIER_H #define FXBARRIER_H namespace FX { /** * Barrier with changeable threshold. * A Barrier holds back threads arriving at the barrier, until the * number of threads exceeds some threshold (quorum), after which all * threads can progress. * The Barrier can be broken in two additional ways. First, the threshold * value could be changed to a number lower than the currently waiting * number of threads. Second, the waiting threads could be released * unconditionally, without reaching quorum. * Since there must be at least one thread, the theshold value should * be at least 1. * Deleting the barrier while threads are blocked in not allowed. */ class FXAPI FXBarrier { private: FXCondition condition; FXMutex mutex; volatile FXuint generation; volatile FXuint thresh; volatile FXuint count; private: FXBarrier(const FXBarrier&); FXBarrier &operator=(const FXBarrier&); public: /// Initialize the barrier with initial threshold thr FXBarrier(FXuint thr=1); /** * Change threshold to thr, possibly releasing all waiting threads. * Return true if current count now exceeds the threshold. */ FXbool threshold(FXuint thr); /** * Return the threshold, i.e. number at which the barrier * breaks through. */ FXuint threshold() const { return thresh; } /** * Wait for all threads to hit the barrier. * Returns true for one thread, false for all other threads. */ FXbool wait(); /** * Release all waiting threads unconditionally; all waiting threads * will break through the barrier and proceed, even if the threshold * was not exceeded. * Return true if any threads were waiting. */ FXbool release(); /// Delete the barrier ~FXBarrier(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXBitmap.h000066400000000000000000000166231455751074500223140ustar00rootroot00000000000000/******************************************************************************** * * * B i t m a p O b j e c t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXBITMAP_H #define FXBITMAP_H #ifndef FXDRAWABLE_H #include "FXDrawable.h" #endif namespace FX { // Image rendering hints enum { BITMAP_KEEP = 0x00000001, // Keep pixel data in client BITMAP_OWNED = 0x00000002, // Pixel data is owned by image BITMAP_SHMI = 0x00000020, // Using shared memory image BITMAP_SHMP = 0x00000040 // Using shared memory pixmap }; // Forward declarations class FXDC; class FXDCWindow; /** * A Bitmap is a rectangular array of pixels. It supports two representations * of these pixels: a client-side pixel buffer, and a server-side pixmap which * is stored in an organization directly compatible with the screen, for fast * drawing onto the device. * The server-side representation is not directly accessible from the current * process as it lives in the process of the X Server or GDI. * The client-side pixel array is of size height x (width+7)/8 bytes, in other * words 8 pixels packed into a single byte, starting at bit 0 on the left. */ class FXAPI FXBitmap : public FXDrawable { FXDECLARE(FXBitmap) friend class FXDC; friend class FXDCWindow; private: #ifdef WIN32 virtual FXID GetDC() const; virtual int ReleaseDC(FXID) const; #endif protected: FXuchar *data; // Pixel data FXint bytewidth; // Number of bytes across FXuint options; // Options protected: FXBitmap(); private: FXBitmap(const FXBitmap&); FXBitmap &operator=(const FXBitmap&); public: /** * Create a bitmap. If a client-side pixel buffer has been specified, * the bitmap does not own the pixel buffer unless the BITMAP_OWNED flag is * set. If the BITMAP_OWNED flag is set but a NULL pixel buffer is * passed, a pixel buffer will be automatically created and will be owned * by the bitmap. The flags BITMAP_SHMI and BITMAP_SHMP may be specified for * large bitmaps to instruct render() to use shared memory to communicate * with the server. */ FXBitmap(FXApp* a,const FXuchar *pix=nullptr,FXuint opts=0,FXint w=1,FXint h=1); /// Change options void setOptions(FXuint opts); /// To get to the option flags FXuint getOptions() const { return options; } /// Set pixel data ownership flag void setOwned(FXbool owned); /// Get pixel data ownership flag FXbool isOwned() const; /** * Populate the bitmap with new pixel data of the same size; it will assume * ownership of the pixel data if image BITMAP_OWNED option is passed. * The server-side representation of the image, if it exists, is not updated. * This can be done by calling render(). */ virtual void setData(FXuchar *pix,FXuint opts=0); /** * Populate the bitmap with new pixel data of a new size; it will assume ownership * of the pixel data if image BITMAP_OWNED option is passed. The size of the server- * side representation of the image, if it exists, is adjusted but the contents are * not updated yet. This can be done by calling render(). */ virtual void setData(FXuchar *pix,FXuint opts,FXint w,FXint h); /// To get to the pixel data FXuchar* getData() const { return data; } /// Get pixel at x,y FXbool getPixel(FXint x,FXint y) const { return (FXbool)((data[y*bytewidth+(x>>3)]>>(x&7))&1); } /// Change pixel at x,y void setPixel(FXint x,FXint y,FXbool color){ color ? data[y*bytewidth+(x>>3)]|=(1<<(x&7)) : data[y*bytewidth+(x>>3)]&=~(1<<(x&7)); } /** * Create the server side pixmap, then call render() to fill it with the * pixel data from the client-side buffer. After the server-side image has * been created, the client-side pixel buffer will be deleted unless * BITMAP_KEEP has been specified. If the pixel buffer is not owned, i.e. * the flag BITMAP_OWNED is not set, the pixel buffer will not be deleted. */ virtual void create(); /** * Detach the server side pixmap from the Bitmap. * Afterwards, the Bitmap is left as if it never had a server-side resources. */ virtual void detach(); /** * Destroy the server-side pixmap. * The client-side pixel buffer is not affected. */ virtual void destroy(); /** * Retrieves pixels from the server-side bitmap. */ virtual void restore(); /** * Render the server-side representation of the bitmap from client-side * pixels. */ virtual void render(); /** * Release the client-side pixels buffer, free it if it was owned. * If it is not owned, the image just forgets about the buffer. */ virtual void release(); /** * Resize both client-side and server-side representations (if any) to the * given width and height. The new representations typically contain garbage * after this operation and need to be re-filled. */ virtual void resize(FXint w,FXint h); /** * Rescale pixels image to the specified width and height; this calls * resize() to adjust the client and server side representations. */ virtual void scale(FXint w,FXint h); /// Mirror bitmap horizontally and/or vertically virtual void mirror(FXbool horizontal,FXbool vertical); /// Rotate bitmap by degrees ccw virtual void rotate(FXint degrees); /** * Crop bitmap to given rectangle; this calls resize() to adjust the client * and server side representations. The new bitmap may be smaller or larger * than the old one; blank areas are filled with color. There must be at * least one pixel of overlap between the old and the new bitmap. */ virtual void crop(FXint x,FXint y,FXint w,FXint h,FXbool color=false); /// Fill bitmap with uniform value virtual void fill(FXbool color); /// Save object to stream virtual void save(FXStream& store) const; /// Load object from stream virtual void load(FXStream& store); /// Save pixel data only virtual FXbool savePixels(FXStream& store) const; /// Load pixel data only virtual FXbool loadPixels(FXStream& store); /// Cleanup virtual ~FXBitmap(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXBitmapFrame.h000066400000000000000000000067021455751074500232640ustar00rootroot00000000000000/******************************************************************************** * * * B i t m a p F r a m e W i d g e t * * * ********************************************************************************* * Copyright (C) 2001,2022 by H. J. Daniel III. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXBITMAPFRAME_H #define FXBITMAPFRAME_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { /** * The bitmap frame is a simple frame widget displaying an monochrome bitmap * image; the bitmap is not owned by the bitmap frame so it must be explicitly * deleted elsewhere. */ class FXAPI FXBitmapFrame : public FXFrame { FXDECLARE(FXBitmapFrame) protected: FXBitmap *bitmap; // The bitmap being displayed FXColor onColor; // Color for on pixels FXColor offColor; // Color for off pixels protected: FXBitmapFrame(); private: FXBitmapFrame(const FXBitmapFrame&); FXBitmapFrame &operator=(const FXBitmapFrame&); public: long onPaint(FXObject*,FXSelector,void* ptr); public: /// Construct image frame and pass it an image FXBitmapFrame(FXComposite* p,FXBitmap *bmp,FXuint opts=FRAME_SUNKEN|FRAME_THICK,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=0,FXint pr=0,FXint pt=0,FXint pb=0); /// Create window virtual void create(); /// Get default width virtual FXint getDefaultWidth(); /// Get default height virtual FXint getDefaultHeight(); /// Change the image being displayed void setBitmap(FXBitmap* bmp); /// Return the current image FXBitmap* getBitmap() const { return bitmap; } /// Set on color void setOnColor(FXColor clr); /// Get on color FXColor getOnColor() const { return onColor; } /// Set off color void setOffColor(FXColor clr); /// Get off color FXColor getOffColor() const { return offColor; } /// Set the current justification mode. void setJustify(FXuint mode); /// Get the current justification mode. FXuint getJustify() const; /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destroy the widget, but do not destroy the image virtual ~FXBitmapFrame(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXBitmapView.h000066400000000000000000000106461455751074500231460ustar00rootroot00000000000000/******************************************************************************** * * * B i t m a p V i e w W i d g e t * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXBITMAPVIEW_H #define FXBITMAPVIEW_H #ifndef FXSCROLLAREA_H #include "FXScrollArea.h" #endif namespace FX { class FXBitmap; /// Bitmap alignment styles enum { BITMAPVIEW_NORMAL = 0, /// Normal mode is centered BITMAPVIEW_CENTER_X = 0, /// Centered horizontally BITMAPVIEW_LEFT = 0x00100000, /// Left-aligned BITMAPVIEW_RIGHT = 0x00200000, /// Right-aligned BITMAPVIEW_CENTER_Y = 0, /// Centered vertically BITMAPVIEW_TOP = 0x00400000, /// Top-aligned BITMAPVIEW_BOTTOM = 0x00800000 /// Bottom-aligned }; /** * The Bitmap View widget display a scrollable view of a monochrome bitmap image; * the bitmap is not owned by the bitmap frame so it must be explicitly deleted * elsewhere. Thus, a single bitmap image can be displayed inside multiple bitmap * view widgets. */ class FXAPI FXBitmapView : public FXScrollArea { FXDECLARE(FXBitmapView) protected: FXBitmap *bitmap; // Image to view FXColor onColor; // Color for on pixels FXColor offColor; // Color for off pixels FXint grabx; // Grab point x FXint graby; // Grab point y protected: FXBitmapView(); private: FXBitmapView(const FXBitmapView&); FXBitmapView &operator=(const FXBitmapView&); public: long onPaint(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onRightBtnPress(FXObject*,FXSelector,void*); long onRightBtnRelease(FXObject*,FXSelector,void*); public: enum { ID_XYZ=FXScrollArea::ID_LAST, ID_LAST }; public: /// Construct a scroll window FXBitmapView(FXComposite* p,FXBitmap* bmp=nullptr,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Perform layout immediately virtual void layout(); /// Image view widget can receive focus virtual FXbool canFocus() const; /// Return the width of the contents virtual FXint getContentWidth(); /// Return the height of the contents virtual FXint getContentHeight(); /// Change image void setBitmap(FXBitmap* bmp); /// Return image FXBitmap* getBitmap() const { return bitmap; } /// Set on color void setOnColor(FXColor clr); /// Get on color FXColor getOnColor() const { return onColor; } /// Set off color void setOffColor(FXColor clr); /// Get off color FXColor getOffColor() const { return offColor; } /// Set the current alignment. void setAlignment(FXuint mode); /// Get the current alignment. FXuint getAlignment() const; /// Save list to a stream virtual void save(FXStream& store) const; /// Load list from a stream virtual void load(FXStream& store); /// Destroy virtual ~FXBitmapView(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXButton.h000066400000000000000000000130441455751074500223450ustar00rootroot00000000000000/******************************************************************************** * * * B u t t o n W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXBUTTON_H #define FXBUTTON_H #ifndef FXLABEL_H #include "FXLabel.h" #endif namespace FX { /// Button states enum { STATE_UP = 0, /// Button is up STATE_DOWN = 1, /// Button is down STATE_ENGAGED = 2, /// Button is engaged STATE_UNCHECKED = STATE_UP, /// Same as STATE_UP (used for check buttons or radio buttons) STATE_CHECKED = STATE_ENGAGED /// Same as STATE_ENGAGED (used for check buttons or radio buttons) }; /// Button flags enum { BUTTON_AUTOGRAY = 0x00800000, /// Automatically gray out when not updated BUTTON_AUTOHIDE = 0x01000000, /// Automatically hide button when not updated BUTTON_TOOLBAR = 0x02000000, /// Toolbar style button [flat look] BUTTON_DEFAULT = 0x04000000, /// May become default button when receiving focus BUTTON_INITIAL = 0x08000000, /// This button is the initial default button BUTTON_NORMAL = (FRAME_RAISED|FRAME_THICK|JUSTIFY_NORMAL|ICON_BEFORE_TEXT) }; /** * A button provides a push button, with optional icon and/or text label. * When pressed, the button widget sends a SEL_COMMAND to its target. * Passing the BUTTON_TOOLBAR style option gives buttons a "flat" look, and * causes the edge of the button to be raised when the cursor moves over it. * Passing BUTTON_DEFAULT allows the button to become the default button in * a dialog, when the focus moves to it. The default widget in a dialog * is the widget which will accept the RETURN key when it is pressed. * The BUTTON_INITIAL flag makes the button the default widget when the * focus moves to a widget which can not itself be a default widget. * There should be only a single button in the dialog which is the * initial default; typically this is the OK or CLOSE button. * The option BUTTON_AUTOGRAY (BUTTON_AUTOHIDE) causes the button to be grayed * out (hidden) if its handler does not respond to the SEL_UPDATE message. * This is useful when messages are delegated, for example when using a * multiple document interface, where the ultimate destination of a message * can be changed. */ class FXAPI FXButton : public FXLabel { FXDECLARE(FXButton) protected: FXuchar state; protected: FXButton(); private: FXButton(const FXButton&); FXButton& operator=(const FXButton&); public: long onPaint(FXObject*,FXSelector,void*); long onUpdate(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onFocusIn(FXObject*,FXSelector,void*); long onFocusOut(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onHotKeyPress(FXObject*,FXSelector,void*); long onHotKeyRelease(FXObject*,FXSelector,void*); long onCheck(FXObject*,FXSelector,void*); long onUncheck(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); public: /// Construct button with text and icon FXButton(FXComposite* p,const FXString& text,FXIcon* ic=nullptr,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=BUTTON_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Returns true because a button can receive focus virtual FXbool canFocus() const; /// Move the focus to this window virtual void setFocus(); /// Remove the focus from this window virtual void killFocus(); /// Set as default button virtual void setDefault(FXuchar flag=true); /// Set the button state void setState(FXuint s); /// Get the button state FXuint getState() const { return state; } /// Set the button style flags void setButtonStyle(FXuint style); /// Get the button style flags FXuint getButtonStyle() const; }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP1250Codec.h000066400000000000000000000011061455751074500226360ustar00rootroot00000000000000#ifndef FXCP1250CODEC_H #define FXCP1250CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP1250 Codec class FXAPI FXCP1250Codec : public FXTextCodec { FXDECLARE(FXCP1250Codec) public: FXCP1250Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP1250Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP1251Codec.h000066400000000000000000000011061455751074500226370ustar00rootroot00000000000000#ifndef FXCP1251CODEC_H #define FXCP1251CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP1251 Codec class FXAPI FXCP1251Codec : public FXTextCodec { FXDECLARE(FXCP1251Codec) public: FXCP1251Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP1251Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP1252Codec.h000066400000000000000000000011061455751074500226400ustar00rootroot00000000000000#ifndef FXCP1252CODEC_H #define FXCP1252CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP1252 Codec class FXAPI FXCP1252Codec : public FXTextCodec { FXDECLARE(FXCP1252Codec) public: FXCP1252Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP1252Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP1253Codec.h000066400000000000000000000011061455751074500226410ustar00rootroot00000000000000#ifndef FXCP1253CODEC_H #define FXCP1253CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP1253 Codec class FXAPI FXCP1253Codec : public FXTextCodec { FXDECLARE(FXCP1253Codec) public: FXCP1253Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP1253Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP1254Codec.h000066400000000000000000000011061455751074500226420ustar00rootroot00000000000000#ifndef FXCP1254CODEC_H #define FXCP1254CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP1254 Codec class FXAPI FXCP1254Codec : public FXTextCodec { FXDECLARE(FXCP1254Codec) public: FXCP1254Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP1254Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP1255Codec.h000066400000000000000000000011061455751074500226430ustar00rootroot00000000000000#ifndef FXCP1255CODEC_H #define FXCP1255CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP1255 Codec class FXAPI FXCP1255Codec : public FXTextCodec { FXDECLARE(FXCP1255Codec) public: FXCP1255Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP1255Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP1256Codec.h000066400000000000000000000011061455751074500226440ustar00rootroot00000000000000#ifndef FXCP1256CODEC_H #define FXCP1256CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP1256 Codec class FXAPI FXCP1256Codec : public FXTextCodec { FXDECLARE(FXCP1256Codec) public: FXCP1256Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP1256Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP1257Codec.h000066400000000000000000000011061455751074500226450ustar00rootroot00000000000000#ifndef FXCP1257CODEC_H #define FXCP1257CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP1257 Codec class FXAPI FXCP1257Codec : public FXTextCodec { FXDECLARE(FXCP1257Codec) public: FXCP1257Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP1257Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP1258Codec.h000066400000000000000000000011061455751074500226460ustar00rootroot00000000000000#ifndef FXCP1258CODEC_H #define FXCP1258CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP1258 Codec class FXAPI FXCP1258Codec : public FXTextCodec { FXDECLARE(FXCP1258Codec) public: FXCP1258Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP1258Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP437Codec.h000066400000000000000000000010771455751074500225730ustar00rootroot00000000000000#ifndef FXCP437CODEC_H #define FXCP437CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP437 Codec class FXAPI FXCP437Codec : public FXTextCodec { FXDECLARE(FXCP437Codec) public: FXCP437Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP437Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP850Codec.h000066400000000000000000000011001455751074500225550ustar00rootroot00000000000000#ifndef FXCP850CODEC_H #define FXCP850CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP8502 Codec class FXAPI FXCP850Codec : public FXTextCodec { FXDECLARE(FXCP850Codec) public: FXCP850Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP850Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP852Codec.h000066400000000000000000000010771455751074500225740ustar00rootroot00000000000000#ifndef FXCP852CODEC_H #define FXCP852CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP852 Codec class FXAPI FXCP852Codec : public FXTextCodec { FXDECLARE(FXCP852Codec) public: FXCP852Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP852Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP855Codec.h000066400000000000000000000010771455751074500225770ustar00rootroot00000000000000#ifndef FXCP855CODEC_H #define FXCP855CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP855 Codec class FXAPI FXCP855Codec : public FXTextCodec { FXDECLARE(FXCP855Codec) public: FXCP855Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP855Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP856Codec.h000066400000000000000000000010771455751074500226000ustar00rootroot00000000000000#ifndef FXCP856CODEC_H #define FXCP856CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP856 Codec class FXAPI FXCP856Codec : public FXTextCodec { FXDECLARE(FXCP856Codec) public: FXCP856Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP856Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP857Codec.h000066400000000000000000000010771455751074500226010ustar00rootroot00000000000000#ifndef FXCP857CODEC_H #define FXCP857CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP857 Codec class FXAPI FXCP857Codec : public FXTextCodec { FXDECLARE(FXCP857Codec) public: FXCP857Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP857Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP860Codec.h000066400000000000000000000010771455751074500225730ustar00rootroot00000000000000#ifndef FXCP860CODEC_H #define FXCP860CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP860 Codec class FXAPI FXCP860Codec : public FXTextCodec { FXDECLARE(FXCP860Codec) public: FXCP860Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP860Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP861Codec.h000066400000000000000000000010771455751074500225740ustar00rootroot00000000000000#ifndef FXCP861CODEC_H #define FXCP861CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP861 Codec class FXAPI FXCP861Codec : public FXTextCodec { FXDECLARE(FXCP861Codec) public: FXCP861Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP861Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP862Codec.h000066400000000000000000000010771455751074500225750ustar00rootroot00000000000000#ifndef FXCP862CODEC_H #define FXCP862CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP862 Codec class FXAPI FXCP862Codec : public FXTextCodec { FXDECLARE(FXCP862Codec) public: FXCP862Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP862Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP863Codec.h000066400000000000000000000010771455751074500225760ustar00rootroot00000000000000#ifndef FXCP863CODEC_H #define FXCP863CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP863 Codec class FXAPI FXCP863Codec : public FXTextCodec { FXDECLARE(FXCP863Codec) public: FXCP863Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP863Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP864Codec.h000066400000000000000000000010771455751074500225770ustar00rootroot00000000000000#ifndef FXCP864CODEC_H #define FXCP864CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP864 Codec class FXAPI FXCP864Codec : public FXTextCodec { FXDECLARE(FXCP864Codec) public: FXCP864Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP864Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP865Codec.h000066400000000000000000000010771455751074500226000ustar00rootroot00000000000000#ifndef FXCP865CODEC_H #define FXCP865CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP865 Codec class FXAPI FXCP865Codec : public FXTextCodec { FXDECLARE(FXCP865Codec) public: FXCP865Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP865Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP866Codec.h000066400000000000000000000010771455751074500226010ustar00rootroot00000000000000#ifndef FXCP866CODEC_H #define FXCP866CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP866 Codec class FXAPI FXCP866Codec : public FXTextCodec { FXDECLARE(FXCP866Codec) public: FXCP866Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP866Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP869Codec.h000066400000000000000000000010771455751074500226040ustar00rootroot00000000000000#ifndef FXCP869CODEC_H #define FXCP869CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP869 Codec class FXAPI FXCP869Codec : public FXTextCodec { FXDECLARE(FXCP869Codec) public: FXCP869Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP869Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCP874Codec.h000066400000000000000000000010771455751074500226000ustar00rootroot00000000000000#ifndef FXCP874CODEC_H #define FXCP874CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// CP874 Codec class FXAPI FXCP874Codec : public FXTextCodec { FXDECLARE(FXCP874Codec) public: FXCP874Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXCP874Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCURCursor.h000066400000000000000000000060721455751074500227240ustar00rootroot00000000000000/******************************************************************************** * * * C U R C u r s o r O b j e c t * * * ********************************************************************************* * Copyright (C) 2001,2022 by Sander Jansen. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCURCURSOR_H #define FXCURCURSOR_H #ifndef FXCURSOR_H #include "FXCursor.h" #endif namespace FX { /// CUR Cursor class class FXAPI FXCURCursor : public FXCursor { FXDECLARE(FXCURCursor) protected: FXCURCursor(){} private: FXCURCursor(const FXCURCursor&); FXCURCursor &operator=(const FXCURCursor&); public: static const FXchar fileExt[]; public: /** * Construct a cursor from memory stream in Microsoft CUR format. * The image is limited to 32x32 pixels. */ FXCURCursor(FXApp* a,const FXuchar* pix); /// Save pixel data only, in CUR format virtual FXbool savePixels(FXStream& store) const; /// Load pixel data only, in CUR format virtual FXbool loadPixels(FXStream& store); /// Destructor virtual ~FXCURCursor(); }; #ifndef FXLOADICO #define FXLOADICO /** * Check if stream contains a ICO, return true if so. */ extern FXAPI FXbool fxcheckICO(FXStream& store); /** * Load an ICO (Microsoft icon format) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadICO(FXStream& store,FXColor*& data,FXint& width,FXint& height,FXint& xspot,FXint& yspot); /** * Save an ICO (Microsoft icon format) file to a stream. * If no hot-spot given, save as an ICO instead of a CUR resource. */ extern FXAPI FXbool fxsaveICO(FXStream& store,const FXColor *data,FXint width,FXint height,FXint xspot=-1,FXint yspot=-1); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCalendar.h000066400000000000000000000135001455751074500226000ustar00rootroot00000000000000/******************************************************************************** * * * C a l e n d a r W i d g e t * * * ********************************************************************************* * Copyright (C) 2006,2022 by Sander Jansen. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCALENDAR_H #define FXCALENDAR_H #ifndef FXPACKER_H #include "FXPacker.h" #endif namespace FX { class FXLabel; class FXPopup; class FXOptionMenu; class FXHorizontalFrame; class FXCalendarView; /** * The Calendar Widget. In addition of displaying the calendar, also provides month and year * controls and optional frame. */ class FXAPI FXCalendar : public FXPacker { FXDECLARE(FXCalendar) protected: FXCalendarView *view; FXHorizontalFrame *frame; FXLabel *year; FXOptionMenu *month; FXPopup *monthpopup; FXOption *months[12]; FXArrowButton *arrows[4]; protected: FXCalendar(); private: FXCalendar(const FXCalendar&); FXCalendar &operator=(const FXCalendar&); public: enum{ ID_CALENDAR=FXPacker::ID_LAST, ID_NEXTYEAR, ID_PREVYEAR, ID_NEXTMONTH, ID_PREVMONTH, ID_MONTH_START, ID_MONTH_END=ID_MONTH_START+12, ID_MONTH }; public: long onCmdDate(FXObject*,FXSelector,void*); long onCmdMonth(FXObject*,FXSelector,void*); long onCmdNextYear(FXObject*,FXSelector,void*); long onCmdPrevYear(FXObject*,FXSelector,void*); long onCmdNextMonth(FXObject*,FXSelector,void*); long onCmdPrevMonth(FXObject*,FXSelector,void*); long onCmdSelectMonth(FXObject*,FXSelector,void*); long onFwdToView(FXObject*,FXSelector,void*); long onFwdToTarget(FXObject*,FXSelector,void*); public: /// Constructor FXCalendar(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Create void create(); /// Enable the window to receive mouse and keyboard events virtual void enable(); /// Disable the window from receiving mouse and keyboard events virtual void disable(); /// Set date void setCurrentDate(FXDate date,FXbool notify=false); /// Get the current date FXDate getCurrentDate() const; /// Set the current month; current day will be properly updated for the choosen month void setCurrentMonth(FXint mo,FXbool notify=false); /** * Return the current month shown. The month may be different than * the current date if a day in a sibling month is current. */ FXint getCurrentMonth() const; /// Return calendar view control FXCalendarView* calendarView() const { return view; } /// Set the first day of the week [0 -> 6] void setFirstDay(FXint d); /// Get the first day of the week [0 -> 6] FXint getFirstDay() const; /// Change the Frame Style void setFrameStyle(FXuint); /// Set the Calendar Style void setCalendarStyle(FXuint); /// Get the Calendar Style FXuint getCalendarStyle() const; /// Set the back color void setBackColor(FXColor c); /// Get the back color FXColor getBackColor() const; /// Set the display color of titles void setTitleColor(FXColor c); /// Get the display color of titles FXColor getTitleColor() const; /// Set the display color of titles void setTitleBackColor(FXColor c); /// Get the display color of titles FXColor getTitleBackColor() const; /// Set the display color of non-weekend days void setDayColor(FXColor c); /// Get the display color of non-weekend days FXColor getDayColor() const; /// Set the display color of non-weekend days not in the current month void setOtherDayColor(FXColor c); /// Get the display color of non-weekend days not in the current month FXColor getOtherDayColor() const; /// Set the display color of today void setTodayColor(FXColor c); /// Get the display color of today FXColor getTodayColor() const; /// Set the display color of days in the weekend void setWeekendColor(FXColor c); /// Get the display color of days in the weekend FXColor getWeekendColor() const; /// Set the display color of days in the weekend not in the current month void setOtherWeekendColor(FXColor c); /// Get the display color of days in the weekend not in the current month FXColor getOtherWeekendColor() const; /// Set font used by the header void setHeaderFont(FXFont *fnt); /// Get font used by the header FXFont* getHeaderFont() const; /// Set font used by the calendar void setCalendarFont(FXFont *fnt); /// Get font used by the calendar FXFont* getCalendarFont() const; /// Destructor virtual ~FXCalendar(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCalendarView.h000066400000000000000000000171101455751074500234340ustar00rootroot00000000000000/******************************************************************************** * * * B a s e C a l e n d a r W i d g e t * * * ********************************************************************************* * Copyright (C) 2006,2022 by Sander Jansen. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCALENDARVIEW_H #define FXCALENDARVIEW_H #ifndef FXWINDOW_H #include "FXWindow.h" #endif namespace FX { /// Calendar styles enum { CALENDAR_BROWSESELECT = 0x00000000, /// Browse selection mode enforces one single item to be selected at all times CALENDAR_SINGLESELECT = 0x00100000, /// Single selection mode allows up to one item to be selected CALENDAR_WEEKNUMBERS = 0x00200000, /// Show ISO8601 Week numbers CALENDAR_STATIC = 0x00400000, /// Disable navigation to prev/next month in display. CALENDAR_HIDEOTHER = 0x00800000, /// Do not show days of other months. }; class FXFont; /** * The Basic Calendar Widget. Renders the base calendar and keeps track of selection. * Most usefull to widget developers. Use it if you need a calendar rendered in some component. */ class FXAPI FXCalendarView : public FXWindow { FXDECLARE(FXCalendarView) protected: FXFont *font; // Font FXDate current; // Current Date FXDate selected; // Selected Date FXDate ds; // First Day in Calendar FXint month; // Which month is being viewed. FXint firstday; // Which day of the week we display in the first column FXint ws; // First week number in Calendar FXColor todayColor; // Today Color FXColor titleColor; // Title Color FXColor titleBackColor; // Title Back Color FXColor dayColor; // Normal Day Color FXColor otherDayColor; // Normal Day Color Disabled FXColor weekendColor; // Weekend Color FXColor otherWeekendColor; // Weekend Color Disabled FXbool has_selection; // If any date is selected FXbool state; // State protected: FXCalendarView(); void moveFocus(FXDate); void markdirty(FXDate); void updateview(FXbool notify=true); private: FXCalendarView(const FXCalendarView&); FXCalendarView &operator=(const FXCalendarView&); public: long onPaint(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onFocusIn(FXObject*,FXSelector,void*); long onFocusOut(FXObject*,FXSelector,void*); long onClicked(FXObject*,FXSelector,void*); long onDoubleClicked(FXObject*,FXSelector,void*); long onTripleClicked(FXObject*,FXSelector,void*); long onCommand(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); public: /// Construct a Calendar View FXCalendarView(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=CALENDAR_BROWSESELECT,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Yes we can virtual FXbool canFocus() const; /// Set focus virtual void setFocus(); /// Kill focus virtual void killFocus(); /// Enable the window virtual void enable(); /// Disable the window virtual void disable(); /// Return the default width of this window virtual FXint getDefaultWidth(); /// Return the default height of this window virtual FXint getDefaultHeight(); /// Get date at x,y if any FXbool getDateAt(FXint x,FXint y,FXDate& date) const; /// Set date void setCurrentDate(FXDate date,FXbool notify=false); /// Get the current date FXDate getCurrentDate() const { return current; } /// Set the current month; current day will be properly updated for the choosen month void setCurrentMonth(FXint month,FXbool notify=false); /** * Return the current month shown. The month may be different than the current * date if a day in a sibling month is current. */ FXint getCurrentMonth() const { return month; } /// Select Date void selectDate(FXDate date,FXbool notify=false); /// Deselect Date void killSelection(FXbool notify=false); /// Get the selected date, if any FXbool getSelectedDate(FXDate& date) const; /// Set the first day of the week [0...6] void setFirstDay(FXint d); /// Get the first day of the week [0...6] FXint getFirstDay() const { return firstday; } /// Set the calendar style void setCalendarStyle(FXuint); /// Get the calendar style FXuint getCalendarStyle() const; /// Set the display color of titles void setTitleColor(FXColor c); /// Get the display color of titles FXColor getTitleColor() const { return titleColor; } /// Set the display background color of titles void setTitleBackColor(FXColor c); /// Get the display background color of titles FXColor getTitleBackColor() const { return titleBackColor; } /// Set the display color of non-weekend days void setDayColor(FXColor c); /// Get the display color of non-weekend days FXColor getDayColor() const { return dayColor; } /// Set the display color of non-weekend days not in the current month void setOtherDayColor(FXColor c); /// Get the display color of non-weekend days not in the current month FXColor getOtherDayColor() const { return otherDayColor; } /// Set the display color of today void setTodayColor(FXColor c); /// Get the display color of today FXColor getTodayColor() const { return todayColor; } /// Set the display color of days in the weekend void setWeekendColor(FXColor c); /// Get the display color of days in the weekend FXColor getWeekendColor() const { return weekendColor; } /// Set the display color of days in the weekend not in the current month void setOtherWeekendColor(FXColor c); /// Get the display color of days in the weekend not in the current month FXColor getOtherWeekendColor() const { return otherWeekendColor; } /// Set the text font void setFont(FXFont *fnt); /// Get the text font FXFont* getFont() const { return font; } /// Destructor virtual ~FXCalendarView(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCallback.h000066400000000000000000000424711455751074500225740ustar00rootroot00000000000000/******************************************************************************** * * * C a l l B a c k C l a s s * * * ********************************************************************************* * Copyright (C) 2016,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCALLBACK_H #define FXCALLBACK_H namespace FX { /********************************************************************************/ // Bland template declaration template class FXCallback; /********************************************************************************/ // Specialization of callback mechanism for callback with signature: // // RT FUNC() // // Both free functions and member functions may be called. template class FXAPI FXCallback { public: typedef RT (*METHOD)(const void*); private: METHOD method; const void* object; private: // Stub call to method template static RT method_call(const void* obj){ return (static_cast(const_cast(obj))->*mfn)(); } // Stub call to const method template static RT const_method_call(const void* obj){ return (static_cast(obj)->*mfn)(); } // Stub call to function template static RT function_call(const void*){ return (fn)(); } // Fallback function static RT default_call(const void*){ return RT(); } public: // Initialize to default FXCallback():method(&default_call),object(0){ } // Copy constructor FXCallback(const FXCallback& org):method(org.method),object(org.object){ } // Assignment operator FXCallback& operator=(const FXCallback& org){ method=org.method; object=org.object; return *this; } // Equality operators FXbool operator==(const FXCallback& other) const { return method==other.method && object==other.object; } FXbool operator!=(const FXCallback& other) const { return method!=other.method || object!=other.object; } // Invoke the function RT operator()() const { return (*method)(object); } // Connect to member function of object template inline void connect(TYPE* obj){ method=&method_call; object=obj; } // Connect to member function of object template inline void connect(const TYPE* obj){ method=&const_method_call; object=obj; } // Connect to plain function template inline void connect(){ method=&function_call; object=nullptr; } // Return trye if connected bool connected() const { return (method!=&default_call); } // Disconnect resets to default void disconnect(){ method=&default_call; object=nullptr; } // Disconnect conditionally void disconnect(const void* obj){ if(obj==object){ disconnect(); } } // Create default callback static inline FXCallback create(){ return FXCallback(); } // Create callback to member function of object template static inline FXCallback create(TYPE* obj){ return FXCallback(&method_call,obj); } // Create callback to member function of constant object template static inline FXCallback create(const TYPE* obj){ return FXCallback(&const_method_call,obj); } // Create callback to function template static inline FXCallback create(){ return FXCallback(&function_call,nullptr); } }; /********************************************************************************/ // Specialization of callback mechanism for callback with signature: // // RT FUNC(PT1) // // Both free functions and member functions may be called. template class FXAPI FXCallback { public: typedef RT (*METHOD)(const void*,PT1); private: METHOD method; const void* object; private: // Stub call to method template static RT method_call(const void* obj,PT1 p1){ return (static_cast(const_cast(obj))->*mfn)(p1); } // Stub call to const method template static RT const_method_call(const void* obj,PT1 p1){ return (static_cast(obj)->*mfn)(p1); } // Stub call to function template static RT function_call(const void*,PT1 p1){ return (fn)(p1); } // Fallback function static RT default_call(const void*,PT1){ return RT(); } public: // Initialize to default FXCallback():method(&default_call),object(0){ } // Copy constructor FXCallback(const FXCallback& org):method(org.method),object(org.object){ } // Assignment operator FXCallback& operator=(const FXCallback& org){ method=org.method; object=org.object; return *this; } // Equality operators FXbool operator==(const FXCallback& other) const { return method==other.method && object==other.object; } FXbool operator!=(const FXCallback& other) const { return method!=other.method || object!=other.object; } // Invoke the function RT operator()(PT1 p1) const { return (*method)(object,p1); } // Connect to member function of object template inline void connect(TYPE* obj){ method=&method_call; object=obj; } // Connect to member function of object template inline void connect(const TYPE* obj){ method=&const_method_call; object=obj; } // Connect to plain function template inline void connect(){ method=&function_call; object=nullptr; } // Return trye if connected bool connected() const { return (method!=&default_call); } // Disconnect resets to default void disconnect(){ method=&default_call; object=nullptr; } // Disconnect conditionally void disconnect(const void* obj){ if(obj==object){ disconnect(); } } // Create default callback static inline FXCallback create(){ return FXCallback(); } // Create callback to member function of object template static inline FXCallback create(TYPE* obj){ return FXCallback(&method_call,obj); } // Create callback to member function of constant object template static inline FXCallback create(const TYPE* obj){ return FXCallback(&const_method_call,obj); } // Create callback to function template static inline FXCallback create(){ return FXCallback(&function_call,nullptr); } }; /********************************************************************************/ // Specialization of callback mechanism for callback with signature: // // RT FUNC(PT1,PT2) // // Both free functions and member functions may be called. template class FXAPI FXCallback { public: typedef RT (*METHOD)(const void*,PT1,PT2); private: METHOD method; const void* object; private: // Stub call to method template static RT method_call(const void* obj,PT1 p1,PT2 p2){ return (static_cast(const_cast(obj))->*mfn)(p1,p2); } // Stub call to const method template static RT const_method_call(const void* obj,PT1 p1,PT2 p2){ return (static_cast(obj)->*mfn)(p1,p2); } // Stub call to function template static RT function_call(const void*,PT1 p1,PT2 p2){ return (fn)(p1,p2); } // Fallback function static RT default_call(const void*,PT1,PT2){ return RT(); } public: // Initialize to default FXCallback():method(&default_call),object(0){ } // Copy constructor FXCallback(const FXCallback& org):method(org.method),object(org.object){ } // Assignment operator FXCallback& operator=(const FXCallback& org){ method=org.method; object=org.object; return *this; } // Equality operators FXbool operator==(const FXCallback& other) const { return method==other.method && object==other.object; } FXbool operator!=(const FXCallback& other) const { return method!=other.method || object!=other.object; } // Invoke the function RT operator()(PT1 p1,PT2 p2) const { return (*method)(object,p1,p2); } // Connect to member function of object template inline void connect(TYPE* obj){ method=&method_call; object=obj; } // Connect to member function of object template inline void connect(const TYPE* obj){ method=&const_method_call; object=obj; } // Connect to plain function template inline void connect(){ method=&function_call; object=nullptr; } // Return trye if connected bool connected() const { return (method!=&default_call); } // Disconnect resets to default void disconnect(){ method=&default_call; object=nullptr; } // Disconnect conditionally void disconnect(const void* obj){ if(obj==object){ disconnect(); } } // Create default callback static inline FXCallback create(){ return FXCallback(); } // Create callback to member function of object template static inline FXCallback create(TYPE* obj){ return FXCallback(&method_call,obj); } // Create callback to member function of constant object template static inline FXCallback create(const TYPE* obj){ return FXCallback(&const_method_call,obj); } // Create callback to function template static inline FXCallback create(){ return FXCallback(&function_call,nullptr); } }; /********************************************************************************/ // Specialization of callback mechanism for callback with signature: // // RT FUNC(PT1,PT2,PT3) // // Both free functions and member functions may be called. template class FXAPI FXCallback { public: typedef RT (*METHOD)(const void*,PT1,PT2,PT3); private: METHOD method; const void* object; private: // Stub call to method template static RT method_call(const void* obj,PT1 p1,PT2 p2,PT3 p3){ return (static_cast(const_cast(obj))->*mfn)(p1,p2,p3); } // Stub call to const method template static RT const_method_call(const void* obj,PT1 p1,PT2 p2,PT3 p3){ return (static_cast(obj)->*mfn)(p1,p2,p3); } // Stub call to function template static RT function_call(const void*,PT1 p1,PT2 p2,PT3 p3){ return (fn)(p1,p2,p3); } // Fallback function static RT default_call(const void*,PT1,PT2,PT3){ return RT(); } public: // Initialize to default FXCallback():method(&default_call),object(0){ } // Copy constructor FXCallback(const FXCallback& org):method(org.method),object(org.object){ } // Assignment operator FXCallback& operator=(const FXCallback& org){ method=org.method; object=org.object; return *this; } // Equality operators FXbool operator==(const FXCallback& other) const { return method==other.method && object==other.object; } FXbool operator!=(const FXCallback& other) const { return method!=other.method || object!=other.object; } // Invoke the function RT operator()(PT1 p1,PT2 p2,PT3 p3) const { return (*method)(object,p1,p2,p3); } // Connect to member function of object template inline void connect(TYPE* obj){ method=&method_call; object=obj; } // Connect to member function of object template inline void connect(const TYPE* obj){ method=&const_method_call; object=obj; } // Connect to plain function template inline void connect(){ method=&function_call; object=nullptr; } // Return trye if connected bool connected() const { return (method!=&default_call); } // Disconnect resets to default void disconnect(){ method=&default_call; object=nullptr; } // Disconnect conditionally void disconnect(const void* obj){ if(obj==object){ disconnect(); } } // Create default callback static inline FXCallback create(){ return FXCallback(); } // Create callback to member function of object template static inline FXCallback create(TYPE* obj){ return FXCallback(&method_call,obj); } // Create callback to member function of constant object template static inline FXCallback create(const TYPE* obj){ return FXCallback(&const_method_call,obj); } // Create callback to function template static inline FXCallback create(){ return FXCallback(&function_call,nullptr); } }; /********************************************************************************/ // Specialization of callback mechanism for callback with signature: // // RT FUNC(PT1,PT2,PT3,PT4) // // Both free functions and member functions may be called. template class FXAPI FXCallback { public: typedef RT (*METHOD)(const void*,PT1,PT2,PT3,PT4); private: METHOD method; const void* object; private: // Stub call to method template static RT method_call(const void* obj,PT1 p1,PT2 p2,PT3 p3,PT4 p4){ return (static_cast(const_cast(obj))->*mfn)(p1,p2,p3,p4); } // Stub call to const method template static RT const_method_call(const void* obj,PT1 p1,PT2 p2,PT3 p3,PT4 p4){ return (static_cast(obj)->*mfn)(p1,p2,p3,p4); } // Stub call to function template static RT function_call(const void*,PT1 p1,PT2 p2,PT3 p3,PT4 p4){ return (fn)(p1,p2,p3,p4); } // Fallback function static RT default_call(const void*,PT1,PT2,PT3,PT4){ return RT(); } public: // Initialize to default FXCallback():method(&default_call),object(0){ } // Copy constructor FXCallback(const FXCallback& org):method(org.method),object(org.object){ } // Assignment operator FXCallback& operator=(const FXCallback& org){ method=org.method; object=org.object; return *this; } // Equality operators FXbool operator==(const FXCallback& other) const { return method==other.method && object==other.object; } FXbool operator!=(const FXCallback& other) const { return method!=other.method || object!=other.object; } // Invoke the function RT operator()(PT1 p1,PT2 p2,PT3 p3,PT4 p4) const { return (*method)(object,p1,p2,p3,p4); } // Connect to member function of object template inline void connect(TYPE* obj){ method=&method_call; object=obj; } // Connect to member function of object template inline void connect(const TYPE* obj){ method=&const_method_call; object=obj; } // Connect to plain function template inline void connect(){ method=&function_call; object=nullptr; } // Return trye if connected bool connected() const { return (method!=&default_call); } // Disconnect resets to default void disconnect(){ method=&default_call; object=nullptr; } // Disconnect conditionally void disconnect(const void* obj){ if(obj==object){ disconnect(); } } // Create default callback static inline FXCallback create(){ return FXCallback(); } // Create callback to member function of object template static inline FXCallback create(TYPE* obj){ return FXCallback(&method_call,obj); } // Create callback to member function of constant object template static inline FXCallback create(const TYPE* obj){ return FXCallback(&const_method_call,obj); } // Create callback to function template static inline FXCallback create(){ return FXCallback(&function_call,nullptr); } }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCanvas.h000066400000000000000000000043651455751074500223130ustar00rootroot00000000000000/******************************************************************************** * * * C a n v a s W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCANVAS_H #define FXCANVAS_H #ifndef FXWINDOW_H #include "FXWindow.h" #endif namespace FX { /// Canvas, an area drawn by another object class FXAPI FXCanvas : public FXWindow { FXDECLARE(FXCanvas) protected: FXCanvas(); private: FXCanvas(const FXCanvas&); FXCanvas &operator=(const FXCanvas&); public: long onPaint(FXObject*,FXSelector,void*); public: /// Construct new drawing canvas widget FXCanvas(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=FRAME_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Return true because canvas can receive focus virtual FXbool canFocus() const; }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCheckButton.h000066400000000000000000000130031455751074500232760ustar00rootroot00000000000000/******************************************************************************** * * * C h e c k B u t t o n W i d g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCHECKBUTTON_H #define FXCHECKBUTTON_H #ifndef FXLABEL_H #include "FXLabel.h" #endif namespace FX { /// CheckButton styles enum { CHECKBUTTON_AUTOGRAY = 0x00800000, /// Automatically gray out when not updated CHECKBUTTON_AUTOHIDE = 0x01000000, /// Automatically hide when not updated CHECKBUTTON_PLUS = 0x02000000, /// Draw a + for unchecked and - for checked CHECKBUTTON_NORMAL = JUSTIFY_NORMAL|ICON_BEFORE_TEXT }; /** * A Check Button is a tri-state button. Normally, it is either * true or false, and toggles between true or false whenever it is pressed. * A third state (maybe) may be set to indicate that no selection has been made yet * by the user, or that the state is ambiguous. * When pressed, the Check Button sends a SEL_COMMAND to its target, and the * message data represents the state of the check button. * The option CHECKBUTTON_AUTOGRAY (CHECKBUTTON_AUTOHIDE) causes the button to be * grayed out (hidden) if its handler does not respond to the SEL_UPDATE message. * With the CHECKBUTTON_PLUS option, the Check Button will draw a + or - sign instead * of a check. You can use this to make collapsable panels, by hooking up a Check * Button to a layout manager via the ID_TOGGLE_SHOWN message. This will give a * similar visual element as collapsing folders in a Tree List. */ class FXAPI FXCheckButton : public FXLabel { FXDECLARE(FXCheckButton) protected: FXColor checkColor; // Color of check mark FXColor boxColor; // Color of check box FXuchar check; // Check state FXuchar oldcheck; // Old check state protected: FXCheckButton(); private: FXCheckButton(const FXCheckButton&); FXCheckButton &operator=(const FXCheckButton&); public: long onPaint(FXObject*,FXSelector,void*); long onUpdate(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onFocusIn(FXObject*,FXSelector,void*); long onFocusOut(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onHotKeyPress(FXObject*,FXSelector,void*); long onHotKeyRelease(FXObject*,FXSelector,void*); long onCheck(FXObject*,FXSelector,void*); long onUncheck(FXObject*,FXSelector,void*); long onUnknown(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); public: /// Construct new check button FXCheckButton(FXComposite* p,const FXString& text,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=CHECKBUTTON_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Returns true because a check button can receive focus virtual FXbool canFocus() const; /// Get default width virtual FXint getDefaultWidth(); /// Get default height virtual FXint getDefaultHeight(); /// Set check button state (true, false or maybe) void setCheck(FXuchar state=true,FXbool notify=false); /// Get check button state (true, false or maybe) FXuchar getCheck() const { return check; } /// Change check button style void setCheckButtonStyle(FXuint style); /// Return current check button style FXuint getCheckButtonStyle() const; /// Get the box background color FXColor getBoxColor() const { return boxColor; } /// Set the box background color void setBoxColor(FXColor clr); /// Get the box check color FXColor getCheckColor() const { return checkColor; } /// Set the box check color void setCheckColor(FXColor clr); /// Save check button to a stream virtual void save(FXStream& store) const; /// Load check button from a stream virtual void load(FXStream& store); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXChoiceBox.h000066400000000000000000000125161455751074500227400ustar00rootroot00000000000000/******************************************************************************** * * * C h o i c e B o x * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCHOICEBOX_H #define FXCHOICEBOX_H #ifndef FXDIALOGBOX_H #include "FXDialogBox.h" #endif namespace FX { class FXList; /** * The Choice Box provides a dialog panel to select one item out of a list * of choices. The choices are provided as a list of text strings. * When the dialog closes, the index of the selected choice is returned, * while a -1 is returned if the dialog was canceled, */ class FXAPI FXChoiceBox : public FXDialogBox { FXDECLARE(FXChoiceBox) protected: FXList *list; protected: FXChoiceBox(){} private: FXChoiceBox(const FXChoiceBox&); FXChoiceBox &operator=(const FXChoiceBox&); void initialize(const FXString& text,FXIcon* icon); public: long onCmdClicked(FXObject*,FXSelector,void*); long onCmdCancel(FXObject*,FXSelector,void*); public: enum{ ID_CLICKED=FXDialogBox::ID_LAST, ID_LAST }; public: /// Construct choice box with given caption, icon, message text, and with choices from array of strings FXChoiceBox(FXWindow* owner,const FXString& caption,const FXString& text,FXIcon* icon,const FXchar** choices,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Construct choice box with given caption, icon, message text, and with choices from newline separated strings FXChoiceBox(FXWindow* owner,const FXString& caption,const FXString& text,FXIcon* icon,const FXString& choices,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Construct free floating choice box with given caption, icon, message text, and with choices from array of strings FXChoiceBox(FXApp* app,const FXString& caption,const FXString& text,FXIcon* icon,const FXchar** choices,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Construct free floating choice box with given caption, icon, message text, and with choices from newline separated strings FXChoiceBox(FXApp* app,const FXString& caption,const FXString& text,FXIcon* icon,const FXString& choices,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Run modal invocation of the dialog virtual FXuint execute(FXuint placement=PLACEMENT_CURSOR); /** * Show a modal choice dialog. * Prompt the user using a dialog with given caption, icon, * message text, and with choices from newline array of strings. * The return value is -1 if cancelled, or the given choice. */ static FXint ask(FXWindow* owner,FXuint opts,const FXString& caption,const FXString& text,FXIcon* icon,const FXchar** choices); /** * Show a modal choice dialog. * Prompt the user using a dialog with given caption, icon, * message text, and with choices from newline separated strings. * The return value is -1 if cancelled, or the given choice */ static FXint ask(FXWindow* owner,FXuint opts,const FXString& caption,const FXString& text,FXIcon* icon,const FXString& choices); /** * Show modal choice message, in free floating window. * Prompt the user using a dialog with given caption, icon, * message text, and with choices from newline array of strings. * The return value is -1 if cancelled, or the given choice */ static FXint ask(FXApp* app,FXuint opts,const FXString& caption,const FXString& text,FXIcon* icon,const FXchar** choices); /** * Show modal choice message, in free floating window. * Prompt the user using a dialog with given caption, icon, * message text, and with choices from newline separated strings. * The return value is -1 if cancelled, or the given choice */ static FXint ask(FXApp* app,FXuint opts,const FXString& caption,const FXString& text,FXIcon* icon,const FXString& choices); /// Save choice box to a stream virtual void save(FXStream& store) const; /// Load choice box from a stream virtual void load(FXStream& store); /// Destroy choice box virtual ~FXChoiceBox(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXColorBar.h000066400000000000000000000113011455751074500225670ustar00rootroot00000000000000/******************************************************************************** * * * C o l o r B a r W i d g e t * * * ********************************************************************************* * Copyright (C) 2001,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCOLORBAR_H #define FXCOLORBAR_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { /// Color bar orientation enum { COLORBAR_HORIZONTAL = 0, /// Color bar shown horizontally COLORBAR_VERTICAL = 0x00008000 /// Color bar shown vertically }; class FXImage; /** * A ColorBar is a widget which controls the brightness (value) of a * color by means of the hue, saturation, value specification system. * It is most useful when used together with the Color Wheel which controls * the hue and saturation. * The options COLORBAR_HORIZONTAL and COLORBAR_VERTICAL control the orientation * of the bar. */ class FXAPI FXColorBar : public FXFrame { FXDECLARE(FXColorBar) protected: FXImage *bar; // Intensity bar FXfloat hsv[3]; // Hue, saturation, value FXString tip; // Tooltip value FXString help; // Help value protected: FXColorBar(); void updatebar(); private: FXColorBar(const FXColorBar&); FXColorBar &operator=(const FXColorBar&); public: long onPaint(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onCmdSetHelp(FXObject*,FXSelector,void*); long onCmdGetHelp(FXObject*,FXSelector,void*); long onCmdSetTip(FXObject*,FXSelector,void*); long onCmdGetTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); public: /// Construct color bar FXColorBar(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=FRAME_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Perform layout virtual void layout(); /// Change hue void setHue(FXfloat h); /// Return hue FXfloat getHue() const { return hsv[0]; } /// Change saturation void setSat(FXfloat s); /// Return saturation FXfloat getSat() const { return hsv[1]; } /// Change value void setVal(FXfloat v); /// Return value FXfloat getVal() const { return hsv[2]; } /// Change the color bar style FXuint getBarStyle() const; /// Get the color bar style void setBarStyle(FXuint style); /// Set status line help text for this color bar void setHelpText(const FXString& text){ help=text; } /// Get status line help text for this color bar const FXString& getHelpText() const { return help; } /// Set tool tip message for this color bar void setTipText(const FXString& text){ tip=text; } /// Get tool tip message for this color bar const FXString& getTipText() const { return tip; } /// Save color bar to a stream virtual void save(FXStream& store) const; /// Load color bar from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXColorBar(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXColorDialog.h000066400000000000000000000076751455751074500233050ustar00rootroot00000000000000/******************************************************************************** * * * C o l o r D i a l o g * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCOLORDIALOG_H #define FXCOLORDIALOG_H #ifndef FXDIALOGBOX_H #include "FXDialogBox.h" #endif namespace FX { class FXColorSelector; /** * The Color dialog is a standard dialog panel used to edit colors. * Colors can be edited via RGB (Red, Green, Blue additive color model), * via HSV (Hue, Saturation, Value color modal), via CMY (Cyan, Magenta, * Yellow subtractive color model), or by name. * Commonly used colors can be dragged into a number of small color wells * to be used repeatedly; colors dropped into the small color wells are * automatically saved into the registry for future use. */ class FXAPI FXColorDialog : public FXDialogBox { FXDECLARE(FXColorDialog) protected: FXColorSelector *colorbox; protected: static const FXchar sectionName[]; protected: FXColorDialog(){} void readRegistry(); void writeRegistry(); private: FXColorDialog(const FXColorDialog&); FXColorDialog &operator=(const FXColorDialog&); public: long onChgColor(FXObject*,FXSelector,void*); long onCmdColor(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); public: enum { ID_COLORSELECTOR=FXDialogBox::ID_LAST, ID_LAST }; public: /// Construct color dialog FXColorDialog(FXWindow* owner,const FXString& name,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Construct free-floating color dialog box FXColorDialog(FXApp* a,const FXString& name,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Create server-side resources virtual void create(); /// Destroy server-side resources virtual void destroy(); /// Set the color void setRGBA(FXColor clr); /// Get the color FXColor getRGBA() const; /// Change active panel void setActivePanel(FXint pnl=COLORTAB_COLOR_RING); /// Return active panel FXint getActivePanel() const; /// Change well color void setWellColor(FXint w,FXColor clr); /// Return well color FXColor getWellColor(FXint w) const; /// Change opaque only mode void setOpaqueOnly(FXbool forceopaque); /// Return true if only opaque colors allowed FXbool isOpaqueOnly() const; /// Save dialog to a stream virtual void save(FXStream& store) const; /// Load dialog from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXColorDialog(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXColorList.h000066400000000000000000000077311455751074500230120ustar00rootroot00000000000000/******************************************************************************** * * * C o l o r L i s t W i d g e t * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCOLORLIST_H #define FXCOLORLIST_H #ifndef FXLIST_H #include "FXList.h" #endif namespace FX { /// Color item class FXAPI FXColorItem : public FXListItem { FXDECLARE(FXColorItem) protected: FXColor color; private: FXColorItem(const FXColorItem&); FXColorItem& operator=(const FXColorItem&); protected: FXColorItem():color(0){} virtual void draw(const FXList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; virtual FXint hitItem(const FXList* list,FXint x,FXint y) const; public: /// Construct new item with given text, color, and user-data FXColorItem(const FXString& text,FXColor clr,void* ptr=nullptr):FXListItem(text,nullptr,ptr),color(clr){} /// Change item's color void setColor(FXColor clr){ color=clr; } /// Return item's color FXColor getColor() const { return color; } /// Return width of item as drawn in list virtual FXint getWidth(const FXList* list) const; /// Return height of item as drawn in list virtual FXint getHeight(const FXList* list) const; }; /** * A ColorList Widget displays a list of colors. */ class FXAPI FXColorList : public FXList { FXDECLARE(FXColorList) protected: FXColorList(){} virtual FXListItem *createItem(const FXString& text,FXIcon* icon,void* ptr); private: FXColorList(const FXColorList&); FXColorList &operator=(const FXColorList&); public: /// Construct a list with initially no items in it FXColorList(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=LIST_BROWSESELECT,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Fill list by appending color items from array of strings and array of colors FXint fillItems(const FXchar *const *strings,FXColor *colors=nullptr,void* ptr=nullptr,FXbool notify=false); /// Insert item at index with given text, color, and user-data pointer FXint insertItem(FXint index,const FXString& text,FXColor color=0,void* ptr=nullptr,FXbool notify=false); /// Append new item with given text, color, and user-data pointer FXint appendItem(const FXString& text,FXColor color=0,void* ptr=nullptr,FXbool notify=false); /// Prepend new item with given text, color, and user-data pointer FXint prependItem(const FXString& text,FXColor color=0,void* ptr=nullptr,FXbool notify=false); /// Change item color void setItemColor(FXint index,FXColor color); /// Return item color FXColor getItemColor(FXint index) const; }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXColorRing.h000066400000000000000000000143201455751074500227660ustar00rootroot00000000000000/******************************************************************************** * * * C o l o r R i n g W i d g e t * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCOLORRING_H #define FXCOLORRING_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { class FXImage; /** * A ColorRing widget provides an intuitive way to specify a color. * The outer ring of the widget is rotated to control the hue of the color * being specified, while the inner triangle varies the color saturation * and the brightness of the color. The color saturation axis of the * triangle goes from a fully saturated "pure" color to "pastel" color; * the brightness goes from black to a bright color. * ColorRing supports justify options to allow control of the placement of * the ring inside the rectangular space of the widget. */ class FXAPI FXColorRing : public FXFrame { FXDECLARE(FXColorRing) protected: FXImage *dial; // HSV dial image FXfloat hsv[3]; // Hue, saturation, value FXint ringwidth; // Width of hue ring FXint ringouter; // Outer radius FXint ringinner; // Inner radius FXint dialx; // Dial x location FXint dialy; // Dial y location FXint satvalx; // Saturation value x FXint satvaly; // Saturation value y FXint huex; // Hue x FXint huey; // Hue y FXint clrx; // Color corner of triangle FXint clry; FXint blkx; // Black corner of triangle FXint blky; FXint whtx; // White corner of triangle FXint whty; FXString tip; // Tooltip value FXString help; // Help value FXuchar mode; // Mode widget is in protected: FXColorRing(); void updatering(); FXfloat hueFromXY(FXint x,FXint y) const; void hueToXY(FXint& x,FXint& y,FXfloat hue) const; void satValToXY(FXint& x,FXint& y,FXfloat s,FXfloat v) const; void satValFromXY(FXfloat& s,FXfloat& v,FXint x,FXint y) const; FXbool inCorner(FXint x,FXint y) const; FXbool inHueRing(FXint x,FXint y) const; FXbool inTriangle(FXint x,FXint y) const; protected: enum { MOUSE_NONE, // No mouse operation MOUSE_HUE, // Moving in hue-ring MOUSE_SATVAL // Moving in saturation/value triangle }; private: FXColorRing(const FXColorRing&); FXColorRing &operator=(const FXColorRing&); public: long onPaint(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onMouseWheel(FXObject*,FXSelector,void*); long onCmdSetHelp(FXObject*,FXSelector,void*); long onCmdGetHelp(FXObject*,FXSelector,void*); long onCmdSetTip(FXObject*,FXSelector,void*); long onCmdGetTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); public: /// Construct color ring with initial color clr FXColorRing(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=FRAME_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Perform layout virtual void layout(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Change hue void setHue(FXfloat h); /// Return hue FXfloat getHue() const { return hsv[0]; } /// Change saturation void setSat(FXfloat s); /// Return saturation FXfloat getSat() const { return hsv[1]; } /// Change value void setVal(FXfloat v); /// Return value FXfloat getVal() const { return hsv[2]; } /// Set hue, saturation, value void setHueSatVal(FXfloat h,FXfloat s,FXfloat v); /// Change width of hue ring void setRingWidth(FXint rw); /// Return width of hue ring FXint getRingWidth() const { return ringwidth; } /// Set the current justification mode void setJustify(FXuint style); /// Get the current justification mode FXuint getJustify() const; /// Set status line help text for this color well void setHelpText(const FXString& text){ help=text; } /// Get status line help text for this color well const FXString& getHelpText() const { return help; } /// Set tool tip message for this color well void setTipText(const FXString& text){ tip=text; } /// Get tool tip message for this color well const FXString& getTipText() const { return tip; } /// Save color well to a stream virtual void save(FXStream& store) const; /// Load color well from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXColorRing(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXColorSelector.h000066400000000000000000000152011455751074500236460ustar00rootroot00000000000000/******************************************************************************** * * * C o l o r S e l e c t o r * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCOLORSELECTOR_H #define FXCOLORSELECTOR_H #ifndef FXPACKER_H #include "FXPacker.h" #endif namespace FX { class FXTabBook; class FXColorBar; class FXColorWell; class FXColorWheel; class FXColorRing; class FXColorList; class FXList; class FXSlider; class FXTextField; class FXButton; class FXIcon; class FXLabel; // Color panel tabs enum { COLORTAB_COLOR_RING, COLORTAB_RED_GREEN_BLUE, COLORTAB_HUE_SATURATION_VALUE, COLORTAB_CYAN_MAGENTA_YELLOW, COLORTAB_COLOR_LIST }; /// Color selection widget class FXAPI FXColorSelector : public FXPacker { FXDECLARE(FXColorSelector) protected: FXTabBook *panels; // Color panes FXColorWell *well; // Main well FXColorList *list; // List of color names FXColorRing *wheel; // Color ring FXSlider *rgbaslider[4]; // RGBA sliders FXTextField *rgbatext[4]; // RGBA text fields FXSlider *hsvaslider[4]; // HSVA sliders FXTextField *hsvatext[4]; // HSVA text fields FXSlider *cmyslider[4]; // CMY sliders FXTextField *cmytext[4]; // CMY text fields FXColorWell *colorwells[24]; // Custom color wells FXIcon *eyedropicon; // Icon for eye dropper FXIcon *dialmodeicon; // Icon for dial mode FXIcon *rgbmodeicon; // Icon for RGB mode FXIcon *hsvmodeicon; // Icon for HSV mode FXIcon *cmymodeicon; // Icon for CMY mode FXIcon *txtmodeicon; // Icon for TEXT mode FXButton *accept; // Accept button FXButton *cancel; // Cancel button FXfloat rgba[4]; // Accurate RGBA color FXfloat hsva[4]; // Accurate HSVA color protected: FXColorSelector(){} void updateWell(); private: FXColorSelector(const FXColorSelector&); FXColorSelector &operator=(const FXColorSelector&); public: long onCmdWell(FXObject*,FXSelector,void*); long onChgWell(FXObject*,FXSelector,void*); long onCmdRGBSlider(FXObject*,FXSelector,void*); long onUpdRGBSlider(FXObject*,FXSelector,void*); long onCmdRGBText(FXObject*,FXSelector,void*); long onUpdRGBText(FXObject*,FXSelector,void*); long onCmdHSVSlider(FXObject*,FXSelector,void*); long onUpdHSVSlider(FXObject*,FXSelector,void*); long onCmdHSVText(FXObject*,FXSelector,void*); long onUpdHSVText(FXObject*,FXSelector,void*); long onCmdCMYSlider(FXObject*,FXSelector,void*); long onUpdCMYSlider(FXObject*,FXSelector,void*); long onCmdCMYText(FXObject*,FXSelector,void*); long onUpdCMYText(FXObject*,FXSelector,void*); long onCmdList(FXObject*,FXSelector,void*); long onCmdCustomWell(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdAlphaSlider(FXObject*,FXSelector,void*); long onUpdAlphaSlider(FXObject*,FXSelector,void*); long onCmdAlphaText(FXObject*,FXSelector,void*); long onUpdAlphaText(FXObject*,FXSelector,void*); long onUpdAlphaLabel(FXObject*,FXSelector,void*); long onCmdWheel(FXObject*,FXSelector,void*); long onUpdWheel(FXObject*,FXSelector,void*); long onCmdColorPick(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); public: enum { ID_CUSTOM_FIRST=FXPacker::ID_LAST, ID_CUSTOM_LAST=ID_CUSTOM_FIRST+24, ID_RGB_RED_SLIDER, ID_RGB_GREEN_SLIDER, ID_RGB_BLUE_SLIDER, ID_RGB_RED_TEXT, ID_RGB_GREEN_TEXT, ID_RGB_BLUE_TEXT, ID_HSV_HUE_SLIDER, ID_HSV_SATURATION_SLIDER, ID_HSV_VALUE_SLIDER, ID_HSV_HUE_TEXT, ID_HSV_SATURATION_TEXT, ID_HSV_VALUE_TEXT, ID_CMY_CYAN_SLIDER, ID_CMY_MAGENTA_SLIDER, ID_CMY_YELLOW_SLIDER, ID_CMY_CYAN_TEXT, ID_CMY_MAGENTA_TEXT, ID_CMY_YELLOW_TEXT, ID_DIAL_WHEEL, ID_COLOR_LIST, ID_WELL_CHANGED, ID_ALPHA_SLIDER, ID_ALPHA_TEXT, ID_ALPHA_LABEL, ID_COLORPICK, ID_LAST }; public: /// Construct a new ColorSelector FXColorSelector(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Return a pointer to the "Accept" button FXButton *acceptButton() const { return accept; } /// Return a pointer to the "Cancel" button FXButton *cancelButton() const { return cancel; } /// Set the selected color void setRGBA(FXColor color,FXbool notify=false); /// Get the selected color FXColor getRGBA() const; /// Change active panel void setActivePanel(FXint pnl=COLORTAB_COLOR_RING); /// Return active panel FXint getActivePanel() const; /// Change well color void setWellColor(FXint w,FXColor clr); /// Return well color FXColor getWellColor(FXint w) const; /// Change opaque only mode void setOpaqueOnly(FXbool opaque); /// Return true if only opaque colors allowed FXbool isOpaqueOnly() const; /// Save to a stream virtual void save(FXStream& store) const; /// Load from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXColorSelector(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXColorWell.h000066400000000000000000000144461455751074500230030ustar00rootroot00000000000000/******************************************************************************** * * * C o l o r W e l l W i d g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCOLORWELL_H #define FXCOLORWELL_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { // Color Well Styles enum { COLORWELL_OPAQUEONLY = 0x00008000, /// Colors must be opaque COLORWELL_SOURCEONLY = 0x00010000, /// ColorWell is never a target COLORWELL_NORMAL = FRAME_SUNKEN|FRAME_THICK }; /** * A color well is a widget which controls color settings. * Colors may be dragged and dropped from one color well to another, * or from color wells to other widgets that understand standard drag-and-drop * behavior, like for example the Gradient Bar widget. * A double-click inside a color well will bring up the standard * color dialog panel to edit the color well's color. * While the color value is being changed, the color well sends a SEL_CHANGED * to its target; at the end of the change, it sends a SEL_COMMAND. * The message data represents the current color value, of the type FXColor. */ class FXAPI FXColorWell : public FXFrame { FXDECLARE(FXColorWell) protected: FXColor wellColor[2]; // Pixel value of RGBA over black and white FXint wellSize; // Well size FXColor rgba; // Color with RGB and Alpha FXString tip; // Tooltip value FXString help; // Help value protected: FXColorWell(); private: FXColorWell(const FXColorWell&); FXColorWell &operator=(const FXColorWell&); public: long onPaint(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onBeginDrag(FXObject*,FXSelector,void*); long onEndDrag(FXObject*,FXSelector,void*); long onDragged(FXObject*,FXSelector,void*); long onFocusIn(FXObject*,FXSelector,void*); long onFocusOut(FXObject*,FXSelector,void*); long onDNDEnter(FXObject*,FXSelector,void*); long onDNDLeave(FXObject*,FXSelector,void*); long onDNDMotion(FXObject*,FXSelector,void*); long onDNDDrop(FXObject*,FXSelector,void*); long onDNDRequest(FXObject*,FXSelector,void*); long onClicked(FXObject*,FXSelector,void*); long onDoubleClicked(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdSetHelp(FXObject*,FXSelector,void*); long onCmdGetHelp(FXObject*,FXSelector,void*); long onCmdSetTip(FXObject*,FXSelector,void*); long onCmdGetTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); long onUpdColor(FXObject*,FXSelector,void*); long onChgColor(FXObject*,FXSelector,void*); long onCmdColor(FXObject*,FXSelector,void*); public: enum { ID_COLOR=FXFrame::ID_LAST, ID_LAST }; public: /// Construct color well with initial color clr FXColorWell(FXComposite* p,FXColor clr=0,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=COLORWELL_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Returns true because a color well can receive focus virtual FXbool canFocus() const; /// Move the focus to this window virtual void setFocus(); /// Remove the focus from this window virtual void killFocus(); /// Set color void setRGBA(FXColor clr,FXbool notify=false); /// Get color FXColor getRGBA() const { return rgba; } /// Set status line help text for this color well void setHelpText(const FXString& text){ help=text; } /// Get status line help text for this color well const FXString& getHelpText() const { return help; } /// Set tool tip message for this color well void setTipText(const FXString& text){ tip=text; } /// Get tool tip message for this color well const FXString& getTipText() const { return tip; } /// Change minimum well size void setWellSise(FXint ws); /// Return well size FXint getWellSize() const { return wellSize; } /// Return true if only opaque colors allowed FXbool isOpaqueOnly() const; /// Change opaque only mode void setOpaqueOnly(FXbool opaque); /// Return true if only a source FXbool isSourceOnly() const; /// Change source only mode void setSourceOnly(FXbool srconly); /// Save color well to a stream virtual void save(FXStream& store) const; /// Load color well from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXColorWell(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXColorWheel.h000066400000000000000000000120131455751074500231300ustar00rootroot00000000000000/******************************************************************************** * * * C o l o r W h e e l W i d g e t * * * ********************************************************************************* * Copyright (C) 2001,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCOLORWHEEL_H #define FXCOLORWHEEL_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { class FXImage; /** * A ColorWheel is a widget which controls the hue and saturation values of a * color. It is most often used together with a ColorBar which controls the * brighness. * ColorWheel supports justify options to allow control of the placement of * the wheel inside the rectangular space of the widget. */ class FXAPI FXColorWheel : public FXFrame { FXDECLARE(FXColorWheel) protected: FXImage *dial; // HSV dial image FXfloat hsv[3]; // Hue, saturation, value FXint dialx; // Dial x location FXint dialy; // Dial Y location FXint spotx; // Spot x location FXint spoty; // Spot Y location FXString tip; // Tooltip value FXString help; // Help value protected: FXColorWheel(); void updatedial(); void movespot(FXint x,FXint y); FXbool hstoxy(FXint& x,FXint& y,FXfloat h,FXfloat s) const; FXbool xytohs(FXfloat& h,FXfloat& s,FXint x,FXint y) const; private: FXColorWheel(const FXColorWheel&); FXColorWheel &operator=(const FXColorWheel&); public: long onPaint(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onMouseWheel(FXObject*,FXSelector,void*); long onCmdSetHelp(FXObject*,FXSelector,void*); long onCmdGetHelp(FXObject*,FXSelector,void*); long onCmdSetTip(FXObject*,FXSelector,void*); long onCmdGetTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); public: /// Construct color wheel with initial color clr FXColorWheel(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=FRAME_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Perform layout virtual void layout(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Change hue void setHue(FXfloat h); /// Return hue FXfloat getHue() const { return hsv[0]; } /// Change saturation void setSat(FXfloat s); /// Return saturation FXfloat getSat() const { return hsv[1]; } /// Change value void setVal(FXfloat v); /// Return value FXfloat getVal() const { return hsv[2]; } /// Set hue, saturation, value void setHueSatVal(FXfloat h,FXfloat s,FXfloat v); /// Set the current justification mode void setJustify(FXuint style); /// Get the current justification mode FXuint getJustify() const; /// Set status line help text for this color well void setHelpText(const FXString& text){ help=text; } /// Get status line help text for this color well const FXString& getHelpText() const { return help; } /// Set tool tip message for this color well void setTipText(const FXString& text){ tip=text; } /// Get tool tip message for this color well const FXString& getTipText() const { return tip; } /// Save color well to a stream virtual void save(FXStream& store) const; /// Load color well from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXColorWheel(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXColors.h000066400000000000000000001136571455751074500223460ustar00rootroot00000000000000/******************************************************************************** * * * C o l o r N a m e s * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCOLORS_H #define FXCOLORS_H namespace FX { namespace FXColors { /// Big list of colors you can reference by name const FXColor AliceBlue = FXRGBA(240,248,255,255); const FXColor AntiqueWhite = FXRGBA(250,235,215,255); const FXColor AntiqueWhite1 = FXRGBA(255,239,219,255); const FXColor AntiqueWhite2 = FXRGBA(238,223,204,255); const FXColor AntiqueWhite3 = FXRGBA(205,192,176,255); const FXColor AntiqueWhite4 = FXRGBA(139,131,120,255); const FXColor Aqua = FXRGBA( 0,255,255,255); const FXColor Aquamarine = FXRGBA(127,255,212,255); const FXColor Aquamarine1 = FXRGBA(127,255,212,255); const FXColor Aquamarine2 = FXRGBA(118,238,198,255); const FXColor Aquamarine3 = FXRGBA(102,205,170,255); const FXColor Aquamarine4 = FXRGBA( 69,139,116,255); const FXColor Azure = FXRGBA(240,255,255,255); const FXColor Azure1 = FXRGBA(240,255,255,255); const FXColor Azure2 = FXRGBA(224,238,238,255); const FXColor Azure3 = FXRGBA(193,205,205,255); const FXColor Azure4 = FXRGBA(131,139,139,255); const FXColor Banana = FXRGBA(227,207, 87,255); const FXColor Beige = FXRGBA(245,245,220,255); const FXColor Bisque = FXRGBA(255,228,196,255); const FXColor Bisque1 = FXRGBA(255,228,196,255); const FXColor Bisque2 = FXRGBA(238,213,183,255); const FXColor Bisque3 = FXRGBA(205,183,158,255); const FXColor Bisque4 = FXRGBA(139,125,107,255); const FXColor Black = FXRGBA( 0, 0, 0,255); const FXColor BlanchedAlmond = FXRGBA(255,235,205,255); const FXColor Blue = FXRGBA( 0, 0,255,255); const FXColor Blue1 = FXRGBA( 0, 0,255,255); const FXColor Blue2 = FXRGBA( 0, 0,238,255); const FXColor Blue3 = FXRGBA( 0, 0,205,255); const FXColor Blue4 = FXRGBA( 0, 0,139,255); const FXColor BlueViolet = FXRGBA(138, 43,226,255); const FXColor Brick = FXRGBA(156,102, 31,255); const FXColor Brown = FXRGBA(165, 42, 42,255); const FXColor Brown1 = FXRGBA(255, 64, 64,255); const FXColor Brown2 = FXRGBA(238, 59, 59,255); const FXColor Brown3 = FXRGBA(205, 51, 51,255); const FXColor Brown4 = FXRGBA(139, 35, 35,255); const FXColor Burlywood = FXRGBA(222,184,135,255); const FXColor Burlywood1 = FXRGBA(255,211,155,255); const FXColor Burlywood2 = FXRGBA(238,197,145,255); const FXColor Burlywood3 = FXRGBA(205,170,125,255); const FXColor Burlywood4 = FXRGBA(139,115, 85,255); const FXColor BurnedSienna = FXRGBA(138, 54, 15,255); const FXColor BurnedUmber = FXRGBA(138, 51, 36,255); const FXColor CadetBlue = FXRGBA( 95,158,160,255); const FXColor CadetBlue1 = FXRGBA(152,245,255,255); const FXColor CadetBlue2 = FXRGBA(142,229,238,255); const FXColor CadetBlue3 = FXRGBA(122,197,205,255); const FXColor CadetBlue4 = FXRGBA( 83,134,139,255); const FXColor CadmiumOrange = FXRGBA(255, 97, 3,255); const FXColor CadmiumRed = FXRGBA(227, 23, 13,255); const FXColor CadmiumYellow = FXRGBA(255,153, 18,255); const FXColor Carrot = FXRGBA(237,145, 33,255); const FXColor Chartreuse = FXRGBA(127,255, 0,255); const FXColor Chartreuse1 = FXRGBA(127,255, 0,255); const FXColor Chartreuse2 = FXRGBA(118,238, 0,255); const FXColor Chartreuse3 = FXRGBA(102,205, 0,255); const FXColor Chartreuse4 = FXRGBA( 69,139, 0,255); const FXColor Chocolate = FXRGBA(210,105, 30,255); const FXColor Chocolate1 = FXRGBA(255,127, 36,255); const FXColor Chocolate2 = FXRGBA(238,118, 33,255); const FXColor Chocolate3 = FXRGBA(205,102, 29,255); const FXColor Chocolate4 = FXRGBA(139, 69, 19,255); const FXColor Clear = FXRGBA( 0, 0, 0, 0); // Transparent const FXColor Cobalt = FXRGBA( 61, 89,171,255); const FXColor CobaltGreen = FXRGBA( 61,145, 64,255); const FXColor ColdGray = FXRGBA(128,138,135,255); const FXColor Coral = FXRGBA(255,127, 80,255); const FXColor Coral1 = FXRGBA(255,114, 86,255); const FXColor Coral2 = FXRGBA(238,106, 80,255); const FXColor Coral3 = FXRGBA(205, 91, 69,255); const FXColor Coral4 = FXRGBA(139, 62, 47,255); const FXColor CornflowerBlue = FXRGBA(100,149,237,255); const FXColor Cornsilk = FXRGBA(255,248,220,255); const FXColor Cornsilk1 = FXRGBA(255,248,220,255); const FXColor Cornsilk2 = FXRGBA(238,232,205,255); const FXColor Cornsilk3 = FXRGBA(205,200,177,255); const FXColor Cornsilk4 = FXRGBA(139,136,120,255); const FXColor Crimson = FXRGBA(220, 20, 60,255); const FXColor Cyan = FXRGBA( 0,255,255,255); const FXColor Cyan1 = FXRGBA( 0,255,255,255); const FXColor Cyan2 = FXRGBA( 0,238,238,255); const FXColor Cyan3 = FXRGBA( 0,205,205,255); const FXColor Cyan4 = FXRGBA( 0,139,139,255); const FXColor DarkBlue = FXRGBA( 0, 0,139,255); const FXColor DarkCyan = FXRGBA( 0,139,139,255); const FXColor DarkGoldenrod = FXRGBA(184,134, 11,255); const FXColor DarkGoldenrod1 = FXRGBA(255,185, 15,255); const FXColor DarkGoldenrod2 = FXRGBA(238,173, 14,255); const FXColor DarkGoldenrod3 = FXRGBA(205,149, 12,255); const FXColor DarkGoldenrod4 = FXRGBA(139,101, 8,255); const FXColor DarkGray = FXRGBA(169,169,169,255); const FXColor DarkGreen = FXRGBA( 0,100, 0,255); const FXColor DarkKhaki = FXRGBA(189,183,107,255); const FXColor DarkMagenta = FXRGBA(139, 0,139,255); const FXColor DarkOliveGreen = FXRGBA( 85,107, 47,255); const FXColor DarkOliveGreen1 = FXRGBA(202,255,112,255); const FXColor DarkOliveGreen2 = FXRGBA(188,238,104,255); const FXColor DarkOliveGreen3 = FXRGBA(162,205, 90,255); const FXColor DarkOliveGreen4 = FXRGBA(110,139, 61,255); const FXColor DarkOrange = FXRGBA(255,140, 0,255); const FXColor DarkOrange1 = FXRGBA(255,127, 0,255); const FXColor DarkOrange2 = FXRGBA(238,118, 0,255); const FXColor DarkOrange3 = FXRGBA(205,102, 0,255); const FXColor DarkOrange4 = FXRGBA(139, 69, 0,255); const FXColor DarkOrchid = FXRGBA(153, 50,204,255); const FXColor DarkOrchid1 = FXRGBA(191, 62,255,255); const FXColor DarkOrchid2 = FXRGBA(178, 58,238,255); const FXColor DarkOrchid3 = FXRGBA(154, 50,205,255); const FXColor DarkOrchid4 = FXRGBA(104, 34,139,255); const FXColor DarkRed = FXRGBA(139, 0, 0,255); const FXColor DarkSalmon = FXRGBA(233,150,122,255); const FXColor DarkSeaGreen = FXRGBA(143,188,143,255); const FXColor DarkSeaGreen1 = FXRGBA(193,255,193,255); const FXColor DarkSeaGreen2 = FXRGBA(180,238,180,255); const FXColor DarkSeaGreen3 = FXRGBA(155,205,155,255); const FXColor DarkSeaGreen4 = FXRGBA(105,139,105,255); const FXColor DarkSlateBlue = FXRGBA( 72, 61,139,255); const FXColor DarkSlateGray = FXRGBA( 47, 79, 79,255); const FXColor DarkSlateGray1 = FXRGBA(151,255,255,255); const FXColor DarkSlateGray2 = FXRGBA(141,238,238,255); const FXColor DarkSlateGray3 = FXRGBA(121,205,205,255); const FXColor DarkSlateGray4 = FXRGBA( 82,139,139,255); const FXColor DarkTurquoise = FXRGBA( 0,206,209,255); const FXColor DarkViolet = FXRGBA(148, 0,211,255); const FXColor DeepPink = FXRGBA(255, 20,147,255); const FXColor DeepPink1 = FXRGBA(255, 20,147,255); const FXColor DeepPink2 = FXRGBA(238, 18,137,255); const FXColor DeepPink3 = FXRGBA(205, 16,118,255); const FXColor DeepPink4 = FXRGBA(139, 10, 80,255); const FXColor DeepSkyBlue = FXRGBA( 0,191,255,255); const FXColor DeepSkyBlue1 = FXRGBA( 0,191,255,255); const FXColor DeepSkyBlue2 = FXRGBA( 0,178,238,255); const FXColor DeepSkyBlue3 = FXRGBA( 0,154,205,255); const FXColor DeepSkyBlue4 = FXRGBA( 0,104,139,255); const FXColor DimGray = FXRGBA(105,105,105,255); const FXColor DodgerBlue = FXRGBA( 30,144,255,255); const FXColor DodgerBlue1 = FXRGBA( 30,144,255,255); const FXColor DodgerBlue2 = FXRGBA( 28,134,238,255); const FXColor DodgerBlue3 = FXRGBA( 24,116,205,255); const FXColor DodgerBlue4 = FXRGBA( 16, 78,139,255); const FXColor Eggshell = FXRGBA(252,230,201,255); const FXColor EmeraldGreen = FXRGBA( 0,201, 87,255); const FXColor Firebrick = FXRGBA(178, 34, 34,255); const FXColor Firebrick1 = FXRGBA(255, 48, 48,255); const FXColor Firebrick2 = FXRGBA(238, 44, 44,255); const FXColor Firebrick3 = FXRGBA(205, 38, 38,255); const FXColor Firebrick4 = FXRGBA(139, 26, 26,255); const FXColor FloralWhite = FXRGBA(255,250,240,255); const FXColor ForestGreen = FXRGBA( 34,139, 34,255); const FXColor Fuchsia = FXRGBA(255, 0,255,255); const FXColor Gainsboro = FXRGBA(220,220,220,255); const FXColor GhostWhite = FXRGBA(248,248,255,255); const FXColor Gold = FXRGBA(255,215, 0,255); const FXColor Gold1 = FXRGBA(255,215, 0,255); const FXColor Gold2 = FXRGBA(238,201, 0,255); const FXColor Gold3 = FXRGBA(205,173, 0,255); const FXColor Gold4 = FXRGBA(139,117, 0,255); const FXColor Goldenrod = FXRGBA(218,165, 32,255); const FXColor Goldenrod1 = FXRGBA(255,193, 37,255); const FXColor Goldenrod2 = FXRGBA(238,180, 34,255); const FXColor Goldenrod3 = FXRGBA(205,155, 29,255); const FXColor Goldenrod4 = FXRGBA(139,105, 20,255); const FXColor Gray = FXRGBA(190,190,190,255); const FXColor Gray0 = FXRGBA( 0, 0, 0,255); // More than Fifty Shades of Grey const FXColor Gray1 = FXRGBA( 3, 3, 3,255); const FXColor Gray2 = FXRGBA( 5, 5, 5,255); const FXColor Gray3 = FXRGBA( 8, 8, 8,255); const FXColor Gray4 = FXRGBA( 10, 10, 10,255); const FXColor Gray5 = FXRGBA( 13, 13, 13,255); const FXColor Gray6 = FXRGBA( 15, 15, 15,255); const FXColor Gray7 = FXRGBA( 18, 18, 18,255); const FXColor Gray8 = FXRGBA( 20, 20, 20,255); const FXColor Gray9 = FXRGBA( 23, 23, 23,255); const FXColor Gray10 = FXRGBA( 26, 26, 26,255); const FXColor Gray11 = FXRGBA( 28, 28, 28,255); const FXColor Gray12 = FXRGBA( 31, 31, 31,255); const FXColor Gray13 = FXRGBA( 33, 33, 33,255); const FXColor Gray14 = FXRGBA( 36, 36, 36,255); const FXColor Gray15 = FXRGBA( 38, 38, 38,255); const FXColor Gray16 = FXRGBA( 41, 41, 41,255); const FXColor Gray17 = FXRGBA( 43, 43, 43,255); const FXColor Gray18 = FXRGBA( 46, 46, 46,255); const FXColor Gray19 = FXRGBA( 48, 48, 48,255); const FXColor Gray20 = FXRGBA( 51, 51, 51,255); const FXColor Gray21 = FXRGBA( 54, 54, 54,255); const FXColor Gray22 = FXRGBA( 56, 56, 56,255); const FXColor Gray23 = FXRGBA( 59, 59, 59,255); const FXColor Gray24 = FXRGBA( 61, 61, 61,255); const FXColor Gray25 = FXRGBA( 64, 64, 64,255); const FXColor Gray26 = FXRGBA( 66, 66, 66,255); const FXColor Gray27 = FXRGBA( 69, 69, 69,255); const FXColor Gray28 = FXRGBA( 71, 71, 71,255); const FXColor Gray29 = FXRGBA( 74, 74, 74,255); const FXColor Gray30 = FXRGBA( 77, 77, 77,255); const FXColor Gray31 = FXRGBA( 79, 79, 79,255); const FXColor Gray32 = FXRGBA( 82, 82, 82,255); const FXColor Gray33 = FXRGBA( 84, 84, 84,255); const FXColor Gray34 = FXRGBA( 87, 87, 87,255); const FXColor Gray35 = FXRGBA( 89, 89, 89,255); const FXColor Gray36 = FXRGBA( 92, 92, 92,255); const FXColor Gray37 = FXRGBA( 94, 94, 94,255); const FXColor Gray38 = FXRGBA( 97, 97, 97,255); const FXColor Gray39 = FXRGBA( 99, 99, 99,255); const FXColor Gray40 = FXRGBA(102,102,102,255); const FXColor Gray41 = FXRGBA(105,105,105,255); const FXColor Gray42 = FXRGBA(107,107,107,255); const FXColor Gray43 = FXRGBA(110,110,110,255); const FXColor Gray44 = FXRGBA(112,112,112,255); const FXColor Gray45 = FXRGBA(115,115,115,255); const FXColor Gray46 = FXRGBA(117,117,117,255); const FXColor Gray47 = FXRGBA(120,120,120,255); const FXColor Gray48 = FXRGBA(122,122,122,255); const FXColor Gray49 = FXRGBA(125,125,125,255); const FXColor Gray50 = FXRGBA(127,127,127,255); const FXColor Gray51 = FXRGBA(130,130,130,255); const FXColor Gray52 = FXRGBA(133,133,133,255); const FXColor Gray53 = FXRGBA(135,135,135,255); const FXColor Gray54 = FXRGBA(138,138,138,255); const FXColor Gray55 = FXRGBA(140,140,140,255); const FXColor Gray56 = FXRGBA(143,143,143,255); const FXColor Gray57 = FXRGBA(145,145,145,255); const FXColor Gray58 = FXRGBA(148,148,148,255); const FXColor Gray59 = FXRGBA(150,150,150,255); const FXColor Gray60 = FXRGBA(153,153,153,255); const FXColor Gray61 = FXRGBA(156,156,156,255); const FXColor Gray62 = FXRGBA(158,158,158,255); const FXColor Gray63 = FXRGBA(161,161,161,255); const FXColor Gray64 = FXRGBA(163,163,163,255); const FXColor Gray65 = FXRGBA(166,166,166,255); const FXColor Gray66 = FXRGBA(168,168,168,255); const FXColor Gray67 = FXRGBA(171,171,171,255); const FXColor Gray68 = FXRGBA(173,173,173,255); const FXColor Gray69 = FXRGBA(176,176,176,255); const FXColor Gray70 = FXRGBA(179,179,179,255); const FXColor Gray71 = FXRGBA(181,181,181,255); const FXColor Gray72 = FXRGBA(184,184,184,255); const FXColor Gray73 = FXRGBA(186,186,186,255); const FXColor Gray74 = FXRGBA(189,189,189,255); const FXColor Gray75 = FXRGBA(191,191,191,255); const FXColor Gray76 = FXRGBA(194,194,194,255); const FXColor Gray77 = FXRGBA(196,196,196,255); const FXColor Gray78 = FXRGBA(199,199,199,255); const FXColor Gray79 = FXRGBA(201,201,201,255); const FXColor Gray80 = FXRGBA(204,204,204,255); const FXColor Gray81 = FXRGBA(207,207,207,255); const FXColor Gray82 = FXRGBA(209,209,209,255); const FXColor Gray83 = FXRGBA(212,212,212,255); const FXColor Gray84 = FXRGBA(214,214,214,255); const FXColor Gray85 = FXRGBA(217,217,217,255); const FXColor Gray86 = FXRGBA(219,219,219,255); const FXColor Gray87 = FXRGBA(222,222,222,255); const FXColor Gray88 = FXRGBA(224,224,224,255); const FXColor Gray89 = FXRGBA(227,227,227,255); const FXColor Gray90 = FXRGBA(229,229,229,255); const FXColor Gray91 = FXRGBA(232,232,232,255); const FXColor Gray92 = FXRGBA(235,235,235,255); const FXColor Gray93 = FXRGBA(237,237,237,255); const FXColor Gray94 = FXRGBA(240,240,240,255); const FXColor Gray95 = FXRGBA(242,242,242,255); const FXColor Gray96 = FXRGBA(245,245,245,255); const FXColor Gray97 = FXRGBA(247,247,247,255); const FXColor Gray98 = FXRGBA(250,250,250,255); const FXColor Gray99 = FXRGBA(252,252,252,255); const FXColor Gray100 = FXRGBA(255,255,255,255); const FXColor Green = FXRGBA( 0,255, 0,255); const FXColor Green1 = FXRGBA( 0,255, 0,255); const FXColor Green2 = FXRGBA( 0,238, 0,255); const FXColor Green3 = FXRGBA( 0,205, 0,255); const FXColor Green4 = FXRGBA( 0,139, 0,255); const FXColor GreenYellow = FXRGBA(173,255, 47,255); const FXColor Honeydew = FXRGBA(240,255,240,255); const FXColor Honeydew1 = FXRGBA(240,255,240,255); const FXColor Honeydew2 = FXRGBA(224,238,224,255); const FXColor Honeydew3 = FXRGBA(193,205,193,255); const FXColor Honeydew4 = FXRGBA(131,139,131,255); const FXColor HotPink = FXRGBA(255,105,180,255); const FXColor HotPink1 = FXRGBA(255,110,180,255); const FXColor HotPink2 = FXRGBA(238,106,167,255); const FXColor HotPink3 = FXRGBA(205, 96,144,255); const FXColor HotPink4 = FXRGBA(139, 58, 98,255); const FXColor IndianRed = FXRGBA(205, 92, 92,255); const FXColor IndianRed1 = FXRGBA(255,106,106,255); const FXColor IndianRed2 = FXRGBA(238, 99, 99,255); const FXColor IndianRed3 = FXRGBA(205, 85, 85,255); const FXColor IndianRed4 = FXRGBA(139, 58, 58,255); const FXColor Indigo = FXRGBA( 75, 0,130,255); const FXColor Ivory = FXRGBA(255,255,240,255); const FXColor Ivory1 = FXRGBA(255,255,240,255); const FXColor Ivory2 = FXRGBA(238,238,224,255); const FXColor Ivory3 = FXRGBA(205,205,193,255); const FXColor Ivory4 = FXRGBA(139,139,131,255); const FXColor Khaki = FXRGBA(240,230,140,255); const FXColor Khaki1 = FXRGBA(255,246,143,255); const FXColor Khaki2 = FXRGBA(238,230,133,255); const FXColor Khaki3 = FXRGBA(205,198,115,255); const FXColor Khaki4 = FXRGBA(139,134, 78,255); const FXColor Lavender = FXRGBA(230,230,250,255); const FXColor LavenderBlush = FXRGBA(255,240,245,255); const FXColor LavenderBlush1 = FXRGBA(255,240,245,255); const FXColor LavenderBlush2 = FXRGBA(238,224,229,255); const FXColor LavenderBlush3 = FXRGBA(205,193,197,255); const FXColor LavenderBlush4 = FXRGBA(139,131,134,255); const FXColor LawnGreen = FXRGBA(124,252, 0,255); const FXColor LemonChiffon = FXRGBA(255,250,205,255); const FXColor LemonChiffon1 = FXRGBA(255,250,205,255); const FXColor LemonChiffon2 = FXRGBA(238,233,191,255); const FXColor LemonChiffon3 = FXRGBA(205,201,165,255); const FXColor LemonChiffon4 = FXRGBA(139,137,112,255); const FXColor LightBlue = FXRGBA(173,216,230,255); const FXColor LightBlue1 = FXRGBA(191,239,255,255); const FXColor LightBlue2 = FXRGBA(178,223,238,255); const FXColor LightBlue3 = FXRGBA(154,192,205,255); const FXColor LightBlue4 = FXRGBA(104,131,139,255); const FXColor LightCoral = FXRGBA(240,128,128,255); const FXColor LightCyan = FXRGBA(224,255,255,255); const FXColor LightCyan1 = FXRGBA(224,255,255,255); const FXColor LightCyan2 = FXRGBA(209,238,238,255); const FXColor LightCyan3 = FXRGBA(180,205,205,255); const FXColor LightCyan4 = FXRGBA(122,139,139,255); const FXColor LightGoldenrod = FXRGBA(238,221,130,255); const FXColor LightGoldenrod1 = FXRGBA(255,236,139,255); const FXColor LightGoldenrod2 = FXRGBA(238,220,130,255); const FXColor LightGoldenrod3 = FXRGBA(205,190,112,255); const FXColor LightGoldenrod4 = FXRGBA(139,129, 76,255); const FXColor LightGoldenrodYellow = FXRGBA(250,250,210,255); const FXColor LightGray = FXRGBA(211,211,211,255); const FXColor LightGreen = FXRGBA(144,238,144,255); const FXColor LightPink = FXRGBA(255,182,193,255); const FXColor LightPink1 = FXRGBA(255,174,185,255); const FXColor LightPink2 = FXRGBA(238,162,173,255); const FXColor LightPink3 = FXRGBA(205,140,149,255); const FXColor LightPink4 = FXRGBA(139, 95,101,255); const FXColor LightSalmon = FXRGBA(255,160,122,255); const FXColor LightSalmon1 = FXRGBA(255,160,122,255); const FXColor LightSalmon2 = FXRGBA(238,149,114,255); const FXColor LightSalmon3 = FXRGBA(205,129, 98,255); const FXColor LightSalmon4 = FXRGBA(139, 87, 66,255); const FXColor LightSeaGreen = FXRGBA( 32,178,170,255); const FXColor LightSkyBlue = FXRGBA(135,206,250,255); const FXColor LightSkyBlue1 = FXRGBA(176,226,255,255); const FXColor LightSkyBlue2 = FXRGBA(164,211,238,255); const FXColor LightSkyBlue3 = FXRGBA(141,182,205,255); const FXColor LightSkyBlue4 = FXRGBA( 96,123,139,255); const FXColor LightSlateBlue = FXRGBA(132,112,255,255); const FXColor LightSlateGray = FXRGBA(119,136,153,255); const FXColor LightSteelBlue = FXRGBA(176,196,222,255); const FXColor LightSteelBlue1 = FXRGBA(202,225,255,255); const FXColor LightSteelBlue2 = FXRGBA(188,210,238,255); const FXColor LightSteelBlue3 = FXRGBA(162,181,205,255); const FXColor LightSteelBlue4 = FXRGBA(110,123,139,255); const FXColor LightYellow = FXRGBA(255,255,224,255); const FXColor LightYellow1 = FXRGBA(255,255,224,255); const FXColor LightYellow2 = FXRGBA(238,238,209,255); const FXColor LightYellow3 = FXRGBA(205,205,180,255); const FXColor LightYellow4 = FXRGBA(139,139,122,255); const FXColor Lime = FXRGBA( 0,255, 0,255); const FXColor LimeGreen = FXRGBA( 50,205, 50,255); const FXColor Linen = FXRGBA(250,240,230,255); const FXColor Magenta = FXRGBA(255, 0,255,255); const FXColor Magenta1 = FXRGBA(255, 0,255,255); const FXColor Magenta2 = FXRGBA(238, 0,238,255); const FXColor Magenta3 = FXRGBA(205, 0,205,255); const FXColor Magenta4 = FXRGBA(139, 0,139,255); const FXColor Maroon = FXRGBA(176, 48, 96,255); const FXColor Maroon1 = FXRGBA(255, 52,179,255); const FXColor Maroon2 = FXRGBA(238, 48,167,255); const FXColor Maroon3 = FXRGBA(205, 41,144,255); const FXColor Maroon4 = FXRGBA(139, 28, 98,255); const FXColor MediumAquamarine = FXRGBA(102,205,170,255); const FXColor MediumBlue = FXRGBA( 0, 0,205,255); const FXColor MediumOrchid = FXRGBA(186, 85,211,255); const FXColor MediumOrchid1 = FXRGBA(224,102,255,255); const FXColor MediumOrchid2 = FXRGBA(209, 95,238,255); const FXColor MediumOrchid3 = FXRGBA(180, 82,205,255); const FXColor MediumOrchid4 = FXRGBA(122, 55,139,255); const FXColor MediumPurple = FXRGBA(147,112,219,255); const FXColor MediumPurple1 = FXRGBA(171,130,255,255); const FXColor MediumPurple2 = FXRGBA(159,121,238,255); const FXColor MediumPurple3 = FXRGBA(137,104,205,255); const FXColor MediumPurple4 = FXRGBA( 93, 71,139,255); const FXColor MediumSeaGreen = FXRGBA( 60,179,113,255); const FXColor MediumSlateBlue = FXRGBA(123,104,238,255); const FXColor MediumSpringGreen = FXRGBA( 0,250,154,255); const FXColor MediumTurquoise = FXRGBA( 72,209,204,255); const FXColor MediumVioletRed = FXRGBA(199, 21,133,255); const FXColor MidnightBlue = FXRGBA( 25, 25,112,255); const FXColor MintCream = FXRGBA(245,255,250,255); const FXColor MistyRose = FXRGBA(255,228,225,255); const FXColor MistyRose1 = FXRGBA(255,228,225,255); const FXColor MistyRose2 = FXRGBA(238,213,210,255); const FXColor MistyRose3 = FXRGBA(205,183,181,255); const FXColor MistyRose4 = FXRGBA(139,125,123,255); const FXColor Moccasin = FXRGBA(255,228,181,255); const FXColor NavajoWhite = FXRGBA(255,222,173,255); const FXColor NavajoWhite1 = FXRGBA(255,222,173,255); const FXColor NavajoWhite2 = FXRGBA(238,207,161,255); const FXColor NavajoWhite3 = FXRGBA(205,179,139,255); const FXColor NavajoWhite4 = FXRGBA(139,121, 94,255); const FXColor Navy = FXRGBA( 0, 0,128,255); const FXColor NavyBlue = FXRGBA( 0, 0,128,255); const FXColor OldLace = FXRGBA(253,245,230,255); const FXColor Olive = FXRGBA(128,128, 0,255); const FXColor OliveDrab = FXRGBA(107,142, 35,255); const FXColor OliveDrab1 = FXRGBA(192,255, 62,255); const FXColor OliveDrab2 = FXRGBA(179,238, 58,255); const FXColor OliveDrab3 = FXRGBA(154,205, 50,255); const FXColor OliveDrab4 = FXRGBA(105,139, 34,255); const FXColor Orange = FXRGBA(255,165, 0,255); const FXColor Orange1 = FXRGBA(255,165, 0,255); const FXColor Orange2 = FXRGBA(238,154, 0,255); const FXColor Orange3 = FXRGBA(205,133, 0,255); const FXColor Orange4 = FXRGBA(139, 90, 0,255); const FXColor OrangeRed = FXRGBA(255, 69, 0,255); const FXColor OrangeRed1 = FXRGBA(255, 69, 0,255); const FXColor OrangeRed2 = FXRGBA(238, 64, 0,255); const FXColor OrangeRed3 = FXRGBA(205, 55, 0,255); const FXColor OrangeRed4 = FXRGBA(139, 37, 0,255); const FXColor Orchid = FXRGBA(218,112,214,255); const FXColor Orchid1 = FXRGBA(255,131,250,255); const FXColor Orchid2 = FXRGBA(238,122,233,255); const FXColor Orchid3 = FXRGBA(205,105,201,255); const FXColor Orchid4 = FXRGBA(139, 71,137,255); const FXColor PaleGoldenrod = FXRGBA(238,232,170,255); const FXColor PaleGreen = FXRGBA(152,251,152,255); const FXColor PaleGreen1 = FXRGBA(154,255,154,255); const FXColor PaleGreen2 = FXRGBA(144,238,144,255); const FXColor PaleGreen3 = FXRGBA(124,205,124,255); const FXColor PaleGreen4 = FXRGBA( 84,139, 84,255); const FXColor PaleTurquoise = FXRGBA(175,238,238,255); const FXColor PaleTurquoise1 = FXRGBA(187,255,255,255); const FXColor PaleTurquoise2 = FXRGBA(174,238,238,255); const FXColor PaleTurquoise3 = FXRGBA(150,205,205,255); const FXColor PaleTurquoise4 = FXRGBA(102,139,139,255); const FXColor PaleVioletRed = FXRGBA(219,112,147,255); const FXColor PaleVioletRed1 = FXRGBA(255,130,171,255); const FXColor PaleVioletRed2 = FXRGBA(238,121,159,255); const FXColor PaleVioletRed3 = FXRGBA(205,104,137,255); const FXColor PaleVioletRed4 = FXRGBA(139, 71, 93,255); const FXColor PapayaWhip = FXRGBA(255,239,213,255); const FXColor PeachPuff = FXRGBA(255,218,185,255); const FXColor PeachPuff1 = FXRGBA(255,218,185,255); const FXColor PeachPuff2 = FXRGBA(238,203,173,255); const FXColor PeachPuff3 = FXRGBA(205,175,149,255); const FXColor PeachPuff4 = FXRGBA(139,119,101,255); const FXColor Peru = FXRGBA(205,133, 63,255); const FXColor Pink = FXRGBA(255,192,203,255); const FXColor Pink1 = FXRGBA(255,181,197,255); const FXColor Pink2 = FXRGBA(238,169,184,255); const FXColor Pink3 = FXRGBA(205,145,158,255); const FXColor Pink4 = FXRGBA(139, 99,108,255); const FXColor Plum = FXRGBA(221,160,221,255); const FXColor Plum1 = FXRGBA(255,187,255,255); const FXColor Plum2 = FXRGBA(238,174,238,255); const FXColor Plum3 = FXRGBA(205,150,205,255); const FXColor Plum4 = FXRGBA(139,102,139,255); const FXColor PowderBlue = FXRGBA(176,224,230,255); const FXColor Purple = FXRGBA(160, 32,240,255); const FXColor Purple1 = FXRGBA(155, 48,255,255); const FXColor Purple2 = FXRGBA(145, 44,238,255); const FXColor Purple3 = FXRGBA(125, 38,205,255); const FXColor Purple4 = FXRGBA( 85, 26,139,255); const FXColor Raspberry = FXRGBA(135, 38, 87,255); const FXColor Red = FXRGBA(255, 0, 0,255); const FXColor Red1 = FXRGBA(255, 0, 0,255); const FXColor Red2 = FXRGBA(238, 0, 0,255); const FXColor Red3 = FXRGBA(205, 0, 0,255); const FXColor Red4 = FXRGBA(139, 0, 0,255); const FXColor RosyBrown = FXRGBA(188,143,143,255); const FXColor RosyBrown1 = FXRGBA(255,193,193,255); const FXColor RosyBrown2 = FXRGBA(238,180,180,255); const FXColor RosyBrown3 = FXRGBA(205,155,155,255); const FXColor RosyBrown4 = FXRGBA(139,105,105,255); const FXColor RoyalBlue = FXRGBA( 65,105,225,255); const FXColor RoyalBlue1 = FXRGBA( 72,118,255,255); const FXColor RoyalBlue2 = FXRGBA( 67,110,238,255); const FXColor RoyalBlue3 = FXRGBA( 58, 95,205,255); const FXColor RoyalBlue4 = FXRGBA( 39, 64,139,255); const FXColor SaddleBrown = FXRGBA(139, 69, 19,255); const FXColor Salmon = FXRGBA(250,128,114,255); const FXColor Salmon1 = FXRGBA(255,140,105,255); const FXColor Salmon2 = FXRGBA(238,130, 98,255); const FXColor Salmon3 = FXRGBA(205,112, 84,255); const FXColor Salmon4 = FXRGBA(139, 76, 57,255); const FXColor SandyBrown = FXRGBA(244,164, 96,255); const FXColor SeaGreen = FXRGBA( 46,139, 87,255); const FXColor SeaGreen1 = FXRGBA( 84,255,159,255); const FXColor SeaGreen2 = FXRGBA( 78,238,148,255); const FXColor SeaGreen3 = FXRGBA( 67,205,128,255); const FXColor SeaGreen4 = FXRGBA( 46,139, 87,255); const FXColor Seashell = FXRGBA(255,245,238,255); const FXColor Seashell1 = FXRGBA(255,245,238,255); const FXColor Seashell2 = FXRGBA(238,229,222,255); const FXColor Seashell3 = FXRGBA(205,197,191,255); const FXColor Seashell4 = FXRGBA(139,134,130,255); const FXColor Sepia = FXRGBA( 94, 38, 18,255); const FXColor Sienna = FXRGBA(160, 82, 45,255); const FXColor Sienna1 = FXRGBA(255,130, 71,255); const FXColor Sienna2 = FXRGBA(238,121, 66,255); const FXColor Sienna3 = FXRGBA(205,104, 57,255); const FXColor Sienna4 = FXRGBA(139, 71, 38,255); const FXColor Silver = FXRGBA(192,192,192,255); const FXColor SkyBlue = FXRGBA(135,206,235,255); const FXColor SkyBlue1 = FXRGBA(135,206,255,255); const FXColor SkyBlue2 = FXRGBA(126,192,238,255); const FXColor SkyBlue3 = FXRGBA(108,166,205,255); const FXColor SkyBlue4 = FXRGBA( 74,112,139,255); const FXColor SlateBlue = FXRGBA(106, 90,205,255); const FXColor SlateBlue1 = FXRGBA(131,111,255,255); const FXColor SlateBlue2 = FXRGBA(122,103,238,255); const FXColor SlateBlue3 = FXRGBA(105, 89,205,255); const FXColor SlateBlue4 = FXRGBA( 71, 60,139,255); const FXColor SlateGray = FXRGBA(112,128,144,255); const FXColor SlateGray1 = FXRGBA(198,226,255,255); const FXColor SlateGray2 = FXRGBA(185,211,238,255); const FXColor SlateGray3 = FXRGBA(159,182,205,255); const FXColor SlateGray4 = FXRGBA(108,123,139,255); const FXColor Snow = FXRGBA(255,250,250,255); const FXColor Snow1 = FXRGBA(255,250,250,255); const FXColor Snow2 = FXRGBA(238,233,233,255); const FXColor Snow3 = FXRGBA(205,201,201,255); const FXColor Snow4 = FXRGBA(139,137,137,255); const FXColor SpringGreen = FXRGBA( 0,255,127,255); const FXColor SpringGreen1 = FXRGBA( 0,255,127,255); const FXColor SpringGreen2 = FXRGBA( 0,238,118,255); const FXColor SpringGreen3 = FXRGBA( 0,205,102,255); const FXColor SpringGreen4 = FXRGBA( 0,139, 69,255); const FXColor SteelBlue = FXRGBA( 70,130,180,255); const FXColor SteelBlue1 = FXRGBA( 99,184,255,255); const FXColor SteelBlue2 = FXRGBA( 92,172,238,255); const FXColor SteelBlue3 = FXRGBA( 79,148,205,255); const FXColor SteelBlue4 = FXRGBA( 54,100,139,255); const FXColor Tan = FXRGBA(210,180,140,255); const FXColor Tan1 = FXRGBA(255,165, 79,255); const FXColor Tan2 = FXRGBA(238,154, 73,255); const FXColor Tan3 = FXRGBA(205,133, 63,255); const FXColor Tan4 = FXRGBA(139, 90, 43,255); const FXColor Teal = FXRGBA( 0,128,128,255); const FXColor Thistle = FXRGBA(216,191,216,255); const FXColor Thistle1 = FXRGBA(255,225,255,255); const FXColor Thistle2 = FXRGBA(238,210,238,255); const FXColor Thistle3 = FXRGBA(205,181,205,255); const FXColor Thistle4 = FXRGBA(139,123,139,255); const FXColor Tomato = FXRGBA(255, 99, 71,255); const FXColor Tomato1 = FXRGBA(255, 99, 71,255); const FXColor Tomato2 = FXRGBA(238, 92, 66,255); const FXColor Tomato3 = FXRGBA(205, 79, 57,255); const FXColor Tomato4 = FXRGBA(139, 54, 38,255); const FXColor Turquoise = FXRGBA( 64,224,208,255); const FXColor Turquoise1 = FXRGBA( 0,245,255,255); const FXColor Turquoise2 = FXRGBA( 0,229,238,255); const FXColor Turquoise3 = FXRGBA( 0,197,205,255); const FXColor Turquoise4 = FXRGBA( 0,134,139,255); const FXColor Ultramarine = FXRGBA( 0, 42,143,255); const FXColor Violet = FXRGBA(238,130,238,255); const FXColor VioletRed = FXRGBA(208, 32,144,255); const FXColor VioletRed1 = FXRGBA(255, 62,150,255); const FXColor VioletRed2 = FXRGBA(238, 58,140,255); const FXColor VioletRed3 = FXRGBA(205, 50,120,255); const FXColor VioletRed4 = FXRGBA(139, 34, 82,255); const FXColor WarmGray = FXRGBA(128,128,105,255); const FXColor Wheat = FXRGBA(245,222,179,255); const FXColor Wheat1 = FXRGBA(255,231,186,255); const FXColor Wheat2 = FXRGBA(238,216,174,255); const FXColor Wheat3 = FXRGBA(205,186,150,255); const FXColor Wheat4 = FXRGBA(139,126,102,255); const FXColor White = FXRGBA(255,255,255,255); const FXColor WhiteSmoke = FXRGBA(245,245,245,255); const FXColor Yellow = FXRGBA(255,255, 0,255); const FXColor Yellow1 = FXRGBA(255,255, 0,255); const FXColor Yellow2 = FXRGBA(238,238, 0,255); const FXColor Yellow3 = FXRGBA(205,205, 0,255); const FXColor Yellow4 = FXRGBA(139,139, 0,255); const FXColor YellowGreen = FXRGBA(154,205, 50,255); } /// Names of commonly used colors extern FXAPI const FXchar *const colorName[683]; /// Values of corresponding colors extern FXAPI const FXColor colorValue[683]; /** * Determine the color value, given a color name. */ extern FXAPI FXColor colorFromName(const FXString& name); extern FXAPI FXColor colorFromName(const FXchar* name); /** * Determine the color name, given a color value. */ extern FXAPI FXString nameFromColor(FXColor color); extern FXAPI FXchar* nameFromColor(FXchar *name,FXColor color); /** * Blend source color over background color. */ extern FXAPI FXColor blendOverBackground(FXColor back,FXColor clr); /** * Blend source color over black background color. */ extern FXAPI FXColor blendOverBlack(FXColor clr); /** * Blend source color over white background color. */ extern FXAPI FXColor blendOverWhite(FXColor clr); /** * Blend color src toward color dst by a given percentage. */ extern FXAPI FXColor makeBlendColor(FXColor src,FXColor dst,FXint percent=50); /** * Compute a highlight color given a base color, brighten it up * toward white by given percentage. */ extern FXAPI FXColor makeHiliteColor(FXColor clr,FXint percent=33); /** * Compute a shadow color given a base color, darken it down toward * black by given percentage. */ extern FXAPI FXColor makeShadowColor(FXColor clr,FXint percent=33); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXComboBox.h000066400000000000000000000252721455751074500226100ustar00rootroot00000000000000/******************************************************************************** * * * C o m b o B o x W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCOMBOBOX_H #define FXCOMBOBOX_H #ifndef FXPACKER_H #include "FXPacker.h" #endif namespace FX { /// ComboBox styles enum { COMBOBOX_NO_REPLACE = 0, /// Leave the list the same COMBOBOX_REPLACE = 0x00020000, /// Replace current item with typed text COMBOBOX_INSERT_BEFORE = 0x00040000, /// Typed text inserted before current COMBOBOX_INSERT_AFTER = 0x00060000, /// Typed text inserted after current COMBOBOX_INSERT_FIRST = 0x00080000, /// Typed text inserted at begin of list COMBOBOX_INSERT_LAST = 0x000A0000, /// Typed text inserted at end of list COMBOBOX_STATIC = 0x00100000, /// Unchangable text box COMBOBOX_NORMAL = 0 /// Can type text but list is not changed }; class FXTextField; class FXMenuButton; class FXList; class FXPopup; /** * A Combo Box provides a way to select a string from a list of strings. * Unless COMBOBOX_STATIC is passed, it also allows the user to enter a new * string into the text field, for example if the desired entry is not in the * list of strings. Passing COMBOBOX_REPLACE, COMBOBOX_INSERT_BEFORE, COMBOBOX_INSERT_AFTER, * COMBOBOX_INSERT_FIRST, or COMBOBOX_INSERT_LAST causes a newly entered text to replace the * current one in the list, or be added before or after the current entry, or to be added at * the beginning or end of the list. * Combo Box is intended to enter text; if you need to enter a choice from a list of * options, it is recommended that the List Box widget is used instead. * When the text in the field is changed, a SEL_COMMAND will be send to the target. * The Combo Box can also receive ID_GETSTRINGVALUE and ID_SETSTRINGVALUE and so * on, which will behave similar to Text Field in that they will retrieve or update * the value of the field. */ class FXAPI FXComboBox : public FXPacker { FXDECLARE(FXComboBox) protected: FXTextField *field; FXMenuButton *button; FXList *list; FXPopup *pane; protected: FXComboBox(){} private: FXComboBox(const FXComboBox&); FXComboBox &operator=(const FXComboBox&); public: long onFocusUp(FXObject*,FXSelector,void*); long onFocusDown(FXObject*,FXSelector,void*); long onFocusSelf(FXObject*,FXSelector,void*); long onMouseWheel(FXObject*,FXSelector,void*); long onTextButton(FXObject*,FXSelector,void*); long onTextChanged(FXObject*,FXSelector,void*); long onTextCommand(FXObject*,FXSelector,void*); long onListClicked(FXObject*,FXSelector,void*); long onListCommand(FXObject*,FXSelector,void*); long onFwdToText(FXObject*,FXSelector,void*); long onUpdFmText(FXObject*,FXSelector,void*); public: enum { ID_LIST=FXPacker::ID_LAST, ID_TEXT, ID_LAST }; public: /// Construct a Combo Box widget with room to display cols columns of text FXComboBox(FXComposite *p,FXint cols,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=COMBOBOX_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Destroy server-side resources virtual void destroy(); /// Enable combo box virtual void enable(); /// Disable combo box virtual void disable(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Perform layout virtual void layout(); /// Return true if combobox is editable FXbool isEditable() const; /// Set editable state void setEditable(FXbool edit=true); /// Set the text; selects the matching item void setText(const FXString& text,FXbool notify=false); /// Get the text FXString getText() const; /// Set the number of columns void setNumColumns(FXint cols); /// Get the number of columns FXint getNumColumns() const; /// Change text justification mode; default is JUSTIFY_LEFT void setJustify(FXuint mode); /// Return text justification mode FXuint getJustify() const; /// Return the number of items in the list FXint getNumItems() const; /// Return the number of visible items FXint getNumVisible() const; /// Set the number of visible items in the drop down list void setNumVisible(FXint nvis); /// Return true if current item FXbool isItemCurrent(FXint index) const; /// Set the current item (index is zero-based) void setCurrentItem(FXint index,FXbool notify=false); /// Get the current item's index FXint getCurrentItem() const; /// Return the item at the given index FXString getItem(FXint index) const; /// Replace the item at index FXint setItem(FXint index,const FXString& text,FXptr ptr=nullptr,FXbool notify=false); /// Fill combo box by appending items from array of strings FXint fillItems(const FXchar *const *strings,FXbool notify=false); /// Fill combo box by appending items from array of strings FXint fillItems(const FXString* strings,FXbool notify=false); /// Fill combo box by appending items from newline separated strings FXint fillItems(const FXString& strings,FXbool notify=false); /// Insert a new item at index FXint insertItem(FXint index,const FXString& text,FXptr ptr=nullptr,FXbool notify=false); /// Append an item to the list FXint appendItem(const FXString& text,FXptr ptr=nullptr,FXbool notify=false); /// Prepend an item to the list FXint prependItem(const FXString& text,FXptr ptr=nullptr,FXbool notify=false); /// Move item from oldindex to newindex FXint moveItem(FXint newindex,FXint oldindex,FXbool notify=false); /// Remove this item from the list void removeItem(FXint index,FXbool notify=false); /// Remove all items from the list void clearItems(FXbool notify=false); /** * Search items by name, beginning from item start. If the start item * is -1 the search will start at the first item in the list. Flags * may be SEARCH_FORWARD or SEARCH_BACKWARD to control the search * direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP * to control whether the search wraps at the start or end of the list. * The option SEARCH_IGNORECASE causes a case-insensitive match. Finally, * passing SEARCH_PREFIX causes searching for a prefix of the item name. * Return -1 if no matching item is found. */ FXint findItem(const FXString& string,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; /** * Search items by associated user data, beginning from item start. If the * start item is -1 the search will start at the first item in the list. * Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control the * search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP * to control whether the search wraps at the start or end of the list. */ FXint findItemByData(FXptr ptr,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; /// Set text for specified item void setItemText(FXint index,const FXString& text); /// Get text for specified item FXString getItemText(FXint index) const; /// Set data pointer for specified item void setItemData(FXint index,FXptr ptr) const; /// Get data pointer for specified item FXptr getItemData(FXint index) const; /// Return true if item is enabled FXbool isItemEnabled(FXint index) const; /// Enable item FXbool enableItem(FXint index); /// Disable item FXbool disableItem(FXint index); /// Show or hide menu void showMenu(FXbool shw); /// Is the menu pane shown FXbool isMenuShown() const; /// Sort items using current sort function void sortItems(); /// Set text font void setFont(FXFont* fnt); /// Get text font FXFont* getFont() const; /// Set the combobox style. void setComboStyle(FXuint mode); /// Get the combobox style. FXuint getComboStyle() const; /// Change popup pane shrinkwrap mode void setShrinkWrap(FXbool flag); /// Return popup pane shrinkwrap mode FXbool getShrinkWrap() const; /// Set window background color virtual void setBackColor(FXColor clr); /// Get background color FXColor getBackColor() const; /// Change text color void setTextColor(FXColor clr); /// Return text color FXColor getTextColor() const; /// Change selected background color void setSelBackColor(FXColor clr); /// Return selected background color FXColor getSelBackColor() const; /// Change selected text color void setSelTextColor(FXColor clr); /// Return selected text color FXColor getSelTextColor() const; /// Return sort function FXListSortFunc getSortFunc() const; /// Change sort function void setSortFunc(FXListSortFunc func); /// Set the combobox help text void setHelpText(const FXString& txt); /// Get the combobox help text const FXString& getHelpText() const; /// Set the tool tip message for this combobox void setTipText(const FXString& txt); /// Get the tool tip message for this combobox const FXString& getTipText() const; /// Save combobox to a stream virtual void save(FXStream& store) const; /// Load combobox from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXComboBox(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCompletion.h000066400000000000000000000061201455751074500232000ustar00rootroot00000000000000/******************************************************************************** * * * C o m p l e t i o n C o u n t e r * * * ********************************************************************************* * Copyright (C) 2014,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCOMPLETION_H #define FXCOMPLETION_H namespace FX { class FXThreadPool; /** * A completion counter allows a single thread to monitor a number of ongoing * concurrent activities for completion. Each activity calls increment() on the * completion counter when started, and decrement() when finished. * The monitoring thread can call wait(), wait(nsec), or done() to determine * the status of the concurrent activity. * Only one thread is allowed to call any of the wait() functions; but multiple * threads can call increment() or decrement(). * The completion counter can not be destroyed until the last thread decrements * the counter back down to zero. */ class FXAPI FXCompletion { private: FXSemaphore semaphore; // Signalled when last task done volatile FXuint counter; // Task counter private: FXCompletion(const FXCompletion&); FXCompletion& operator=(const FXCompletion&); public: /// Initialize completion counter FXCompletion(); /// Return current counter value FXuint count() const { return counter; } /// Increment counter by cnt void increment(FXuint cnt=1); /// Decrement counter by cnt void decrement(FXuint cnt=1); /// Wait till count becomes zero again void wait(); /// Wait till count becomes zero, or timeout; return false if timed out FXbool wait(FXTime nsec); /// Return true if count is zero FXbool done() const { return (counter==0); } /// Wait till count becomes zero, then destroy ~FXCompletion(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXComplexd.h000066400000000000000000000201431455751074500226430ustar00rootroot00000000000000/******************************************************************************** * * * D o u b l e - P r e c i s i o n C o m p l e x N u m b e r * * * ********************************************************************************* * Copyright (C) 2006,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCOMPLEXD_H #define FXCOMPLEXD_H namespace FX { /// Double-precision complex class FXAPI FXComplexd { public: FXdouble re; FXdouble im; public: /// Default constructor; value is not initialized FXComplexd(){ } /// Construct from real FXComplexd(FXdouble r):re(r),im(0.0){ } /// Construct from components FXComplexd(FXdouble r,FXdouble i):re(r),im(i){ } /// Initialize from another complex FXComplexd(const FXComplexd& c):re(c.re),im(c.im){ } /// Set value from real FXComplexd& set(FXdouble r){ re=r; im=0.0; return *this; } /// Set value from components FXComplexd& set(FXdouble r,FXdouble i){ re=r; im=i; return *this;} /// Set value from another complex FXComplexd& set(const FXComplexd& c){ re=c.re; im=c.im; return *this;} /// Test if zero FXbool operator!() const { return (re==0.0) && (im==0.0); } /// Access real part FXdouble& real(){ return re; } const FXdouble& real() const { return re; } /// Access imaginary part FXdouble& imag(){ return im; } const FXdouble& imag() const { return im; } /// Squared modulus FXdouble modulus2() const { return re*re+im*im; } /// Modulus or absolute value of complex FXdouble modulus() const { return Math::sqrt(modulus2()); } /// Argument of complex FXdouble argument() const { return Math::atan2(im,re); } /// Return a non-const reference to the ith element FXdouble& operator[](FXint i){ return (&re)[i]; } /// Return a const reference to the ith element const FXdouble& operator[](FXint i) const { return (&re)[i]; } /// Unary FXComplexd operator+() const { return *this; } FXComplexd operator-() const { return FXComplexd(-re,-im); } /// Assignment from real FXComplexd& operator=(const FXdouble r){ return set(r); } /// Assignment from another complex FXComplexd& operator=(const FXComplexd& c){ return set(c); } /// Assigning operators with real FXComplexd& operator+=(FXdouble r){ re+=r; return *this; } FXComplexd& operator-=(FXdouble r){ re-=r; return *this; } FXComplexd& operator*=(FXdouble r){ re*=r; im*=r; return *this; } FXComplexd& operator/=(FXdouble r){ re/=r; im/=r; return *this; } /// Assigning operators with another complex FXComplexd& operator+=(const FXComplexd& c){ return set(re+c.re,im+c.im); } FXComplexd& operator-=(const FXComplexd& c){ return set(re-c.re,im-c.im); } FXComplexd& operator*=(const FXComplexd& c){ return set(re*c.re-im*c.im,re*c.im+im*c.re); } FXComplexd& operator/=(const FXComplexd& c){ FXdouble m=c.re*c.re+c.im*c.im; return set((re*c.re+im*c.im)/m,(im*c.re-re*c.im)/m); } /// Destructor ~FXComplexd(){} }; /// Return complex complex conjugate inline FXComplexd conj(const FXComplexd& c){ return FXComplexd(c.real(),-c.imag()); } /// Return complex number from modulus and argument inline FXComplexd polar(FXdouble mod,FXdouble arg){ return FXComplexd(Math::cos(arg)*mod,Math::sin(arg)*mod); } /// Return norm of complex inline FXdouble norm(const FXComplexd& c){ return c.real()*c.real()+c.imag()*c.imag(); } /// Return modulus or absolute value of complex inline FXdouble abs(const FXComplexd& c){ return Math::sqrt(norm(c)); } /// Return argument of complex inline FXdouble arg(const FXComplexd& c){ return Math::atan2(c.imag(),c.real()); } /// Returns the complex base e exponential of c inline FXComplexd exp(const FXComplexd& c){ return polar(Math::exp(c.real()),c.imag()); } /// Returns the complex base e logarithm of c inline FXComplexd log(const FXComplexd& c){ return FXComplexd(Math::log(abs(c)),arg(c)); } /// Equality between complex and real inline FXbool operator==(const FXComplexd& c,FXdouble r){ return c.real()==r && c.imag()==0.0; } inline FXbool operator!=(const FXComplexd& c,FXdouble r){ return c.real()!=r || c.imag()!=0.0; } /// Equality between real and complex inline FXbool operator==(FXdouble r,const FXComplexd& c){ return r==c.real() && c.imag()==0.0; } inline FXbool operator!=(FXdouble r,const FXComplexd& c){ return r!=c.real() || c.imag()!=0.0; } /// Equality between one complex and another inline FXbool operator==(const FXComplexd& a,const FXComplexd& b){ return a.real()==b.real() && a.imag()==b.imag(); } inline FXbool operator!=(const FXComplexd& a,const FXComplexd& b){ return a.real()!=b.real() || a.imag()!=b.imag(); } /// Operators between complex and real inline FXComplexd operator+(const FXComplexd& a,FXdouble b){ return FXComplexd(a.real()+b,a.imag()); } inline FXComplexd operator-(const FXComplexd& a,FXdouble b){ return FXComplexd(a.real()-b,a.imag()); } inline FXComplexd operator*(const FXComplexd& a,FXdouble b){ return FXComplexd(a.real()*b,a.imag()*b); } inline FXComplexd operator/(const FXComplexd& a,FXdouble b){ return FXComplexd(a.real()/b,a.imag()/b); } /// Operators between real and complex inline FXComplexd operator+(FXdouble a,const FXComplexd& b){ return FXComplexd(a+b.real(),b.imag()); } inline FXComplexd operator-(FXdouble a,const FXComplexd& b){ return FXComplexd(a-b.real(),-b.imag()); } inline FXComplexd operator*(FXdouble a,const FXComplexd& b){ return FXComplexd(a*b.real(),a*b.imag()); } inline FXComplexd operator/(FXdouble a,const FXComplexd& b){ FXdouble m=norm(b); return FXComplexd((a*b.real())/m,(-a*b.imag())/m); } /// Operators between one complex and another inline FXComplexd operator+(const FXComplexd& a,const FXComplexd& b){ return FXComplexd(a.real()+b.real(),a.imag()+b.imag()); } inline FXComplexd operator-(const FXComplexd& a,const FXComplexd& b){ return FXComplexd(a.real()-b.real(),a.imag()-b.imag()); } inline FXComplexd operator*(const FXComplexd& a,const FXComplexd& b){ return FXComplexd(a.real()*b.real()-a.imag()*b.imag(),a.real()*b.imag()+a.imag()*b.real()); } inline FXComplexd operator/(const FXComplexd& a,const FXComplexd& b){ FXdouble m=norm(b); return FXComplexd((a.real()*b.real()+a.imag()*b.imag())/m,(a.imag()*b.real()-a.real()*b.imag())/m); } /// Complex square root extern FXAPI FXComplexd csqrt(const FXComplexd& c); /// Complex sine extern FXAPI FXComplexd csin(const FXComplexd& c); /// Complex cosine extern FXAPI FXComplexd ccos(const FXComplexd& c); /// Complex square root extern FXAPI FXComplexd ctan(const FXComplexd& c); /// Complex hyperbolic sine extern FXAPI FXComplexd csinh(const FXComplexd& c); /// Complex hyperbolic cosine extern FXAPI FXComplexd ccosh(const FXComplexd& c); /// Complex hyperbolic tangent extern FXAPI FXComplexd ctanh(const FXComplexd& c); /// Save to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXComplexd& c); /// Load from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXComplexd& c); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXComplexf.h000066400000000000000000000200751455751074500226510ustar00rootroot00000000000000/******************************************************************************** * * * S i n g l e - P r e c i s i o n C o m p l e x N u m b e r * * * ********************************************************************************* * Copyright (C) 2006,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCOMPLEXF_H #define FXCOMPLEXF_H namespace FX { /// Single-precision complex class FXAPI FXComplexf { public: FXfloat re; FXfloat im; public: /// Default constructor; value is not initialized FXComplexf(){ } /// Construct from real FXComplexf(FXfloat r):re(r),im(0.0f){ } /// Construct from components FXComplexf(FXfloat r,FXfloat i):re(r),im(i){ } /// Initialize from another complex FXComplexf(const FXComplexf& c):re(c.re),im(c.im){ } /// Set value from real FXComplexf& set(FXfloat r){ re=r; im=0.0f; return *this; } /// Set value from components FXComplexf& set(FXfloat r,FXfloat i){ re=r; im=i; return *this;} /// Set value from another complex FXComplexf& set(const FXComplexf& c){ re=c.re; im=c.im; return *this;} /// Test if zero FXbool operator!() const { return (re==0.0f) && (im==0.0f); } /// Access real part FXfloat& real(){ return re; } const FXfloat& real() const { return re; } /// Access imaginary part FXfloat& imag(){ return im; } const FXfloat& imag() const { return im; } /// Squared modulus FXfloat modulus2() const { return re*re+im*im; } /// Modulus or absolute value of complex FXfloat modulus() const { return Math::sqrt(modulus2()); } /// Argument of complex FXfloat argument() const { return Math::atan2(im,re); } /// Return a non-const reference to the ith element FXfloat& operator[](FXint i){ return (&re)[i]; } /// Return a const reference to the ith element const FXfloat& operator[](FXint i) const { return (&re)[i]; } /// Unary FXComplexf operator+() const { return *this; } FXComplexf operator-() const { return FXComplexf(-re,-im); } /// Assignment from real FXComplexf& operator=(const FXfloat r){ return set(r); } /// Assignment from another complex FXComplexf& operator=(const FXComplexf& c){ return set(c); } /// Assigning operators with real FXComplexf& operator+=(FXfloat r){ re+=r; return *this; } FXComplexf& operator-=(FXfloat r){ re-=r; return *this; } FXComplexf& operator*=(FXfloat r){ re*=r; im*=r; return *this; } FXComplexf& operator/=(FXfloat r){ re/=r; im/=r; return *this; } /// Assigning operators with another complex FXComplexf& operator+=(const FXComplexf& c){ return set(re+c.re,im+c.im); } FXComplexf& operator-=(const FXComplexf& c){ return set(re-c.re,im-c.im); } FXComplexf& operator*=(const FXComplexf& c){ return set(re*c.re-im*c.im,re*c.im+im*c.re); } FXComplexf& operator/=(const FXComplexf& c){ FXfloat m=c.re*c.re+c.im*c.im; return set((re*c.re+im*c.im)/m,(im*c.re-re*c.im)/m); } /// Destructor ~FXComplexf(){} }; /// Return complex complex conjugate inline FXComplexf conj(const FXComplexf& c){ return FXComplexf(c.real(),-c.imag()); } /// Return complex number from modulus and argument inline FXComplexf polar(FXfloat mod,FXfloat arg){ return FXComplexf(Math::cos(arg)*mod,Math::sin(arg)*mod); } /// Return norm of complex inline FXfloat norm(const FXComplexf& c){ return c.real()*c.real()+c.imag()*c.imag(); } /// Return modulus or absolute value of complex inline FXfloat abs(const FXComplexf& c){ return Math::sqrt(norm(c)); } /// Return argument of complex inline FXfloat arg(const FXComplexf& c){ return Math::atan2(c.imag(),c.real()); } /// Returns the complex base e exponential of c inline FXComplexf exp(const FXComplexf& c){ return polar(Math::exp(c.real()),c.imag()); } /// Returns the complex base e logarithm of c inline FXComplexf log(const FXComplexf& c){ return FXComplexf(Math::log(abs(c)),arg(c)); } /// Equality between complex and real inline FXbool operator==(const FXComplexf& c,FXfloat r){ return c.real()==r && c.imag()==0.0f; } inline FXbool operator!=(const FXComplexf& c,FXfloat r){ return c.real()!=r || c.imag()!=0.0f; } /// Equality between real and complex inline FXbool operator==(FXfloat r,const FXComplexf& c){ return r==c.real() && c.imag()==0.0f; } inline FXbool operator!=(FXfloat r,const FXComplexf& c){ return r!=c.real() || c.imag()!=0.0f; } /// Equality between one complex and another inline FXbool operator==(const FXComplexf& a,const FXComplexf& b){ return a.real()==b.real() && a.imag()==b.imag(); } inline FXbool operator!=(const FXComplexf& a,const FXComplexf& b){ return a.real()!=b.real() || a.imag()!=b.imag(); } /// Operators between complex and real inline FXComplexf operator+(const FXComplexf& a,FXfloat b){ return FXComplexf(a.real()+b,a.imag()); } inline FXComplexf operator-(const FXComplexf& a,FXfloat b){ return FXComplexf(a.real()-b,a.imag()); } inline FXComplexf operator*(const FXComplexf& a,FXfloat b){ return FXComplexf(a.real()*b,a.imag()*b); } inline FXComplexf operator/(const FXComplexf& a,FXfloat b){ return FXComplexf(a.real()/b,a.imag()/b); } /// Operators between real and complex inline FXComplexf operator+(FXfloat a,const FXComplexf& b){ return FXComplexf(a+b.real(),b.imag()); } inline FXComplexf operator-(FXfloat a,const FXComplexf& b){ return FXComplexf(a-b.real(),-b.imag()); } inline FXComplexf operator*(FXfloat a,const FXComplexf& b){ return FXComplexf(a*b.real(),a*b.imag()); } inline FXComplexf operator/(FXfloat a,const FXComplexf& b){ FXfloat m=norm(b); return FXComplexf((a*b.real())/m,(-a*b.imag())/m); } /// Operators between one complex and another inline FXComplexf operator+(const FXComplexf& a,const FXComplexf& b){ return FXComplexf(a.real()+b.real(),a.imag()+b.imag()); } inline FXComplexf operator-(const FXComplexf& a,const FXComplexf& b){ return FXComplexf(a.real()-b.real(),a.imag()-b.imag()); } inline FXComplexf operator*(const FXComplexf& a,const FXComplexf& b){ return FXComplexf(a.real()*b.real()-a.imag()*b.imag(),a.real()*b.imag()+a.imag()*b.real()); } inline FXComplexf operator/(const FXComplexf& a,const FXComplexf& b){ FXfloat m=norm(b); return FXComplexf((a.real()*b.real()+a.imag()*b.imag())/m,(a.imag()*b.real()-a.real()*b.imag())/m); } /// Complex square root extern FXAPI FXComplexf csqrt(const FXComplexf& c); /// Complex sine extern FXAPI FXComplexf csin(const FXComplexf& c); /// Complex cosine extern FXAPI FXComplexf ccos(const FXComplexf& c); /// Complex tangent extern FXAPI FXComplexf ctan(const FXComplexf& c); /// Complex hyperbolic sine extern FXAPI FXComplexf csinh(const FXComplexf& c); /// Complex hyperbolic cosine extern FXAPI FXComplexf ccosh(const FXComplexf& c); /// Complex hyperbolic tangent extern FXAPI FXComplexf ctanh(const FXComplexf& c); /// Save to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXComplexf& c); /// Load from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXComplexf& c); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXComposeContext.h000066400000000000000000000064101455751074500240430ustar00rootroot00000000000000/******************************************************************************** * * * C o m p o s e - C o n t e x t * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCOMPOSECONTEXT_H #define FXCOMPOSECONTEXT_H #ifndef FXID_H #include "FXId.h" #endif namespace FX { class FXApp; class FXWindow; class FXFont; /** * Compose Context manages the state of an input method * if input method support is enabled. */ class FXAPI FXComposeContext : public FXId { FXDECLARE(FXComposeContext) protected: FXWindow *window; // Window we belong to FXSelector message; // Message to send it private: #ifndef WIN32 void* fontset; static int editStartCallback(void*,FXComposeContext*,void*); static void editDoneCallback(void*,FXComposeContext*,void*); static void editDrawCallback(void*,FXComposeContext*,void*); static void editCaretCallback(void*,FXComposeContext*,void*); static void statusStartCallback(void*,FXComposeContext*,void*); static void statusDoneCallback(void*,FXComposeContext*,void*); static void statusDrawCallback(void*,FXComposeContext*,void*); #endif protected: FXComposeContext(); private: FXComposeContext(const FXComposeContext&); FXComposeContext &operator=(const FXComposeContext&); public: /// Construct compose context for given window FXComposeContext(FXApp* a,FXWindow* win=nullptr,FXSelector sel=0); /// Create resource virtual void create(); /// Destroy resource virtual void destroy(); /// Focus in void focusIn(); /// Focus out void focusOut(); /// Set the font void setFont(FXFont* fnt); /// Set the spot void setSpot(FXint x,FXint y); /// Set the area void setArea(FXint x,FXint y,FXint w,FXint h); /// Translate key event FXString translateEvent(FXRawEvent& event); /// Destructor virtual ~FXComposeContext(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXComposite.h000066400000000000000000000060571455751074500230420ustar00rootroot00000000000000/******************************************************************************** * * * C o m p o s i t e W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCOMPOSITE_H #define FXCOMPOSITE_H #ifndef FXWINDOW_H #include "FXWindow.h" #endif namespace FX { /// Base composite class FXAPI FXComposite : public FXWindow { FXDECLARE(FXComposite) protected: FXComposite(){} FXComposite(FXApp* a,FXVisual *vis); FXComposite(FXApp* a,FXWindow* own,FXuint opts,FXint x,FXint y,FXint w,FXint h); private: FXComposite(const FXComposite&); FXComposite &operator=(const FXComposite&); public: long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onFocusNext(FXObject*,FXSelector,void*); long onFocusPrev(FXObject*,FXSelector,void*); long onCmdUpdate(FXObject*,FXSelector,void*); public: /// Constructor FXComposite(FXComposite* p,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Destroy server-side resources virtual void destroy(); /// Perform layout virtual void layout(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Return the width of the widest child window FXint maxChildWidth() const; /// Return the height of the tallest child window FXint maxChildHeight() const; /// Overrides this virtual function to return true virtual FXbool isComposite() const; /// Destructor virtual ~FXComposite(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCondition.h000066400000000000000000000066621455751074500230300ustar00rootroot00000000000000/******************************************************************************** * * * C o n d i t i o n C l a s s * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCONDITION_H #define FXCONDITION_H namespace FX { /** * A condition allows one or more threads to synchronize * to an event. When a thread calls wait, the associated * mutex is unlocked while the thread is blocked. When the * condition becomes signaled, the associated mutex is * locked and the thread(s) are reawakened. */ class FXAPI FXCondition { private: FXuval data[12]; private: FXCondition(const FXCondition&); FXCondition& operator=(const FXCondition&); public: /// Initialize the condition FXCondition(); /** * Wake or unblock a single blocked thread */ void signal(); /** * Wake or unblock all blocked threads */ void broadcast(); /** * Wait until condition becomes signalled, using given mutex, * which must already have been locked prior to this call. * Return true if the wait ended due to the condition being * signalled through signal() or broadcast(), and false if the * wait was interrupted or some error occurred. */ FXbool wait(FXMutex& mtx); FXbool wait(FXScopedMutex& smx){ return wait(smx.mutex()); } FXbool wait(FXReverseMutex& rmx){ return wait(rmx.mutex()); } /** * Wait until condition becomes signalled, using given mutex, * which must already have been locked prior to this call. * Return true if the wait ended due to the condition being * signalled through signal() or broadcast(), and false if the * wait timed out, was interrupted, or some other error occurred. * The relative timeout nsec is specified in nanoseconds; if the * special value 'forever' is passed, wait indefinitely. */ FXbool wait(FXMutex& mtx,FXTime nsec); FXbool wait(FXScopedMutex& smx,FXTime nsec){ return wait(smx.mutex(),nsec); } FXbool wait(FXReverseMutex& rmx,FXTime nsec){ return wait(rmx.mutex(),nsec); } /// Delete the condition ~FXCondition(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXConsole.h000066400000000000000000000150011455751074500224670ustar00rootroot00000000000000/******************************************************************************** * * * C o n s o l e W i d g e t * * * ********************************************************************************* * Copyright (C) 2006,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCONSOLE_H #define FXCONSOLE_H #ifndef FXSCROLLAREA_H #include "FXScrollArea.h" #endif #ifndef FXARRAY_H #include "FXArray.h" #endif ////////////////////////////// UNDER DEVELOPMENT ////////////////////////////// namespace FX { /// Scrollbar options enum { CONSOLE_WRAPLINES = 0x00100000 /// Wrap lines }; // Strings buffer typedef FXArray FXStringBuffer; /** * The console widget is a scrolling text widget used primarily * for logging purposes and "terminals" It is high-performance * and features bounded but arbitrary scroll-back capability. */ class FXAPI FXConsole : public FXScrollArea { FXDECLARE(FXConsole) protected: FXStringBuffer contents; // Text data FXStringBuffer style; // Text style FXFont *font; // Text font FXint margintop; // Margins top FXint marginbottom; // Margin bottom FXint marginleft; // Margin left FXint marginright; // Margin right FXint historylines; // History lines FXint visiblelines; // Visible lines FXint topline; // Where first line is in contents FXint vrows; // Default visible rows FXint vcols; // Default visible columns FXColor textColor; // Normal text color FXColor selbackColor; // Select background color FXColor seltextColor; // Select text color FXColor cursorColor; // Cursor color FXString help; // Status line help FXString tip; // Tooltip protected: FXConsole(); FXint charWidth(FXwchar ch,FXint col) const; FXuint styleOf(FXint line,FXint index,FXint p,FXint c) const; virtual void moveContents(FXint x,FXint y); void drawTextFragment(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,const FXchar *text,FXint n,FXuint sty) const; void drawTextLine(FXDCWindow& dc,FXint line,FXint left,FXint right) const; void drawContents(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h) const; protected: enum { STYLE_MASK = 0x00FF, // Mask color table STYLE_TEXT = 0x0100, // Draw some content STYLE_SELECTED = 0x0200, // Selected STYLE_CONTROL = 0x0400, // Control character STYLE_HILITE = 0x0800, // Highlighted STYLE_ACTIVE = 0x1000 // Active }; private: FXConsole(const FXConsole&); FXConsole &operator=(const FXConsole&); public: long onPaint(FXObject*,FXSelector,void*); long onXXX(FXObject*,FXSelector,void*); public: enum { ID_XXX=FXScrollArea::ID_LAST, ID_LAST }; public: /// Construct console window FXConsole(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=3,FXint pr=3,FXint pt=2,FXint pb=2); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Perform layout virtual void layout(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Returns true because a text widget can receive focus virtual FXbool canFocus() const; /// Return content width virtual FXint getContentWidth(); /// Return content height virtual FXint getContentHeight(); /// Change text font void setFont(FXFont* fnt); /// Return text font FXFont* getFont() const { return font; } /// Change top margin void setMarginTop(FXint pt); /// Return top margin FXint getMarginTop() const { return margintop; } /// Change bottom margin void setMarginBottom(FXint pb); /// Return bottom margin FXint getMarginBottom() const { return marginbottom; } /// Change left margin void setMarginLeft(FXint pl); /// Return left margin FXint getMarginLeft() const { return marginleft; } /// Change right margin void setMarginRight(FXint pr); /// Return right margin FXint getMarginRight() const { return marginright; } /// Change history lines void setHistoryLines(FXint hl); /// Return history lines FXint getHistoryLines() const { return historylines; } /// Change number of visible rows void setVisibleRows(FXint rows); /// Return number of visible rows FXint getVisibleRows() const { return vrows; } /// Change number of visible columns void setVisibleColumns(FXint cols); /// Return number of visible columns FXint getVisibleColumns() const { return vcols; } /// Set help text void setHelpText(const FXString& text){ help=text; } /// Return help text FXString getHelpText() const { return help; } /// Set the tool tip message for this widget void setTipText(const FXString& text){ tip=text; } /// Get the tool tip message for this widget FXString getTipText() const { return tip; } /// Save to a stream virtual void save(FXStream& store) const; /// Load from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXConsole(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXCursor.h000066400000000000000000000111211455751074500223410ustar00rootroot00000000000000/******************************************************************************** * * * C u r s o r - O b j e c t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCURSOR_H #define FXCURSOR_H #ifndef FXID_H #include "FXId.h" #endif namespace FX { // Stock cursors enum FXStockCursor { CURSOR_ARROW=1, /// Default left pointing arrow CURSOR_RARROW, /// Right arrow CURSOR_IBEAM, /// Text I-Beam CURSOR_WATCH, /// Stopwatch or hourglass CURSOR_CROSS, /// Crosshair CURSOR_UPDOWN, /// Move up, down CURSOR_LEFTRIGHT, /// Move left, right CURSOR_MOVE /// Move up,down,left,right }; /// Cursor options enum { CURSOR_KEEP = 0x00000100, /// Keep pixel data in client CURSOR_OWNED = 0x00000200 /// Pixel data is owned by image }; /// Cursor class class FXAPI FXCursor : public FXId { FXDECLARE(FXCursor) protected: FXColor *data; // Source data FXint width; // Width FXint height; // Height FXint hotx; // Hot spot x FXint hoty; // Hot spot y FXuint options; // Options protected: FXCursor(); private: FXCursor(const FXCursor&); FXCursor &operator=(const FXCursor&); public: /// Make stock cursor FXCursor(FXApp* a,FXStockCursor curid=CURSOR_ARROW); /// Make cursor from source and mask; cursor size should at most 32x32 for portability! FXCursor(FXApp* a,const FXuchar* src,const FXuchar* msk,FXint w=32,FXint h=32,FXint hx=0,FXint hy=0); /// Make cursor from FXColor pixels; cursor size should be at most 32x32 for portability! FXCursor(FXApp* a,const FXColor* pix,FXint w=32,FXint h=32,FXint hx=0,FXint hy=0); /// Change options void setOptions(FXuint opts); /// To get to the option flags FXuint getOptions() const { return options; } /// Set pixel data ownership flag void setOwned(FXbool owned); /// Get pixel data ownership flag FXbool isOwned() const; /// Width of cursor; returns 0 for stock cursors FXint getWidth() const { return width; } /// Height of cursor; returns 0 for stock cursors FXint getHeight() const { return height; } /// Set hotspot x; returns 0 for stock cursors void setHotX(FXint x){ hotx=x; } /// Get hotspot x; returns 0 for stock cursors FXint getHotX() const { return hotx; } /// Set hotspot y; returns 0 for stock cursors void setHotY(FXint y){ hoty=y; } /// Get hotspot y; returns 0 for stock cursors FXint getHotY() const { return hoty; } /// Check if there is color in the cursor FXbool isColor() const; /// Create cursor virtual void create(); /// Detach cursor virtual void detach(); /// Destroy cursor virtual void destroy(); /// Release pixels buffer if it was owned virtual void release(); /// Save pixel data only virtual FXbool savePixels(FXStream& store) const; /// Load pixel data only virtual FXbool loadPixels(FXStream& store); /// Save cursor to a stream virtual void save(FXStream& store) const; /// Load cursor from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXCursor(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDC.h000066400000000000000000000351701455751074500213640ustar00rootroot00000000000000/******************************************************************************** * * * D e v i c e C o n t e x t B a s e C l a s s * * * ********************************************************************************* * Copyright (C) 1999,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDC_H #define FXDC_H namespace FX { /// Drawing (BITBLT) functions enum FXFunction { BLT_CLR, /// D := 0 BLT_SRC_AND_DST, /// D := S & D BLT_SRC_AND_NOT_DST, /// D := S & ~D BLT_SRC, /// D := S BLT_NOT_SRC_AND_DST, /// D := ~S & D BLT_DST, /// D := D BLT_SRC_XOR_DST, /// D := S ^ D BLT_SRC_OR_DST, /// D := S | D BLT_NOT_SRC_AND_NOT_DST, /// D := ~S & ~D == D := ~(S | D) BLT_NOT_SRC_XOR_DST, /// D := ~S ^ D BLT_NOT_DST, /// D := ~D BLT_SRC_OR_NOT_DST, /// D := S | ~D BLT_NOT_SRC, /// D := ~S BLT_NOT_SRC_OR_DST, /// D := ~S | D BLT_NOT_SRC_OR_NOT_DST, /// D := ~S | ~D == ~(S & D) BLT_SET /// D := 1 }; /// Line Styles enum FXLineStyle { LINE_SOLID, /// Solid lines LINE_ONOFF_DASH, /// On-off dashed lines LINE_DOUBLE_DASH /// Double dashed lines }; /// Line Cap Styles enum FXCapStyle { CAP_NOT_LAST, /// Don't include last end cap CAP_BUTT, /// Butting line end caps CAP_ROUND, /// Round line end caps CAP_PROJECTING /// Projecting line end caps }; /// Line Join Styles enum FXJoinStyle { JOIN_MITER, /// Mitered or pointy joints JOIN_ROUND, /// Round line joints JOIN_BEVEL /// Beveled or flat joints }; /// Fill Styles enum FXFillStyle { FILL_SOLID, /// Fill with solid color FILL_TILED, /// Fill with tiled bitmap FILL_STIPPLED, /// Fill where stipple mask is 1 FILL_OPAQUESTIPPLED /// Fill with foreground where mask is 1, background otherwise }; /// Fill Rules enum FXFillRule { RULE_EVEN_ODD, /// Even odd polygon filling RULE_WINDING /// Winding rule polygon filling }; /// Stipple/dither patterns enum FXStipplePattern { STIPPLE_0 = 0, STIPPLE_NONE = 0, STIPPLE_BLACK = 0, /// All ones STIPPLE_1 = 1, STIPPLE_2 = 2, STIPPLE_3 = 3, STIPPLE_4 = 4, STIPPLE_5 = 5, STIPPLE_6 = 6, STIPPLE_7 = 7, STIPPLE_8 = 8, STIPPLE_GRAY = 8, /// 50% gray STIPPLE_9 = 9, STIPPLE_10 = 10, STIPPLE_11 = 11, STIPPLE_12 = 12, STIPPLE_13 = 13, STIPPLE_14 = 14, STIPPLE_15 = 15, STIPPLE_16 = 16, STIPPLE_WHITE = 16, /// All zeroes STIPPLE_HORZ = 17, /// Horizontal hatch pattern STIPPLE_VERT = 18, /// Vertical hatch pattern STIPPLE_CROSS = 19, /// Cross-hatch pattern STIPPLE_DIAG = 20, /// Diagonal // hatch pattern STIPPLE_REVDIAG = 21, /// Reverse diagonal \\ hatch pattern STIPPLE_CROSSDIAG = 22 /// Cross-diagonal hatch pattern }; /// Line segment struct FXSegment { FXshort x1,y1,x2,y2; }; /// Arc struct FXArc { FXshort x,y,w,h,a,b; }; class FXApp; class FXImage; class FXBitmap; class FXIcon; class FXFont; class FXDrawable; class FXRegion; /** * Abstract Device Context * * A Device Context is used to maintain the state of the graphics drawing system. * Defining your drawing code in terms of the Abstract Device Context allows the * drawing commands to be rendered on different types of surfaces, such as windows * and images (FXDCWindow), or on paper (FXDCPrint). * WYSYWYG may be obtained by using the same identical drawing code in your * application regardless of the actual device surface being utilized. */ class FXAPI FXDC { friend class FXFont; private: FXApp *app; // Application protected: void *ctx; // Context handle FXFont *font; // Drawing font FXStipplePattern pattern; // Stipple pattern FXBitmap *stipple; // Stipple bitmap FXImage *tile; // Tile image FXBitmap *mask; // Mask bitmap FXRectangle clip; // Clip rectangle FXColor fg; // Foreground color FXColor bg; // Background color FXuint width; // Line width FXCapStyle cap; // Line cap style FXJoinStyle join; // Line join style FXLineStyle style; // Line style FXFillStyle fill; // Fill style FXFillRule rule; // Fill rule FXFunction rop; // RasterOp FXuchar dashpat[32]; // Line dash pattern data FXuint dashlen; // Line dash pattern length FXuint dashoff; // Line dash pattern offset FXint tx; // Tile dx FXint ty; // Tile dy FXint cx; // Clip x FXint cy; // Clip y private: FXDC(); FXDC(const FXDC&); FXDC &operator=(const FXDC&); public: /// Construct dummy DC FXDC(FXApp* a); /// Get application FXApp* getApp() const { return app; } /// Get context handle void* context() const { return ctx; } /// Read back pixel virtual FXColor readPixel(FXint x,FXint y); /// Draw points virtual void drawPoint(FXint x,FXint y); virtual void drawPoints(const FXPoint* points,FXuint npoints); virtual void drawPointsRel(const FXPoint* points,FXuint npoints); /// Draw lines virtual void drawLine(FXint x1,FXint y1,FXint x2,FXint y2); virtual void drawLines(const FXPoint* points,FXuint npoints); virtual void drawLinesRel(const FXPoint* points,FXuint npoints); virtual void drawLineSegments(const FXSegment* segments,FXuint nsegments); /// Draw rectangles virtual void drawRectangle(FXint x,FXint y,FXint w,FXint h); virtual void drawRectangles(const FXRectangle* rectangles,FXuint nrectangles); /// Draw rounded rectangle with ellipse with ew and ellips height eh virtual void drawRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh); /** * Draw arcs. * The argument ang1 specifies the start of the arc relative to the * three-o'clock position from the center, in units of degrees*64. * The argument ang2 specifies the path and extent of the arc relative * to the start of the arc, in units of degrees*64. * The arguments x,y,w,h specify the bounding rectangle. */ virtual void drawArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2); virtual void drawArcs(const FXArc* arcs,FXuint narcs); /// Draw ellipse virtual void drawEllipse(FXint x,FXint y,FXint w,FXint h); /// Filled rectangles virtual void fillRectangle(FXint x,FXint y,FXint w,FXint h); virtual void fillRectangles(const FXRectangle* rectangles,FXuint nrectangles); /// Filled rounded rectangle with ellipse with ew and ellips height eh virtual void fillRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh); /// Fill chord virtual void fillChord(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2); virtual void fillChords(const FXArc* chords,FXuint nchords); /// Fill arcs virtual void fillArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2); virtual void fillArcs(const FXArc* arcs,FXuint narcs); /// Fill ellipse virtual void fillEllipse(FXint x,FXint y,FXint w,FXint h); /// Filled polygon virtual void fillPolygon(const FXPoint* points,FXuint npoints); virtual void fillConcavePolygon(const FXPoint* points,FXuint npoints); virtual void fillComplexPolygon(const FXPoint* points,FXuint npoints); /// Filled polygon with relative points virtual void fillPolygonRel(const FXPoint* points,FXuint npoints); virtual void fillConcavePolygonRel(const FXPoint* points,FXuint npoints); virtual void fillComplexPolygonRel(const FXPoint* points,FXuint npoints); /// Fill vertical gradient rectangle virtual void fillVerticalGradient(FXint x,FXint y,FXint w,FXint h,FXColor top,FXColor bottom); /// Fill horizontal gradient rectangle virtual void fillHorizontalGradient(FXint x,FXint y,FXint w,FXint h,FXColor left,FXColor right); /// Draw hashed box virtual void drawHashBox(FXint x,FXint y,FXint w,FXint h,FXint b=1); /// Draw focus rectangle virtual void drawFocusRectangle(FXint x,FXint y,FXint w,FXint h); /// Draw area from source virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy); /// Draw area stretched area from source virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy,FXint dw,FXint dh); /// Draw image virtual void drawImage(const FXImage* image,FXint dx,FXint dy); /// Draw bitmap virtual void drawBitmap(const FXBitmap* bitmap,FXint dx,FXint dy); /// Draw icon virtual void drawIcon(const FXIcon* icon,FXint dx,FXint dy); virtual void drawIconShaded(const FXIcon* icon,FXint dx,FXint dy); virtual void drawIconSunken(const FXIcon* icon,FXint dx,FXint dy); /// Draw string with base line starting at x, y virtual void drawText(FXint x,FXint y,const FXString& string); virtual void drawText(FXint x,FXint y,const FXchar* string,FXuint length); /// Draw text starting at x, y over filled background virtual void drawImageText(FXint x,FXint y,const FXString& string); virtual void drawImageText(FXint x,FXint y,const FXchar* string,FXuint length); /// Set foreground drawing color virtual void setForeground(FXColor clr); /// Get foreground drawing color FXColor getForeground() const { return fg; } /// Set background drawing color virtual void setBackground(FXColor clr); /// Get background drawing color FXColor getBackground() const { return bg; } /** * Set dash pattern and dash offset. * A dash pattern of [1 2 3 4] is a repeating pattern of 1 foreground pixel, * 2 background pixels, 3 foreground pixels, and 4 background pixels. * The offset is where in the pattern the system will start counting. * The maximum length of the dash pattern is 32. */ virtual void setDashes(FXuint dashoffset,const FXuchar *dashpattern,FXuint dashlength); /// Get dash pattern const FXuchar* getDashPattern() const { return dashpat; } /// Get dash offset FXuint getDashOffset() const { return dashoff; } /// Get dash length FXuint getDashLength() const { return dashlen; } /// Set line width:- 0 means thinnest/fastest possible virtual void setLineWidth(FXuint linewidth=0); /// Get line width FXuint getLineWidth() const { return width; } /// Set line cap style virtual void setLineCap(FXCapStyle capstyle=CAP_BUTT); /// Get line cap style FXCapStyle getLineCap() const { return cap; } /// Set line join style virtual void setLineJoin(FXJoinStyle joinstyle=JOIN_MITER); /// Get line join style FXJoinStyle getLineJoin() const { return join; } /// Set line style virtual void setLineStyle(FXLineStyle linestyle=LINE_SOLID); /// Get line style FXLineStyle getLineStyle() const { return style; } /// Set fill style virtual void setFillStyle(FXFillStyle fillstyle=FILL_SOLID); /// Get fill style FXFillStyle getFillStyle() const { return fill; } /// Set fill rule virtual void setFillRule(FXFillRule fillrule=RULE_EVEN_ODD); /// Get fill rule FXFillRule getFillRule() const { return rule; } /// Set rasterop function virtual void setFunction(FXFunction func=BLT_SRC); /// Get rasterop function FXFunction getFunction() const { return rop; } /// Set the tile image virtual void setTile(FXImage* image,FXint dx=0,FXint dy=0); /// Get the tile image FXImage *getTile() const { return tile; } /// Set the stipple pattern virtual void setStipple(FXBitmap *bitmap,FXint dx=0,FXint dy=0); /// Get stipple bitmap FXBitmap *getStippleBitmap() const { return stipple; } /// Set the stipple pattern virtual void setStipple(FXStipplePattern pat,FXint dx=0,FXint dy=0); /// Get pattern FXStipplePattern getStipplePattern() const { return pattern; } /// Set clip region virtual void setClipRegion(const FXRegion& region); /// Set clip rectangle virtual void setClipRectangle(FXint x,FXint y,FXint w,FXint h); /// Change clip rectangle virtual void setClipRectangle(const FXRectangle& rectangle); /// Return clip rectangle const FXRectangle& getClipRectangle() const { return clip; } /// Return clip x FXint getClipX() const { return clip.x; } /// Return clip y FXint getClipY() const { return clip.y; } /// Return clip width FXint getClipWidth() const { return clip.w; } /// Return clip height FXint getClipHeight() const { return clip.h; } /// Clear clipping virtual void clearClipRectangle(); /// Set clip mask virtual void setClipMask(FXBitmap* bitmap,FXint dx=0,FXint dy=0); /// Clear clip mask virtual void clearClipMask(); /// Set font to draw text with virtual void setFont(FXFont *fnt); /// Get text font FXFont* getFont() const { return font; } /// Clip against child windows virtual void clipChildren(FXbool yes); /// Destructor virtual ~FXDC(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDCPrint.h000066400000000000000000000252521455751074500224010ustar00rootroot00000000000000/******************************************************************************** * * * D e v i c e C o n t e x t F o r P r i n t i n g * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDCPRINT_H #define FXDCPRINT_H #ifndef FXDC_H #include "FXDC.h" #endif ////////////////////////////// UNDER DEVELOPMENT ////////////////////////////// namespace FX { class FXApp; class FXDrawable; class FXImage; class FXBitmap; class FXIcon; class FXFont; /// Printer flags enum FXPrintFlags { PRINT_DEST_PAPER = 0, /// Send print to paper PRINT_DEST_FILE = 1, /// Send print to file PRINT_PAGES_ALL = 0, /// Print all pages PRINT_PAGES_EVEN = 2, /// Print even pages only PRINT_PAGES_ODD = 4, /// Print odd pages only PRINT_PAGES_RANGE = 8, /// Print range of pages PRINT_COLLATE_NORMAL = 0, /// Normal collate order PRINT_COLLATE_REVERSED = 16, /// Reversed collate order PRINT_PORTRAIT = 0, /// Portrait orientation PRINT_LANDSCAPE = 32, /// Landscape orientation PRINT_BLACKANDWHITE = 0, /// Black and white output PRINT_COLOR = 64, /// Color output PRINT_NOBOUNDS = 128 /// Must determine bounding box }; /// Printer media size enum FXMediaSize { MEDIA_CUSTOM = 0, /// Custom paper size MEDIA_USLETTER = 1, /// US Letter size MEDIA_LEGAL = 2, /// US Legal size MEDIA_A4 = 3, /// A4 MEDIA_ENVELOPE = 4 /// #10 Envelope }; /// Bounding box struct FXPSBounds { FXdouble xmin; FXdouble xmax; FXdouble ymin; FXdouble ymax; }; /// Describes printer struct FXAPI FXPrinter { FXString name; /// Printer name FXuint firstpage; /// First page that can be printed FXuint lastpage; /// Last page that can be printed FXuint currentpage; /// Current page to print FXuint frompage; /// On output, this is the first page to print FXuint topage; /// On output, last page to print FXuint mediasize; /// Media size index FXdouble mediawidth; /// Width of paper in points [1/72 of an inch] FXdouble mediaheight; /// Height of paper in points FXdouble leftmargin; /// Left margin FXdouble rightmargin; /// Right margin FXdouble topmargin; /// Top margin FXdouble bottommargin; /// Bottom margin FXuint numcopies; /// Number of copies FXuint flags; /// Flags }; /// Postscript Printer Device Context class FXAPI FXDCPrint : public FXDC { protected: void *psout; // File Stream for PS output FXFont *font; FXuint flags; FXint Xr,Yr; FXdouble mediawidth; // Media width FXdouble mediaheight; // Media height FXPSBounds mediabb; // Media bounding box FXPSBounds docbb; // Document bounding box FXPSBounds pagebb; // Page bounding box FXint pagecount; // Number of pages printed FXint nchars; // Number of characters on a line FXint pxmin; // min X coord in content FXint pymin; // min Y coord in content FXint pxmax; // max X coord in content FXint pymax; // max Y coord in content protected: void bbox(FXdouble x,FXdouble y); void tfm(FXdouble& xo,FXdouble& yo,FXdouble xi,FXdouble yi); private: FXDCPrint(); FXDCPrint(const FXDCPrint&); FXDCPrint &operator=(const FXDCPrint&); public: /// Construct FXDCPrint(FXApp* a); /// Generate print job prolog FXbool beginPrint(FXPrinter& job); /// Generate print job epilog FXbool endPrint(); /// Generate begin of page FXbool beginPage(FXuint page=1); /// Generate end of page FXbool endPage(); FXbool setContentRange(FXint pxmin,FXint pymin,FXint pxmax,FXint pymax); /// Draw points virtual void drawPoint(FXint x,FXint y); virtual void drawPoints(const FXPoint* points,FXuint npoints); virtual void drawPointsRel(const FXPoint* points,FXuint npoints); /// Draw lines virtual void drawLine(FXint x1,FXint y1,FXint x2,FXint y2); virtual void drawLines(const FXPoint* points,FXuint npoints); virtual void drawLinesRel(const FXPoint* points,FXuint npoints); virtual void drawLineSegments(const FXSegment* segments,FXuint nsegments); /// Draw rectangles virtual void drawRectangle(FXint x,FXint y,FXint w,FXint h); virtual void drawRectangles(const FXRectangle* rectangles,FXuint nrectangles); /// Draw rounded rectangle with ellipse with ew and ellips height eh virtual void drawRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh); /// Draw arcs virtual void drawArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2); virtual void drawArcs(const FXArc* arcs,FXuint narcs); /// Draw ellipse virtual void drawEllipse(FXint x,FXint y,FXint w,FXint h); /// Filled rectangles virtual void fillRectangle(FXint x,FXint y,FXint w,FXint h); virtual void fillRectangles(const FXRectangle* rectangles,FXuint nrectangles); /// Filled rounded rectangle with ellipse with ew and ellips height eh virtual void fillRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh); /// Fill chord virtual void fillChord(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2); virtual void fillChords(const FXArc* chords,FXuint nchords); /// Draw arcs virtual void fillArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2); virtual void fillArcs(const FXArc* arcs,FXuint narcs); /// Fill ellipse virtual void fillEllipse(FXint x,FXint y,FXint w,FXint h); /// Filled polygon virtual void fillPolygon(const FXPoint* points,FXuint npoints); virtual void fillConcavePolygon(const FXPoint* points,FXuint npoints); virtual void fillComplexPolygon(const FXPoint* points,FXuint npoints); /// Filled polygon with relative points virtual void fillPolygonRel(const FXPoint* points,FXuint npoints); virtual void fillConcavePolygonRel(const FXPoint* points,FXuint npoints); virtual void fillComplexPolygonRel(const FXPoint* points,FXuint npoints); /// Draw hashed box virtual void drawHashBox(FXint x,FXint y,FXint w,FXint h,FXint b=1); /// Draw area from source virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy); /// Draw area stretched area from source virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy,FXint dw,FXint dh); /// Draw image virtual void drawImage(const FXImage* image,FXint dx,FXint dy); /// Draw bitmap virtual void drawBitmap(const FXBitmap* bitmap,FXint dx,FXint dy); /// Draw icon virtual void drawIcon(const FXIcon* icon,FXint dx,FXint dy); virtual void drawIconShaded(const FXIcon* icon,FXint dx,FXint dy); virtual void drawIconSunken(const FXIcon* icon,FXint dx,FXint dy); /// Draw string with base line starting at x, y virtual void drawText(FXint x,FXint y,const FXString& string); virtual void drawText(FXint x,FXint y,const FXchar* string,FXuint length); /// Draw text starting at x, y over filled background virtual void drawImageText(FXint x,FXint y,const FXString& string); virtual void drawImageText(FXint x,FXint y,const FXchar* string,FXuint length); /// Set foreground/background drawing color virtual void setForeground(FXColor clr); virtual void setBackground(FXColor clr); /// Set dash pattern virtual void setDashes(FXuint dashoffset,const FXuchar *dashlist,FXuint n); /// Set line width virtual void setLineWidth(FXuint linewidth=0); /// Set line cap style virtual void setLineCap(FXCapStyle capstyle=CAP_BUTT); /// Set line join style virtual void setLineJoin(FXJoinStyle joinstyle=JOIN_MITER); /// Set line style virtual void setLineStyle(FXLineStyle linestyle=LINE_SOLID); /// Set fill style virtual void setFillStyle(FXFillStyle fillstyle=FILL_SOLID); /// Set fill rule virtual void setFillRule(FXFillRule fillrule=RULE_EVEN_ODD); /// Set blit function virtual void setFunction(FXFunction func=BLT_SRC); /// Set the tile virtual void setTile(FXImage* tile,FXint dx=0,FXint dy=0); /// Set the stipple pattern virtual void setStipple(FXBitmap *stipple,FXint dx=0,FXint dy=0); /// Set the stipple pattern virtual void setStipple(FXStipplePattern stipple,FXint dx=0,FXint dy=0); /// Set clip rectangle virtual void setClipRectangle(FXint x,FXint y,FXint w,FXint h); /// Set clip rectangle virtual void setClipRectangle(const FXRectangle& rectangle); /// Clear clipping virtual void clearClipRectangle(); /// Set clip mask virtual void setClipMask(FXBitmap* mask,FXint dx=0,FXint dy=0); /// Clear clip mask virtual void clearClipMask(); /// Set font to draw text with virtual void setFont(FXFont *fnt); /// Clip drawing by child windows virtual void clipChildren(FXbool yes); /// Temporarily public; do not rely on this!! void outhex(FXuint hex); void outf(const char* format,...); /// Cleanup virtual ~FXDCPrint(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDCWindow.h000066400000000000000000000215531455751074500225540ustar00rootroot00000000000000/******************************************************************************** * * * D e v i c e C o n t e x t F o r W i n d o w s a n d I m a g e s * * * ********************************************************************************* * Copyright (C) 1999,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDCWINDOW_H #define FXDCWINDOW_H #ifndef FXDC_H #include "FXDC.h" #endif namespace FX { class FXApp; class FXDrawable; class FXImage; class FXBitmap; class FXIcon; class FXFont; /** * Window Device Context * * The Window Device Context allows drawing into an FXDrawable, such as an * on-screen window (FXWindow and derivatives) or an off-screen image (FXImage * and its derivatives). * Because certain hardware resources are locked down, only one FXDCWindow may be * locked on a drawable at any one time. */ class FXAPI FXDCWindow : public FXDC { friend class FXFont; protected: FXDrawable *surface; // Drawable surface FXRectangle rect; // Paint rectangle inside drawable FXPixel devfg; // Device foreground pixel value FXPixel devbg; // Device background pixel value #ifdef WIN32 FXID oldpalette; FXID oldbrush; FXID oldpen; FXbool needsNewBrush; FXbool needsNewPen; FXbool needsPath; FXbool needsClipReset; #else void *xftDraw; FXuint flags; #endif private: #ifdef WIN32 void updateBrush(); void updatePen(); #endif private: FXDCWindow(); FXDCWindow(const FXDCWindow&); FXDCWindow &operator=(const FXDCWindow&); public: /// Construct for painting in response to expose; /// This sets the clip rectangle to the exposed rectangle FXDCWindow(FXDrawable* draw,FXEvent* event); /// Construct for normal drawing; /// This sets clip rectangle to the whole drawable FXDCWindow(FXDrawable* draw); /// Return active drawable FXDrawable *drawable() const { return surface; } /// Begin locks in a drawable surface void begin(FXDrawable *draw); /// End unlock the drawable surface void end(); /// Read back pixel virtual FXColor readPixel(FXint x,FXint y); /// Draw points virtual void drawPoint(FXint x,FXint y); virtual void drawPoints(const FXPoint* points,FXuint npoints); virtual void drawPointsRel(const FXPoint* points,FXuint npoints); /// Draw lines virtual void drawLine(FXint x1,FXint y1,FXint x2,FXint y2); virtual void drawLines(const FXPoint* points,FXuint npoints); virtual void drawLinesRel(const FXPoint* points,FXuint npoints); virtual void drawLineSegments(const FXSegment* segments,FXuint nsegments); /// Draw rectangles virtual void drawRectangle(FXint x,FXint y,FXint w,FXint h); virtual void drawRectangles(const FXRectangle* rectangles,FXuint nrectangles); /// Draw rounded rectangle with ellipse with ew and ellips height eh virtual void drawRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh); /// Draw arcs virtual void drawArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2); virtual void drawArcs(const FXArc* arcs,FXuint narcs); /// Draw ellipse virtual void drawEllipse(FXint x,FXint y,FXint w,FXint h); /// Filled rectangles virtual void fillRectangle(FXint x,FXint y,FXint w,FXint h); virtual void fillRectangles(const FXRectangle* rectangles,FXuint nrectangles); /// Filled rounded rectangle with ellipse with ew and ellips height eh virtual void fillRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh); /// Fill chord virtual void fillChord(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2); virtual void fillChords(const FXArc* chords,FXuint nchords); /// Draw arcs virtual void fillArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2); virtual void fillArcs(const FXArc* arcs,FXuint narcs); /// Fill ellipse virtual void fillEllipse(FXint x,FXint y,FXint w,FXint h); /// Filled polygon virtual void fillPolygon(const FXPoint* points,FXuint npoints); virtual void fillConcavePolygon(const FXPoint* points,FXuint npoints); virtual void fillComplexPolygon(const FXPoint* points,FXuint npoints); /// Filled polygon with relative points virtual void fillPolygonRel(const FXPoint* points,FXuint npoints); virtual void fillConcavePolygonRel(const FXPoint* points,FXuint npoints); virtual void fillComplexPolygonRel(const FXPoint* points,FXuint npoints); /// Fill vertical gradient rectangle virtual void fillVerticalGradient(FXint x,FXint y,FXint w,FXint h,FXColor top,FXColor bottom); /// Fill horizontal gradient rectangle virtual void fillHorizontalGradient(FXint x,FXint y,FXint w,FXint h,FXColor left,FXColor right); /// Draw hashed box virtual void drawHashBox(FXint x,FXint y,FXint w,FXint h,FXint b=1); /// Draw focus rectangle virtual void drawFocusRectangle(FXint x,FXint y,FXint w,FXint h); /// Draw area from source virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy); /// Draw area stretched area from source virtual void drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy,FXint dw,FXint dh); /// Draw image virtual void drawImage(const FXImage* image,FXint dx,FXint dy); /// Draw bitmap virtual void drawBitmap(const FXBitmap* bitmap,FXint dx,FXint dy); /// Draw icon virtual void drawIcon(const FXIcon* icon,FXint dx,FXint dy); virtual void drawIconShaded(const FXIcon* icon,FXint dx,FXint dy); virtual void drawIconSunken(const FXIcon* icon,FXint dx,FXint dy); /// Draw string with base line starting at x, y virtual void drawText(FXint x,FXint y,const FXString& string); virtual void drawText(FXint x,FXint y,const FXchar* string,FXuint length); /// Draw text starting at x, y over filled background virtual void drawImageText(FXint x,FXint y,const FXString& string); virtual void drawImageText(FXint x,FXint y,const FXchar* string,FXuint length); /// Set foreground/background drawing color virtual void setForeground(FXColor clr); virtual void setBackground(FXColor clr); /// Set dash pattern virtual void setDashes(FXuint dashoffset,const FXuchar *dashpattern,FXuint dashlength); /// Set line width virtual void setLineWidth(FXuint linewidth=0); /// Set line cap style virtual void setLineCap(FXCapStyle capstyle=CAP_BUTT); /// Set line join style virtual void setLineJoin(FXJoinStyle joinstyle=JOIN_MITER); /// Set line style virtual void setLineStyle(FXLineStyle linestyle=LINE_SOLID); /// Set fill style virtual void setFillStyle(FXFillStyle fillstyle=FILL_SOLID); /// Set fill rule virtual void setFillRule(FXFillRule fillrule=RULE_EVEN_ODD); /// Set blit function virtual void setFunction(FXFunction func=BLT_SRC); /// Set the tile virtual void setTile(FXImage* tile,FXint dx=0,FXint dy=0); /// Set the stipple pattern virtual void setStipple(FXBitmap *stipple,FXint dx=0,FXint dy=0); /// Set the stipple pattern virtual void setStipple(FXStipplePattern stipple,FXint dx=0,FXint dy=0); /// Set clip region virtual void setClipRegion(const FXRegion& region); /// Set clip rectangle virtual void setClipRectangle(FXint x,FXint y,FXint w,FXint h); /// Set clip rectangle virtual void setClipRectangle(const FXRectangle& rectangle); /// Clear clipping virtual void clearClipRectangle(); /// Set clip mask virtual void setClipMask(FXBitmap* mask,FXint dx=0,FXint dy=0); /// Clear clip mask virtual void clearClipMask(); /// Set font to draw text with virtual void setFont(FXFont *fnt); /// Clip against child windows virtual void clipChildren(FXbool yes); /// Destructor virtual ~FXDCWindow(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDDSIcon.h000066400000000000000000000061301455751074500223130ustar00rootroot00000000000000/******************************************************************************** * * * D D S I c o n O b j e c t * * * ********************************************************************************* * Copyright (C) 2008,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDDSICON_H #define FXDDSICON_H #ifndef FXICON_H #include "FXIcon.h" #endif namespace FX { /** * The DDS Icon class is a convenience class for working with icons in the * Direct Draw Surface (DDS) file format. */ class FXAPI FXDDSIcon : public FXIcon { FXDECLARE(FXDDSIcon) protected: FXDDSIcon(){} private: FXDDSIcon(const FXDDSIcon&); FXDDSIcon &operator=(const FXDDSIcon&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct icon from memory stream formatted in DDS format FXDDSIcon(FXApp* a,const FXuchar *pix=nullptr,FXColor clr=FXRGB(192,192,192),FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in DDS format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in DDS format virtual FXbool loadPixels(FXStream& store); /// Destroy icon virtual ~FXDDSIcon(); }; #ifndef FXLOADDDS #define FXLOADDDS /** * Check if stream contains a DDS format, return true if so. */ extern FXAPI FXbool fxcheckDDS(FXStream& store); /** * Load an DDS (Direct Draw Surface) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadDDS(FXStream& store,FXColor*& data,FXint& width,FXint& height,FXint& depth); /** * Save a DDS (Direct Draw Surface) file to a stream. */ extern FXAPI FXbool fxsaveDDS(FXStream& store,FXColor* data,FXint width,FXint height,FXint depth); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDDSImage.h000066400000000000000000000061121455751074500224450ustar00rootroot00000000000000/******************************************************************************** * * * D D S I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 2008,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDDSIMAGE_H #define FXDDSIMAGE_H #ifndef FXIMAGE_H #include "FXImage.h" #endif namespace FX { /** * The DDS Image class is a convenience class for working with images in the * Direct Draw Surface (DDS) file format. */ class FXAPI FXDDSImage : public FXImage { FXDECLARE(FXDDSImage) protected: FXDDSImage(){} private: FXDDSImage(const FXDDSImage&); FXDDSImage &operator=(const FXDDSImage&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct image from memory stream formatted in DDS format FXDDSImage(FXApp* a,const FXuchar *pix=nullptr,FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in DDS format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in DDS format virtual FXbool loadPixels(FXStream& store); /// Destroy icon virtual ~FXDDSImage(); }; #ifndef FXLOADDDS #define FXLOADDDS /** * Check if stream contains a DDS format, return true if so. */ extern FXAPI FXbool fxcheckDDS(FXStream& store); /** * Load an DDS (Direct Draw Surface) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadDDS(FXStream& store,FXColor*& data,FXint& width,FXint& height,FXint& depth); /** * Save a DDS (Direct Draw Surface) file to a stream. */ extern FXAPI FXbool fxsaveDDS(FXStream& store,FXColor* data,FXint width,FXint height,FXint depth); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDLL.h000066400000000000000000000064751455751074500215170ustar00rootroot00000000000000/******************************************************************************** * * * D y n a m i c L i n k L i b r a r y S u p p o r t * * * ********************************************************************************* * Copyright (C) 2002,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDLL_H #define FXDLL_H namespace FX { /** * Wrap library module handle to allow various operations * on libraries to be performed. */ class FXAPI FXDLL { private: void *hnd; public: /// Construct with no handle FXDLL():hnd(nullptr){} /// Construct with existing handle FXDLL(void *h):hnd(h){} /// Construct copy from original FXDLL(const FXDLL& org):hnd(org.hnd){} /// Return the name of the library module FXString name() const; /// Return library module handle void* handle() const { return hnd; } /// True if library was loaded FXbool loaded() const { return hnd!=nullptr; } /// Load the library module from the name FXbool load(const FXString& nm); /// Unload the library module void unload(); /// Return the address of the symbol in this library module void* address(const FXchar* sym) const; void* address(const FXString& sym) const; /// Return the symbol name of the given address static FXString symbol(void *addr); /// Return the name of the library module containing the address static FXString name(void *addr); /// Find DLL containing symbol static FXDLL dll(void* addr); /// Find DLL of ourselves static FXDLL dll(); /// Return error message if error occurred loading the library module static FXString error(); }; /** * Auto DLL wraps a library module handle but also owns it; thus, the library * module will automatically be unloaded when auto-dll is destroyed. */ class FXAPI FXAUTODLL : public FXDLL { private: FXAUTODLL(const FXAUTODLL&); FXAUTODLL &operator=(const FXAUTODLL&); public: /// Initialize by loading given library name FXAUTODLL(const FXString& nm); /// Unload library if we have one ~FXAUTODLL(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDataTarget.h000066400000000000000000000260661455751074500231220ustar00rootroot00000000000000/******************************************************************************** * * * D a t a T a r g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDATATARGET_H #define FXDATATARGET_H #ifndef FXOBJECT_H #include "FXObject.h" #endif namespace FX { /** * A Data Target allows a widget to be directly connected with a associated variable, * without any additional "glue code". This connection is bi-directional: widgets can * not only only change the associated variable, but also query the associated variable, * and reflect its value in the widget. * * The value of the associated variable is changed by the data target when it receives * a SEL_COMMAND or SEL_CHANGED message from the widget. Conversely, the widget's state * may be updated from the data target's associated variable when the it receives a * SEL_UPDATE query message from the widget. * * Valuator widgets should send an ID_VALUE message to the data target. When a data * target receives the ID_VALUE message, it will obtain the value of the sending valuator * widget by querying it with a ID_GETINTVALUE, ID_GETLONGVALUE, ID_GETREALVALUE, or * ID_GETSTRINGVALUE message, depending on the type of the associated variable. * * Radio Buttons, Menu Commands, and so on can also be connected to a data target. * In this case, the widget must send an ID_OPTION+i message; the value of the associated * variable will be obtained from the message itself, by simply subtracting ID_OPTION * from the message ID, that is to say, the value will be i (-10000 <= i <= 10000). * * Updating of widgets from the data target is performed when the widget sends the data * target a SEL_UPDATE message. For ID_VALUE update queries, the data target responds * with ID_SETINTVALUE, ID_SETLONGVALUE, ID_SETREALVALUE, or ID_SETSTRINGVALUE depending * on the type of the associated variable. * For ID_OPTION+i update queries, the data target responds with a ID_CHECK or ID_UNCHECK * depending on whether the connected variable's value is equal to i or not. * * A data target may be subclassed to handle additional, user-defined data types; to * this end, the message handlers return 1 if the type is one of DT_VOID...DT_STRING * and 0 otherwise. */ class FXAPI FXDataTarget : public FXObject { FXDECLARE(FXDataTarget) protected: void *data; // Associated data FXObject *target; // Target object FXSelector message; // Message ID FXuint type; // Type of data private: FXDataTarget(const FXDataTarget&); FXDataTarget& operator=(const FXDataTarget&); public: long onCmdValue(FXObject*,FXSelector,void*); long onUpdValue(FXObject*,FXSelector,void*); long onCmdOption(FXObject*,FXSelector,void*); long onUpdOption(FXObject*,FXSelector,void*); public: enum { DT_VOID=0, DT_BOOL, DT_CHAR, DT_UCHAR, DT_SHORT, DT_USHORT, DT_INT, DT_UINT, DT_LONG, DT_ULONG, DT_FLOAT, DT_DOUBLE, DT_STRING, DT_LAST }; public: enum { ID_VALUE=1, /// Will cause the FXDataTarget to ask sender for value ID_OPTION=ID_VALUE+10001, /// ID_OPTION+i will set the value to i where -10000<=i<=10000 ID_LAST=ID_OPTION+10000 }; public: /// Associate with nothing FXDataTarget():data(nullptr),target(nullptr),message(0),type(DT_VOID){} /// Associate with nothing FXDataTarget(FXObject* tgt,FXSelector sel):data(nullptr),target(tgt),message(sel),type(DT_VOID){} /// Associate with character variable FXDataTarget(FXbool& value,FXObject* tgt=nullptr,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_BOOL){} /// Associate with character variable FXDataTarget(FXchar& value,FXObject* tgt=nullptr,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_CHAR){} /// Associate with unsigned character variable FXDataTarget(FXuchar& value,FXObject* tgt=nullptr,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_UCHAR){} /// Associate with signed short variable FXDataTarget(FXshort& value,FXObject* tgt=nullptr,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_SHORT){} /// Associate with unsigned short variable FXDataTarget(FXushort& value,FXObject* tgt=nullptr,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_USHORT){} /// Associate with int variable FXDataTarget(FXint& value,FXObject* tgt=nullptr,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_INT){} /// Associate with unsigned int variable FXDataTarget(FXuint& value,FXObject* tgt=nullptr,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_UINT){} /// Associate with long variable FXDataTarget(FXlong& value,FXObject* tgt=nullptr,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_LONG){} /// Associate with unsigned long variable FXDataTarget(FXulong& value,FXObject* tgt=nullptr,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_ULONG){} /// Associate with float variable FXDataTarget(FXfloat& value,FXObject* tgt=nullptr,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_FLOAT){} /// Associate with double variable FXDataTarget(FXdouble& value,FXObject* tgt=nullptr,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_DOUBLE){} /// Associate with string variable FXDataTarget(FXString& value,FXObject* tgt=nullptr,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_STRING){} /// Set the message target object for this data target void setTarget(FXObject *t){ target=t; } /// Get the message target object for this data target, if any FXObject* getTarget() const { return target; } /// Set the message identifier for this data target void setSelector(FXSelector sel){ message=sel; } /// Get the message identifier for this data target FXSelector getSelector() const { return message; } /// Return type of data its connected to FXuint getType() const { return type; } /// Return pointer to data its connected to void* getData() const { return data; } /// Associate with nothing void connect(){ data=nullptr; type=DT_VOID; } /// Associate with FXbool variable void connect(FXbool& value){ data=&value; type=DT_BOOL; } /// Associate with character variable void connect(FXchar& value){ data=&value; type=DT_CHAR; } /// Associate with unsigned character variable void connect(FXuchar& value){ data=&value; type=DT_UCHAR; } /// Associate with signed short variable void connect(FXshort& value){ data=&value; type=DT_SHORT; } /// Associate with unsigned short variable void connect(FXushort& value){ data=&value; type=DT_USHORT; } /// Associate with int variable void connect(FXint& value){ data=&value; type=DT_INT; } /// Associate with unsigned int variable void connect(FXuint& value){ data=&value; type=DT_UINT; } /// Associate with long variable void connect(FXlong& value){ data=&value; type=DT_LONG; } /// Associate with unsigned long variable void connect(FXulong& value){ data=&value; type=DT_ULONG; } /// Associate with float variable void connect(FXfloat& value){ data=&value; type=DT_FLOAT; } /// Associate with double variable void connect(FXdouble& value){ data=&value; type=DT_DOUBLE; } /// Associate with string variable void connect(FXString& value){ data=&value; type=DT_STRING; } /// Associate with nothing; also set target and message void connect(FXObject* tgt,FXSelector sel){ data=nullptr; target=tgt; message=sel; type=DT_VOID; } /// Associate with character variable; also set target and message void connect(FXbool& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_BOOL; } /// Associate with character variable; also set target and message void connect(FXchar& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_CHAR; } /// Associate with unsigned character variable; also set target and message void connect(FXuchar& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_UCHAR; } /// Associate with signed short variable; also set target and message void connect(FXshort& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_SHORT; } /// Associate with unsigned short variable; also set target and message void connect(FXushort& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_USHORT; } /// Associate with int variable; also set target and message void connect(FXint& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_INT; } /// Associate with unsigned int variable; also set target and message void connect(FXuint& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_UINT; } /// Associate with long variable; also set target and message void connect(FXlong& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_LONG; } /// Associate with unsigned long variable; also set target and message void connect(FXulong& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_ULONG; } /// Associate with float variable; also set target and message void connect(FXfloat& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_FLOAT; } /// Associate with double variable; also set target and message void connect(FXdouble& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_DOUBLE; } /// Associate with string variable; also set target and message void connect(FXString& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_STRING; } /// Destroy virtual ~FXDataTarget(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDate.h000066400000000000000000000151411455751074500217470ustar00rootroot00000000000000/******************************************************************************** * * * D a t e C l a s s * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDATE_H #define FXDATE_H namespace FX { /** * Gregorian date class, which is useful for calendrical calculations. */ class FXAPI FXDate { private: FXuint julian; private: static const FXchar shortMonthName[12][4]; static const FXchar longMonthName[12][10]; static const FXchar shortWeekDay[7][4]; static const FXchar longWeekDay[7][10]; public: /// Names for the months enum { Jan=1,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec }; /// Names for the weekdays enum { Sun=0,Mon,Tue,Wed,Thu,Fri,Sat }; public: /// Default constructor FXDate(){} /// Copy constructor FXDate(const FXDate& date):julian(date.julian){} /// Initialize with julian day number FXDate(FXuint jd):julian(jd){} /// Initialize with year and day of year FXDate(FXint yr,FXint dy); /// Initialize with year, month, and day of month FXDate(FXint yr,FXint mo,FXint dy); /// Set julian day number void setJulian(FXuint jd){ julian=jd; } /// Get julian day number FXuint getJulian() const { return julian; } /// Set date to year and day of year void setDate(FXint yr,FXint dy); /// Get year and day of year from date void getDate(FXint& yr,FXint& dy) const; /// Set date to year, month, and day of month void setDate(FXint yr,FXint mo,FXint dy); /// Get year, month, and day of month from date void getDate(FXint& yr,FXint& mo,FXint& dy) const; /// Set date from nanoseconds since 1/1/1970 void setTime(FXTime ns); /// Get nanoseconds since 1/1/1970 from date FXTime getTime() const; /// Return day of the month (1..31) FXint day() const; /// Return month (1..12) FXint month() const; /// Return year FXint year() const; /// Return day of the week FXint dayOfWeek() const; /// Return day of year (1..366) FXint dayOfYear() const; /// Return ISO8601 week number of this date FXint weekOfYear() const; /// Return true if this is a leap year FXbool leapYear() const; /// Return number of days in this year FXint daysInYear() const; /// Return days in this month FXint daysInMonth() const; /// Add d days to this date FXDate& addDays(FXint d); /// Add m months to this date; day of month is adjusted for leap-years FXDate& addMonths(FXint m); /// Add y years to this date; day of month is adjusted for leap-years FXDate& addYears(FXint y); /// Is the value a leap year static FXbool leapYear(FXint yr); /// Return number of days in a given year static FXint daysInYear(FXint yr); /// Return number of days in the month in given year, month static FXint daysInMonth(FXint yr,FXint mo); /// Get the name of the month static const FXchar *monthName(FXint mo){ return longMonthName[mo-1]; } /// Get the abbreviated name of the month static const FXchar *monthNameShort(FXint mo){ return shortMonthName[mo-1]; } /// Get the name of the day static const FXchar *dayName(FXint dy){ return longWeekDay[dy]; } /// Get the abbreviated name of the day static const FXchar *dayNameShort(FXint dy){ return shortWeekDay[dy]; } /// Return current local date static FXDate localDate(); /// Return current universal (UTC) date static FXDate universalDate(); /// Assignment FXDate& operator=(const FXDate& date){julian=date.julian;return *this;} /// Assignment operators FXDate& operator+=(FXint x){ julian+=x; return *this; } FXDate& operator-=(FXint x){ julian-=x; return *this; } /// Pre-Increment and decrement FXDate& operator++(){ ++julian; return *this; } FXDate& operator--(){ --julian; return *this; } /// Post-Increment and decrement FXDate operator++(int){ FXDate t(julian++); return t; } FXDate operator--(int){ FXDate t(julian--); return t; } /// Equality tests FXbool operator==(const FXDate& date) const { return julian==date.julian;} FXbool operator!=(const FXDate& date) const { return julian!=date.julian;} /// Inequality tests FXbool operator<(const FXDate& date) const { return julian(const FXDate& date) const { return julian>date.julian;} FXbool operator>=(const FXDate& date) const { return julian>=date.julian;} /// Add days to date yielding another date friend inline FXDate operator+(const FXDate& d,FXint x); friend inline FXDate operator+(FXint x,const FXDate& d); /// Subtract dates yielding days friend inline FXint operator-(const FXDate& a,const FXDate& b); /// save to stream friend FXAPI FXStream& operator<<(FXStream& store,const FXDate& d); /// load from stream friend FXAPI FXStream& operator>>(FXStream& store,FXDate& d); /// Destructor ~FXDate(){} }; inline FXDate operator+(const FXDate& d,FXint x){ return FXDate(d.julian+x); } inline FXDate operator+(FXint x,const FXDate& d){ return FXDate(x+d.julian); } inline FXint operator-(const FXDate& a,const FXDate& b){return a.julian-b.julian; } extern FXAPI FXStream& operator<<(FXStream& store,const FXDate& d); extern FXAPI FXStream& operator>>(FXStream& store,FXDate& d); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDebugTarget.h000066400000000000000000000044601455751074500232710ustar00rootroot00000000000000/******************************************************************************** * * * D e b u g T a r g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDEBUGTARGET_H #define FXDEBUGTARGET_H #ifndef FXOBJECT_H #include "FXObject.h" #endif namespace FX { /** * A DebugTarget prints out every message it receives. * To use it, simply make the DebugTarget a target of the widget * whose messages you want to see, */ class FXAPI FXDebugTarget : public FXObject { FXDECLARE(FXDebugTarget) protected: FXObject *lastsender; FXSelector lastsel; FXuint count; public: static const FXchar *const messageTypeName[]; private: FXDebugTarget(const FXDebugTarget&); FXDebugTarget &operator=(const FXDebugTarget&); public: long onMessage(FXObject*,FXSelector,void*); public: /// Construct a debug target FXDebugTarget(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDelegator.h000066400000000000000000000052651455751074500230060ustar00rootroot00000000000000/******************************************************************************** * * * D e l e g a t o r T a r g e t * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDELEGATOR_H #define FXDELEGATOR_H #ifndef FXOBJECT_H #include "FXObject.h" #endif namespace FX { /** * A delegator forwards messages to a delegate object. * Delegators are used when you need to multiplex messages * toward any number of target objects. * For example, many controls may be connected to FXDelegator, * instead of directly to the document object. Changing the * delegate in FXDelegator will then reconnect the controls with their * new target. */ class FXAPI FXDelegator : public FXObject { FXDECLARE(FXDelegator) protected: FXObject *delegate; private: FXDelegator(const FXDelegator&); FXDelegator &operator=(const FXDelegator&); public: virtual long onDefault(FXObject*,FXSelector,void*); public: /// Construct a delegator FXDelegator(FXObject* target=nullptr):delegate(target){ } /// Return delegate object FXObject* getDelegate() const { return delegate; } /// Change delegate object void setDelegate(FXObject* target){ delegate=target; } /// Always trash during detroy virtual ~FXDelegator(){ delegate=(FXObject*)-1L; } }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDial.h000066400000000000000000000164341455751074500217510ustar00rootroot00000000000000/******************************************************************************** * * * D i a l W i d g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDIAL_H #define FXDIAL_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { // Dial style options enum { DIAL_VERTICAL = 0, // Vertically oriented DIAL_HORIZONTAL = 0x00008000, // Horizontal oriented DIAL_CYCLIC = 0x00010000, // Value wraps around DIAL_HAS_NOTCH = 0x00020000, // Dial has a Center Notch DIAL_NORMAL = DIAL_VERTICAL }; /** * The Dial widget is a valuator widget which is able to provide a cyclic * value range when the DIAL_CYCLIC is passed, or a simple linear value range. * While being turned, the dial sends a SEL_CHANGED message to its target; * at the end of the interaction, a SEL_COMMAND message is sent. * The message data represents the current value, of type FXint. The options * DIAL_VERTICAL and DIAL_HORIZONTAL control the orientation of the dial. * An optional notch can be used to indicate the zero-position of * the dial; display of the notch is controlled by the DIAL_HAS_NOTCH option. */ class FXAPI FXDial : public FXFrame { FXDECLARE(FXDial) protected: FXint notchAngle; // Angle of main notch FXint notchSpacing; // Angle between notches FXint notchOffset; // Notch offset FXColor notchColor; // Main notch color FXint dragPoint; // Place where clicked FXint dragPos; // Value where clicked FXint range[2]; // Reported data range FXint incr; // Rate of change/revolution FXint pos; // Reported data position FXString help; // Help string FXString tip; // Tip string protected: FXDial(); private: FXDial(const FXDial&); FXDial &operator=(const FXDial&); public: long onPaint(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onMouseWheel(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void* ); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdSetLongValue(FXObject*,FXSelector,void*); long onCmdGetLongValue(FXObject*,FXSelector,void*); long onCmdSetRealValue(FXObject*,FXSelector,void*); long onCmdGetRealValue(FXObject*,FXSelector,void*); long onCmdSetIntRange(FXObject*,FXSelector,void*); long onCmdGetIntRange(FXObject*,FXSelector,void*); long onCmdSetRealRange(FXObject*,FXSelector,void*); long onCmdGetRealRange(FXObject*,FXSelector,void*); long onCmdSetHelp(FXObject*,FXSelector,void*); long onCmdGetHelp(FXObject*,FXSelector,void*); long onCmdSetTip(FXObject*,FXSelector,void*); long onCmdGetTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); public: /// Construct a dial widget FXDial(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=DIAL_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Returns true because a dial can receive focus virtual FXbool canFocus() const; /// Set the dial value void setValue(FXint value,FXbool notify=false); /// Return the dial value FXint getValue() const { return pos; } /// Change the dial's range void setRange(FXint lo,FXint hi,FXbool notify=false); /// Obtain the current range of the dial void getRange(FXint& lo,FXint& hi) const { lo=range[0]; hi=range[1]; } /** * Set the revolution increment, which is the amount of change * in the position for revolution of the dial; the dial may go * through multiple revolutions to go through its whole range; * by default it takes one 360 degree turn of the dial to go * from the lower to the upper range. */ void setRevolutionIncrement(FXint i); /// Get the current value of the revolution increment FXint getRevolutionIncrement() const { return incr; } /** * Change the spacing for the small notches; this should be set * in tenths of degrees in the range [1,3600], and the value should * be a divisor of 3600, so as to make the notches come out evenly */ void setNotchSpacing(FXint spacing); /// Get the current notch spacing FXint getNotchSpacing() const { return notchSpacing; } /** * Change the notch offset, which is the position of the * center notch; the value should be tenths of degrees * in the range [-3600,3600] */ void setNotchOffset(FXint offset); /// Get the current center notch offset FXint getNotchOffset() const { return notchOffset; } /// Changes the dial style. void setDialStyle(FXuint opts); /// Get the current dial style. FXuint getDialStyle() const; /// Change the center notch color void setNotchColor(FXColor clr); /// Get the current center notch color FXColor getNotchColor() const { return notchColor; } /// Set the help text to be displayed on the status line void setHelpText(const FXString& text); /// Get the current help text const FXString& getHelpText() const { return help; } /// Set the tip text to be displayed in the tooltip void setTipText(const FXString& text); /// Get the current tooltip text value const FXString& getTipText() const { return tip; } /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDialogBox.h000066400000000000000000000062451455751074500227470ustar00rootroot00000000000000/******************************************************************************** * * * D i a l o g B o x * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDIALOGBOX_H #define FXDIALOGBOX_H #ifndef FXTOPWINDOW_H #include "FXTopWindow.h" #endif namespace FX { /** * DialogBox window. * When receiving ID_CANCEL or ID_ACCEPT, the DialogBox breaks out of the * modal loop and returns false or true, respectively. * To close the DialogBox when not running modally, simply send it ID_HIDE. */ class FXAPI FXDialogBox : public FXTopWindow { FXDECLARE(FXDialogBox) protected: FXDialogBox(){} private: FXDialogBox(const FXDialogBox&); FXDialogBox &operator=(const FXDialogBox&); public: long onCmdAccept(FXObject*,FXSelector,void*); long onCmdCancel(FXObject*,FXSelector,void*); public: enum { ID_CANCEL=FXTopWindow::ID_LAST, /// Closes the dialog, cancel the entry ID_ACCEPT, /// Closes the dialog, accept the entry ID_LAST }; public: /// Construct free-floating dialog FXDialogBox(FXApp* a,const FXString& name,FXuint opts=DECOR_TITLE|DECOR_BORDER,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=10,FXint pr=10,FXint pt=10,FXint pb=10,FXint hs=4,FXint vs=4); /// Construct dialog which will always float over the owner window FXDialogBox(FXWindow* owner,const FXString& name,FXuint opts=DECOR_TITLE|DECOR_BORDER,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=10,FXint pr=10,FXint pt=10,FXint pb=10,FXint hs=4,FXint vs=4); /** * Run modal invocation of the dialog. * The dialog is placed according to the placement parameter, * which may be any of the FXTopWindow placement options. */ virtual FXuint execute(FXuint placement=PLACEMENT_CURSOR); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDictionary.h000066400000000000000000000134621455751074500232030ustar00rootroot00000000000000/******************************************************************************** * * * D i c t i o n a r y C l a s s * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDICTIONARY_H #define FXDICTIONARY_H namespace FX { /** * The dictionary class is a fast-access hash table, mapping strings to void-pointers. * Subclasses of dictionary can easily specialize the void-pointers to pointers to * particular types; to this end subclasses must overload certain API's and * perform the necessary type-casts for the proper interpretation of the stored * pointer values. * Note that many complex containers in FOX now fit inside a pointer, and thus * these types can be used in dictionaries as well! */ class FXAPI FXDictionary { protected: struct Entry { FXString key; // Key void* data; // Value FXuint hash; // Hash of key }; protected: Entry* table; // Hash table protected: // Change size of the table FXbool no(FXival n); // Change number of used entries void used(FXival u){ ((FXival*)table)[-2]=u; } // Change number of free entries void free(FXival f){ ((FXival*)table)[-3]=f; } // Resize the table to the given size, keeping contents FXbool resize(FXival n); public: /// Construct empty dictionary FXDictionary(); /// Construct from another dictionary FXDictionary(const FXDictionary& other); /// Return the size of the table, including the empty slots FXival no() const { return ((FXival*)table)[-1]; } /// Return number of used slots in the table FXival used() const { return ((FXival*)table)[-2]; } /// Return number of free slots in the table FXival free() const { return ((FXival*)table)[-3]; } /// See if map is empty FXbool empty() const { return ((FXival*)table)[-1]<=1; } /// Assignment operator FXDictionary& operator=(const FXDictionary& other); /// Adopt dictionary from another FXDictionary& adopt(FXDictionary& other); /// Find position of given key, returning -1 if not found FXival find(const FXchar* ky) const; /// Find position of given key, returning -1 if not found FXival find(const FXString& ky) const { return find(ky.text()); } /// Check if key is mapped FXbool has(const FXchar* ky) const { return 0<=find(ky); } /// Check if key is mapped FXbool has(const FXString& ky) const { return has(ky.text()); } /// Return reference to slot assocated with given key void*& at(const FXchar* ky); /// Return constant reference to slot assocated with given key void *const& at(const FXchar* ky) const; /// Return reference to slot assocated with given key void*& at(const FXString& ky){ return at(ky.text()); } /// Return constant reference to slot assocated with given key void *const& at(const FXString& ky) const { return at(ky.text()); } /// Return reference to slot assocated with given key void*& operator[](const FXchar* ky){ return at(ky); } /// Return constant reference to slot assocated with given key void *const& operator[](const FXchar* ky) const { return at(ky); } /// Return reference to slot assocated with given key void*& operator[](const FXString& ky){ return at(ky); } /// Return constant reference to slot assocated with given key void *const& operator[](const FXString& ky) const { return at(ky); } /// Insert association with given key; return old value, if any void* insert(const FXchar* ky,void* ptr=nullptr){ return swap(ptr,at(ky)); } /// Insert association with given key; return old value, if any void* insert(const FXString& ky,void* ptr=nullptr){ return swap(ptr,at(ky)); } /// Remove association with given key; return old value, if any void* remove(const FXchar* ky); /// Remove association with given key; return old value, if any void* remove(const FXString& ky){ return remove(ky.text()); } /// Erase data at pos in the table; return old value, if any void* erase(FXival pos); /// Return true if slot is empty. FXbool empty(FXival pos) const { return table[pos].key.empty(); } /// Return key at position pos const FXString& key(FXival pos) const { return table[pos].key; } /// Return reference to slot at position pos void*& data(FXival pos){ return table[pos].data; } /// Return constant reference to slot at position pos void *const& data(FXival pos) const { return table[pos].data; } /// Clear entire table FXbool clear(); /// Destroy table ~FXDictionary(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDictionaryOf.h000066400000000000000000000112771455751074500234720ustar00rootroot00000000000000/******************************************************************************** * * * D i c t i o n a r y O f P o i n t e r s T o T y p e * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDICTIONARYOF_H #define FXDICTIONARYOF_H namespace FX { /** * Dictionary of pointers to TYPE. */ template class FXDictionaryOf : public FXDictionary { public: /// Default constructor FXDictionaryOf(){} /// Copy constructor FXDictionaryOf(const FXDictionaryOf& other):FXDictionary(other){ } /// Assignment operator FXDictionaryOf& operator=(const FXDictionaryOf& other){ return reinterpret_cast&>(FXDictionary::operator=(other)); } /// Adopt dictionary from another FXDictionaryOf& adopt(FXDictionaryOf& other){ return reinterpret_cast&>(FXDictionary::adopt(other)); } /// Return reference to slot assocated with given key TYPE*& at(const FXchar* ky){ return reinterpret_cast(FXDictionary::at(ky)); } /// Return constant reference to slot assocated with given key TYPE *const& at(const FXchar* ky) const { return reinterpret_cast(FXDictionary::at(ky)); } /// Return reference to slot assocated with given key TYPE*& at(const FXString& ky){ return reinterpret_cast(FXDictionary::at(ky.text())); } /// Return constant reference to slot assocated with given key TYPE *const& at(const FXString& ky) const { return reinterpret_cast(FXDictionary::at(ky.text())); } /// Return reference to slot assocated with given key TYPE*& operator[](const FXchar* ky){ return reinterpret_cast(FXDictionary::at(ky)); } /// Return constant reference to slot assocated with given key TYPE *const& operator[](const FXchar* ky) const { return reinterpret_cast(FXDictionary::at(ky)); } /// Return reference to slot assocated with given key TYPE*& operator[](const FXString& ky){ return reinterpret_cast(FXDictionary::at(ky.text())); } /// Return constant reference to slot assocated with given key TYPE *const& operator[](const FXString& ky) const { return reinterpret_cast(FXDictionary::at(ky.text())); } /// Insert association with given key; return old value, if any TYPE* insert(const FXchar* ky,TYPE* ptr=nullptr){ return reinterpret_cast(FXDictionary::insert(ky,ptr)); } /// Insert association with given key; return old value, if any TYPE* insert(const FXString& ky,TYPE* ptr=nullptr){ return insert(ky.text(),ptr); } /// Remove association with given key; return old value, if any TYPE* remove(const FXchar* ky){ return reinterpret_cast(FXDictionary::remove(ky)); } /// Remove association with given key; return old value, if any TYPE* remove(const FXString& ky){ return reinterpret_cast(FXDictionary::remove(ky.text())); } /// Erase data at pos in the table; return old value, if any TYPE* erase(FXival pos){ return reinterpret_cast(FXDictionary::erase(pos)); } /// Return reference to slot at position pos TYPE*& data(FXival pos){ return reinterpret_cast(FXDictionary::data(pos)); } /// Return constant reference to slot at position pos TYPE *const& data(FXival pos) const { return reinterpret_cast(FXDictionary::data(pos)); } }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDir.h000066400000000000000000000076111455751074500216130ustar00rootroot00000000000000/******************************************************************************** * * * D i r e c t o r y E n u m e r a t o r * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDIR_H #define FXDIR_H namespace FX { /// Directory enumerator class FXAPI FXDir { private: FXuval space[256]; public: /// Options for listing files enum { MatchAll = 0, /// Only files and directories matching pattern NoFiles = 1, /// Don't list any files NoDirs = 2, /// Don't list any directories AllFiles = 4, /// List all files AllDirs = 8, /// List all directories HiddenFiles = 16, /// List hidden files also HiddenDirs = 32, /// List hidden directories also NoParent = 64, /// Don't include '.' and '..' in the listing CaseFold = 128 /// Matching is case-insensitive }; private: FXDir(const FXDir&); FXDir &operator=(const FXDir&); public: /// Construct directory enumerator FXDir(); /// Construct directory enumerator open on path FXDir(const FXString& path); /// Open directory to path, return true if ok. FXbool open(const FXString& path); /// Returns true if the directory is open FXbool isOpen() const; /// Go to next directory entry and return its name FXbool next(FXString& name); /// Close directory void close(); /// Create directory static FXbool create(const FXString& path,FXuint perm=FXIO::AllFull); /// Remove directory static FXbool remove(const FXString& path); /** * List files in a given directory. * Returns the number of files in the string-array list which matched the * pattern or satisfied the flag conditions. */ static FXint listFiles(FXString*& filelist,const FXString& path,const FXString& pattern="*",FXuint flags=FXDir::MatchAll); /** * List drives, i.e. the roots of directory trees. * On Windows, this returns an array of strings like {"C:\", "D:\", ..., ""}, * while on Unix it will be just a two-element list like {"/", ""}. * The last element will be always be set to the empty string. * The list can be released by means of delete [] list. * Returns the number of non-empty elements in the array. */ static FXint listDrives(FXString*& drivelist); /// Create a directories recursively static FXbool createDirectories(const FXString& path,FXuint perm=FXIO::AllFull); /// Destructor ~FXDir(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDirBox.h000066400000000000000000000106701455751074500222630ustar00rootroot00000000000000/******************************************************************************** * * * D i r e c t o r y B o x W i d g e t * * * ********************************************************************************* * Copyright (C) 1999,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDIRBOX_H #define FXDIRBOX_H #ifndef FXTREELISTBOX_H #include "FXTreeListBox.h" #endif namespace FX { class FXIcon; class FXFileAssociations; /// Directory Box options enum { DIRBOX_NO_OWN_ASSOC = 0x00020000 /// Do not create associations for files }; /** * A Directory Box widget allows the user to select parts of a file path. * First, it is filled with a string comprising a file path, like "/a/b/c". * Then, the user can select "/a/b/c", "/a/b", "/a", and "/" from the drop-down * list. The entries in the drop-down list are automatically provided with icons * by consulting the file-associations registry settings. * The Directory Box sends SEL_CHANGED and SEL_COMMAND messages, with the string * containing the full path to the selected item. */ class FXAPI FXDirBox : public FXTreeListBox { FXDECLARE(FXDirBox) protected: FXFileAssociations *associations; // Association table FXIcon *foldericon; // Folder icons FXIcon *cdromicon; // CDROM icon FXIcon *harddiskicon; // Hard disk icon FXIcon *netdriveicon; // Networked drive icon FXIcon *floppyicon; // Floppy icon FXIcon *nethoodicon; // Network neighborhood icon FXIcon *zipdiskicon; // Zip drive icon protected: FXDirBox(){} FXString getItemPathname(FXTreeItem *item) const; FXTreeItem* getPathnameItem(const FXString& path); private: FXDirBox(const FXDirBox&); FXDirBox &operator=(const FXDirBox&); public: long onTreeChanged(FXObject*,FXSelector,void*); long onTreeCommand(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetStringValue(FXObject*,FXSelector,void*); long onCmdGetStringValue(FXObject*,FXSelector,void*); public: /// Construct a Directory Box FXDirBox(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=FRAME_SUNKEN|FRAME_THICK|TREELISTBOX_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Destroy server-side resources virtual void destroy(); /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Set current directory void setDirectory(const FXString& pathname,FXbool notify=false); /// Return current directory FXString getDirectory() const; /// Change file associations; delete the old one unless it was shared void setAssociations(FXFileAssociations* assoc,FXbool owned=false,FXbool notify=false); /// Return file associations FXFileAssociations* getAssociations() const { return associations; } /// Destructor virtual ~FXDirBox(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDirDialog.h000066400000000000000000000101611455751074500227250ustar00rootroot00000000000000/******************************************************************************** * * * D i r e c t o r y S e l e c t i o n D i a l o g * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDIRDIALOG_H #define FXDIRDIALOG_H #ifndef FXDIALOGBOX_H #include "FXDialogBox.h" #endif namespace FX { class FXFileAssociations; class FXDirSelector; /** * A Directory Dialog provides a way to select a directory. In function, * the directory selection dialog is very similar to the file dialog, except that * the Directory Dialog displays a tree-structured view of the file system, and * thereby makes up and down navigation through the file system significantly easier. */ class FXAPI FXDirDialog : public FXDialogBox { FXDECLARE(FXDirDialog) protected: FXDirSelector *dirbox; // Directory selection widget protected: static const FXchar sectionName[]; protected: FXDirDialog(){} void initdialog(); private: FXDirDialog(const FXDirDialog&); FXDirDialog &operator=(const FXDirDialog&); public: /// Construct Directory Dialog box FXDirDialog(FXWindow* owner,const FXString& name,FXuint opts=0,FXint x=0,FXint y=0,FXint w=400,FXint h=300); /// Construct free-floating Directory Dialog box FXDirDialog(FXApp* a,const FXString& name,FXuint opts=0,FXint x=0,FXint y=0,FXint w=400,FXint h=300); /// Hide this window virtual void hide(); /// Change directory void setDirectory(const FXString& path); /// Return directory FXString getDirectory() const; /// Change wildcard matching pattern void setPattern(const FXString& ptrn); /// Return wildcard pattern FXString getPattern() const; /// Return wildcard matching mode FXuint getMatchMode() const; /// Change wildcard matching mode (see FXPath) void setMatchMode(FXuint mode); /// Return true if showing files as well as directories FXbool showFiles() const; /// Show or hide normal files void showFiles(FXbool showing); /// Return true if showing hidden files FXbool showHiddenFiles() const; /// Show or hide hidden files void showHiddenFiles(FXbool showing); /// Change directory list style void setDirBoxStyle(FXuint style); /// Return directory list style FXuint getDirBoxStyle() const; /// Change file associations; delete old ones if owned void setAssociations(FXFileAssociations* assoc,FXbool owned=false); /// Return file associations FXFileAssociations* getAssociations() const; /// Open directory name static FXString getOpenDirectory(FXWindow* owner,const FXString& caption,const FXString& path); /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destructor virtual ~FXDirDialog(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDirList.h000066400000000000000000000313041455751074500224430ustar00rootroot00000000000000/******************************************************************************** * * * D i r e c t o r y L i s t W i d g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDIRLIST_H #define FXDIRLIST_H #ifndef FXTREELIST_H #include "FXTreeList.h" #endif namespace FX { class FXDirList; class FXFileAssociations; struct FXFileAssoc; /// Directory List options enum { DIRLIST_SHOWFILES = 0x08000000, /// Show files as well as directories DIRLIST_SHOWHIDDEN = 0x10000000, /// Show hidden files or directories DIRLIST_NO_OWN_ASSOC = 0x20000000 /// Do not create associations for files }; /// Directory item class FXAPI FXDirItem : public FXTreeItem { FXDECLARE(FXDirItem) friend class FXDirList; protected: FXFileAssoc *assoc; // File association FXDirItem *link; // Link to next item FXDirItem *list; // List of child items FXlong size; // File size (if a file) FXTime date; // Time of item FXuint mode; // Mode flags private: FXDirItem(const FXDirItem&); FXDirItem& operator=(const FXDirItem&); protected: FXDirItem():assoc(nullptr),link(nullptr),list(nullptr),size(0L),date(0),mode(0){} public: /// Constructor FXDirItem(const FXString& text,FXIcon* oi=nullptr,FXIcon* ci=nullptr,void* ptr=nullptr):FXTreeItem(text,oi,ci,ptr),assoc(nullptr),link(nullptr),list(nullptr),size(0),date(0),mode(0){} /// Return true if this is a file item FXbool isFile() const { return (mode&(FXIO::File))!=0; } /// Return true if this is a directory item FXbool isDirectory() const { return (mode&FXIO::Directory)!=0; } /// Return true if this is an executable item FXbool isExecutable() const { return (mode&FXIO::File)!=0 && (mode&FXIO::AllExec)!=0; } /// Return true if this is a symbolic link item FXbool isSymlink() const { return (mode&FXIO::SymLink)!=0; } /// Return true if this is a character device item FXbool isChardev() const { return (mode&FXIO::Character)!=0; } /// Return true if this is a block device item FXbool isBlockdev() const { return (mode&FXIO::Block)!=0; } /// Return true if this is an FIFO item FXbool isFifo() const { return (mode&FXIO::Fifo)!=0; } /// Return true if this is a socket FXbool isSocket() const { return (mode&FXIO::Socket)!=0; } /// Set the file-association object for this item void setAssoc(FXFileAssoc* a){ assoc=a; } /// Return the file-association object for this item FXFileAssoc* getAssoc() const { return assoc; } /// Set the file size for this item void setSize(FXlong s){ size=s; } /// Return the file size for this item FXlong getSize() const { return size; } /// Set the date for this item, in nanoseconds void setDate(FXTime d){ date=d; } /// Return the date for this item, in nanoseconds FXTime getDate() const { return date; } /// Set file mode bits void setMode(FXuint m){ mode=m; } /// Return file mode flags FXuint getMode() const { return mode; } }; /** * A Directory List widget provides a tree-structured view of the file system. * It automatically updates itself periodically by re-scanning the file system * for any changes. As it scans the displayed directories and files, it automatically * determines the icons to be displayed by consulting the file-associations registry * settings. A number of messages can be sent to the Directory List to control the * filter pattern, sorting order, case sensitivity, and hidden file display mode. * The Directory list widget supports drags and drops of files. */ class FXAPI FXDirList : public FXTreeList { FXDECLARE(FXDirList) protected: FXFileAssociations *associations; // Association table FXDirItem *list; // Root item list FXIcon *opendiricon; // Open folder icon FXIcon *closeddiricon; // Closed folder icon FXIcon *documenticon; // Document icon FXIcon *applicationicon; // Application icon FXIcon *cdromicon; // CDROM icon FXIcon *harddiskicon; // Hard drive icon FXIcon *networkicon; // Network icon FXIcon *floppyicon; // Floppy icon FXIcon *zipdiskicon; // Zip disk icon FXString pattern; // Pattern of file names FXString dropdirectory; // Drop directory FXString dragfiles; // Dragged file names FXString dropfiles; // Dropped file names FXDragAction dropaction; // Drop action FXuint matchmode; // File wildcard match mode FXuint counter; // Refresh counter FXbool draggable; // Dragable files protected: FXDirList(); void listItems(FXbool force,FXbool notify); void listRootItems(FXbool force,FXbool notify); FXbool listChildItems(FXDirItem *par,FXbool force,FXbool notify); FXString getSelectedFiles() const; virtual FXTreeItem* createItem(const FXString& text,FXIcon* oi,FXIcon* ci,void* ptr); FXTreeItem* expandPath(const FXString& path,FXbool notify); private: FXDirList(const FXDirList&); FXDirList &operator=(const FXDirList&); public: long onRefreshTimer(FXObject*,FXSelector,void*); long onBeginDrag(FXObject*,FXSelector,void*); long onEndDrag(FXObject*,FXSelector,void*); long onDragged(FXObject*,FXSelector,void*); long onDNDEnter(FXObject*,FXSelector,void*); long onDNDLeave(FXObject*,FXSelector,void*); long onDNDMotion(FXObject*,FXSelector,void*); long onDNDDrop(FXObject*,FXSelector,void*); long onDNDRequest(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetStringValue(FXObject*,FXSelector,void*); long onCmdGetStringValue(FXObject*,FXSelector,void*); long onCmdToggleHidden(FXObject*,FXSelector,void*); long onUpdToggleHidden(FXObject*,FXSelector,void*); long onCmdShowHidden(FXObject*,FXSelector,void*); long onUpdShowHidden(FXObject*,FXSelector,void*); long onCmdHideHidden(FXObject*,FXSelector,void*); long onUpdHideHidden(FXObject*,FXSelector,void*); long onCmdToggleFiles(FXObject*,FXSelector,void*); long onUpdToggleFiles(FXObject*,FXSelector,void*); long onCmdShowFiles(FXObject*,FXSelector,void*); long onUpdShowFiles(FXObject*,FXSelector,void*); long onCmdHideFiles(FXObject*,FXSelector,void*); long onUpdHideFiles(FXObject*,FXSelector,void*); long onCmdSetPattern(FXObject*,FXSelector,void*); long onUpdSetPattern(FXObject*,FXSelector,void*); long onCmdSortReverse(FXObject*,FXSelector,void*); long onUpdSortReverse(FXObject*,FXSelector,void*); long onCmdSortCase(FXObject*,FXSelector,void*); long onUpdSortCase(FXObject*,FXSelector,void*); long onCmdRefresh(FXObject*,FXSelector,void*); long onUpdHaveSel(FXObject*,FXSelector,void*); long onCmdDeleteSel(FXObject*,FXSelector,void*); long onCmdDropAsk(FXObject*,FXSelector,void*); long onCmdDropCopy(FXObject*,FXSelector,void*); long onCmdDropMove(FXObject*,FXSelector,void*); long onCmdDropLink(FXObject*,FXSelector,void*); public: static FXint ascending(const FXTreeItem* a,const FXTreeItem* b); static FXint descending(const FXTreeItem* a,const FXTreeItem* b); static FXint ascendingCase(const FXTreeItem* a,const FXTreeItem* b); static FXint descendingCase(const FXTreeItem* a,const FXTreeItem* b); public: enum { ID_REFRESHTIMER=FXTreeList::ID_LAST, ID_DROPASK, ID_DROPCOPY, ID_DROPMOVE, ID_DROPLINK, ID_SHOW_FILES, /// Show files ID_HIDE_FILES, /// Hide files ID_TOGGLE_FILES, /// Toggle show files ID_SHOW_HIDDEN, /// Show hidden files ID_HIDE_HIDDEN, /// Hide hidden files ID_TOGGLE_HIDDEN, /// Toggle display of hidden files ID_SET_PATTERN, /// Set match pattern ID_SORT_REVERSE, /// Reverse sort order ID_SORT_CASE, /// Toggle sort case sensitivity ID_REFRESH, /// Refresh immediately ID_DELETE_SEL, /// Delete selected files ID_LAST }; public: /// Construct a directory list FXDirList(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Destroy server-side resources virtual void destroy(); /// Set current file; return true if success FXbool setCurrentFile(const FXString& file,FXbool notify=false); /// Return current file FXString getCurrentFile() const; /// Set current directory; return true if success FXbool setDirectory(const FXString& path,FXbool notify=false); /// Return current directory FXString getDirectory() const; /// Return absolute pathname of item FXString getItemPathname(const FXTreeItem* item) const; /// Return the (closest) item from the absolute pathname FXTreeItem* getPathnameItem(const FXString& path) const; /// Return true if item is a file FXbool isItemFile(const FXTreeItem* item) const; /// Return true if item is a directory FXbool isItemDirectory(const FXTreeItem* item) const; /// Return true if item is executable FXbool isItemExecutable(const FXTreeItem* item) const; /// Return true if this is a symbolic link item FXbool isItemSymlink(const FXTreeItem* item) const; /// Return file association of item FXFileAssoc* getItemAssoc(const FXTreeItem* item) const; /// Return the file size for this item FXlong getItemSize(const FXTreeItem* item) const; /// Return the date for this item, in nanoseconds FXTime getItemDate(const FXTreeItem* item) const; /// Return the mode bits for this item FXuint getItemMode(const FXTreeItem* item) const; /// Collapse tree virtual FXbool collapseTree(FXTreeItem* tree,FXbool notify=false); /// Expand tree virtual FXbool expandTree(FXTreeItem* tree,FXbool notify=false); /// Change wildcard matching pattern FXbool selectMatching(const FXString& ptrn="*",FXuint mode=FXPath::PathName|FXPath::NoEscape,FXbool notify=false); /// Change wildcard matching pattern void setPattern(const FXString& ptrn="*",FXbool notify=false); /// Return wildcard pattern FXString getPattern() const { return pattern; } /// Change wildcard matching mode (see FXPath) void setMatchMode(FXuint mode=FXPath::PathName|FXPath::NoEscape,FXbool notify=false); /// Return wildcard matching mode FXuint getMatchMode() const { return matchmode; } /// Show or hide normal files void showFiles(FXbool flag,FXbool notify=false); /// Return true if showing files as well as directories FXbool showFiles() const; /// Show or hide hidden files and directories void showHiddenFiles(FXbool flag,FXbool notify=false); /// Return true if showing hidden files and directories FXbool showHiddenFiles() const; /// Change file associations; delete the old one unless it was shared void setAssociations(FXFileAssociations* assoc,FXbool owned=false,FXbool notify=false); /// Return file associations FXFileAssociations* getAssociations() const { return associations; } /// Set draggable files void setDraggableFiles(FXbool flag,FXbool notify=false); /// Are files draggable FXbool getDraggableFiles() const { return draggable; } /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destructor virtual ~FXDirList(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDirSelector.h000066400000000000000000000136101455751074500233100ustar00rootroot00000000000000/******************************************************************************** * * * D i r e c t o r y S e l e c t i o n W i d g e t * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDIRSELECTOR_H #define FXDIRSELECTOR_H #ifndef FXPACKER_H #include "FXPacker.h" #endif namespace FX { class FXButton; class FXDirList; class FXTextField; class FXFileAssociations; /** * The Directory Selector widget is the reusable mega-widget component which * is the core of the Directory Dialog. The function of the directory selector widget * is very similar to the file selector widget, except that the directory selector widget * displays a tree-structured view of the file system, and thereby makes up and down * navigation through the file system significantly easier. */ class FXAPI FXDirSelector : public FXPacker { FXDECLARE(FXDirSelector) protected: FXDirList *dirbox; // Directory list widget FXTextField *dirname; // Directory name entry field FXButton *accept; // Accept button FXButton *cancel; // Cancel button FXIcon *updiricon; // Up directory icon FXIcon *homeicon; // Go home icon FXIcon *workicon; // Go home icon FXIcon *bookmarkicon; // Book mark icon FXIcon *bookaddicon; // Book add icon FXIcon *bookdelicon; // Book delete icon FXIcon *bookclricon; // Book clear icon FXIcon *sortingicon; // Sorting icon FXIcon *newicon; // New directory icon FXIcon *deleteicon; // Delete file icon FXIcon *moveicon; // Rename file icon FXIcon *copyicon; // Copy file icon FXIcon *linkicon; // Link file icon FXRecentFiles mrufiles; // Recently visited places protected: FXDirSelector(){} private: FXDirSelector(const FXDirSelector&); FXDirSelector &operator=(const FXDirSelector&); public: long onCmdName(FXObject*,FXSelector,void*); long onCmdOpened(FXObject*,FXSelector,void*); long onCmdHome(FXObject*,FXSelector,void*); long onCmdWork(FXObject*,FXSelector,void*); long onCmdDirectoryUp(FXObject*,FXSelector,void*); long onPopupMenu(FXObject*,FXSelector,void*); long onCmdBookmark(FXObject*,FXSelector,void*); long onCmdUnBookmark(FXObject*,FXSelector,void*); long onCmdVisit(FXObject*,FXSelector,void*); long onCmdNew(FXObject*,FXSelector,void*); long onUpdNew(FXObject*,FXSelector,void*); long onCmdMove(FXObject*,FXSelector,void*); long onCmdCopy(FXObject*,FXSelector,void*); long onCmdLink(FXObject*,FXSelector,void*); long onCmdRemove(FXObject*,FXSelector,void*); long onUpdSelected(FXObject*,FXSelector,void*); public: enum { ID_DIRNAME=FXPacker::ID_LAST, ID_DIRLIST, ID_HOME, ID_WORK, ID_DIRECTORY_UP, ID_BOOKMARK, ID_UNBOOKMARK, ID_VISIT, ID_NEW, ID_REMOVE, ID_MOVE, ID_COPY, ID_LINK, ID_LAST }; public: /// Constructor FXDirSelector(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Return a pointer to the "Accept" button FXButton *acceptButton() const { return accept; } /// Return a pointer to the "Cancel" button FXButton *cancelButton() const { return cancel; } /// Change directory void setDirectory(const FXString& path); /// Return directory FXString getDirectory() const; /// Change wildcard matching pattern void setPattern(const FXString& ptrn); /// Return wildcard pattern FXString getPattern() const; /// Return wildcard matching mode FXuint getMatchMode() const; /// Change wildcard matching mode (see FXPath) void setMatchMode(FXuint mode); /// Return true if showing files as well as directories FXbool showFiles() const; /// Show or hide normal files void showFiles(FXbool showing); /// Return true if showing hidden directories FXbool showHiddenFiles() const; /// Show or hide hidden directories void showHiddenFiles(FXbool showing); /// Change Directory List style void setDirBoxStyle(FXuint style); /// Return Directory List style FXuint getDirBoxStyle() const; /// Change file associations; delete old ones if owned void setAssociations(FXFileAssociations* assoc,FXbool owned=false); /// Return file associations FXFileAssociations* getAssociations() const; /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destructor virtual ~FXDirSelector(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDirVisitor.h000066400000000000000000000147341455751074500231770ustar00rootroot00000000000000/******************************************************************************** * * * D i r e c t o r y V i s i t o r * * * ********************************************************************************* * Copyright (C) 2008,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDIRVISITOR_H #define FXDIRVISITOR_H namespace FX { /** * Directory visitor walks across all files and directories recursively, * starting from the given path. * If the path represents a directory, enter() is called to determine if * the directory should be processed. The visitor then recursively processes * items in the directory, and concludes by calling leave() to indicate it * has left that directory. * If the path represents a regular file, visit() is called to process the * file. * Thus the functions are called in nested fashion, and each successful * call to enter() is matched with a call to leave(), and calls to visit() * are made for each regular file in between. * To influence processing, the three API's can return any of the following values: * * 0 Skip the entry and proceed to the next item. * 1 Continue processing the entry. * 2 Abandon processing altogether and return from traverse(). * * If processing is abandoned, the visitor closes off each unmatched enter() * with a call to leave() and returns without visiting any further directories * or files. * The visitor automatically skips entries already visited or directories with * unsufficient permissions. * Recursion may be optionally limited with the limit parameter; setting limit * equal to 1 traverses the given path only; a setting of 2 traverses the path * and its immediate children, but stops there. A limit of 0 does nothing at * all. * The function info() returns information about the current file or directory * being visited; valid only while in enter(), leave(), or visit() callbacks. */ class FXAPI FXDirVisitor { private: struct Seen; private: Seen* current; private: FXDirVisitor(const FXDirVisitor&); FXDirVisitor& operator=(const FXDirVisitor&); public: /// Initialize directory visitor FXDirVisitor():current(nullptr){} /// Start traversal at given path FXuint traverse(const FXString& path,FXint limit=1000); /// Return true if we're actively visiting directories FXbool visiting() const { return current!=nullptr; } /// Return stats on current file or directory const FXStat& info() const; /// Enter directory virtual FXuint enter(const FXString& path); /// Visit file virtual FXuint visit(const FXString& path); /// Leave directory virtual FXuint leave(const FXString& path); /// Destructor virtual ~FXDirVisitor(); }; /** * Visit directory entries according to flags and matching with wild card pattern, * with similar matching conditions as FXDir::listFiles(). */ class FXAPI FXGlobVisitor : public FXDirVisitor { private: FXString wildcard; // Match files against this wild card FXuint options; // Matching options private: FXGlobVisitor(const FXGlobVisitor&); FXGlobVisitor& operator=(const FXGlobVisitor&); public: /// Construct directory visitor FXGlobVisitor():options(0){} /// Start traversal at given path FXuint traverse(const FXString& path,const FXString& wild="*",FXuint opts=FXDir::MatchAll,FXint depth=1000); /// Enter directory; returns 1 if path matches criteria virtual FXuint enter(const FXString& path); /// Visit file; returns 1 if path matches criteria virtual FXuint visit(const FXString& path); /// Leave directory; always returns 1 virtual FXuint leave(const FXString& path); /// Destructor virtual ~FXGlobVisitor(); }; /** * Visit directory entries according to flags and matching with wild card pattern, * as per FXGlobVisitor above. * In addition, count numbers of items visited, with an eye toward setting progress * bar boundaries. */ class FXAPI FXGlobCountVisitor : public FXGlobVisitor { private: FXlong countFolders; // Count of folders seen FXlong countFiles; // Count of files seen FXlong countBytes; // Total number of bytes in files FXlong maxDepth; // Maximum depth FXlong depth; // Current depth during traversal private: FXGlobCountVisitor(const FXGlobCountVisitor&); FXGlobCountVisitor& operator=(const FXGlobCountVisitor&); public: /// Create new glob counting visitor FXGlobCountVisitor(); /// Start traversal of path FXuint traverse(const FXString& path,const FXString& wild="*",FXuint opts=FXDir::MatchAll,FXint limit=1000); /// Return total number of folders found FXlong getTotalFolders() const { return countFolders; } /// Return total number of files matched FXlong getTotalFiles() const { return countFiles; } /// Return total number of bytes in matching files FXlong getTotalBytes() const { return countBytes; } /// Return maximum depth of directory tree FXlong getMaximumDepth() const { return maxDepth; } /// Count directories virtual FXuint enter(const FXString& path); /// Count files virtual FXuint visit(const FXString& path); /// Count depth virtual FXuint leave(const FXString& path); /// Destructor virtual ~FXGlobCountVisitor(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDirWatch.h000066400000000000000000000066701455751074500226060ustar00rootroot00000000000000/******************************************************************************** * * * W a t c h D i r e c t o r i e s f o r C h a n g e s * * * ********************************************************************************* * Copyright (C) 2006,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDIRWATCH_H #define FXDIRWATCH_H #ifndef FXOBJECT_H #include "FXObject.h" #endif namespace FX { class FXApp; #define DIRWATCH 1 /** * Watches one or more directories (on Linux, also files..). * Issue messages when one of them was changed. * Each path has a corresponding handle which is used to interact with * the operating system. */ class FXAPI FXDirWatch : public FXObject { FXDECLARE(FXDirWatch) private: FXApp* app; // Back link to application object protected: FXInputHandle hnd; // Handle FXDictionary pathToHandle; // Path to handle map FXReverseDictionary handleToPath; // Handle to path map FXTime timestamp; // Time stamp FXObject* target; // Target object FXSelector message; // Message ID private: FXDirWatch(const FXDirWatch&); FXDirWatch& operator=(const FXDirWatch&); public: enum{ ID_CHANGE=1, ID_LAST }; public: long onMessage(FXObject*,FXSelector,void*); public: /// Initialize directory watcher FXDirWatch(FXApp* a=nullptr,FXObject* tgt=nullptr,FXSelector sel=0); /// Get application pointer FXApp* getApp() const { return app; } /// Set the message target object void setTarget(FXObject *t){ target=t; } /// Get the message target object FXObject* getTarget() const { return target; } /// Set the message identifier void setSelector(FXSelector sel){ message=sel; } /// Get the message identifier FXSelector getSelector() const { return message; } /// Add path to watch; return true if added FXbool addWatch(const FXString& path); /// Remove path to watch; return true if removed FXbool remWatch(const FXString& path); /// Clear all watches FXbool clearAll(); /// Clean up directory watcher virtual ~FXDirWatch(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDispatcher.h000066400000000000000000000122251455751074500231600ustar00rootroot00000000000000/******************************************************************************** * * * C a l l b a c k D i s p a t c h e r * * * ********************************************************************************* * Copyright (C) 2006,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************/ #ifndef FXDISPATCHER_H #define FXDISPATCHER_H #ifndef FXREACTOR_H #include "FXReactor.h" #endif namespace FX { /** * A FXDispatcher watches a number of devices and signals for activity * and dispatches to the proper function when activity is observed. */ class FXAPI FXDispatcher : public FXReactor { private: struct Handle; struct Signal; struct Idle; struct Timer; private: FXHash handles; // Handle callbacks Signal **signals; // Signal callbacks Timer *timers; // Timeout callbacks Idle *idles; // Idle callbacks Timer *timerrecs; // Timer records Idle *idlerecs; // Idle records private: FXDispatcher(const FXDispatcher&); FXDispatcher &operator=(const FXDispatcher&); public: /// I/O Handle callback when a handle is raised typedef FXCallback HandleCallback; /// Signal callback when signal has been fired typedef FXCallback SignalCallback; /// Timer callback when timer expired typedef FXCallback TimeoutCallback; /// Idle callback when dispatcher is about to block typedef FXCallback IdleCallback; public: /// Construct dispatcher object. FXDispatcher(); /// Initialize dispatcher. virtual FXbool init(); /// Add callback cb with new handle hnd to watch-list virtual FXbool addHandle(HandleCallback cb,FXInputHandle hnd,FXuint mode=InputRead,void* ptr=nullptr); /// Add new handle hnd to watch-list (no callback) virtual FXbool addHandle(FXInputHandle hnd,FXuint mode=InputRead); /// Remove handle hnd from watch-list virtual FXbool remHandle(FXInputHandle hnd); /// Return true if handle has been set. virtual FXbool hasHandle(FXInputHandle hnd) const; /// Dispatch handler when handle index is raised. /// Return true if the handle was raised and the callback returned true. virtual FXbool dispatchHandle(FXInputHandle hnd,FXuint mode,FXuint flags); /// Add (optionally asynchronous) callback cb for signal sig to signal-set virtual FXbool addSignal(SignalCallback cb,FXint sig,void* ptr=nullptr,FXbool async=false); /// Add (optionally asynchronous) signal sig to signal-set (no callback) virtual FXbool addSignal(FXint sig,FXbool async=false); /// Remove signal from signal-set virtual FXbool remSignal(FXint sig); /// Dispatch a signal handler if signal fired. /// Return true if the signal was raised and the callback handler returned true. virtual FXbool dispatchSignal(FXint sig); /// Add timeout callback cb at time due (ns since Epoch). /// If callback cb was already set, remove it and return its old /// data pointer, then reset it to the new time and data pointer. virtual void* addTimeout(TimeoutCallback cb,FXTime due,void* ptr=nullptr); /// Add timeout callback cb after time interval (ns). /// If callback cb was already set, remove it and return its old /// data pointer, then reset it to the new time and data pointer. virtual void* addInterval(TimeoutCallback cb,FXTime interval,void* ptr=nullptr); /// Remove timeout callback cb. /// If callback cb was set, return its data pointer. virtual void* remTimeout(TimeoutCallback cb); /// Return when timeout callback cb is due. /// If callback cb was not set or has expired, return forever. virtual FXTime getTimeout(TimeoutCallback cb) const; /// Return true if timeout callback cb been set. virtual FXbool hasTimeout(TimeoutCallback cb) const; /// Return time when first timer callback is due. /// If no timeout callback is currently set, return forever. virtual FXTime nextTimeout(); /// Dispatch a timer when due. /// Return true if a timer was due and the callback returned true. virtual FXbool dispatchTimeout(FXTime due); /// Add idle callback be executed when dispatch about to block. /// If callback cb was already set, remove it and return its old /// data pointer, then reset the callback with the new pointer. virtual void* addIdle(IdleCallback cb,void* ptr=nullptr); /// Remove idle callback cb. /// If callback cb was set, return its data pointer. virtual void* remIdle(IdleCallback cb); /// Return true if idle callback cb been set. virtual FXbool hasIdle(IdleCallback cb) const; /// Dispatch one idle callback. /// Return true if a chore was set and the callback returned true. virtual FXbool dispatchIdle(); /// Exit dispatcher. virtual FXbool exit(); /// Destroy dispatcher object. virtual ~FXDispatcher(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDisplay.h000066400000000000000000000036671455751074500225110ustar00rootroot00000000000000/******************************************************************************** * * * D i s p l a y C l a s s * * * ********************************************************************************* * Copyright (C) 2019,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDISPLAY_H #define FXDISPLAY_H namespace FX { /** * Display class. */ class FXAPI FXDisplay { private: FXptr display; // Display private: FXDisplay(const FXDisplay&); FXDisplay &operator=(const FXDisplay&); public: /// Construct display FXDisplay(); /// Destroy display ~FXDisplay(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDockBar.h000066400000000000000000000205441455751074500224020ustar00rootroot00000000000000/******************************************************************************** * * * D o c k B a r W i d g e t * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDOCKBAR_H #define FXDOCKBAR_H #ifndef FXPACKER_H #include "FXPacker.h" #endif namespace FX { class FXDockSite; /** * A dock bar widget can be docked inside a dock site widget, or floated * around freely. Users can move, undock, and dock the dock bar widget * by means of a handle such as a tool bar grip. When docking, the dock * bar sends a SEL_DOCKED message to its target; when undocking, it sends * a SEL_FLOATED message. In either case the dock site involved is passed * in the void* pointer argument of the message. */ class FXAPI FXDockBar : public FXPacker { FXDECLARE(FXDockBar) protected: FXComposite *drydock; // Parent when docked FXComposite *wetdock; // Parent when floating FXint gripx; // Grip offset x FXint gripy; // Grip offset y FXuchar allowed; // Where we're allowed to dock // FXuchar mode; // Dragging mode //protected: // static const FXDefaultCursor cursorType[16]; protected: FXDockBar(); FXbool isAllowable(FXuint hints) const; // FXuchar where(FXint x,FXint y) const; protected: enum { DRAG_NONE = 0, DRAG_TOP = 1, DRAG_BOTTOM = 2, DRAG_LEFT = 4, DRAG_RIGHT = 8, DRAG_TOPLEFT = (DRAG_TOP|DRAG_LEFT), DRAG_TOPRIGHT = (DRAG_TOP|DRAG_RIGHT), DRAG_BOTTOMLEFT = (DRAG_BOTTOM|DRAG_LEFT), DRAG_BOTTOMRIGHT = (DRAG_BOTTOM|DRAG_RIGHT) }; private: FXDockBar(const FXDockBar&); FXDockBar &operator=(const FXDockBar&); public: // long onEnter(FXObject*,FXSelector,void*); // long onLeave(FXObject*,FXSelector,void*); // long onMotion(FXObject*,FXSelector,void*); // long onLeftBtnPress(FXObject*,FXSelector,void*); // long onLeftBtnRelease(FXObject*,FXSelector,void*); long onCmdUndock(FXObject*,FXSelector,void*); long onUpdUndock(FXObject*,FXSelector,void*); long onCmdDockTop(FXObject*,FXSelector,void*); long onUpdDockTop(FXObject*,FXSelector,void*); long onCmdDockBottom(FXObject*,FXSelector,void*); long onUpdDockBottom(FXObject*,FXSelector,void*); long onCmdDockLeft(FXObject*,FXSelector,void*); long onUpdDockLeft(FXObject*,FXSelector,void*); long onCmdDockRight(FXObject*,FXSelector,void*); long onUpdDockRight(FXObject*,FXSelector,void*); long onUpdDockFlip(FXObject*,FXSelector,void*); long onBeginDragGrip(FXObject*,FXSelector,void*); long onEndDragGrip(FXObject*,FXSelector,void*); long onDraggedGrip(FXObject*,FXSelector,void*); long onPopupMenu(FXObject*,FXSelector,void*); long onDockTimer(FXObject*,FXSelector,void*); public: enum { ID_DOCK_FLOAT=FXPacker::ID_LAST, /// Undock the dock bar ID_DOCK_TOP, /// Dock on the top ID_DOCK_BOTTOM, /// Dock on the bottom ID_DOCK_LEFT, /// Dock on the left ID_DOCK_RIGHT, /// Dock on the right ID_DOCK_FLIP, /// Flip orientation ID_TOOLBARGRIP, /// Tool bar grip ID_TIMER, ID_LAST }; public: enum { ALLOW_NOWHERE=0, /// Don't allow docking anywhere ALLOW_TOP=1, /// Docking at the top only ALLOW_BOTTOM=2, /// Docking at the bottom only ALLOW_LEFT=4, /// Docking at the left only ALLOW_RIGHT=8, /// Docking at the right only ALLOW_HORIZONTAL=ALLOW_TOP|ALLOW_BOTTOM, /// Docking at the top and bottom ALLOW_VERTICAL=ALLOW_LEFT|ALLOW_RIGHT, /// Docking at the left and right ALLOW_EVERYWHERE=ALLOW_HORIZONTAL|ALLOW_VERTICAL /// Docking can be everywhere }; public: /** * Construct a floatable dock bar, with a default parent p and an * alternate parent q. To allow docking and dragging the default parent * p must be of type FXDockSite, and the alternate parent q must be of * type FXToolBarShell. * Normally, the dock bar is docked under a window p of type FXDockSite. * When floated, the toolbar can be docked under window q, which is * usually an kind of FXToolBarShell window. */ FXDockBar(FXComposite* p,FXComposite* q,FXuint opts=LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FILL_X,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=3,FXint pr=3,FXint pt=2,FXint pb=2,FXint hs=DEFAULT_SPACING,FXint vs=DEFAULT_SPACING); /** * Construct a non-floatable dock bar. * The dock bar can not be undocked. */ FXDockBar(FXComposite* p,FXuint opts,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=2,FXint pr=3,FXint pt=3,FXint pb=2,FXint hs=DEFAULT_SPACING,FXint vs=DEFAULT_SPACING); /// Return true if docked FXbool isDocked() const; /** * Check if the dock bar would dock or undock if at locaton barx, bary. */ FXbool insideDock(FXDockSite* docksite,FXint barx,FXint bary); /** * Set parent when docked. * If it was docked, reparent under the new docking window. */ void setDryDock(FXComposite* dry); /** * Set parent when floating. * If it was undocked, then reparent under the new floating window. */ void setWetDock(FXComposite* wet); /// Return parent when docked FXComposite* getDryDock() const { return drydock; } /// Return parent when floating FXComposite* getWetDock() const { return wetdock; } /// Search for dock against given side of main window FXDockSite* findDockAtSide(FXuint side=LAYOUT_SIDE_TOP); /// Search for dock close to coordinates rootx, rooty FXDockSite* findDockNear(FXint rootx,FXint rooty); /** * Dock the bar against the given side, after some other widget. * However, if after is -1, it will be docked as the innermost bar just before * the work-area, while if after is 0, if will be docked as the outermost bar. */ virtual void dock(FXDockSite* docksite,FXWindow* other=nullptr,FXbool notify=false); /** * Dock the bar against the given side, near the given position relative * to the toolbar dock's origin. */ virtual void dock(FXDockSite* docksite,FXint localx,FXint localy,FXbool notify); /** * Undock or float the bar. * The initial position of the wet dock is a few pixels * below and to the right of the original docked position. */ virtual void undock(FXint rootx,FXint rooty,FXbool notify=false); /** * Change set of sides (a combination of ALLOW_TOP, ALLOW_LEFT, etc.), * where docking is allowed. The default is to allow docking on all sides. */ void allowedSides(FXuchar allow){ allowed=allow; } /** * Return set of sides where docking is allowed */ FXuchar allowedSides() const { return allowed; } /// Save toolbar to a stream virtual void save(FXStream& store) const; /// Load toolbar from a stream virtual void load(FXStream& store); /// Destroy virtual ~FXDockBar(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDockHandler.h000066400000000000000000000066341455751074500232570ustar00rootroot00000000000000/******************************************************************************** * * * D o c k H a n d l e r W i d g e t * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDOCKHANDLER_H #define FXDOCKHANDLER_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { /** * The dock handler exists as a common base class for tool bar grip * and dock title. */ class FXAPI FXDockHandler : public FXFrame { FXDECLARE_ABSTRACT(FXDockHandler) protected: FXString tip; // Tool tip FXString help; // Help string private: FXID xxx; protected: FXDockHandler(); private: FXDockHandler(const FXDockHandler&); FXDockHandler& operator=(const FXDockHandler&); public: long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onCmdSetTip(FXObject*,FXSelector,void*); long onCmdGetTip(FXObject*,FXSelector,void*); long onCmdSetHelp(FXObject*,FXSelector,void*); long onCmdGetHelp(FXObject*,FXSelector,void*); protected: FXDockHandler(FXComposite* p,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb); public: /// The grip can receive the focus virtual FXbool canFocus() const; /// Set the status line help text for grip void setHelpText(const FXString& text){ help=text; } /// Get the status line help text for grip const FXString& getHelpText() const { return help; } /// Set the tool tip message for the grip void setTipText(const FXString& text){ tip=text; } /// Get the tool tip message for the grip const FXString& getTipText() const { return tip; } /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDockSite.h000066400000000000000000000170401455751074500225770ustar00rootroot00000000000000/******************************************************************************** * * * D o c k S i t e W i d g e t * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDOCKSITE_H #define FXDOCKSITE_H #ifndef FXPACKER_H #include "FXPacker.h" #endif namespace FX { class FXDockBar; /// Dock site options enum { DOCKSITE_WRAP = 0, /// Dockbars are wrapped to another galley when not enough space on current galley DOCKSITE_NO_WRAP = 0x00020000 /// Never wrap dockbars to another galley even if not enough space }; /** * The dock site widget is a widget where dock bars can be docked. * Dock site widgets are typically embedded inside the main window, placed * against those sides where docking of toolbars is to be allowed. * Dock bars placed inside a dock site are laid out in horizontal or vertical bands * called galleys. A toolbar with the LAYOUT_DOCK_SAME hint is preferentially placed * on the same galley as its previous sibling. A dock bar with the LAYOUT_DOCK_NEXT is * always placed on the next galley. * Each galley will have at least one dock bar shown in it. Several dock bars * may be placed side-by-side inside one galley, unless there is insufficient * room. If there is insufficient room to place another dock bar, that dock bar * will be moved to the next galley, even though its LAYOUT_DOCK_NEXT option * is not set. This implies that when the main window is resized and more room * becomes available, it will jump back to its preferred galley. * Within a galley, dock bars will be placed from left to right, at the given * x and y coordinates, with the constraints that the dock bar will stay within * the galley, and do not overlap each other. It is possible to use LAYOUT_FILL_X * and/or LAYOUT_FILL_Y to stretch a toolbar to the available space on its galley. * The galleys are oriented horizontally if the dock site is placed inside * a top level window using LAYOUT_SIDE_TOP or LAYOUT_SIDE_BOTTOM, and * vertically oriented if placed with LAYOUT_SIDE_LEFT or LAYOUT_SIDE_RIGHT. */ class FXAPI FXDockSite : public FXPacker { FXDECLARE(FXDockSite) protected: // FXuchar mode; // Dragging mode protected: // static const FXDefaultCursor cursorType[16]; private: FXDockSite(const FXDockSite&); FXDockSite &operator=(const FXDockSite&); protected: FXDockSite(){} void moveVerBar(FXWindow*& begin,FXWindow*& end,FXWindow* bar,FXint barx,FXint bary,FXint barw,FXint barh,FXbool hop); void moveHorBar(FXWindow*& begin,FXWindow*& end,FXWindow* bar,FXint barx,FXint bary,FXint barw,FXint barh,FXbool hop); void galleyOfHorzBar(FXWindow *bar,FXWindow*& begin,FXWindow*& end) const; void galleyOfVertBar(FXWindow *bar,FXWindow*& begin,FXWindow*& end) const; FXint galleyWidth(FXWindow* begin,FXWindow*& end,FXint space,FXint& require,FXint& expand) const; FXint galleyHeight(FXWindow* begin,FXWindow*& end,FXint space,FXint& require,FXint& expand) const; protected: enum { DRAG_NONE = 0, DRAG_TOP = 1, DRAG_BOTTOM = 2, DRAG_LEFT = 4, DRAG_RIGHT = 8, DRAG_TOPLEFT = (DRAG_TOP|DRAG_LEFT), DRAG_TOPRIGHT = (DRAG_TOP|DRAG_RIGHT), DRAG_BOTTOMLEFT = (DRAG_BOTTOM|DRAG_LEFT), DRAG_BOTTOMRIGHT = (DRAG_BOTTOM|DRAG_RIGHT) }; public: // long onEnter(FXObject*,FXSelector,void*); // long onLeave(FXObject*,FXSelector,void*); // long onMotion(FXObject*,FXSelector,void*); // long onLeftBtnPress(FXObject*,FXSelector,void*); // long onLeftBtnRelease(FXObject*,FXSelector,void*); public: /** * Construct a toolbar dock layout manager. Passing LAYOUT_SIDE_TOP or LAYOUT_SIDE_BOTTOM * causes the toolbar dock to be oriented horizontally. Passing LAYOUT_SIDE_LEFT or * LAYOUT_SIDE_RIGHT causes it to be oriented vertically. */ FXDockSite(FXComposite *p,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=0,FXint pr=0,FXint pt=0,FXint pb=0,FXint hs=0,FXint vs=0); /** * Return default width. This is the width the toolbar * dock would have if no toolbars need to be moved to other * galleys than they would be logically placed. */ virtual FXint getDefaultWidth(); /** * Return default height. This is the height the toolbar * dock would have if no toolbars need to be moved to other * galleys than they would be logically placed. */ virtual FXint getDefaultHeight(); /** * For a vertically oriented dock site, this computes * the total width of all the galleys based on any "wrapping" * needed to fit the toolbars on a galley. */ virtual FXint getWidthForHeight(FXint h); /** * For a horizontally oriented dock site, this computes * the total height of all the galleys based on any "wrapping" * needed to fit the toolbars on a galley. */ virtual FXint getHeightForWidth(FXint w); /// Perform layout virtual void layout(); /// Resize toolbar virtual void resizeToolBar(FXDockBar* bar,FXint barx,FXint bary,FXint barw,FXint barh); /** * Move tool bar, changing its options to suite the new position. * Used by the toolbar dragging to rearrange the toolbars inside the * toolbar dock. */ virtual void moveToolBar(FXDockBar* bar,FXint barx,FXint bary); /** * The dock site is notified that the given bar has been added * logically before the other window, and is to placed on a new * galley all by itself. The default implementation adjusts * the layout options of the bars accordingly. */ virtual void dockToolBar(FXDockBar* bar,FXWindow* other); /** * The dock site is informed that the given bar has been docked * at the given coordinates. The default implementation determines * where to insert the newly docked bar and adjusts the layout * options of the bars accordingly. */ virtual void dockToolBar(FXDockBar* bar,FXint barx,FXint bary); /** * The dock site is informed that the given bar has been removed. * In the default implementation, the dock site fixes the layout * options of the remaining bars so they stay in the same place * if possible. */ virtual void undockToolBar(FXDockBar* bar); /// Change wrap option void wrapGalleys(FXbool wrap); /// Get wrap option FXbool wrapGalleys() const; }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDockTitle.h000066400000000000000000000073201455751074500227540ustar00rootroot00000000000000/******************************************************************************** * * * D o c k T i t l e W i d g e t * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDOCKTITLE_H #define FXDOCKTITLE_H #ifndef FXDOCKHANDLER_H #include "FXDockHandler.h" #endif namespace FX { /** * A dock title is used to move its container, a dock bar. * The dock title is also used simultaneously to provide a * caption above the dock bar. */ class FXAPI FXDockTitle : public FXDockHandler { FXDECLARE(FXDockTitle) protected: FXString caption; // Caption text FXFont *font; // Caption font FXColor captionColor; // Caption color protected: FXDockTitle(); private: FXDockTitle(const FXDockTitle&); FXDockTitle& operator=(const FXDockTitle&); public: long onPaint(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetStringValue(FXObject*,FXSelector,void*); long onCmdGetStringValue(FXObject*,FXSelector,void*); public: /// Construct dock bar title widget FXDockTitle(FXComposite* p,const FXString& text,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=FRAME_NORMAL|JUSTIFY_CENTER_X|JUSTIFY_CENTER_Y,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=0,FXint pr=0,FXint pt=0,FXint pb=0); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Set the caption for the grip void setCaption(const FXString& text); /// Get the caption for the grip FXString getCaption() const { return caption; } /// Set caption font void setFont(FXFont *fnt); /// Get caption font FXFont* getFont() const { return font; } /// Get the current caption color FXColor getCaptionColor() const { return captionColor; } /// Set the current caption color void setCaptionColor(FXColor clr); /// Set the current justification mode. void setJustify(FXuint mode); /// Get the current justification mode. FXuint getJustify() const; /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destroy virtual ~FXDockTitle(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDocument.h000066400000000000000000000057551455751074500226620ustar00rootroot00000000000000/******************************************************************************** * * * D o c u m e n t O b j e c t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDOCUMENT_H #define FXDOCUMENT_H #ifndef FXOBJECT_H #include "FXObject.h" #endif namespace FX { // Forward class FXWindow; /// Abstract base class for documents class FXAPI FXDocument : public FXObject { FXDECLARE(FXDocument) private: FXString title; // Title to appear above windows FXString filename; // File name to save to FXbool modified; // Document has been modified public: long onUpdTitle(FXObject*,FXSelector,void*); long onUpdFilename(FXObject*,FXSelector,void*); public: enum { ID_TITLE=10000, // Don't interfere with viewer's message id's ID_FILENAME, ID_LAST }; public: /// Constructor FXDocument(); /// Return true if document is modified FXbool isModified() const { return modified; } /// Set its modified state void setModified(FXbool mdfy=true){ modified=mdfy; } /// Set document title void setTitle(const FXString& name); /// Get document title const FXString& getTitle() const { return title; } /// Set document filename void setFilename(const FXString& path); /// Get document filename const FXString& getFilename() const { return filename; } /// Save document to a stream virtual void save(FXStream& store) const; /// Load document from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXDocument(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDragCorner.h000066400000000000000000000061541455751074500231240ustar00rootroot00000000000000/******************************************************************************** * * * D r a g C o r n e r W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDRAGCORNER_H #define FXDRAGCORNER_H #ifndef FXWINDOW_H #include "FXWindow.h" #endif namespace FX { /** * A drag corner widget may be placed in the bottom right corner * so as to allow the window to be resized more easily. */ class FXAPI FXDragCorner : public FXWindow { FXDECLARE(FXDragCorner) protected: FXColor hiliteColor; FXColor shadowColor; FXint oldw; FXint oldh; FXint xoff; FXint yoff; FXbool ewmh; protected: FXDragCorner(); private: FXDragCorner(const FXDragCorner&); FXDragCorner &operator=(const FXDragCorner&); public: long onPaint(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); public: /// Construct a drag corner FXDragCorner(FXComposite* p); /// Get default width virtual FXint getDefaultWidth(); /// Get default height virtual FXint getDefaultHeight(); /// Create all of the server-side resources for this window virtual void create(); /// Change highlight color void setHiliteColor(FXColor clr); /// Return current highlight color FXColor getHiliteColor() const { return hiliteColor; } /// Change shadow color void setShadowColor(FXColor clr); /// Return current shadow color FXColor getShadowColor() const { return shadowColor; } /// Save drag corner to a stream virtual void save(FXStream& store) const; /// Load drag corner from a stream virtual void load(FXStream& store); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDrawable.h000066400000000000000000000056601455751074500226200ustar00rootroot00000000000000/******************************************************************************** * * * D r a w a b l e A r e a * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDRAWABLE_H #define FXDRAWABLE_H #ifndef FXID_H #include "FXId.h" #endif namespace FX { class FXVisual; /** * Drawable is an abstract base class for any surface that can be * drawn upon, such as a FXWindow, or FXImage. */ class FXAPI FXDrawable : public FXId { FXDECLARE_ABSTRACT(FXDrawable) friend class FXDC; friend class FXDCWindow; friend class FXGLContext; protected: FXVisual *visual; // Visual for this window FXint width; // Width FXint height; // Height protected: FXDrawable(); FXDrawable(FXApp* a,FXint w,FXint h); private: FXDrawable(const FXDrawable&); FXDrawable &operator=(const FXDrawable&); #ifdef WIN32 virtual FXID GetDC() const { return nullptr; } virtual int ReleaseDC(FXID) const { return 0; } #endif public: /// Get the visual FXVisual* getVisual() const { return visual; } /// Width of drawable FXint getWidth() const { return width; } /// Height of drawable FXint getHeight() const { return height; } /// Change visual void setVisual(FXVisual* vis); /// Resize drawable to the specified width and height virtual void resize(FXint w,FXint h); /// Save object to stream virtual void save(FXStream& store) const; /// Load object from stream virtual void load(FXStream& store); /// Cleanup virtual ~FXDrawable(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXDriveBox.h000066400000000000000000000073621455751074500226220ustar00rootroot00000000000000/******************************************************************************** * * * D r i v e B o x W i d g e t * * * ********************************************************************************* * Copyright (C) 1999,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDRIVEBOX_H #define FXDRIVEBOX_H #ifndef FXLISTBOX_H #include "FXListBox.h" #endif namespace FX { class FXFileAssociations; /// Drive Box options enum { DRIVEBOX_NO_OWN_ASSOC = 0x00020000 /// Do not create associations for files }; /// Directory Box class FXAPI FXDriveBox : public FXListBox { FXDECLARE(FXDriveBox) protected: FXFileAssociations *associations; // Association table FXIcon *foldericon; // Folder icons FXIcon *cdromicon; // CDROM icon FXIcon *harddiskicon; // Hard disk icon FXIcon *netdriveicon; // Networked drive icon FXIcon *floppyicon; // Floppy icon FXIcon *nethoodicon; // Network neighborhood icon FXIcon *zipdiskicon; // Zip drive icon protected: FXDriveBox(){} void listDrives(); private: FXDriveBox(const FXDriveBox&); FXDriveBox &operator=(const FXDriveBox&); public: long onListChanged(FXObject*,FXSelector,void*); long onListClicked(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetStringValue(FXObject*,FXSelector,void*); long onCmdGetStringValue(FXObject*,FXSelector,void*); public: /// Constructor FXDriveBox(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=FRAME_SUNKEN|FRAME_THICK|LISTBOX_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Destroy server-side resources virtual void destroy(); /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Set current drive FXbool setDrive(const FXString& drive); /// Return current drive FXString getDrive() const; /// Change file associations void setAssociations(FXFileAssociations* assoc); /// Return file associations FXFileAssociations* getAssociations() const { return associations; } /// Destructor virtual ~FXDriveBox(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXEXEIcon.h000066400000000000000000000063711455751074500223310ustar00rootroot00000000000000/******************************************************************************** * * * E X E I c o n O b j e c t * * * ********************************************************************************* * Copyright (C) 2014,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXEXEICON_H #define FXEXEICON_H #ifndef FXICON_H #include "FXIcon.h" #endif namespace FX { /// Icon from resource in Microsoft Windows executable class FXAPI FXEXEIcon : public FXIcon { FXDECLARE(FXEXEIcon) protected: FXint rtype; // Resource type FXint rid; // Resource id protected: FXEXEIcon(){} private: FXEXEIcon(const FXEXEIcon&); FXEXEIcon &operator=(const FXEXEIcon&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct icon from memory stream comprising Microsoft Windows executable FXEXEIcon(FXApp* a,const FXuchar *pix=nullptr,FXColor clr=FXRGB(192,192,192),FXuint opts=0,FXint w=1,FXint h=1,FXint ri=-1,FXint rt=3); /// Set resource group (type) to load from void setResType(FXint rt){ rtype=rt; } /// Get resource group (type) FXint getResType() const { return rtype; } /// Set resource id to load void setResId(FXint ri){ rid=ri; } /// Get resource id FXint getResId() const { return rid; } /// Save pixels into stream in Microsoft icon format format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in Microsoft icon format format virtual FXbool loadPixels(FXStream& store); /// Destroy icon virtual ~FXEXEIcon(); }; #ifndef FXLOADEXE #define FXLOADEXE /** * Check if stream represents a Windows executable. */ extern FXAPI FXbool fxcheckEXE(FXStream& store); /** * Pull an icon from a Microsoft Windows executable; try and load resource id under resource group type. */ extern FXAPI FXbool fxloadEXE(FXStream& store,FXColor*& data,FXint& width,FXint& height,FXint type,FXint id); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXEXEImage.h000066400000000000000000000063361455751074500224640ustar00rootroot00000000000000/******************************************************************************** * * * E X E I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 2014,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXEXEIMAGE_H #define FXEXEIMAGE_H #ifndef FXIMAGE_H #include "FXImage.h" #endif namespace FX { /// Bitmap from resource in Microsoft Windows executable class FXAPI FXEXEImage : public FXImage { FXDECLARE(FXEXEImage) protected: FXint rtype; // Resource type FXint rid; // Resource id protected: FXEXEImage(){} private: FXEXEImage(const FXEXEImage&); FXEXEImage &operator=(const FXEXEImage&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct image from memory stream comprising Microsoft Windows executable FXEXEImage(FXApp* a,const FXuchar *pix=nullptr,FXuint opts=0,FXint w=1,FXint h=1,FXint ri=-1,FXint rt=3); /// Set resource group (type) to load from void setResType(FXint rt){ rtype=rt; } /// Get resource group (type) FXint getResType() const { return rtype; } /// Set resource id to load void setResId(FXint ri){ rid=ri; } /// Get resource id FXint getResId() const { return rid; } /// Save pixels into stream in Microsoft icon format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in Microsoft icon format virtual FXbool loadPixels(FXStream& store); /// Destroy image virtual ~FXEXEImage(); }; #ifndef FXLOADEXE #define FXLOADEXE /** * Check if stream represents a Windows executable. */ extern FXAPI FXbool fxcheckEXE(FXStream& store); /** * Pull an icon from a Microsoft Windows executable; try and load resource id under resource group type. */ extern FXAPI FXbool fxloadEXE(FXStream& store,FXColor*& data,FXint& width,FXint& height,FXint type,FXint id); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXElement.h000066400000000000000000000254601455751074500224700ustar00rootroot00000000000000/******************************************************************************** * * * G e n e r i c E l e m e n t H a n d l i n g * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXELEMENT_H #define FXELEMENT_H namespace FX { /**************************** D e f i n i t i o n ****************************/ // Generic implementations for generic objects // In-situ construct element at pointer template inline EType* construct(EType* ptr){ ::new ((void*)ptr) EType; return ptr; } // In-situ construct element at pointer, with argument template inline EType* construct(EType* ptr,Arg arg){ ::new ((void*)ptr) EType(arg); return ptr; } // In-situ destroy element at pointer template inline void destruct(EType* ptr){ ptr->~EType(); } /// Construct some elements at a location template inline void constructElms(EType* ptr,FXuval n){ while(n--){ construct(ptr); ptr++; } } /// Construct some elements at a location, with argument template inline void constructElms(EType* ptr,Arg arg,FXuval n){ while(n--){ construct(ptr,arg); ptr++; } } /// Destruct some elements at a location template inline void destructElms(EType* ptr,FXuval n){ while(n--){ destruct(ptr); ptr++; } } /// Copy some elements from one place to another template inline void copyElms(EType* dst,const OType* src,FXuval n){ while(n--){ *dst++ = *src++; } } /// Bit-wise copy elements from overlapping place to another template inline void bitcopyElms(EType* dst,const EType* src,FXuval n){ memcpy((void*)dst,(const void*)src,n*sizeof(EType)); } /// Move some elements from overlapping place to another template inline void moveElms(EType* dst,const EType* src,FXuval n){ if(src>dst){ while(n--){ *dst++ = *src++; } } else if(dst>src){ dst+=n; src+=n; while(n--){ *--dst = *--src; } } } /// Bit-wise move elements from overlapping place to another template inline void bitmoveElms(EType* dst,const EType* src,FXuval n){ memmove((void*)dst,(const void*)src,n*sizeof(EType)); } /// Swap element dst and src template inline EType& swap(EType& dst,EType& src){ EType t=dst; dst=src; src=t; return dst; } /// Swap some elements from one place with another template inline void swapElms(EType* dst,const EType* src,FXuval n){ while(n--){ swap(*dst++,*src++); } } /// Test elements for equality, using equality operator template inline FXbool equalElms(const EType* dst,const EType* src,FXuval n){ while(n--){ if(!(*dst++ == *src++)) return false; } return true; } /// Fill array of elements with given element template inline void fillElms(EType* dst,const OType& src,FXuval n){ while(n--){ *dst++ = src; } } /// Zero out array of elements template inline void clearElms(EType* dst,FXuval n){ memset((void*)dst,0,sizeof(EType)*n); } /// Allocate array of elements, uninitialized template inline FXbool allocElms(EType*& ptr,FXuval n){ return fxmalloc((void**)&ptr,sizeof(EType)*n); } /// Allocate array of elements, initialized with zero template inline FXbool callocElms(EType*& ptr,FXuval n){ return fxcalloc((void**)&ptr,sizeof(EType)*n); } /// Allocate array of elements, initialized with bit-wise copy of src array template inline FXbool dupElms(EType*& ptr,const EType* src,FXuval n){ return fxmemdup((void**)&ptr,src,sizeof(EType)*n); } /// Resize array of elements, without constructor or destructor template inline FXbool resizeElms(EType*& ptr,FXuval n){ return fxresize((void**)&ptr,sizeof(EType)*n); } /// Free array of elements, without destruction template inline void freeElms(EType*& ptr){ fxfree((void**)&ptr); } /********************** I m p l e m e n t a t i o n ************************/ // Specific implementations for built-in types // No-op constructors for array of basic type inline void constructElms(FXchar*,FXuval){ } inline void constructElms(FXuchar*,FXuval){ } inline void constructElms(FXschar*,FXuval){ } inline void constructElms(FXushort*,FXuval){ } inline void constructElms(FXshort*,FXuval){ } inline void constructElms(FXuint*,FXuval){ } inline void constructElms(FXint*,FXuval){ } inline void constructElms(FXulong*,FXuval){ } inline void constructElms(FXlong*,FXuval){ } inline void constructElms(FXfloat*,FXuval){ } inline void constructElms(FXdouble*,FXuval){ } // No-op constructors for array of pointers to any type template inline void constructElms(EType**,FXuval){ } // No-op destructors for array of basic type inline void destructElms(FXchar*,FXuval){ } inline void destructElms(FXuchar*,FXuval){ } inline void destructElms(FXschar*,FXuval){ } inline void destructElms(FXushort*,FXuval){ } inline void destructElms(FXshort*,FXuval){ } inline void destructElms(FXuint*,FXuval){ } inline void destructElms(FXint*,FXuval){ } inline void destructElms(FXulong*,FXuval){ } inline void destructElms(FXlong*,FXuval){ } inline void destructElms(FXfloat*,FXuval){ } inline void destructElms(FXdouble*,FXuval){ } // No-op destructors for array of pointers to any type template inline void destructElms(EType**,FXuval){ } // Simple bit-wise copy for array of basic type inline void copyElms(FXchar* dst,const FXchar* src,FXuval n){ memcpy(dst,src,n); } inline void copyElms(FXuchar* dst,const FXuchar* src,FXuval n){ memcpy(dst,src,n); } inline void copyElms(FXschar* dst,const FXschar* src,FXuval n){ memcpy(dst,src,n); } inline void copyElms(FXushort* dst,const FXushort* src,FXuval n){ memcpy(dst,src,n<<1); } inline void copyElms(FXshort* dst,const FXshort* src,FXuval n){ memcpy(dst,src,n<<1); } inline void copyElms(FXuint* dst,const FXuint* src,FXuval n){ memcpy(dst,src,n<<2); } inline void copyElms(FXint* dst,const FXint* src,FXuval n){ memcpy(dst,src,n<<2); } inline void copyElms(FXulong* dst,const FXulong* src,FXuval n){ memcpy(dst,src,n<<3); } inline void copyElms(FXlong* dst,const FXlong* src,FXuval n){ memcpy(dst,src,n<<3); } inline void copyElms(FXfloat* dst,const FXfloat* src,FXuval n){ memcpy(dst,src,n<<2); } inline void copyElms(FXdouble* dst,const FXdouble* src,FXuval n){ memcpy(dst,src,n<<3); } // Simple bit-wise copy for array of pointers to any type template inline void copyElms(EType** dst,const EType** src,FXuval n){ memcpy(dst,src,n*sizeof(void*)); } // Simple bit-wise move for array of basic type inline void moveElms(FXchar* dst,const FXchar* src,FXuval n){ memmove(dst,src,n); } inline void moveElms(FXuchar* dst,const FXuchar* src,FXuval n){ memmove(dst,src,n); } inline void moveElms(FXschar* dst,const FXschar* src,FXuval n){ memmove(dst,src,n); } inline void moveElms(FXushort* dst,const FXushort* src,FXuval n){ memmove(dst,src,n<<1); } inline void moveElms(FXshort* dst,const FXshort* src,FXuval n){ memmove(dst,src,n<<1); } inline void moveElms(FXuint* dst,const FXuint* src,FXuval n){ memmove(dst,src,n<<2); } inline void moveElms(FXint* dst,const FXint* src,FXuval n){ memmove(dst,src,n<<2); } inline void moveElms(FXulong* dst,const FXulong* src,FXuval n){ memmove(dst,src,n<<3); } inline void moveElms(FXlong* dst,const FXlong* src,FXuval n){ memmove(dst,src,n<<3); } inline void moveElms(FXfloat* dst,const FXfloat* src,FXuval n){ memmove(dst,src,n<<2); } inline void moveElms(FXdouble* dst,const FXdouble* src,FXuval n){ memmove(dst,src,n<<3); } // Simple bit-wise move for array of pointers to any type template inline void moveElms(EType** dst,const EType** src,FXuval n){ memmove(dst,src,n*sizeof(void*)); } // Simple bit-wise comparison for array of basic type inline FXbool equalElms(const FXchar* dst,const FXchar* src,FXuval n){ return memcmp(dst,src,n)==0; } inline FXbool equalElms(const FXuchar* dst,const FXuchar* src,FXuval n){ return memcmp(dst,src,n)==0; } inline FXbool equalElms(const FXschar* dst,const FXschar* src,FXuval n){ return memcmp(dst,src,n)==0; } inline FXbool equalElms(const FXushort* dst,const FXushort* src,FXuval n){ return memcmp(dst,src,n<<1)==0; } inline FXbool equalElms(const FXshort* dst,const FXshort* src,FXuval n){ return memcmp(dst,src,n<<1)==0; } inline FXbool equalElms(const FXuint* dst,const FXuint* src,FXuval n){ return memcmp(dst,src,n<<2)==0; } inline FXbool equalElms(const FXint* dst,const FXint* src,FXuval n){ return memcmp(dst,src,n<<2)==0; } inline FXbool equalElms(const FXulong* dst,const FXulong* src,FXuval n){ return memcmp(dst,src,n<<3)==0; } inline FXbool equalElms(const FXlong* dst,const FXlong* src,FXuval n){ return memcmp(dst,src,n<<3)==0; } inline FXbool equalElms(const FXfloat* dst,const FXfloat* src,FXuval n){ return memcmp(dst,src,n<<2)==0; } inline FXbool equalElms(const FXdouble* dst,const FXdouble* src,FXuval n){ return memcmp(dst,src,n<<3)==0; } // Simple bit-wise comparison for array of pointers to any type template inline FXbool equalElms(EType** dst,const EType** src,FXuval n){ return memcmp(dst,src,n*sizeof(void*))==0; } // Fill byte arrays with constant inline void fillElms(FXchar* dst,const FXchar& src,FXuval n){ memset(dst,src,n); } inline void fillElms(FXuchar* dst,const FXuchar& src,FXuval n){ memset(dst,src,n); } inline void fillElms(FXschar* dst,const FXschar& src,FXuval n){ memset(dst,src,n); } } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXEvent.h000066400000000000000000000226461455751074500221630ustar00rootroot00000000000000/******************************************************************************** * * * F O X E v e n t S t u f f * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXEVENT_H #define FXEVENT_H namespace FX { /// FOX Keyboard and Button states enum { SHIFTMASK = 0x001, /// Shift key is down CAPSLOCKMASK = 0x002, /// Caps Lock key is down CONTROLMASK = 0x004, /// Ctrl key is down #ifdef __APPLE__ ALTMASK = 0x2000, /// Alt key is down METAMASK = 0x10, /// Meta key is down #else ALTMASK = 0x008, /// Alt key is down METAMASK = 0x040, /// Meta key is down #endif NUMLOCKMASK = 0x010, /// Num Lock key is down SCROLLLOCKMASK = 0x0E0, /// Scroll Lock key is down (seems to vary) LEFTBUTTONMASK = 0x100, /// Left mouse button is down MIDDLEBUTTONMASK = 0x200, /// Middle mouse button is down RIGHTBUTTONMASK = 0x400 /// Right mouse button is down }; /// FOX Mouse buttons enum { LEFTBUTTON = 1, MIDDLEBUTTON = 2, RIGHTBUTTON = 3 }; /// FOX window crossing modes enum { CROSSINGNORMAL, /// Normal crossing event CROSSINGGRAB, /// Crossing due to mouse grab CROSSINGUNGRAB /// Crossing due to mouse ungrab }; /// FOX window visibility modes enum { VISIBILITYTOTAL, VISIBILITYPARTIAL, VISIBILITYNONE }; /// FOX Event Types enum { SEL_NONE, SEL_KEYPRESS, /// Key pressed SEL_KEYRELEASE, /// Key released SEL_LEFTBUTTONPRESS, /// Left mouse button pressed SEL_LEFTBUTTONRELEASE, /// Left mouse button released SEL_MIDDLEBUTTONPRESS, /// Middle mouse button pressed SEL_MIDDLEBUTTONRELEASE, /// Middle mouse button released SEL_RIGHTBUTTONPRESS, /// Right mouse button pressed SEL_RIGHTBUTTONRELEASE, /// Right mouse button released SEL_MOTION, /// Mouse motion SEL_ENTER, /// Mouse entered window SEL_LEAVE, /// Mouse left window SEL_FOCUSIN, /// Focus into window SEL_FOCUSOUT, /// Focus out of window SEL_KEYMAP, SEL_UNGRABBED, /// Lost the grab (Windows) SEL_PAINT, /// Must repaint window SEL_CREATE, SEL_DESTROY, SEL_UNMAP, /// Window was hidden SEL_MAP, /// Window was shown SEL_CONFIGURE, /// Resize SEL_SELECTION_LOST, /// Widget lost selection SEL_SELECTION_GAINED, /// Widget gained selection SEL_SELECTION_REQUEST, /// Inquire selection data SEL_RAISED, /// Window to top of stack SEL_LOWERED, /// Window to bottom of stack SEL_CLOSE, /// Close window SEL_DELETE, /// Delete window SEL_MINIMIZE, /// Iconified SEL_RESTORE, /// No longer iconified or maximized SEL_MAXIMIZE, /// Maximized SEL_UPDATE, /// GUI update SEL_COMMAND, /// GUI command SEL_CLICKED, /// Clicked SEL_DOUBLECLICKED, /// Double-clicked SEL_TRIPLECLICKED, /// Triple-clicked SEL_MOUSEWHEEL, /// Mouse wheel SEL_CHANGED, /// GUI has changed SEL_VERIFY, /// Verify change SEL_DESELECTED, /// Deselected SEL_SELECTED, /// Selected SEL_INSERTED, /// Inserted SEL_REPLACED, /// Replaced SEL_DELETED, /// Deleted SEL_OPENED, /// Opened SEL_CLOSED, /// Closed SEL_EXPANDED, /// Expanded SEL_COLLAPSED, /// Collapsed SEL_BEGINDRAG, /// Start a drag SEL_ENDDRAG, /// End a drag SEL_DRAGGED, /// Dragged SEL_LASSOED, /// Lassoed SEL_TIMEOUT, /// Timeout occurred SEL_SIGNAL, /// Signal received SEL_CLIPBOARD_LOST, /// Widget lost clipboard SEL_CLIPBOARD_GAINED, /// Widget gained clipboard SEL_CLIPBOARD_REQUEST, /// Inquire clipboard data SEL_CHORE, /// Background chore SEL_FOCUS_SELF, /// Focus on widget itself SEL_FOCUS_RIGHT, /// Focus moved right SEL_FOCUS_LEFT, /// Focus moved left SEL_FOCUS_DOWN, /// Focus moved down SEL_FOCUS_UP, /// Focus moved up SEL_FOCUS_NEXT, /// Focus moved to next widget SEL_FOCUS_PREV, /// Focus moved to previous widget SEL_DND_ENTER, /// Drag action entering potential drop target SEL_DND_LEAVE, /// Drag action leaving potential drop target SEL_DND_DROP, /// Drop on drop target SEL_DND_MOTION, /// Drag position changed over potential drop target SEL_DND_REQUEST, /// Inquire drag and drop data SEL_IO_READ, /// Read activity on a pipe SEL_IO_WRITE, /// Write activity on a pipe SEL_IO_EXCEPT, /// Except activity on a pipe SEL_PICKED, /// Picked some location SEL_QUERY_TIP, /// Message inquiring about tooltip SEL_QUERY_HELP, /// Message inquiring about statusline help SEL_DOCKED, /// Toolbar docked SEL_FLOATED, /// Toolbar floated SEL_SPACEBALLMOTION, /// Moved space ball puck SEL_SPACEBALLBUTTONPRESS, /// Pressed space ball button SEL_SPACEBALLBUTTONRELEASE, /// Released space ball button SEL_SESSION_NOTIFY, /// Session is about to close SEL_SESSION_CLOSED, /// Session is closed SEL_COPYDATA, /// Copy data message SEL_IME_START, /// IME mode SEL_IME_END, /// IME mode SEL_LAST }; /// FOX Event struct FXAPI FXEvent { FXuint type; /// Event type FXuint time; /// Time of last event FXint win_x; /// Window-relative x-coord FXint win_y; /// Window-relative y-coord FXint root_x; /// Root x-coord FXint root_y; /// Root y-coord FXint state; /// Mouse button and modifier key state FXint code; /// Button, Keysym, or mode; DDE Source FXString text; /// Text of keyboard event FXint last_x; /// Window-relative x-coord of previous mouse location FXint last_y; /// Window-relative y-coord of previous mouse location FXint click_x; /// Window-relative x-coord of mouse press FXint click_y; /// Window-relative y-coord of mouse press FXint rootclick_x; /// Root-relative x-coord of mouse press FXint rootclick_y; /// Root-relative y-coord of mouse press FXuint click_time; /// Time of mouse button press FXint click_button; /// Mouse button pressed FXint click_count; /// Click-count FXint values[6]; /// Valuators from space ball FXbool moved; /// Moved cursor since press FXRectangle rect; /// Rectangle FXbool synthetic; /// True if synthetic expose event FXDragType target; /// Target drag type being requested /// Initialize empty event FXEvent(FXuint t=SEL_NONE){ type=t; time=0; win_x=0; win_y=0; root_x=0; root_y=0; state=0; code=0; last_x=0; last_y=0; click_x=0; click_y=0; rootclick_x=0; rootclick_y=0; click_time=0; click_button=0; click_count=0; values[0]=0; values[1]=0; values[2]=0; values[3]=0; values[4]=0; values[5]=0; moved=false; rect.x=0; rect.y=0; rect.w=0; rect.h=0; synthetic=false; target=0; } }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXEventDispatcher.h000066400000000000000000000037041455751074500241640ustar00rootroot00000000000000/******************************************************************************** * * * E v e n t D i s p a t c h e r * * * ********************************************************************************* * Copyright (C) 2019,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************/ #ifndef FXEVENTDISPATCHER_H #define FXEVENTDISPATCHER_H #ifndef FXDISPATCHER_H #include "FXDispatcher.h" #endif namespace FX { /** * A FXEventDispatcher extends FXDispatcher, adding graphical user interface * handling and other display-related events. */ class FXAPI FXEventDispatcher : public FXDispatcher { private: FXptr display; // Display private: FXEventDispatcher(const FXEventDispatcher&); FXEventDispatcher &operator=(const FXEventDispatcher&); public: /// Event callback when GUI has activity typedef FXCallback EventCallback; public: /// Construct event dispatcher object. FXEventDispatcher(); /// Initialize dispatcher with display. virtual FXbool init(FXptr dpy); /// Initialize dispatcher without display. virtual FXbool init(); /// Return display pointer FXptr getDisplay() const { return display; } /// Dispatch if something happens within given blocking time. /// Flags control subsets of events to be dispatched (signals, timers, /// idle, and more). Default is to dispatch all events. virtual FXbool dispatch(FXTime blocking=forever,FXuint flags=DispatchAll); /// Dispatch platform-dependent event virtual FXbool dispatchEvent(FXRawEvent& event); /// Exit dispatcher. virtual FXbool exit(); /// Destroy event dispatcher object. virtual ~FXEventDispatcher(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXEventLoop.h000066400000000000000000000066721455751074500230160ustar00rootroot00000000000000/******************************************************************************** * * * F O X E v e n t L o o p * * * ********************************************************************************* * Copyright (C) 2019,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXEVENTLOOP_H #define FXEVENTLOOP_H namespace FX { // Forward declarations class FXWindow; class FXEventLoop; class FXEventDispatcher; /// Recursive event loop class FXAPI FXEventLoop { private: FXEventDispatcher *dispatcher; // Event dispatcher FXEventLoop **invocation; // Pointer to variable holding pointer to current invocation FXEventLoop *upper; // Invocation above this one FXWindow *window; // Modal window (if any) FXuint modality; // Modality mode FXint code; // Return code FXbool done; // True if breaking out public: enum{ ModalForNone = 0, ModalForWindow = 1, ModalForPopup = 2 }; private: FXEventLoop(const FXEventLoop&); FXEventLoop& operator=(const FXEventLoop&); public: /// Initialize event loop FXEventLoop(FXEventLoop** inv,FXWindow* win=nullptr,FXuint mode=0); /// Set dispatcher void setDispatcher(FXEventDispatcher* disp){ dispatcher=disp; } /// Get dispatcher FXEventDispatcher* getDispatcher() const { return dispatcher; } /// Test if the window is involved in a modal invocation FXbool isModal(FXWindow *win) const; /// Return window of current modal event loop FXWindow* getModalWindow() const; /// Return window of this model event loop FXWindow* getWindow() const { return window; } /// Return mode of this model event loop FXuint getModality() const { return modality; } /// Break out of topmost event loop, closing all nested loops void stop(FXint value); /// Break out of modal loop matching window, and all deeper ones void stopModal(FXWindow* win,FXint value); /// Break out of modal loop, and all deeper non-modal ones void stopModal(FXint value); /// Destroy event loop ~FXEventLoop(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXException.h000066400000000000000000000122061455751074500230270ustar00rootroot00000000000000/******************************************************************************** * * * E x c e p t i o n T y p e s * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXEXCEPTION_H #define FXEXCEPTION_H namespace FX { /** * Generic catch-all exception. * An optional message may be passed in the constructor, which must be a string * literal constant. */ class FXAPI FXException { private: const FXchar *message; private: static const FXchar exceptionName[]; public: FXException():message(FXException::exceptionName){} FXException(const FXchar *msg):message(msg){} const FXchar *what() const { return message; } ~FXException(){} }; /** * Fatal error exception. */ class FXAPI FXFatalException : public FXException { private: static const FXchar exceptionName[]; public: FXFatalException():FXException(FXFatalException::exceptionName){} FXFatalException(const FXchar *msg):FXException(msg){} }; /** * Generic error exception. */ class FXAPI FXErrorException : public FXException { private: static const FXchar exceptionName[]; public: FXErrorException():FXException(FXErrorException::exceptionName){} FXErrorException(const FXchar *msg):FXException(msg){} }; /** * Index out of range. */ class FXAPI FXRangeException : public FXErrorException { private: static const FXchar exceptionName[]; public: FXRangeException():FXErrorException(FXRangeException::exceptionName){} FXRangeException(const FXchar *msg):FXErrorException(msg){} }; /** * Invalid pointer. */ class FXAPI FXPointerException : public FXErrorException { private: static const FXchar exceptionName[]; public: FXPointerException():FXErrorException(FXPointerException::exceptionName){} FXPointerException(const FXchar *msg):FXErrorException(msg){} }; /** * Generic resource exception. */ class FXAPI FXResourceException : public FXException { private: static const FXchar exceptionName[]; public: FXResourceException():FXException(FXResourceException::exceptionName){} FXResourceException(const FXchar *msg):FXException(msg){} }; /** * Out of memory. */ class FXAPI FXMemoryException : public FXResourceException { private: static const FXchar exceptionName[]; public: FXMemoryException():FXResourceException(FXMemoryException::exceptionName){} FXMemoryException(const FXchar *msg):FXResourceException(msg){} }; /** * Window exception. */ class FXAPI FXWindowException : public FXResourceException { private: static const FXchar exceptionName[]; public: FXWindowException():FXResourceException(FXWindowException::exceptionName){} FXWindowException(const FXchar *msg):FXResourceException(msg){} }; /** * Image, cursor, bitmap exception. */ class FXAPI FXImageException : public FXResourceException { private: static const FXchar exceptionName[]; public: FXImageException():FXResourceException(FXImageException::exceptionName){} FXImageException(const FXchar *msg):FXResourceException(msg){} }; /** * Font exception. */ class FXAPI FXFontException : public FXResourceException { private: static const FXchar exceptionName[]; public: FXFontException():FXResourceException(FXFontException::exceptionName){} FXFontException(const FXchar *msg):FXResourceException(msg){} }; /** * Throw this exception to terminate the calling thread gracefully, and * pass the given return code back to a possible join() operation if one * is in effect. */ class FXAPI FXThreadException : public FXException { private: FXint exitcode; private: static const FXchar exceptionName[]; public: FXThreadException(FXint xc=-1):FXException(FXThreadException::exceptionName),exitcode(xc){} FXThreadException(const FXchar *msg,FXint xc=-1):FXException(msg),exitcode(xc){} FXint code() const { return exitcode; } }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXExpression.h000066400000000000000000000135651455751074500232410ustar00rootroot00000000000000/******************************************************************************** * * * E x p r e s s i o n E v a l u a t o r * * * ********************************************************************************* * Copyright (C) 1998,2023 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXEXPRESSION_H #define FXEXPRESSION_H namespace FX { /** * Expression compiles a simple numerical expression into efficient byte-code * for repeated evaluation. * When an expression is compiled, an optional comma-separated list of variable * names may be passed; during evaluation, values may be provided for these variable * by passing an array of values. * For instance, when compiling an expression: * * b**2-4*a*c * * with the list of variables: * * a,b,c * * then a subsequent evaluation can pass an array of three numbers: * * [1 4 2] * * which will then evaluate the expression: * * 4**2-4*1*2 * * which should yield: * * 8 * * The expression syntax can be build from the following operators, * in order of increasing precedence: * * ? : alternate expression * <, <=, >, >=, ==, != comparisons * <<, >> bit-shifts * &, |, ^ bit-wise operations * +, - addition and subtraction * *, /, % multiply, divide, modulo * ** power * -, ~ unary minus, bitwise not * ( ) parenthesized subexpressions * * The following functions are available: * * abs, acos, acosh, asin, asinh, atan, atanh, * cbrt, ceil, cos, cosh, cub, erf, erfc, exp, exp2, * exp10, floor, inverf, inverfc, isfin, isinf, isnan, * log, log2, log10, near, round, sin, sinh, sqr, sqrt, * tan, tanh, trunc, wrap, wrap4, max, min, atan2 * * The expression engine also contains the following constants: * * PI, E, DTOR, RTOD * * Variables should not use any of these reserved names. * * Initially, FXExpression will be set to a dummy program which * will return 0 when evaluated. */ class FXAPI FXExpression { private: FXuchar *code; private: static const FXuchar initial[]; static const FXchar *const errors[]; public: /// Expression error codes enum Error { ErrOK, /// No errors ErrEmpty, /// Empty input ErrMore, /// More characters after input ErrMemory, /// Out of memory ErrParent, /// Unmatched parentheses ErrToken, /// Illegal token ErrComma, /// Expected comma ErrIdent, /// Unknown identifier ErrColon, /// Expected colon ErrLong /// Expression too long }; public: /// Construct empty expression object FXExpression(); /// Copy expression object FXExpression(const FXExpression& orig); /// Compile expression; if error is not NULL, error code is returned FXExpression(const FXchar* expression,const FXchar* variables=nullptr,Error* error=nullptr); /// Compile expression; if error is not NULL, error code is returned FXExpression(const FXString& expression,const FXString& variables=FXString::null,Error* error=nullptr); /// Assign another expression to this one FXExpression& operator=(const FXExpression& orig); /// See if expression is empty FXbool empty() const { return (code==initial); } /** * Evaluate expression with given arguments, if any. * The array of arguments should match the number of variables * passed when compiling the expression. */ FXdouble evaluate(const FXdouble *args=nullptr) const; /** * Parse expression, return error code if syntax error is found. * If a comma-separated list of variables is passed, then an array of * equal number of doubles must be passed when calling evaluate. * The values of the array will be read in place of the variable names * in the expression. */ Error parse(const FXchar* expression,const FXchar* variables=nullptr); Error parse(const FXString& expression,const FXString& variables=FXString::null); /// Returns error code for given error static const FXchar* getError(Error err){ return errors[err]; } /// Saving and loading friend FXAPI FXStream& operator<<(FXStream& store,const FXExpression& s); friend FXAPI FXStream& operator>>(FXStream& store,FXExpression& s); /// Clear the expression void clear(); /// Delete ~FXExpression(); }; // Serialization extern FXAPI FXStream& operator<<(FXStream& store,const FXExpression& s); extern FXAPI FXStream& operator>>(FXStream& store,FXExpression& s); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXExtentd.h000066400000000000000000000125141455751074500225060ustar00rootroot00000000000000/******************************************************************************** * * * D o u b l e - P r e c i s i o n E x t e n t C l a s s * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXEXTENTD_H #define FXEXTENTD_H namespace FX { /// Extent class FXAPI FXExtentd { public: FXVec2d lower; FXVec2d upper; public: /// Default constructor; value is not initialized FXExtentd(){} /// Copy constructor FXExtentd(const FXExtentd& ext):lower(ext.lower),upper(ext.upper){} /// Initialize with a single point FXExtentd(const FXVec2d& p):lower(p),upper(p){} /// Initialize from corner points FXExtentd(const FXVec2d& lo,const FXVec2d& hi):lower(lo),upper(hi){} /// Initialize with a single point FXExtentd(FXdouble x,FXdouble y):lower(x,y),upper(x,y){} /// Initialize with explicit values FXExtentd(FXdouble xl,FXdouble xh,FXdouble yl,FXdouble yh):lower(xl,yl),upper(xh,yh){} /// Assignment FXExtentd& operator=(const FXExtentd& ext){ lower=ext.lower; upper=ext.upper; return *this; } /// Set value from another range FXExtentd& set(const FXExtentd& ext){ lower=ext.lower; upper=ext.upper; return *this; } /// Set value from single point FXExtentd& set(const FXVec2d& p){ lower=upper=p; return *this; } /// Set value from corner points FXExtentd& set(const FXVec2d& lo,const FXVec2d& hi){ lower=lo; upper=hi; return *this; } /// Set value from single point FXExtentd& set(FXdouble x,FXdouble y){ lower.x=upper.x=x; lower.y=upper.y=y; return *this; } /// Set value from explicit values FXExtentd& set(FXdouble xl,FXdouble xh,FXdouble yl,FXdouble yh){ lower.set(xl,yl); upper.set(xh,yh); return *this; } /// Indexing with 0..1 FXVec2d& operator[](FXint i){ return (&lower)[i]; } /// Indexing with 0..1 const FXVec2d& operator[](FXint i) const { return (&lower)[i]; } /// Comparison FXbool operator==(const FXExtentd& ext) const { return lower==ext.lower && upper==ext.upper;} FXbool operator!=(const FXExtentd& ext) const { return lower!=ext.lower || upper!=ext.upper;} /// Width of box FXdouble width() const { return upper.x-lower.x; } /// Height of box FXdouble height() const { return upper.y-lower.y; } /// Area FXdouble area() const { return width()*height(); } /// Longest side FXdouble longest() const; /// Shortest side FXdouble shortest() const; /// Length of diagonal FXdouble diameter() const; /// Get radius of box FXdouble radius() const; /// Compute diagonal FXVec2d diagonal() const; /// Get center of box FXVec2d center() const; /// Test if empty FXbool empty() const; /// Test if box contains point x,y FXbool contains(FXdouble x,FXdouble y) const; /// Test if box contains point p FXbool contains(const FXVec2d& p) const; /// Test if box properly contains another box FXbool contains(const FXExtentd& ext) const; /// Include point FXExtentd& include(FXdouble x,FXdouble y); /// Include point FXExtentd& include(const FXVec2d& v); /// Include given range into extent FXExtentd& include(const FXExtentd& ext); /// Intersect box with ray u-v FXbool intersect(const FXVec2d& u,const FXVec2d& v) const; /// Intersect box with ray pos+lambda*dir, returning true if hit FXbool intersect(const FXVec2d& pos,const FXVec2d& dir,FXdouble hit[]) const; /// Get corner number 0..3 FXVec2d corner(FXint c) const { return FXVec2d((&lower)[c&1].x, (&lower)[(c>>1)&1].y); } /// Destructor ~FXExtentd(){} }; /// Test if bounds overlap extern FXAPI FXbool overlap(const FXExtentd& a,const FXExtentd& b); /// Union of two boxes extern FXAPI FXExtentd unite(const FXExtentd& a,const FXExtentd& b); /// Intersection of two boxes extern FXAPI FXExtentd intersect(const FXExtentd& a,const FXExtentd& b); /// Save object to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXExtentd& ext); /// Load object from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXExtentd& ext); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXExtentf.h000066400000000000000000000124641455751074500225140ustar00rootroot00000000000000/******************************************************************************** * * * S i n g l e - P r e c i s i o n E x t e n t C l a s s * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXEXTENTF_H #define FXEXTENTF_H namespace FX { /// Extent class FXAPI FXExtentf { public: FXVec2f lower; FXVec2f upper; public: /// Default constructor; value is not initialized FXExtentf(){} /// Copy constructor FXExtentf(const FXExtentf& ext):lower(ext.lower),upper(ext.upper){} /// Initialize with a single point FXExtentf(const FXVec2f& p):lower(p),upper(p){} /// Initialize from corner points FXExtentf(const FXVec2f& lo,const FXVec2f& hi):lower(lo),upper(hi){} /// Initialize with a single point FXExtentf(FXfloat x,FXfloat y):lower(x,y),upper(x,y){} /// Initialize with explicit values FXExtentf(FXfloat xl,FXfloat xh,FXfloat yl,FXfloat yh):lower(xl,yl),upper(xh,yh){} /// Assignment FXExtentf& operator=(const FXExtentf& ext){ lower=ext.lower; upper=ext.upper; return *this; } /// Set value from another range FXExtentf& set(const FXExtentf& ext){ lower=ext.lower; upper=ext.upper; return *this; } /// Set value from single point FXExtentf& set(const FXVec2f& p){ lower=upper=p; return *this; } /// Set value from corner points FXExtentf& set(const FXVec2f& lo,const FXVec2f& hi){ lower=lo; upper=hi; return *this; } /// Set value from single point FXExtentf& set(FXfloat x,FXfloat y){ lower.x=upper.x=x; lower.y=upper.y=y; return *this; } /// Set value from explicit values FXExtentf& set(FXfloat xl,FXfloat xh,FXfloat yl,FXfloat yh){ lower.set(xl,yl); upper.set(xh,yh); return *this; } /// Indexing with 0..1 FXVec2f& operator[](FXint i){ return (&lower)[i]; } /// Indexing with 0..1 const FXVec2f& operator[](FXint i) const { return (&lower)[i]; } /// Comparison FXbool operator==(const FXExtentf& ext) const { return lower==ext.lower && upper==ext.upper;} FXbool operator!=(const FXExtentf& ext) const { return lower!=ext.lower || upper!=ext.upper;} /// Width of box FXfloat width() const { return upper.x-lower.x; } /// Height of box FXfloat height() const { return upper.y-lower.y; } /// Area FXfloat area() const { return width()*height(); } /// Longest side FXfloat longest() const; /// Shortest side FXfloat shortest() const; /// Length of diagonal FXfloat diameter() const; /// Get radius of box FXfloat radius() const; /// Compute diagonal FXVec2f diagonal() const; /// Get center of box FXVec2f center() const; /// Test if empty FXbool empty() const; /// Test if box contains point x,y FXbool contains(FXfloat x,FXfloat y) const; /// Test if box contains point p FXbool contains(const FXVec2f& p) const; /// Test if box properly contains another box FXbool contains(const FXExtentf& ext) const; /// Include point FXExtentf& include(FXfloat x,FXfloat y); /// Include point FXExtentf& include(const FXVec2f& v); /// Include given range into extent FXExtentf& include(const FXExtentf& ext); /// Intersect box with ray u-v FXbool intersect(const FXVec2f& u,const FXVec2f& v) const; /// Intersect box with ray pos+lambda*dir, returning true if hit FXbool intersect(const FXVec2f& pos,const FXVec2f& dir,FXfloat hit[]) const; /// Get corner number 0..3 FXVec2f corner(FXint c) const { return FXVec2f((&lower)[c&1].x, (&lower)[(c>>1)&1].y); } /// Destructor ~FXExtentf(){} }; /// Test if bounds overlap extern FXAPI FXbool overlap(const FXExtentf& a,const FXExtentf& b); /// Union of two boxes extern FXAPI FXExtentf unite(const FXExtentf& a,const FXExtentf& b); /// Intersection of two boxes extern FXAPI FXExtentf intersect(const FXExtentf& a,const FXExtentf& b); /// Save object to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXExtentf& ext); /// Load object from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXExtentf& ext); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXFile.h000066400000000000000000000105151455751074500217510ustar00rootroot00000000000000/******************************************************************************** * * * F i l e C l a s s * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXFILE_H #define FXFILE_H #ifndef FXIODEVICE_H #include "FXIODevice.h" #endif namespace FX { /** * Low level file access. */ class FXAPI FXFile : public FXIODevice { private: FXFile(const FXFile&); FXFile &operator=(const FXFile&); public: /// Construct file FXFile(){ } /// Construct file and attach existing handle h FXFile(FXInputHandle h); /// Construct and open a file FXFile(const FXString& filename,FXuint m=FXIO::Reading,FXuint perm=FXIO::AllReadWrite); /// Open file virtual FXbool open(const FXString& filename,FXuint m=FXIO::Reading,FXuint perm=FXIO::AllReadWrite); /// Return true if serial access only virtual FXbool isSerial() const; /// Get current file position virtual FXlong position() const; /// Change file position, returning new position from start virtual FXlong position(FXlong offset,FXuint from=FXIO::Begin); /// Truncate file to size s virtual FXlong truncate(FXlong sz); /// Flush to disk virtual FXbool flush(); /// Test if we're at the end; -1 if error virtual FXint eof(); /// Return file size virtual FXlong size(); /// Create new (empty) file static FXbool create(const FXString& file,FXuint perm=FXIO::AllReadWrite); /// Link file static FXbool link(const FXString& srcfile,const FXString& dstfile); /// Read symbolic link static FXString symlink(const FXString& file); /// Symbolic link file static FXbool symlink(const FXString& srcfile,const FXString& dstfile); /// Return true if files are identical (identical node on disk) static FXbool identical(const FXString& file1,const FXString& file2); /// Copy srcfile to dstfile, overwriting dstfile if allowed static FXbool copy(const FXString& srcfile,const FXString& dstfile,FXbool overwrite=false); /// Recursively copy files or directories from srcfile to dstfile, overwriting dstfile if allowed static FXbool copyFiles(const FXString& srcfile,const FXString& dstfile,FXbool overwrite=false); /// Move or rename srcfile to dstfile, overwriting dstfile if allowed static FXbool move(const FXString& srcfile,const FXString& dstfile,FXbool overwrite=false); /// Recursively copy or move files or directories from srcfile to dstfile, overwriting dstfile if allowed static FXbool moveFiles(const FXString& srcfile,const FXString& dstfile,FXbool overwrite=false); /// Remove file static FXbool remove(const FXString& file); /// Recursively remove file or directory, recurse if allowed static FXbool removeFiles(const FXString& path,FXbool recursive=false); /// Concatenate srcfile1 and srcfile2 to dstfile, overwriting dstfile if allowed static FXbool concat(const FXString& srcfile1,const FXString& srcfile2,const FXString& dstfile,FXbool overwrite=false); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXFileAssociations.h000066400000000000000000000225671455751074500243430ustar00rootroot00000000000000/******************************************************************************** * * * F i l e A s s o c i a t i o n s * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXFILEASSOCIATIONS_H #define FXFILEASSOCIATIONS_H #ifndef FXOBJECT_H #include "FXObject.h" #endif namespace FX { class FXIcon; class FXIconSource; /// Registers stuff to know about the extension struct FXFileAssoc { FXString command; /// Command to execute FXString extension; /// Full extension name FXString mimetype; /// Mime type name FXIcon *bigicon; /// Big normal icon FXIcon *bigiconopen; /// Big open icon FXIcon *miniicon; /// Mini normal icon FXIcon *miniiconopen; /// Mini open icon FXDragType dragtype; /// Registered drag type FXuint flags; /// Flags; 1=cd, 2=term }; // Dictionary of file associations typedef FXDictionaryOf FXFileAssocDictionary; /** * The FileAssociations object manages file associations between a file extension * and a FileAssoc record which contains command name, mime-type, icons, and other * information about a type of file. * Icons referenced by the FileAssoc record are managed by an icon cache, which * guarantees that each icon is loaded into memory only once, when it is encountered * for the first time. * Associations for a file or directory are determined by the information in the * FOX Registry setting under the "FILETYPES" section. * Each entry maps a (partial) pathname to an association record comprising command * name, description, large and small icons, mime-types, and flags: * * command ';' description ';' bigicon [ ':' bigiconopen ] ';' icon [ ':' iconopen ] ';' mime [ ';' flags ] * * For example, the binding for "bmp" would be: * * [FILETYPES] * bmp="eog %s &;Bitmap Image;bigimage.bmp;miniimage.bmp;image/x-ms-bmp;" * * And bindings for directories would be like: * * [FILETYPES] * /=";Root Folder;bigroot.bmp:bigroot_open.bmp;miniroot.bmp:miniroot_open.bmp;application/x-folder;" * /home/jane=";Home Folder;mansion.bmp:mansion_open.bmp;hut.bmp:hut_open.bmp;application/x-folder;" * * Three types of pathnames are distinguished: regular files, directories, and * executable files. * The association for a regular file name is determined by first looking at the entire * file name, then at the whole extension, and then at sub-extensions. * For example, "package.tar.gz", "tar.gz", and "gz" can each be given a different * file associations. * If no extension is found, then a special fallback extension "defaultfilebinding" * is consulted. Thus, you can assign fallback properties for all reguler files * by setting the "defaultfilebinding" entry under the "FILETYPES" section. * The association for a directory name is found by first checking the full pathname, * then dropping leading directory components in turn. * For example: "/usr/local/include", "/local/include", and "/include" are checked in * turn. This scheme allows convenient assignment of an association for projects with * common directory-structures but different project roots. * If a directory association is not found, a fallback association "defaultdirbinding" * is used to determine the association. * The association for an executable file is found by looking up the binding for the * "defaultexecbinding" under the "FILETYPES" section. * The flags field is used for a number of bit-flags; two flags are currently * defined: 'cd' and 'term'. The first one is intended to cause a launcher * to execute the application in the shown directory; the second one is meant * to indicate that the application is to be ran inside a new terminal. */ class FXAPI FXFileAssociations : public FXObject { FXDECLARE(FXFileAssociations) protected: FXFileAssocDictionary bindings; // File bindings dictionary FXIconCache cache; // Cache icons for rapid access FXSettings *settings; // Settings database for looking up extensions protected: FXFileAssociations(); private: FXFileAssociations(const FXFileAssociations&); FXFileAssociations &operator=(const FXFileAssociations&); public: /// Registry key used to find fallback executable icons static const FXchar defaultExecBinding[]; /// Registry key used to find fallback directory icons static const FXchar defaultDirBinding[]; /// Registry key used to find fallback document icons static const FXchar defaultFileBinding[]; public: /** * Construct a dictionary mapping file-extension to file associations, * using the application registry settings as a source for the bindings. * The pointer to the application class is passed down to the icon source * which is inside the icon dictionary. */ FXFileAssociations(FXApp* app); /** * Construct a dictionary mapping file-extension to file associations, * using the specified settings database as a source for the bindings. * The pointer to the application class is passed down to the icon source * which is inside the icon dictionary. */ FXFileAssociations(FXApp* app,FXSettings* sdb); /** * Change settings database being used to determine extension mappings. */ void setSettings(FXSettings* sdb){ settings=sdb; } /** * Return settings database. */ FXSettings* getSettings() const { return settings; } /** * Change the IconSource object used by the icon cache to load icons. */ void setIconSource(FXIconSource* src){ cache.setIconSource(src); } /** * Return the current IconSource object. */ FXIconSource* getIconSource() const { return cache.getIconSource(); } /** * Set the icon search paths for the icon cache. */ void setIconPath(const FXString& path){ cache.setIconPath(path); } /** * Return the current icon search paths from the icon cache. */ const FXString& getIconPath() const { return cache.getIconPath(); } /** * Parse string containing description of the association. */ virtual FXFileAssoc* parse(const FXString& assoc); /** * Return mapping of input string to file-association; if no mapping * exists, try to add a new association mapping by consulting the * FILETYPES section of the settings database. * You can overload this function if you need to supply custom * mappings for selected extensions. */ virtual FXFileAssoc* fetch(const FXString& ext); /** * Determine binding for the given file. * The default implementation tries the whole filename first, * then tries the extensions. * For example, for a file "source.tar.gz": * * "source.tar.gz", * "tar.gz", * "gz" * * are tried in succession. If no association is found the * key "defaultfilebinding" is tried as a fallback association. * A NULL is returned if no association of any kind is found. */ virtual FXFileAssoc* findFileBinding(const FXString& pathname); /** * Find directory binding from registry. * The default implementation tries the whole pathname first, * then tries successively smaller parts of the path. * For example, a pathname "/usr/people/jeroen": * * "/usr/people/jeroen" * "/people/jeroen" * "/jeroen" * * are tried in succession. If no bindings are found, the * key "defaultdirbinding" is tried as a fallback association. * A NULL is returned if no association of any kind is found. */ virtual FXFileAssoc* findDirBinding(const FXString& pathname); /** * Determine binding for the given executable. * The default implementation returns the fallback binding associated with * the key "defaultexecbinding". * A NULL is returned if no association of any kind is found. */ virtual FXFileAssoc* findExecBinding(const FXString& pathname); /** * Delete all file-associations, and clear all icons from the cache. */ void clear(); /** * Save object to stream. */ virtual void save(FXStream& store) const; /** * Load object from stream. */ virtual void load(FXStream& store); /** * Delete all FileAssoc's, and the IconCache. */ virtual ~FXFileAssociations(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXFileDialog.h000066400000000000000000000202131455751074500230650ustar00rootroot00000000000000/******************************************************************************** * * * F i l e S e l e c t i o n D i a l o g * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXFILEDIALOG_H #define FXFILEDIALOG_H #ifndef FXDIALOGBOX_H #include "FXDialogBox.h" #endif namespace FX { class FXFileSelector; class FXIconSource; class FXFileAssociations; /// File selection dialog class FXAPI FXFileDialog : public FXDialogBox { FXDECLARE(FXFileDialog) protected: FXFileSelector *filebox; protected: static const FXchar sectionName[]; protected: FXFileDialog(){} void readRegistry(); void writeRegistry(); private: FXFileDialog(const FXFileDialog&); FXFileDialog &operator=(const FXFileDialog&); public: /// Construct file dialog box FXFileDialog(FXWindow* owner,const FXString& name,FXuint opts=0,FXint x=0,FXint y=0,FXint w=500,FXint h=300); /// Construct free-floating file dialog box FXFileDialog(FXApp* a,const FXString& name,FXuint opts=0,FXint x=0,FXint y=0,FXint w=500,FXint h=300); /// Create server-side resources virtual void create(); /// Destroy server-side resources virtual void destroy(); /// Change file name void setFilename(const FXString& path); /// Return file name, if any FXString getFilename() const; /// Return empty-string terminated list of selected file names, or NULL if none selected FXString* getFilenames() const; /// Change directory void setDirectory(const FXString& path); /// Return directory FXString getDirectory() const; /// Change file selection mode; the default is SELECTFILE_ANY void setSelectMode(FXuint mode); /// Return file selection mode FXuint getSelectMode() const; /// Change file pattern void setPattern(const FXString& ptrn); /// Return file pattern FXString getPattern() const; /// Change wildcard matching mode (see FXPath) void setMatchMode(FXuint mode); /// Return wildcard matching mode FXuint getMatchMode() const; /** * Change the list of file patterns shown in the file dialog. * Each pattern comprises an optional name, followed by a pattern in * parentheses. The patterns are separated by newlines. * For example, * * "*\n*.cpp,*.cc\n*.hpp,*.hh,*.h" * * and * * "All Files (*)\nC++ Sources (*.cpp,*.cc)\nC++ Headers (*.hpp,*.hh,*.h)" * * will set the same three patterns, but the former shows no pattern names. */ void setPatternList(const FXString& patterns); /// Return list of patterns FXString getPatternList() const; /** * After setting the list of patterns, this call will * initially select pattern patno as the active one. */ void setCurrentPattern(FXint patno); /// Return current pattern number FXint getCurrentPattern() const; /// Change pattern text for pattern number void setPatternText(FXint patno,const FXString& text); /// Get pattern text for given pattern number FXString getPatternText(FXint patno) const; /// Return number of patterns FXint getNumPatterns() const; /// Allow pattern entry void allowPatternEntry(FXbool flag); /// Return true if pattern entry is allowed FXbool allowPatternEntry() const; /// Set the inter-item spacing (in pixels) void setItemSpace(FXint s); /// Return the inter-item spacing (in pixels) FXint getItemSpace() const; /// Return true if showing hidden files FXbool showHiddenFiles() const; /// Show or hide hidden files void showHiddenFiles(FXbool flag); /// Return true if image preview on FXbool showImages() const; /// Show or hide preview images void showImages(FXbool flag); /// Return images preview size FXint getImageSize() const; /// Change images preview size void setImageSize(FXint size); /// Show readonly button void showReadOnly(FXbool flag); /// Return true if readonly is shown FXbool shownReadOnly() const; /// Set initial state of readonly button void setReadOnly(FXbool flag); /// Get readonly state FXbool getReadOnly() const; /// Change File List style void setFileBoxStyle(FXuint style); /// Return File List style FXuint getFileBoxStyle() const; /// Allow or disallow navigation void allowNavigation(FXbool flag); /// Is navigation allowed? FXbool allowNavigation() const; /// Set draggable files void setDraggableFiles(FXbool flag); /// Are files draggable? FXbool getDraggableFiles() const; /// Set file time format void setTimeFormat(const FXString& fmt); /// Return file time format FXString getTimeFormat() const; /// Change file associations; delete old ones if owned void setAssociations(FXFileAssociations* assoc,FXbool owned=false); /// Return file associations FXFileAssociations* getAssociations() const; /// Change icon loader void setIconSource(FXIconSource* src); /// Return icon loader FXIconSource* getIconSource() const; /** * Open existing filename. * The new dialog will have the given caption and select the indicated path. * Files will be filtered by the pattern or patterns. If there is more than one pattern, * the initial pattern will be selected in the drop-down box of the file dialog. */ static FXString getOpenFilename(FXWindow* owner,const FXString& caption,const FXString& path,const FXString& patterns="*",FXint initial=0); /** * Open multiple existing files. * The new dialog will have the given caption and select the indicated path. * Files will be filtered by the pattern or patterns. If there is more than one pattern, * the initial pattern will be selected in the drop-down box of the file dialog. * The return value of this function is an array of strings; the last item in the * array is an empty string. */ static FXString* getOpenFilenames(FXWindow* owner,const FXString& caption,const FXString& path,const FXString& patterns="*",FXint initial=0); /** * Save to filename. * The new dialog will have the given caption and select the indicated path. * Files will be filtered by the pattern or patterns. If there is more than one pattern, * the initial pattern will be selected in the drop-down box of the file dialog. */ static FXString getSaveFilename(FXWindow* owner,const FXString& caption,const FXString& path,const FXString& patterns="*",FXint initial=0); /** * Open directory name. * The new dialog will have the given caption and select the indicated path. * Files will be filtered by the pattern or patterns. If there is more than one pattern, * the initial pattern will be selected in the drop-down box of the file dialog. */ static FXString getOpenDirectory(FXWindow* owner,const FXString& caption,const FXString& path); /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destructor virtual ~FXFileDialog(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXFileList.h000066400000000000000000000406641455751074500226150ustar00rootroot00000000000000/******************************************************************************** * * * F i l e L i s t W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXFILELIST_H #define FXFILELIST_H #ifndef FXICONLIST_H #include "FXIconList.h" #endif namespace FX { struct FXFileAssoc; class FXFileList; class FXIconSource; class FXFileAssociations; /// File List options enum { FILELIST_SHOWHIDDEN = 0x04000000, /// Show hidden files or directories FILELIST_SHOWDIRS = 0x08000000, /// Show only directories FILELIST_SHOWFILES = 0x10000000, /// Show only files FILELIST_SHOWIMAGES = 0x20000000, /// Show preview of images FILELIST_NO_OWN_ASSOC = 0x40000000, /// Do not create associations for files FILELIST_NO_PARENT = 0x80000000 /// Suppress display of '.' and '..' }; /// File item class FXAPI FXFileItem : public FXIconItem { FXDECLARE(FXFileItem) friend class FXFileList; protected: FXFileAssoc *assoc; // File association record FXFileItem *link; // Link to next item FXlong size; // File size FXTime date; // File time FXuint mode; // Mode flags private: FXFileItem(const FXFileItem&); FXFileItem& operator=(const FXFileItem&); protected: FXFileItem():assoc(nullptr),link(nullptr),size(0),date(0){} public: /// Constructor FXFileItem(const FXString& text,FXIcon* bi=nullptr,FXIcon* mi=nullptr,void* ptr=nullptr):FXIconItem(text,bi,mi,ptr),assoc(nullptr),link(nullptr),size(0L),date(0L),mode(0){} /// Return true if this is a file item FXbool isFile() const { return (mode&(FXIO::File))!=0; } /// Return true if this is a directory item FXbool isDirectory() const { return (mode&FXIO::Directory)!=0; } /// Return true if this is an executable item FXbool isExecutable() const { return (mode&FXIO::File)!=0 && (mode&FXIO::AllExec)!=0; } /// Return true if this is a symbolic link item FXbool isSymlink() const { return (mode&FXIO::SymLink)!=0; } /// Return true if this is a character device item FXbool isChardev() const { return (mode&FXIO::Character)!=0; } /// Return true if this is a block device item FXbool isBlockdev() const { return (mode&FXIO::Block)!=0; } /// Return true if this is an FIFO item FXbool isFifo() const { return (mode&FXIO::Fifo)!=0; } /// Return true if this is a socket FXbool isSocket() const { return (mode&FXIO::Socket)!=0; } /// Return true if item is a special navigational item like '.' or '..' FXbool isNavigational() const { return (label[0]=='.' && (label[1]=='\t' || (label[1]=='.' && label[2]=='\t'))); } /// Set the file-association object for this item void setAssoc(FXFileAssoc* a){ assoc=a; } /// Return the file-association object for this item FXFileAssoc* getAssoc() const { return assoc; } /// Set the file size for this item void setSize(FXlong s){ size=s; } /// Return the file size for this item FXlong getSize() const { return size; } /// Set the date for this item, in nanoseconds void setDate(FXTime d){ date=d; } /// Return the date for this item, in nanoseconds FXTime getDate() const { return date; } /// Set file mode bits void setMode(FXuint m){ mode=m; } /// Return file mode bits FXuint getMode() const { return mode; } }; /** * A File List widget provides an icon rich view of the file system. * It automatically updates itself periodically by re-scanning the file system * for any changes. As it scans the displayed directory, it automatically * determines the icons to be displayed by consulting the file associations registry * settings. A number of messages can be sent to the File List to control the * filter pattern, sort category, sorting order, case sensitivity, and hidden file * display mode. * The File list widget supports drags and drops of files. */ class FXAPI FXFileList : public FXIconList { FXDECLARE(FXFileList) protected: FXFileAssociations *associations; // Association table FXIconSource *iconloader; // Icon loader FXFileItem *list; // File item list FXIcon *big_folder; // Big folder icon FXIcon *mini_folder; // Mini folder icon FXIcon *big_doc; // Big document icon FXIcon *mini_doc; // Mini document icon FXIcon *big_app; // Big application icon FXIcon *mini_app; // Mini application icon FXString directory; // Current directory FXString pattern; // Pattern of file names FXString timeformat; // File time formatting FXString startdirectory; // Start directory FXString dropdirectory; // Drop directory FXString clipfiles; // Clipped files FXString dragfiles; // Dragged files FXString dropfiles; // Dropped files FXDragAction dropaction; // Drop action FXuint matchmode; // File wildcard match mode FXint imagesize; // Image size FXTime timestamp; // Time when last refreshed FXuint counter; // Refresh counter FXbool clipcut; // Cut or copy FXbool draggable; // Dragable files protected: FXFileList(); FXbool listItems(FXbool force,FXbool notify); FXString getSelectedFiles() const; virtual FXIconItem *createItem(const FXString& text,FXIcon *big,FXIcon* mini,void* ptr); void delete_files(const FXString& files); void copy_files(const FXString& directory,const FXString& files); void move_files(const FXString& directory,const FXString& files); static FXint compareSectionNatural(const FXchar* s1,const FXchar* s2,FXint s,FXbool ci=false); private: FXFileList(const FXFileList&); FXFileList &operator=(const FXFileList&); public: long onOpenTimer(FXObject*,FXSelector,void*); long onRefreshTimer(FXObject*,FXSelector,void*); long onPreviewChore(FXObject*,FXSelector,void*); long onDNDEnter(FXObject*,FXSelector,void*); long onDNDLeave(FXObject*,FXSelector,void*); long onDNDMotion(FXObject*,FXSelector,void*); long onDNDDrop(FXObject*,FXSelector,void*); long onDNDRequest(FXObject*,FXSelector,void*); long onBeginDrag(FXObject*,FXSelector,void*); long onEndDrag(FXObject*,FXSelector,void*); long onDragged(FXObject*,FXSelector,void*); long onClipboardLost(FXObject*,FXSelector,void*); long onClipboardRequest(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdGetStringValue(FXObject*,FXSelector,void*); long onCmdSetStringValue(FXObject*,FXSelector,void*); long onCmdDirectoryUp(FXObject*,FXSelector,void*); long onUpdDirectoryUp(FXObject*,FXSelector,void*); long onCmdSortByName(FXObject*,FXSelector,void*); long onUpdSortByName(FXObject*,FXSelector,void*); long onCmdSortByType(FXObject*,FXSelector,void*); long onUpdSortByType(FXObject*,FXSelector,void*); long onCmdSortBySize(FXObject*,FXSelector,void*); long onUpdSortBySize(FXObject*,FXSelector,void*); long onCmdSortByTime(FXObject*,FXSelector,void*); long onUpdSortByTime(FXObject*,FXSelector,void*); long onCmdSortByUser(FXObject*,FXSelector,void*); long onUpdSortByUser(FXObject*,FXSelector,void*); long onCmdSortByGroup(FXObject*,FXSelector,void*); long onUpdSortByGroup(FXObject*,FXSelector,void*); long onCmdSortReverse(FXObject*,FXSelector,void*); long onUpdSortReverse(FXObject*,FXSelector,void*); long onCmdSortCase(FXObject*,FXSelector,void*); long onUpdSortCase(FXObject*,FXSelector,void*); long onCmdSetPattern(FXObject*,FXSelector,void*); long onUpdSetPattern(FXObject*,FXSelector,void*); long onCmdSetDirectory(FXObject*,FXSelector,void*); long onUpdSetDirectory(FXObject*,FXSelector,void*); long onCmdToggleHidden(FXObject*,FXSelector,void*); long onUpdToggleHidden(FXObject*,FXSelector,void*); long onCmdShowHidden(FXObject*,FXSelector,void*); long onUpdShowHidden(FXObject*,FXSelector,void*); long onCmdHideHidden(FXObject*,FXSelector,void*); long onUpdHideHidden(FXObject*,FXSelector,void*); long onCmdToggleImages(FXObject*,FXSelector,void*); long onUpdToggleImages(FXObject*,FXSelector,void*); long onCmdHeader(FXObject*,FXSelector,void*); long onUpdHeader(FXObject*,FXSelector,void*); long onCmdRefresh(FXObject*,FXSelector,void*); long onUpdHaveSel(FXObject*,FXSelector,void*); long onCmdCutSel(FXObject*,FXSelector,void*); long onCmdCopySel(FXObject*,FXSelector,void*); long onCmdPasteSel(FXObject*,FXSelector,void*); long onCmdDeleteSel(FXObject*,FXSelector,void*); long onCmdDropAsk(FXObject*,FXSelector,void*); long onCmdDropCopy(FXObject*,FXSelector,void*); long onCmdDropMove(FXObject*,FXSelector,void*); long onCmdDropLink(FXObject*,FXSelector,void*); public: static FXint ascending(const FXIconItem* a,const FXIconItem* b); static FXint descending(const FXIconItem* a,const FXIconItem* b); static FXint ascendingCase(const FXIconItem* a,const FXIconItem* b); static FXint descendingCase(const FXIconItem* a,const FXIconItem* b); static FXint ascendingType(const FXIconItem* a,const FXIconItem* b); static FXint descendingType(const FXIconItem* a,const FXIconItem* b); static FXint ascendingSize(const FXIconItem* a,const FXIconItem* b); static FXint descendingSize(const FXIconItem* a,const FXIconItem* b); static FXint ascendingTime(const FXIconItem* a,const FXIconItem* b); static FXint descendingTime(const FXIconItem* a,const FXIconItem* b); static FXint ascendingUser(const FXIconItem* a,const FXIconItem* b); static FXint descendingUser(const FXIconItem* a,const FXIconItem* b); static FXint ascendingGroup(const FXIconItem* a,const FXIconItem* b); static FXint descendingGroup(const FXIconItem* a,const FXIconItem* b); public: enum { ID_OPENTIMER=FXIconList::ID_LAST, ID_REFRESHTIMER, ID_DROPASK, ID_DROPCOPY, ID_DROPMOVE, ID_DROPLINK, ID_PREVIEWCHORE, ID_SORT_BY_NAME, /// Sort by name ID_SORT_BY_TYPE, /// Sort by type ID_SORT_BY_SIZE, /// Sort by size ID_SORT_BY_TIME, /// Sort by access time ID_SORT_BY_USER, /// Sort by owner name ID_SORT_BY_GROUP, /// Sort by group name ID_SORT_REVERSE, /// Reverse sort order ID_SORT_CASE, /// Toggle sort case sensitivity ID_DIRECTORY_UP, /// Move up one directory ID_SET_PATTERN, /// Set match pattern ID_SET_DIRECTORY, /// Set directory ID_SHOW_HIDDEN, /// Show hidden files ID_HIDE_HIDDEN, /// Hide hidden files ID_TOGGLE_HIDDEN, /// Toggle display of hidden files ID_TOGGLE_IMAGES, /// Toggle display of images ID_REFRESH, /// Refresh immediately ID_CUT_SEL, /// Cut selected files to clipboard ID_COPY_SEL, /// Copy selected files to clipboard ID_DELETE_SEL, /// Delete selected files ID_PASTE_SEL, /// Paste selected files from clipboard ID_LAST }; public: /// Construct a file list FXFileList(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Destroy server-side resources virtual void destroy(); /// Set current file; return true if success FXbool setCurrentFile(const FXString& file,FXbool notify=false); /// Return current file FXString getCurrentFile() const; /// Set current directory; return true if success FXbool setDirectory(const FXString& path,FXbool notify=false); /// Return current directory FXString getDirectory() const { return directory; } /// Return name of item at index FXString getItemFilename(FXint index) const; /// Return full pathname of item at index FXString getItemPathname(FXint index) const; /// Return true if item is a file FXbool isItemFile(FXint index) const; /// Return true if item is a directory FXbool isItemDirectory(FXint index) const; /// Return true if item is executable FXbool isItemExecutable(FXint index) const; /// Return true if this is a symbolic link item FXbool isItemSymlink(FXint index) const; /// Return true if item is navigational item like '.' or '..' FXbool isItemNavigational(FXint index) const; /// Return file association of item FXFileAssoc* getItemAssoc(FXint index) const; /// Return the file size for this item FXlong getItemSize(FXint index) const; /// Return the date for this item, in nanoseconds FXTime getItemDate(FXint index) const; /// Return the mode bits for this item FXuint getItemMode(FXint index) const; /// Select files matching wildcard pattern FXbool selectMatching(const FXString& ptrn="*",FXuint mode=FXPath::PathName|FXPath::NoEscape,FXbool notify=false); /// Change wildcard matching pattern void setPattern(const FXString& ptrn="*",FXbool notify=false); /// Return wildcard pattern FXString getPattern() const { return pattern; } /// Change wildcard matching mode (see FXPath) void setMatchMode(FXuint mode=FXPath::PathName|FXPath::NoEscape,FXbool notify=false); /// Return wildcard matching mode FXuint getMatchMode() const { return matchmode; } /// Show or hide hidden files void showHiddenFiles(FXbool flag,FXbool notify=false); /// Return true if showing hidden files FXbool showHiddenFiles() const; /// Show directories only void showOnlyDirectories(FXbool flag,FXbool notify=false); /// Return true if showing directories only FXbool showOnlyDirectories() const; /// Show files only void showOnlyFiles(FXbool flag,FXbool notify=false); /// Return true if showing files only FXbool showOnlyFiles() const; /// Show parent directories void showParents(FXbool flag,FXbool notify=false); /// Return true if showing parent directories FXbool showParents() const; /// Show or hide preview images void showImages(FXbool flag,FXbool notify=false); /// Return true if image preview on FXbool showImages() const; /// Change images preview size void setImageSize(FXint size,FXbool notify=false); /// Return images preview size FXint getImageSize() const { return imagesize; } /// Set draggable files void setDraggableFiles(FXbool flag,FXbool notify=false); /// Are draggable files FXbool getDraggableFiles() const { return draggable; } /// Set file time format void setTimeFormat(const FXString& fmt,FXbool notify=false); /// Return file time format const FXString& getTimeFormat() const { return timeformat; } /// Change file associations; delete the old one unless it was shared void setAssociations(FXFileAssociations* assoc,FXbool owned=false,FXbool notify=false); /// Return file associations FXFileAssociations* getAssociations() const { return associations; } /// Change icon loader void setIconSource(FXIconSource* src){ iconloader=src; } /// Return icon loader FXIconSource* getIconSource() const { return iconloader; } /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destructor virtual ~FXFileList(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXFileProgressDialog.h000066400000000000000000000077101455751074500246210ustar00rootroot00000000000000/******************************************************************************** * * * F i l e P r o g r e s s D i a l o g * * * ********************************************************************************* * Copyright (C) 2016,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXFILEPROGRESSDIALOG_H #define FXFILEPROGRESSDIALOG_H #ifndef FXDIALOGBOX_H #include "FXDialogBox.h" #endif namespace FX { class FXHorizontalSeparator; class FXProgressBar; class FXLabel; class FXIcon; /** * File Progress Dialog. */ class FXAPI FXFileProgressDialog : public FXDialogBox { FXDECLARE(FXFileProgressDialog) protected: FXProgressBar *progress; // Progress bar FXLabel *activitylabel; // Label describing ongoing activity FXLabel *originlabel; // Original file name FXLabel *targetlabel; // Target file name FXLabel *byteslabel; // Bytes copied thus far FXLabel *fileslabel; // Files copied thus far FXLabel *originfile; // Origin file name FXLabel *targetfile; // Target file name FXLabel *numbytes; // Number of bytes FXLabel *numfiles; // Number of files FXbool cancelled; // Cancelled button was pressed protected: FXFileProgressDialog(); private: FXFileProgressDialog(const FXFileProgressDialog&); FXFileProgressDialog &operator=(const FXFileProgressDialog&); public: long onCmdCancel(FXObject*,FXSelector,void*); public: /// Construct input dialog box with given caption, icon, and prompt text FXFileProgressDialog(FXWindow* owner,const FXString& caption,const FXString& label,FXIcon* ico=nullptr,FXuint opts=DECOR_TITLE|DECOR_BORDER|DECOR_RESIZE,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Change the amount of progress void setProgress(FXuint value); /// Get current progress FXuint getProgress() const; /// Set total amount of progress void setTotal(FXuint value); /// Return total amount of progrss FXuint getTotal() const; /// Increment progress by given amount void increment(FXuint value); /// Change activity description void setActivityText(const FXString& text); /// Change activity icon void setActivityIcon(FXIcon* ico); /// Change origin filename void setOriginFile(const FXString& fn); /// Change target filename void setTargetFile(const FXString& fn); /// Change number of bytes void setNumBytes(FXlong num); /// Change number of files void setNumFiles(FXlong num); /// Access cancelled flag void setCancelled(FXbool flg); /// Check if operation is cancelled FXbool isCancelled() const; /// Destroy virtual ~FXFileProgressDialog(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXFileSelector.h000066400000000000000000000264061455751074500234600ustar00rootroot00000000000000/******************************************************************************** * * * F i l e S e l e c t i o n W i d g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXFILESELECTOR_H #define FXFILESELECTOR_H #ifndef FXPACKER_H #include "FXPacker.h" #endif namespace FX { class FXFileAssociations; class FXFileList; class FXTextField; class FXComboBox; class FXDirBox; class FXButton; class FXMenuButton; class FXIcon; class FXMenuPane; class FXCheckButton; class FXMatrix; class FXIconSource; class FXHorizontalFrame; /// File selection modes enum { SELECTFILE_ANY, /// A single file, existing or not (to save to) SELECTFILE_EXISTING, /// An existing file (to load) SELECTFILE_MULTIPLE, /// Multiple existing files SELECTFILE_MULTIPLE_ALL, /// Multiple existing files or directories, but not '.' and '..' SELECTFILE_DIRECTORY /// Existing directory, including '.' or '..' }; /// File selection widget class FXAPI FXFileSelector : public FXPacker { FXDECLARE(FXFileSelector) protected: FXFileList *filebox; // File list widget FXTextField *filename; // File name entry field FXComboBox *filefilter; // Combobox for pattern list FXMenuPane *bookmarkmenu; // Menu for bookmarks FXHorizontalFrame *navbuttons; // Navigation buttons FXHorizontalFrame *fileboxframe; // Frame around file list FXMatrix *entryblock; // Entry block FXCheckButton *readonly; // Open file as read only FXDirBox *dirbox; // Directory hierarchy list FXButton *accept; // Accept button FXButton *cancel; // Cancel button FXIcon *updiricon; // Up directory icon FXIcon *listicon; // List mode icon FXIcon *detailicon; // Detail mode icon FXIcon *iconsicon; // Icon mode icon FXIcon *homeicon; // Go home icon FXIcon *workicon; // Go home icon FXIcon *shownicon; // Files shown icon FXIcon *hiddenicon; // Files hidden icon FXIcon *bookmarkicon; // Book mark icon FXIcon *bookaddicon; // Book add icon FXIcon *bookdelicon; // Book delete icon FXIcon *bookclricon; // Book clear icon FXIcon *sortingicon; // Sorting icon FXIcon *newicon; // New directory icon FXIcon *renameicon; // Rename file icon FXIcon *copyicon; // Copy file icon FXIcon *moveicon; // Rename file icon FXIcon *linkicon; // Link file icon FXIcon *deleteicon; // Delete file icon FXRecentFiles bookmarks; // Bookmarked places FXuint selectmode; // Select mode FXbool navigable; // May navigate protected: FXFileSelector(){} static FXint countFilenames(const FXString& string); static FXString decodeFilename(const FXString& string,FXint n=0); static FXString encodeFilename(const FXString& string); private: FXFileSelector(const FXFileSelector&); FXFileSelector &operator=(const FXFileSelector&); public: long onCmdAccept(FXObject*,FXSelector,void*); long onCmdFilter(FXObject*,FXSelector,void*); long onCmdItemDblClicked(FXObject*,FXSelector,void*); long onCmdItemSelected(FXObject*,FXSelector,void*); long onCmdItemDeselected(FXObject*,FXSelector,void*); long onCmdDirectoryUp(FXObject*,FXSelector,void*); long onUpdDirectoryUp(FXObject*,FXSelector,void*); long onUpdDirTree(FXObject*,FXSelector,void*); long onCmdDirTree(FXObject*,FXSelector,void*); long onCmdHome(FXObject*,FXSelector,void*); long onCmdWork(FXObject*,FXSelector,void*); long onCmdBookmark(FXObject*,FXSelector,void*); long onCmdUnBookmark(FXObject*,FXSelector,void*); long onCmdVisit(FXObject*,FXSelector,void*); long onCmdNew(FXObject*,FXSelector,void*); long onUpdNew(FXObject*,FXSelector,void*); long onCmdRename(FXObject*,FXSelector,void*); long onCmdCopy(FXObject*,FXSelector,void*); long onCmdMove(FXObject*,FXSelector,void*); long onCmdLink(FXObject*,FXSelector,void*); long onCmdRemove(FXObject*,FXSelector,void*); long onUpdSelected(FXObject*,FXSelector,void*); long onPopupMenu(FXObject*,FXSelector,void*); long onCmdImageSize(FXObject*,FXSelector,void*); long onUpdImageSize(FXObject*,FXSelector,void*); long onUpdNavigable(FXObject*,FXSelector,void*); public: enum { ID_FILEFILTER=FXPacker::ID_LAST, ID_ACCEPT, ID_FILELIST, ID_DIRECTORY_UP, ID_DIRTREE, ID_MINI_SIZE, ID_NORMAL_SIZE, ID_MEDIUM_SIZE, ID_GIANT_SIZE, ID_HOME, ID_WORK, ID_BOOKMARK, ID_UNBOOKMARK, ID_BOOKMENU, ID_VISIT, ID_NEW, ID_RENAME, ID_COPY, ID_MOVE, ID_LINK, ID_REMOVE, ID_LAST }; public: /// Constructor FXFileSelector(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Create server-side resources virtual void create(); /// Return a pointer to the "Accept" button FXButton *acceptButton() const { return accept; } /// Return a pointer to the "Cancel" button FXButton *cancelButton() const { return cancel; } /// Change file name void setFilename(const FXString& path); /// Return file name, if any FXString getFilename() const; /** * Return array of strings containing the selected file names, terminated * by an empty string. This string array must be freed using delete []. * If no files were selected, a NULL is returned. */ FXString* getFilenames() const; /// Change directory void setDirectory(const FXString& path); /// Return directory FXString getDirectory() const; /// Change file selection mode; the default is SELECTFILE_ANY void setSelectMode(FXuint mode); /// Return file selection mode FXuint getSelectMode() const { return selectmode; } /// Change file pattern void setPattern(const FXString& ptrn); /// Return file pattern FXString getPattern() const; /// Change wildcard matching mode (see FXPath) void setMatchMode(FXuint mode); /// Return wildcard matching mode FXuint getMatchMode() const; /** * Change the list of file patterns shown in the file dialog. * Each pattern comprises an optional name, followed by a pattern in * parentheses. The patterns are separated by newlines. * For example, * * "*\n*.cpp,*.cc\n*.hpp,*.hh,*.h" * * and * * "All Files (*)\nC++ Sources (*.cpp,*.cc)\nC++ Headers (*.hpp,*.hh,*.h)" * * will set the same three patterns, but the former shows no pattern names. */ void setPatternList(const FXString& patterns); /// Return list of patterns FXString getPatternList() const; /** * After setting the list of patterns, this call will * initially select pattern n as the active one. */ void setCurrentPattern(FXint patno); /// Return current pattern number FXint getCurrentPattern() const; /// Change pattern text for pattern number void setPatternText(FXint patno,const FXString& text); /// Get pattern text for given pattern number FXString getPatternText(FXint patno) const; /// Return number of patterns FXint getNumPatterns() const; /// Allow pattern entry void allowPatternEntry(FXbool flag); /// Return true if pattern entry is allowed FXbool allowPatternEntry() const; /// Set the inter-item spacing (in pixels) void setItemSpace(FXint s); /// Return the inter-item spacing (in pixels) FXint getItemSpace() const; /// Change file list style void setFileBoxStyle(FXuint style); /// Return file list style FXuint getFileBoxStyle() const; /// Return true if showing hidden files FXbool showHiddenFiles() const; /// Show or hide hidden files void showHiddenFiles(FXbool flag); /// Return true if image preview on FXbool showImages() const; /// Show or hide preview images void showImages(FXbool flag); /// Return images preview size FXint getImageSize() const; /// Change images preview size void setImageSize(FXint size); /// Show readonly button void showReadOnly(FXbool flag); /// Return true if readonly is shown FXbool shownReadOnly() const; /// Set initial state of readonly button void setReadOnly(FXbool flag); /// Get readonly state FXbool getReadOnly() const; /// Allow or disallow navigation void allowNavigation(FXbool flag); /// Is navigation allowed? FXbool allowNavigation() const { return navigable; } /// Set draggable files void setDraggableFiles(FXbool flag); /// Are files draggable? FXbool getDraggableFiles() const; /// Set file time format void setTimeFormat(const FXString& fmt); /// Return file time format FXString getTimeFormat() const; /// Change file associations; delete old ones if owned void setAssociations(FXFileAssociations* assoc,FXbool owned=false); /// Return file associations FXFileAssociations* getAssociations() const; /// Change icon loader void setIconSource(FXIconSource* src); /// Return icon loader FXIconSource* getIconSource() const; /** * Given filename pattern of the form "GIF Format (*.gif)", * returns the pattern only, i.e. "*.gif" in this case. * If the parentheses are not found then returns the entire * input pattern. */ static FXString patternFromText(const FXString& pattern); /** * Given a pattern of the form "*.gif,*.GIF", return * the first extension of the pattern, i.e. "gif" in this * example. Returns empty string if it doesn't work out. */ static FXString extensionFromPattern(const FXString& pattern); /// Save object to a stream virtual void save(FXStream& store) const; /// Load object from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXFileSelector(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXFileStream.h000066400000000000000000000156631455751074500231360ustar00rootroot00000000000000/******************************************************************************** * * * F i l e S t r e a m C l a s s * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXFILESTREAM_H #define FXFILESTREAM_H #ifndef FXSTREAM_H #include "FXStream.h" #endif namespace FX { /// File Store Definition class FXAPI FXFileStream : public FXStream { protected: FXFile file; protected: virtual FXuval writeBuffer(FXuval count); virtual FXuval readBuffer(FXuval count); private: FXFileStream(const FXFileStream&); FXFileStream& operator=(const FXFileStream&); public: /// Create file stream FXFileStream(const FXObject* cont=nullptr); /// Create and open file stream FXFileStream(const FXString& filename,FXStreamDirection save_or_load=FXStreamLoad,FXuval size=8192UL); /** * Open binary data file stream; allocate a buffer of the given size * for the file I/O; the buffer must be at least 16 bytes. */ FXbool open(const FXString& filename,FXStreamDirection save_or_load=FXStreamLoad,FXuval size=8192UL); /// Close file stream virtual FXbool close(); /// Get position FXlong position() const { return FXStream::position(); } /// Move to position virtual FXbool position(FXlong offset,FXWhence whence=FXFromStart); /// Save single items to stream FXFileStream& operator<<(const FXuchar& v){ FXStream::operator<<(v); return *this; } FXFileStream& operator<<(const FXchar& v){ FXStream::operator<<(v); return *this; } FXFileStream& operator<<(const FXbool& v){ FXStream::operator<<(v); return *this; } FXFileStream& operator<<(const FXushort& v){ FXStream::operator<<(v); return *this; } FXFileStream& operator<<(const FXshort& v){ FXStream::operator<<(v); return *this; } FXFileStream& operator<<(const FXuint& v){ FXStream::operator<<(v); return *this; } FXFileStream& operator<<(const FXint& v){ FXStream::operator<<(v); return *this; } FXFileStream& operator<<(const FXfloat& v){ FXStream::operator<<(v); return *this; } FXFileStream& operator<<(const FXdouble& v){ FXStream::operator<<(v); return *this; } FXFileStream& operator<<(const FXlong& v){ FXStream::operator<<(v); return *this; } FXFileStream& operator<<(const FXulong& v){ FXStream::operator<<(v); return *this; } /// Save arrays of items to stream FXFileStream& save(const FXuchar* p,FXuval n){ FXStream::save(p,n); return *this; } FXFileStream& save(const FXchar* p,FXuval n){ FXStream::save(p,n); return *this; } FXFileStream& save(const FXbool* p,FXuval n){ FXStream::save(p,n); return *this; } FXFileStream& save(const FXushort* p,FXuval n){ FXStream::save(p,n); return *this; } FXFileStream& save(const FXshort* p,FXuval n){ FXStream::save(p,n); return *this; } FXFileStream& save(const FXuint* p,FXuval n){ FXStream::save(p,n); return *this; } FXFileStream& save(const FXint* p,FXuval n){ FXStream::save(p,n); return *this; } FXFileStream& save(const FXfloat* p,FXuval n){ FXStream::save(p,n); return *this; } FXFileStream& save(const FXdouble* p,FXuval n){ FXStream::save(p,n); return *this; } FXFileStream& save(const FXlong* p,FXuval n){ FXStream::save(p,n); return *this; } FXFileStream& save(const FXulong* p,FXuval n){ FXStream::save(p,n); return *this; } /// Load single items from stream FXFileStream& operator>>(FXuchar& v){ FXStream::operator>>(v); return *this; } FXFileStream& operator>>(FXchar& v){ FXStream::operator>>(v); return *this; } FXFileStream& operator>>(FXbool& v){ FXStream::operator>>(v); return *this; } FXFileStream& operator>>(FXushort& v){ FXStream::operator>>(v); return *this; } FXFileStream& operator>>(FXshort& v){ FXStream::operator>>(v); return *this; } FXFileStream& operator>>(FXuint& v){ FXStream::operator>>(v); return *this; } FXFileStream& operator>>(FXint& v){ FXStream::operator>>(v); return *this; } FXFileStream& operator>>(FXfloat& v){ FXStream::operator>>(v); return *this; } FXFileStream& operator>>(FXdouble& v){ FXStream::operator>>(v); return *this; } FXFileStream& operator>>(FXlong& v){ FXStream::operator>>(v); return *this; } FXFileStream& operator>>(FXulong& v){ FXStream::operator>>(v); return *this; } /// Load arrays of items from stream FXFileStream& load(FXuchar* p,FXuval n){ FXStream::load(p,n); return *this; } FXFileStream& load(FXchar* p,FXuval n){ FXStream::load(p,n); return *this; } FXFileStream& load(FXbool* p,FXuval n){ FXStream::load(p,n); return *this; } FXFileStream& load(FXushort* p,FXuval n){ FXStream::load(p,n); return *this; } FXFileStream& load(FXshort* p,FXuval n){ FXStream::load(p,n); return *this; } FXFileStream& load(FXuint* p,FXuval n){ FXStream::load(p,n); return *this; } FXFileStream& load(FXint* p,FXuval n){ FXStream::load(p,n); return *this; } FXFileStream& load(FXfloat* p,FXuval n){ FXStream::load(p,n); return *this; } FXFileStream& load(FXdouble* p,FXuval n){ FXStream::load(p,n); return *this; } FXFileStream& load(FXlong* p,FXuval n){ FXStream::load(p,n); return *this; } FXFileStream& load(FXulong* p,FXuval n){ FXStream::load(p,n); return *this; } /// Save object FXFileStream& saveObject(const FXObject* v){ FXStream::saveObject(v); return *this; } /// Load object FXFileStream& loadObject(FXObject*& v){ FXStream::loadObject(v); return *this; } /// Load object template FXFileStream& operator>>(TYPE*& obj){ return loadObject(reinterpret_cast(obj)); } /// Save object template FXFileStream& operator<<(const TYPE* obj){ return saveObject(static_cast(obj)); } /// Destructor virtual ~FXFileStream(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXFoldingList.h000066400000000000000000000576401455751074500233220ustar00rootroot00000000000000/******************************************************************************** * * * F o l d i n g L i s t W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXFOLDINGLIST_H #define FXFOLDINGLIST_H #ifndef FXSCROLLAREA_H #include "FXScrollArea.h" #endif namespace FX { class FXIcon; class FXFont; class FXHeader; class FXFoldingList; /// Folding list styles enum { FOLDINGLIST_EXTENDEDSELECT = 0, /// Extended selection mode allows for drag-selection of ranges of items FOLDINGLIST_SINGLESELECT = 0x00100000, /// Single selection mode allows up to one item to be selected FOLDINGLIST_BROWSESELECT = 0x00200000, /// Browse selection mode enforces one single item to be selected at all times FOLDINGLIST_MULTIPLESELECT = 0x00300000, /// Multiple selection mode is used for selection of individual items FOLDINGLIST_AUTOSELECT = 0x00400000, /// Automatically select under cursor FOLDINGLIST_SHOWS_LINES = 0x00800000, /// Lines shown FOLDINGLIST_SHOWS_BOXES = 0x01000000, /// Boxes to expand shown FOLDINGLIST_ROOT_BOXES = 0x02000000, /// Display root boxes also FOLDINGLIST_NORMAL = FOLDINGLIST_EXTENDEDSELECT }; /// Tree list Item class FXAPI FXFoldingItem : public FXObject { FXDECLARE(FXFoldingItem) friend class FXFoldingList; friend class FXDirList; protected: FXFoldingItem *parent; FXFoldingItem *prev; FXFoldingItem *next; FXFoldingItem *first; FXFoldingItem *last; FXString label; FXIcon *openIcon; FXIcon *closedIcon; FXptr data; FXuint state; FXint x,y; private: FXFoldingItem(const FXFoldingItem&); FXFoldingItem& operator=(const FXFoldingItem&); protected: FXFoldingItem():parent(nullptr),prev(nullptr),next(nullptr),first(nullptr),last(nullptr),openIcon(nullptr),closedIcon(nullptr),data(nullptr),state(0),x(0),y(0){} virtual void draw(const FXFoldingList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; virtual FXint hitItem(const FXFoldingList* list,FXint x,FXint y) const; public: enum{ SELECTED = 1, /// Selected FOCUS = 2, /// Focus DISABLED = 4, /// Disabled OPENED = 8, /// Opened EXPANDED = 16, /// Expanded HASITEMS = 32, /// Has virtual subitems DRAGGABLE = 64, /// Draggable OPENICONOWNED = 128, /// Open icon owned by item CLOSEDICONOWNED = 256 /// Close icon owned by item }; public: /// Constructor FXFoldingItem(const FXString& text,FXIcon* oi=nullptr,FXIcon* ci=nullptr,FXptr ptr=nullptr):parent(nullptr),prev(nullptr),next(nullptr),first(nullptr),last(nullptr),label(text),openIcon(oi),closedIcon(ci),data(ptr),state(0),x(0),y(0){} /// Get parent item FXFoldingItem* getParent() const { return parent; } /// Get next sibling item FXFoldingItem* getNext() const { return next; } /// Get previous sibling item FXFoldingItem* getPrev() const { return prev; } /// Get first child item FXFoldingItem* getFirst() const { return first; } /// Get las child item FXFoldingItem* getLast() const { return last; } /// Get item below this one in list FXFoldingItem* getBelow() const; /// Get item above this one in list FXFoldingItem* getAbove() const; /// Get number of children of item FXint getNumChildren() const; /// Change item label virtual void setText(const FXString& txt); /// Get item label const FXString& getText() const { return label; } /// Change open icon, deleting old icon if it was owned virtual void setOpenIcon(FXIcon* icn,FXbool owned=false); /// Get open icon FXIcon* getOpenIcon() const { return openIcon; } /// Change closed icon, deleting old icon if it was owned virtual void setClosedIcon(FXIcon* icn,FXbool owned=false); /// Get closed icon FXIcon* getClosedIcon() const { return closedIcon; } /// Change item user data void setData(FXptr ptr){ data=ptr; } /// Get item user data FXptr getData() const { return data; } /// Make item draw as focused virtual void setFocus(FXbool focus); /// Return true if item has focus FXbool hasFocus() const { return (state&FOCUS)!=0; } /// Select item virtual void setSelected(FXbool selected); /// Return true if this item is selected FXbool isSelected() const { return (state&SELECTED)!=0; } /// Make item show as open virtual void setOpened(FXbool opened); /// Return true if this item is open FXbool isOpened() const { return (state&OPENED)!=0; } /// Expand or collapse item virtual void setExpanded(FXbool expanded); /// Return true if this item is expanded into sub items FXbool isExpanded() const { return (state&EXPANDED)!=0; } /// Enable or disable item virtual void setEnabled(FXbool enabled); /// Return true if this item is enabled FXbool isEnabled() const { return (state&DISABLED)==0; } /// Make item draggable virtual void setDraggable(FXbool draggable); /// Return true if this item is draggable FXbool isDraggable() const { return (state&DRAGGABLE)!=0; } /// Return true if subitems, real or imagined FXbool hasItems() const { return (state&HASITEMS)!=0; } /// Change has items flag void setHasItems(FXbool flag); /// Return true if descendent of parent item FXbool isChildOf(const FXFoldingItem* item) const; /// Return true if ancestor of child item FXbool isParentOf(const FXFoldingItem* item) const; /// Return tip text virtual FXString getTipText() const; /// Return width of item as drawn in list virtual FXint getWidth(const FXFoldingList* list) const; /// Return height of item as drawn in list virtual FXint getHeight(const FXFoldingList* list) const; /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Destroy server-side resources virtual void destroy(); /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destroy item and free icons if owned virtual ~FXFoldingItem(); }; /// Folding item collate function typedef FXint (*FXFoldingListSortFunc)(const FXFoldingItem*,const FXFoldingItem*); /** * A Folding List Widget resembles a Tree list except that it supports a * header control to provide each item with multiple columns of text. * Subtrees can be collapsed or expanded by double-clicking on an item * or by clicking on the optional plus button in front of the item. * Each item may have a text and optional open-icon as well as a closed-icon. * The items may be connected by optional lines to show the hierarchical * relationship. * When an item's selected state changes, the folding list emits a SEL_SELECTED * or SEL_DESELECTED message. If an item is opened or closed, a message * of type SEL_OPENED or SEL_CLOSED is sent. When the subtree under an * item is expanded, a SEL_EXPANDED or SEL_COLLAPSED message is issued. * A change of the current item is signified by the SEL_CHANGED message. * In addition, the folding list sends SEL_COMMAND messages when the user * clicks on an item, and SEL_CLICKED, SEL_DOUBLECLICKED, and SEL_TRIPLECLICKED * when the user clicks once, twice, or thrice, respectively. * When items are added or removed, the folding list sends messages of the * type SEL_INSERTED or SEL_DELETED. * In each of these cases, a pointer to the item, if any, is passed in the * 3rd argument of the message. * The text in each item is a string separated by tabs for each column; * in mini- or big-icon mode, only the text before the first tab is shown. * In detail-mode, the text before the first tab is shown in the first column, * the text between the first and second tab is shown in the second column, * and so on. */ class FXAPI FXFoldingList : public FXScrollArea { FXDECLARE(FXFoldingList) protected: FXHeader *header; // Tree header FXFoldingItem *firstitem; // First root item FXFoldingItem *lastitem; // Last root item FXFoldingItem *anchoritem; // Selection anchor item FXFoldingItem *currentitem; // Current item FXFoldingItem *extentitem; // Selection extent FXFoldingItem *viewableitem; // Viewable item FXFont *font; // Font FXFoldingListSortFunc sortfunc; // Item sort function FXColor textColor; // Text color FXColor selbackColor; // Selected background color FXColor seltextColor; // Selected text color FXColor lineColor; // Line color FXint treeWidth; // Tree width FXint treeHeight; // Tree height FXint visible; // Number of visible items FXint indent; // Parent to child indentation FXint grabx; // Grab point x FXint graby; // Grab point y FXString lookup; // Lookup string FXString help; // Help string FXbool state; // State of item protected: FXFoldingList(); void recompute(); void mergesort(FXFoldingItem*& list); void sort(FXFoldingItem*& f1,FXFoldingItem*& t1,FXFoldingItem*& f2,FXFoldingItem*& t2,int n); virtual void moveContents(FXint x,FXint y); virtual FXFoldingItem* createItem(const FXString& text,FXIcon* oi,FXIcon* ci,FXptr ptr); static FXint compareSection(const FXchar *p,const FXchar* q,FXint s); static FXint compareSectionCase(const FXchar *p,const FXchar* q,FXint s); private: FXFoldingList(const FXFoldingList&); FXFoldingList& operator=(const FXFoldingList&); public: long onPaint(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onRightBtnPress(FXObject*,FXSelector,void*); long onRightBtnRelease(FXObject*,FXSelector,void*); long onChgHeader(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onTipTimer(FXObject*,FXSelector,void*); long onFocusIn(FXObject*,FXSelector,void*); long onFocusOut(FXObject*,FXSelector,void*); long onAutoScroll(FXObject*,FXSelector,void*); long onClicked(FXObject*,FXSelector,void*); long onDoubleClicked(FXObject*,FXSelector,void*); long onTripleClicked(FXObject*,FXSelector,void*); long onCommand(FXObject*,FXSelector,void*); long onLookupTimer(FXObject*,FXSelector,void*); public: static FXint ascending(const FXFoldingItem*,const FXFoldingItem*); static FXint descending(const FXFoldingItem*,const FXFoldingItem*); static FXint ascendingCase(const FXFoldingItem*,const FXFoldingItem*); static FXint descendingCase(const FXFoldingItem*,const FXFoldingItem*); public: enum { ID_LOOKUPTIMER=FXScrollArea::ID_LAST, ID_HEADER, ID_LAST }; public: /// Construct a folding list; the folding list is initially empty FXFoldingList(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=FOLDINGLIST_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Perform layout virtual void layout(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Return visible scroll-area y position virtual FXint getVisibleY() const; /// Return visible scroll-area height virtual FXint getVisibleHeight() const; /// Compute and return content width virtual FXint getContentWidth(); /// Return content height virtual FXint getContentHeight(); /// Recalculate layout virtual void recalc(); /// Tree list can receive focus virtual FXbool canFocus() const; /// Move the focus to this window virtual void setFocus(); /// Remove the focus from this window virtual void killFocus(); /// Return header control FXHeader* getHeader() const { return header; } /// Set headers from array of strings void setHeaders(const FXchar *const *strings,FXint size=1); /// Set headers from array of strings void setHeaders(const FXString* strings,FXint size=1); /// Set headers from newline separated strings void setHeaders(const FXString& strings,FXint size=1); /// Append header with given text and optional icon void appendHeader(const FXString& text,FXIcon *icon=nullptr,FXint size=1); /// Remove header at index void removeHeader(FXint index); /// Change text of header at index void setHeaderText(FXint index,const FXString& text); /// Return text of header at index FXString getHeaderText(FXint index) const; /// Change icon of header at index void setHeaderIcon(FXint index,FXIcon *icon); /// Return icon of header at index FXIcon* getHeaderIcon(FXint index) const; /// Change size of header at index void setHeaderSize(FXint index,FXint size); /// Return width of header at index FXint getHeaderSize(FXint index) const; /// Return number of headers FXint getNumHeaders() const; /// Return number of items FXint getNumItems() const; /// Return number of visible items FXint getNumVisible() const { return visible; } /// Change number of visible items void setNumVisible(FXint nvis); /// Return first root item FXFoldingItem* getFirstItem() const { return firstitem; } /// Return last root item FXFoldingItem* getLastItem() const { return lastitem; } /// Fill list by appending items from array of strings FXint fillItems(FXFoldingItem* father,const FXchar *const *strings,FXIcon* oi=nullptr,FXIcon* ci=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Fill list by appending items from array of strings FXint fillItems(FXFoldingItem* father,const FXString* strings,FXIcon* oi=nullptr,FXIcon* ci=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Fill list by appending items from newline separated strings FXint fillItems(FXFoldingItem* father,const FXString& strings,FXIcon* oi=nullptr,FXIcon* ci=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Replace the original item orig with new [possibly subclassed] item FXFoldingItem* setItem(FXFoldingItem* orig,FXFoldingItem* item,FXbool notify=false); /// Insert [possibly subclassed] item under father before other item FXFoldingItem* insertItem(FXFoldingItem* other,FXFoldingItem* father,FXFoldingItem* item,FXbool notify=false); /// Insert item with given text and optional icons, and user-data pointer under father before other item FXFoldingItem* insertItem(FXFoldingItem* other,FXFoldingItem* father,const FXString& text,FXIcon* oi=nullptr,FXIcon* ci=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Append [possibly subclassed] item as last child of father FXFoldingItem* appendItem(FXFoldingItem* father,FXFoldingItem* item,FXbool notify=false); /// Append item with given text and optional icons, and user-data pointer as last child of father FXFoldingItem* appendItem(FXFoldingItem* father,const FXString& text,FXIcon* oi=nullptr,FXIcon* ci=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Prepend [possibly subclassed] item as first child of father FXFoldingItem* prependItem(FXFoldingItem* father,FXFoldingItem* item,FXbool notify=false); /// Prepend item with given text and optional icons, and user-data pointer as first child of father FXFoldingItem* prependItem(FXFoldingItem* father,const FXString& text,FXIcon* oi=nullptr,FXIcon* ci=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Move item under father before other item FXFoldingItem *moveItem(FXFoldingItem* other,FXFoldingItem* father,FXFoldingItem* item); /// Extract item FXFoldingItem* extractItem(FXFoldingItem* item,FXbool notify=false); /// Remove item void removeItem(FXFoldingItem* item,FXbool notify=false); /// Remove items in range [fm, to] inclusively void removeItems(FXFoldingItem* fm,FXFoldingItem* to,FXbool notify=false); /// Remove all items from list void clearItems(FXbool notify=false); /// Return item width FXint getItemWidth(const FXFoldingItem* item) const { return item->getWidth(this); } /// Return item height FXint getItemHeight(const FXFoldingItem* item) const { return item->getHeight(this); } /// Get item at x,y, if any virtual FXFoldingItem* getItemAt(FXint x,FXint y) const; /// Return item hit code: 0 outside, 1 icon, 2 text, 3 box FXint hitItem(const FXFoldingItem* item,FXint x,FXint y) const; /// Scroll to make item visible virtual void makeItemVisible(FXFoldingItem* item); /** * Search items by name, beginning from item start. If the start item * is NULL the search will start at the first, top-most item in the list. * Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control the search * direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP * to control whether the search wraps at the start or end of the list. * The option SEARCH_IGNORECASE causes a case-insensitive match. Finally, * passing SEARCH_PREFIX causes searching for a prefix of the item name. * Return NULL if no matching item is found. */ FXFoldingItem* findItem(const FXString& string,FXFoldingItem* start=nullptr,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; /** * Search items by associated user data, beginning from item start. If the * start item is NULL the search will start at the first, top-most item * in the list. Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control * the search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP * to control whether the search wraps at the start or end of the list. */ FXFoldingItem* findItemByData(FXptr ptr,FXFoldingItem* start=nullptr,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; /// Change item's text void setItemText(FXFoldingItem* item,const FXString& text); /// Return item's text FXString getItemText(const FXFoldingItem* item) const; /// Change item's open icon, deleting old icon if it was owned void setItemOpenIcon(FXFoldingItem* item,FXIcon* icon,FXbool owned=false); /// Return item's open icon FXIcon* getItemOpenIcon(const FXFoldingItem* item) const; /// Chance item's closed icon, deleting old icon if it was owned void setItemClosedIcon(FXFoldingItem* item,FXIcon* icon,FXbool owned=false); /// Return item's closed icon FXIcon* getItemClosedIcon(const FXFoldingItem* item) const; /// Change item user-data pointer void setItemData(FXFoldingItem* item,FXptr ptr) const; /// Return item user-data pointer FXptr getItemData(const FXFoldingItem* item) const; /// Return true if item is selected FXbool isItemSelected(const FXFoldingItem* item) const; /// Return true if item is current FXbool isItemCurrent(const FXFoldingItem* item) const; /// Return true if item is visible FXbool isItemVisible(const FXFoldingItem* item) const; /// Return true if item opened FXbool isItemOpened(const FXFoldingItem* item) const; /// Return true if item expanded FXbool isItemExpanded(const FXFoldingItem* item) const; /// Return true if item is a leaf-item, i.e. has no children FXbool isItemLeaf(const FXFoldingItem* item) const; /// Return true if item is enabled FXbool isItemEnabled(const FXFoldingItem* item) const; /// Repaint item void updateItem(FXFoldingItem* item); /// Enable item virtual FXbool enableItem(FXFoldingItem* item); /// Disable item virtual FXbool disableItem(FXFoldingItem* item); /// Select item virtual FXbool selectItem(FXFoldingItem* item,FXbool notify=false); /// Deselect item virtual FXbool deselectItem(FXFoldingItem* item,FXbool notify=false); /// Toggle item selection virtual FXbool toggleItem(FXFoldingItem* item,FXbool notify=false); /// Extend selection from anchor item to item virtual FXbool extendSelection(FXFoldingItem* item,FXbool notify=false); /// Select all items virtual FXbool selectAll(FXbool notify=false); /// Deselect all items virtual FXbool killSelection(FXbool notify=false); /// Open item virtual FXbool openItem(FXFoldingItem* item,FXbool notify=false); /// Close item virtual FXbool closeItem(FXFoldingItem* item,FXbool notify=false); /// Collapse tree virtual FXbool collapseTree(FXFoldingItem* tree,FXbool notify=false); /// Expand tree virtual FXbool expandTree(FXFoldingItem* tree,FXbool notify=false); /// Change current item virtual void setCurrentItem(FXFoldingItem* item,FXbool notify=false); /// Return current item, if any FXFoldingItem* getCurrentItem() const { return currentitem; } /// Change anchor item void setAnchorItem(FXFoldingItem* item); /// Return anchor item, if any FXFoldingItem* getAnchorItem() const { return anchoritem; } /// Sort all items recursively void sortItems(); /// Sort root items void sortRootItems(); /// Sort children of item void sortChildItems(FXFoldingItem* item); /// Return sort function FXFoldingListSortFunc getSortFunc() const { return sortfunc; } /// Change sort function void setSortFunc(FXFoldingListSortFunc func){ sortfunc=func; } /// Change text font void setFont(FXFont* fnt); /// Return text font FXFont* getFont() const { return font; } /// Change parent-child indent amount void setIndent(FXint in); /// Return parent-child indent amount FXint getIndent() const { return indent; } /// Return normal text color FXColor getTextColor() const { return textColor; } /// Change normal text color void setTextColor(FXColor clr); /// Return selected text background FXColor getSelBackColor() const { return selbackColor; } /// Change selected text background void setSelBackColor(FXColor clr); /// Return selected text color FXColor getSelTextColor() const { return seltextColor; } /// Change selected text color void setSelTextColor(FXColor clr); /// Return line color FXColor getLineColor() const { return lineColor; } /// Change line color void setLineColor(FXColor clr); /// Return list style FXuint getListStyle() const; /// Change list style void setListStyle(FXuint style); /// Set the status line help text for this list void setHelpText(const FXString& text); /// Get the status line help text for this list const FXString& getHelpText() const { return help; } /// Save object to a stream virtual void save(FXStream& store) const; /// Load object from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXFoldingList(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXFont.h000066400000000000000000000407671455751074500220140ustar00rootroot00000000000000/******************************************************************************** * * * F o n t O b j e c t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXFONT_H #define FXFONT_H #ifndef FXID_H #include "FXId.h" #endif namespace FX { /// Font character set encoding enum FXFontEncoding { FONTENCODING_DEFAULT, /// Don't care character encoding FONTENCODING_ISO_8859_1 = 1, /// West European (Latin1) FONTENCODING_ISO_8859_2 = 2, /// Central and East European (Latin2) FONTENCODING_ISO_8859_3 = 3, /// Esperanto (Latin3) FONTENCODING_ISO_8859_4 = 4, FONTENCODING_ISO_8859_5 = 5, /// Cyrillic (almost obsolete) FONTENCODING_ISO_8859_6 = 6, /// Arabic FONTENCODING_ISO_8859_7 = 7, /// Greek FONTENCODING_ISO_8859_8 = 8, /// Hebrew FONTENCODING_ISO_8859_9 = 9, /// Turkish (Latin5) FONTENCODING_ISO_8859_10 = 10, /// Nordic language (Latin6) FONTENCODING_ISO_8859_11 = 11, /// Thai FONTENCODING_ISO_8859_13 = 13, /// Baltic FONTENCODING_ISO_8859_14 = 14, /// Celtic (Latin8) FONTENCODING_ISO_8859_15 = 15, /// West-European (Latin9) FONTENCODING_ISO_8859_16 = 16, /// South-Eastern European (Latin10) FONTENCODING_KOI8 = 17, /// Russian FONTENCODING_KOI8_R = 18, /// Russian FONTENCODING_KOI8_U = 19, /// Ukrainian FONTENCODING_KOI8_UNIFIED = 20, FONTENCODING_CP437 = 437, /// IBM-PC code page FONTENCODING_CP850 = 850, /// IBMPC Multilingual FONTENCODING_CP851 = 851, /// IBM-PC Greek FONTENCODING_CP852 = 852, /// IBM-PC Latin2 FONTENCODING_CP855 = 855, /// IBM-PC Cyrillic FONTENCODING_CP856 = 856, /// IBM-PC Hebrew FONTENCODING_CP857 = 857, /// IBM-PC Turkish FONTENCODING_CP860 = 860, /// IBM-PC Portugese FONTENCODING_CP861 = 861, /// IBM-PC Iceland FONTENCODING_CP862 = 862, /// IBM-PC Israel FONTENCODING_CP863 = 863, /// IBM-PC Canadian/French FONTENCODING_CP864 = 864, /// IBM-PC Arabic FONTENCODING_CP865 = 865, /// IBM-PC Nordic FONTENCODING_CP866 = 866, /// IBM-PC Cyrillic #2 FONTENCODING_CP869 = 869, /// IBM-PC Greek #2 FONTENCODING_CP870 = 870, /// Latin-2 Multilingual FONTENCODING_CP1250 = 1250, /// Windows Central European FONTENCODING_CP1251 = 1251, /// Windows Russian FONTENCODING_CP1252 = 1252, /// Windows Latin1 FONTENCODING_CP1253 = 1253, /// Windows Greek FONTENCODING_CP1254 = 1254, /// Windows Turkish FONTENCODING_CP1255 = 1255, /// Windows Hebrew FONTENCODING_CP1256 = 1256, /// Windows Arabic FONTENCODING_CP1257 = 1257, /// Windows Baltic FONTENCODING_CP1258 = 1258, /// Windows Vietnam FONTENCODING_CP874 = 874, /// Windows Thai FONTENCODING_UNICODE = 9999, FONTENCODING_LATIN1 = FONTENCODING_ISO_8859_1, /// Latin 1 (West European) FONTENCODING_LATIN2 = FONTENCODING_ISO_8859_2, /// Latin 2 (East European) FONTENCODING_LATIN3 = FONTENCODING_ISO_8859_3, /// Latin 3 (South European) FONTENCODING_LATIN4 = FONTENCODING_ISO_8859_4, /// Latin 4 (North European) FONTENCODING_LATIN5 = FONTENCODING_ISO_8859_9, /// Latin 5 (Turkish) FONTENCODING_LATIN6 = FONTENCODING_ISO_8859_10, /// Latin 6 (Nordic) FONTENCODING_LATIN7 = FONTENCODING_ISO_8859_13, /// Latin 7 (Baltic Rim) FONTENCODING_LATIN8 = FONTENCODING_ISO_8859_14, /// Latin 8 (Celtic) FONTENCODING_LATIN9 = FONTENCODING_ISO_8859_15, /// Latin 9 AKA Latin 0 FONTENCODING_LATIN10 = FONTENCODING_ISO_8859_16, /// Latin 10 FONTENCODING_USASCII = FONTENCODING_ISO_8859_1, /// Latin 1 FONTENCODING_WESTEUROPE = FONTENCODING_ISO_8859_1, /// Latin 1 (West European) FONTENCODING_EASTEUROPE = FONTENCODING_ISO_8859_2, /// Latin 2 (East European) FONTENCODING_SOUTHEUROPE = FONTENCODING_ISO_8859_3, /// Latin 3 (South European) FONTENCODING_NORTHEUROPE = FONTENCODING_ISO_8859_4, /// Latin 4 (North European) FONTENCODING_CYRILLIC = FONTENCODING_ISO_8859_5, /// Cyrillic FONTENCODING_RUSSIAN = FONTENCODING_KOI8, /// Cyrillic FONTENCODING_ARABIC = FONTENCODING_ISO_8859_6, /// Arabic FONTENCODING_GREEK = FONTENCODING_ISO_8859_7, /// Greek FONTENCODING_HEBREW = FONTENCODING_ISO_8859_8, /// Hebrew FONTENCODING_TURKISH = FONTENCODING_ISO_8859_9, /// Latin 5 (Turkish) FONTENCODING_NORDIC = FONTENCODING_ISO_8859_10, /// Latin 6 (Nordic) FONTENCODING_THAI = FONTENCODING_ISO_8859_11, /// Thai FONTENCODING_BALTIC = FONTENCODING_ISO_8859_13, /// Latin 7 (Baltic Rim) FONTENCODING_CELTIC = FONTENCODING_ISO_8859_14 /// Latin 8 (Celtic) }; /// Font description struct FXFontDesc { FXchar face[116]; /// Face name FXushort size; /// Size in deci-points (one point is 1/72 inch) FXushort weight; /// Weight [light, normal, bold, ...] FXushort slant; /// Slant [normal, italic, oblique, ...] FXushort setwidth; /// Set width [normal, condensed, expanded, ...] FXushort encoding; /// Encoding of character set FXushort flags; /// Flags /// Set font description from a string void setFont(const FXString& string); /// Get string of font description FXString getFont() const; }; class FXDC; class FXDCWindow; /// Font class class FXAPI FXFont : public FXId { friend class FXDCWindow; FXDECLARE(FXFont) protected: FXString wantedName; // Desired font font name FXString actualName; // Matched font font name FXushort wantedSize; // Font size (points*10) FXushort actualSize; // Actual size that was matched FXushort wantedWeight; // Font weight FXushort actualWeight; // Font weight FXushort wantedSlant; // Font slant FXushort actualSlant; // Font slant FXushort wantedSetwidth; // Relative setwidth FXushort actualSetwidth; // Relative setwidth FXushort wantedEncoding; // Character set encoding FXushort actualEncoding; // Character set encoding FXushort hints; // Matching hint flags FXushort flags; // Actual flags FXshort angle; // Angle void *font; // Info about the font private: #ifdef WIN32 FXID dc; #endif protected: FXFont(); void* match(const FXString& wantfamily,const FXString& wantforge,FXuint wantsize,FXuint wantweight,FXuint wantslant,FXuint wantsetwidth,FXuint wantencoding,FXuint wanthints,FXint res); private: FXFont(const FXFont&); FXFont &operator=(const FXFont&); public: /// Font pitch hints enum { Mono = 1, /// Mono spaced font Variable = 2, /// Variable pitch, proportional spacing Dual = 4, /// Dual pitch font Cell = 8, /// Character cell font Fixed = Mono|Cell /// Mono spaced or cell font }; /// Font style hints enum { Decorative = 16, /// Fancy fonts Modern = 32, /// Monospace typewriter font Roman = 64, /// Variable width times-like font, serif Script = 128, /// Script or cursive Swiss = 256, /// Helvetica/swiss type font, sans-serif System = 512, /// System font X11 = 1024, /// Raw X11 font string Scalable = 2048, /// Scalable fonts Polymorphic = 4096, /// Polymorphic fonts, e.g. parametric weight, slant, etc. Rotatable = 8192 /// Rotatable fonts }; /// Font slant options enum { ReverseOblique = 1, /// Reversed oblique ReverseItalic = 2, /// Reversed italic Straight = 5, /// Straight, not slanted Italic = 8, /// Italics Oblique = 9 /// Oblique slant }; /// Font weight options enum { Thin = 10, /// Thin ExtraLight = 20, /// Extra light Light = 30, /// Light Normal = 40, /// Normal or regular weight Medium = 50, /// Medium bold face DemiBold = 60, /// Demi bold face Bold = 70, /// Bold face ExtraBold = 80, /// Extra Black = 90 /// Black }; /// Condensed or expanded options enum { UltraCondensed = 50, /// Ultra condensed printing ExtraCondensed = 63, /// Extra condensed Condensed = 75, /// Condensed SemiCondensed = 87, /// Semi-condensed NonExpanded = 100, /// Regular printing SemiExpanded = 113, /// Semi expanded Expanded = 125, /// Expanded ExtraExpanded = 150, /// Extra expanded UltraExpanded = 200 /// Ultra expanded }; public: /** * Construct a font with given font description of the form: * * fontname [ "[" foundry "]" ] ["," size ["," weight ["," slant ["," setwidth ["," encoding ["," hints]]]]]] * * For example: * * "helvetica [bitstream],120,bold,italic,normal,iso8859-1,0" * * Typically, at least the font name, and size must be given for * normal font matching. As a special case, raw X11 fonts can also be * passed, for example: * * "9x15bold" * * Note: use of the raw X11 fonts is stronly discouraged. */ FXFont(FXApp* a,const FXString& string); /** * Construct a font with given name, size in points, weight, slant, character set * encoding, setwidth, and hints. * The font name may be comprised of a family name and optional foundry name enclosed in * square brackets, for example, "helvetica [bitstream]". */ FXFont(FXApp* a,const FXString& face,FXuint size,FXuint weight=FXFont::Normal,FXuint slant=FXFont::Straight,FXuint encoding=FONTENCODING_DEFAULT,FXuint setwidth=FXFont::NonExpanded,FXuint h=0); /// Construct font from font description FXFont(FXApp* a,const FXFontDesc& fontdesc); /// Create the font virtual void create(); /// Detach the font virtual void detach(); /// Destroy the font virtual void destroy(); /// Return family part of name FXString getFamily() const; /// Return foundry part of name FXString getFoundry() const; /// Get font family name const FXString& getName() const { return wantedName; } /// Get actual family name const FXString& getActualName() const { return actualName; } /// Get size in deci-points FXuint getSize() const { return wantedSize; } /// Get actual size in deci-points FXuint getActualSize() const { return actualSize; } /// Get font weight FXuint getWeight() const { return wantedWeight; } /// Get actual font weight FXuint getActualWeight() const { return actualWeight; } /// Get slant FXuint getSlant() const { return wantedSlant; } /// Get actual slant FXuint getActualSlant() const { return actualSlant; } /// Get character set encoding FXuint getEncoding() const { return wantedEncoding; } /// Get actual encoding FXuint getActualEncoding() const { return actualEncoding; } /// Get setwidth FXuint getSetWidth() const { return wantedSetwidth; } /// Get actual setwidth FXuint getActualSetWidth() const { return actualSetwidth; } /// Get hints FXuint getHints() const { return hints; } /// Get flags FXuint getFlags() const { return flags; } /// Change font description virtual void setFontDesc(const FXFontDesc& fontdesc); /// Get font description FXFontDesc getFontDesc() const; /// Get actual font description FXFontDesc getActualFontDesc() const; /// Return angle FXint getAngle() const { return angle; } /// Set to new angle, in degrees*64 relative to positive x axis virtual void setAngle(FXint ang); /** * Return the font description as a string suitable for * parsing with setFont(), see above. */ FXString getFont() const; /** * Change the font to the specified font description string. */ virtual void setFont(const FXString& string); /// Find out if the font is monotype or proportional virtual FXbool isFontMono() const; /// See if font has glyph for ch virtual FXbool hasChar(FXwchar ch) const; /// Get first character glyph in font virtual FXwchar getMinChar() const; /// Get last character glyph in font virtual FXwchar getMaxChar() const; /// Left bearing virtual FXint leftBearing(FXwchar ch) const; /// Right bearing virtual FXint rightBearing(FXwchar ch) const; /// Width of widest character in font virtual FXint getFontWidth() const; /// Height of highest character in font virtual FXint getFontHeight() const; /// Ascent from baseline virtual FXint getFontAscent() const; /// Descent from baseline virtual FXint getFontDescent() const; /// Get font leading [that is lead-ing as in Pb!] virtual FXint getFontLeading() const; /// Get font line spacing virtual FXint getFontSpacing() const; /// Calculate width of single wide character in this font virtual FXint getCharWidth(const FXwchar ch) const; /// Calculate width of given text in this font virtual FXint getTextWidth(const FXString& string) const; /// Calculate width of given text in this font virtual FXint getTextWidth(const FXchar* string,FXuint length) const; /// Calculate height of given text in this font virtual FXint getTextHeight(const FXString& string) const; /// Calculate height of given text in this font virtual FXint getTextHeight(const FXchar *string,FXuint length) const; /// Convert style hints to string and vice versa static FXuint styleFromString(const FXString& str); static FXString stringFromStyle(FXuint style); /// Convert slant to string and vice versa static FXuint slantFromString(const FXString& str); static FXString stringFromSlant(FXuint slant); /// Convert weight to string and vice versa static FXuint weightFromString(const FXString& str); static FXString stringFromWeight(FXuint weight); /// Convert setwidth to string and vice versa static FXuint setWidthFromString(const FXString& str); static FXString stringFromSetWidth(FXuint setwidth); /// Convert encoding to string and vice versa static FXuint encodingFromString(const FXString& str); static FXString stringFromEncoding(FXuint encoding); /** * List all fonts matching hints. If listFonts() returns true then * fonts points to a newly-allocated array of length numfonts. It * is the caller's responsibility to free this array using freeElms(). */ static FXbool listFonts(FXFontDesc*& fonts,FXuint& numfonts,const FXString& face,FXuint wt=0,FXuint sl=0,FXuint sw=0,FXuint en=0,FXuint h=0); /// Save font data into stream virtual void save(FXStream& store) const; /// Load font data from stream virtual void load(FXStream& store); /// Destroy font virtual ~FXFont(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXFontDialog.h000066400000000000000000000060561455751074500231250ustar00rootroot00000000000000/******************************************************************************** * * * F o n t S e l e c t i o n D i a l o g * * * ********************************************************************************* * Copyright (C) 1999,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXFONTDIALOG_H #define FXFONTDIALOG_H #ifndef FXDIALOGBOX_H #include "FXDialogBox.h" #endif namespace FX { class FXFontSelector; /// Font selection dialog class FXAPI FXFontDialog : public FXDialogBox { FXDECLARE(FXFontDialog) protected: FXFontSelector *fontbox; protected: static const FXchar sectionName[]; protected: FXFontDialog(){} void loadSettings(); void saveSettings(); private: FXFontDialog(const FXFontDialog&); FXFontDialog &operator=(const FXFontDialog&); public: /// Constructor font dialog box FXFontDialog(FXWindow* owner,const FXString& name,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Constructor free-floating font dialog box FXFontDialog(FXApp* a,const FXString& name,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Set font selection as a string void setFont(const FXString& string); /// Get font selection as a string FXString getFont() const; /// Set the current font selection void setFontDesc(const FXFontDesc& fontdesc); /// Get the current font selection const FXFontDesc& getFontDesc() const; /// Set sample text for font sample void setSampleText(const FXString& sampletext); /// Get sample text for font sample FXString getSampleText() const; /// Save dialog to a stream virtual void save(FXStream& store) const; /// Load dialog from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXFontDialog(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXFontSelector.h000066400000000000000000000113141455751074500234770ustar00rootroot00000000000000/******************************************************************************** * * * F o n t S e l e c t i o n B o x * * * ********************************************************************************* * Copyright (C) 1999,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXFONTSELECTOR_H #define FXFONTSELECTOR_H #ifndef FXPACKER_H #include "FXPacker.h" #endif namespace FX { class FXTextField; class FXList; class FXComboBox; class FXLabel; class FXButton; class FXCheckButton; class FXFont; /// Font selection widget class FXAPI FXFontSelector : public FXPacker { FXDECLARE(FXFontSelector) protected: FXTextField *family; FXList *familylist; FXTextField *weight; FXList *weightlist; FXTextField *style; FXList *stylelist; FXTextField *size; FXList *sizelist; FXComboBox *charset; FXComboBox *setwidth; FXComboBox *pitch; FXCheckButton *scalable; FXCheckButton *allfonts; FXButton *accept; FXButton *cancel; FXLabel *preview; FXFont *previewfont; FXFontDesc selected; protected: FXFontSelector(){} void listFontFaces(); void listWeights(); void listSlants(); void listFontSizes(); void previewFont(); private: FXFontSelector(const FXFontSelector&); FXFontSelector &operator=(const FXFontSelector&); public: long onCmdFamily(FXObject*,FXSelector,void*); long onCmdWeight(FXObject*,FXSelector,void*); long onCmdStyle(FXObject*,FXSelector,void*); long onCmdStyleText(FXObject*,FXSelector,void*); long onCmdSize(FXObject*,FXSelector,void*); long onCmdSizeText(FXObject*,FXSelector,void*); long onCmdCharset(FXObject*,FXSelector,void*); long onUpdCharset(FXObject*,FXSelector,void*); long onCmdSetWidth(FXObject*,FXSelector,void*); long onUpdSetWidth(FXObject*,FXSelector,void*); long onCmdPitch(FXObject*,FXSelector,void*); long onUpdPitch(FXObject*,FXSelector,void*); long onCmdScalable(FXObject*,FXSelector,void*); long onUpdScalable(FXObject*,FXSelector,void*); long onCmdAllFonts(FXObject*,FXSelector,void*); long onUpdAllFonts(FXObject*,FXSelector,void*); public: enum{ ID_FAMILY=FXPacker::ID_LAST, ID_WEIGHT, ID_STYLE, ID_STYLE_TEXT, ID_SIZE, ID_SIZE_TEXT, ID_CHARSET, ID_SETWIDTH, ID_PITCH, ID_SCALABLE, ID_ALLFONTS, ID_LAST }; public: /// Constructor FXFontSelector(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Create server-side resources virtual void create(); /// Return a pointer to the "Accept" button FXButton *acceptButton() const { return accept; } /// Return a pointer to the "Cancel" button FXButton *cancelButton() const { return cancel; } /// Set font selection as a string void setFont(const FXString& string); /// Get font selection as a string FXString getFont() const; /// Set font selection void setFontDesc(const FXFontDesc& fontdesc); /// Get font selection const FXFontDesc& getFontDesc() const; /// Set sample text for font sample void setSampleText(const FXString& sampletext); /// Get sample text for font sample FXString getSampleText() const { return preview->getText(); } /// Save to a stream virtual void save(FXStream& store) const; /// Load from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXFontSelector(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXFrame.h000066400000000000000000000137241455751074500221310ustar00rootroot00000000000000/******************************************************************************** * * * F r a m e W i n d o w W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXFRAME_H #define FXFRAME_H #ifndef FXWINDOW_H #include "FXWindow.h" #endif namespace FX { /// Justification modes used by certain subclasses enum { JUSTIFY_NORMAL = 0, /// Default justification is centered text JUSTIFY_CENTER_X = 0, /// Contents centered horizontally JUSTIFY_LEFT = 0x00008000, /// Contents left-justified JUSTIFY_RIGHT = 0x00010000, /// Contents right-justified JUSTIFY_HZ_APART = JUSTIFY_LEFT|JUSTIFY_RIGHT, /// Combination of JUSTIFY_LEFT & JUSTIFY_RIGHT JUSTIFY_CENTER_Y = 0, /// Contents centered vertically JUSTIFY_TOP = 0x00020000, /// Contents aligned with label top JUSTIFY_BOTTOM = 0x00040000, /// Contents aligned with label bottom JUSTIFY_VT_APART = JUSTIFY_TOP|JUSTIFY_BOTTOM /// Combination of JUSTIFY_TOP & JUSTIFY_BOTTOM }; /// Default padding enum { DEFAULT_PAD = 2 }; /** * The Frame widget provides borders around some contents. Borders may be raised, sunken, * thick, ridged or etched. They can also be turned off completely. * In addition, a certain amount of padding may be specified between the contents of * the widget and the borders. The contents may be justified inside the widget using the * justification options. * The Frame widget is sometimes used by itself as a place holder, but most often is used * as a convenient base class for simple controls. */ class FXAPI FXFrame : public FXWindow { FXDECLARE(FXFrame) protected: FXColor baseColor; // Base color FXColor hiliteColor; // Highlight color FXColor shadowColor; // Shadow color FXColor borderColor; // Border color FXint padtop; // Top padding FXint padbottom; // Bottom padding FXint padleft; // Left padding FXint padright; // right padding FXint border; // Border size protected: FXFrame(); void drawBorderRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawRaisedRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawSunkenRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawRidgeRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawGrooveRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawDoubleRaisedRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawDoubleSunkenRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawFrame(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); private: FXFrame(const FXFrame&); FXFrame &operator=(const FXFrame&); public: long onPaint(FXObject*,FXSelector,void*); public: /// Construct frame window FXFrame(FXComposite* p,FXuint opts=FRAME_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Change frame style void setFrameStyle(FXuint style); /// Get current frame style FXuint getFrameStyle() const; /// Get border width FXint getBorderWidth() const { return border; } /// Change top padding void setPadTop(FXint pt); /// Get top interior padding FXint getPadTop() const { return padtop; } /// Change bottom padding void setPadBottom(FXint pb); /// Get bottom interior padding FXint getPadBottom() const { return padbottom; } /// Change left padding void setPadLeft(FXint pl); /// Get left interior padding FXint getPadLeft() const { return padleft; } /// Change right padding void setPadRight(FXint pr); /// Get right interior padding FXint getPadRight() const { return padright; } /// Change highlight color void setHiliteColor(FXColor clr); /// Get highlight color FXColor getHiliteColor() const { return hiliteColor; } /// Change shadow color void setShadowColor(FXColor clr); /// Get shadow color FXColor getShadowColor() const { return shadowColor; } /// Change border color void setBorderColor(FXColor clr); /// Get border color FXColor getBorderColor() const { return borderColor; } /// Change base gui color void setBaseColor(FXColor clr); /// Get base gui color FXColor getBaseColor() const { return baseColor; } /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXGIFCursor.h000066400000000000000000000064701455751074500227020ustar00rootroot00000000000000/******************************************************************************** * * * G I F C u r so r O b j e c t * * * ********************************************************************************* * Copyright (C) 2000,2022 by Daniel Gehriger. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXGIFCURSOR_H #define FXGIFCURSOR_H #ifndef FXCURSOR_H #include "FXCursor.h" #endif namespace FX { /// GIF Cursor class class FXAPI FXGIFCursor : public FXCursor { FXDECLARE(FXGIFCursor) protected: FXGIFCursor(){} private: FXGIFCursor(const FXGIFCursor&); FXGIFCursor &operator=(const FXGIFCursor&); public: static const FXchar fileExt[]; public: /** * Construct a cursor from memory stream in Compuserve GIF format. * Hot spot may be specified using hx and hy parameters, since the GIF * format does not specify a hot spot. The image must be smaller than * 32x32 pixels. */ FXGIFCursor(FXApp* a,const FXuchar* pix,FXint hx=0,FXint hy=0); /// Save pixel data only, in GIF format virtual FXbool savePixels(FXStream& store) const; /// Load pixel data only, in GIF format virtual FXbool loadPixels(FXStream& store); /// Destroy virtual ~FXGIFCursor(){} }; #ifndef FXLOADGIF #define FXLOADGIF /** * Check if stream contains a GIF, return true if so. */ extern FXAPI FXbool fxcheckGIF(FXStream& store); /** * Load an GIF (Graphics Interchange Format) file from a stream; if the flag * flag is true, the background color is considered transparent. Upon successful return, * the pixel array and size are returned. If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadGIF(FXStream& store,FXColor*& data,FXint& width,FXint& height,FXbool flag=true); /** * Save an GIF (Graphics Interchange Format) file to a stream. If flag * is true, the faster Floyd-Steinberg dither method instead of the slower Wu * quantization algorithm. */ extern FXAPI FXbool fxsaveGIF(FXStream& store,const FXColor *data,FXint width,FXint height,FXbool flag=true); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXGIFIcon.h000066400000000000000000000063051455751074500223120ustar00rootroot00000000000000/******************************************************************************** * * * G I F I c o n O b j e c t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXGIFICON_H #define FXGIFICON_H #ifndef FXICON_H #include "FXIcon.h" #endif namespace FX { /// GIF Icon class class FXAPI FXGIFIcon : public FXIcon { FXDECLARE(FXGIFIcon) protected: FXGIFIcon(){} private: FXGIFIcon(const FXGIFIcon&); FXGIFIcon &operator=(const FXGIFIcon&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct an icon from memory stream formatted as GIF format FXGIFIcon(FXApp* a,const FXuchar *pix=nullptr,FXColor clr=FXRGB(192,192,192),FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in GIF format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in GIF format virtual FXbool loadPixels(FXStream& store); /// Destroy virtual ~FXGIFIcon(); }; #ifndef FXLOADGIF #define FXLOADGIF /** * Check if stream contains a GIF, return true if so. */ extern FXAPI FXbool fxcheckGIF(FXStream& store); /** * Load an GIF (Graphics Interchange Format) file from a stream; if the flag * flag is true, the background color is considered transparent. Upon successful return, * the pixel array and size are returned. If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadGIF(FXStream& store,FXColor*& data,FXint& width,FXint& height,FXbool flag=true); /** * Save an GIF (Graphics Interchange Format) file to a stream. If flag * is true, the faster Floyd-Steinberg dither method instead of the slower Wu * quantization algorithm. */ extern FXAPI FXbool fxsaveGIF(FXStream& store,const FXColor *data,FXint width,FXint height,FXbool flag=true); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXGIFImage.h000066400000000000000000000063201455751074500224410ustar00rootroot00000000000000/******************************************************************************** * * * G I F I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXGIFIMAGE_H #define FXGIFIMAGE_H #ifndef FXIMAGE_H #include "FXImage.h" #endif namespace FX { /// GIF Image class class FXAPI FXGIFImage : public FXImage { FXDECLARE(FXGIFImage) protected: FXGIFImage(){} private: FXGIFImage(const FXGIFImage&); FXGIFImage &operator=(const FXGIFImage&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct an image from memory stream formatted as CompuServe GIF format FXGIFImage(FXApp* a,const FXuchar *pix=nullptr,FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in [un]GIF format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in CompuServe GIF format virtual FXbool loadPixels(FXStream& store); /// Destroy virtual ~FXGIFImage(); }; #ifndef FXLOADGIF #define FXLOADGIF /** * Check if stream contains a GIF, return true if so. */ extern FXAPI FXbool fxcheckGIF(FXStream& store); /** * Load an GIF (Graphics Interchange Format) file from a stream; if the flag * flag is true, the background color is considered transparent. Upon successful return, * the pixel array and size are returned. If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadGIF(FXStream& store,FXColor*& data,FXint& width,FXint& height,FXbool flag=true); /** * Save an GIF (Graphics Interchange Format) file to a stream. If flag * is true, the faster Floyd-Steinberg dither method instead of the slower Wu * quantization algorithm. */ extern FXAPI FXbool fxsaveGIF(FXStream& store,const FXColor *data,FXint width,FXint height,FXbool flag=true); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXGLCanvas.h000066400000000000000000000075171455751074500225400ustar00rootroot00000000000000/******************************************************************************** * * * G L C a n v a s W i n d o w W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXGLCANVAS_H #define FXGLCANVAS_H #ifndef FXCANVAS_H #include "FXCanvas.h" #endif namespace FX { class FXGLVisual; class FXGLContext; // GL Canvas options enum { GLCANVAS_OWN_CONTEXT = 0x00008000 /// Context is owned }; /// GLCanvas, an area drawn by another object class FXAPI FXGLCanvas : public FXCanvas { FXDECLARE(FXGLCanvas) protected: FXGLContext *context; // Graphic context protected: FXGLCanvas(); private: FXGLCanvas(const FXGLCanvas&); FXGLCanvas &operator=(const FXGLCanvas&); #ifdef WIN32 virtual const void* GetClass() const; #endif public: /** * Construct a GL canvas with its private context and private display lists. */ FXGLCanvas(FXComposite* p,FXGLVisual *vis,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /** * Construct a GL canvas with its private context but shared display lists. */ FXGLCanvas(FXComposite* p,FXGLVisual *vis,FXGLCanvas* share,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /** * Construct a GL canvas with a shared context. */ FXGLCanvas(FXComposite* p,FXGLContext* ctx,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Change context void setContext(FXGLContext *ctx,FXbool owned=false); /// Get context FXGLContext* getContext() const { return context; } /// Create all of the server-side resources for this window virtual void create(); /// Detach the server-side resources for this window virtual void detach(); /// Destroy the server-side resources for this window virtual void destroy(); /// Make OpenGL context current prior to performing OpenGL commands virtual FXbool makeCurrent(); /// Make OpenGL context non current virtual FXbool makeNonCurrent(); /// Return true if this window's context is current virtual FXbool isCurrent() const; /// Swap front and back buffer virtual void swapBuffers(); /// Return true if it is sharing display lists FXbool isShared() const; /// Save object to stream virtual void save(FXStream& store) const; /// Load object from stream virtual void load(FXStream& store); /// Destructor virtual ~FXGLCanvas(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXGLContext.h000066400000000000000000000070371455751074500227460ustar00rootroot00000000000000/******************************************************************************** * * * G L R e n d e r i n g C o n t e x t * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXGLCONTEXT_H #define FXGLCONTEXT_H #ifndef FXID_H #include "FXId.h" #endif namespace FX { /// GL Context class FXAPI FXGLContext : public FXId { FXDECLARE(FXGLContext) private: FXDrawable *surface; // Drawable surface FXGLVisual *visual; // Visual of the context FXGLContext *shared; // Shared with other private: FXGLContext(const FXGLContext&); FXGLContext &operator=(const FXGLContext&); protected: FXGLContext(); public: /** * Construct an GLContext with given GL Visual. Optionally * share GL objects (textures, etc) with another GLContext shr. */ FXGLContext(FXApp *a,FXGLVisual *vis,FXGLContext* shr=nullptr); /// Create context virtual void create(); /// Detach context virtual void detach(); /// Destroy context virtual void destroy(); /// Change visual void setVisual(FXGLVisual* vis); /// Get the visual FXGLVisual* getVisual() const { return visual; } /// Change share context void setShared(FXGLContext *ctx); /// Get share context FXGLContext* getShared() const { return shared; } /// Return active drawable FXDrawable *drawable() const { return surface; } /// Make context current on drawable FXbool begin(FXDrawable *draw); /// Make context non current FXbool end(); /// Swap front and back buffer void swapBuffers(); /// Return true if THIS context is current FXbool isCurrent() const; /// Return true if thread has ANY current context static FXbool hasCurrent(); /// Has double buffering FXbool isDoubleBuffer() const; /// Has stereo buffering FXbool isStereo() const; /// Save object to stream virtual void save(FXStream& store) const; /// Load object from stream virtual void load(FXStream& store); /// Destructor virtual ~FXGLContext(); }; /// Create a display list of bitmaps from font glyphs in a font extern FXAPI FXbool glUseFXFont(FXFont* font,int first,int count,int list); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXGLObject.h000066400000000000000000000117751455751074500225340ustar00rootroot00000000000000/******************************************************************************** * * * O p e n G L O b j e c t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXGLOBJECT_H #define FXGLOBJECT_H #ifndef FXOBJECT_H #include "FXObject.h" #endif namespace FX { class FXGLViewer; class FXGLObject; /// Basic OpenGL object class FXAPI FXGLObject : public FXObject { FXDECLARE(FXGLObject) public: enum { ID_LAST=10000 // Leaving ample room for FXGLViewer subclasses }; public: /// Constructors FXGLObject(){} /// Copy constructor FXGLObject(const FXGLObject& orig):FXObject(orig){} /// Called by the viewer to get bounds for this object virtual void bounds(FXRangef& box); /// Draw this object in a viewer virtual void draw(FXGLViewer* viewer); /// Draw this object for hit-testing purposes virtual void hit(FXGLViewer* viewer); /// Copy this object virtual FXGLObject* copy(); /// Identify sub-object given path virtual FXGLObject* identify(FXuint* path); /// Return true if this object can be dragged around virtual FXbool canDrag() const; /// Return true if this object can be deleted from the scene virtual FXbool canDelete() const; /// Drag this object from one position to another virtual FXbool drag(FXGLViewer* viewer,FXint fx,FXint fy,FXint tx,FXint ty); /// Destructor virtual ~FXGLObject(){} }; /// List of GL objects typedef FXObjectListOf FXGLObjectList; /// Group object class FXAPI FXGLGroup : public FXGLObject { FXDECLARE(FXGLGroup) protected: FXGLObjectList list; // List of all objects public: /// Constructor FXGLGroup(){ } /// Copy constructor FXGLGroup(const FXGLGroup& orig):FXGLObject(orig),list(orig.list){ } /// Return list of childern FXGLObjectList& getList(){ return list; } /// Return bounding box virtual void bounds(FXRangef& box); /// Draw into viewer virtual void draw(FXGLViewer* viewer); /// Hit in viewer virtual void hit(FXGLViewer* viewer); /// Copy this object virtual FXGLObject* copy(); /// Identify object by means of path virtual FXGLObject* identify(FXuint* path); /// Return true if group can be dragged virtual FXbool canDrag() const; /// Drag group object virtual FXbool drag(FXGLViewer* viewer,FXint fx,FXint fy,FXint tx,FXint ty); /// Return number of children FXival no() const { return list.no(); } /// Child at position FXGLObject* child(FXival pos) const { return list[pos]; } /// Insert child object at given position void insert(FXival pos,FXGLObject* obj){ list.insert(pos,obj); } /// Insert list of child objects at given position void insert(FXival pos,const FXGLObjectList& objs){ list.insert(pos,objs); } /// Prepend child object void prepend(FXGLObject* obj){ list.prepend(obj); } /// Prepend list of child objects at given position void prepend(const FXGLObjectList& objs){ list.prepend(objs); } /// Append child object void append(FXGLObject* obj){ list.append(obj); } /// Append list of child objects at given position void append(const FXGLObjectList& objs){ list.append(objs); } /// Replace child object void replace(FXival pos,FXGLObject* obj){ list.replace(pos,obj); } /// Remove child object void remove(FXGLObject* obj){ list.remove(obj); } /// Remove child object at given position void erase(FXival pos){ list.erase(pos); } /// Remove all children void clear(){ list.clear(); } /// Stream save and load virtual void save(FXStream& store) const; virtual void load(FXStream& store); /// Destructor virtual ~FXGLGroup(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXGLViewer.h000066400000000000000000000476751455751074500225770ustar00rootroot00000000000000/******************************************************************************** * * * O p e n G L V i e w e r W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXGLVIEWER_H #define FXGLVIEWER_H #ifndef FXGLCANVAS_H #include "FXGLCanvas.h" #endif namespace FX { class FXDCPrint; class FXGLObject; class FXGLVisual; // GL Viewer options enum { GLVIEWER_LIGHTING = 0x00010000, /// Lighting is on GLVIEWER_FOG = 0x00020000, /// Fog mode on GLVIEWER_DITHER = 0x00040000 /// Dithering }; /******************************* Viewer Structs *****************************/ /// OpenGL Viewer Viewport struct FXViewport { FXint w; /// Viewport width FXint h; /// Viewport height FXdouble left; /// World left FXdouble right; /// World right FXdouble bottom; /// World bottom FXdouble top; /// World top FXdouble hither; /// World hither (near) FXdouble yon; /// World yon (far) }; /// OpenGL Light Source struct FXAPI FXLight { FXVec4f ambient; /// Ambient light color FXVec4f diffuse; /// Diffuse light color FXVec4f specular; /// Specular light color FXVec4f position; /// Light position FXVec3f direction; /// Spot direction FXfloat exponent; /// Spotlight exponent FXfloat cutoff; /// Spotlight cutoff angle FXfloat c_attn; /// Constant attenuation factor FXfloat l_attn; /// Linear attenuation factor FXfloat q_attn; /// Quadratic attenuation factor }; /// OpenGL Material Description struct FXAPI FXMaterial { FXVec4f ambient; /// Ambient material color FXVec4f diffuse; /// Diffuse material color FXVec4f specular; /// Specular material color FXVec4f emission; /// Emissive material color FXfloat shininess; /// Specular shininess }; // Feedback buffer sort routine typedef FXbool (*FXZSortFunc)(FXfloat*& buffer,FXint& used,FXint& size); /******************************** Viewer Class ******************************/ /// OpenGL viewer widget class FXAPI FXGLViewer : public FXGLCanvas { FXDECLARE(FXGLViewer) friend class FXGLObject; protected: FXViewport wvt; // Window viewport transform FXMat4f transform; // Current transformation matrix FXMat4f itransform; // Inverse of current transformation matrix FXuint projection; // Projection mode FXQuatf rotation; // Viewer orientation FXdouble fov; // Field of view FXdouble zoom; // Zoom factor FXVec3f center; // Model center FXVec3f scale; // Model scale FXdouble worldpx; // Pixel size in world FXdouble modelpx; // Pixel size in model FXint maxhits; // Maximum number of hits FXdouble ax,ay; // Quick view->world coordinate mapping FXdouble diameter; // Size of model diameter ( always > 0) FXdouble distance; // Distance of PRP to target FXVec4f background[2]; // Background colors FXVec4f ambient; // Global ambient light FXLight light; // Light source FXMaterial material; // Base material properties FXint dial[3]; // Dial positions FXString help; // Status help FXString tip; // Tooltip for background FXGLObject *dropped; // Object being dropped on FXGLObject *selection; // Current object FXZSortFunc zsortfunc; // Routine to sort feedback buffer FXGLObject *scene; // What we're looking at FXbool doesturbo; // Doing turbo mode FXbool turbomode; // Turbo mode FXuchar mode; // Mode the widget is in public: // Common DND types static FXDragType objectType; // GL Object type protected: // Mouse actions when in viewing window enum { HOVERING, // Hovering mouse w/o doing anything PICKING, // Pick mode ROTATING, // Rotating camera around target POSTING, // Posting right-mouse menu TRANSLATING, // Translating camera ZOOMING, // Zooming FOVING, // Change field-of-view DRAGGING, // Dragging objects TRUCKING, // Trucking camera GYRATING, // Rotation of camera around eye DO_LASSOSELECT, // Lasso select when mouse pressed LASSOSELECT, // Anchor of lasso rectangle DO_LASSOZOOM, // Zoom when mouse pressed LASSOZOOM // Zoom rectangle }; protected: FXGLViewer(); void glsetup(); virtual void updateProjection(); virtual void updateTransform(); FXVec3f spherePoint(FXint px,FXint py); FXQuatf turn(FXint fx,FXint fy,FXint tx,FXint ty); void drawWorld(FXViewport& wv); void drawAnti(FXViewport& wv); void drawLasso(FXint x0,FXint y0,FXint x1,FXint y1); FXint selectHits(FXuint*& hits,FXint& nhits,FXint x,FXint y,FXint w,FXint h); FXint renderFeedback(FXfloat *buffer,FXint x,FXint y,FXint w,FXint h,FXint maxbuffer); void drawFeedback(FXDCPrint& pdc,const FXfloat* buffer,FXint used); virtual FXGLObject* processHits(FXuint *pickbuffer,FXint nhits); void setOp(FXuint o); private: FXGLViewer(const FXGLViewer&); FXGLViewer &operator=(const FXGLViewer&); void initialize(); public: // Events long onPaint(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onMouseWheel(FXObject*,FXSelector,void*); long onChanged(FXObject*,FXSelector,void*); long onPick(FXObject*,FXSelector,void*); long onClicked(FXObject*,FXSelector,void*); long onDoubleClicked(FXObject*,FXSelector,void*); long onTripleClicked(FXObject*,FXSelector,void*); long onLassoed(FXObject*,FXSelector,void*); long onSelected(FXObject*,FXSelector,void*); long onDeselected(FXObject*,FXSelector,void*); long onInserted(FXObject*,FXSelector,void*); long onDeleted(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onMiddleBtnPress(FXObject*,FXSelector,void*); long onMiddleBtnRelease(FXObject*,FXSelector,void*); long onRightBtnPress(FXObject*,FXSelector,void*); long onRightBtnRelease(FXObject*,FXSelector,void*); long onSpaceBallMotion(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onFocusIn(FXObject*,FXSelector,void*); long onFocusOut(FXObject*,FXSelector,void*); long onClipboardLost(FXObject*,FXSelector,void*); long onClipboardGained(FXObject*,FXSelector,void*); long onClipboardRequest(FXObject*,FXSelector,void*); // Commands long onCmdPerspective(FXObject*,FXSelector,void*); long onUpdPerspective(FXObject*,FXSelector,void*); long onCmdParallel(FXObject*,FXSelector,void*); long onUpdParallel(FXObject*,FXSelector,void*); long onCmdFront(FXObject*,FXSelector,void*); long onUpdFront(FXObject*,FXSelector,void*); long onCmdBack(FXObject*,FXSelector,void*); long onUpdBack(FXObject*,FXSelector,void*); long onCmdLeft(FXObject*,FXSelector,void*); long onUpdLeft(FXObject*,FXSelector,void*); long onCmdRight(FXObject*,FXSelector,void*); long onUpdRight(FXObject*,FXSelector,void*); long onCmdTop(FXObject*,FXSelector,void*); long onUpdTop(FXObject*,FXSelector,void*); long onCmdBottom(FXObject*,FXSelector,void*); long onUpdBottom(FXObject*,FXSelector,void*); long onCmdResetView(FXObject*,FXSelector,void*); long onCmdFitView(FXObject*,FXSelector,void*); long onDNDEnter(FXObject*,FXSelector,void*); long onDNDLeave(FXObject*,FXSelector,void*); long onDNDMotion(FXObject*,FXSelector,void*); long onDNDDrop(FXObject*,FXSelector,void*); long onTipTimer(FXObject*,FXSelector,void*); long onCmdXYZDial(FXObject*,FXSelector,void*); long onUpdXYZDial(FXObject*,FXSelector,void*); long onCmdRollPitchYaw(FXObject*,FXSelector,void*); long onUpdRollPitchYaw(FXObject*,FXSelector,void*); long onCmdXYZScale(FXObject*,FXSelector,void*); long onUpdXYZScale(FXObject*,FXSelector,void*); long onUpdCurrent(FXObject*,FXSelector,void*); long onCmdCutSel(FXObject*,FXSelector,void*); long onCmdCopySel(FXObject*,FXSelector,void*); long onCmdPasteSel(FXObject*,FXSelector,void*); long onCmdDeleteSel(FXObject*,FXSelector,void*); long onUpdDeleteSel(FXObject*,FXSelector,void*); long onCmdBackColor(FXObject*,FXSelector,void*); long onUpdBackColor(FXObject*,FXSelector,void*); long onCmdGradientBackColor(FXObject*,FXSelector,void*); long onUpdGradientBackColor(FXObject*,FXSelector,void*); long onCmdAmbientColor(FXObject*,FXSelector,void*); long onUpdAmbientColor(FXObject*,FXSelector,void*); long onCmdLighting(FXObject*,FXSelector,void*); long onUpdLighting(FXObject*,FXSelector,void*); long onCmdFog(FXObject*,FXSelector,void*); long onUpdFog(FXObject*,FXSelector,void*); long onCmdDither(FXObject*,FXSelector,void*); long onUpdDither(FXObject*,FXSelector,void*); long onCmdFov(FXObject*,FXSelector,void*); long onUpdFov(FXObject*,FXSelector,void*); long onCmdZoom(FXObject*,FXSelector,void*); long onUpdZoom(FXObject*,FXSelector,void*); long onCmdLightAmbient(FXObject*,FXSelector,void*); long onUpdLightAmbient(FXObject*,FXSelector,void*); long onCmdLightDiffuse(FXObject*,FXSelector,void*); long onUpdLightDiffuse(FXObject*,FXSelector,void*); long onCmdLightSpecular(FXObject*,FXSelector,void*); long onUpdLightSpecular(FXObject*,FXSelector,void*); long onCmdTurbo(FXObject*,FXSelector,void*); long onUpdTurbo(FXObject*,FXSelector,void*); long onCmdPrintImage(FXObject*,FXSelector,void*); long onCmdPrintVector(FXObject*,FXSelector,void*); long onCmdLassoZoom(FXObject*,FXSelector,void*); long onCmdLassoSelect(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); virtual long onDefault(FXObject*,FXSelector,void*); public: // Projection modes enum { PARALLEL, // Parallel projection PERSPECTIVE // Perspective projection }; // Messages enum { ID_PERSPECTIVE=FXGLCanvas::ID_LAST, ID_PARALLEL, ID_FRONT, ID_BACK, ID_LEFT, ID_RIGHT, ID_TOP, ID_BOTTOM, ID_RESETVIEW, ID_FITVIEW, ID_TOP_COLOR, ID_BOTTOM_COLOR, ID_BACK_COLOR, ID_AMBIENT_COLOR, ID_LIGHT_AMBIENT, ID_LIGHT_DIFFUSE, ID_LIGHT_SPECULAR, ID_LIGHTING, ID_TURBO, ID_FOG, ID_DITHER, ID_SCALE_X, ID_SCALE_Y, ID_SCALE_Z, ID_DIAL_X, ID_DIAL_Y, ID_DIAL_Z, ID_ROLL, ID_PITCH, ID_YAW, ID_FOV, ID_ZOOM, ID_CUT_SEL, ID_COPY_SEL, ID_PASTE_SEL, ID_DELETE_SEL, ID_PRINT_IMAGE, ID_PRINT_VECTOR, ID_LASSO_ZOOM, ID_LASSO_SELECT, ID_LAST }; public: // Common DND type names static const FXchar objectTypeName[]; public: /// Construct GL viewer widget FXGLViewer(FXComposite* p,FXGLVisual *vis,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Construct GL viewer widget sharing display lists with another GL canvas FXGLViewer(FXComposite* p,FXGLVisual *vis,FXGLCanvas* share,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Construct GL viewer widget sharing context FXGLViewer(FXComposite* p,FXGLContext* ctx,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Create all of the server-side resources for this window virtual void create(); /// Detach server-side resources virtual void detach(); /// Perform layout virtual void layout(); /// Return size of pixel in world coordinates FXdouble worldPix() const { return worldpx; } /// Return size of pixel in model coordinates FXdouble modelPix() const { return modelpx; } /// Return a NULL-terminated list of all objects in the given rectangle, or NULL FXGLObject** lasso(FXint x1,FXint y1,FXint x2,FXint y2); /// Return a NULL-terminated list of all objects in the given rectangle, or NULL virtual FXGLObject** select(FXint x,FXint y,FXint w,FXint h); /// Perform a pick operation, returning the object at the given x,y position, or NULL virtual FXGLObject* pick(FXint x,FXint y); /// Change the model bounding box; this adjusts the viewer virtual FXbool setBounds(const FXRangef& box); /// Fit viewer to the given bounding box FXbool fitToBounds(const FXRangef& box); /// Return the viewer's viewport void getViewport(FXViewport& v) const; /// Translate eye-coordinate to screen coordinate void eyeToScreen(FXint& sx,FXint& sy,FXVec3f e); /// Translate screen coordinate to eye coordinate at the given depth FXVec3f screenToEye(FXint sx,FXint sy,FXfloat eyez=0.0f); /// Translate screen coordinate to eye coordinate at the target point depth FXVec3f screenToTarget(FXint sx,FXint sy); /// Translate world coordinate to eye coordinate FXVec3f worldToEye(FXVec3f w); /// Translate world coordinate to eye coordinate depth FXfloat worldToEyeZ(FXVec3f w); /// Translate eye coordinate to eye coordinate FXVec3f eyeToWorld(FXVec3f e); /// Calculate world coordinate vector from screen movement FXVec3f worldVector(FXint fx,FXint fy,FXint tx,FXint ty); /// Change default object material setting void setMaterial(const FXMaterial &mtl); /// Return default object material setting void getMaterial(FXMaterial &mtl) const; /// Change camera field of view angle (in degrees) void setFieldOfView(FXdouble fv); /// Return camera field of view angle FXdouble getFieldOfView() const { return fov; } /// Change camera zoom factor void setZoom(FXdouble zm); /// Return camera zoom factor FXdouble getZoom() const { return zoom; } /// Change target point distance void setDistance(FXdouble ed); /// Return target point distance FXdouble getDistance() const { return distance; } /// Change unequal model scaling factors void setScale(FXVec3f s); /// Return current scaling factors const FXVec3f& getScale() const { return scale; } /// Change camera orientation from quaternion void setOrientation(const FXQuatf& rot); /// Return current camera orientation quaternion const FXQuatf& getOrientation() const { return rotation; } /// Change object center (tranlation) void setCenter(FXVec3f cntr); /// Return object center const FXVec3f& getCenter() const { return center; } /// Translate object center void translate(FXVec3f vec); /// Return boresight vector FXbool getBoreVector(FXint sx,FXint sy,FXVec3f& point,FXVec3f& dir); /// Return eyesight vector FXVec3f getEyeVector() const; /// Return eye position FXVec3f getEyePosition() const; /// Change help text void setHelpText(const FXString& text); /// Return help text const FXString& getHelpText() const { return help; } /// Change tip text void setTipText(const FXString& text); /// Return tip text const FXString& getTipText() const { return tip; } /// Return the current transformation matrix const FXMat4f& getTransform() const { return transform; } /// Return the inverse of the current transformation matrix const FXMat4f& getInvTransform() const { return itransform; } /// Change the scene, i.e. the object being displayed. void setScene(FXGLObject* sc); /// Return the current scene object FXGLObject* getScene() const { return scene; } /// Change selection void setSelection(FXGLObject* sel); /// Return selection FXGLObject* getSelection() const { return selection; } /// Change the projection mode, PERSPECTIVE or PARALLEL void setProjection(FXuint proj); /// Return the projection mode FXuint getProjection() const { return projection; } /// Change both top and bottom background colors void setBackgroundColor(const FXVec4f& clr); /// Change top or bottom background color void setBackgroundColor(const FXVec4f& clr,FXbool bottom); /// Return top or bottom window background color const FXVec4f& getBackgroundColor(FXbool bottom) const { return background[bottom]; } /// Change global ambient light color void setAmbientColor(const FXVec4f& clr); /// Return global ambient light color const FXVec4f& getAmbientColor() const { return ambient; } /** * Read the pixels off the screen as array of FXColor; * this array can be directly passed to fxsaveBMP and other image * output routines. */ FXbool readPixels(FXColor*& buffer,FXint x,FXint y,FXint w,FXint h); /** * Read the feedback buffer containing the current scene, returning used * and allocated size. */ FXbool readFeedback(FXfloat*& buffer,FXint& used,FXint& size,FXint x,FXint y,FXint w,FXint h); /** * Change hidden-surface feedback buffer sorting algorithm. * This can be used for move/draw printed output depth sorting. */ void setZSortFunc(FXZSortFunc func){ zsortfunc=func; } /// Return hidden surface sorting function. FXZSortFunc getZSortFunc() const { return zsortfunc; } /** * Change the maximum hits, i.e. the maximum size of the pick buffer. * When set to less than or equal to zero, picking is essentially turned off. */ void setMaxHits(FXint maxh) { maxhits=maxh; } /// Return maximum pickbuffer size FXint getMaxHits() const { return maxhits; } /** * When drawing a GL object, if doesTurbo() is true, the object * may choose to perform a reduced complexity drawing as the user is * interactively manipulating; another update will be done later when * the full complexity drawing can be performed again. */ FXbool doesTurbo() const { return doesturbo; } /// Return turbo mode setting FXbool getTurboMode() const { return turbomode; } /// Set turbo mode void setTurboMode(FXbool turbo=true); /// Return light source settings void getLight(FXLight& lite) const; /// Change light source settings void setLight(const FXLight& lite); /// Save viewer to a stream virtual void save(FXStream& store) const; /// Load viewer from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXGLViewer(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXGLVisual.h000066400000000000000000000144511455751074500225630ustar00rootroot00000000000000/******************************************************************************** * * * V i s u a l C l a s s * * * ********************************************************************************* * Copyright (C) 1999,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXGLVISUAL_H #define FXGLVISUAL_H #ifndef FXVISUAL_H #include "FXVisual.h" #endif namespace FX { class FXFont; class FXWindow; class FXImage; class FXIcon; class FXBitmap; class FXDCWindow; /// Visual describes pixel format of a drawable class FXAPI FXGLVisual : public FXVisual { FXDECLARE(FXGLVisual) friend class FXWindow; friend class FXImage; friend class FXIcon; friend class FXBitmap; friend class FXDCWindow; protected: struct FXGLSpecs; protected: FXuchar redSize; // Red bits FXuchar greenSize; // Green depth FXuchar blueSize; // Blue bits FXuchar alphaSize; // Alpha bits FXuchar depthSize; // Depth bits FXuchar stencilSize; // Stencil bits FXuchar multiSamples; // Multi-sampling FXuchar accumRedSize; // Red accu buffer bits FXuchar accumGreenSize; // Green accu buffer bits FXuchar accumBlueSize; // Blue accu buffer bits FXuchar accumAlphaSize; // Alpha accu buffer bits FXuchar actualRedSize; // Actual Red bits FXuchar actualGreenSize; // Actual Green depth FXuchar actualBlueSize; // Actual Blue bits FXuchar actualAlphaSize; // Actual Alpha bits FXuchar actualDepthSize; // Actual Depth bits FXuchar actualStencilSize; // Actual Stencil bits FXuchar actualMultiSamples; // Actual multi-sampling FXuchar actualAccumRedSize; // Actual Red accu buffer bits FXuchar actualAccumGreenSize; // Actual Green accu buffer bits FXuchar actualAccumBlueSize; // Actual Blue accu buffer bits FXuchar actualAccumAlphaSize; // Actual Alpha accu buffer bits FXbool doubleBuffer; FXbool stereoBuffer; FXbool accelerated; FXbool copying; protected: FXGLVisual(); private: FXGLVisual(const FXGLVisual&); FXGLVisual &operator=(const FXGLVisual&); FXint matchSpecs(const FXGLSpecs& s); public: /// Construct default visual FXGLVisual(FXApp* a,FXuint flgs=VISUAL_DOUBLE_BUFFER); /// Create visual virtual void create(); /// Detach visual virtual void detach(); /// Destroy visual virtual void destroy(); /// Get sizes for bit-planes FXint getRedSize() const { return redSize; } FXint getGreenSize() const { return greenSize; } FXint getBlueSize() const { return blueSize; } FXint getAlphaSize() const { return alphaSize; } FXint getDepthSize() const { return depthSize; } FXint getStencilSize() const { return stencilSize; } FXint getMultiSamples() const { return multiSamples; } FXint getAccumRedSize() const { return accumRedSize; } FXint getAccumGreenSize() const { return accumGreenSize; } FXint getAccumBlueSize() const { return accumBlueSize; } FXint getAccumAlphaSize() const { return accumAlphaSize; } /// Set sizes for bit-planes void setRedSize(FXint rs){ redSize=rs; } void setGreenSize(FXint gs){ greenSize=gs; } void setBlueSize(FXint bs){ blueSize=bs; } void setAlphaSize(FXint as){ alphaSize=as; } void setDepthSize(FXint ds){ depthSize=ds; } void setStencilSize(FXint ss){ stencilSize=ss; } void setMultiSamples(FXint ms){ multiSamples=ms; } void setAccumRedSize(FXint rs){ accumRedSize=rs; } void setAccumGreenSize(FXint gs){ accumGreenSize=gs; } void setAccumBlueSize(FXint bs){ accumBlueSize=bs; } void setAccumAlphaSize(FXint as){ accumAlphaSize=as; } /// Get ACTUAL sizes for bit-planes FXint getActualRedSize() const { return actualRedSize; } FXint getActualGreenSize() const { return actualGreenSize; } FXint getActualBlueSize() const { return actualBlueSize; } FXint getActualAlphaSize() const { return actualAlphaSize; } FXint getActualDepthSize() const { return actualDepthSize; } FXint getActualStencilSize() const { return actualStencilSize; } FXint getActualMultiSamples() const { return actualMultiSamples; } FXint getActualAccumRedSize() const { return actualAccumRedSize; } FXint getActualAccumGreenSize() const { return actualAccumGreenSize; } FXint getActualAccumBlueSize() const { return actualAccumBlueSize; } FXint getActualAccumAlphaSize() const { return actualAccumAlphaSize; } /// Is it double buffered? FXbool isDoubleBuffer() const { return doubleBuffer; } /// Is it stereo? FXbool isStereo() const { return stereoBuffer; } /// Is it hardware-accelerated? FXbool isAccelerated() const { return accelerated; } /// Does it swap by copying instead of flipping buffers FXbool isBufferSwapCopy() const { return copying; } /// Test if if OpenGL is supported. static FXbool hasOpenGL(FXApp* application); /// Save visual info to a stream virtual void save(FXStream& store) const; /// Load visual info to a stream virtual void load(FXStream& store); /// Destructor virtual ~FXGLVisual(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXGZFileStream.h000066400000000000000000000160671455751074500233760ustar00rootroot00000000000000/******************************************************************************** * * * G Z F i l e S t r e a m C l a s s e s * * * ********************************************************************************* * Copyright (C) 2002,2022 by Sander Jansen. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifdef HAVE_ZLIB_H #ifndef FXGZFILESTREAM_H #define FXGZFILESTREAM_H #ifndef FXFILESTREAM_H #include "FXFileStream.h" #endif namespace FX { struct ZBlock; /// GZIP compressed stream class FXAPI FXGZFileStream : public FXFileStream { private: ZBlock *gz; int ac; protected: virtual FXuval writeBuffer(FXuval count); virtual FXuval readBuffer(FXuval count); private: FXGZFileStream(const FXGZFileStream&); FXGZFileStream& operator=(const FXGZFileStream&); public: /// Create GZIP compressed file stream FXGZFileStream(const FXObject* cont=nullptr); /// Create and open GZIP compressed file stream FXGZFileStream(const FXString& filename,FXStreamDirection save_or_load=FXStreamLoad,FXuval size=8192UL); /// Open file stream FXbool open(const FXString& filename,FXStreamDirection save_or_load=FXStreamLoad,FXuval size=8192UL); /// Flush buffer virtual FXbool flush(); /// Close file stream virtual FXbool close(); /// Get position FXlong position() const { return FXStream::position(); } /// Move to position virtual FXbool position(FXlong,FXWhence){ return false; } /// Save single items to stream FXGZFileStream& operator<<(const FXuchar& v){ FXStream::operator<<(v); return *this; } FXGZFileStream& operator<<(const FXchar& v){ FXStream::operator<<(v); return *this; } FXGZFileStream& operator<<(const FXbool& v){ FXStream::operator<<(v); return *this; } FXGZFileStream& operator<<(const FXushort& v){ FXStream::operator<<(v); return *this; } FXGZFileStream& operator<<(const FXshort& v){ FXStream::operator<<(v); return *this; } FXGZFileStream& operator<<(const FXuint& v){ FXStream::operator<<(v); return *this; } FXGZFileStream& operator<<(const FXint& v){ FXStream::operator<<(v); return *this; } FXGZFileStream& operator<<(const FXfloat& v){ FXStream::operator<<(v); return *this; } FXGZFileStream& operator<<(const FXdouble& v){ FXStream::operator<<(v); return *this; } FXGZFileStream& operator<<(const FXlong& v){ FXStream::operator<<(v); return *this; } FXGZFileStream& operator<<(const FXulong& v){ FXStream::operator<<(v); return *this; } /// Save arrays of items to stream FXGZFileStream& save(const FXuchar* p,FXuval n){ FXStream::save(p,n); return *this; } FXGZFileStream& save(const FXchar* p,FXuval n){ FXStream::save(p,n); return *this; } FXGZFileStream& save(const FXbool* p,FXuval n){ FXStream::save(p,n); return *this; } FXGZFileStream& save(const FXushort* p,FXuval n){ FXStream::save(p,n); return *this; } FXGZFileStream& save(const FXshort* p,FXuval n){ FXStream::save(p,n); return *this; } FXGZFileStream& save(const FXuint* p,FXuval n){ FXStream::save(p,n); return *this; } FXGZFileStream& save(const FXint* p,FXuval n){ FXStream::save(p,n); return *this; } FXGZFileStream& save(const FXfloat* p,FXuval n){ FXStream::save(p,n); return *this; } FXGZFileStream& save(const FXdouble* p,FXuval n){ FXStream::save(p,n); return *this; } FXGZFileStream& save(const FXlong* p,FXuval n){ FXStream::save(p,n); return *this; } FXGZFileStream& save(const FXulong* p,FXuval n){ FXStream::save(p,n); return *this; } /// Load single items from stream FXGZFileStream& operator>>(FXuchar& v){ FXStream::operator>>(v); return *this; } FXGZFileStream& operator>>(FXchar& v){ FXStream::operator>>(v); return *this; } FXGZFileStream& operator>>(FXbool& v){ FXStream::operator>>(v); return *this; } FXGZFileStream& operator>>(FXushort& v){ FXStream::operator>>(v); return *this; } FXGZFileStream& operator>>(FXshort& v){ FXStream::operator>>(v); return *this; } FXGZFileStream& operator>>(FXuint& v){ FXStream::operator>>(v); return *this; } FXGZFileStream& operator>>(FXint& v){ FXStream::operator>>(v); return *this; } FXGZFileStream& operator>>(FXfloat& v){ FXStream::operator>>(v); return *this; } FXGZFileStream& operator>>(FXdouble& v){ FXStream::operator>>(v); return *this; } FXGZFileStream& operator>>(FXlong& v){ FXStream::operator>>(v); return *this; } FXGZFileStream& operator>>(FXulong& v){ FXStream::operator>>(v); return *this; } /// Load arrays of items from stream FXGZFileStream& load(FXuchar* p,FXuval n){ FXStream::load(p,n); return *this; } FXGZFileStream& load(FXchar* p,FXuval n){ FXStream::load(p,n); return *this; } FXGZFileStream& load(FXbool* p,FXuval n){ FXStream::load(p,n); return *this; } FXGZFileStream& load(FXushort* p,FXuval n){ FXStream::load(p,n); return *this; } FXGZFileStream& load(FXshort* p,FXuval n){ FXStream::load(p,n); return *this; } FXGZFileStream& load(FXuint* p,FXuval n){ FXStream::load(p,n); return *this; } FXGZFileStream& load(FXint* p,FXuval n){ FXStream::load(p,n); return *this; } FXGZFileStream& load(FXfloat* p,FXuval n){ FXStream::load(p,n); return *this; } FXGZFileStream& load(FXdouble* p,FXuval n){ FXStream::load(p,n); return *this; } FXGZFileStream& load(FXlong* p,FXuval n){ FXStream::load(p,n); return *this; } FXGZFileStream& load(FXulong* p,FXuval n){ FXStream::load(p,n); return *this; } /// Save object FXGZFileStream& saveObject(const FXObject* v){ FXStream::saveObject(v); return *this; } /// Load object FXGZFileStream& loadObject(FXObject*& v){ FXStream::loadObject(v); return *this; } /// Load object template FXGZFileStream& operator>>(TYPE*& obj){ return loadObject(reinterpret_cast(obj)); } /// Save object template FXGZFileStream& operator<<(const TYPE* obj){ return saveObject(static_cast(obj)); } /// Clean up virtual ~FXGZFileStream(); }; } #endif #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXGauge.h000066400000000000000000000165071455751074500221310ustar00rootroot00000000000000/******************************************************************************** * * * G a u g e W i d g e t * * * ********************************************************************************* * Copyright (C) 2010,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXGAUGE_H #define FXGAUGE_H #ifndef FXFRAME_H #include "FXFrame.h" #endif ////////////////////////////// UNDER DEVELOPMENT ////////////////////////////// namespace FX { /// Gauge styles enum { GAUGE_NORMAL = 0, /// Normal gauge style GAUGE_PIVOT_CENTER = 0x00008000, /// Gauge pivot in center of widget GAUGE_PIVOT_INSIDE = 0x00010000, /// Keep pivot inside widget GAUGE_ELLIPTICAL = 0x00020000, /// Allow gauge to be elliptical GAUGE_CYCLIC = 0x00040000 /// Dials go around full circle }; /** * Gauge widget. */ class FXAPI FXGauge : public FXFrame { FXDECLARE(FXGauge) protected: struct Indicator { FXdouble radius; // Fraction of dial radius FXdouble ratio; // Ratio of movement FXColor color; // Color FXbool shown; // Whether its shown or not }; protected: FXString caption; // Caption text FXFont *numberFont; // Font for number labels FXFont *captionFont; // Font for centered caption Indicator indicator[3]; // Up to three indicators FXint startAngle; // Start angle of arc (ccw from x-axis) FXint sweepAngle; // Sweep angle of arc (ccw from startAngle) FXdouble range[2]; // Reported data range FXdouble value; // Reported data value FXdouble innerRadius; // Inside radius FXdouble majorTickDelta; // Major tick delta FXdouble minorTickDelta; // Minor tick delta FXColor majorTickColor; // Major tickmark color FXColor minorTickColor; // Major tickmark color FXshort majorTickSize; // Major tick size FXshort minorTickSize; // Minor tick size FXColor faceColor; // Dial face color FXColor arcColor; // Color of arc FXshort arcWeight; // Line weight FXString help; // Help string FXString tip; // Tip string protected: FXGauge(); void drawPointer(FXDCWindow& dc,FXdouble ang,FXint xx,FXint yy,FXint ww,FXint hh,FXint cx,FXint cy,FXint rx,FXint ry,FXint p) const; void drawGauge(FXDCWindow& dc,FXint xx,FXint yy,FXint ww,FXint hh,FXint cx,FXint cy,FXint rx,FXint ry) const; private: FXGauge(const FXGauge&); FXGauge &operator=(const FXGauge&); public: long onPaint(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdSetRealValue(FXObject*,FXSelector,void*); long onCmdGetRealValue(FXObject*,FXSelector,void*); long onCmdSetLongValue(FXObject*,FXSelector,void*); long onCmdGetLongValue(FXObject*,FXSelector,void*); long onCmdSetIntRange(FXObject*,FXSelector,void*); long onCmdGetIntRange(FXObject*,FXSelector,void*); long onCmdSetRealRange(FXObject*,FXSelector,void*); long onCmdGetRealRange(FXObject*,FXSelector,void*); long onCmdSetHelp(FXObject*,FXSelector,void*); long onCmdGetHelp(FXObject*,FXSelector,void*); long onCmdSetTip(FXObject*,FXSelector,void*); long onCmdGetTip(FXObject*,FXSelector,void*); public: /// Construct Gauge widget FXGauge(FXComposite* p,FXuint opts=FRAME_NORMAL,FXint startang=180,FXint sweepang=-180,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Set the text for caption void setCaption(const FXString& text); /// Get the text for caption FXString getCaption() const { return caption; } /// Set start angle in degrees ccw void setStartAngle(FXint degrees); /// Return start angle in degrees ccw FXint getStartAngle() const { return startAngle; } /// Set sweep angle in degrees ccw void setSweepAngle(FXint degrees); /// Return sweep angle in degrees ccw FXint getSweepAngle() const { return sweepAngle; } /// Change current value void setValue(FXdouble v,FXbool notify=false); /// Get current value FXdouble getValue() const { return value; } /// Change the gauge range void setRange(FXdouble lo,FXdouble hi,FXbool notify=false); /// Get the gauge range void getRange(FXdouble& lo,FXdouble& hi) const { lo=range[0]; hi=range[1]; } /// Change major tick space void setMajorTickDelta(FXdouble delta); /// Get major tick space FXdouble getMajorTickDelta() const { return majorTickDelta; } /// Change minor tick space void setMinorTickDelta(FXdouble delta); /// Get minor tick space FXdouble getMinorTickDelta() const { return minorTickDelta; } /// Set the current gauge style void setGaugeStyle(FXuint style); /// Get the gauge style FXuint getGaugeStyle() const; /// Set the number font void setNumberFont(FXFont* fnt); /// Get the number font FXFont* getNumberFont() const { return numberFont; } /// Set the caption font void setCaptionFont(FXFont* fnt); /// Get the caption font FXFont* getCaptionFont() const { return captionFont; } /// Set the help text to be displayed on the status line void setHelpText(const FXString& text){ help=text; } /// Get the current help text const FXString& getHelpText() const { return help; } /// Set the tip text to be displayed in the tooltip void setTipText(const FXString& text){ tip=text; } /// Get the current tooltip text value const FXString& getTipText() const { return tip; } /// Save gauge to a stream virtual void save(FXStream& store) const; /// Load gauge from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXGauge(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXGradientBar.h000066400000000000000000000304371455751074500232610ustar00rootroot00000000000000/******************************************************************************** * * * G r a d i e n t B a r W i d g e t * * * ********************************************************************************* * Copyright (C) 2002,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXGRADIENTBAR_H #define FXGRADIENTBAR_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { /// Gradient bar orientation enum { GRADIENTBAR_HORIZONTAL = 0, /// Gradient bar shown horizontally GRADIENTBAR_VERTICAL = 0x00008000, /// Gradient bar shown vertically GRADIENTBAR_NO_CONTROLS = 0, /// No controls shown GRADIENTBAR_CONTROLS_TOP = 0x00010000, /// Controls on top GRADIENTBAR_CONTROLS_BOTTOM = 0x00020000, /// Controls on bottom GRADIENTBAR_CONTROLS_LEFT = GRADIENTBAR_CONTROLS_TOP, /// Controls on left GRADIENTBAR_CONTROLS_RIGHT = GRADIENTBAR_CONTROLS_BOTTOM /// Controls on right }; /// Blend modes enum { GRADIENT_BLEND_LINEAR, /// Linear blend GRADIENT_BLEND_POWER, /// Power law blend GRADIENT_BLEND_SINE, /// Sine blend GRADIENT_BLEND_INCREASING, /// Quadratic increasing blend GRADIENT_BLEND_DECREASING /// Quadratic decreasing blend }; // Gradient segment struct FXGradient { FXdouble lower; /// Lower value FXdouble middle; /// Middle value FXdouble upper; /// Upper value FXColor lowerColor; /// Lower color FXColor upperColor; /// Upper color FXuchar blend; /// Blend method }; class FXImage; /** * The gradient bar is a control that is used to edit color gradient, * such as used in texture mapping and shape filling. */ class FXAPI FXGradientBar : public FXFrame { FXDECLARE(FXGradientBar) protected: FXImage *bar; // Image containing colors FXGradient *seg; // Segments FXint nsegs; // Number of segments FXint sellower; // Lower selected segment FXint selupper; // Upper selected segment FXint dropped; // Dropped segment FXint current; // Current segment FXint anchor; // Anchor segment FXint grip; // Grip being dragged, if any FXint where; // Where dropped in segment FXint barsize; // Bar size FXint controlsize; // Size of control FXColor selectColor; // Select color FXString tip; // Tooltip value FXString help; // Help value FXint offset; // Offset protected: FXGradientBar(); void updatebar(); FXdouble getValue(FXint x,FXint y) const; FXint getSegmentLowerPos(FXint sg) const; FXint getSegmentUpperPos(FXint sg) const; FXint getSegmentMiddlePos(FXint sg) const; void drawUpArrow(FXDCWindow& dc,FXint x,FXint y,FXColor clr); void drawDnArrow(FXDCWindow& dc,FXint x,FXint y,FXColor clr); void drawRtArrow(FXDCWindow& dc,FXint x,FXint y,FXColor clr); void drawLtArrow(FXDCWindow& dc,FXint x,FXint y,FXColor clr); void drawBottomArrows(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawTopArrows(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawLeftArrows(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawRightArrows(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); static FXdouble blendlinear(FXdouble middle,FXdouble pos); static FXdouble blendpower(FXdouble middle,FXdouble pos); static FXdouble blendsine(FXdouble middle,FXdouble pos); static FXdouble blendincreasing(FXdouble middle,FXdouble pos); static FXdouble blenddecreasing(FXdouble middle,FXdouble pos); static const FXGradient defaultGradient[3]; private: FXGradientBar(const FXGradientBar&); FXGradientBar &operator=(const FXGradientBar&); public: enum { GRIP_NONE, GRIP_LOWER, GRIP_SEG_LOWER, GRIP_MIDDLE, GRIP_SEG_UPPER, GRIP_UPPER }; public: long onPaint(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onRightBtnPress(FXObject*,FXSelector,void*); long onRightBtnRelease(FXObject*,FXSelector,void*); long onDNDEnter(FXObject*,FXSelector,void*); long onDNDLeave(FXObject*,FXSelector,void*); long onDNDMotion(FXObject*,FXSelector,void*); long onDNDDrop(FXObject*,FXSelector,void*); long onCmdBlending(FXObject*,FXSelector,void*); long onUpdBlending(FXObject*,FXSelector,void*); long onUpdSegColor(FXObject*,FXSelector,void*); long onCmdSegColor(FXObject*,FXSelector,void*); long onUpdRecenter(FXObject*,FXSelector,void*); long onCmdRecenter(FXObject*,FXSelector,void*); long onUpdSplit(FXObject*,FXSelector,void*); long onCmdSplit(FXObject*,FXSelector,void*); long onUpdMerge(FXObject*,FXSelector,void*); long onCmdMerge(FXObject*,FXSelector,void*); long onUpdUniform(FXObject*,FXSelector,void*); long onCmdUniform(FXObject*,FXSelector,void*); long onCmdReset(FXObject*,FXSelector,void*); long onCmdSetHelp(FXObject*,FXSelector,void*); long onCmdGetHelp(FXObject*,FXSelector,void*); long onCmdSetTip(FXObject*,FXSelector,void*); long onCmdGetTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); public: enum{ ID_LOWER_COLOR=FXFrame::ID_LAST, ID_UPPER_COLOR, ID_BLEND_LINEAR, ID_BLEND_POWER, ID_BLEND_SINE, ID_BLEND_INCREASING, ID_BLEND_DECREASING, ID_RECENTER, ID_SPLIT, ID_MERGE, ID_UNIFORM, ID_RESET, ID_LAST }; public: /// Construct a gradient bar FXGradientBar(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=FRAME_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Create server-side resources virtual void create(); /// Perform layout virtual void layout(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /** * Obtain segment containing location x, y. * Returns -1 if no matching segment was found. */ FXint getSegment(FXint x,FXint y) const; /** * Get the grip in segment sg which is closest to location (x, y), * one of GRIP_LOWER, GRIP_SEG_LOWER, GRIP_MIDDLE, GRIP_SEG_UPPER, * GRIP_UPPER or GRIP_NONE. */ FXint getGrip(FXint sg,FXint x,FXint y) const; /// Return the number of segments FXint getNumSegments() const { return nsegs; } /** * Reset gradients to default color ramp. */ void resetGradients(); /** * Replace the current gradient segments. * The gradient bar makes a copy of the input segments array. */ void setGradients(const FXGradient *segments,FXint nsegments); /** * Return a copy of the gradient segments. * The array of segments is allocated using allocElms() and should be freed * by the caller using freeElms(). */ void getGradients(FXGradient*& segments,FXint& nsegments) const; /// Change current segment void setCurrentSegment(FXint index,FXbool notify=false); /// Return current segment, or -1 if there is no current segment FXint getCurrentSegment() const { return current; } /// Change anchor segment void setAnchorSegment(FXint index); /// Return anchor segment, or -1 if there is no anchor segment FXint getAnchorSegment() const { return anchor; } /// Select segment(s) FXbool selectSegments(FXint fm,FXint to,FXbool notify=false); /// Deselect all segments FXbool deselectSegments(FXbool notify=false); /// Returns true if the specified segment is selected FXbool isSegmentSelected(FXint s) const; /// Set lower color of a segment void setSegmentLowerColor(FXint s,FXColor clr,FXbool notify=false); /// Set upper color of a segment void setSegmentUpperColor(FXint s,FXColor clr,FXbool notify=false); /// Get lower color of a segment FXColor getSegmentLowerColor(FXint s) const; /// Get upper color of a segment FXColor getSegmentUpperColor(FXint s) const; /// Move lower point of segment sg void moveSegmentLower(FXint sg,FXdouble val,FXbool notify=false); /// Move middle point of segment sg void moveSegmentMiddle(FXint sg,FXdouble val,FXbool notify=false); /// Move upper point of segment sg void moveSegmentUpper(FXint sg,FXdouble val,FXbool notify=false); /// Move segments sglo to sghi to new position val void moveSegments(FXint sglo,FXint sghi,FXdouble val,FXbool notify=false); /// Get lower value of segment sg FXdouble getSegmentLower(FXint sg) const; /// Get middle value of segment sg FXdouble getSegmentMiddle(FXint sg) const; /// Get upper value of segment sg FXdouble getSegmentUpper(FXint sg) const; /** * Get gradient ramp. * The ramp argument should be an array of size nramp, which will be * filled with the appropriate color values. */ void gradient(FXColor *ramp,FXint nramp) const; /** * Get blend mode of segment, one of GRADIENT_BLEND_LINEAR, * GRADIENT_BLEND_POWER, GRADIENT_BLEND_SINE, GRADIENT_BLEND_INCREASING, * or GRADIENT_BLEND_DECREASING. */ FXuint getSegmentBlend(FXint s) const; /// Split segment at the midpoint void splitSegments(FXint sglo,FXint sghi,FXbool notify=false); /// Merge segments void mergeSegments(FXint sglo,FXint sghi,FXbool notify=false); /// Make segments uniformly distributed void uniformSegments(FXint sglo,FXint sghi,FXbool notify=false); /// Change blend mode of segment void blendSegments(FXint sglo,FXint sghi,FXuint blend=GRADIENT_BLEND_LINEAR,FXbool notify=false); /// Change control size void setControlSize(FXint cs); /// Get control size FXint getControlSize() const { return controlsize; } /// Change bar size void setBarSize(FXint bs); /// Get bar size FXint getBarSize() const { return barsize; } /// Get the gradient bar style FXuint getBarStyle() const; /// Change the gradient bar style void setBarStyle(FXuint style); /// Set color void setSelectColor(FXColor clr); /// Get color FXColor getSelectColor() const { return selectColor; } /// Set status line help text for this gradient bar void setHelpText(const FXString& text){ help=text; } /// Get status line help text for this gradient bar const FXString& getHelpText() const { return help; } /// Set tool tip message for this gradient bar void setTipText(const FXString& text){ tip=text; } /// Get tool tip message for this gradient bar const FXString& getTipText() const { return tip; } /// Save gradient bar to a stream virtual void save(FXStream& store) const; /// Load gradient bar from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXGradientBar(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXGroupBox.h000066400000000000000000000100421455751074500226320ustar00rootroot00000000000000/******************************************************************************** * * * G r o u p B o x W i n d o w W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXGROUPBOX_H #define FXGROUPBOX_H #ifndef FXPACKER_H #include "FXPacker.h" #endif namespace FX { // Group box options enum { GROUPBOX_TITLE_LEFT = 0, /// Title is left-justified GROUPBOX_TITLE_CENTER = 0x00020000, /// Title is centered GROUPBOX_TITLE_RIGHT = 0x00040000, /// Title is right-justified GROUPBOX_NORMAL = GROUPBOX_TITLE_LEFT }; /** * A group box widget provides a nice raised or sunken border * around a group of widgets, providing a visual delineation. * Typically, a title is placed over the border to provide some * clarification. */ class FXAPI FXGroupBox : public FXPacker { FXDECLARE(FXGroupBox) protected: FXString label; FXFont *font; FXColor textColor; protected: FXGroupBox(); private: FXGroupBox(const FXGroupBox&); FXGroupBox &operator=(const FXGroupBox&); public: long onPaint(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetStringValue(FXObject*,FXSelector,void*); long onCmdGetStringValue(FXObject*,FXSelector,void*); public: /// Construct group box layout manager FXGroupBox(FXComposite* p,const FXString& text,FXuint opts=GROUPBOX_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_SPACING,FXint pr=DEFAULT_SPACING,FXint pt=DEFAULT_SPACING,FXint pb=DEFAULT_SPACING,FXint hs=DEFAULT_SPACING,FXint vs=DEFAULT_SPACING); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Perform layout virtual void layout(); /// Enable the window virtual void enable(); /// Disable the window virtual void disable(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Change group box title text void setText(const FXString& text); /// Return current groupbox title text FXString getText() const { return label; } /// Change group box style void setGroupBoxStyle(FXuint style); /// Return current group box style FXuint getGroupBoxStyle() const; /// Change title font void setFont(FXFont* fnt); /// Return title font FXFont* getFont() const { return font; } /// Change title text color void setTextColor(FXColor clr); /// Return text color FXColor getTextColor() const { return textColor; } /// Save to a stream virtual void save(FXStream& store) const; /// Load from a stream virtual void load(FXStream& store); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXHash.h000066400000000000000000000114601455751074500217550ustar00rootroot00000000000000/******************************************************************************** * * * H a s h T a b l e C l a s s * * * ********************************************************************************* * Copyright (C) 2003,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXHASH_H #define FXHASH_H namespace FX { /** * A hash table for mapping pointers to pointers. * Two special key values are disallowed: NULL and the pointer value (-1L); * NULL is used to designate an unoccupied slot, while (-1L) is used to designate * a formerly occupied slot. */ class FXAPI FXHash { protected: struct Entry { const void *key; void *data; }; protected: Entry *table; protected: // Change size of the table & hash existing contents FXbool no(FXival n); // Change number of used entries void used(FXival u){ ((FXival*)table)[-2]=u; } // Change number of free entries void free(FXival f){ ((FXival*)table)[-3]=f; } // Resize the table to the given size, keeping contents FXbool resize(FXival n); public: /** * Construct empty hash table. */ FXHash(); /** * Construct from another table. */ FXHash(const FXHash& other); /** * Return the total number of slots in the table. */ FXival no() const { return ((FXival*)table)[-1]; } /** * Return number of used slots in the table. */ FXival used() const { return ((FXival*)table)[-2]; } /** * Return number of free slots in the table. */ FXival free() const { return ((FXival*)table)[-3]; } /** * See if hash table is empty */ FXbool empty() const { return ((FXival*)table)[-1]<=1; } /** * Assign from another table. */ FXHash &operator=(const FXHash& other); /** * Adopt table from another; the other table becomes empty. */ FXHash& adopt(FXHash& other); /** * Find position of given key, returning -1 if not found. */ FXival find(const void* ky) const; /** * Check if key is mapped. */ FXbool has(const void* ky) const { return 0<=find(ky); } /** * Return reference to slot assocated with given key. */ void*& at(const void* ky); /** * Return constant reference to slot assocated with given key. */ void *const& at(const void* ky) const; /** * Return reference to slot assocated with given key. */ void*& operator[](const void* ky){ return at(ky); } /** * Return constant reference to slot assocated with given key. */ void *const& operator[](const void* ky) const { return at(ky); } /** * Replace key in table, overwriting the old value if the * given key already exists. Returns the old value of the key. */ void* insert(const void* ky,void* ptr=nullptr){ return swap(ptr,at(ky)); } /** * Remove key from the table. Returns the old value of the key. */ void* remove(const void* ky); /** * Erase entry from table at pos, returning old value. */ void* erase(FXival pos); /** * Return true if slot is not occupied by a key. */ FXbool empty(FXival pos) const { return (table[pos].key==nullptr)||(table[pos].key==(const void*)-1L); } /** * Return key at position pos. */ const void* key(FXival pos) const { return table[pos].key; } /** * Return reference to data pointer at position pos. */ void*& data(FXival pos){ return table[pos].data; } /** * Return constant reference data pointer at position pos. */ void *const& data(FXival pos) const { return table[pos].data; } /** * Clear hash table. */ FXbool clear(); /// Destructor ~FXHash(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXHashOf.h000066400000000000000000000104431455751074500222420ustar00rootroot00000000000000/******************************************************************************** * * * H a s h T a b l e O f P o i n t e r s T o T y p e * * * ********************************************************************************* * Copyright (C) 2003,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXHASHOF_H #define FXHASHOF_H namespace FX { /** * A hash table mapping pointers to KEYTYPE to pointers of VALUETYPE. * Two special key values are disallowed: NULL and the pointer value (-1L); * NULL is used to designate an unoccupied slot, while (-1L) is used to designate * a formerly occupied slot. */ template class FXHashOf : public FXHash { public: /// Default constructor FXHashOf(){} /// Copy constructor FXHashOf(const FXHashOf& other):FXHash(other){} /// Assignment operator FXHashOf& operator=(const FXHashOf& other){ return reinterpret_cast&>(FXHash::operator=(other)); } /// Adopt objects from orig, leaving orig empty FXHashOf& adopt(FXHashOf& other){ return reinterpret_cast&>(FXHash::adopt(other)); } /// Find position of given key, returning -1 if not found. FXival find(KEYTYPE* ky) const { return FXHash::find(ky); } /// Check if key is mapped. FXbool has(KEYTYPE* ky) const { return FXHash::has(ky); } /// Return reference to slot assocated with given key VALUETYPE*& at(KEYTYPE* ky){ return reinterpret_cast(FXHash::at(ky)); } /// Return constant reference to slot assocated with given key VALUETYPE *const& at(KEYTYPE* ky) const { return reinterpret_cast(FXHash::at(ky)); } /// Return reference to slot assocated with given key VALUETYPE*& operator[](KEYTYPE* ky){ return reinterpret_cast(FXHash::at(ky)); } /// Return constant reference to slot assocated with given key VALUETYPE *const& operator[](KEYTYPE* ky) const { return reinterpret_cast(FXHash::at(ky)); } /// Insert association with given key; return old value, if any VALUETYPE* insert(KEYTYPE* ky,VALUETYPE* ptr=nullptr){ return reinterpret_cast(FXHash::insert(ky,ptr)); } /// Remove association with given key; return old value, if any VALUETYPE* remove(KEYTYPE* ky){ return reinterpret_cast(FXHash::remove(ky)); } /// Erase data at pos in the table; return old value, if any VALUETYPE* erase(FXival pos){ return reinterpret_cast(FXHash::erase(pos)); } /// Return key at position pos KEYTYPE* key(FXival pos) const { return reinterpret_cast(FXHash::key(pos)); } /// Return reference to slot at position pos VALUETYPE*& data(FXival pos){ return reinterpret_cast(FXHash::data(pos)); } /// Return constant reference to slot at position pos VALUETYPE *const& data(FXival pos) const { return reinterpret_cast(FXHash::data(pos)); } }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXHeader.h000066400000000000000000000364321455751074500222700ustar00rootroot00000000000000/******************************************************************************** * * * H e a d e r W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXHEADER_H #define FXHEADER_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { class FXIcon; class FXFont; class FXHeader; /// Header style options enum { HEADER_BUTTON = 0x00008000, /// Button style can be clicked HEADER_HORIZONTAL = 0, /// Horizontal header control (default) HEADER_VERTICAL = 0x00010000, /// Vertical header control HEADER_TRACKING = 0x00020000, /// Tracks continuously while moving HEADER_RESIZE = 0x00040000, /// Allow resizing sections HEADER_NORMAL = HEADER_HORIZONTAL|FRAME_NORMAL }; /// Header item class FXAPI FXHeaderItem : public FXObject { FXDECLARE(FXHeaderItem) friend class FXHeader; protected: FXString label; // Text of item FXString tip; // Tooltip of item FXIcon *icon; // Icon of item void *data; // User data pointer FXint size; // Item size FXint pos; // Item position FXuint state; // State flags private: FXHeaderItem(const FXHeaderItem&); FXHeaderItem& operator=(const FXHeaderItem&); protected: FXHeaderItem(){} virtual void draw(const FXHeader* header,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; public: enum{ ARROW_NONE = 0, /// No arrow ARROW_UP = 0x00000001, /// Arrow pointing up ARROW_DOWN = 0x00000002, /// Arrow pointing down PRESSED = 0x00000004, /// Pressed down ICONOWNED = 0x00000008, /// Icon owned by header item RIGHT = 0x00000010, /// Align on right LEFT = 0x00000020, /// Align on left CENTER_X = 0, /// Aling centered horizontally (default) TOP = 0x00000040, /// Align on top BOTTOM = 0x00000080, /// Align on bottom CENTER_Y = 0, /// Aling centered vertically (default) BEFORE = 0x00000100, /// Icon before the text AFTER = 0x00000200, /// Icon after the text ABOVE = 0x00000400, /// Icon above the text BELOW = 0x00000800 /// Icon below the text }; public: /// Construct new item with given text, icon, size, and user-data FXHeaderItem(const FXString& text,FXIcon* ic=nullptr,FXint s=0,void* ptr=nullptr); /// Change item's text label virtual void setText(const FXString& txt); /// Return item's text label const FXString& getText() const { return label; } /// Set the tool tip message for this item void setTipText(const FXString& text){ tip=text; } /// Get the tool tip message for this item const FXString& getTipText() const { return tip; } /// Change item's icon, deleting the old icon if it was owned virtual void setIcon(FXIcon* icn,FXbool owned=false); /// Return item's icon FXIcon* getIcon() const { return icon; } /// Change item's user data void setData(void* ptr){ data=ptr; } /// Get item's user data void* getData() const { return data; } /// Change size void setSize(FXint s){ size=s; } /// Obtain current size FXint getSize() const { return size; } /// Change position void setPos(FXint p){ pos=p; } /// Obtain current position FXint getPos() const { return pos; } /// Change sort direction (ARROW_NONE, ARROW_UP, ARROW_DOWN) void setArrowDir(FXuint dir=ARROW_NONE); /// Return sort direction (ARROW_NONE, ARROW_UP, ARROW_DOWN) FXuint getArrowDir() const; /// Change content justification void setJustify(FXuint justify=LEFT|CENTER_Y); /// Return content justification FXuint getJustify() const; /// Change icon position void setIconPosition(FXuint mode=BEFORE); /// Return icon position FXuint getIconPosition() const; /// Change state to pressed void setPressed(FXbool pressed); /// Return pressed state FXbool isPressed() const; /// Return the item's content width in the header virtual FXint getWidth(const FXHeader* header) const; /// Return the item's content height in the header virtual FXint getHeight(const FXHeader* header) const; /// Create server-side resources virtual void create(); /// Detach from server-side resources virtual void detach(); /// Destroy server-side resources virtual void destroy(); /// Stream serialization virtual void save(FXStream& store) const; virtual void load(FXStream& store); /// Delete item and free icon if owned virtual ~FXHeaderItem(); }; /// Header item numbering function typedef FXString (*FXNumberingFunc)(FXint); /// List of FXHeaderItem's typedef FXObjectListOf FXHeaderItemList; /** * Header control may be placed over a table or list to provide a resizable * captions above a number of columns. * Each caption comprises a label and an optional icon; in addition, an arrow * may be shown to indicate whether the items in that column are sorted, and * if so, whether they are sorted in increasing or decreasing order. * Each caption can be interactively resized. During the resizing, if the * HEADER_TRACKING was specified, the header control sends a SEL_CHANGED message * to its target, with the message data set to the caption number being resized, * of the type FXint. * If the HEADER_TRACKING was not specified the SEL_CHANGED message is sent at * the end of the resizing operation. * Clicking on a caption causes a message of type SEL_COMMAND to be sent to the * target, with the message data set to the caption number being clicked. * A single click on a split causes a message of type SEL_CLICKED to be sent to the * target; a typical response to this message would be to adjust the size of * the split to fit the contents displayed underneath it. * The contents may be scrolled by calling setPosition(). */ class FXAPI FXHeader : public FXFrame { FXDECLARE(FXHeader) protected: FXHeaderItemList items; // Item list FXFont *font; // Text font FXNumberingFunc numbering; // Automatic caption renumbering method FXString help; // Help text FXColor textColor; // Text color FXint pos; // Scroll position FXint active; // Active button FXint activepos; // Position of active item FXint activesize; // Size of active item FXint offset; // Offset where split grabbed protected: FXHeader(); void drawSplit(FXint pos); virtual FXHeaderItem *createItem(const FXString& text,FXIcon* icon,FXint size,void* ptr); private: FXHeader(const FXHeader&); FXHeader &operator=(const FXHeader&); public: long onPaint(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onTipTimer(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); public: /// Generate numbers 1, 2, 3, ... as a function of index 0,1,2,... static FXString decimalNumbering(FXint index); /// Generate letters A, B, C, ... as a function of index 0,1,2,... static FXString alphaNumbering(FXint index); public: /// Construct new header control FXHeader(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=HEADER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Perform layout virtual void layout(); /// Return number of items FXint getNumItems() const { return (FXint)items.no(); } /// Return total size of all items FXint getTotalSize() const; /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Set the current position void setPosition(FXint pos); /// Return the current position FXint getPosition() const { return pos; } /** * Return item-index given coordinate offset, or -1 if coordinate * is before first item in header, or nitems if coordinate is after * last item in header. */ FXint getItemAt(FXint coord) const; /// Return item at given index FXHeaderItem *getItem(FXint index) const; /// Replace the item with a [possibly subclassed] item FXint setItem(FXint index,FXHeaderItem* item,FXbool notify=false); /// Replace items text, icon, and user-data pointer FXint setItem(FXint index,const FXString& text,FXIcon *icon=nullptr,FXint size=0,void* ptr=nullptr,FXbool notify=false); /// Fill header by appending items from array of strings FXint fillItems(const FXchar *const *strings,FXIcon *icon=nullptr,FXint size=0,void* ptr=nullptr,FXbool notify=false); /// Fill header by appending items from array of strings FXint fillItems(const FXString* strings,FXIcon *icon=nullptr,FXint size=0,void* ptr=nullptr,FXbool notify=false); /// Fill header by appending items from newline separated strings FXint fillItems(const FXString& strings,FXIcon *icon=nullptr,FXint size=0,void* ptr=nullptr,FXbool notify=false); /// Insert a new [possibly subclassed] item at the give index FXint insertItem(FXint index,FXHeaderItem* item,FXbool notify=false); /// Insert item at index with given text, icon, and user-data pointer FXint insertItem(FXint index,const FXString& text,FXIcon *icon=nullptr,FXint size=0,void* ptr=nullptr,FXbool notify=false); /// Append a [possibly subclassed] item to the list FXint appendItem(FXHeaderItem* item,FXbool notify=false); /// Append new item with given text and optional icon, and user-data pointer FXint appendItem(const FXString& text,FXIcon *icon=nullptr,FXint size=0,void* ptr=nullptr,FXbool notify=false); /// Prepend a [possibly subclassed] item to the list FXint prependItem(FXHeaderItem* item,FXbool notify=false); /// Prepend new item with given text and optional icon, and user-data pointer FXint prependItem(const FXString& text,FXIcon *icon=nullptr,FXint size=0,void* ptr=nullptr,FXbool notify=false); /// Extract item from list FXHeaderItem* extractItem(FXint index,FXbool notify=false); /// Remove item at index void removeItem(FXint index,FXbool notify=false); /// Remove all items void clearItems(FXbool notify=false); /// Change text label for item at index void setItemText(FXint index,const FXString& text); /// Get text of item at index FXString getItemText(FXint index) const; /// Change tool tip message for item at index void setItemTipText(FXint index,const FXString& text); /// Get tool tip message of item at index FXString getItemTipText(FXint index) const; /// Change icon of item at index void setItemIcon(FXint index,FXIcon* icon,FXbool owned=false); /// Return icon of item at index FXIcon* getItemIcon(FXint index) const; /// Change size of item at index void setItemSize(FXint index,FXint size); /// Return size of item at index FXint getItemSize(FXint index) const; /// Compute offset from the left side of item at index FXint getItemOffset(FXint index) const; /// Change data of item at index void setItemData(FXint index,void* ptr); /// Return data of item at index void* getItemData(FXint index) const; /// Change sort direction (ARROW_NONE, ARROW_UP, ARROW_DOWN) void setArrowDir(FXint index,FXuint dir=FXHeaderItem::ARROW_NONE); /// Return sort direction (ARROW_NONE, ARROW_UP, ARROW_DOWN) FXuint getArrowDir(FXint index) const; /** * Change item justification. Horizontal justification is controlled by passing * FXHeaderItem::RIGHT, FXHeaderItem::LEFT, or FXHeaderItem::CENTER_X. * Vertical justification is controlled by FXHeaderItem::TOP, FXHeaderItem::BOTTOM, * or FXHeaderItem::CENTER_Y. * The default is a combination of FXHeaderItem::LEFT and FXHeaderItem::CENTER_Y. */ void setItemJustify(FXint index,FXuint justify); /// Return item justification FXuint getItemJustify(FXint index) const; /** * Change relative position of icon and text of item. * Passing FXHeaderItem::BEFORE or FXHeaderItem::AFTER places the icon * before or after the text, and passing FXHeaderItem::ABOVE or * FXHeaderItem::BELOW places it above or below the text, respectively. * The default of FXHeaderItem::BEFORE places the icon in front of the text. */ void setItemIconPosition(FXint index,FXuint mode); /// Return relative icon and text position FXuint getItemIconPosition(FXint index) const; /// Changed button item's pressed state void setItemPressed(FXint index,FXbool pressed=true); /// Return true if button item is pressed in FXbool isItemPressed(FXint index) const; /// Scroll to make given item visible void makeItemVisible(FXint index); /// Repaint header at index void updateItem(FXint index) const; /// Change text font void setFont(FXFont* fnt); /// return text font FXFont* getFont() const { return font; } /// Manually renumber captions between fm and to inclusively void renumberCaptions(FXNumberingFunc func,FXint fm=0,FXint to=2147483647); /// Enable auto-renumbering using the given function, or disable it if NULL void setAutoNumbering(FXNumberingFunc func); /// Return auto-renumbering function FXNumberingFunc getAutoNumbering() const { return numbering; } /// Change text color void setTextColor(FXColor clr); /// Return text color FXColor getTextColor() const { return textColor; } /// Set header style options void setHeaderStyle(FXuint style); /// Get header style options FXuint getHeaderStyle() const; /// Set the status line help text for this header void setHelpText(const FXString& text){ help=text; } /// Get the status line help text for this header const FXString& getHelpText() const { return help; } /// Save header to a stream virtual void save(FXStream& store) const; /// Load header from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXHeader(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXHorizontalFrame.h000066400000000000000000000051661455751074500242040ustar00rootroot00000000000000/******************************************************************************** * * * H o r i z o n t a l C o n t a i n e r W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXHORIZONTALFRAME_H #define FXHORIZONTALFRAME_H #ifndef FXPACKER_H #include "FXPacker.h" #endif namespace FX { /** * Horizontal frame layout manager widget is used to automatically * place child-windows horizontally from left-to-right, or right-to-left, * depending on the child window's layout hints. */ class FXAPI FXHorizontalFrame : public FXPacker { FXDECLARE(FXHorizontalFrame) protected: FXHorizontalFrame(){} private: FXHorizontalFrame(const FXHorizontalFrame&); FXHorizontalFrame &operator=(const FXHorizontalFrame&); public: /// Construct a horizontal frame layout manager FXHorizontalFrame(FXComposite *p,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_SPACING,FXint pr=DEFAULT_SPACING,FXint pt=DEFAULT_SPACING,FXint pb=DEFAULT_SPACING,FXint hs=DEFAULT_SPACING,FXint vs=DEFAULT_SPACING); /// Perform layout virtual void layout(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXICOIcon.h000066400000000000000000000062261455751074500223210ustar00rootroot00000000000000/******************************************************************************** * * * I C O I c o n O b j e c t * * * ********************************************************************************* * Copyright (C) 2001,2022 by Janusz Ganczarski. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXICOICON_H #define FXICOICON_H #ifndef FXICON_H #include "FXIcon.h" #endif namespace FX { /// ICO (Microsoft icon format) icon class FXAPI FXICOIcon : public FXIcon { FXDECLARE(FXICOIcon) protected: FXICOIcon(){} private: FXICOIcon(const FXICOIcon&); FXICOIcon &operator=(const FXICOIcon&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct icon from memory stream formatted in Microsoft icon format FXICOIcon(FXApp* a,const FXuchar *pix=nullptr,FXColor clr=FXRGB(192,192,192),FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in Microsoft icon format format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in Microsoft icon format format virtual FXbool loadPixels(FXStream& store); /// Destroy icon virtual ~FXICOIcon(); }; #ifndef FXLOADICO #define FXLOADICO /** * Check if stream contains a ICO, return true if so. */ extern FXAPI FXbool fxcheckICO(FXStream& store); /** * Load an ICO (Microsoft icon format) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadICO(FXStream& store,FXColor*& data,FXint& width,FXint& height,FXint& xspot,FXint& yspot); /** * Save an ICO (Microsoft icon format) file to a stream. * If no hot-spot given, save as an ICO instead of a CUR resource. */ extern FXAPI FXbool fxsaveICO(FXStream& store,const FXColor *data,FXint width,FXint height,FXint xspot=-1,FXint yspot=-1); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXICOImage.h000066400000000000000000000062021455751074500224450ustar00rootroot00000000000000/******************************************************************************** * * * I C O I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 2001,2022 by Janusz Ganczarski. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXICOIMAGE_H #define FXICOIMAGE_H #ifndef FXIMAGE_H #include "FXImage.h" #endif namespace FX { /// ICO (Microsoft icon format) graphics file class FXAPI FXICOImage : public FXImage { FXDECLARE(FXICOImage) protected: FXICOImage(){} private: FXICOImage(const FXICOImage&); FXICOImage &operator=(const FXICOImage&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct image from memory stream formatted in Microsoft icon format FXICOImage(FXApp* a,const FXuchar *pix=nullptr,FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in Microsoft icon format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in Microsoft icon format virtual FXbool loadPixels(FXStream& store); /// Destroy image virtual ~FXICOImage(); }; #ifndef FXLOADICO #define FXLOADICO /** * Check if stream contains a ICO, return true if so. */ extern FXAPI FXbool fxcheckICO(FXStream& store); /** * Load an ICO (Microsoft icon format) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadICO(FXStream& store,FXColor*& data,FXint& width,FXint& height,FXint& xspot,FXint& yspot); /** * Save an ICO (Microsoft icon format) file to a stream. * If no hot-spot given, save as an ICO instead of a CUR resource. */ extern FXAPI FXbool fxsaveICO(FXStream& store,const FXColor *data,FXint width,FXint height,FXint xspot=-1,FXint yspot=-1); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXIFFIcon.h000066400000000000000000000055641455751074500223170ustar00rootroot00000000000000/******************************************************************************** * * * I F F I c o n O b j e c t * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXIFFICON_H #define FXIFFICON_H #ifndef FXICON_H #include "FXIcon.h" #endif namespace FX { /** * The IFF Icon provides support for the EA/Amiga Image File Format. */ class FXAPI FXIFFIcon : public FXIcon { FXDECLARE(FXIFFIcon) protected: FXIFFIcon(){} private: FXIFFIcon(const FXIFFIcon&); FXIFFIcon &operator=(const FXIFFIcon&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct an icon from memory stream formatted as IFF format FXIFFIcon(FXApp* a,const FXuchar *pix=nullptr,FXColor clr=FXRGB(192,192,192),FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in IFF format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in IFF format virtual FXbool loadPixels(FXStream& store); /// Destroy virtual ~FXIFFIcon(); }; #ifndef FXLOADIFF #define FXLOADIFF /** * Check if stream contains a IFF, return true if so. */ extern FXAPI FXbool fxcheckIFF(FXStream& store); /** * Load an IFF (EA Image File Format) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadIFF(FXStream& store,FXColor*& data,FXint& width,FXint& height); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXIFFImage.h000066400000000000000000000055451455751074500224500ustar00rootroot00000000000000/******************************************************************************** * * * I F F I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXIFFIMAGE_H #define FXIFFIMAGE_H #ifndef FXIMAGE_H #include "FXImage.h" #endif namespace FX { /** * The IFF Image provides support for the EA/Amiga Image File Format. */ class FXAPI FXIFFImage : public FXImage { FXDECLARE(FXIFFImage) protected: FXIFFImage(){} private: FXIFFImage(const FXIFFImage&); FXIFFImage &operator=(const FXIFFImage&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct an image from memory stream formatted as IFF format FXIFFImage(FXApp* a,const FXuchar *pix=nullptr,FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in IFF format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in IFF format virtual FXbool loadPixels(FXStream& store); /// Destroy virtual ~FXIFFImage(); }; #ifndef FXLOADIFF #define FXLOADIFF /** * Check if stream contains a IFF, return true if so. */ extern FXAPI FXbool fxcheckIFF(FXStream& store); /** * Load an IFF (EA Image File Format) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadIFF(FXStream& store,FXColor*& data,FXint& width,FXint& height); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXINI.h000066400000000000000000000146771455751074500215260ustar00rootroot00000000000000/******************************************************************************** * * * I N I R e a d e r & W r i t e r * * * ********************************************************************************* * Copyright (C) 2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXINI_H #define FXINI_H #ifndef FXPARSEBUFFER_H #include "FXParseBuffer.h" #endif namespace FX { /** * The FXINI class loads or saves an FXVariant to an .INI text file. * The FXVariant structure is subject to some limits: * * - Must be a map of maps, of the form variant[SECTION][KEY] where * SECTION and KEY are both strings. * * - Each KEY maps to boolean, integer, double, or string type, or * be empty (equal to FXVariant::null). * * - The variant tree may contain other items, but only items of the * aforementioned types will be serialized to the .INI file. * * When saving, numeric values are printed with configurable precision; * (default=15 digits which results in minimal information loss for real * numbers). * Values may be arbitrary strings, and this includes any legal UTF8- * encoded value. When saving, strings may be escaped to ensure the * information may be read back in unchanged. The following applies * to when strings are escaped: * * - Escape mode 0: UTF8 characters are passed unescaped. * - Escape mode 1: UTF8 characters are escaped as \xXX. * - Escape mode 2: UTF8 will be escaed using Unicode escape sequences of * the for \uXXXX or \uXXXX\uXXXX (two surrogate-pairs escape codes * for code points exceeding 16 bits). * * The default setting is to allow UTF8 characters in the output. */ class FXAPI FXINI : public FXParseBuffer { public: enum Error { ErrOK, /// No errors ErrSave, /// Unable to save ErrLoad, /// Unable to load ErrToken, /// Illegal token ErrColon, /// Expected colon ':' ErrComma, /// Expected comma ',' ErrBracket, /// Expected closing bracket ErrBrace, /// Expected closing brace ErrQuotes, /// Expected closing quotes ErrQuote, /// Expected closing quote ErrNumber, /// Numeric conversion ErrEnd /// Unexpected end of file }; protected: FXlong offset; // Position from start FXint token; // Current token FXint column; // Current column FXint indent; // Indentation level FXint line; // Line number FXuchar state; // Parse state FXuchar prec; // Numeric precision FXuchar fmt; // Numeric format FXuchar esc; // Escape mode private: FXint next(); Error loadVariant(FXVariant& var); Error saveVariant(const FXVariant& section); Error saveSection(const FXString& str); Error saveEntry(const FXVariant& var); Error saveString(const FXString& str); private: static const FXchar *const errors[]; private: FXINI(const FXINI&); FXINI &operator=(const FXINI&); public: /** * Initialize INI parser. */ FXINI(); /** * Initialize INI parser with buffer of size and direction. * Text location (column, line number, byte offset) is reset. */ FXINI(FXchar* buffer,FXuval sz=8192,Direction d=Load); /** * Open INI parse buffer with given size and direction. * Text location (column, line number, byte offset) is reset. */ FXbool open(FXchar* buffer,FXuval sz=8192,Direction d=Load); /** * Return current line number. */ FXint getLine() const { return line; } /** * Return current column number. */ FXint getColumn() const { return column; } /** * Return offset from begin of file. */ FXlong getOffset() const { return offset; } /** * Load a variant from stream. * Return false if stream wasn't opened for loading, or syntax error. */ Error load(FXVariant& variant); /** * Save a variant to stream. * Return false if stream wasn't opened for saving, or disk was full. */ Error save(const FXVariant& variant); /** * Returns error code for given error. */ static const FXchar* getError(Error err){ return errors[err]; } /** * Floating point output precision control. * This controls the number of significant digits written to * the output. The default is 15. */ void setNumericPrecision(FXint p){ prec=p; } FXint getNumericPrecision() const { return prec; } /** * Floating point output format control. * The format mode is interpreted as follows: * * 0 No exponent. * 1 Exponent. * 2 Output exponent when required. * * The default mode is 2. */ void setNumericFormat(FXint f){ fmt=f; } FXint getNumericFormat() const { return fmt; } /** * Change string escape mode; 0=don't escape unicode in strings; * 1=escape unicode as \xHH, 2=escape UTF8 multi-byte characters * as \uXXXX or \uXXXX\uXXXX. * Default is to escape control characters only. */ void setEscapeMode(FXint e){ esc=e; } FXint getEscapeMode() const { return esc; } /** * Close INI parser. * To permit diagnostics, text location not reset. */ FXbool close(); /** * Close INI parser and clean up. */ virtual ~FXINI(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXINIFile.h000066400000000000000000000051531455751074500223130ustar00rootroot00000000000000/******************************************************************************** * * * I N I F i l e I / O * * * ********************************************************************************* * Copyright (C) 2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXINIFILE_H #define FXINIFILE_H #ifndef FXINI_H #include "FXINI.h" #endif namespace FX { /** * Serialize a variant to or from INI formatted file. */ class FXAPI FXINIFile : public FXINI { private: FXFile file; private: FXINIFile(const FXINIFile&); FXINIFile &operator=(const FXINIFile&); public: /** * Create INI file i/o object. */ FXINIFile(); /** * Create INI file i/o object and open it. */ FXINIFile(const FXString& filename,Direction d=Load,FXuval sz=8192); /** * Open INI file from given handle for direction d. */ FXbool open(const FXString& filename,Direction d=Load,FXuval sz=8192); /// Read at least count bytes into buffer; return bytes available, or -1 for error virtual FXival fill(FXival count); /// Write at least count bytes from buffer; return space available, or -1 for error virtual FXival flush(FXival count); /** * Close INI file and delete buffers. */ FXbool close(); /** * Close INI file. */ virtual ~FXINIFile(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXIO.h000066400000000000000000000162511455751074500214040ustar00rootroot00000000000000/******************************************************************************** * * * A b s t r a c t I / O C l a s s * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXIO_H #define FXIO_H namespace FX { /** * FXIO is a base class for a generic i/o device. * The FXIO implementation provides an endless source or sink of data. * You can use FXIO to tally the number of bytes required to save * something to storage before actually doing so. */ class FXAPI FXIO { public: /// Access modes enum { /// Basic access options NoAccess = 0, /// No access ReadOnly = 1, /// Open for reading WriteOnly = 2, /// Open for writing ReadWrite = ReadOnly|WriteOnly, /// Open for both read and write Append = 4, /// Open for append Truncate = 8, /// Truncate to zero when writing Create = 16, /// Create if it doesn't exist Exclusive = 32, /// Fail if trying to create a file which already exists NonBlocking = 64, /// Non-blocking i/o Executable = 128, /// Executable (memory map) OwnHandle = 256, /// File handle is ours NoAccessTime = 512, /// Don't change access time of file Inheritable = 1024, /// Child process can inherit handle Reading = ReadOnly, /// Normal options for reading Writing = ReadWrite|Create|Truncate /// Normal options for writing }; /// Positioning modes enum { Begin = 0, /// Position from the begin (default) Current = 1, /// Position relative to current position End = 2 /// Position from the end }; /// Permissions enum { /// Other permissions OtherExec = 0x00001, /// Others have execute permission OtherWrite = 0x00002, /// Others have write permisson OtherRead = 0x00004, /// Others have read permission OtherReadWrite = OtherRead|OtherWrite, /// Others have read and write permission OtherFull = OtherReadWrite|OtherExec, /// Others have full access /// Group permissions GroupExec = 0x00008, /// Group has execute permission GroupWrite = 0x00010, /// Group has write permission GroupRead = 0x00020, /// Group has read permission GroupReadWrite = GroupRead|GroupWrite, /// Group has read and write permission GroupFull = GroupReadWrite|GroupExec, /// Group has full access /// Owner permissions OwnerExec = 0x00040, /// Owner has execute permission OwnerWrite = 0x00080, /// Owner has write permission OwnerRead = 0x00100, /// Owner has read permission OwnerReadWrite = OwnerRead|OwnerWrite, /// Owner has read and write permission OwnerFull = OwnerReadWrite|OwnerExec, /// Owner has full access /// Combined permissions AllRead = OtherRead|GroupRead|OwnerRead, /// Read permission for all AllWrite = OtherWrite|GroupWrite|OwnerWrite, /// Write permisson for all AllExec = OtherExec|GroupExec|OwnerExec, /// Execute permission for all AllReadWrite = AllRead|AllWrite, /// Read and write permission for all AllFull = AllReadWrite|AllExec, /// Full access for all /// Other flags Hidden = 0x00200, /// Hidden file Directory = 0x00400, /// Is directory File = 0x00800, /// Is regular file SymLink = 0x01000, /// Is symbolic link /// Special mode bits SetUser = 0x02000, /// Set user id SetGroup = 0x04000, /// Set group id Sticky = 0x08000, /// Sticky bit /// Device special files Character = 0x10000, /// Character device Block = 0x20000, /// Block device Socket = 0x40000, /// Socket device Fifo = 0x80000 /// Fifo device }; /// Error return codes for readBlock() and writeBlock() enum { Error = -1, /// Error in operation Again = -2, /// Try again (for non-blocking handles) Broken = -3 /// Broken pipe or socket }; protected: FXIO(); private: FXIO(const FXIO&); FXIO &operator=(const FXIO&); public: /// Return true if open virtual FXbool isOpen() const; /// Return true if serial access only virtual FXbool isSerial() const; /// Return access mode virtual FXuint mode() const; /// Change access mode of open device virtual FXbool mode(FXuint m); /// Return permissions virtual FXuint perms() const; /// Set permissions virtual FXbool perms(FXuint p); /// Get current file position virtual FXlong position() const; /// Change file position, returning new position from start virtual FXlong position(FXlong offset,FXuint from=FXIO::Begin); /// Read block of bytes, returning number of bytes read virtual FXival readBlock(void* ptr,FXival count); /// Write block of bytes, returning number of bytes written virtual FXival writeBlock(const void* ptr,FXival count); /// Read character FXbool readChar(FXchar& ch); /// Write character FXbool writeChar(FXchar ch); /// Truncate file virtual FXlong truncate(FXlong sz); /// Flush to disk virtual FXbool flush(); /// Test if we're at the end; -1 if error virtual FXint eof(); /// Return size virtual FXlong size(); /// Close handle virtual FXbool close(); /// Destroy and close virtual ~FXIO(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXIOBuffer.h000066400000000000000000000062711455751074500225370ustar00rootroot00000000000000/******************************************************************************** * * * I / O B u f f e r C l a s s * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXIOBUFFER_H #define FXIOBUFFER_H #ifndef FXIO_H #include "FXIO.h" #endif namespace FX { /** * IOBuffer provides a file-interface to a memory-buffer of a given size. */ class FXAPI FXIOBuffer : public FXIO { protected: FXuchar *buffer; // Memory buffer FXuval pointer; // Stream pointer FXuval space; // Space in buffer private: FXIOBuffer(const FXIOBuffer&); FXIOBuffer &operator=(const FXIOBuffer&); public: /// Construct FXIOBuffer(); /// Construct and open FXIOBuffer(FXuchar* ptr,FXuval sz); /// Open buffer virtual FXbool open(FXuchar* ptr,FXuval sz); /// Obtain pointer to buffer FXuchar* data() const { return buffer; } /// Return true if open virtual FXbool isOpen() const; /// Return true if serial access only virtual FXbool isSerial() const; /// Get current buffer position virtual FXlong position() const; /// Change buffer position, returning new position from start virtual FXlong position(FXlong offset,FXuint from=FXIO::Begin); /// Read block of bytes, returning number of bytes read virtual FXival readBlock(void* ptr,FXival count); /// Write block of bytes, returning number of bytes written virtual FXival writeBlock(const void* ptr,FXival count); /// Truncate size of the buffer virtual FXlong truncate(FXlong sz); /// Flush to disk virtual FXbool flush(); /// Test if we're at the end; -1 if error virtual FXint eof(); /// Return size of the buffer virtual FXlong size(); /// Close handle virtual FXbool close(); /// Destroy and close virtual ~FXIOBuffer(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXIODevice.h000066400000000000000000000063601455751074500225240ustar00rootroot00000000000000/******************************************************************************** * * * I / O D e v i c e C l a s s * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXIODEVICE_H #define FXIODEVICE_H #ifndef FXIO_H #include "FXIO.h" #endif namespace FX { /** * FXIODevice manipulates a handle to operating system i/o device, * such as pipes, sockets, or files. */ class FXAPI FXIODevice : public FXIO { protected: FXInputHandle device; private: FXIODevice(const FXIODevice&); FXIODevice &operator=(const FXIODevice&); public: /// Construct FXIODevice(); /// Construct device and attach existing handle h FXIODevice(FXInputHandle h); /// Return handle FXInputHandle handle() const { return device; } /// Return true if open virtual FXbool isOpen() const; /// Return access mode virtual FXuint mode() const; /// Change access mode of open device virtual FXbool mode(FXuint m); /// Return permissions virtual FXuint perms() const; /// Set permissions virtual FXbool perms(FXuint p); /// Attach existing device handle, taking ownership of the handle virtual FXbool attach(FXInputHandle h); /// Detach device handle virtual FXbool detach(); /// Read block of bytes, returning number of bytes read virtual FXival readBlock(void* ptr,FXival count); /// Write block of bytes, returning number of bytes written virtual FXival writeBlock(const void* ptr,FXival count); /// Truncate file virtual FXlong truncate(FXlong sz); /// Flush to disk virtual FXbool flush(); /// Test if we're at the end; -1 if error virtual FXint eof(); /// Return size virtual FXlong size(); /// Close handle virtual FXbool close(); /// Check handle validity static FXbool valid(FXInputHandle hnd); /// Destroy and close virtual ~FXIODevice(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXIcon.h000066400000000000000000000121631455751074500217630ustar00rootroot00000000000000/******************************************************************************** * * * I c o n - O b j e c t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXICON_H #define FXICON_H #ifndef FXIMAGE_H #include "FXImage.h" #endif namespace FX { class FXDC; class FXDCWindow; class FXDrawable; class FXTopWindow; /** * An Icon is an image with two additional server-side resources: a shape * bitmap, which is used to mask those pixels where the background should * be preserved during the drawing, and a etch bitmap, which is used to * draw the icon when it is disabled. */ class FXAPI FXIcon : public FXImage { FXDECLARE(FXIcon) friend class FXDC; friend class FXWindow; friend class FXDCWindow; friend class FXDrawable; friend class FXTopWindow; protected: FXID shape; // Shape pixmap FXID etch; // Etch pixmap FXColor transp; // Transparency color FXshort thresh; // Treshold for etch mask protected: FXIcon(); FXColor guesstransp() const; FXshort guessthresh() const; private: FXIcon(const FXIcon&); FXIcon &operator=(const FXIcon&); public: /** * Create an icon with an initial pixel buffer pix, a transparent color clr, * and options as in FXImage. The transparent color is used to determine which * pixel values are transparent, i.e. need to be masked out in the absence of * a true alpha channel. * If the flag IMAGE_OPAQUE is passed, the shape and etch bitmaps are generated * as if the image is fully opaque, even if it has an alpha channel or transparancy * color. The flag IMAGE_ALPHACOLOR is used to force a specific alpha color instead * of the alpha channel obtained from the image file. * Specifying IMAGE_ALPHAGUESS causes Icon to obtain the alpha color from the background * color of the image; it has the same effect as IMAGE_ALPHACOLOR in the sense that * the icon will be transparent for those colors matching the alpha color. */ FXIcon(FXApp* a,const FXColor *pix=nullptr,FXColor clr=0,FXuint opts=0,FXint w=1,FXint h=1); /** * Create the server side pixmap, the shape bitmap, and the etch bitmap, then * call render() to fill it with the pixel data from the client-side buffer. After * the server-side pixmap and bitmaps have been created, the client-side pixel * buffer will be deleted unless IMAGE_KEEP has been specified. If the pixel buffer * is not owned, i.e. the flag IMAGE_OWNED is not set, the pixel buffer will not * be deleted; however the pixel buffer will be set to NULL. */ virtual void create(); /** * Detach the server side pixmap, shape bitmap, and etch bitmap from the Icon. * Afterwards, the Icon is left as if it never had a server-side resources. */ virtual void detach(); /** * Destroy the server-side pixmap and the shape bitmap and etch bitmap. * The client-side pixel buffer is not affected. */ virtual void destroy(); /** * Render the server-side pixmap, shape bitmap and etch bitmap for the icon * from the client-side pixel buffer. */ virtual void render(); /** * Resize both client-side and server-side representations (if any) to the * given width and height. The new representations typically contain garbage * after this operation and need to be re-filled. */ virtual void resize(FXint w,FXint h); /// Get transparency color FXColor getTransparentColor() const { return transp; } /// Change transparency color void setTransparentColor(FXColor color){ transp=color; } /// Get threshold value FXshort getThresholdValue() const { return thresh; } /// Change threshold value void setThresholdValue(FXshort value){ thresh=value; } /// Destructor virtual ~FXIcon(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXIconCache.h000066400000000000000000000111251455751074500227040ustar00rootroot00000000000000/******************************************************************************** * * * I c o n C a c h e * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXICONCACHE_H #define FXICONCACHE_H #ifndef FXOBJECT_H #include "FXObject.h" #endif namespace FX { // Forward declarations class FXIcon; class FXIconSource; // Dictionary of icons typedef FXDictionaryOf FXIconDictionary; /** * The Icon Cache manages a collection of icons. The icons are referenced * by their file name. When first encountering a new file name, the icon is * located by searching the icon search path for the icon file. If found, the * services of the Icon Source object are used to load the icon from the file. * A custom Icon Source may be installed to furnish support for additonal * image file formats. * Once the icon is loaded, an association between the icon name and the icon * is entered into the Icon Dictionary. Subsequent searches for an icon with * this name will be satisfied from the cached value. * The lifetype of the icons is managed by the Icon Cache, and thus all * icons will be deleted when the Icon Cache itself is deleted. */ class FXAPI FXIconCache : public FXObject { FXDECLARE(FXIconCache) private: FXApp *app; // Application object FXIconSource *loader; // Icon source loads the icons FXIconDictionary dict; // Map filename to icon resource FXString path; // Paths to search for icons protected: FXIconCache(); private: FXIconCache(const FXIconCache&); FXIconCache &operator=(const FXIconCache&); public: /// Default icon search path static const FXchar defaultIconPath[]; public: /** * Construct Icon Cache, and set initial search path; also * sets a pointer to the default icon source object. */ FXIconCache(FXApp* ap,const FXString& sp=defaultIconPath); /// Get application FXApp* getApp() const { return app; } /// Change icon source void setIconSource(FXIconSource* src){ loader=src; } /// Return icon source FXIconSource* getIconSource() const { return loader; } /// Set the icon search paths void setIconPath(const FXString& p){ path=p; } /// Return the current icon search paths const FXString& getIconPath() const { return path; } /// Insert icon into cache, load it from file if not already cached. FXIcon* insert(const FXchar* name); /// Insert icon into cache, load it from file if not already cached. FXIcon* insert(const FXString& name){ return insert(name.text()); } /// Find icon by name, return NULL if no icon found in cache FXIcon* find(const FXchar* name) const { return dict.at(name); } /// Find icon by name, return NULL if no icon found in cache FXIcon* find(const FXString& name) const { return dict.at(name); } /// Remove icon from cache and delete it void remove(const FXchar* name); /// Remove icon from cache void remove(const FXString& name){ remove(name.text()); } /// Delete all icons void clear(); /// Save object to stream virtual void save(FXStream& store) const; /// Load object from stream virtual void load(FXStream& store); /// Delete everything virtual ~FXIconCache(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXIconList.h000066400000000000000000000543621455751074500226260ustar00rootroot00000000000000/******************************************************************************** * * * I c o n L i s t W i d g e t * * * ********************************************************************************* * Copyright (C) 1999,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXICONLIST_H #define FXICONLIST_H #ifndef FXSCROLLAREA_H #include "FXScrollArea.h" #endif namespace FX { /// Icon list styles enum { ICONLIST_EXTENDEDSELECT = 0, /// Extended selection mode ICONLIST_SINGLESELECT = 0x00100000, /// At most one selected item ICONLIST_BROWSESELECT = 0x00200000, /// Always exactly one selected item ICONLIST_MULTIPLESELECT = 0x00300000, /// Multiple selection mode ICONLIST_AUTOSIZE = 0x00400000, /// Automatically size item spacing ICONLIST_DETAILED = 0, /// List mode ICONLIST_MINI_ICONS = 0x00800000, /// Mini Icon mode ICONLIST_BIG_ICONS = 0x01000000, /// Big Icon mode ICONLIST_ROWS = 0, /// Row-wise mode ICONLIST_COLUMNS = 0x02000000, /// Column-wise mode ICONLIST_NORMAL = ICONLIST_EXTENDEDSELECT }; class FXIcon; class FXHeader; class FXFont; class FXIconList; class FXFileList; /// Icon item class FXAPI FXIconItem : public FXObject { FXDECLARE(FXIconItem) friend class FXIconList; friend class FXFileList; protected: FXString label; // Text of item FXIcon *bigIcon; // Big icon shown in big icon mode FXIcon *miniIcon; // Mini icon shown in mini icon mode FXptr data; // User data pointer FXuint state; // State flags private: FXIconItem(const FXIconItem&); FXIconItem& operator=(const FXIconItem&); protected: FXIconItem():bigIcon(nullptr),miniIcon(nullptr),data(nullptr),state(0){} virtual void draw(const FXIconList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; virtual FXint hitItem(const FXIconList* list,FXint rx,FXint ry,FXint rw=1,FXint rh=1) const; protected: virtual void drawBigIcon(const FXIconList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; virtual void drawMiniIcon(const FXIconList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; virtual void drawDetails(const FXIconList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; public: enum { SELECTED = 1, /// Selected FOCUS = 2, /// Focus DISABLED = 4, /// Disabled DRAGGABLE = 8, /// Draggable BIGICONOWNED = 16, /// Big icon owned by item MINIICONOWNED = 32 /// Mini icon owned by item }; public: /// Construct new item with given text, icons, and user-data FXIconItem(const FXString& text,FXIcon* bi=nullptr,FXIcon* mi=nullptr,FXptr ptr=nullptr):label(text),bigIcon(bi),miniIcon(mi),data(ptr),state(0){} /// Change item's text label virtual void setText(const FXString& txt); /// Return item's text label const FXString& getText() const { return label; } /// Change item's big icon, deleting the old icon if it was owned virtual void setBigIcon(FXIcon* icn,FXbool owned=false); /// Return item's big icon FXIcon* getBigIcon() const { return bigIcon; } /// Change item's mini icon, deleting the old icon if it was owned virtual void setMiniIcon(FXIcon* icn,FXbool owned=false); /// Return item's mini icon FXIcon* getMiniIcon() const { return miniIcon; } /// Change item's user data void setData(FXptr ptr){ data=ptr; } /// Get item's user data FXptr getData() const { return data; } /// Make item draw as focused virtual void setFocus(FXbool focus); /// Return true if item has focus FXbool hasFocus() const { return (state&FOCUS)!=0; } /// Select item virtual void setSelected(FXbool selected); /// Return true if this item is selected FXbool isSelected() const { return (state&SELECTED)!=0; } /// Enable or disable item virtual void setEnabled(FXbool enabled); /// Return true if this item is enabled FXbool isEnabled() const { return (state&DISABLED)==0; } /// Make item draggable virtual void setDraggable(FXbool draggable); /// Return true if this item is draggable FXbool isDraggable() const { return (state&DRAGGABLE)!=0; } /// Return tip text virtual FXString getTipText() const; /// Return width of item as drawn in list virtual FXint getWidth(const FXIconList* list) const; /// Return height of item as drawn in list virtual FXint getHeight(const FXIconList* list) const; /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Destroy server-side resources virtual void destroy(); /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destroy item and free icons if owned virtual ~FXIconItem(); }; /// Icon item collate function typedef FXint (*FXIconListSortFunc)(const FXIconItem*,const FXIconItem*); /// List of FXIconItem's typedef FXObjectListOf FXIconItemList; /** * A Icon List Widget displays a list of items, each with a text and * optional icon. Icon List can display its items in essentially three * different ways; in big-icon mode, the bigger of the two icons is used * for each item, and the text is placed underneath the icon. In mini- * icon mode, the icons are listed in rows and columns, with the smaller * icon preceding the text. Finally, in detail mode the icons are listed * in a single column, and all fields of the text are shown under a * header control with one button for each subfield. * When an item's selected state changes, the icon list sends * a SEL_SELECTED or SEL_DESELECTED message. A change of the current * item is signified by the SEL_CHANGED message. * The icon list sends SEL_COMMAND messages when the user clicks on an item, * and SEL_CLICKED, SEL_DOUBLECLICKED, and SEL_TRIPLECLICKED when the user * clicks once, twice, or thrice, respectively. * When items are inserted or removed, the icon list sends messages * of the type SEL_INSERTED or SEL_DELETED. * In each of these cases, the index to the item, if any, is passed in the * 3rd argument of the message. * The text in each item is a string separated by tabs for each column; * in mini- or big-icon mode, only the text before the first tab is shown. * In detail-mode, the text before the first tab is shown in the first column, * the text between the first and second tab is shown in the second column, * and so on. */ class FXAPI FXIconList : public FXScrollArea { FXDECLARE(FXIconList) protected: FXHeader *header; // Header control FXIconItemList items; // Item list FXint nrows; // Number of rows FXint ncols; // Number of columns FXint anchor; // Anchor item FXint current; // Current item FXint extent; // Extent item FXint viewable; // Visible item FXFont *font; // Font FXIconListSortFunc sortfunc; // Item sort function FXColor textColor; // Text color FXColor selbackColor; // Selected back color FXColor seltextColor; // Selected text color FXint itemSpace; // Space for item label FXint itemWidth; // Item width FXint itemHeight; // Item height FXint anchorx; // Rectangular selection FXint anchory; FXint currentx; FXint currenty; FXint grabx; // Grab point x FXint graby; // Grab point y FXString lookup; // Lookup string FXString help; // Help text FXbool state; // State of item protected: FXIconList(); void recompute(); void startLasso(FXint ax,FXint ay); void updateLasso(FXint cx,FXint cy); void endLasso(); void getrowscols(FXint& nr,FXint& nc,FXint w,FXint h) const; void lassoChanged(FXint ox,FXint oy,FXint ow,FXint oh,FXint nx,FXint ny,FXint nw,FXint nh,FXbool notify); virtual void moveContents(FXint x,FXint y); virtual FXIconItem *createItem(const FXString& text,FXIcon *big,FXIcon* mini,FXptr ptr); static FXint compareSection(const FXchar *p,const FXchar* q,FXint s); static FXint compareSectionCase(const FXchar *p,const FXchar* q,FXint s); private: FXIconList(const FXIconList&); FXIconList &operator=(const FXIconList&); public: long onPaint(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onRightBtnPress(FXObject*,FXSelector,void*); long onRightBtnRelease(FXObject*,FXSelector,void*); long onMouseWheel(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onTipTimer(FXObject*,FXSelector,void*); long onCmdSelectAll(FXObject*,FXSelector,void*); long onCmdDeselectAll(FXObject*,FXSelector,void*); long onCmdSelectInverse(FXObject*,FXSelector,void*); long onCmdArrangeByRows(FXObject*,FXSelector,void*); long onUpdArrangeByRows(FXObject*,FXSelector,void*); long onCmdArrangeByColumns(FXObject*,FXSelector,void*); long onUpdArrangeByColumns(FXObject*,FXSelector,void*); long onCmdShowDetails(FXObject*,FXSelector,void*); long onUpdShowDetails(FXObject*,FXSelector,void*); long onCmdShowBigIcons(FXObject*,FXSelector,void*); long onUpdShowBigIcons(FXObject*,FXSelector,void*); long onCmdShowMiniIcons(FXObject*,FXSelector,void*); long onUpdShowMiniIcons(FXObject*,FXSelector,void*); long onChgHeader(FXObject*,FXSelector,void*); long onClkHeader(FXObject*,FXSelector,void*); long onFocusIn(FXObject*,FXSelector,void*); long onFocusOut(FXObject*,FXSelector,void*); long onClicked(FXObject*,FXSelector,void*); long onDoubleClicked(FXObject*,FXSelector,void*); long onTripleClicked(FXObject*,FXSelector,void*); long onCommand(FXObject*,FXSelector,void*); long onAutoScroll(FXObject*,FXSelector,void*); long onLookupTimer(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); public: static FXint ascending(const FXIconItem* a,const FXIconItem* b); static FXint descending(const FXIconItem* a,const FXIconItem* b); static FXint ascendingCase(const FXIconItem* a,const FXIconItem* b); static FXint descendingCase(const FXIconItem* a,const FXIconItem* b); public: enum { ID_LOOKUPTIMER=FXScrollArea::ID_LAST, ID_HEADER, ID_SHOW_DETAILS, ID_SHOW_MINI_ICONS, ID_SHOW_BIG_ICONS, ID_ARRANGE_BY_ROWS, ID_ARRANGE_BY_COLUMNS, ID_SELECT_ALL, ID_DESELECT_ALL, ID_SELECT_INVERSE, ID_LAST }; public: /// Construct icon list with no items in it initially FXIconList(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=ICONLIST_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Recalculate layout virtual void recalc(); /// Perform layout virtual void layout(); /// Compute and return content width virtual FXint getContentWidth(); /// Return content height virtual FXint getContentHeight(); /// Return visible area y position virtual FXint getVisibleY() const; /// Return visible area height virtual FXint getVisibleHeight() const; /// Icon list can receive focus virtual FXbool canFocus() const; /// Move the focus to this window virtual void setFocus(); /// Remove the focus from this window virtual void killFocus(); /// Resize this window to the specified width and height virtual void resize(FXint w,FXint h); /// Move and resize this window in the parent's coordinates virtual void position(FXint x,FXint y,FXint w,FXint h); /// Return number of items FXint getNumItems() const { return (FXint)items.no(); } /// Return number of rows FXint getNumRows() const { return nrows; } /// Return number of columns FXint getNumCols() const { return ncols; } /// Return header control FXHeader* getHeader() const { return header; } /// Set headers from array of strings void setHeaders(const FXchar** strings,FXint size=1); /// Set headers from newline separated strings void setHeaders(const FXString& strings,FXint size=1); /// Append header with given text and optional icon void appendHeader(const FXString& text,FXIcon *icon=nullptr,FXint size=1); /// Remove header at index void removeHeader(FXint index); /// Change text of header at index void setHeaderText(FXint index,const FXString& text); /// Return text of header at index FXString getHeaderText(FXint index) const; /// Change icon of header at index void setHeaderIcon(FXint index,FXIcon *icon); /// Return icon of header at index FXIcon* getHeaderIcon(FXint index) const; /// Change size of header at index void setHeaderSize(FXint index,FXint size); /// Return width of header at index FXint getHeaderSize(FXint index) const; /// Return number of headers FXint getNumHeaders() const; /// Return the item at the given index FXIconItem *getItem(FXint index) const; /// Replace the item with a [possibly subclassed] item FXint setItem(FXint index,FXIconItem* item,FXbool notify=false); /// Replace items text, icons, and user-data pointer FXint setItem(FXint index,const FXString& text,FXIcon *big=nullptr,FXIcon* mini=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Fill list by appending items from array of strings FXint fillItems(const FXchar** strings,FXIcon *big=nullptr,FXIcon* mini=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Fill list by appending items from array of strings FXint fillItems(const FXString* strings,FXIcon *big=nullptr,FXIcon* mini=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Fill list by appending items from newline separated strings FXint fillItems(const FXString& strings,FXIcon *big=nullptr,FXIcon* mini=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Insert a new [possibly subclassed] item at the give index FXint insertItem(FXint index,FXIconItem* item,FXbool notify=false); /// Insert item at index with given text, icons, and user-data pointer FXint insertItem(FXint index,const FXString& text,FXIcon *big=nullptr,FXIcon* mini=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Append a [possibly subclassed] item to the end of the list FXint appendItem(FXIconItem* item,FXbool notify=false); /// Append new item with given text and optional icons, and user-data pointer FXint appendItem(const FXString& text,FXIcon *big=nullptr,FXIcon* mini=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Prepend a [possibly subclassed] item to the end of the list FXint prependItem(FXIconItem* item,FXbool notify=false); /// Prepend new item with given text and optional icons, and user-data pointer FXint prependItem(const FXString& text,FXIcon *big=nullptr,FXIcon* mini=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Move item from oldindex to newindex FXint moveItem(FXint newindex,FXint oldindex,FXbool notify=false); /// Extract item from list FXIconItem* extractItem(FXint index,FXbool notify=false); /// Remove item from list void removeItem(FXint index,FXbool notify=false); /// Remove all items from list void clearItems(FXbool notify=false); /// Return item width FXint getItemWidth() const { return itemWidth; } /// Return item height FXint getItemHeight() const { return itemHeight; } /// Return index of item at x,y, or -1 if none virtual FXint getItemAt(FXint x,FXint y) const; /** * Search items by name, beginning from item start. If the start * item is -1 the search will start at the first item in the list. * Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control the * search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP * to control whether the search wraps at the start or end of the list. * The option SEARCH_IGNORECASE causes a case-insensitive match. Finally, * passing SEARCH_PREFIX causes searching for a prefix of the item name. * Return -1 if no matching item is found. */ FXint findItem(const FXString& string,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; /** * Search items by associated user data, beginning from item start. If the * start item is -1 the search will start at the first item in the list. * Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control the * search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP * to control whether the search wraps at the start or end of the list. */ FXint findItemByData(FXptr ptr,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; /// Scroll to make item at index visible virtual void makeItemVisible(FXint index); /// Change item text void setItemText(FXint index,const FXString& text); /// Return item text FXString getItemText(FXint index) const; /// Change item big icon void setItemBigIcon(FXint index,FXIcon* icon,FXbool owned=false); /// Return big icon of item at index FXIcon* getItemBigIcon(FXint index) const; /// Change item mini icon void setItemMiniIcon(FXint index,FXIcon* icon,FXbool owned=false); /// Return mini icon of item at index FXIcon* getItemMiniIcon(FXint index) const; /// Change item user-data pointer void setItemData(FXint index,FXptr ptr); /// Return item user-data pointer FXptr getItemData(FXint index) const; /// Return true if item at index is selected FXbool isItemSelected(FXint index) const; /// Return true if item at index is current FXbool isItemCurrent(FXint index) const; /// Return true if item at index is visible FXbool isItemVisible(FXint index) const; /// Return true if item at index is enabled FXbool isItemEnabled(FXint index) const; /// Return item hit code: 0 outside, 1 icon, 2 text FXint hitItem(FXint index,FXint x,FXint y,FXint ww=1,FXint hh=1) const; /// Repaint item at index void updateItem(FXint index) const; /// Enable item at index virtual FXbool enableItem(FXint index); /// Disable item at index virtual FXbool disableItem(FXint index); /// Select item at index virtual FXbool selectItem(FXint index,FXbool notify=false); /// Deselect item at index virtual FXbool deselectItem(FXint index,FXbool notify=false); /// Toggle item at index virtual FXbool toggleItem(FXint index,FXbool notify=false); /// Select items in rectangle virtual FXbool selectInRectangle(FXint x,FXint y,FXint w,FXint h,FXbool notify=false); /// Extend selection from anchor index to index virtual FXbool extendSelection(FXint index,FXbool notify=false); /// Select all items virtual FXbool selectAll(FXbool notify=false); /// Deselect all items virtual FXbool killSelection(FXbool notify=false); /// Change current item index virtual void setCurrentItem(FXint index,FXbool notify=false); /// Return current item index, or -1 if none FXint getCurrentItem() const { return current; } /// Change anchor item index void setAnchorItem(FXint index); /// Return anchor item index, or -1 if none FXint getAnchorItem() const { return anchor; } /// Sort items void sortItems(); /// Return sort function FXIconListSortFunc getSortFunc() const { return sortfunc; } /// Change sort function void setSortFunc(FXIconListSortFunc func){ sortfunc=func; } /// Change text font void setFont(FXFont* fnt); /// Return text font FXFont* getFont() const { return font; } /// Return normal text color FXColor getTextColor() const { return textColor; } /// Change normal text color void setTextColor(FXColor clr); /// Return selected text background FXColor getSelBackColor() const { return selbackColor; } /// Change selected text background void setSelBackColor(FXColor clr); /// Return selected text color FXColor getSelTextColor() const { return seltextColor; } /// Change selected text color void setSelTextColor(FXColor clr); /// Change maximum item space for each item void setItemSpace(FXint s); /// Return maximum item space FXint getItemSpace() const { return itemSpace; } /// Get the current icon list style FXuint getListStyle() const; /// Set the current icon list style. void setListStyle(FXuint style); /// Set the status line help text for this widget void setHelpText(const FXString& text); /// Get the status line help text for this widget const FXString& getHelpText() const { return help; } /// Save list to a stream virtual void save(FXStream& store) const; /// Load list from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXIconList(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXIconSource.h000066400000000000000000000201201455751074500231340ustar00rootroot00000000000000/******************************************************************************** * * * I c o n S o u r c e * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXICONSOURCE_H #define FXICONSOURCE_H #ifndef FXOBJECT_H #include "FXObject.h" #endif namespace FX { class FXApp; class FXIcon; class FXImage; /** * An icon source is a class that loads an icon of any type. * It exists purely for convenience, to make loading icons simpler by concentrating the * knowledge of the supported icon formats into a single place. * Needless to say, this class is subclassable, allowing users to add additional icon * types and make them available to all widgets which deal with icons. * When icons are loaded, they are NOT created (realized) yet; this allows users to * manipulate the pixel data prior to realizing the icons. * Image/icon formats can be determined by file extension type, or by their contents. * The latter method may be less reliable for some types of file formats which don't * have well-defined file-header signatures. File signature recognition is always * attempted when file extension method fails, as a fallback method. */ class FXAPI FXIconSource : public FXObject { FXDECLARE(FXIconSource) private: FXImage *scaleToSize(FXImage *image,FXint size,FXint qual) const; public: /** * Default icon source provides icons and images for all types built into * the FOX library at compile time. */ static FXIconSource defaultIconSource; /** * Determine icon type from extension string, return icon of that type. * Return NULL if no match. */ virtual FXIcon *iconFromType(FXApp* app,const FXString& type) const; /** * Determine icon type from header bytes in stream, return icon of that type. * Rewind the stream to the start. Return NULL if no match. */ virtual FXIcon *iconFromStream(FXApp* app,FXStream& store) const; /** * Load an icon from the file filename. By default, the file extension is * stripped and used as the icon type; if an explicit icon type is forced, * then that type is used and the extension is ignored. * For example, loadIcon("icon","gif") will try to load a CompuServe GIF * file, since the filename does not give any clue as to the type of the * icon. */ virtual FXIcon *loadIconFile(FXApp* app,const FXString& filename,const FXString& type=FXString::null) const; /** * Load an icon of a given type (e.g. "gif") from reswrapped data. * Returns NULL if there's some error loading the icon. [The optional * parameter is actually mandatory at the time of this writing; future * versions will attempt to inspect the first few bytes of the stream * to divine the icon format if the parameter is omitted]. */ virtual FXIcon *loadIconData(FXApp* app,const FXuchar *pixels,const FXString& type=FXString::null) const; /** * Load an icon of a given type (e.g. "gif") from an already open stream. * Returns NULL if there's some error loading the icon. [The optional * parameter is actually mandatory at the time of this writing; future * versions will attempt to inspect the first few bytes of the stream * to divine the icon format if the parameter is omitted]. */ virtual FXIcon *loadIconStream(FXApp* app,FXStream& store,const FXString& type=FXString::null) const; /** * Determine image type from extension string, return image of that type. * Return NULL if no match. */ virtual FXImage *imageFromType(FXApp* app,const FXString& type) const; /** * Determine image type from header bytes in stream, return image of that type. * Rewind the stream to the start. Return NULL if no match. */ virtual FXImage *imageFromStream(FXApp* app,FXStream& store) const; /** * Load an image from the file filename. By default, the file extension is * stripped and used as the image type; if an explicit image type is forced, * then that type is used and the extension is ignored. * For example, loadImage("image","gif") will try to load a CompuServe GIF * file, since the filename does not give any clue as to the type of the * image. */ virtual FXImage *loadImageFile(FXApp* app,const FXString& filename,const FXString& type=FXString::null) const; /** * Load an image of a given type (e.g. "gif") from reswrapped data. * Returns NULL if there's some error loading the icon. [The optional * parameter is actually mandatory at the time of this writing; future * versions will attempt to inspect the first few bytes of the stream * to divine the icon format if the parameter is omitted]. */ virtual FXImage *loadImageData(FXApp* app,const FXuchar *pixels,const FXString& type=FXString::null) const; /** * Load an image of a given type (e.g. "gif") from an already open stream. * Returns NULL if there's some error loading the image. [The optional * parameter is actually mandatory at the time of this writing; future * versions will attempt to inspect the first few bytes of the stream * to divine the image format if the parameter is omitted]. */ virtual FXImage *loadImageStream(FXApp* app,FXStream& store,const FXString& type=FXString::null) const; /** * Load an icon from filename and scale it such that its dimensions does not exceed given size. * The icon type is determined from the filename extension unless explicitly forced. */ virtual FXIcon *loadScaledIconFile(FXApp* app,const FXString& filename,FXint size=32,FXint qual=0,const FXString& type=FXString::null) const; /** * Load an icon from pixels and scale it such that its dimensions does not exceed given size. */ virtual FXIcon *loadScaledIconData(FXApp* app,const FXuchar *pixels,FXint size=32,FXint qual=0,const FXString& type=FXString::null) const; /** * Load icon from stream and scale it such that its dimensions does not exceed given size. */ virtual FXIcon *loadScaledIconStream(FXApp* app,FXStream& store,FXint size=32,FXint qual=0,const FXString& type=FXString::null) const; /** * Load image from filename and scale it such that its dimensions does not exceed given size. * The image type is determined from the filename extension unless explicitly forced. */ virtual FXImage *loadScaledImageFile(FXApp* app,const FXString& filename,FXint size=32,FXint qual=0,const FXString& type=FXString::null) const; /** * Load image and scale it such that its dimensions does not exceed given size. */ virtual FXImage *loadScaledImageData(FXApp* app,const FXuchar *pixels,FXint size=32,FXint qual=0,const FXString& type=FXString::null) const; /** * Load image and scale it such that its dimensions does not exceed given size. */ virtual FXImage *loadScaledImageStream(FXApp* app,FXStream& store,FXint size=32,FXint qual=0,const FXString& type=FXString::null) const; }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXId.h000066400000000000000000000053221455751074500214260ustar00rootroot00000000000000/******************************************************************************** * * * X - O b j e c t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXID_H #define FXID_H #ifndef FXOBJECT_H #include "FXObject.h" #endif namespace FX { class FXApp; /// Encapsulates server side resource class FXAPI FXId : public FXObject { FXDECLARE_ABSTRACT(FXId) private: FXApp *app; // Back link to application object FXptr data; // User data protected: FXID xid; private: FXId(const FXId&); FXId &operator=(const FXId&); protected: FXId():app((FXApp*)-1L),data(nullptr),xid(0){} FXId(FXApp* a):app(a),data(nullptr),xid(0){} public: /// Get application FXApp* getApp() const { return app; } /// Get XID handle FXID id() const { return xid; } /// Create resource virtual void create(); /// Detach resource virtual void detach(); /// Destroy resource virtual void destroy(); /// Set user data pointer void setUserData(FXptr ptr){ data=ptr; } /// Get user data pointer FXptr getUserData() const { return data; } /// Save object to stream virtual void save(FXStream& store) const; /// Load object from stream virtual void load(FXStream& store); /// Destructor virtual ~FXId(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXImage.h000066400000000000000000000256051455751074500221220ustar00rootroot00000000000000/******************************************************************************** * * * I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXIMAGE_H #define FXIMAGE_H #ifndef FXDRAWABLE_H #include "FXDrawable.h" #endif namespace FX { /// Image rendering hints enum { IMAGE_KEEP = 0x00000001, /// Keep pixel data in client IMAGE_OWNED = 0x00000002, /// Pixel data is owned by image IMAGE_DITHER = 0, /// Dither image to look better IMAGE_NEAREST = 0x00000004, /// Turn off dithering and map to nearest color IMAGE_OPAQUE = 0x00000008, /// Force opaque background IMAGE_ALPHACOLOR = 0x00000010, /// Override transparancy color IMAGE_SHMI = 0x00000020, /// Using shared memory image IMAGE_SHMP = 0x00000040, /// Using shared memory pixmap IMAGE_ALPHAGUESS = 0x00000080, /// Guess transparency color from corners IMAGE_THRESGUESS = 0x00000100 /// Guess threshold for etch mask }; class FXDC; class FXDCWindow; /** * An Image is a rectangular array of pixels. It supports two representations * of these pixels: a client-side pixel buffer which is stored as an array of * FXColor, and a server-side pixmap which is stored in an organization directly * compatible with the screen, for fast drawing onto the device. * The server-side representation is not directly accessible from the current * process as it lives in the process of the X Server or GDI. * Before the image can be used in drawing operations, the server-side representation * of the image must be realized by calling create(); until this is done, only the * client-side pixel buffer exists. * Usually the client-side pixel buffer is released when the server-side representation * is generated [thus saving substantial amounts of memory when only the server-resident * part of the image is of interest]. But if further manipulation of the client-side * pixel buffer is needed, the IMAGE_KEEP option can be passed. In that case, the * client-side buffer can be modified, and the server-side pixmap can be updated by * calling render(). */ class FXAPI FXImage : public FXDrawable { FXDECLARE(FXImage) friend class FXDC; friend class FXDCWindow; protected: FXColor *data; // Pixel data FXuint options; // Options private: #ifdef WIN32 virtual FXID GetDC() const; virtual int ReleaseDC(FXID) const; #else void render_true_32(void *xim,FXuchar *img); void render_true_24(void *xim,FXuchar *img); void render_true_16_fast(void *xim,FXuchar *img); void render_true_16_dither(void *xim,FXuchar *img); void render_true_8_fast(void *xim,FXuchar *img); void render_true_8_dither(void *xim,FXuchar *img); void render_true_N_fast(void *xim,FXuchar *img); void render_true_N_dither(void *xim,FXuchar *img); void render_index_4_fast(void *xim,FXuchar *img); void render_index_4_dither(void *xim,FXuchar *img); void render_index_8_fast(void *xim,FXuchar *img); void render_index_8_dither(void *xim,FXuchar *img); void render_index_N_fast(void *xim,FXuchar *img); void render_index_N_dither(void *xim,FXuchar *img); void render_gray_8_fast(void *xim,FXuchar *img); void render_gray_8_dither(void *xim,FXuchar *img); void render_gray_N_fast(void *xim,FXuchar *img); void render_gray_N_dither(void *xim,FXuchar *img); void render_mono_1_fast(void *xim,FXuchar *img); void render_mono_1_dither(void *xim,FXuchar *img); #endif protected: FXImage(); private: FXImage(const FXImage&); FXImage &operator=(const FXImage&); public: /** * Create an image. If a client-side pixel buffer has been specified, * the image does not own the pixel buffer unless the IMAGE_OWNED flag is * set. If the IMAGE_OWNED flag is set but a NULL pixel buffer is * passed, a pixel buffer will be automatically created and will be owned * by the image. The flags IMAGE_SHMI and IMAGE_SHMP may be specified for * large images to instruct render() to use shared memory to communicate * with the server. */ FXImage(FXApp* a,const FXColor *pix=nullptr,FXuint opts=0,FXint w=1,FXint h=1); /// Change options void setOptions(FXuint opts); /// To get to the option flags FXuint getOptions() const { return options; } /// Set pixel data ownership flag void setOwned(FXbool owned); /// Get pixel data ownership flag FXbool isOwned() const; /** * Populate the image with new pixel data of the same size; it will assume * ownership of the pixel data if image IMAGE_OWNED option is passed. * The server-side representation of the image, if it exists, is not updated. * This can be done by calling render(). */ virtual void setData(FXColor *pix,FXuint opts=0); /** * Populate the image with new pixel data of a new size; it will assume ownership * of the pixel data if image IMAGE_OWNED option is passed. The size of the server- * side representation of the image, if it exists, is adjusted but the contents are * not updated yet. This can be done by calling render(). */ virtual void setData(FXColor *pix,FXuint opts,FXint w,FXint h); /// Return pointer to the pixel data of the image FXColor* getData() const { return data; } /// Get pixel at x,y FXColor getPixel(FXint x,FXint y) const { return data[y*width+x]; } /// Change pixel at x,y void setPixel(FXint x,FXint y,FXColor color){ data[y*width+x]=color; } /// Scan the image and return false if fully opaque FXbool hasAlpha() const; /** * Create the server side pixmap, then call render() to fill it with the * pixel data from the client-side buffer. After the server-side image has * been created, the client-side pixel buffer will be deleted unless * IMAGE_KEEP has been specified. If the pixel buffer is not owned, i.e. * the flag IMAGE_OWNED is not set, the pixel buffer will not be deleted, * however the pixel buffer will be set to NULL. */ virtual void create(); /** * Detach the server side pixmap from the Image. * Afterwards, the Image is left as if it never had a server-side resources. */ virtual void detach(); /** * Destroy the server-side pixmap. * The client-side pixel buffer is not affected. */ virtual void destroy(); /** * Retrieves pixels from the server-side image. For example, to make * screen snapshots, or to retrieve an image after it has been drawn * into by various means. */ virtual void restore(); /** * Render the server-side representation of the image from client-side * pixels. Normally, IMAGE_DITHER is used which causes the server-side * representation to be rendered using a 16x16 ordered dither if necessary; * however if IMAGE_NEAREST is used a faster (but uglier-looking), nearest * neighbor algorithm is used. */ virtual void render(); /** * Release the client-side pixels buffer, free it if it was owned. * If it is not owned, the image just forgets about the buffer. */ virtual void release(); /** * Resize both client-side and server-side representations (if any) to the * given width and height. The new representations typically contain garbage * after this operation and need to be re-filled. */ virtual void resize(FXint w,FXint h); /** * Rescale pixels image to the specified width and height; this calls * resize() to adjust the client and server side representations. */ virtual void scale(FXint w,FXint h,FXint quality=0); /// Mirror image horizontally and/or vertically virtual void mirror(FXbool horizontal,FXbool vertical); /** * Rotate image by degrees ccw; this calls resize() to adjust the client * and server side representations if necessary. */ virtual void rotate(FXint degrees); /** * Crop image to given rectangle; this calls resize() to adjust the client * and server side representations. The new image may be smaller or larger * than the old one; blank areas are filled with color. There must be at * least one pixel of overlap between the old and the new image. */ virtual void crop(FXint x,FXint y,FXint w,FXint h,FXColor color=0); /// Fill image with uniform color virtual void fill(FXColor color); /// Fade image to uniform color virtual void fade(FXColor color,FXint factor=255); /** * Shear image horizontally; the number of pixels is equal to the * shear parameter times 256. The area outside the image is filled * with transparent black, unless another color is specified. */ virtual void xshear(FXint shear,FXColor clr=0); /** * Shear image vertically; the number of pixels is equal to the * shear parameter times 256. The area outside the image is filled * with transparent black, unless another color is specified. */ virtual void yshear(FXint shear,FXColor clr=0); /// Fill horizontal gradient virtual void hgradient(FXColor left,FXColor right); /// Fill vertical gradient virtual void vgradient(FXColor top,FXColor bottom); /// Fill with gradient virtual void gradient(FXColor topleft,FXColor topright,FXColor bottomleft,FXColor bottomright); /// Blend image over uniform color virtual void blend(FXColor color); /// Invert colors of an image virtual void invert(); /// Colorize image based on luminance virtual void colorize(FXColor color); /// Save pixel data only virtual FXbool savePixels(FXStream& store) const; /// Load pixel data only virtual FXbool loadPixels(FXStream& store); /// Save object to stream virtual void save(FXStream& store) const; /// Load object from stream virtual void load(FXStream& store); /// Destructor virtual ~FXImage(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXImageFrame.h000066400000000000000000000061051455751074500230670ustar00rootroot00000000000000/******************************************************************************** * * * I m a g e F r a m e W i d g e t * * * ********************************************************************************* * Copyright (C) 2001,2022 by H. J. Daniel III. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXIMAGEFRAME_H #define FXIMAGEFRAME_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { /** * The image frame is a simple frame widget displaying * an image; the image is not owned by the image frame so * it must be explicitly deleted elsewhere. */ class FXAPI FXImageFrame : public FXFrame { FXDECLARE(FXImageFrame) protected: FXImage* image; // The image being displayed protected: FXImageFrame(); private: FXImageFrame(const FXImageFrame&); FXImageFrame &operator=(const FXImageFrame&); public: long onPaint(FXObject*,FXSelector,void* ptr); public: /// Construct image frame and pass it an image FXImageFrame(FXComposite* p,FXImage *img,FXuint opts=FRAME_SUNKEN|FRAME_THICK,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=0,FXint pr=0,FXint pt=0,FXint pb=0); /// Create window virtual void create(); /// Get default width virtual FXint getDefaultWidth(); /// Get default height virtual FXint getDefaultHeight(); /// Change the image being displayed void setImage(FXImage* img); /// Return the current image FXImage* getImage() const { return image; } /// Set the current justification mode. void setJustify(FXuint mode); /// Get the current justification mode. FXuint getJustify() const; /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destroy the widget, but do not destroy the image virtual ~FXImageFrame(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXImageView.h000066400000000000000000000075571455751074500227630ustar00rootroot00000000000000/******************************************************************************** * * * I m a g e V i e w W i d g e t * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXIMAGEVIEW_H #define FXIMAGEVIEW_H #ifndef FXSCROLLAREA_H #include "FXScrollArea.h" #endif namespace FX { class FXImage; /// Image alignment styles enum { IMAGEVIEW_NORMAL = 0, /// Normal mode is centered IMAGEVIEW_CENTER_X = 0, /// Centered horizontally IMAGEVIEW_LEFT = 0x00100000, /// Left-aligned IMAGEVIEW_RIGHT = 0x00200000, /// Right-aligned IMAGEVIEW_CENTER_Y = 0, /// Centered vertically IMAGEVIEW_TOP = 0x00400000, /// Top-aligned IMAGEVIEW_BOTTOM = 0x00800000 /// Bottom-aligned }; /** * The Image View widget display a scrollable view of an image. */ class FXAPI FXImageView : public FXScrollArea { FXDECLARE(FXImageView) protected: FXImage *image; // Image to view FXint grabx; // Grab point x FXint graby; // Grab point y protected: FXImageView(); private: FXImageView(const FXImageView&); FXImageView &operator=(const FXImageView&); public: long onPaint(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onRightBtnPress(FXObject*,FXSelector,void*); long onRightBtnRelease(FXObject*,FXSelector,void*); public: enum { ID_XYZ=FXScrollArea::ID_LAST, ID_LAST }; public: /// Construct a scroll window FXImageView(FXComposite* p,FXImage* img=nullptr,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Perform layout virtual void layout(); /// Image view widget can receive focus virtual FXbool canFocus() const; /// Return the width of the contents virtual FXint getContentWidth(); /// Return the height of the contents virtual FXint getContentHeight(); /// Change image void setImage(FXImage* img); /// Return image FXImage* getImage() const { return image; } /// Set the current alignment. void setAlignment(FXuint mode); /// Get the current alignment. FXuint getAlignment() const; /// Save list to a stream virtual void save(FXStream& store) const; /// Load list from a stream virtual void load(FXStream& store); /// Destroy virtual ~FXImageView(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXInputDialog.h000066400000000000000000000125771455751074500233230ustar00rootroot00000000000000/******************************************************************************** * * * I n p u t D i a l o g B o x * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXINPUTDIALOG_H #define FXINPUTDIALOG_H #ifndef FXDIALOGBOX_H #include "FXDialogBox.h" #endif namespace FX { /// Input dialog options enum { INPUTDIALOG_STRING = 0, /// Ask for a string INPUTDIALOG_INTEGER = 0x02000000, /// Ask for an integer number INPUTDIALOG_REAL = 0x04000000, /// Ask for a real number INPUTDIALOG_PASSWORD = 0x08000000 /// Do not reveal key-in }; class FXTextField; /** * An Input Dialog is a simple dialog which is used * to obtain a text string, integer, or real number from the user. * A password mode allows the key-in to remain hidden. */ class FXAPI FXInputDialog : public FXDialogBox { FXDECLARE(FXInputDialog) protected: FXTextField *input; // Text field widget FXdouble limlo; // Lower limit FXdouble limhi; // Upper limit protected: FXInputDialog(){} private: FXInputDialog(const FXInputDialog&); FXInputDialog &operator=(const FXInputDialog&); virtual void initialize(const FXString& text,FXIcon* icon); public: long onCmdAccept(FXObject*,FXSelector,void*); public: /// Construct input dialog box with given caption, icon, and prompt text FXInputDialog(FXWindow* owner,const FXString& caption,const FXString& label,FXIcon* icon=nullptr,FXuint opts=INPUTDIALOG_STRING,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Construct free floating input dialog box with given caption, icon, and prompt text FXInputDialog(FXApp* app,const FXString& caption,const FXString& label,FXIcon* icon=nullptr,FXuint opts=INPUTDIALOG_STRING,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Get input string FXString getText() const; /// Set input string void setText(const FXString& text); /// Change number of visible columns of text void setNumColumns(FXint num); /// Return number of visible columns of text FXint getNumColumns() const; /// Change limits void setLimits(FXdouble lo,FXdouble hi){ limlo=lo; limhi=hi; } /// Return limits void getLimits(FXdouble& lo,FXdouble& hi){ lo=limlo; hi=limhi; } /// Run modal invocation of the dialog virtual FXuint execute(FXuint placement=PLACEMENT_CURSOR); /** * Prompt for a string, start with the initial value. * Return true if the new value is accepted, and false otherwise. */ static FXbool getString(FXString& result,FXWindow* owner,const FXString& caption,const FXString& label,FXIcon* icon=nullptr); /** * Prompt for a string, in free floating window. */ static FXbool getString(FXString& result,FXApp* app,const FXString& caption,const FXString& label,FXIcon* icon=nullptr); /** * Prompt for an integer number, start with the given initial value. * Return true if the new value is accepted, and false otherwise. * The input is constrained between lo and hi. */ static FXbool getInteger(FXint& result,FXWindow* owner,const FXString& caption,const FXString& label,FXIcon* icon=nullptr,FXint lo=-2147483647,FXint hi=2147483647); /** * Prompt for a integer number, in free floating window. */ static FXbool getInteger(FXint& result,FXApp* app,const FXString& caption,const FXString& label,FXIcon* icon=nullptr,FXint lo=-2147483647,FXint hi=2147483647); /** * Prompt for an real number, start with the given initial value. * Return true if the new value is accepted, and false otherwise. * The input is constrained between lo and hi. */ static FXbool getReal(FXdouble& result,FXWindow* owner,const FXString& caption,const FXString& label,FXIcon* icon=nullptr,FXdouble lo=-1.797693134862315e+308,FXdouble hi=1.797693134862315e+308); /** * Prompt for a real number, in free floating window. */ static FXbool getReal(FXdouble& result,FXApp* app,const FXString& caption,const FXString& label,FXIcon* icon=nullptr,FXdouble lo=-1.797693134862315e+308,FXdouble hi=1.797693134862315e+308); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXJP2Icon.h000066400000000000000000000063551455751074500223050ustar00rootroot00000000000000/******************************************************************************** * * * J P E G - 2 0 0 0 I c o n O b j e c t * * * ********************************************************************************* * Copyright (C) 2009,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXJP2ICON_H #define FXJP2ICON_H #ifndef FXICON_H #include "FXIcon.h" #endif namespace FX { /// JPEG-2000 Icon class class FXAPI FXJP2Icon : public FXIcon { FXDECLARE(FXJP2Icon) protected: FXint quality; protected: FXJP2Icon(){} private: FXJP2Icon(const FXJP2Icon&); FXJP2Icon &operator=(const FXJP2Icon&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct an icon from memory stream formatted in JPEG-2000 format FXJP2Icon(FXApp *a,const FXuchar *pix=nullptr,FXColor clr=FXRGB(192,192,192),FXuint opts=0,FXint w=1,FXint h=1,FXint q=100); /// True if format is supported static const FXbool supported; /// Set image quality to save with void setQuality(FXint q){ quality=q; } /// Get image quality setting FXint getQuality() const { return quality; } /// Save pixels into stream in JPEG format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in JPEG format virtual FXbool loadPixels(FXStream& store); /// Destroy virtual ~FXJP2Icon(); }; #ifndef FXLOADJP2 #define FXLOADJP2 /** * Check if stream contains a JP2, return true if so. */ extern FXAPI FXbool fxcheckJP2(FXStream& store); /** * Load an JPEG-2000 file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadJP2(FXStream& store,FXColor*& data,FXint& width,FXint& height,FXint& quality); /** * Save an JPEG-2000 file to a stream. */ extern FXAPI FXbool fxsaveJP2(FXStream& store,const FXColor* data,FXint width,FXint height,FXint quality); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXJP2Image.h000066400000000000000000000063361455751074500224360ustar00rootroot00000000000000/******************************************************************************** * * * J P E G - 2 0 0 0 I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 2009,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXJP2IMAGE_H #define FXJP2IMAGE_H #ifndef FXIMAGE_H #include "FXImage.h" #endif namespace FX { /// JPEG-2000 Image class class FXAPI FXJP2Image : public FXImage { FXDECLARE(FXJP2Image) protected: FXint quality; protected: FXJP2Image(){} private: FXJP2Image(const FXJP2Image&); FXJP2Image &operator=(const FXJP2Image&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct an image from memory stream formatted in JPEG-2000 format FXJP2Image(FXApp *a,const FXuchar *pix=nullptr,FXuint opts=0,FXint w=1,FXint h=1,FXint q=100); /// True if format is supported static const FXbool supported; /// Set image quality to save with void setQuality(FXint q){ quality=q; } /// Get image quality setting FXint getQuality() const { return quality; } /// Load pixels from stream in JPEG format virtual FXbool savePixels(FXStream& store) const; /// Save pixels into stream in JPEG format virtual FXbool loadPixels(FXStream& store); /// Destroy virtual ~FXJP2Image(); }; #ifndef FXLOADJP2 #define FXLOADJP2 /** * Check if stream contains a JP2, return true if so. */ extern FXAPI FXbool fxcheckJP2(FXStream& store); /** * Load an JPEG-2000 file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadJP2(FXStream& store,FXColor*& data,FXint& width,FXint& height,FXint& quality); /** * Save an JPEG-2000 file to a stream. */ extern FXAPI FXbool fxsaveJP2(FXStream& store,const FXColor* data,FXint width,FXint height,FXint quality); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXJPGIcon.h000066400000000000000000000064401455751074500223250ustar00rootroot00000000000000/******************************************************************************** * * * J P E G I c o n O b j e c t * * * ********************************************************************************* * Copyright (C) 2000,2022 by David Tyree. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXJPGICON_H #define FXJPGICON_H #ifndef FXICON_H #include "FXIcon.h" #endif namespace FX { /// JPEG Icon class class FXAPI FXJPGIcon : public FXIcon { FXDECLARE(FXJPGIcon) protected: FXint quality; protected: FXJPGIcon(){} private: FXJPGIcon(const FXJPGIcon&); FXJPGIcon &operator=(const FXJPGIcon&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct an icon from memory stream formatted in JPEG format FXJPGIcon(FXApp *a,const FXuchar *pix=nullptr,FXColor clr=FXRGB(192,192,192),FXuint opts=0,FXint w=1,FXint h=1,FXint q=75); /// True if format is supported static const FXbool supported; /// Set image quality to save with void setQuality(FXint q){ quality=q; } /// Get image quality setting FXint getQuality() const { return quality; } /// Save pixels into stream in JPEG format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in JPEG format virtual FXbool loadPixels(FXStream& store); /// Destroy virtual ~FXJPGIcon(); }; #ifndef FXLOADJPG #define FXLOADJPG /** * Check if stream contains a JPG, return true if so. */ extern FXAPI FXbool fxcheckJPG(FXStream& store); /** * Load an JPEG (Joint Photographics Experts Group) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadJPG(FXStream& store,FXColor*& data,FXint& width,FXint& height,FXint& quality); /** * Save an JPEG (Joint Photographics Experts Group) file to a stream. */ extern FXAPI FXbool fxsaveJPG(FXStream& store,const FXColor* data,FXint width,FXint height,FXint quality); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXJPGImage.h000066400000000000000000000064211455751074500224560ustar00rootroot00000000000000/******************************************************************************** * * * J P E G I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 2000,2022 by David Tyree. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXJPGIMAGE_H #define FXJPGIMAGE_H #ifndef FXIMAGE_H #include "FXImage.h" #endif namespace FX { /// JPEG Image class class FXAPI FXJPGImage : public FXImage { FXDECLARE(FXJPGImage) protected: FXint quality; protected: FXJPGImage(){} private: FXJPGImage(const FXJPGImage&); FXJPGImage &operator=(const FXJPGImage&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct an image from memory stream formatted in JPEG format FXJPGImage(FXApp *a,const FXuchar *pix=nullptr,FXuint opts=0,FXint w=1,FXint h=1,FXint q=75); /// True if format is supported static const FXbool supported; /// Set image quality to save with void setQuality(FXint q){ quality=q; } /// Get image quality setting FXint getQuality() const { return quality; } /// Load pixels from stream in JPEG format virtual FXbool savePixels(FXStream& store) const; /// Save pixels into stream in JPEG format virtual FXbool loadPixels(FXStream& store); /// Destroy virtual ~FXJPGImage(); }; #ifndef FXLOADJPG #define FXLOADJPG /** * Check if stream contains a JPG, return true if so. */ extern FXAPI FXbool fxcheckJPG(FXStream& store); /** * Load an JPEG (Joint Photographics Experts Group) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadJPG(FXStream& store,FXColor*& data,FXint& width,FXint& height,FXint& quality); /** * Save an JPEG (Joint Photographics Experts Group) file to a stream. */ extern FXAPI FXbool fxsaveJPG(FXStream& store,const FXColor* data,FXint width,FXint height,FXint quality); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXJSON.h000066400000000000000000000240651455751074500216500ustar00rootroot00000000000000/******************************************************************************** * * * J S O N R e a d e r & W r i t e r * * * ********************************************************************************* * Copyright (C) 2013,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXJSON_H #define FXJSON_H #ifndef FXPARSEBUFFER_H #include "FXParseBuffer.h" #endif namespace FX { /** * The FXJSON serializer loads or saves an FXVariant to a JSON text file. * Since FXVariant can contain an arbitrarily complex data structure, this * provides applications with a convenient way to load and save state information * in a well-defined and human-readable file format. * The base class implements serialization/deserialization to/from an external * buffer. * * Subclasses FXJSONFile and FXJSONString serialize from/to strings and disk- * based files, respectively. * The new JSON5 standard may also be parsed, allowing for single- and multi-line * nested comments to be embedded in the input, and makes quotation of variable * names optional. In addition, JSON5 also allows use of single quotes (') as * well as double quotes ("). * * Syntax errors in the input cause the parser to return an error, and allow * diagnosis of the problem and its location in the file by line number, column * number, and byte-offset from the start of the file. * * When writing a json stream, the generated output may be formatted in different * ways. The flow-mode controls the overall layout of the resulting text output; * when flow is set to Stream, all output is generated with no formatting to * improve human legibility. This is the most space-friendly format possible. * If flow is set to Compact, a human readable, compact format, aiming to * maximize the amount of information on each line is generated. * When flow is set to Pretty, a nicely indented, but extremely "airy" output * results, and the resulting document will contain many, many lines with * little data. * * Numeric values are printed with configurable precision; (default=15 digits * which results in minimal information loss for real numbers). * For Pretty flow format, output may be indented in multiples of the indent * level (default=2). Depending on flow setting, lines may be wrapped at a * maximum number of columns (default=80). * Output strings containing reserved characters may have to be escaped. * For UTF8 characters, there are 3 options for escaping. * * - Escape mode 0: UTF8 characters are passed unescaped. * - Escape mode 1: UTF8 characters are escaped as \xXX. * - Escape mode 2: UTF8 will be escaed using Unicode escape sequences of * the for \uXXXX or \uXXXX\uXXXX (two surrogate-pairs escape codes * for code points exceeding 16 bits). * * The default setting is to allow UTF8 characters in the output, but be aware * that such outputs need UTF8-capable viewer software to be rendered properly. * Finally, in JSON5 mode (version set to 5), variable names may be written as * unquoted strings if their syntax allows for it; in JSON5 mode, single quotes * may be selected to improve human legibility. */ class FXAPI FXJSON : public FXParseBuffer { public: /// JSON deserializer error codes enum Error { ErrOK, /// No errors ErrSave, /// Unable to save ErrLoad, /// Unable to load ErrToken, /// Illegal token ErrColon, /// Expected colon ':' ErrComma, /// Expected comma ',' ErrBracket, /// Expected closing bracket ErrBrace, /// Expected closing brace ErrQuotes, /// Expected closing quotes ErrQuote, /// Expected closing quote ErrNumber, /// Numeric conversion ErrIdent, /// Unexpected identifier ErrEnd /// Unexpected end of file }; /// JSON serializer flow modes enum Flow { Stream, /// Stream-of-consciousness output Compact, /// Compact, human readable output (default) Pretty /// Pretty printed, indented output }; protected: enum Token { TK_ERROR, TK_EOF, TK_COMMA, TK_COLON, TK_IDENT, TK_NAN, TK_INF, TK_NULL, TK_FALSE, TK_TRUE, TK_STRING, TK_PLUS, TK_MINUS, TK_INT, TK_HEX, TK_REAL, TK_LBRACK, TK_LBRACE, TK_RBRACK, TK_RBRACE }; protected: FXString value; // Token value FXlong offset; // Position from start Token token; // Token FXint column; // Column number FXint indent; // Indent level FXint line; // Line number FXint wrap; // Line wrap column FXchar quote; // Quote type used FXuchar flow; // Output flow FXuchar prec; // Float precision FXuchar fmt; // Float format FXuchar esc; // Escape mode FXuchar dent; // Indentation amount FXuchar ver; // Version protected: static const FXchar *const errors[]; protected: virtual Token next(); Token ident(); Token string(); static Token identoken(const FXString& str); Error loadMap(FXVariant& var); Error loadArray(FXVariant& var); Error loadVariant(FXVariant& var); Error saveString(const FXString& str); Error saveIdent(const FXString& str); Error saveMap(const FXVariant& var); Error saveArray(const FXVariant& var); Error saveVariant(const FXVariant& var); private: FXJSON(const FXJSON&); FXJSON &operator=(const FXJSON&); public: /** * Initialize JSON serializer. */ FXJSON(); /** * Initialize JSON serializer with buffer of size and direction. * Text location (column, line number, byte offset) is reset. */ FXJSON(FXchar* buffer,FXuval sz=8192,Direction d=Load); /** * Open JSON parse buffer with given size and direction. * Text location (column, line number, byte offset) is reset. */ FXbool open(FXchar* buffer=nullptr,FXuval sz=8192,Direction d=Load); /** * Return current line number. */ FXint getLine() const { return line; } /** * Return current column number. */ FXint getColumn() const { return column; } /** * Return offset from begin of file. */ FXlong getOffset() const { return offset; } /** * Load a variant from JSON stream. * Return false if stream wasn't opened for loading, or syntax error. */ virtual Error load(FXVariant& variant); /** * Save a variant to JSON stream. * Return false if stream wasn't opened for saving, or disk was full. */ virtual Error save(const FXVariant& variant); /** * Returns error for given error code. */ static const FXchar* getError(Error err){ return errors[err]; } /** * Floating point output precision control. * This controls the number of significant digits written to * the output. The default is 15. */ void setNumericPrecision(FXint p){ prec=p; } FXint getNumericPrecision() const { return prec; } /** * Floating point output format control. * The format mode is interpreted as follows: * * 0 No exponent. * 1 Exponent. * 2 Output exponent when required. * * The default mode is 2. */ void setNumericFormat(FXint f){ fmt=f; } FXint getNumericFormat() const { return fmt; } /** * Change output flow format (Stream, Compact, Pretty). * Stream is the most compact, but pretty much unreadable by humans; it * aims to be compact. * Compact is very human-readable while at the same time using minimum number * of lines to represent the output. * Pretty will print one item on each line, with indentation. It is very easily * readable but produces large numbers of text lines. */ void setOutputFlow(FXint f){ flow=f; } FXint getOutputFlow() const { return flow; } /** * Change indentation level for pretty print flow, the amount of * indentation applied for each level. */ void setIndentation(FXint d){ dent=d; } FXint getIndentation() const { return dent; } /** * Change column at which lines are wrapped. */ void setLineWrap(FXint w){ wrap=w; } FXint getLineWrap() const { return wrap; } /** * Change string escape mode. * The escape mode is interpreted as follows: * * 0 Don't escape unicode in strings; * 1 Escape unicode as \xXX * 2 Escape unicode as \uXXXX or \uXXXX\uXXXX. * * Default is to escape control characters only. */ void setEscapeMode(FXint e){ esc=e; } FXint getEscapeMode() const { return esc; } /** * Change json version. */ void setVersion(FXint v){ ver=v; } FXint getVersion() const { return ver; } /** * Change quote type, either (') or ("). */ void setQuote(FXint q){ quote=q; } FXint getQuote() const { return quote; } /** * Close stream and delete buffer, if owned. * To permit diagnostics, text location not reset. */ FXbool close(); /** * Close JSON stream and clean up. */ virtual ~FXJSON(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXJSONFile.h000066400000000000000000000052001455751074500224360ustar00rootroot00000000000000/******************************************************************************** * * * J S O N F i l e I / O * * * ********************************************************************************* * Copyright (C) 2013,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXJSONFILE_H #define FXJSONFILE_H #ifndef FXJSON_H #include "FXJSON.h" #endif namespace FX { /** * Serialize a variant to or from JSON formatted file. */ class FXAPI FXJSONFile : public FXJSON { private: FXFile file; private: FXJSONFile(const FXJSONFile&); FXJSONFile &operator=(const FXJSONFile&); public: /** * Create JSON file i/o object. */ FXJSONFile(); /** * Create JSON file i/o object and open it. */ FXJSONFile(const FXString& filename,Direction d=Load,FXuval sz=4096); /** * Open JSON file for direction d. */ FXbool open(const FXString& filename,Direction d=Load,FXuval sz=4096); /** * Read at least count bytes into buffer; return bytes available, or -1 for error. */ virtual FXival fill(FXival count); /** * Write at least count bytes from buffer; return space available, or -1 for error. */ virtual FXival flush(FXival count); /** * Close JSON file and delete buffers. */ FXbool close(); /** * Close JSON file. */ virtual ~FXJSONFile(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXJSONString.h000066400000000000000000000057331455751074500230400ustar00rootroot00000000000000/******************************************************************************** * * * J S O N S t r i n g I / O * * * ********************************************************************************* * Copyright (C) 2018,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXJSONSTRING_H #define FXJSONSTRING_H #ifndef FXJSON_H #include "FXJSON.h" #endif namespace FX { /** * Serialize a variant to or from JSON formatted string. */ class FXAPI FXJSONString : public FXJSON { private: FXString buffer; private: FXJSONString(const FXJSONString&); FXJSONString &operator=(const FXJSONString&); public: /** * Create JSON string i/o object. */ FXJSONString(); /** * Create JSON string i/o object and open it. */ FXJSONString(const FXString& string,Direction d=Load); /** * Create JSON i/o object and open it. */ FXJSONString(const FXchar* string,FXuval length,Direction d=Load); /** * Open JSON string for loading or saving. */ FXbool open(const FXString& string,Direction d=Load); /** * Open JSON character string of length for direction d. */ FXbool open(const FXchar* string,FXuval length,Direction d=Load); /** * Return string. */ const FXString text() const { return buffer; } /** * Read at least count bytes into buffer; return bytes available, or -1 for error. */ virtual FXival fill(FXival count); /** * Write at least count bytes from buffer; return space available, or -1 for error. */ virtual FXival flush(FXival count); /** * Close JSON string and delete buffers. */ FXbool close(); /** * Close JSON string. */ virtual ~FXJSONString(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXKOI8RCodec.h000066400000000000000000000011031455751074500226550ustar00rootroot00000000000000#ifndef FXKOI8RCODEC_H #define FXKOI8RCODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// KOI8-R Codec class FXAPI FXKOI8RCodec : public FXTextCodec { FXDECLARE(FXKOI8RCodec) public: FXKOI8RCodec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint mibEnum() const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual const FXchar* const* aliases() const; virtual ~FXKOI8RCodec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXKnob.h000066400000000000000000000160141455751074500217630ustar00rootroot00000000000000/******************************************************************************** * * * K n o b W i d g e t * * * ********************************************************************************* * Copyright (C) 2005,2022 by Leandro Nini. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXKNOB_H #define FXKNOB_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { /// Knob Control styles enum { KNOB_NEEDLE = 0, /// Use a needle as indicator KNOB_DOT = 0x00008000, /// Use a dot as indicator KNOB_TICKS = 0x00010000, /// Show ticks around the knob KNOB_INDICATOR = 0x00020000, /// Show only the indicator (like a speedometer) KNOB_NORMAL = (KNOB_NEEDLE|KNOB_TICKS) /// Normal knob looks }; /** * The knob widget is a valuator widget which provides simple linear value range. * While being moved, the knob sends SEL_CHANGED messages to its target; * at the end of the interaction, a final SEL_COMMAND message is sent. * The message data represents the current knob value, of type FXint. */ class FXAPI FXKnob : public FXFrame { FXDECLARE(FXKnob) protected: FXint range[2]; // Reported data range FXdouble limits[2]; // Starting and ending positions FXColor lineColor; // Color of indicator needle FXint pos; // Reported data position FXint incr; // Increment when auto-sliding FXint delta; // Interval between ticks FXString help; // Help string FXString tip; // Tip string protected: FXKnob(); FXint calcValue(FXint x,FXint y); private: FXKnob(const FXKnob&); FXKnob &operator=(const FXKnob&); public: long onPaint(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onMiddleBtnPress(FXObject*,FXSelector,void*); long onMiddleBtnRelease(FXObject*,FXSelector,void*); long onMouseWheel(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onFocusIn(FXObject*,FXSelector,void*); long onFocusOut(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onAutoSlide(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdSetLongValue(FXObject*,FXSelector,void*); long onCmdGetLongValue(FXObject*,FXSelector,void*); long onCmdSetRealValue(FXObject*,FXSelector,void*); long onCmdGetRealValue(FXObject*,FXSelector,void*); long onCmdSetIntRange(FXObject*,FXSelector,void*); long onCmdGetIntRange(FXObject*,FXSelector,void*); long onCmdSetRealRange(FXObject*,FXSelector,void*); long onCmdGetRealRange(FXObject*,FXSelector,void*); long onCmdSetHelp(FXObject*,FXSelector,void*); long onCmdGetHelp(FXObject*,FXSelector,void*); long onCmdSetTip(FXObject*,FXSelector,void*); long onCmdGetTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); public: enum{ ID_AUTOSLIDE=FXFrame::ID_LAST, ID_LAST }; public: /// Construct a knob widget FXKnob(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=KNOB_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Returns true because a knob can receive focus virtual FXbool canFocus() const; /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Perform layout virtual void layout(); /// Enable the knob virtual void enable(); /// Disable the knob virtual void disable(); /// Change knob value void setValue(FXint value,FXbool notify=false); /// Return knob value FXint getValue() const { return pos; } /// Change the knob's range void setRange(FXint lo,FXint hi,FXbool notify=false); /// Get the knob's current range void getRange(FXint& lo,FXint& hi) const { lo=range[0]; hi=range[1]; } /** * Change the knob's movement limits (start and ending angles) * accept values in degrees from 0 (south) to 360. */ void setLimits(FXint start,FXint end,FXbool notify=false); /// Get the knob's current limits void getLimits(FXint& start,FXint& end); /// Change the knob style FXuint getKnobStyle() const; /// Get the current knob style void setKnobStyle(FXuint style); /// Get the knob's auto-increment/decrement value FXint getIncrement() const { return incr; } /// Change the knob's auto-increment/decrement value void setIncrement(FXint inc){ incr=inc; } /// Change the delta between ticks void setTickDelta(FXint dist); /// Get delta between ticks FXint getTickDelta() const { return delta; } /// Change the indicator needle color void setLineColor(FXColor clr); /// Get the current indicator needle color FXColor getLineColor() const { return lineColor; } /// Set the help text to be displayed on the status line void setHelpText(const FXString& text){ help=text; } /// Get the current help text const FXString& getHelpText() const { return help; } /// Set the tip text to be displayed in the tooltip void setTipText(const FXString& text){ tip=text; } /// Get the current tooltip text value const FXString& getTipText() const { return tip; } /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destroy the knob virtual ~FXKnob(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXLFQueue.h000066400000000000000000000062531455751074500224040ustar00rootroot00000000000000/******************************************************************************** * * * L o c k - F r e e Q u e u e * * * ********************************************************************************* * Copyright (C) 2012,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXLFQUEUE_H #define FXLFQUEUE_H namespace FX { /// Lock-free queue of void pointers class FXAPI FXLFQueue { private: FXPtrList items; // Item buffer volatile FXuint whead; // Head write pointer volatile FXuint wtail; // Tail write pointer volatile FXuint rhead; // Head read pointer volatile FXuint rtail; // Tail read pointer private: FXLFQueue(const FXLFQueue&); FXLFQueue &operator=(const FXLFQueue&); public: /// Create initially empty queue FXLFQueue(); /// Create queue with initial size, which must be a power of two FXLFQueue(FXuint sz); /// Change size of queue (must be power of two); return true if success FXbool setSize(FXuint sz); /// Return size FXuint getSize() const { return (FXuint)items.no(); } /// Return number of used slots FXuint getUsed() const; /// Return number of free slots FXuint getFree() const; /// If queue not full, can write if no other producers FXbool isFull() const; /// If queue not empty, can read if no other consumers FXbool isEmpty() const; /// Add item to queue, return true if success FXbool push(FXptr ptr); /// Remove item from queue, return true if success FXbool pop(FXptr& ptr); /// Destroy queue ~FXLFQueue(); }; /// Lock-free queue of pointers to TYPE template class FXLFQueueOf : public FXLFQueue { public: FXLFQueueOf(){} FXLFQueueOf(FXuint sz):FXLFQueue(sz){} FXbool push(TYPE* ptr){ return FXLFQueue::push((FXptr)ptr); } FXbool pop(TYPE*& ptr){ return FXLFQueue::pop((FXptr&)ptr); } }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXLabel.h000066400000000000000000000152401455751074500221110ustar00rootroot00000000000000/******************************************************************************** * * * L a b e l W i d g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXLABEL_H #define FXLABEL_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { /// Relationship options for icon-labels enum { ICON_UNDER_TEXT = 0, /// Icon appears under text ICON_AFTER_TEXT = 0x00080000, /// Icon appears after text (to its right) ICON_BEFORE_TEXT = 0x00100000, /// Icon appears before text (to its left) ICON_ABOVE_TEXT = 0x00200000, /// Icon appears above text ICON_BELOW_TEXT = 0x00400000, /// Icon appears below text TEXT_OVER_ICON = ICON_UNDER_TEXT, /// Same as ICON_UNDER_TEXT TEXT_AFTER_ICON = ICON_BEFORE_TEXT, /// Same as ICON_BEFORE_TEXT TEXT_BEFORE_ICON = ICON_AFTER_TEXT, /// Same as ICON_AFTER_TEXT TEXT_ABOVE_ICON = ICON_BELOW_TEXT, /// Same as ICON_BELOW_TEXT TEXT_BELOW_ICON = ICON_ABOVE_TEXT /// Same as ICON_ABOVE_TEXT }; /// Normal way to show label enum { LABEL_NORMAL = JUSTIFY_NORMAL|ICON_BEFORE_TEXT }; class FXIcon; class FXFont; /** * A label widget can be used to place a text and/or icon for * explanation purposes. The text label may have an optional tooltip * and/or help string. Icon and label are placed relative to the widget * using the justification options, and relative to each other as determined * by the icon relationship options. A large number of arrangements is * possible. */ class FXAPI FXLabel : public FXFrame { FXDECLARE(FXLabel) protected: FXString label; // Text on the label FXIcon *icon; // Icon on the label FXFont *font; // Label font FXString help; // Help message FXString tip; // Tooltip FXColor textColor; // Text color FXHotKey hotkey; // Hotkey FXint hotoff; // Offset in string protected: FXLabel(); FXint labelHeight(const FXString& text) const; FXint labelWidth(const FXString& text) const; void drawLabel(FXDCWindow& dc,const FXString& text,FXint hot,FXint tx,FXint ty,FXint tw,FXint th); void just_x(FXint& tx,FXint& ix,FXint tw,FXint iw); void just_y(FXint& ty,FXint& iy,FXint th,FXint ih); private: FXLabel(const FXLabel&); FXLabel &operator=(const FXLabel&); public: long onPaint(FXObject*,FXSelector,void*); long onHotKeyPress(FXObject*,FXSelector,void*); long onHotKeyRelease(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetStringValue(FXObject*,FXSelector,void*); long onCmdGetStringValue(FXObject*,FXSelector,void*); long onCmdSetIconValue(FXObject*,FXSelector,void*); long onCmdGetIconValue(FXObject*,FXSelector,void*); long onCmdSetHelp(FXObject*,FXSelector,void*); long onCmdGetHelp(FXObject*,FXSelector,void*); long onCmdSetTip(FXObject*,FXSelector,void*); long onCmdGetTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); public: /// Construct label with given text and icon FXLabel(FXComposite* p,const FXString& text,FXIcon* ic=0,FXuint opts=LABEL_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Enable the window virtual void enable(); /// Disable the window virtual void disable(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Change text and hotkey void setTextAndHotKey(const FXString& hotkeytext); /// Set the text for this label void setText(const FXString& text); /// Get the text for this label FXString getText() const { return label; } /// Set the icon for this label void setIcon(FXIcon* ic); /// Get the icon for this label FXIcon* getIcon() const { return icon; } /// Set the text font void setFont(FXFont *fnt); /// Get the text font FXFont* getFont() const { return font; } /// Get the current text color FXColor getTextColor() const { return textColor; } /// Set the current text color void setTextColor(FXColor clr); /// Set the current text-justification mode. void setJustify(FXuint mode); /// Get the current text-justification mode. FXuint getJustify() const; /// Set the current icon position void setIconPosition(FXuint mode); /// Get the current icon position FXuint getIconPosition() const; /// Set the status line help text for this label void setHelpText(const FXString& text){ help=text; } /// Get the status line help text for this label const FXString& getHelpText() const { return help; } /// Set the tool tip message for this label void setTipText(const FXString& text){ tip=text; } /// Get the tool tip message for this label const FXString& getTipText() const { return tip; } /// Save label to a stream virtual void save(FXStream& store) const; /// Load label from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXLabel(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXList.h000066400000000000000000000407761455751074500220210ustar00rootroot00000000000000/******************************************************************************** * * * L i s t W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXLIST_H #define FXLIST_H #ifndef FXSCROLLAREA_H #include "FXScrollArea.h" #endif namespace FX { /// List styles enum { LIST_EXTENDEDSELECT = 0, /// Extended selection mode allows for drag-selection of ranges of items LIST_SINGLESELECT = 0x00100000, /// Single selection mode allows up to one item to be selected LIST_BROWSESELECT = 0x00200000, /// Browse selection mode enforces one single item to be selected at all times LIST_MULTIPLESELECT = 0x00300000, /// Multiple selection mode is used for selection of individual items LIST_AUTOSELECT = 0x00400000, /// Automatically select under cursor LIST_NORMAL = LIST_EXTENDEDSELECT }; class FXIcon; class FXFont; class FXList; /// List item class FXAPI FXListItem : public FXObject { FXDECLARE(FXListItem) friend class FXList; protected: FXString label; FXIcon *icon; FXptr data; FXuint state; FXint x,y; private: FXListItem(const FXListItem&); FXListItem& operator=(const FXListItem&); protected: FXListItem():icon(nullptr),data(nullptr),state(0),x(0),y(0){} virtual void draw(const FXList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; virtual FXint hitItem(const FXList* list,FXint x,FXint y) const; public: enum { SELECTED = 1, /// Selected FOCUS = 2, /// Focus DISABLED = 4, /// Disabled DRAGGABLE = 8, /// Draggable ICONOWNED = 16 /// Icon owned by item }; public: /// Construct new item with given text, icon, and user-data FXListItem(const FXString& text,FXIcon* ic=nullptr,FXptr ptr=nullptr):label(text),icon(ic),data(ptr),state(0),x(0),y(0){} /// Change item's text label virtual void setText(const FXString& txt); /// Return item's text label const FXString& getText() const { return label; } /// Change item's icon, deleting the old icon if it was owned virtual void setIcon(FXIcon* icn,FXbool owned=false); /// Return item's icon FXIcon* getIcon() const { return icon; } /// Change item's user data void setData(FXptr ptr){ data=ptr; } /// Get item's user data FXptr getData() const { return data; } /// Make item draw as focused virtual void setFocus(FXbool focus); /// Return true if item has focus FXbool hasFocus() const { return (state&FOCUS)!=0; } /// Select item virtual void setSelected(FXbool selected); /// Return true if this item is selected FXbool isSelected() const { return (state&SELECTED)!=0; } /// Enable or disable item virtual void setEnabled(FXbool enabled); /// Return true if this item is enabled FXbool isEnabled() const { return (state&DISABLED)==0; } /// Make item draggable virtual void setDraggable(FXbool draggable); /// Return true if this item is draggable FXbool isDraggable() const { return (state&DRAGGABLE)!=0; } /// Return tip text virtual FXString getTipText() const; /// Return width of item as drawn in list virtual FXint getWidth(const FXList* list) const; /// Return height of item as drawn in list virtual FXint getHeight(const FXList* list) const; /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Destroy server-side resources virtual void destroy(); /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destroy item and free icons if owned virtual ~FXListItem(); }; /// List item collate function typedef FXint (*FXListSortFunc)(const FXListItem*,const FXListItem*); /// List of FXListItem's typedef FXObjectListOf FXListItemList; /** * A List Widget displays a list of items, each with a text and * optional icon. When an item's selected state changes, the list sends * a SEL_SELECTED or SEL_DESELECTED message. A change of the current * item is signified by the SEL_CHANGED message. * The list sends SEL_COMMAND messages when the user clicks on an item, * and SEL_CLICKED, SEL_DOUBLECLICKED, and SEL_TRIPLECLICKED when the user * clicks once, twice, or thrice, respectively. * When items are inserted or removed, the list sends messages of * the type SEL_INSERTED or SEL_DELETED. * In each of these cases, the index to the item, if any, is passed in the * 3rd argument of the message. */ class FXAPI FXList : public FXScrollArea { FXDECLARE(FXList) protected: FXListItemList items; // Item list FXint anchor; // Anchor item FXint current; // Current item FXint extent; // Extent item FXint viewable; // Viewable item FXFont *font; // Font FXColor textColor; // Text color FXColor selbackColor; // Selected back color FXColor seltextColor; // Selected text color FXint listWidth; // List width FXint listHeight; // List height FXint visible; // Number of rows high FXString help; // Help text FXListSortFunc sortfunc; // Item sort function FXint grabx; // Grab point x FXint graby; // Grab point y FXString lookup; // Lookup string FXbool state; // State of item protected: FXList(); void recompute(); virtual FXListItem *createItem(const FXString& text,FXIcon* icon,FXptr ptr); private: FXList(const FXList&); FXList &operator=(const FXList&); public: long onPaint(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onRightBtnPress(FXObject*,FXSelector,void*); long onRightBtnRelease(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onFocusIn(FXObject*,FXSelector,void*); long onFocusOut(FXObject*,FXSelector,void*); long onAutoScroll(FXObject*,FXSelector,void*); long onClicked(FXObject*,FXSelector,void*); long onDoubleClicked(FXObject*,FXSelector,void*); long onTripleClicked(FXObject*,FXSelector,void*); long onCommand(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onTipTimer(FXObject*,FXSelector,void*); long onLookupTimer(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*);public: long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); public: static FXint ascending(const FXListItem* a,const FXListItem* b); static FXint descending(const FXListItem* a,const FXListItem* b); static FXint ascendingCase(const FXListItem* a,const FXListItem* b); static FXint descendingCase(const FXListItem* a,const FXListItem* b); public: enum { ID_LOOKUPTIMER=FXScrollArea::ID_LAST, ID_LAST }; public: /// Construct a list with initially no items in it FXList(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=LIST_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Perform layout virtual void layout(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Compute and return content width virtual FXint getContentWidth(); /// Return content height virtual FXint getContentHeight(); /// Recalculate layout virtual void recalc(); /// List widget can receive focus virtual FXbool canFocus() const; /// Move the focus to this window virtual void setFocus(); /// Remove the focus from this window virtual void killFocus(); /// Return the number of items in the list FXint getNumItems() const { return (FXint)items.no(); } /// Return number of visible items FXint getNumVisible() const { return visible; } /// Change the number of visible items void setNumVisible(FXint nvis); /// Return the item at the given index FXListItem *getItem(FXint index) const; /// Replace the item with a [possibly subclassed] item FXint setItem(FXint index,FXListItem* item,FXbool notify=false); /// Replace items text, icon, and user-data pointer FXint setItem(FXint index,const FXString& text,FXIcon *icon=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Fill list by appending items from array of strings FXint fillItems(const FXchar *const *strings,FXIcon *icon=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Fill list by appending items from array of strings FXint fillItems(const FXString* strings,FXIcon *icon=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Fill list by appending items from newline separated strings FXint fillItems(const FXString& strings,FXIcon *icon=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Insert a new [possibly subclassed] item at the give index FXint insertItem(FXint index,FXListItem* item,FXbool notify=false); /// Insert item at index with given text, icon, and user-data pointer FXint insertItem(FXint index,const FXString& text,FXIcon *icon=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Append a [possibly subclassed] item to the list FXint appendItem(FXListItem* item,FXbool notify=false); /// Append new item with given text and optional icon, and user-data pointer FXint appendItem(const FXString& text,FXIcon *icon=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Prepend a [possibly subclassed] item to the list FXint prependItem(FXListItem* item,FXbool notify=false); /// Prepend new item with given text and optional icon, and user-data pointer FXint prependItem(const FXString& text,FXIcon *icon=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Move item from oldindex to newindex FXint moveItem(FXint newindex,FXint oldindex,FXbool notify=false); /// Extract item from list FXListItem* extractItem(FXint index,FXbool notify=false); /// Remove item from list void removeItem(FXint index,FXbool notify=false); /// Remove all items from list void clearItems(FXbool notify=false); /// Return item width FXint getItemWidth(FXint index) const; /// Return item height FXint getItemHeight(FXint index) const; /// Return index of item at x,y, if any virtual FXint getItemAt(FXint x,FXint y) const; /// Return item hit code: 0 no hit; 1 hit the icon; 2 hit the text FXint hitItem(FXint index,FXint x,FXint y) const; /// Scroll to bring item into view virtual void makeItemVisible(FXint index); /** * Search items by name, beginning from item start. If the start * item is -1 the search will start at the first item in the list. * Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control the * search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP * to control whether the search wraps at the start or end of the list. * The option SEARCH_IGNORECASE causes a case-insensitive match. Finally, * passing SEARCH_PREFIX causes searching for a prefix of the item name. * Return -1 if no matching item is found. */ FXint findItem(const FXString& string,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; /** * Search items by associated user data, beginning from item start. If the * start item is -1 the search will start at the first item in the list. * Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control the * search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP * to control whether the search wraps at the start or end of the list. */ FXint findItemByData(FXptr ptr,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; /// Change item text void setItemText(FXint index,const FXString& text); /// Return item text FXString getItemText(FXint index) const; /// Change item icon, deleting the old icon if it was owned void setItemIcon(FXint index,FXIcon* icon,FXbool owned=false); /// Return item icon, if any FXIcon* getItemIcon(FXint index) const; /// Change item user-data pointer void setItemData(FXint index,FXptr ptr); /// Return item user-data pointer FXptr getItemData(FXint index) const; /// Return true if item is selected FXbool isItemSelected(FXint index) const; /// Return true if item is current FXbool isItemCurrent(FXint index) const; /// Return true if item is visible FXbool isItemVisible(FXint index) const; /// Return true if item is enabled FXbool isItemEnabled(FXint index) const; /// Repaint item void updateItem(FXint index) const; /// Enable item virtual FXbool enableItem(FXint index); /// Disable item virtual FXbool disableItem(FXint index); /// Select item virtual FXbool selectItem(FXint index,FXbool notify=false); /// Deselect item virtual FXbool deselectItem(FXint index,FXbool notify=false); /// Toggle item selection state virtual FXbool toggleItem(FXint index,FXbool notify=false); /// Extend selection from anchor item to index virtual FXbool extendSelection(FXint index,FXbool notify=false); /// Select all items virtual FXbool selectAll(FXbool notify=false); /// Deselect all items virtual FXbool killSelection(FXbool notify=false); /// Change current item virtual void setCurrentItem(FXint index,FXbool notify=false); /// Return current item, if any FXint getCurrentItem() const { return current; } /// Change anchor item void setAnchorItem(FXint index); /// Return anchor item, if any FXint getAnchorItem() const { return anchor; } /// Sort items using current sort function void sortItems(); /// Return sort function FXListSortFunc getSortFunc() const { return sortfunc; } /// Change sort function void setSortFunc(FXListSortFunc func){ sortfunc=func; } /// Change text font void setFont(FXFont* fnt); /// Return text font FXFont* getFont() const { return font; } /// Return normal text color FXColor getTextColor() const { return textColor; } /// Change normal text color void setTextColor(FXColor clr); /// Return selected text background FXColor getSelBackColor() const { return selbackColor; } /// Change selected text background void setSelBackColor(FXColor clr); /// Return selected text color FXColor getSelTextColor() const { return seltextColor; } /// Change selected text color void setSelTextColor(FXColor clr); /// Return list style FXuint getListStyle() const; /// Change list style void setListStyle(FXuint style); /// Set the status line help text for this list void setHelpText(const FXString& text); /// Get the status line help text for this list const FXString& getHelpText() const { return help; } /// Save list to a stream virtual void save(FXStream& store) const; /// Load list from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXList(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXListBox.h000066400000000000000000000231771455751074500224660ustar00rootroot00000000000000/******************************************************************************** * * * L i s t B o x W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXLISTBOX_H #define FXLISTBOX_H #ifndef FXPACKER_H #include "FXPacker.h" #endif namespace FX { /// List Box styles enum { LISTBOX_NORMAL = 0 // Normal style }; class FXButton; class FXMenuButton; class FXList; class FXPopup; /** * The List Box is a control to select one of a list of options. It looks * similar to a Combo Box except that List Box yields integer numbers only. * When an option is selected, List Box will send an SEL_COMMAND with the * index of the opton. While manipulating the list, it may send SEL_CHANGED * messages to indicate which option the cursor is hovering over. * The List Box is able to receive ID_GETINTVALUE and ID_SETINTVALUE which * will retrieve the current option or change the selected option. * When items are added, replaced, or removed, the list sends messages of * the type SEL_INSERTED, SEL_REPLACED, or SEL_DELETED, with the index of * the affected item as argument. */ class FXAPI FXListBox : public FXPacker { FXDECLARE(FXListBox) protected: FXButton *field; FXMenuButton *button; FXList *list; FXPopup *pane; protected: FXListBox(){} private: FXListBox(const FXListBox&); FXListBox &operator=(const FXListBox&); public: long onFocusUp(FXObject*,FXSelector,void*); long onFocusDown(FXObject*,FXSelector,void*); long onFocusSelf(FXObject*,FXSelector,void*); long onMouseWheel(FXObject*,FXSelector,void*); long onFieldButton(FXObject*,FXSelector,void*); long onListUpdate(FXObject*,FXSelector,void*); long onListClicked(FXObject*,FXSelector,void*); long onListChanged(FXObject*,FXSelector,void*); long onListCommand(FXObject*,FXSelector,void*); long onListForward(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); public: enum { ID_LIST=FXPacker::ID_LAST, ID_FIELD, ID_LAST }; public: /// Constructor FXListBox(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=FRAME_SUNKEN|FRAME_THICK|LISTBOX_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Destroy server-side resources virtual void destroy(); /// Perform layout virtual void layout(); /// Enable drive box virtual void enable(); /// Disable drive box virtual void disable(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Return the number of items in the list FXint getNumItems() const; /// Return the number of visible items FXint getNumVisible() const; /// Set the number of visible items void setNumVisible(FXint nvis); /// Return true if current item FXbool isItemCurrent(FXint index) const; /// Set the current item (index is zero-based) virtual void setCurrentItem(FXint index,FXbool notify=false); /// Get the current item's index FXint getCurrentItem() const; /// Return the item at the given index FXString getItem(FXint index) const; /// Replace the item at index FXint setItem(FXint index,const FXString& text,FXIcon* icon=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Fill list box by appending items from array of strings FXint fillItems(const FXchar *const *strings,FXIcon* icon=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Fill list box by appending items from array of strings FXint fillItems(const FXString* strings,FXIcon* icon=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Fill list box by appending items from newline separated strings FXint fillItems(const FXString& strings,FXIcon* icon=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Insert a new item at index FXint insertItem(FXint index,const FXString& text,FXIcon* icon=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Add an item to the end of the list FXint appendItem(const FXString& text,FXIcon* icon=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Prepend an item to the list FXint prependItem(const FXString& text,FXIcon* icon=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Move item from oldindex to newindex FXint moveItem(FXint newindex,FXint oldindex,FXbool notify=false); /// Extract item from list FXListItem* extractItem(FXint index,FXbool notify=false); /// Remove this item from the list void removeItem(FXint index,FXbool notify=false); /// Remove all items from the list void clearItems(FXbool notify=false); /** * Search items by name, beginning from item start. If the start * item is -1 the search will start at the first item in the list. * Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control the * search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP * to control whether the search wraps at the start or end of the list. * The option SEARCH_IGNORECASE causes a case-insensitive match. Finally, * passing SEARCH_PREFIX causes searching for a prefix of the item name. * Return -1 if no matching item is found. */ FXint findItem(const FXString& string,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; /** * Search items by associated user data, beginning from item start. If the * start item is -1 the search will start at the first item in the list. * Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control the * search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP * to control whether the search wraps at the start or end of the list. */ FXint findItemByData(FXptr ptr,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; /// Set text for specified item void setItemText(FXint index,const FXString& text); /// Get text for specified item FXString getItemText(FXint index) const; /// Change item icon, deleting old one if it was owned void setItemIcon(FXint index,FXIcon* icon,FXbool owned=false); /// Return icon of item at index FXIcon* getItemIcon(FXint index) const; /// Set data pointer for specified item void setItemData(FXint index,FXptr ptr) const; /// Get data pointer for specified item FXptr getItemData(FXint index) const; /// Return true if item is enabled FXbool isItemEnabled(FXint index) const; /// Enable item FXbool enableItem(FXint index); /// Disable item FXbool disableItem(FXint index); /// Show or hide menu void showMenu(FXbool shw); /// Is the menu pane shown FXbool isMenuShown() const; /// Sort items using current sort function void sortItems(); /// Set text font void setFont(FXFont* fnt); /// Get text font FXFont* getFont() const; /// Change popup pane shrinkwrap mode void setShrinkWrap(FXbool flag); /// Return popup pane shrinkwrap mode FXbool getShrinkWrap() const; /// Set window background color virtual void setBackColor(FXColor clr); /// Get background color FXColor getBackColor() const; /// Change text color void setTextColor(FXColor clr); /// Return text color FXColor getTextColor() const; /// Change selected background color void setSelBackColor(FXColor clr); /// Return selected background color FXColor getSelBackColor() const; /// Change selected text color void setSelTextColor(FXColor clr); /// Return selected text color FXColor getSelTextColor() const; /// Return sort function FXListSortFunc getSortFunc() const; /// Change sort function void setSortFunc(FXListSortFunc func); /// Set the combobox help text void setHelpText(const FXString& txt); /// Get the combobox help text const FXString& getHelpText() const; /// Set the tool tip message for this combobox void setTipText(const FXString& txt); /// Get the tool tip message for this combobox const FXString& getTipText() const; /// Save combobox to a stream virtual void save(FXStream& store) const; /// Load combobox from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXListBox(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXLocale.h000066400000000000000000000035461455751074500222770ustar00rootroot00000000000000/******************************************************************************** * * * L o c a l e C l a s s * * * ********************************************************************************* * Copyright (C) 2007,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXLOCALE_H #define FXLOCALE_H //////////////////////////// UNDER DEVELOPMENT //////////////////////////////// namespace FX { /** * Locale definitions. */ class FXAPI FXLocale { public: FXLocale(); virtual ~FXLocale(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMDIButton.h000066400000000000000000000116141455751074500227000ustar00rootroot00000000000000/******************************************************************************** * * * M u l t i p l e D o c u m e n t B u t t o n * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMDIBUTTON_H #define FXMDIBUTTON_H #ifndef FXBUTTON_H #include "FXButton.h" #endif namespace FX { class FXIcon; /// MDI Delete button class FXAPI FXMDIDeleteButton : public FXButton { FXDECLARE(FXMDIDeleteButton) protected: FXMDIDeleteButton(){} private: FXMDIDeleteButton(const FXMDIDeleteButton&); FXMDIDeleteButton &operator=(const FXMDIDeleteButton&); public: long onPaint(FXObject*,FXSelector,void*); public: /// Constructor FXMDIDeleteButton(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=FRAME_RAISED,FXint x=0,FXint y=0,FXint w=0,FXint h=0); virtual FXint getDefaultWidth(); virtual FXint getDefaultHeight(); }; /// MDI Restore button class FXAPI FXMDIRestoreButton : public FXButton { FXDECLARE(FXMDIRestoreButton) protected: FXMDIRestoreButton(){} private: FXMDIRestoreButton(const FXMDIRestoreButton&); FXMDIRestoreButton &operator=(const FXMDIRestoreButton&); public: long onPaint(FXObject*,FXSelector,void*); public: /// Constructor FXMDIRestoreButton(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=FRAME_RAISED,FXint x=0,FXint y=0,FXint w=0,FXint h=0); virtual FXint getDefaultWidth(); virtual FXint getDefaultHeight(); }; /// MDI Maximize button class FXAPI FXMDIMaximizeButton : public FXButton { FXDECLARE(FXMDIMaximizeButton) protected: FXMDIMaximizeButton(){} private: FXMDIMaximizeButton(const FXMDIMaximizeButton&); FXMDIMaximizeButton &operator=(const FXMDIMaximizeButton&); public: long onPaint(FXObject*,FXSelector,void*); public: /// Constructor FXMDIMaximizeButton(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=FRAME_RAISED,FXint x=0,FXint y=0,FXint w=0,FXint h=0); virtual FXint getDefaultWidth(); virtual FXint getDefaultHeight(); }; /// MDI Minimize button class FXAPI FXMDIMinimizeButton : public FXButton { FXDECLARE(FXMDIMinimizeButton) protected: FXMDIMinimizeButton(){} private: FXMDIMinimizeButton(const FXMDIMinimizeButton&); FXMDIMinimizeButton &operator=(const FXMDIMinimizeButton&); public: long onPaint(FXObject*,FXSelector,void*); public: /// Constructor FXMDIMinimizeButton(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=FRAME_RAISED,FXint x=0,FXint y=0,FXint w=0,FXint h=0); virtual FXint getDefaultWidth(); virtual FXint getDefaultHeight(); }; /// MDI Window button class FXAPI FXMDIWindowButton : public FXMenuButton { FXDECLARE(FXMDIWindowButton) protected: FXMDIWindowButton(){} private: FXMDIWindowButton(const FXMDIWindowButton&); FXMDIWindowButton &operator=(const FXMDIWindowButton&); public: long onPaint(FXObject*,FXSelector,void*); public: /// Constructor FXMDIWindowButton(FXComposite* p,FXPopup* pup,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); virtual FXint getDefaultWidth(); virtual FXint getDefaultHeight(); }; /// MDI Window Menu class FXAPI FXMDIMenu : public FXMenuPane { FXDECLARE(FXMDIMenu) private: FXIcon *closeicon; FXIcon *maximizeicon; FXIcon *minimizeicon; FXIcon *restoreicon; protected: FXMDIMenu(){} private: FXMDIMenu(const FXMDIMenu&); FXMDIMenu &operator=(const FXMDIMenu&); public: /// Construct MDI menu FXMDIMenu(FXWindow *owner,FXObject* tgt=nullptr); /// Destructor virtual ~FXMDIMenu(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMDIChild.h000066400000000000000000000271721455751074500224560ustar00rootroot00000000000000/******************************************************************************** * * * M u l t i p l e D o c u m e n t C h i l d W i n d o w * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMDICHILD_H #define FXMDICHILD_H #ifndef FXCOMPOSITE_H #include "FXComposite.h" #endif namespace FX { class FXMDIClient; class FXMenuButton; class FXButton; class FXFont; /// MDI Child Window styles enum { MDI_NORMAL = 0, /// Normal display mode MDI_MAXIMIZED = 0x00001000, /// Window appears maximized MDI_MINIMIZED = 0x00002000, /// Window is iconified or minimized MDI_TRACKING = 0x00004000 /// Track continuously during dragging }; /** * The MDI child window contains the application work area in a Multiple Document * Interface application. GUI Controls are connected to the MDI child via delegation * through the MDI client, which forwards messages it receives to the active MDI child. * The MDI child itself tries to further delegate messages to its single content window, * and if not handled there, to its target object. * When the MDI child is maximized, it sends a SEL_MAXIMIZE message; when the MDI * child is minimized, it sends a SEL_MINIMIZE message. When it is restored, it * sends a SEL_RESTORE message to its target. * The MDI child also notifies its target when it becomes the active MDI child, via the * SEL_SELECTED message. The void* in the SEL_SELECTED message refers to the previously * active MDI child, if any. * When an MDI child ceases to be the active window, a SEL_DESELECTED message * is sent to its target, and the void* in the SEL_DESELECTED message refers to the newly * activated MDI child, if any. * Thus, interception of SEL_SELECTED and SEL_DESELECTED allows the target object to determine * whether the user switched between MDI windows of the same document (target) or merely between * two MDI windows belonging to the same document. * When the MDI child is closed, it first sends a SEL_DESELECTED to its target to * notify it that it is no longer the active window; next, it sends a SEL_CLOSE message * to its target to allow the target to clean up (for example, destroy the document * if this was the last window of the document). * The target can prevent the MDI child window from being closed by returning 1 from * the SEL_CLOSE message handler (objection). If the target returns 0 or does not * handle the SEL_CLOSE message, the MDI child will be closed. * If the MDI child windows was not closed, the child window will be reselected * as the currently active MDI child widget, and a SEL_SELECTED will be sent to * its target to notify it of this fact. * The SEL_UPDATE message can be used to modify the MDI child's title (via * ID_SETSTRINGVALUE), and window icon (via ID_SETICONVALUE). */ class FXAPI FXMDIChild : public FXComposite { FXDECLARE(FXMDIChild) protected: FXString title; // Window title FXMenuButton *windowbtn; // Window button FXButton *minimizebtn; // Minimize button FXButton *restorebtn; // Restore button FXButton *maximizebtn; // Maximize buton FXButton *deletebtn; // Close button FXFont *font; // Title font FXColor baseColor; // Colors FXColor hiliteColor; FXColor shadowColor; FXColor borderColor; FXColor titleColor; FXColor titleBackColor; FXint iconPosX; // Saved icon position FXint iconPosY; FXint iconWidth; FXint iconHeight; FXint normalPosX; // Saved normal position FXint normalPosY; FXint normalWidth; FXint normalHeight; FXint spotx; // Grab-spot of mouse on window FXint spoty; FXint xoff; // Mouse offset to add FXint yoff; FXint newx; // New location of window FXint newy; FXint neww; FXint newh; FXuchar mode; // Dragging mode protected: FXMDIChild(); void drawRubberBox(FXint x,FXint y,FXint w,FXint h); void animateRectangles(FXint ox,FXint oy,FXint ow,FXint oh,FXint nx,FXint ny,FXint nw,FXint nh); FXuchar where(FXint x,FXint y) const; void changeCursor(FXuchar which); protected: enum { DRAG_NONE = 0, DRAG_TOP = 1, DRAG_BOTTOM = 2, DRAG_LEFT = 4, DRAG_RIGHT = 8, DRAG_TOPLEFT = (DRAG_TOP|DRAG_LEFT), DRAG_TOPRIGHT = (DRAG_TOP|DRAG_RIGHT), DRAG_BOTTOMLEFT = (DRAG_BOTTOM|DRAG_LEFT), DRAG_BOTTOMRIGHT = (DRAG_BOTTOM|DRAG_RIGHT), DRAG_INVERTED = 16, DRAG_TITLE = 32 }; private: FXMDIChild(const FXMDIChild&); FXMDIChild &operator=(const FXMDIChild&); public: long onPaint(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onFocusSelf(FXObject*,FXSelector,void*); long onFocusIn(FXObject*,FXSelector,void*); long onFocusOut(FXObject*,FXSelector,void*); long onRightBtnPress(FXObject*,FXSelector,void*); long onRightBtnRelease(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onMiddleBtnPress(FXObject*,FXSelector,void*); long onMiddleBtnRelease(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onSelected(FXObject*,FXSelector,void*); long onDeselected(FXObject*,FXSelector,void*); long onCmdClose(FXObject*,FXSelector,void*); long onUpdClose(FXObject*,FXSelector,void*); long onCmdRestore(FXObject*,FXSelector,void*); long onUpdRestore(FXObject*,FXSelector,void*); long onUpdMaximize(FXObject*,FXSelector,void*); long onUpdMinimize(FXObject*,FXSelector,void*); long onCmdMaximize(FXObject*,FXSelector,void*); long onCmdMinimize(FXObject*,FXSelector,void*); long onUpdWindow(FXObject*,FXSelector,void*); long onUpdMenuRestore(FXObject*,FXSelector,void*); long onUpdMenuMinimize(FXObject*,FXSelector,void*); long onUpdMenuClose(FXObject*,FXSelector,void*); long onUpdMenuWindow(FXObject*,FXSelector,void*); long onCmdSetStringValue(FXObject*,FXSelector,void*); long onCmdGetStringValue(FXObject*,FXSelector,void*); long onCmdSetIconValue(FXObject*,FXSelector,void*); long onCmdGetIconValue(FXObject*,FXSelector,void*); virtual long onDefault(FXObject*,FXSelector,void*); public: /// Construct MDI Child window with given name and icon FXMDIChild(FXMDIClient* p,const FXString& name,FXIcon* ic=nullptr,FXPopup* pup=nullptr,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Create window virtual void create(); /// Detach window virtual void detach(); /// Perform layout virtual void layout(); /// Return the default width of this window virtual FXint getDefaultWidth(); /// Return the default height of this window virtual FXint getDefaultHeight(); /// Move the focus to this window virtual void setFocus(); /// MDI Child can receive focus virtual FXbool canFocus() const; /// Move this window to the specified position in the parent's coordinates virtual void move(FXint x,FXint y); /// Resize this window to the specified width and height virtual void resize(FXint w,FXint h); /// Move and resize this window in the parent's coordinates virtual void position(FXint x,FXint y,FXint w,FXint h); /// Change normal (restored) position void setNormalX(FXint x){ normalPosX=x; } void setNormalY(FXint y){ normalPosY=y; } void setNormalWidth(FXint w){ normalWidth=w; } void setNormalHeight(FXint h){ normalHeight=h; } /// Return normal (restored) position FXint getNormalX() const { return normalPosX; } FXint getNormalY() const { return normalPosY; } FXint getNormalWidth() const { return normalWidth; } FXint getNormalHeight() const { return normalHeight; } /// Change iconified position void setIconX(FXint x){ iconPosX=x; } void setIconY(FXint y){ iconPosY=y; } void setIconWidth(FXint w){ iconWidth=w; } void setIconHeight(FXint h){ iconHeight=h; } /// Return iconified position FXint getIconX() const { return iconPosX; } FXint getIconY() const { return iconPosY; } FXint getIconWidth() const { return iconWidth; } FXint getIconHeight() const { return iconHeight; } /// Return content window FXWindow *contentWindow() const; /// Change MDI Child's title void setTitle(const FXString& name); /// Get current title FXString getTitle() const { return title; } /// Get colors FXColor getHiliteColor() const { return hiliteColor; } FXColor getShadowColor() const { return shadowColor; } FXColor getBaseColor() const { return baseColor; } FXColor getBorderColor() const { return borderColor; } FXColor getTitleColor () const { return titleColor; } FXColor getTitleBackColor() const { return titleBackColor; } /// Change colors void setHiliteColor(FXColor clr); void setShadowColor(FXColor clr); void setBaseColor(FXColor clr); void setBorderColor(FXColor clr); void setTitleColor(FXColor clr); void setTitleBackColor(FXColor clr); /// Restore MDI window to normal, return true if restored virtual FXbool restore(FXbool notify=false); /// Maximize MDI window, return true if maximized virtual FXbool maximize(FXbool notify=false); /// Minimize/iconify MDI window, return true if minimized virtual FXbool minimize(FXbool notify=false); /// Close MDI window, return true if actually closed virtual FXbool close(FXbool notify=false); /// Return true if maximized FXbool isMaximized() const; /// Return true if minimized FXbool isMinimized() const; /// Get window icon FXIcon *getIcon() const; /// Set window icon void setIcon(FXIcon* icon); /// Get window menu FXPopup* getMenu() const; /// Set window menu void setMenu(FXPopup* menu); /// Set tracking instead of just outline void setTracking(FXbool tracking=true); /// Return true if tracking FXbool getTracking() const; /// Set title font void setFont(FXFont *fnt); /// Get title font FXFont* getFont() const { return font; } /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destroy virtual ~FXMDIChild(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMDIClient.h000066400000000000000000000166761455751074500226600ustar00rootroot00000000000000/******************************************************************************** * * * M u l t i p l e D o c u m e n t C l i e n t W i n d o w * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMDICLIENT_H #define FXMDICLIENT_H #ifndef FXCOMPOSITE_H #include "FXComposite.h" #endif namespace FX { class FXMDIChild; /** * The MDI client window manages a number of MDI child windows in a multiple-document * interface (MDI) application. MDI child windows usually receive messages from the GUI controls * by delegation via the MDI client. This is accomplished by making the MDI client window * the target for most GUI controls. The MDI client filters out messages intented for itself, * and delegates the remaining messages to its currently active MDI child, if any. * If you use the auto-gray or auto-hide feature available in some GUI controls, these * controls can be automatically grayed out or hidden when there is no active MDI child. * When delegating messages via MDI client to MDI child windows of different types, care * should be taken that message ID's do not overlap, so that all message ID's only map to * the intented handlers no matter which MDI child window type is active. * The MDI client sends a SEL_CHANGED message to its target when the active MDI child is * switched, with the void* pointer refering to the new MDI child. * A MDI Window selection dialog can be brought up through the ID_MDI_OVER_X messages; * a menu button connected to the MDI client with the ID_MDI_OVER_X message will be * automatically grayed out if there are less than X MDI child windows. * The ID_MDI_ANY may be connected to a menu separator to cause automatic hiding of the * menu separator when no MDI child windows are present. */ class FXAPI FXMDIClient : public FXComposite { FXDECLARE(FXMDIClient) friend class FXMDIChild; protected: FXMDIChild *active; // Active child FXImage *backImage; // Optional background image FXint cascadex; // Cascade offset X FXint cascadey; // Cascade offset Y protected: FXMDIClient(); private: FXMDIClient(const FXMDIClient&); FXMDIClient &operator=(const FXMDIClient&); public: long onPaint(FXObject*,FXSelector,void*); long onCmdActivateNext(FXObject*,FXSelector,void*); long onCmdActivatePrev(FXObject*,FXSelector,void*); long onCmdTileHorizontal(FXObject*,FXSelector,void*); long onCmdTileVertical(FXObject*,FXSelector,void*); long onCmdCascade(FXObject*,FXSelector,void*); long onUpdActivateNext(FXObject*,FXSelector,void*); long onUpdActivatePrev(FXObject*,FXSelector,void*); long onUpdTileVertical(FXObject*,FXSelector,void*); long onUpdTileHorizontal(FXObject*,FXSelector,void*); long onUpdCascade(FXObject*,FXSelector,void*); long onUpdClose(FXObject*,FXSelector,void*); long onUpdMenuClose(FXObject*,FXSelector,void*); long onUpdRestore(FXObject*,FXSelector,void*); long onUpdMenuRestore(FXObject*,FXSelector,void*); long onUpdMinimize(FXObject*,FXSelector,void*); long onUpdMenuMinimize(FXObject*,FXSelector,void*); long onUpdMaximize(FXObject*,FXSelector,void*); long onUpdMenuWindow(FXObject*,FXSelector,void*); long onCmdWindowSelect(FXObject*,FXSelector,void*); long onUpdWindowSelect(FXObject*,FXSelector,void*); long onCmdOthersWindows(FXObject*,FXSelector,void*); long onUpdOthersWindows(FXObject*,FXSelector,void*); long onUpdAnyWindows(FXObject*,FXSelector,void*); virtual long onDefault(FXObject*,FXSelector,void*); public: enum { ID_MDI_ANY=65400, ID_MDI_1, // Select MDI child 1 ID_MDI_2, ID_MDI_3, ID_MDI_4, ID_MDI_5, ID_MDI_6, ID_MDI_7, ID_MDI_8, ID_MDI_9, ID_MDI_10, ID_MDI_OVER_1, // Sensitize MDI menu when 1 or more children ID_MDI_OVER_2, ID_MDI_OVER_3, ID_MDI_OVER_4, ID_MDI_OVER_5, ID_MDI_OVER_6, ID_MDI_OVER_7, ID_MDI_OVER_8, ID_MDI_OVER_9, ID_MDI_OVER_10, ID_LAST }; public: /// Construct MDI Client window FXMDIClient(FXComposite* p,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Create window virtual void create(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Perform layout virtual void layout(); /** * Pass message to all MDI windows, stopping when one of * the MDI windows fails to handle the message. */ long forallWindows(FXObject* sender,FXSelector sel,void* ptr); /** * Pass message once to all MDI windows with the same document, * stopping when one of the MDI windows fails to handle the message. */ long forallDocuments(FXObject* sender,FXSelector sel,void* ptr); /** * Pass message to all MDI Child windows whose target is document, * stopping when one of the MDI windows fails to handle the message. */ long forallDocWindows(FXObject* document,FXObject* sender,FXSelector sel,void* ptr); /// Set active MDI Child virtual FXbool setActiveChild(FXMDIChild* child=nullptr,FXbool notify=true); /// Get current active child; may be NULL! FXMDIChild* getActiveChild() const { return active; } /// Get active document; this is the target of the active MDI Child, if any FXObject* getActiveDocument() const; /// Change background image void setBackImage(FXImage* img); /// Return background image FXImage* getBackImage() const { return backImage; } /// Cascade windows virtual void cascade(FXbool notify=false); /// Layout horizontally virtual void horizontal(FXbool notify=false); /// Layout vertically virtual void vertical(FXbool notify=false); /// Change cascade offset X void setCascadeX(FXint off){ cascadex=off; } /// Change cascade offset Y void setCascadeY(FXint off){ cascadey=off; } /// Get cascade offset X FXint getCascadeX() const { return cascadex; } /// Get cascade offset Y FXint getCascadeY() const { return cascadey; } /// Save object to a stream virtual void save(FXStream& store) const; /// Load object from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXMDIClient(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMainWindow.h000066400000000000000000000053071455751074500231510ustar00rootroot00000000000000/******************************************************************************** * * * M a i n W i n d o w W i d g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMAINWINDOW_H #define FXMAINWINDOW_H #ifndef FXTOPWINDOW_H #include "FXTopWindow.h" #endif namespace FX { /** * The Main Window is usually the central window of an application. Applications * may have any number of main windows. * When a MainWindow is closed, it sends a SEL_CLOSE message to its target; the target * should return 0 if there is no objection against proceeding with the close, and * return 1 otherwise. * After the SEL_CLOSE message has been sent and no objection was raised, the main * window will delete itself. */ class FXAPI FXMainWindow : public FXTopWindow { FXDECLARE(FXMainWindow) protected: FXMainWindow(){} private: FXMainWindow(const FXMainWindow&); FXMainWindow &operator=(const FXMainWindow&); public: /// Construct a main window FXMainWindow(FXApp* a,const FXString& name,FXIcon *ic=nullptr,FXIcon *mi=nullptr,FXuint opts=DECOR_ALL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=0,FXint pr=0,FXint pt=0,FXint pb=0,FXint hs=0,FXint vs=0); /// Create server-side resources virtual void create(); /// Destructor virtual ~FXMainWindow(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMappedFile.h000066400000000000000000000060561455751074500231050ustar00rootroot00000000000000/******************************************************************************** * * * M a p p e d F i l e C l a s s * * * ********************************************************************************* * Copyright (C) 2023 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMAPPEDFILE_H #define FXMAPPEDFILE_H #ifndef FXFILE_H #include "FXFile.h" #endif //////////////////////////// UNDER DEVELOPMENT //////////////////////////////// namespace FX { /** * Memory mapped file. */ class FXAPI FXMappedFile : public FXIODevice { private: FXInputHandle memhandle; // Handle for the map FXptr mempointer; // Memory base where it is mapped FXlong memlength; // Length of the map FXlong memoffset; // Offset of the map private: FXMappedFile(const FXMappedFile&); FXMappedFile &operator=(const FXMappedFile&); public: /// Construct a memory map FXMappedFile(); /// Open a file, and map a view of it into memory; the offset must be a multiple of the page size FXptr open(const FXString& filename,FXuint m=FXIO::Reading,FXuint perm=FXIO::AllReadWrite,FXlong len=0,FXlong off=0); /// Return true if serial access only virtual FXbool isSerial() const; /// Return pointer to memory area FXptr data() const { return mempointer; } /// Obtain length of the map FXival length() const { return memlength; } /// Obtain offset of the map FXlong offset() const { return memoffset; } /// Return size virtual FXlong size(); /// Flush to disk virtual FXbool flush(); /// Close file, and also the map virtual FXbool close(); /// Return memory mapping granularity static FXival granularity(); /// Destroy the map virtual ~FXMappedFile(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMat2d.h000066400000000000000000000126701455751074500220450ustar00rootroot00000000000000/******************************************************************************** * * * D o u b l e - P r e c i s i o n 2 x 2 M a t r i x * * * ********************************************************************************* * Copyright (C) 2003,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMAT2D_H #define FXMAT2D_H namespace FX { class FXMat3d; /// Double-precision 2x2 matrix class FXAPI FXMat2d { protected: FXVec2d m[2]; public: /// Default constructor; value is not initialized FXMat2d(){} /// Initialize matrix from scalar FXMat2d(FXdouble s); /// Initialize matrix from another matrix FXMat2d(const FXMat2d& s); /// Initialize from rotation and scaling part of 3x3 matrix FXMat2d(const FXMat3d& s); /// Initialize matrix from array FXMat2d(const FXdouble s[]); /// Initialize diagonal matrix FXMat2d(FXdouble a,FXdouble b); /// Initialize matrix from components FXMat2d(FXdouble a00,FXdouble a01,FXdouble a10,FXdouble a11); /// Initialize matrix from two vectors FXMat2d(const FXVec2d& a,const FXVec2d& b); /// Assignment from scalar FXMat2d& operator=(FXdouble s); /// Assignment FXMat2d& operator=(const FXMat2d& s); FXMat2d& operator=(const FXMat3d& s); /// Assignment from array FXMat2d& operator=(const FXdouble s[]); /// Set value from scalar FXMat2d& set(FXdouble s); /// Set value from another matrix FXMat2d& set(const FXMat2d& s); /// Set from rotation and scaling part of 3x3 matrix FXMat2d& set(const FXMat3d& s); /// Set value from array FXMat2d& set(const FXdouble s[]); /// Set diagonal matrix FXMat2d& set(FXdouble a,FXdouble b); /// Set value from components FXMat2d& set(FXdouble a00,FXdouble a01,FXdouble a10,FXdouble a11); /// Set value from two vectors FXMat2d& set(const FXVec2d& a,const FXVec2d& b); /// Assignment operators FXMat2d& operator+=(const FXMat2d& s); FXMat2d& operator-=(const FXMat2d& s); FXMat2d& operator*=(const FXMat2d& s); FXMat2d& operator*=(FXdouble s); FXMat2d& operator/=(FXdouble s); /// Indexing FXVec2d& operator[](FXint i){return m[i];} const FXVec2d& operator[](FXint i) const {return m[i];} /// Conversion operator FXdouble*(){return m[0];} operator const FXdouble*() const {return m[0];} /// Unary minus FXMat2d operator-() const; /// Set to identity matrix FXMat2d& identity(); /// Return true if identity matrix FXbool isIdentity() const; /// Multiply by rotation of phi FXMat2d& rot(FXdouble c,FXdouble s); FXMat2d& rot(FXdouble phi); /// Multiply by scaling FXMat2d& scale(FXdouble sx,FXdouble sy); FXMat2d& scale(FXdouble s); /// Determinant FXdouble det() const; /// Transpose FXMat2d transpose() const; /// Invert FXMat2d invert() const; /// Destructor ~FXMat2d(){} }; /// Matrix times vector extern FXAPI FXVec2d operator*(const FXMat2d& m,const FXVec2d& v); /// Vector times matrix extern FXAPI FXVec2d operator*(const FXVec2d& v,const FXMat2d& m); /// Matrix and matrix addition extern FXAPI FXMat2d operator+(const FXMat2d& a,const FXMat2d& b); extern FXAPI FXMat2d operator-(const FXMat2d& a,const FXMat2d& b); /// Matrix and matrix multiply extern FXAPI FXMat2d operator*(const FXMat2d& a,const FXMat2d& b); /// Scaling extern FXAPI FXMat2d operator*(FXdouble x,const FXMat2d& a); extern FXAPI FXMat2d operator*(const FXMat2d& a,FXdouble x); extern FXAPI FXMat2d operator/(const FXMat2d& a,FXdouble x); extern FXAPI FXMat2d operator/(FXdouble x,const FXMat2d& a); /// Equality tests extern FXAPI FXbool operator==(const FXMat2d& a,const FXMat2d& b); extern FXAPI FXbool operator!=(const FXMat2d& a,const FXMat2d& b); extern FXAPI FXbool operator==(const FXMat2d& a,FXdouble n); extern FXAPI FXbool operator!=(const FXMat2d& a,FXdouble n); extern FXAPI FXbool operator==(FXdouble n,const FXMat2d& a); extern FXAPI FXbool operator!=(FXdouble n,const FXMat2d& a); /// Orthogonalize matrix extern FXAPI FXMat2d orthogonalize(const FXMat2d& m); /// Save matrix to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXMat2d& m); /// Load matrix from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXMat2d& m); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMat2f.h000066400000000000000000000126251455751074500220470ustar00rootroot00000000000000/******************************************************************************** * * * S i n g l e - P r e c i s i o n 2 x 2 M a t r i x * * * ********************************************************************************* * Copyright (C) 2003,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMAT2F_H #define FXMAT2F_H namespace FX { class FXMat3f; /// Single-precision 2x2 matrix class FXAPI FXMat2f { protected: FXVec2f m[2]; public: /// Default constructor; value is not initialized FXMat2f(){} /// Initialize matrix from scalar FXMat2f(FXfloat s); /// Initialize matrix from another matrix FXMat2f(const FXMat2f& s); /// Initialize from rotation and scaling part of 3x3 matrix FXMat2f(const FXMat3f& s); /// Initialize matrix from array FXMat2f(const FXfloat s[]); /// Initialize diagonal matrix FXMat2f(FXfloat a,FXfloat b); /// Initialize matrix from components FXMat2f(FXfloat a00,FXfloat a01,FXfloat a10,FXfloat a11); /// Initialize matrix from three vectors FXMat2f(const FXVec2f& a,const FXVec2f& b); /// Assignment from scalar FXMat2f& operator=(FXfloat s); /// Assignment FXMat2f& operator=(const FXMat2f& s); FXMat2f& operator=(const FXMat3f& s); /// Assignment from array FXMat2f& operator=(const FXfloat s[]); /// Set value from scalar FXMat2f& set(FXfloat s); /// Set value from another matrix FXMat2f& set(const FXMat2f& s); /// Set from rotation and scaling part of 3x3 matrix FXMat2f& set(const FXMat3f& s); /// Set value from array FXMat2f& set(const FXfloat s[]); /// Set diagonal matrix FXMat2f& set(FXfloat a,FXfloat b); /// Set value from components FXMat2f& set(FXfloat a00,FXfloat a01,FXfloat a10,FXfloat a11); /// Set value from two vectors FXMat2f& set(const FXVec2f& a,const FXVec2f& b); /// Assignment operators FXMat2f& operator+=(const FXMat2f& s); FXMat2f& operator-=(const FXMat2f& s); FXMat2f& operator*=(const FXMat2f& s); FXMat2f& operator*=(FXfloat s); FXMat2f& operator/=(FXfloat s); /// Indexing FXVec2f& operator[](FXint i){return m[i];} const FXVec2f& operator[](FXint i) const {return m[i];} /// Conversion operator FXfloat*(){return m[0];} operator const FXfloat*() const {return m[0];} /// Unary minus FXMat2f operator-() const; /// Set to identity matrix FXMat2f& identity(); /// Return true if identity matrix FXbool isIdentity() const; /// Multiply by rotation of phi FXMat2f& rot(FXfloat c,FXfloat s); FXMat2f& rot(FXfloat phi); /// Multiply by scaling FXMat2f& scale(FXfloat sx,FXfloat sy); FXMat2f& scale(FXfloat s); /// Determinant FXfloat det() const; /// Transpose FXMat2f transpose() const; /// Invert FXMat2f invert() const; /// Destructor ~FXMat2f(){} }; /// Matrix times vector extern FXAPI FXVec2f operator*(const FXMat2f& m,const FXVec2f& v); /// Vector times matrix extern FXAPI FXVec2f operator*(const FXVec2f& v,const FXMat2f& m); /// Matrix and matrix addition extern FXAPI FXMat2f operator+(const FXMat2f& a,const FXMat2f& b); extern FXAPI FXMat2f operator-(const FXMat2f& a,const FXMat2f& b); /// Matrix and matrix multiply extern FXAPI FXMat2f operator*(const FXMat2f& a,const FXMat2f& b); /// Scaling extern FXAPI FXMat2f operator*(FXfloat x,const FXMat2f& a); extern FXAPI FXMat2f operator*(const FXMat2f& a,FXfloat x); extern FXAPI FXMat2f operator/(const FXMat2f& a,FXfloat x); extern FXAPI FXMat2f operator/(FXfloat x,const FXMat2f& a); /// Equality tests extern FXAPI FXbool operator==(const FXMat2f& a,const FXMat2f& b); extern FXAPI FXbool operator!=(const FXMat2f& a,const FXMat2f& b); extern FXAPI FXbool operator==(const FXMat2f& a,FXfloat n); extern FXAPI FXbool operator!=(const FXMat2f& a,FXfloat n); extern FXAPI FXbool operator==(FXfloat n,const FXMat2f& a); extern FXAPI FXbool operator!=(FXfloat n,const FXMat2f& a); /// Orthogonalize matrix extern FXAPI FXMat2f orthogonalize(const FXMat2f& m); /// Save matrix to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXMat2f& m); /// Load matrix from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXMat2f& m); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMat3d.h000066400000000000000000000154211455751074500220430ustar00rootroot00000000000000/******************************************************************************** * * * D o u b l e - P r e c i s i o n 3 x 3 M a t r i x * * * ********************************************************************************* * Copyright (C) 2003,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMAT3D_H #define FXMAT3D_H namespace FX { class FXQuatd; class FXMat2d; class FXMat4d; /// Double-precision 3x3 matrix class FXAPI FXMat3d { protected: FXVec3d m[3]; public: /// Default constructor; value is not initialized FXMat3d(){} /// Initialize matrix from scalar FXMat3d(FXdouble s); /// Initialize with 2x2 rotation and scale matrix FXMat3d(const FXMat2d& s); /// Initialize matrix from another matrix FXMat3d(const FXMat3d& s); /// Initialize from rotation and scaling part of 4x4 matrix FXMat3d(const FXMat4d& s); /// Initialize matrix from array FXMat3d(const FXdouble s[]); /// Initialize diagonal matrix FXMat3d(FXdouble a,FXdouble b,FXdouble c); /// Initialize matrix from components FXMat3d(FXdouble a00,FXdouble a01,FXdouble a02, FXdouble a10,FXdouble a11,FXdouble a12, FXdouble a20,FXdouble a21,FXdouble a22); /// Initialize matrix from three vectors FXMat3d(const FXVec3d& a,const FXVec3d& b,const FXVec3d& c); /// Initialize matrix from quaternion FXMat3d(const FXQuatd& quat); /// Assignment from scalar FXMat3d& operator=(FXdouble s); /// Assignment FXMat3d& operator=(const FXMat2d& s); FXMat3d& operator=(const FXMat3d& s); FXMat3d& operator=(const FXMat4d& s); /// Assignment from quaternion FXMat3d& operator=(const FXQuatd& quat); /// Assignment from array FXMat3d& operator=(const FXdouble s[]); /// Set value from scalar FXMat3d& set(FXdouble s); /// Set value from 2x2 rotation and scale matrix FXMat3d& set(const FXMat2d& s); /// Set value from another matrix FXMat3d& set(const FXMat3d& s); /// Set from rotation and scaling part of 4x4 matrix FXMat3d& set(const FXMat4d& s); /// Set value from array FXMat3d& set(const FXdouble s[]); /// Set diagonal matrix FXMat3d& set(FXdouble a,FXdouble b,FXdouble c); /// Set value from components FXMat3d& set(FXdouble a00,FXdouble a01,FXdouble a02, FXdouble a10,FXdouble a11,FXdouble a12, FXdouble a20,FXdouble a21,FXdouble a22); /// Set value from three vectors FXMat3d& set(const FXVec3d& a,const FXVec3d& b,const FXVec3d& c); /// Set value from quaternion FXMat3d& set(const FXQuatd& quat); /// Assignment operators FXMat3d& operator+=(const FXMat3d& w); FXMat3d& operator-=(const FXMat3d& w); FXMat3d& operator*=(const FXMat3d& w); FXMat3d& operator*=(FXdouble w); FXMat3d& operator/=(FXdouble w); /// Indexing FXVec3d& operator[](FXint i){return m[i];} const FXVec3d& operator[](FXint i) const {return m[i];} /// Conversion operator FXdouble*(){return m[0];} operator const FXdouble*() const {return m[0];} /// Unary minus FXMat3d operator-() const; /// Set to identity matrix FXMat3d& identity(); /// Return true if identity matrix FXbool isIdentity() const; /// Multiply by rotation about unit-quaternion FXMat3d& rot(const FXQuatd& q); /// Multiply by rotation c,s about unit axis FXMat3d& rot(const FXVec3d& v,FXdouble c,FXdouble s); /// Multiply by rotation of phi about unit axis FXMat3d& rot(const FXVec3d& v,FXdouble phi); /// Multiply by x-rotation FXMat3d& xrot(FXdouble c,FXdouble s); FXMat3d& xrot(FXdouble phi); /// Multiply by y-rotation FXMat3d& yrot(FXdouble c,FXdouble s); FXMat3d& yrot(FXdouble phi); /// Multiply by z-rotation FXMat3d& zrot(FXdouble c,FXdouble s); FXMat3d& zrot(FXdouble phi); /// Multiply by scaling FXMat3d& scale(FXdouble sx,FXdouble sy,FXdouble sz); FXMat3d& scale(const FXVec3d& v); FXMat3d& scale(FXdouble s); /// Determinant FXdouble det() const; /// Transpose FXMat3d transpose() const; /// Invert FXMat3d invert() const; /// Destructor ~FXMat3d(){} }; /// Matrix times vector extern FXAPI FXVec2d operator*(const FXMat3d& m,const FXVec2d& v); extern FXAPI FXVec3d operator*(const FXMat3d& m,const FXVec3d& v); /// Vector times matrix extern FXAPI FXVec2d operator*(const FXVec2d& v,const FXMat3d& m); extern FXAPI FXVec3d operator*(const FXVec3d& v,const FXMat3d& m); /// Matrix and matrix addition extern FXAPI FXMat3d operator+(const FXMat3d& a,const FXMat3d& b); extern FXAPI FXMat3d operator-(const FXMat3d& a,const FXMat3d& b); /// Matrix and matrix multiply extern FXAPI FXMat3d operator*(const FXMat3d& a,const FXMat3d& b); /// Scaling extern FXAPI FXMat3d operator*(FXdouble x,const FXMat3d& a); extern FXAPI FXMat3d operator*(const FXMat3d& a,FXdouble x); extern FXAPI FXMat3d operator/(const FXMat3d& a,FXdouble x); extern FXAPI FXMat3d operator/(FXdouble x,const FXMat3d& a); /// Equality tests extern FXAPI FXbool operator==(const FXMat3d& a,const FXMat3d& b); extern FXAPI FXbool operator!=(const FXMat3d& a,const FXMat3d& b); extern FXAPI FXbool operator==(const FXMat3d& a,FXdouble n); extern FXAPI FXbool operator!=(const FXMat3d& a,FXdouble n); extern FXAPI FXbool operator==(FXdouble n,const FXMat3d& a); extern FXAPI FXbool operator!=(FXdouble n,const FXMat3d& a); /// Orthogonalize matrix extern FXAPI FXMat3d orthogonalize(const FXMat3d& m); /// Save matrix to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXMat3d& m); /// Load matrix from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXMat3d& m); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMat3f.h000066400000000000000000000153261455751074500220510ustar00rootroot00000000000000/******************************************************************************** * * * S i n g l e - P r e c i s i o n 3 x 3 M a t r i x * * * ********************************************************************************* * Copyright (C) 2003,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMAT3F_H #define FXMAT3F_H namespace FX { class FXQuatf; class FXMat2f; class FXMat4f; /// Single-precision 3x3 matrix class FXAPI FXMat3f { protected: FXVec3f m[3]; public: /// Default constructor; value is not initialized FXMat3f(){} /// Initialize matrix from scalar FXMat3f(FXfloat s); /// Initialize with 2x2 rotation and scale matrix FXMat3f(const FXMat2f& s); /// Initialize matrix from another matrix FXMat3f(const FXMat3f& s); /// Initialize from rotation and scaling part of 4x4 matrix FXMat3f(const FXMat4f& s); /// Initialize matrix from array FXMat3f(const FXfloat s[]); /// Initialize diagonal matrix FXMat3f(FXfloat a,FXfloat b,FXfloat c); /// Initialize matrix from components FXMat3f(FXfloat a00,FXfloat a01,FXfloat a02, FXfloat a10,FXfloat a11,FXfloat a12, FXfloat a20,FXfloat a21,FXfloat a22); /// Initialize matrix from three vectors FXMat3f(const FXVec3f& a,const FXVec3f& b,const FXVec3f& c); /// Initialize matrix from quaternion FXMat3f(const FXQuatf& quat); /// Assignment from scalar FXMat3f& operator=(FXfloat s); /// Assignment FXMat3f& operator=(const FXMat2f& s); FXMat3f& operator=(const FXMat3f& s); FXMat3f& operator=(const FXMat4f& s); /// Assignment from quaternion FXMat3f& operator=(const FXQuatf& quat); /// Assignment from array FXMat3f& operator=(const FXfloat s[]); /// Set value from scalar FXMat3f& set(FXfloat s); /// Set value from 2x2 rotation and scale matrix FXMat3f& set(const FXMat2f& s); /// Set value from another matrix FXMat3f& set(const FXMat3f& s); /// Set from rotation and scaling part of 4x4 matrix FXMat3f& set(const FXMat4f& s); /// Set value from array FXMat3f& set(const FXfloat s[]); /// Set diagonal matrix FXMat3f& set(FXfloat a,FXfloat b,FXfloat c); /// Set value from components FXMat3f& set(FXfloat a00,FXfloat a01,FXfloat a02, FXfloat a10,FXfloat a11,FXfloat a12, FXfloat a20,FXfloat a21,FXfloat a22); /// Set value from three vectors FXMat3f& set(const FXVec3f& a,const FXVec3f& b,const FXVec3f& c); /// Set value from quaternion FXMat3f& set(const FXQuatf& quat); /// Assignment operators FXMat3f& operator+=(const FXMat3f& w); FXMat3f& operator-=(const FXMat3f& w); FXMat3f& operator*=(const FXMat3f& w); FXMat3f& operator*=(FXfloat w); FXMat3f& operator/=(FXfloat w); /// Indexing FXVec3f& operator[](FXint i){return m[i];} const FXVec3f& operator[](FXint i) const {return m[i];} /// Conversion operator FXfloat*(){return m[0];} operator const FXfloat*() const {return m[0];} /// Unary minus FXMat3f operator-() const; /// Set to identity matrix FXMat3f& identity(); /// Return true if identity matrix FXbool isIdentity() const; /// Multiply by rotation about unit-quaternion FXMat3f& rot(const FXQuatf& q); /// Multiply by rotation c,s about unit axis FXMat3f& rot(const FXVec3f& v,FXfloat c,FXfloat s); /// Multiply by rotation of phi about unit axis FXMat3f& rot(const FXVec3f& v,FXfloat phi); /// Multiply by x-rotation FXMat3f& xrot(FXfloat c,FXfloat s); FXMat3f& xrot(FXfloat phi); /// Multiply by y-rotation FXMat3f& yrot(FXfloat c,FXfloat s); FXMat3f& yrot(FXfloat phi); /// Multiply by z-rotation FXMat3f& zrot(FXfloat c,FXfloat s); FXMat3f& zrot(FXfloat phi); /// Multiply by scaling FXMat3f& scale(FXfloat sx,FXfloat sy,FXfloat sz); FXMat3f& scale(const FXVec3f& v); FXMat3f& scale(FXfloat s); /// Determinant FXfloat det() const; /// Transpose FXMat3f transpose() const; /// Invert FXMat3f invert() const; /// Destructor ~FXMat3f(){} }; /// Matrix times vector extern FXAPI FXVec2f operator*(const FXMat3f& m,const FXVec2f& v); extern FXAPI FXVec3f operator*(const FXMat3f& m,const FXVec3f& v); /// Vector times matrix extern FXAPI FXVec2f operator*(const FXVec2f& v,const FXMat3f& m); extern FXAPI FXVec3f operator*(const FXVec3f& v,const FXMat3f& m); /// Matrix and matrix addition extern FXAPI FXMat3f operator+(const FXMat3f& a,const FXMat3f& b); extern FXAPI FXMat3f operator-(const FXMat3f& a,const FXMat3f& b); /// Matrix and matrix multiply extern FXAPI FXMat3f operator*(const FXMat3f& a,const FXMat3f& b); /// Scaling extern FXAPI FXMat3f operator*(FXfloat x,const FXMat3f& a); extern FXAPI FXMat3f operator*(const FXMat3f& a,FXfloat x); extern FXAPI FXMat3f operator/(const FXMat3f& a,FXfloat x); extern FXAPI FXMat3f operator/(FXfloat x,const FXMat3f& a); /// Equality tests extern FXAPI FXbool operator==(const FXMat3f& a,const FXMat3f& b); extern FXAPI FXbool operator!=(const FXMat3f& a,const FXMat3f& b); extern FXAPI FXbool operator==(const FXMat3f& a,FXfloat n); extern FXAPI FXbool operator!=(const FXMat3f& a,FXfloat n); extern FXAPI FXbool operator==(FXfloat n,const FXMat3f& a); extern FXAPI FXbool operator!=(FXfloat n,const FXMat3f& a); /// Orthogonalize matrix extern FXAPI FXMat3f orthogonalize(const FXMat3f& m); /// Save matrix to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXMat3f& m); /// Load matrix from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXMat3f& m); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMat4d.h000066400000000000000000000204071455751074500220440ustar00rootroot00000000000000/******************************************************************************** * * * D o u b l e - P r e c i s i o n 4 x 4 M a t r i x * * * ********************************************************************************* * Copyright (C) 1994,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMAT4D_H #define FXMAT4D_H namespace FX { class FXQuatd; class FXMat3d; /// Double-precision 4x4 matrix class FXAPI FXMat4d { protected: FXVec4d m[4]; public: /// Default constructor; value is not initialized FXMat4d(){} /// Initialize matrix from scalar FXMat4d(FXdouble s); /// Initialize with 3x3 rotation and scaling matrix FXMat4d(const FXMat3d& s); /// Initialize matrix from another matrix FXMat4d(const FXMat4d& s); /// Initialize matrix from array FXMat4d(const FXdouble s[]); /// Initialize diagonal matrix FXMat4d(FXdouble a,FXdouble b,FXdouble c,FXdouble d); /// Initialize matrix from components FXMat4d(FXdouble a00,FXdouble a01,FXdouble a02,FXdouble a03, FXdouble a10,FXdouble a11,FXdouble a12,FXdouble a13, FXdouble a20,FXdouble a21,FXdouble a22,FXdouble a23, FXdouble a30,FXdouble a31,FXdouble a32,FXdouble a33); /// Initialize matrix from four vectors FXMat4d(const FXVec4d& a,const FXVec4d& b,const FXVec4d& c,const FXVec4d& d); /// Initialize matrix from quaternion FXMat4d(const FXQuatd& quat); /// Assignment from scalar FXMat4d& operator=(FXdouble s); /// Assignment FXMat4d& operator=(const FXMat3d& s); FXMat4d& operator=(const FXMat4d& s); /// Assignment from quaternion FXMat4d& operator=(const FXQuatd& quat); /// Assignment from array FXMat4d& operator=(const FXdouble s[]); /// Set value from scalar FXMat4d& set(FXdouble s); /// Set value from 3x3 rotation and scaling matrix FXMat4d& set(const FXMat3d& s); /// Set value from another matrix FXMat4d& set(const FXMat4d& s); /// Set value from array FXMat4d& set(const FXdouble s[]); /// Set diagonal matrix FXMat4d& set(FXdouble a,FXdouble b,FXdouble c,FXdouble d); /// Set value from components FXMat4d& set(FXdouble a00,FXdouble a01,FXdouble a02,FXdouble a03, FXdouble a10,FXdouble a11,FXdouble a12,FXdouble a13, FXdouble a20,FXdouble a21,FXdouble a22,FXdouble a23, FXdouble a30,FXdouble a31,FXdouble a32,FXdouble a33); /// Set value from four vectors FXMat4d& set(const FXVec4d& a,const FXVec4d& b,const FXVec4d& c,const FXVec4d& d); /// Set value from quaternion FXMat4d& set(const FXQuatd& quat); /// Assignment operators FXMat4d& operator+=(const FXMat4d& w); FXMat4d& operator-=(const FXMat4d& w); FXMat4d& operator*=(const FXMat4d& w); FXMat4d& operator*=(FXdouble w); FXMat4d& operator/=(FXdouble w); /// Indexing FXVec4d& operator[](FXint i){return m[i];} const FXVec4d& operator[](FXint i) const {return m[i];} /// Conversion operator FXdouble*(){return m[0];} operator const FXdouble*() const {return m[0];} /// Unary minus FXMat4d operator-() const; /// Set to identity matrix FXMat4d& identity(); /// Return true if identity matrix FXbool isIdentity() const; /// Set orthographic projection from view volume FXMat4d& setOrtho(FXdouble xlo,FXdouble xhi,FXdouble ylo,FXdouble yhi,FXdouble zlo,FXdouble zhi); /// Get view volume from orthographic projection void getOrtho(FXdouble& xlo,FXdouble& xhi,FXdouble& ylo,FXdouble& yhi,FXdouble& zlo,FXdouble& zhi) const; /// Set to inverse orthographic projection FXMat4d& setInverseOrtho(FXdouble xlo,FXdouble xhi,FXdouble ylo,FXdouble yhi,FXdouble zlo,FXdouble zhi); /// Set to perspective projection from view volume FXMat4d& setFrustum(FXdouble xlo,FXdouble xhi,FXdouble ylo,FXdouble yhi,FXdouble zlo,FXdouble zhi); /// Get view volume from perspective projection void getFrustum(FXdouble& xlo,FXdouble& xhi,FXdouble& ylo,FXdouble& yhi,FXdouble& zlo,FXdouble& zhi) const; /// Set to inverse perspective projection from view volume FXMat4d& setInverseFrustum(FXdouble xlo,FXdouble xhi,FXdouble ylo,FXdouble yhi,FXdouble zlo,FXdouble zhi); /// Multiply by left-hand matrix FXMat4d& left(); /// Multiply by rotation matrix FXMat4d& rot(const FXMat3d& r); /// Multiply by rotation about unit-quaternion FXMat4d& rot(const FXQuatd& q); /// Multiply by rotation c,s about unit axis FXMat4d& rot(const FXVec3d& v,FXdouble c,FXdouble s); /// Multiply by rotation of phi about unit axis FXMat4d& rot(const FXVec3d& v,FXdouble phi); /// Multiply by x-rotation FXMat4d& xrot(FXdouble c,FXdouble s); FXMat4d& xrot(FXdouble phi); /// Multiply by y-rotation FXMat4d& yrot(FXdouble c,FXdouble s); FXMat4d& yrot(FXdouble phi); /// Multiply by z-rotation FXMat4d& zrot(FXdouble c,FXdouble s); FXMat4d& zrot(FXdouble phi); /// Look at FXMat4d& look(const FXVec3d& from,const FXVec3d& to,const FXVec3d& up); /// Multiply by translation FXMat4d& trans(FXdouble tx,FXdouble ty,FXdouble tz); FXMat4d& trans(const FXVec3d& v); /// Multiply by scaling FXMat4d& scale(FXdouble sx,FXdouble sy,FXdouble sz); FXMat4d& scale(const FXVec3d& v); FXMat4d& scale(FXdouble s); /// Determinant FXdouble det() const; /// Transpose FXMat4d transpose() const; /// Invert FXMat4d invert() const; /// Invert affine matrix FXMat4d affineInvert() const; /// Invert rigid body transform matrix FXMat4d rigidInvert() const; /// Return normal-transformation matrix FXMat3d normalMatrix() const; /// Destructor ~FXMat4d(){} }; /// Matrix times vector extern FXAPI FXVec3d operator*(const FXMat4d& m,const FXVec3d& v); extern FXAPI FXVec4d operator*(const FXMat4d& m,const FXVec4d& v); /// Vector times matrix extern FXAPI FXVec3d operator*(const FXVec3d& v,const FXMat4d& m); extern FXAPI FXVec4d operator*(const FXVec4d& v,const FXMat4d& m); /// Matrix and matrix addition extern FXAPI FXMat4d operator+(const FXMat4d& a,const FXMat4d& b); extern FXAPI FXMat4d operator-(const FXMat4d& a,const FXMat4d& b); /// Matrix and matrix multiply extern FXAPI FXMat4d operator*(const FXMat4d& a,const FXMat4d& b); /// Scaling extern FXAPI FXMat4d operator*(FXdouble x,const FXMat4d& a); extern FXAPI FXMat4d operator*(const FXMat4d& a,FXdouble x); extern FXAPI FXMat4d operator/(const FXMat4d& a,FXdouble x); extern FXAPI FXMat4d operator/(FXdouble x,const FXMat4d& a); /// Equality tests extern FXAPI FXbool operator==(const FXMat4d& a,const FXMat4d& b); extern FXAPI FXbool operator!=(const FXMat4d& a,const FXMat4d& b); extern FXAPI FXbool operator==(const FXMat4d& a,FXdouble n); extern FXAPI FXbool operator!=(const FXMat4d& a,FXdouble n); extern FXAPI FXbool operator==(FXdouble n,const FXMat4d& a); extern FXAPI FXbool operator!=(FXdouble n,const FXMat4d& a); /// Orthogonalize matrix extern FXAPI FXMat4d orthogonalize(const FXMat4d& m); /// Save matrix to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXMat4d& m); /// Load matrix from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXMat4d& m); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMat4f.h000066400000000000000000000202251455751074500220440ustar00rootroot00000000000000/******************************************************************************** * * * S i n g l e - P r e c i s i o n 4 x 4 M a t r i x * * * ********************************************************************************* * Copyright (C) 1994,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMAT4F_H #define FXMAT4F_H namespace FX { class FXQuatf; class FXMat3f; /// Single-precision 4x4 matrix class FXAPI FXMat4f { protected: FXVec4f m[4]; public: /// Default constructor; value is not initialized FXMat4f(){} /// Initialize matrix from scalar FXMat4f(FXfloat s); /// Initialize with 3x3 rotation and scaling matrix FXMat4f(const FXMat3f& s); /// Initialize matrix from another matrix FXMat4f(const FXMat4f& s); /// Initialize matrix from array FXMat4f(const FXfloat s[]); /// Initialize diagonal matrix FXMat4f(FXfloat a,FXfloat b,FXfloat c,FXfloat d); /// Initialize matrix from components FXMat4f(FXfloat a00,FXfloat a01,FXfloat a02,FXfloat a03, FXfloat a10,FXfloat a11,FXfloat a12,FXfloat a13, FXfloat a20,FXfloat a21,FXfloat a22,FXfloat a23, FXfloat a30,FXfloat a31,FXfloat a32,FXfloat a33); /// Initialize matrix from four vectors FXMat4f(const FXVec4f& a,const FXVec4f& b,const FXVec4f& c,const FXVec4f& d); /// Initialize matrix from quaternion FXMat4f(const FXQuatf& quat); /// Assignment from scalar FXMat4f& operator=(FXfloat s); /// Assignment FXMat4f& operator=(const FXMat3f& s); FXMat4f& operator=(const FXMat4f& s); /// Assignment from quaternion FXMat4f& operator=(const FXQuatf& quat); /// Assignment from array FXMat4f& operator=(const FXfloat s[]); /// Set value from scalar FXMat4f& set(FXfloat s); /// Set value from 3x3 rotation and scaling matrix FXMat4f& set(const FXMat3f& s); /// Set value from another matrix FXMat4f& set(const FXMat4f& s); /// Set value from array FXMat4f& set(const FXfloat s[]); /// Set diagonal matrix FXMat4f& set(FXfloat a,FXfloat b,FXfloat c,FXfloat d); /// Set value from components FXMat4f& set(FXfloat a00,FXfloat a01,FXfloat a02,FXfloat a03, FXfloat a10,FXfloat a11,FXfloat a12,FXfloat a13, FXfloat a20,FXfloat a21,FXfloat a22,FXfloat a23, FXfloat a30,FXfloat a31,FXfloat a32,FXfloat a33); /// Set value from four vectors FXMat4f& set(const FXVec4f& a,const FXVec4f& b,const FXVec4f& c,const FXVec4f& d); /// Set value from quaternion FXMat4f& set(const FXQuatf& quat); /// Assignment operators FXMat4f& operator+=(const FXMat4f& s); FXMat4f& operator-=(const FXMat4f& s); FXMat4f& operator*=(const FXMat4f& s); FXMat4f& operator*=(FXfloat s); FXMat4f& operator/=(FXfloat s); /// Indexing FXVec4f& operator[](FXint i){return m[i];} const FXVec4f& operator[](FXint i) const {return m[i];} /// Conversion operator FXfloat*(){return m[0];} operator const FXfloat*() const {return m[0];} /// Unary minus FXMat4f operator-() const; /// Set to identity matrix FXMat4f& identity(); /// Return true if identity matrix FXbool isIdentity() const; /// Set orthographic projection from view volume FXMat4f& setOrtho(FXfloat xlo,FXfloat xhi,FXfloat ylo,FXfloat yhi,FXfloat zlo,FXfloat zhi); /// Get view volume from orthographic projection void getOrtho(FXfloat& xlo,FXfloat& xhi,FXfloat& ylo,FXfloat& yhi,FXfloat& zlo,FXfloat& zhi) const; /// Set to inverse orthographic projection FXMat4f& setInverseOrtho(FXfloat xlo,FXfloat xhi,FXfloat ylo,FXfloat yhi,FXfloat zlo,FXfloat zhi); /// Set to perspective projection from view volume FXMat4f& setFrustum(FXfloat xlo,FXfloat xhi,FXfloat ylo,FXfloat yhi,FXfloat zlo,FXfloat zhi); /// Get view volume from perspective projection void getFrustum(FXfloat& xlo,FXfloat& xhi,FXfloat& ylo,FXfloat& yhi,FXfloat& zlo,FXfloat& zhi) const; /// Set to inverse perspective projection from view volume FXMat4f& setInverseFrustum(FXfloat xlo,FXfloat xhi,FXfloat ylo,FXfloat yhi,FXfloat zlo,FXfloat zhi); /// Multiply by left-hand matrix FXMat4f& left(); /// Multiply by rotation matrix FXMat4f& rot(const FXMat3f& r); /// Multiply by rotation about unit-quaternion FXMat4f& rot(const FXQuatf& q); /// Multiply by rotation c,s about unit axis FXMat4f& rot(const FXVec3f& v,FXfloat c,FXfloat s); /// Multiply by rotation of phi about unit axis FXMat4f& rot(const FXVec3f& v,FXfloat phi); /// Multiply by x-rotation FXMat4f& xrot(FXfloat c,FXfloat s); FXMat4f& xrot(FXfloat phi); /// Multiply by y-rotation FXMat4f& yrot(FXfloat c,FXfloat s); FXMat4f& yrot(FXfloat phi); /// Multiply by z-rotation FXMat4f& zrot(FXfloat c,FXfloat s); FXMat4f& zrot(FXfloat phi); /// Look at FXMat4f& look(const FXVec3f& from,const FXVec3f& to,const FXVec3f& up); /// Multiply by translation FXMat4f& trans(FXfloat tx,FXfloat ty,FXfloat tz); FXMat4f& trans(const FXVec3f& v); /// Multiply by scaling FXMat4f& scale(FXfloat sx,FXfloat sy,FXfloat sz); FXMat4f& scale(const FXVec3f& v); FXMat4f& scale(FXfloat s); /// Determinant FXfloat det() const; /// Transpose FXMat4f transpose() const; /// Invert FXMat4f invert() const; /// Invert affine matrix FXMat4f affineInvert() const; /// Invert rigid body transform matrix FXMat4f rigidInvert() const; /// Return normal-transformation matrix FXMat3f normalMatrix() const; /// Destructor ~FXMat4f(){} }; /// Matrix times vector extern FXAPI FXVec3f operator*(const FXMat4f& m,const FXVec3f& v); extern FXAPI FXVec4f operator*(const FXMat4f& m,const FXVec4f& v); /// Vector times matrix extern FXAPI FXVec3f operator*(const FXVec3f& v,const FXMat4f& m); extern FXAPI FXVec4f operator*(const FXVec4f& v,const FXMat4f& m); /// Matrix and matrix addition extern FXAPI FXMat4f operator+(const FXMat4f& a,const FXMat4f& b); extern FXAPI FXMat4f operator-(const FXMat4f& a,const FXMat4f& b); /// Matrix and matrix multiply extern FXAPI FXMat4f operator*(const FXMat4f& a,const FXMat4f& b); /// Scaling extern FXAPI FXMat4f operator*(FXfloat x,const FXMat4f& a); extern FXAPI FXMat4f operator*(const FXMat4f& a,FXfloat x); extern FXAPI FXMat4f operator/(const FXMat4f& a,FXfloat x); extern FXAPI FXMat4f operator/(FXfloat x,const FXMat4f& a); /// Equality tests extern FXAPI FXbool operator==(const FXMat4f& a,const FXMat4f& b); extern FXAPI FXbool operator!=(const FXMat4f& a,const FXMat4f& b); extern FXAPI FXbool operator==(const FXMat4f& a,FXfloat n); extern FXAPI FXbool operator!=(const FXMat4f& a,FXfloat n); extern FXAPI FXbool operator==(FXfloat n,const FXMat4f& a); extern FXAPI FXbool operator!=(FXfloat n,const FXMat4f& a); /// Orthogonalize matrix extern FXAPI FXMat4f orthogonalize(const FXMat4f& m); /// Save matrix to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXMat4f& m); /// Load matrix from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXMat4f& m); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMatrix.h000066400000000000000000000110201455751074500223260ustar00rootroot00000000000000/******************************************************************************** * * * M a t r i x C o n t a i n e r W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMATRIX_H #define FXMATRIX_H #ifndef FXPACKER_H #include "FXPacker.h" #endif namespace FX { /// Matrix packing options enum { MATRIX_BY_ROWS = 0, /// Fixed number of rows, add columns as needed MATRIX_BY_COLUMNS = 0x00020000 /// Fixed number of columns, adding rows as needed }; /** * The Matrix layout manager automatically arranges its child windows * in rows and columns. If the matrix style is MATRIX_BY_ROWS, then * the matrix will have the given number of rows and the number of columns * grows as more child windows are added; if the matrix style is MATRIX_BY_COLUMNS, * then the number of columns is fixed and the number of rows grows as more children * are added. * If all children in a row (column) have the LAYOUT_FILL_ROW (LAYOUT_FILL_COLUMN) * hint set, then the row (column) will be stretchable as the matrix layout manager * itself is resized. If more than one row (column) is stretchable, the space is * apportioned to each stretchable row (column) proportionally. * Within each cell of the matrix, all other layout hints are observed. * For example, a child having LAYOUT_CENTER_Y and LAYOUT_FILL_X hints will * be centered in the Y-direction, while being stretched in the X-direction. * Empty cells can be obtained by simply placing a borderless FXFrame widget * as a space-holder. */ class FXAPI FXMatrix : public FXPacker { FXDECLARE(FXMatrix) protected: FXint num; protected: FXMatrix(){} private: FXMatrix(const FXMatrix&); FXMatrix &operator=(const FXMatrix&); public: long onFocusUp(FXObject*,FXSelector,void*); long onFocusDown(FXObject*,FXSelector,void*); long onFocusLeft(FXObject*,FXSelector,void*); long onFocusRight(FXObject*,FXSelector,void*); public: /// Construct a matrix layout manager with n rows or columns FXMatrix(FXComposite *p,FXint n=1,FXuint opts=MATRIX_BY_ROWS,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_SPACING,FXint pr=DEFAULT_SPACING,FXint pt=DEFAULT_SPACING,FXint pb=DEFAULT_SPACING,FXint hs=DEFAULT_SPACING,FXint vs=DEFAULT_SPACING); /// Perform layout virtual void layout(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Obtain the child placed at a certain row and column FXWindow* childAtRowCol(FXint r,FXint c) const; /// Return the row in which the given child is placed FXint rowOfChild(const FXWindow* child) const; /// Return the column in which the given child is placed FXint colOfChild(const FXWindow* child) const; /// Change the matrix style void setMatrixStyle(FXuint ph); /// Return the current matrix style FXuint getMatrixStyle() const; /// Change the number of rows void setNumRows(FXint nr); /// Return the number of rows FXint getNumRows() const; /// Change the number of columns void setNumColumns(FXint nc); /// Return the number of columns FXint getNumColumns() const; }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMemoryStream.h000066400000000000000000000171431455751074500235220ustar00rootroot00000000000000/******************************************************************************** * * * M e m o r y S t r e a m C l a s s e s * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMEMORYSTREAM_H #define FXMEMORYSTREAM_H #ifndef FXSTREAM_H #include "FXStream.h" #endif namespace FX { /// Memory Store Definition class FXAPI FXMemoryStream : public FXStream { protected: virtual FXuval writeBuffer(FXuval count); virtual FXuval readBuffer(FXuval count); private: FXMemoryStream(const FXMemoryStream&); FXMemoryStream &operator=(const FXMemoryStream&); public: /// Create memory stream FXMemoryStream(const FXObject* cont=nullptr); /// Create and open memory stream FXMemoryStream(FXStreamDirection save_or_load,FXuchar* data=nullptr,FXuval size=~0UL,FXbool owned=false); /** * Open memory stream. * When reading from the data buffer, the size parameter is optional. If not given, * the reader will need to know when to stop reading by some other means, like end-of-file * markers in the data. When writing, the size parameter must be set to reflect the actual * buffer size, and should be at least 16. * If the owned flag is true, the stream becomes the owner of the data buffer; otherwise, * the stream will not delete the buffer. * Passing NULL for the data buffer will cause the stream to allocate a buffer of the * given size. */ FXbool open(FXStreamDirection save_or_load,FXuchar* data=nullptr,FXuval size=~0UL,FXbool owned=false); /// Take buffer away from stream void takeBuffer(FXuchar*& data,FXuval& size); /// Give buffer to stream, making it the owner of this buffer void giveBuffer(FXuchar *data,FXuval size); /// Get position FXlong position() const { return FXStream::position(); } /// Move to position virtual FXbool position(FXlong offset,FXWhence whence=FXFromStart); /// Save single items to stream FXMemoryStream& operator<<(const FXuchar& v){ FXStream::operator<<(v); return *this; } FXMemoryStream& operator<<(const FXchar& v){ FXStream::operator<<(v); return *this; } FXMemoryStream& operator<<(const FXbool& v){ FXStream::operator<<(v); return *this; } FXMemoryStream& operator<<(const FXushort& v){ FXStream::operator<<(v); return *this; } FXMemoryStream& operator<<(const FXshort& v){ FXStream::operator<<(v); return *this; } FXMemoryStream& operator<<(const FXuint& v){ FXStream::operator<<(v); return *this; } FXMemoryStream& operator<<(const FXint& v){ FXStream::operator<<(v); return *this; } FXMemoryStream& operator<<(const FXfloat& v){ FXStream::operator<<(v); return *this; } FXMemoryStream& operator<<(const FXdouble& v){ FXStream::operator<<(v); return *this; } FXMemoryStream& operator<<(const FXlong& v){ FXStream::operator<<(v); return *this; } FXMemoryStream& operator<<(const FXulong& v){ FXStream::operator<<(v); return *this; } /// Save arrays of items to stream FXMemoryStream& save(const FXuchar* p,FXuval n){ FXStream::save(p,n); return *this; } FXMemoryStream& save(const FXchar* p,FXuval n){ FXStream::save(p,n); return *this; } FXMemoryStream& save(const FXbool* p,FXuval n){ FXStream::save(p,n); return *this; } FXMemoryStream& save(const FXushort* p,FXuval n){ FXStream::save(p,n); return *this; } FXMemoryStream& save(const FXshort* p,FXuval n){ FXStream::save(p,n); return *this; } FXMemoryStream& save(const FXuint* p,FXuval n){ FXStream::save(p,n); return *this; } FXMemoryStream& save(const FXint* p,FXuval n){ FXStream::save(p,n); return *this; } FXMemoryStream& save(const FXfloat* p,FXuval n){ FXStream::save(p,n); return *this; } FXMemoryStream& save(const FXdouble* p,FXuval n){ FXStream::save(p,n); return *this; } FXMemoryStream& save(const FXlong* p,FXuval n){ FXStream::save(p,n); return *this; } FXMemoryStream& save(const FXulong* p,FXuval n){ FXStream::save(p,n); return *this; } /// Load single items from stream FXMemoryStream& operator>>(FXuchar& v){ FXStream::operator>>(v); return *this; } FXMemoryStream& operator>>(FXchar& v){ FXStream::operator>>(v); return *this; } FXMemoryStream& operator>>(FXbool& v){ FXStream::operator>>(v); return *this; } FXMemoryStream& operator>>(FXushort& v){ FXStream::operator>>(v); return *this; } FXMemoryStream& operator>>(FXshort& v){ FXStream::operator>>(v); return *this; } FXMemoryStream& operator>>(FXuint& v){ FXStream::operator>>(v); return *this; } FXMemoryStream& operator>>(FXint& v){ FXStream::operator>>(v); return *this; } FXMemoryStream& operator>>(FXfloat& v){ FXStream::operator>>(v); return *this; } FXMemoryStream& operator>>(FXdouble& v){ FXStream::operator>>(v); return *this; } FXMemoryStream& operator>>(FXlong& v){ FXStream::operator>>(v); return *this; } FXMemoryStream& operator>>(FXulong& v){ FXStream::operator>>(v); return *this; } /// Load arrays of items from stream FXMemoryStream& load(FXuchar* p,FXuval n){ FXStream::load(p,n); return *this; } FXMemoryStream& load(FXchar* p,FXuval n){ FXStream::load(p,n); return *this; } FXMemoryStream& load(FXbool* p,FXuval n){ FXStream::load(p,n); return *this; } FXMemoryStream& load(FXushort* p,FXuval n){ FXStream::load(p,n); return *this; } FXMemoryStream& load(FXshort* p,FXuval n){ FXStream::load(p,n); return *this; } FXMemoryStream& load(FXuint* p,FXuval n){ FXStream::load(p,n); return *this; } FXMemoryStream& load(FXint* p,FXuval n){ FXStream::load(p,n); return *this; } FXMemoryStream& load(FXfloat* p,FXuval n){ FXStream::load(p,n); return *this; } FXMemoryStream& load(FXdouble* p,FXuval n){ FXStream::load(p,n); return *this; } FXMemoryStream& load(FXlong* p,FXuval n){ FXStream::load(p,n); return *this; } FXMemoryStream& load(FXulong* p,FXuval n){ FXStream::load(p,n); return *this; } /// Save object FXMemoryStream& saveObject(const FXObject* v){ FXStream::saveObject(v); return *this; } /// Load object FXMemoryStream& loadObject(FXObject*& v){ FXStream::loadObject(v); return *this; } /// Load object template FXMemoryStream& operator>>(TYPE*& obj){ return loadObject(reinterpret_cast(obj)); } /// Save object template FXMemoryStream& operator<<(const TYPE* obj){ return saveObject(static_cast(obj)); } /// Destructor virtual ~FXMemoryStream(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMenuBar.h000066400000000000000000000061761455751074500224330ustar00rootroot00000000000000/******************************************************************************** * * * M e n u B a r W i d g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMENUBAR_H #define FXMENUBAR_H #ifndef FXTOOLBAR_H #include "FXToolBar.h" #endif namespace FX { /// Menu bar class FXAPI FXMenuBar : public FXToolBar { FXDECLARE(FXMenuBar) protected: FXMenuBar(){} private: FXMenuBar(const FXMenuBar&); FXMenuBar &operator=(const FXMenuBar&); public: long onFocusLeft(FXObject*,FXSelector,void*); long onFocusRight(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onButtonPress(FXObject*,FXSelector,void*); long onButtonRelease(FXObject*,FXSelector,void*); long onCmdUnpost(FXObject*,FXSelector,void*); public: /** * Construct a floatable menubar * Normally, the menubar is docked under window p. * When floated, the menubar can be docked under window q, which is * typically an FXToolbarShell window. */ FXMenuBar(FXComposite* p,FXComposite* q,FXuint opts=LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FILL_X,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=3,FXint pr=3,FXint pt=2,FXint pb=2,FXint hs=DEFAULT_SPACING,FXint vs=DEFAULT_SPACING); /** * Construct a non-floatable menubar. * The menubar can not be undocked. */ FXMenuBar(FXComposite* p,FXuint opts,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=3,FXint pr=3,FXint pt=2,FXint pb=2,FXint hs=DEFAULT_SPACING,FXint vs=DEFAULT_SPACING); /// Returns true if specified coordinate (in parent's coordinate system) is in menubar virtual FXbool contains(FXint parentx,FXint parenty) const; }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMenuButton.h000066400000000000000000000167031455751074500231770ustar00rootroot00000000000000/******************************************************************************** * * * M e n u B u t t o n W i d g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMENUBUTTON_H #define FXMENUBUTTON_H #ifndef FXLABEL_H #include "FXLabel.h" #endif namespace FX { class FXPopup; // Menu button options enum { MENUBUTTON_AUTOGRAY = 0x00800000, /// Automatically gray out when no target MENUBUTTON_AUTOHIDE = 0x01000000, /// Automatically hide when no target MENUBUTTON_TOOLBAR = 0x02000000, /// Toolbar style MENUBUTTON_DOWN = 0, /// Popup window appears below menu button MENUBUTTON_UP = 0x04000000, /// Popup window appears above menu button MENUBUTTON_LEFT = 0x08000000, /// Popup window to the left of the menu button MENUBUTTON_RIGHT = MENUBUTTON_LEFT|MENUBUTTON_UP, /// Popup window to the right of the menu button MENUBUTTON_NOARROWS = 0x10000000, /// Do not show arrows MENUBUTTON_ATTACH_LEFT = 0, /// Popup attaches to the left side of the menu button MENUBUTTON_ATTACH_TOP = MENUBUTTON_ATTACH_LEFT, /// Popup attaches to the top of the menu button MENUBUTTON_ATTACH_RIGHT = 0x20000000, /// Popup attaches to the right side of the menu button MENUBUTTON_ATTACH_BOTTOM = MENUBUTTON_ATTACH_RIGHT, /// Popup attaches to the bottom of the menu button MENUBUTTON_ATTACH_CENTER = 0x40000000, /// Popup attaches to the center of the menu button MENUBUTTON_ATTACH_BOTH = MENUBUTTON_ATTACH_CENTER|MENUBUTTON_ATTACH_RIGHT /// Popup attaches to both sides of the menu button }; /** * A menu button posts a popup menu when clicked. * There are many ways to control the placement where the popup will appear; * first, the popup may be placed on either of the four sides relative to the * menu button; this is controlled by the flags MENUBUTTON_DOWN, etc. * Next, there are several attachment modes; the popup's left/bottom edge may * attach to the menu button's left/top edge, or the popup's right/top edge may * attach to the menu button's right/bottom edge, or both. * Also, the popup may apear centered relative to the menu button. * Finally, a small offset may be specified to displace the location of the * popup by a few pixels so as to account for borders and so on. * Normally, the menu button shows an arrow pointing to the direction where * the popup is set to appear; this can be turned off by passing the option * MENUBUTTON_NOARROWS. */ class FXAPI FXMenuButton : public FXLabel { FXDECLARE(FXMenuButton) protected: FXPopup *pane; // Pane to pop up FXint offsetx; // Shift attachment point x FXint offsety; // Shift attachment point y FXbool state; // Pane was popped protected: FXMenuButton(); private: FXMenuButton(const FXMenuButton&); FXMenuButton &operator=(const FXMenuButton&); public: long onPaint(FXObject*,FXSelector,void*); long onUpdate(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onFocusIn(FXObject*,FXSelector,void*); long onFocusOut(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onButtonPress(FXObject*,FXSelector,void*); long onButtonRelease(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onHotKeyPress(FXObject*,FXSelector,void*); long onHotKeyRelease(FXObject*,FXSelector,void*); long onCmdPost(FXObject*,FXSelector,void*); long onCmdUnpost(FXObject*,FXSelector,void*); public: /// Constructor FXMenuButton(FXComposite* p,const FXString& text,FXIcon* ic=nullptr,FXPopup* pup=nullptr,FXuint opts=JUSTIFY_NORMAL|ICON_BEFORE_TEXT|MENUBUTTON_DOWN,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Returns true because a menu button can receive focus virtual FXbool canFocus() const; /// Remove the focus from this window virtual void killFocus(); /// Return true if window logically contains the given point virtual FXbool contains(FXint parentx,FXint parenty) const; /// Change the popup menu void setMenu(FXPopup *pup); /// Return current popup menu FXPopup* getMenu() const { return pane; } /// Show or hide menu void showMenu(FXbool shw); /// Is the pane shown FXbool isMenuShown() const; /// Set X offset where menu pops up relative to button void setXOffset(FXint offx){ offsetx=offx; } /// Return current X offset FXint getXOffset() const { return offsetx; } /// Set Y offset where menu pops up relative to button void setYOffset(FXint offy){ offsety=offy; } /// Return current Y offset FXint getYOffset() const { return offsety; } /// Change menu button style void setButtonStyle(FXuint style); /// Get menu button style FXuint getButtonStyle() const; /// Change popup style void setPopupStyle(FXuint style); /// Get popup style FXuint getPopupStyle() const; /// Change attachment void setAttachment(FXuint att); /// Get attachment FXuint getAttachment() const; /// Save menu button to a stream virtual void save(FXStream& store) const; /// Load menu button from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXMenuButton(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMenuCaption.h000066400000000000000000000145331455751074500233200ustar00rootroot00000000000000/******************************************************************************** * * * M e n u C a p t i o n W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMENUCAPTION_H #define FXMENUCAPTION_H #ifndef FXWINDOW_H #include "FXWindow.h" #endif namespace FX { /// Menu Caption options enum { MENU_AUTOGRAY = 0x00008000, /// Automatically gray out when not updated MENU_AUTOHIDE = 0x00010000 /// Automatically hide button when not updated }; class FXIcon; class FXFont; /** * The menu caption is a widget which can be used as a caption above a number * of menu commands in a menu. * When passing a tab-separated list of fields in the text parameter, the caption * text is set to the first field, and the help string to the third field. * If the caption text contains an ampersand, the letter following it will be * underlined, and a suitable hotkey will be installed. The actual ampersand * will be removed. * To display an ampersand in the caption, use two consecutive ampersands. */ class FXAPI FXMenuCaption : public FXWindow { FXDECLARE(FXMenuCaption) protected: FXString label; // Text on the label FXIcon *icon; // Icon on the label FXFont *font; // Label font FXString help; // Help message FXString tip; // Tooltip FXColor textColor; // Text color FXColor selbackColor; // Selection background color FXColor seltextColor; // Selected text color FXColor hiliteColor; // Highlight color FXColor shadowColor; // Shadow color FXHotKey hotkey; // Hotkey FXint hotoff; // Offset in string protected: FXMenuCaption(); private: FXMenuCaption(const FXMenuCaption&); FXMenuCaption &operator=(const FXMenuCaption&); public: long onPaint(FXObject*,FXSelector,void*); long onUpdate(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdGetStringValue(FXObject*,FXSelector,void*); long onCmdSetStringValue(FXObject*,FXSelector,void*); long onCmdSetIconValue(FXObject*,FXSelector,void*); long onCmdGetIconValue(FXObject*,FXSelector,void*); long onCmdSetHelp(FXObject*,FXSelector,void*); long onCmdGetHelp(FXObject*,FXSelector,void*); long onCmdSetTip(FXObject*,FXSelector,void*); long onCmdGetTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); public: /// Construct a menu caption FXMenuCaption(FXComposite* p,const FXString& text,FXIcon* ic=nullptr,FXuint opts=0); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Enable the menu virtual void enable(); /// Disable the menu virtual void disable(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Change text and hotkey for this menu void setTextAndHotKey(const FXString& hotkeytext); /// Change the text for this menu void setText(const FXString& text); /// Get the text for this menu FXString getText() const { return label; } /// Set the icon for this menu void setIcon(FXIcon* ic); /// Get the icon for this menu FXIcon* getIcon() const { return icon; } /// Set the text font void setFont(FXFont* fnt); /// Return the text font FXFont* getFont() const { return font; } /// Set menu caption style void setMenuStyle(FXuint style); /// Get menu caption style FXuint getMenuStyle() const; /// Return the current text color void setTextColor(FXColor clr); /// Get the current text color FXColor getTextColor() const { return textColor; } /// Return the selection background color void setSelBackColor(FXColor clr); /// Return the selection background color FXColor getSelBackColor() const { return selbackColor; } /// Return the selection text color void setSelTextColor(FXColor clr); /// Return the selection text color FXColor getSelTextColor() const { return seltextColor; } /// Change highlight color void setHiliteColor(FXColor clr); /// Get highlight color FXColor getHiliteColor() const { return hiliteColor; } /// Change shadow color void setShadowColor(FXColor clr); /// Get shadow color FXColor getShadowColor() const { return shadowColor; } /// Set the status line help text for this menu void setHelpText(const FXString& text); /// Get the status line help text for this menu const FXString& getHelpText() const { return help; } /// Set the tool tip message for this menu void setTipText(const FXString& text){ tip=text; } /// Get the tool tip message for this menu const FXString& getTipText() const { return tip; } /// Save menu to a stream virtual void save(FXStream& store) const; /// Load menu from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXMenuCaption(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMenuCascade.h000066400000000000000000000073741455751074500232530ustar00rootroot00000000000000/******************************************************************************** * * * M e n u C a s c a d e W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMENUCASCADE_H #define FXMENUCASCADE_H #ifndef FXMENUCAPTION_H #include "FXMenuCaption.h" #endif namespace FX { class FXPopup; /** * The cascade menu widget is used to bring up a sub menu from a * pull down menu. */ class FXAPI FXMenuCascade : public FXMenuCaption { FXDECLARE(FXMenuCascade) protected: FXPopup *pane; protected: FXMenuCascade(); void drawTriangle(FXDCWindow& dc,FXint l,FXint t,FXint r,FXint b); private: FXMenuCascade(const FXMenuCascade&); FXMenuCascade &operator=(const FXMenuCascade&); public: long onPaint(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onButtonPress(FXObject*,FXSelector,void*); long onButtonRelease(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onHotKeyPress(FXObject*,FXSelector,void*); long onHotKeyRelease(FXObject*,FXSelector,void*); long onCmdPost(FXObject*,FXSelector,void*); long onCmdUnpost(FXObject*,FXSelector,void*); public: enum { ID_MENUTIMER=FXMenuCaption::ID_LAST, ID_LAST }; public: /// Construct a menu cascade responsible for the given popup menu FXMenuCascade(FXComposite* p,const FXString& text,FXIcon* ic=nullptr,FXPopup* pup=nullptr,FXuint opts=0); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Destroy server-side resources virtual void destroy(); /// Yes it can receive the focus virtual FXbool canFocus() const; /// Move the focus to this window virtual void setFocus(); /// Remove the focus from this window virtual void killFocus(); /// Set popup menu to pop up void setMenu(FXPopup *pup){ pane = pup; } /// Return popup menu FXPopup* getMenu() const { return pane; } /// True if this menu or is popup logically contains the mouse virtual FXbool contains(FXint parentx,FXint parenty) const; /// Save menu to a stream virtual void save(FXStream& store) const; /// Load menu from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXMenuCascade(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMenuCheck.h000066400000000000000000000073501455751074500227370ustar00rootroot00000000000000/******************************************************************************** * * * M e n u C h e c k W i d g e t * * * ********************************************************************************* * Copyright (C) 2002,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMENUCHECK_H #define FXMENUCHECK_H #ifndef FXMENUCOMMAND_H #include "FXMenuCommand.h" #endif namespace FX { /** * The menu check widget is used to change a state in the * application from a menu. Menu checks may reflect * the state of the application by graying out, becoming hidden, * or by a check mark. * When activated, a menu check sends a SEL_COMMAND to its target; * the void* argument of the message contains the new state. */ class FXAPI FXMenuCheck : public FXMenuCommand { FXDECLARE(FXMenuCheck) protected: FXColor boxColor; // Box color FXuchar check; // State of menu protected: FXMenuCheck(); private: FXMenuCheck(const FXMenuCheck&); FXMenuCheck &operator=(const FXMenuCheck&); public: long onPaint(FXObject*,FXSelector,void*); long onButtonPress(FXObject*,FXSelector,void*); long onButtonRelease(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onHotKeyPress(FXObject*,FXSelector,void*); long onHotKeyRelease(FXObject*,FXSelector,void*); long onCheck(FXObject*,FXSelector,void*); long onUncheck(FXObject*,FXSelector,void*); long onUnknown(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdAccel(FXObject*,FXSelector,void*); public: /// Construct a menu check FXMenuCheck(FXComposite* p,const FXString& text,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Set check state (true, false or maybe) void setCheck(FXuchar s=true); /// Get check state (true, false or maybe) FXuchar getCheck() const { return check; } /// Get the box background color FXColor getBoxColor() const { return boxColor; } /// Set the box background color void setBoxColor(FXColor clr); /// Save menu to a stream virtual void save(FXStream& store) const; /// Load menu from a stream virtual void load(FXStream& store); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMenuCommand.h000066400000000000000000000101741455751074500232760ustar00rootroot00000000000000/******************************************************************************** * * * M e n u C o m m a n d W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMENUCOMMAND_H #define FXMENUCOMMAND_H #ifndef FXMENUCAPTION_H #include "FXMenuCaption.h" #endif namespace FX { /** * The menu command widget is used to invoke a command in the * application from a menu. Menu commands may reflect * the state of the application by graying out, or becoming hidden. * When activated, a menu command sends a SEL_COMMAND to its target. * When passing a tab-separated list of fields in the text parameters, the caption * text is set to the first field, the accelerator to the second field, and the * help text to the third field (see description of menu caption). * If an accelerator string is given, the corresponding accelerator key combination * is parsed out and installed into the menu pane's owner's accelerator table. * Note that this means owners of menu panes should delete their menupanes properly * upon destruction. */ class FXAPI FXMenuCommand : public FXMenuCaption { FXDECLARE(FXMenuCommand) protected: FXString accel; // Accelerator string FXHotKey acckey; // Accelerator key protected: FXMenuCommand(); private: FXMenuCommand(const FXMenuCommand&); FXMenuCommand &operator=(const FXMenuCommand&); public: long onPaint(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onButtonPress(FXObject*,FXSelector,void*); long onButtonRelease(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onHotKeyPress(FXObject*,FXSelector,void*); long onHotKeyRelease(FXObject*,FXSelector,void*); long onCmdAccel(FXObject*,FXSelector,void*); public: /// Construct a menu command FXMenuCommand(FXComposite* p,const FXString& text,FXIcon* ic=nullptr,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Yes it can receive the focus virtual FXbool canFocus() const; /// Move the focus to this window virtual void setFocus(); /// Remove the focus from this window virtual void killFocus(); /// Set accelerator text; update accelerator if acc is true void setAccelText(const FXString& text,FXbool acc=false); /// Return accelarator text FXString getAccelText() const { return accel; } /// Save menu to a stream virtual void save(FXStream& store) const; /// Load menu from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXMenuCommand(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMenuPane.h000066400000000000000000000041511455751074500226010ustar00rootroot00000000000000/******************************************************************************** * * * M e n u P a n e W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMENUPANE_H #define FXMENUPANE_H #ifndef FXPOPUP_H #include "FXPopup.h" #endif namespace FX { /// Popup menu pane class FXAPI FXMenuPane : public FXPopup { FXDECLARE(FXMenuPane) protected: FXMenuPane(){} private: FXMenuPane(const FXMenuPane&); FXMenuPane &operator=(const FXMenuPane&); public: /// Construct menu pane FXMenuPane(FXWindow* owner,FXuint opts=0); /// Return true if popup contains this point virtual FXbool contains(FXint parentx,FXint parenty) const; }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMenuRadio.h000066400000000000000000000076631455751074500227670ustar00rootroot00000000000000/******************************************************************************** * * * M e n u R a d i o W i d g e t * * * ********************************************************************************* * Copyright (C) 2002,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMENURADIO_H #define FXMENURADIO_H #ifndef FXMENUCOMMAND_H #include "FXMenuCommand.h" #endif namespace FX { /** * The menu radio widget is used to invoke a command in the * application from a menu. Menu commands may reflect * the state of the application by graying out, becoming hidden, * or by a bullit. * When activated, a menu radio sends a SEL_COMMAND to its target; * the void* argument of the message contains the new state. * A collection of menu radio widgets which belong to each other * is supposed to be updated by a common SEL_UPDATE handler to * properly maintain the state between them. */ class FXAPI FXMenuRadio : public FXMenuCommand { FXDECLARE(FXMenuRadio) protected: FXColor radioColor; // Color of the radio FXuchar check; // State of menu protected: FXMenuRadio(); private: FXMenuRadio(const FXMenuRadio&); FXMenuRadio &operator=(const FXMenuRadio&); public: long onPaint(FXObject*,FXSelector,void*); long onButtonPress(FXObject*,FXSelector,void*); long onButtonRelease(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onHotKeyPress(FXObject*,FXSelector,void*); long onHotKeyRelease(FXObject*,FXSelector,void*); long onCheck(FXObject*,FXSelector,void*); long onUncheck(FXObject*,FXSelector,void*); long onUnknown(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdAccel(FXObject*,FXSelector,void*); public: /// Construct a menu radio FXMenuRadio(FXComposite* p,const FXString& text,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Set radio button state (true, false or maybe) void setCheck(FXuchar s=true); /// Get radio button state (true, false or maybe) FXuchar getCheck() const { return check; } /// Get the radio background color FXColor getRadioColor() const { return radioColor; } /// Set the radio background color void setRadioColor(FXColor clr); /// Save menu to a stream virtual void save(FXStream& store) const; /// Load menu from a stream virtual void load(FXStream& store); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMenuSeparator.h000066400000000000000000000063721455751074500236650ustar00rootroot00000000000000/******************************************************************************** * * * M e n u S e p a r a t o r W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMENUSEPARATOR_H #define FXMENUSEPARATOR_H #ifndef FXWINDOW_H #include "FXWindow.h" #endif namespace FX { /** * The menu separator is a simple decorative groove used to delineate items in a * popup menu. When a target/message is given, the menu separator is usually * connected to an instance of the recent files class using the ID_ANYFILES * message. This automatically hides the menu separator when no files are listed * in the recent files section. Another possible target is the MDI client using * the ID_MDI_ANY message: in this case, the menu separator will be automatically * hidden when no MDI child windows are present. */ class FXAPI FXMenuSeparator : public FXWindow { FXDECLARE(FXMenuSeparator) protected: FXColor hiliteColor; FXColor shadowColor; protected: FXMenuSeparator(); private: FXMenuSeparator(const FXMenuSeparator&); FXMenuSeparator &operator=(const FXMenuSeparator&); public: long onPaint(FXObject*,FXSelector,void*); public: /// Construct a menu separator FXMenuSeparator(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Change highlight color void setHiliteColor(FXColor clr); /// Get highlight color FXColor getHiliteColor() const { return hiliteColor; } /// Change shadow color void setShadowColor(FXColor clr); /// Get shadow color FXColor getShadowColor() const { return shadowColor; } /// Save menu to a stream virtual void save(FXStream& store) const; /// Load menu from a stream virtual void load(FXStream& store); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMenuTitle.h000066400000000000000000000074721455751074500230100ustar00rootroot00000000000000/******************************************************************************** * * * M e n u T i t l e W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMENUTITLE_H #define FXMENUTITLE_H #ifndef FXMENUCAPTION_H #include "FXMenuCaption.h" #endif namespace FX { class FXPopup; /** * A menu title is a child of a menu bar which is responsible * for popping up a pulldown menu. */ class FXAPI FXMenuTitle : public FXMenuCaption { FXDECLARE(FXMenuTitle) protected: FXPopup *pane; // Pane to pop up protected: FXMenuTitle(){} private: FXMenuTitle(const FXMenuTitle&); FXMenuTitle &operator=(const FXMenuTitle&); public: long onPaint(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onHotKeyPress(FXObject*,FXSelector,void*); long onHotKeyRelease(FXObject*,FXSelector,void*); long onFocusUp(FXObject*,FXSelector,void*); long onFocusDown(FXObject*,FXSelector,void*); long onFocusIn(FXObject*,FXSelector,void*); long onFocusOut(FXObject*,FXSelector,void*); long onCmdPost(FXObject*,FXSelector,void*); long onCmdUnpost(FXObject*,FXSelector,void*); public: /// Constructor FXMenuTitle(FXComposite* p,const FXString& text,FXIcon* ic=nullptr,FXPopup* pup=nullptr,FXuint opts=0); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Yes it can receive the focus virtual FXbool canFocus() const; /// Move the focus to this window virtual void setFocus(); /// Remove the focus from this window virtual void killFocus(); /// Set popup menu to pop up void setMenu(FXPopup *menu); /// Return popup menu FXPopup* getMenu() const { return pane; } /// True if this menu or is popup logically contains the mouse virtual FXbool contains(FXint parentx,FXint parenty) const; /// Save menu to a stream virtual void save(FXStream& store) const; /// Load menu from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXMenuTitle(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMessageBox.h000066400000000000000000000146441455751074500231360ustar00rootroot00000000000000/******************************************************************************** * * * M e s s a g e B o x e s * * * ********************************************************************************* * Copyright (C) 1997,2023 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMESSAGEBOX_H #define FXMESSAGEBOX_H #ifndef FXDIALOGBOX_H #include "FXDialogBox.h" #endif namespace FX { // Message box buttons enum { MBOX_OK = 0x10000000, /// Message box has a only an OK button MBOX_OK_CANCEL = 0x20000000, /// Message box has OK and CANCEL buttons MBOX_YES_NO = 0x30000000, /// Message box has YES and NO buttons MBOX_YES_NO_CANCEL = 0x40000000, /// Message box has YES, NO, and CANCEL buttons MBOX_QUIT_CANCEL = 0x50000000, /// Message box has QUIT and CANCEL buttons MBOX_QUIT_SAVE_CANCEL = 0x60000000, /// Message box has QUIT, SAVE, and CANCEL buttons MBOX_SKIP_SKIPALL_CANCEL = 0x70000000, /// Message box has SKIP, SKIP ALL, and CANCEL buttons MBOX_SAVE_CANCEL_DONTSAVE = 0x80000000, /// Message box has DON'T SAVE,CANCEL and SAVE buttons MBOX_YES_YESALL_NO_NOALL_CANCEL = 0xA0000000 /// Message box has YES, YES ALL, NO, NO ALL, and CANCEL buttons }; // Return values enum { MBOX_CLICKED_YES = 1, /// The YES button was clicked MBOX_CLICKED_NO = 2, /// The NO button was clicked MBOX_CLICKED_OK = 3, /// The OK button was clicked MBOX_CLICKED_CANCEL = 4, /// The CANCEL button was clicked MBOX_CLICKED_QUIT = 5, /// The QUIT button was clicked MBOX_CLICKED_SAVE = 6, /// The SAVE button was clicked MBOX_CLICKED_SKIP = 7, /// The SKIP button was clicked MBOX_CLICKED_SKIPALL = 8, /// The SKIP ALL button was clicked MBOX_CLICKED_YESALL = 9, /// The YES ALL button was clicked MBOX_CLICKED_NOALL = 10 /// The NO ALL button was clicked }; /** * A Message Box is a convenience class which provides a dialog for * very simple common yes/no type interactions with the user. * The message box has an optional icon, a title string, and the question * which is presented to the user. It also has up to three buttons which * furnish standard responses to the question. * Message boxes are usually ran modally: the question must be answered * before the program may continue. */ class FXAPI FXMessageBox : public FXDialogBox { FXDECLARE(FXMessageBox) protected: FXMessageBox(){} private: FXMessageBox(const FXMessageBox&); FXMessageBox &operator=(const FXMessageBox&); void initialize(const FXString& text,FXIcon* ic,FXuint whichbuttons); public: long onCmdClicked(FXObject*,FXSelector,void*); long onCmdCancel(FXObject*,FXSelector,void*); public: enum{ ID_CLICKED_YES=FXDialogBox::ID_LAST, ID_CLICKED_NO, ID_CLICKED_OK, ID_CLICKED_CANCEL, ID_CLICKED_QUIT, ID_CLICKED_SAVE, ID_CLICKED_SKIP, ID_CLICKED_SKIPALL, ID_CLICKED_YESALL, ID_CLICKED_NOALL, ID_LAST }; public: /// Construct message box with given caption, icon, and message text FXMessageBox(FXWindow* owner,const FXString& caption,const FXString& text,FXIcon* ic=nullptr,FXuint opts=0,FXint x=0,FXint y=0); /// Construct free floating message box with given caption, icon, and message text FXMessageBox(FXApp* app,const FXString& caption,const FXString& text,FXIcon* ic=nullptr,FXuint opts=0,FXint x=0,FXint y=0); /** * Show a modal error message. * The text message may contain printf-tyle formatting commands. */ static FXuint error(FXWindow* owner,FXuint opts,const char* caption,const char* message,...) FX_PRINTF(4,5) ; /** * Show modal error message, in free floating window. */ static FXuint error(FXApp* app,FXuint opts,const char* caption,const char* message,...) FX_PRINTF(4,5) ; /** * Show a modal warning message * The text message may contain printf-tyle formatting commands. */ static FXuint warning(FXWindow* owner,FXuint opts,const char* caption,const char* message,...) FX_PRINTF(4,5) ; /** * Show modal warning message, in free floating window. */ static FXuint warning(FXApp* app,FXuint opts,const char* caption,const char* message,...) FX_PRINTF(4,5) ; /** * Show a modal question dialog * The text message may contain printf-tyle formatting commands. */ static FXuint question(FXWindow* owner,FXuint opts,const char* caption,const char* message,...) FX_PRINTF(4,5) ; /** * Show modal question message, in free floating window. */ static FXuint question(FXApp* app,FXuint opts,const char* caption,const char* message,...) FX_PRINTF(4,5) ; /** * Show a modal information dialog * The text message may contain printf-tyle formatting commands. */ static FXuint information(FXWindow* owner,FXuint opts,const char* caption,const char* message,...) FX_PRINTF(4,5) ; /** * Show modal information message, in free floating window. */ static FXuint information(FXApp* app,FXuint opts,const char* caption,const char* message,...) FX_PRINTF(4,5) ; }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMessageChannel.h000066400000000000000000000077561455751074500237640ustar00rootroot00000000000000/******************************************************************************** * * * I n t e r - T h r e a d M e s s a g i n g C h a n n e l * * * ********************************************************************************* * Copyright (C) 2006,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMESSAGECHANNEL_H #define FXMESSAGECHANNEL_H #ifndef FXOBJECT_H #include "FXObject.h" #endif namespace FX { class FXApp; /** * FXMessageChannel manages a messaging channel between a worker thread and the main * user-interface thread. * When an FXMessageChannel is constructed, it automatically calls addInput() function to * register itself as the message handler for the SEL_IO_READ message from FXApp. * Likewise, when FXMessageChannel is destroyed, it calls removeInput() to remove itself * as the message handler for the SEL_IO_READ message from FXApp. * When a worker thread calls the message() API, the target and message, as well * as optional message data, are written into the message channel. * The main user-interface thread is awakened and subsequently dispatches to the * onMessage handler of FXMessageChannel, which reads the target, selector, and optional * message data from the channel and then dispatches to this target using the given * selector. * Thus, FXMessageChannel provides a worker thread with a way to asynchronously invoke * any message handler in the context of the main user-interface thread. * If the size of the optional data is zero, the message handler will be passed a * NULL pointer. * The maximum payload size passed with message() is 8192 bytes. */ class FXAPI FXMessageChannel : public FXObject { FXDECLARE(FXMessageChannel) private: FXApp *app; protected: FXInputHandle h[3]; FXMutex m; protected: FXMessageChannel(); private: FXMessageChannel(const FXMessageChannel&); FXMessageChannel& operator=(const FXMessageChannel&); public: enum{ ID_IO_READ=1, ID_LAST }; public: long onMessage(FXObject*,FXSelector,void*); public: /** * Initialize message channel. * Adds the message channel to FXApp's input watch set. */ FXMessageChannel(FXApp* a); /** * Get application pointer. */ FXApp* getApp() const { return app; } /** * Send a message msg comprising of FXSEL(type,id) to a target tgt, and pass optional * data of size bytes. * This asynchronously calls the indicated handler in the context of the main GUI * thread's event loop. * Up to 8192 bytes may be passed along. */ FXbool message(FXObject* tgt,FXSelector msg,const void* data=nullptr,FXint size=0); /** * Clean up message channel. * Removes the message channel from FXApp's input watch set. */ virtual ~FXMessageChannel(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMetaClass.h000066400000000000000000000066671455751074500227630ustar00rootroot00000000000000/******************************************************************************** * * * M e t a C l a s s O b j e c t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMETACLASS_H #define FXMETACLASS_H namespace FX { class FXObject; /// Minimum and maximum message type enum { MINTYPE = 0, MAXTYPE = 65535 }; /// Minimum and maximum message id enum { MINKEY = 0, MAXKEY = 65535 }; /// Association key typedef FXuint FXSelector; /// Describes a FOX object class FXAPI FXMetaClass { private: const FXchar *className; // Class name FXObject* (*manufacture)(); // Factory function const FXMetaClass *baseClass; // Base classes' metaclass const void *assoc; // Associated handlers FXuint nassocs; // Count of handlers FXuint assocsz; // Size of association private: static const FXMetaClass **metaClassTable; // Class table static FXuint metaClassSlots; // Number of slots static FXuint metaClassCount; // Number items private: static void resize(FXuint slots); private: FXMetaClass(const FXMetaClass&); FXMetaClass &operator=(const FXMetaClass&); public: /// Create one metaclass for each class FXMetaClass(const FXchar* name,FXObject *(fac)(),const FXMetaClass* base,const void* ass,FXuint nass,FXuint assz); /// Make instance of some object FXObject* makeInstance() const; /// Search message map const void* search(FXSelector key) const; /// Ask class name const FXchar* getClassName() const { return className; } /// Ask base class const FXMetaClass* getBaseClass() const { return baseClass; } /// Check if metaclass is subclass of some other metaclass FXbool isSubClassOf(const FXMetaClass* metaclass) const; /// Find metaclass object static const FXMetaClass* getMetaClassFromName(const FXchar* name); /// Make NULL object static FXObject* nullObject(); /// Destroy metaclass ~FXMetaClass(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXMutex.h000066400000000000000000000105201455751074500221700ustar00rootroot00000000000000/******************************************************************************** * * * M u t e x C l a s s * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMUTEX_H #define FXMUTEX_H namespace FX { /** * FXMutex provides a mutex which can be used to enforce critical * sections around updates of data shared by multiple threads. */ class FXAPI FXMutex { friend class FXCondition; private: FXuval data[24]; private: FXMutex(const FXMutex&); FXMutex &operator=(const FXMutex&); public: /** * Initialize the mutex; if the parameter recursive is true, * the mutex is reentrant, i.e. counts the number of locks and unlocks. */ FXMutex(FXbool recursive=false); /// Lock the mutex void lock(); /// Return true if succeeded locking the mutex FXbool trylock(); /// Return true if mutex is already locked FXbool locked(); /// Unlock mutex void unlock(); /// Delete the mutex ~FXMutex(); }; /** * Establish a correspondence between a C++ scope and a FXMutex, * so that entering and leaving the scope in which the scoped lock * is defined will automatically lock and unlock the associated * mutex. * This will typically result in much less coding, and in addition * will make the code safe from exceptions. */ class FXAPI FXScopedMutex { private: FXMutex& mtx; private: FXScopedMutex(); FXScopedMutex(const FXScopedMutex&); FXScopedMutex& operator=(const FXScopedMutex&); public: /// Construct and lock associated mutex FXScopedMutex(FXMutex& m):mtx(m){ lock(); } /// Return reference to associated mutex FXMutex& mutex(){ return mtx; } /// Lock mutex void lock(){ mtx.lock(); } /// Return true if succeeded locking the mutex FXbool trylock(){ return mtx.trylock(); } /// Return true if mutex is already locked FXbool locked(){ return mtx.locked(); } /// Unlock mutex void unlock(){ mtx.unlock(); } /// Destroy and unlock associated mutex ~FXScopedMutex(){ unlock(); } }; /** * The Reverse Mutex unlocks its associated FXMutex when entering the * scope, and automatically relocks it upon exiting the scope. * Exceptions raised while in this region will automatically relock * the mutex upon leaving the enclosing scope. */ class FXAPI FXReverseMutex { private: FXMutex& mtx; private: FXReverseMutex(); FXReverseMutex(const FXReverseMutex&); FXReverseMutex& operator=(const FXReverseMutex&); public: /// Construct and unlock associated mutex FXReverseMutex(FXMutex& m):mtx(m){ unlock(); } /// Return reference to associated mutex FXMutex& mutex(){ return mtx; } /// Lock mutex void lock(){ mtx.lock(); } /// Return true if succeeded locking the mutex FXbool trylock(){ return mtx.trylock(); } /// Return true if mutex is already locked FXbool locked(){ return mtx.locked(); } /// Unlock mutex void unlock(){ mtx.unlock(); } /// Destroy and relock associated mutex ~FXReverseMutex(){ lock(); } }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXObject.h000066400000000000000000000126441455751074500223050ustar00rootroot00000000000000/******************************************************************************** * * * T o p l e v e l O b j e c t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXOBJECT_H #define FXOBJECT_H #ifndef FXMETACLASS_H #include "FXMetaClass.h" #endif namespace FX { class FXStream; /// Macro to set up class declaration #define FXDECLARE(classname) \ public: \ struct FXMapEntry { FX::FXSelector keylo; FX::FXSelector keyhi; long (classname::* func)(FX::FXObject*,FX::FXSelector,void*); }; \ static const FX::FXMetaClass metaClass; \ static FX::FXObject* manufacture(); \ virtual long handle(FX::FXObject* sender,FX::FXSelector sel,void* ptr); \ virtual const FX::FXMetaClass* getMetaClass() const { return &metaClass; } \ private: /// Macro to set up class implementation #define FXIMPLEMENT(classname,baseclassname,mapping,nmappings) \ FX::FXObject* classname::manufacture(){return new classname;} \ const FX::FXMetaClass classname::metaClass(#classname,classname::manufacture,&baseclassname::metaClass,mapping,nmappings,sizeof(classname::FXMapEntry)); \ long classname::handle(FX::FXObject* sender,FX::FXSelector sel,void* ptr){ \ const FXMapEntry* me=(const FXMapEntry*)metaClass.search(sel); \ return me ? (this->* me->func)(sender,sel,ptr) : baseclassname::handle(sender,sel,ptr); \ } /// Macro to set up abstract class declaration #define FXDECLARE_ABSTRACT(classname) \ public: \ struct FXMapEntry { FX::FXSelector keylo; FX::FXSelector keyhi; long (classname::* func)(FX::FXObject*,FX::FXSelector,void*); }; \ static const FX::FXMetaClass metaClass; \ virtual long handle(FX::FXObject* sender,FX::FXSelector sel,void* ptr); \ virtual const FX::FXMetaClass* getMetaClass() const { return &metaClass; } \ private: /// Macro to set up abstract class implementation #define FXIMPLEMENT_ABSTRACT(classname,baseclassname,mapping,nmappings) \ const FX::FXMetaClass classname::metaClass(#classname,FX::FXMetaClass::nullObject,&baseclassname::metaClass,mapping,nmappings,sizeof(classname::FXMapEntry)); \ long classname::handle(FX::FXObject* sender,FX::FXSelector sel,void* ptr){ \ const FXMapEntry* me=(const FXMapEntry*)metaClass.search(sel); \ return me ? (this->* me->func)(sender,sel,ptr) : baseclassname::handle(sender,sel,ptr); \ } /// MetaClass of a class #define FXMETACLASS(classname) (&classname::metaClass) /// Set up map type #define FXDEFMAP(classname) static const classname::FXMapEntry /// Define range of function types #define FXMAPTYPES(typelo,typehi,func) {FXSEL(typelo,FX::MINKEY),FXSEL(typehi,FX::MAXKEY),&func} /// Define range of function types #define FXMAPTYPE(type,func) {FXSEL(type,FX::MINKEY),FXSEL(type,FX::MAXKEY),&func} /// Define range of functions #define FXMAPFUNCS(type,keylo,keyhi,func) {FXSEL(type,keylo),FXSEL(type,keyhi),&func} /// Define one function #define FXMAPFUNC(type,key,func) {FXSEL(type,key),FXSEL(type,key),&func} /** * Object is the base class for all objects in FOX; in order to receive * messages from the user interface, your class must derive from Object. * The Object class also provides serialization facilities, with which * you can save and restore the object's state. If you've subclassed * from Object, you can save your subclasses' state by overloading the * save() and load() functions and use the stream API to serialize its * member data. */ class FXAPI FXObject { FXDECLARE(FXObject) public: /// Get class name of some object const FXchar* getClassName() const; /// Check if object is member of metaclass FXbool isMemberOf(const FXMetaClass* metaclass) const; /// Try handle message safely, catching certain exceptions virtual long tryHandle(FXObject* sender,FXSelector sel,void* ptr); /// Called for unhandled messages virtual long onDefault(FXObject*,FXSelector,void*); /// Save object to stream virtual void save(FXStream& store) const; /// Load object from stream virtual void load(FXStream& store); /// Virtual destructor virtual ~FXObject(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXObjectList.h000066400000000000000000000244541455751074500231430ustar00rootroot00000000000000/******************************************************************************** * * * O b j e c t L i s t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXOBJECTLIST_H #define FXOBJECTLIST_H #ifndef FXOBJECT_H #include "FXObject.h" #endif namespace FX { /// List of pointers to objects class FXAPI FXObjectList { protected: FXObject **ptr; public: /// Default constructor FXObjectList(); /// Copy constructor FXObjectList(const FXObjectList& other); /// Construct and init with single object FXObjectList(FXObject* object); /// Construct and init with n copies of object FXObjectList(FXObject* object,FXival n); /// Construct and init with list of objects FXObjectList(FXObject** objects,FXival n); /// Assignment operator FXObjectList& operator=(const FXObjectList& other); /// Adopt objects from other, leaving other empty FXObjectList& adopt(FXObjectList& other); /// Return number of objects FXival no() const { return *((FXival*)(ptr-1)); } /// Set number of objects FXbool no(FXival num); /// Indexing operator FXObject*& operator[](FXival i){ return ptr[i]; } FXObject* const& operator[](FXival i) const { return ptr[i]; } /// Indexing operator FXObject*& at(FXival i){ return ptr[i]; } FXObject* const& at(FXival i) const { return ptr[i]; } /// First element in list FXObject*& head(){ return ptr[0]; } FXObject* const& head() const { return ptr[0]; } /// Last element in list FXObject*& tail(){ return ptr[no()-1]; } FXObject* const& tail() const { return ptr[no()-1]; } /// Access to content array FXObject** data(){ return ptr; } FXObject *const * data() const { return ptr; } /// Find object in list, searching forward; return position or -1 FXival find(const FXObject *object,FXival pos=0) const; /// Find object in list, searching backward; return position or -1 FXival rfind(const FXObject *object,FXival pos=2147483647) const; /// Assign object to list FXbool assign(FXObject* object); /// Assign n copies of object to list FXbool assign(FXObject* object,FXival n); /// Assign n objects to list FXbool assign(FXObject** objects,FXival n); /// Assign objects to list FXbool assign(const FXObjectList& objects); /// Insert object at certain position FXbool insert(FXival pos,FXObject* object); /// Insert n copies of object at specified position FXbool insert(FXival pos,FXObject* object,FXival n); /// Insert n objects at specified position FXbool insert(FXival pos,FXObject** objects,FXival n); /// Insert objects at specified position FXbool insert(FXival pos,const FXObjectList& objects); /// Prepend object FXbool prepend(FXObject* object); /// Prepend n copies of object FXbool prepend(FXObject* object,FXival n); /// Prepend n objects FXbool prepend(FXObject** objects,FXival n); /// Prepend objects FXbool prepend(const FXObjectList& objects); /// Append object FXbool append(FXObject* object); /// Append n copies of object FXbool append(FXObject* object,FXival n); /// Append n objects FXbool append(FXObject** objects,FXival n); /// Append objects FXbool append(const FXObjectList& objects); /// Replace object at position by given object FXbool replace(FXival pos,FXObject* object); /// Replaces the m objects at pos with n copies of object FXbool replace(FXival pos,FXival m,FXObject* object,FXival n); /// Replaces the m objects at pos with n objects FXbool replace(FXival pos,FXival m,FXObject** objects,FXival n); /// Replace the m objects at pos with objects FXbool replace(FXival pos,FXival m,const FXObjectList& objects); /// Remove object at pos FXbool erase(FXival pos); /// Remove n objects at pos FXbool erase(FXival pos,FXival n); /// Remove object FXbool remove(const FXObject* object); /// Push object to end FXbool push(FXObject* object); /// Pop object from end FXbool pop(); /// Remove all objects FXbool clear(); /// Save to a stream void save(FXStream& store) const; /// Load from a stream void load(FXStream& store); /// Destructor ~FXObjectList(); }; /// List to pointers to objects of TYPE template class FXObjectListOf : public FXObjectList { public: /// Default constructor FXObjectListOf(){} /// Copy constructor FXObjectListOf(const FXObjectListOf& src):FXObjectList(src){ } /// Construct and init with single object FXObjectListOf(TYPE* object):FXObjectList(object){ } /// Construct and init with n copies of object FXObjectListOf(TYPE* object,FXival n):FXObjectList(object,n){ } /// Construct and init with list of objects FXObjectListOf(TYPE** objects,FXival n):FXObjectList(objects,n){ } /// Assignment operator FXObjectListOf& operator=(const FXObjectListOf& orig){ return reinterpret_cast&>(FXObjectList::operator=(orig)); } /// Adopt objects from src, leaving src empty FXObjectListOf& adopt(FXObjectListOf& src){ return reinterpret_cast&>(FXObjectList::adopt(src)); } /// Indexing operator TYPE*& operator[](FXival i){ return reinterpret_cast(ptr[i]); } TYPE *const& operator[](FXival i) const { return reinterpret_cast(ptr[i]); } /// Indexing operator TYPE*& at(FXival i){ return reinterpret_cast(ptr[i]); } TYPE *const& at(FXival i) const { return reinterpret_cast(ptr[i]); } /// First element in list TYPE*& head(){ return reinterpret_cast(ptr[0]); } TYPE* const& head() const { return reinterpret_cast(ptr[0]); } /// Last element in list TYPE*& tail(){ return reinterpret_cast(ptr[no()-1]); } TYPE* const& tail() const { return reinterpret_cast(ptr[no()-1]); } /// Access to content array TYPE** data(){ return reinterpret_cast(ptr); } TYPE *const * data() const { return reinterpret_cast(ptr); } /// Find object in list, searching forward; return position or -1 FXival find(TYPE* object,FXival pos=0) const { return FXObjectList::find(object,pos); } /// Find object in list, searching backward; return position or -1 FXival rfind(TYPE* object,FXival pos=2147483647) const { return FXObjectList::rfind(object,pos); } /// Assign object to list FXbool assign(TYPE* object){ return FXObjectList::assign(object); } /// Assign n copies of object to list FXbool assign(TYPE* object,FXival n){ return FXObjectList::assign(object,n); } /// Assign n objects to list FXbool assign(TYPE** objects,FXival n){ return FXObjectList::assign(objects,n); } /// Assign objects to list FXbool assign(const FXObjectListOf& objects){ return FXObjectList::assign(objects); } /// Insert object at certain position FXbool insert(FXival pos,TYPE* object){ return FXObjectList::insert(pos,object); } /// Insert n copies of object at specified position FXbool insert(FXival pos,TYPE* object,FXival n){ return FXObjectList::insert(pos,object,n); } /// Insert n objects at specified position FXbool insert(FXival pos,TYPE** objects,FXival n){ return FXObjectList::insert(pos,objects,n); } /// Insert objects at specified position FXbool insert(FXival pos,const FXObjectListOf& objects){ return FXObjectList::insert(pos,objects); } /// Prepend object FXbool prepend(TYPE* object){ return FXObjectList::prepend(object); } /// Prepend n copies of object FXbool prepend(TYPE* object,FXival n){ return FXObjectList::prepend(object,n); } /// Prepend n objects FXbool prepend(TYPE** objects,FXival n){ return FXObjectList::prepend(objects,n); } /// Prepend objects FXbool prepend(const FXObjectListOf& objects){ return FXObjectList::prepend(objects); } /// Append object FXbool append(TYPE* object){ return FXObjectList::append(object); } /// Append n copies of object FXbool append(TYPE* object,FXival n){ return FXObjectList::append(object,n); } /// Append n objects FXbool append(TYPE** objects,FXival n){ return FXObjectList::append(objects,n); } /// Append objects FXbool append(const FXObjectListOf& objects){ return FXObjectList::append(objects); } /// Replace object at position by given object FXbool replace(FXival pos,TYPE* object){ return FXObjectList::replace(pos,object); } /// Replaces the m objects at pos with n copies of object FXbool replace(FXival pos,FXival m,TYPE* object,FXival n){ return FXObjectList::replace(pos,m,object,n); } /// Replaces the m objects at pos with n objects FXbool replace(FXival pos,FXival m,TYPE** objects,FXival n){ return FXObjectList::replace(pos,m,objects,n); } /// Replace the m objects at pos with objects FXbool replace(FXival pos,FXival m,const FXObjectListOf& objects){ return FXObjectList::replace(pos,m,objects); } /// Remove object FXbool remove(TYPE* object){ return FXObjectList::remove(object); } /// Push object to end FXbool push(TYPE* object){ return FXObjectList::push(object); } }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXOptionMenu.h000066400000000000000000000147531455751074500231770ustar00rootroot00000000000000/******************************************************************************** * * * O p t i o n M e n u * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXOPTIONMENU_H #define FXOPTIONMENU_H #ifndef FXLABEL_H #include "FXLabel.h" #endif namespace FX { class FXPopup; /// Option Menu Button flags enum { OPTIONMENU_TOOLBAR = 0x00800000, /// Toolbar style button [flat look] OPTIONMENU_NOGLYPH = 0x01000000, /// Do not display a glyph }; /// Option Menu Button class FXAPI FXOption : public FXLabel { FXDECLARE(FXOption) protected: FXColor selbackColor; FXColor seltextColor; protected: FXOption(); private: FXOption(const FXOption&); FXOption &operator=(const FXOption&); public: long onPaint(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onHotKeyPress(FXObject*,FXSelector,void*); long onHotKeyRelease(FXObject*,FXSelector,void*); public: /// Constructor FXOption(FXComposite* p,const FXString& text,FXIcon* ic=nullptr,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=JUSTIFY_NORMAL|ICON_BEFORE_TEXT,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Returns true because a menu button can receive focus virtual FXbool canFocus() const; /// Set focus to this window virtual void setFocus(); /// Remove the focus from this window virtual void killFocus(); /// Return the selection background color void setSelBackColor(FXColor clr); /// Return the selection background color FXColor getSelBackColor() const { return selbackColor; } /// Return the selection text color void setSelTextColor(FXColor clr); /// Return the selection text color FXColor getSelTextColor() const { return seltextColor; } /// Destructor virtual ~FXOption(); }; /// Option Menu class FXAPI FXOptionMenu : public FXLabel { FXDECLARE(FXOptionMenu) protected: FXPopup *pane; FXOption *current; protected: FXOptionMenu(){} private: FXOptionMenu(const FXOptionMenu&); FXOptionMenu &operator=(const FXOptionMenu&); public: long onPaint(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onFocusIn(FXObject*,FXSelector,void*); long onFocusOut(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onCmdPost(FXObject*,FXSelector,void*); long onCmdUnpost(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onMouseWheel(FXObject*,FXSelector,void*); public: /// Constructor FXOptionMenu(FXComposite* p,FXPopup* pup=nullptr,FXuint opts=JUSTIFY_NORMAL|ICON_BEFORE_TEXT,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Delete server-side resources virtual void destroy(); /// Perform layout virtual void layout(); /// Remove the focus from this window virtual void killFocus(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Return true if the position is logically in the pane virtual FXbool contains(FXint parentx,FXint parenty) const; /// Return the option item at the given index FXOption *getItem(FXint index) const; /// Set the current option void setCurrent(FXOption *win,FXbool notify=false); /// Return the current option FXOption* getCurrent() const { return current; } /// Set the current option number void setCurrentNo(FXint no,FXbool notify=false); /// Get the current option number FXint getCurrentNo() const; /// Get number of options FXint getNumOptions() const; /// Set the pane which will be popped up void setMenu(FXPopup *pup); /// Return the pane which is poppup up FXPopup* getMenu() const { return pane; } /// Returns true because a option menu can receive focus virtual FXbool canFocus() const; /// Return true if popped up FXbool isPopped() const; /// Save option menu to a stream virtual void save(FXStream& store) const; /// Load option menu from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXOptionMenu(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXPCXIcon.h000066400000000000000000000057251455751074500223440ustar00rootroot00000000000000/******************************************************************************** * * * P C X I c o n O b j e c t * * * ********************************************************************************* * Copyright (C) 2001,2022 by Janusz Ganczarski. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXPCXICON_H #define FXPCXICON_H #ifndef FXICON_H #include "FXIcon.h" #endif namespace FX { /// PCX icon class FXAPI FXPCXIcon : public FXIcon { FXDECLARE(FXPCXIcon) protected: FXPCXIcon(){} private: FXPCXIcon(const FXPCXIcon&); FXPCXIcon &operator=(const FXPCXIcon&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct icon from memory stream formatted in PCX file format FXPCXIcon(FXApp* a,const FXuchar *pix=nullptr,FXColor clr=FXRGB(192,192,192),FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in PCX file format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in PCX file format virtual FXbool loadPixels(FXStream& store); /// Destroy icon virtual ~FXPCXIcon(); }; #ifndef FXLOADPCX #define FXLOADPCX /** * Check if stream contains a PCX, return true if so. */ extern FXAPI FXbool fxcheckPCX(FXStream& store); /** * Load an PCX (PC Paintbrush) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadPCX(FXStream& store,FXColor*& data,FXint& width,FXint& height); /** * Save an PCX (PC Paintbrush) file to a stream. */ extern FXAPI FXbool fxsavePCX(FXStream& store,const FXColor *data,FXint width,FXint height); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXPCXImage.h000066400000000000000000000057001455751074500224670ustar00rootroot00000000000000/******************************************************************************** * * * P C X I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 2001,2022 by Janusz Ganczarski. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXPCXIMAGE_H #define FXPCXIMAGE_H #ifndef FXIMAGE_H #include "FXImage.h" #endif namespace FX { /// PCX graphics file class FXAPI FXPCXImage : public FXImage { FXDECLARE(FXPCXImage) protected: FXPCXImage(){} private: FXPCXImage(const FXPCXImage&); FXPCXImage &operator=(const FXPCXImage&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct image from memory stream formatted in PCX file FXPCXImage(FXApp* a,const FXuchar *pix=nullptr,FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in PCX file virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in bitmap format virtual FXbool loadPixels(FXStream& store); /// Destroy icon virtual ~FXPCXImage(); }; #ifndef FXLOADPCX #define FXLOADPCX /** * Check if stream contains a PCX, return true if so. */ extern FXAPI FXbool fxcheckPCX(FXStream& store); /** * Load an PCX (PC Paintbrush) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadPCX(FXStream& store,FXColor*& data,FXint& width,FXint& height); /** * Save an PCX (PC Paintbrush) file to a stream. */ extern FXAPI FXbool fxsavePCX(FXStream& store,const FXColor *data,FXint width,FXint height); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXPNGIcon.h000066400000000000000000000061031455751074500223250ustar00rootroot00000000000000/******************************************************************************** * * * P N G I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 1999,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXPNGICON_H #define FXPNGICON_H #ifndef FXICON_H #include "FXIcon.h" #endif namespace FX { /// Portable Network Graphics (PNG) Icon class class FXAPI FXPNGIcon : public FXIcon { FXDECLARE(FXPNGIcon) protected: FXPNGIcon(){} private: FXPNGIcon(const FXPNGIcon&); FXPNGIcon &operator=(const FXPNGIcon&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct an icon from memory stream formatted in PNG format FXPNGIcon(FXApp *a,const FXuchar *pix=nullptr,FXColor clr=FXRGB(192,192,192),FXuint opts=0,FXint w=1,FXint h=1); /// True if format is supported static const FXbool supported; /// Save pixels into stream in PNG format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in PNG format virtual FXbool loadPixels(FXStream& store); /// Destroy virtual ~FXPNGIcon(); }; #ifndef FXLOADPNG #define FXLOADPNG /** * Check if stream contains a PNG, return true if so. */ extern FXAPI FXbool fxcheckPNG(FXStream& store); /** * Load an PNG (Portable Network Graphics) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadPNG(FXStream& store,FXColor*& data,FXint& width,FXint& height); /** * Save an PNG (Portable Network Graphics) file to a stream. */ extern FXAPI FXbool fxsavePNG(FXStream& store,const FXColor* data,FXint width,FXint height); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXPNGImage.h000066400000000000000000000060641455751074500224650ustar00rootroot00000000000000/******************************************************************************** * * * P N G I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 1999,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXPNGIMAGE_H #define FXPNGIMAGE_H #ifndef FXIMAGE_H #include "FXImage.h" #endif namespace FX { /// Portable Network Graphics (PNG) Image class class FXAPI FXPNGImage : public FXImage { FXDECLARE(FXPNGImage) protected: FXPNGImage(){} private: FXPNGImage(const FXPNGImage&); FXPNGImage &operator=(const FXPNGImage&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct an image from memory stream formatted in PNG format FXPNGImage(FXApp *a,const FXuchar *pix=nullptr,FXuint opts=0,FXint w=1,FXint h=1); /// True if format is supported static const FXbool supported; /// Load pixels from stream in PNG format virtual FXbool savePixels(FXStream& store) const; /// Save pixels into stream in PNG format virtual FXbool loadPixels(FXStream& store); /// Destroy virtual ~FXPNGImage(); }; #ifndef FXLOADPNG #define FXLOADPNG /** * Check if stream contains a PNG, return true if so. */ extern FXAPI FXbool fxcheckPNG(FXStream& store); /** * Load an PNG (Portable Network Graphics) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadPNG(FXStream& store,FXColor*& data,FXint& width,FXint& height); /** * Save an PNG (Portable Network Graphics) file to a stream. */ extern FXAPI FXbool fxsavePNG(FXStream& store,const FXColor* data,FXint width,FXint height); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXPPMIcon.h000066400000000000000000000060111455751074500223330ustar00rootroot00000000000000/******************************************************************************** * * * P P M I c o n O b j e c t * * * ********************************************************************************* * Copyright (C) 2003,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXPPMICON_H #define FXPPMICON_H #ifndef FXICON_H #include "FXIcon.h" #endif namespace FX { /// Portable Pixmap icon class FXAPI FXPPMIcon : public FXIcon { FXDECLARE(FXPPMIcon) protected: FXPPMIcon(){} private: FXPPMIcon(const FXPPMIcon&); FXPPMIcon &operator=(const FXPPMIcon&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct icon from memory stream formatted in Portable Pixmap format FXPPMIcon(FXApp* a,const FXuchar *pix=nullptr,FXColor clr=FXRGB(192,192,192),FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in Portable Pixmap format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in Portable Pixmap format virtual FXbool loadPixels(FXStream& store); /// Destroy icon virtual ~FXPPMIcon(); }; #ifndef FXLOADPPM #define FXLOADPPM /** * Check if stream contains a PPM, return true if so. */ extern FXAPI FXbool fxcheckPPM(FXStream& store); /** * Load an PPM (Portable Pixmap Format) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadPPM(FXStream& store,FXColor*& data,FXint& width,FXint& height); /** * Save an PPM (Portable Pixmap Format) file to a stream. */ extern FXAPI FXbool fxsavePPM(FXStream& store,const FXColor *data,FXint width,FXint height); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXPPMImage.h000066400000000000000000000057711455751074500225010ustar00rootroot00000000000000/******************************************************************************** * * * P P M I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 2003,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXPPMIMAGE_H #define FXPPMIMAGE_H #ifndef FXIMAGE_H #include "FXImage.h" #endif namespace FX { /// Portable Pixmap Image class FXAPI FXPPMImage : public FXImage { FXDECLARE(FXPPMImage) protected: FXPPMImage(){} private: FXPPMImage(const FXPPMImage&); FXPPMImage &operator=(const FXPPMImage&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct icon from memory stream formatted in Portable Pixmap format FXPPMImage(FXApp* a,const FXuchar *pix=nullptr,FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in Portable Pixmap format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in Portable Pixmap format virtual FXbool loadPixels(FXStream& store); /// Destroy icon virtual ~FXPPMImage(); }; #ifndef FXLOADPPM #define FXLOADPPM /** * Check if stream contains a PPM, return true if so. */ extern FXAPI FXbool fxcheckPPM(FXStream& store); /** * Load an PPM (Portable Pixmap Format) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadPPM(FXStream& store,FXColor*& data,FXint& width,FXint& height); /** * Save an PPM (Portable Pixmap Format) file to a stream. */ extern FXAPI FXbool fxsavePPM(FXStream& store,const FXColor *data,FXint width,FXint height); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXPacker.h000066400000000000000000000146451455751074500223070ustar00rootroot00000000000000/******************************************************************************** * * * P a c k e r C o n t a i n e r W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXPACKER_H #define FXPACKER_H #ifndef FXCOMPOSITE_H #include "FXComposite.h" #endif namespace FX { /// Default spacing enum { DEFAULT_SPACING = 4 }; /** * Packer is a layout manager which automatically places child windows * inside its area against the left, right, top, or bottom side. * Each time a child is placed, the remaining space is decreased by the * amount of space taken by the child window. * The side against which a child is placed is determined by the LAYOUT_SIDE_TOP, * LAYOUT_SIDE_BOTTOM, LAYOUT_SIDE_LEFT, and LAYOUT_SIDE_RIGHT hints given by * the child window. Other layout hints from the child are observed as far as * sensible. So for example, a child placed against the right edge can still * have LAYOUT_FILL_Y or LAYOUT_TOP, and so on. * The last child may have both LAYOUT_FILL_X and LAYOUT_FILL_Y, in which * case it will be placed to take all remaining space. */ class FXAPI FXPacker : public FXComposite { FXDECLARE(FXPacker) protected: FXColor baseColor; // Base color FXColor hiliteColor; // Highlight color FXColor shadowColor; // Shadow color FXColor borderColor; // Border color FXint padtop; // Top margin FXint padbottom; // Bottom margin FXint padleft; // Left margin FXint padright; // Right margin FXint hspacing; // Horizontal child spacing FXint vspacing; // Vertical child spacing FXint border; // Border width protected: FXPacker(); void drawBorderRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawRaisedRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawSunkenRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawRidgeRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawGrooveRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawDoubleRaisedRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawDoubleSunkenRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawFocusRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawFrame(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); private: FXPacker(const FXPacker&); FXPacker &operator=(const FXPacker&); public: long onPaint(FXObject*,FXSelector,void*); long onFocusUp(FXObject*,FXSelector,void*); long onFocusDown(FXObject*,FXSelector,void*); long onFocusLeft(FXObject*,FXSelector,void*); long onFocusRight(FXObject*,FXSelector,void*); public: /// Construct packer layout manager FXPacker(FXComposite *p,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_SPACING,FXint pr=DEFAULT_SPACING,FXint pt=DEFAULT_SPACING,FXint pb=DEFAULT_SPACING,FXint hs=DEFAULT_SPACING,FXint vs=DEFAULT_SPACING); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Perform layout virtual void layout(); /// Change frame style void setFrameStyle(FXuint style); /// Get current frame style FXuint getFrameStyle() const; /// Change packing hints void setPackingHints(FXuint ph); /// Return packing hints FXuint getPackingHints() const; /// Get border width FXint getBorderWidth() const { return border; } /// Change top padding void setPadTop(FXint pt); /// Get top interior padding FXint getPadTop() const { return padtop; } /// Change bottom padding void setPadBottom(FXint pb); /// Get bottom interior padding FXint getPadBottom() const { return padbottom; } /// Change left padding void setPadLeft(FXint pl); /// Get left interior padding FXint getPadLeft() const { return padleft; } /// Change right padding void setPadRight(FXint pr); /// Get right interior padding FXint getPadRight() const { return padright; } /// Change highlight color void setHiliteColor(FXColor clr); /// Get highlight color FXColor getHiliteColor() const { return hiliteColor; } /// Change shadow color void setShadowColor(FXColor clr); /// Get shadow color FXColor getShadowColor() const { return shadowColor; } /// Change border color void setBorderColor(FXColor clr); /// Get border color FXColor getBorderColor() const { return borderColor; } /// Change base gui color void setBaseColor(FXColor clr); /// Get base gui color FXColor getBaseColor() const { return baseColor; } /// Change horizontal inter-child spacing void setHSpacing(FXint hs); /// Return current horizontal inter-child spacing FXint getHSpacing() const { return hspacing; } /// Change vertical inter-child spacing void setVSpacing(FXint vs); /// Return current vertical inter-child spacing FXint getVSpacing() const { return vspacing; } /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXParallel.h000066400000000000000000000340531455751074500226310ustar00rootroot00000000000000/******************************************************************************** * * * P a r a l l e l C o m p u t a t i o n * * * ********************************************************************************* * Copyright (C) 2012,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXPARALLEL_H #define FXPARALLEL_H namespace FX { enum{ FXParallelMax=128 // Maximum number of parallel jobs }; /** * FXParallelCallFunctor is a helper for FXParallelInvoke. It executes a functor on * a thread provided by the FXThreadPool. */ template class FXParallelCallFunctor : public FXRunnable { const Functor& functor; private: FXParallelCallFunctor(const FXParallelCallFunctor&); FXParallelCallFunctor &operator=(const FXParallelCallFunctor&); public: FXParallelCallFunctor(const Functor& fun):functor(fun){ } virtual FXint run(){ functor(); return 0; } }; /** * Perform a parallel call to functors fun1 and fun2 using the given FXThreadPool. * Return when all functors have completed. */ template void FXParallelInvoke(FXThreadPool* pool,const Functor1& fun1,const Functor2& fun2){ FXTaskGroup group(pool); FXParallelCallFunctor task1(fun1); FXParallelCallFunctor task2(fun2); group.execute(&task1); group.executeAndWait(&task2); } /** * Perform a parallel call to functors fun1 and fun2 using the FXThreadPool * associated with the calling thread. * Return when all functors have completed. */ template void FXParallelInvoke(const Functor1& fun1,const Functor2& fun2){ FXParallelInvoke(FXThreadPool::instance(),fun1,fun2); } /** * Perform a parallel call to functors fun1, fun2, and fun3, using the given FXThreadPool. * Return when all functors have completed. */ template void FXParallelInvoke(FXThreadPool* pool,const Functor1& fun1,const Functor2& fun2,const Functor3& fun3){ FXTaskGroup group(pool); FXParallelCallFunctor task1(fun1); FXParallelCallFunctor task2(fun2); FXParallelCallFunctor task3(fun3); group.execute(&task1); group.execute(&task2); group.executeAndWait(&task3); } /** * Perform a parallel call to functors fun1, fun2, and fun3, using the FXThreadPool * associated with the calling thread. * Return when all functors have completed. */ template void FXParallelInvoke(const Functor1& fun1,const Functor2& fun2,const Functor3& fun3){ FXParallelInvoke(FXThreadPool::instance(),fun1,fun2,fun3); } /** * Perform a parallel call to functors fun1, fun2, fun3, and fun4, using the given FXThreadPool. * Return when all functors have completed. */ template void FXParallelInvoke(FXThreadPool* pool,const Functor1& fun1,const Functor2& fun2,const Functor3& fun3,const Functor4& fun4){ FXTaskGroup group(pool); FXParallelCallFunctor task1(fun1); FXParallelCallFunctor task2(fun2); FXParallelCallFunctor task3(fun3); FXParallelCallFunctor task4(fun4); group.execute(&task1); group.execute(&task2); group.execute(&task3); group.executeAndWait(&task4); } /** * Perform a parallel call to functors fun1, fun2, fun3, and fun4, using the FXThreadPool * associated with the calling thread. * Return when all functors have completed. */ template void FXParallelInvoke(const Functor1& fun1,const Functor2& fun2,const Functor3& fun3,const Functor4& fun4){ FXParallelInvoke(FXThreadPool::instance(),fun1,fun2,fun3,fun4); } /** * Perform a parallel call to functors fun1, fun2, fun3, fun4, and fun5, using the given FXThreadPool. * Return when all functors have completed. */ template void FXParallelInvoke(FXThreadPool* pool,const Functor1& fun1,const Functor2& fun2,const Functor3& fun3,const Functor4& fun4,const Functor4& fun5){ FXTaskGroup group(pool); FXParallelCallFunctor task1(fun1); FXParallelCallFunctor task2(fun2); FXParallelCallFunctor task3(fun3); FXParallelCallFunctor task4(fun4); FXParallelCallFunctor task5(fun5); group.execute(&task1); group.execute(&task2); group.execute(&task3); group.execute(&task4); group.executeAndWait(&task5); } /** * Perform a parallel call to functors fun1, fun2, fun3, fun4, and fun5, using the * FXThreadPool associated with the calling thread. * Return when all functors have completed. */ template void FXParallelInvoke(const Functor1& fun1,const Functor2& fun2,const Functor3& fun3,const Functor4& fun4,const Functor4& fun5){ FXParallelInvoke(FXThreadPool::instance(),fun1,fun2,fun3,fun4,fun5); } /** * Perform a parallel call to functors fun1, fun2, fun3, fun4, fun5, and fun6, using the given FXThreadPool. * Return when all functors have completed. */ template void FXParallelInvoke(FXThreadPool* pool,const Functor1& fun1,const Functor2& fun2,const Functor3& fun3,const Functor4& fun4,const Functor5& fun5,const Functor6& fun6){ FXTaskGroup group(pool); FXParallelCallFunctor task1(fun1); FXParallelCallFunctor task2(fun2); FXParallelCallFunctor task3(fun3); FXParallelCallFunctor task4(fun4); FXParallelCallFunctor task5(fun5); FXParallelCallFunctor task6(fun6); group.execute(&task1); group.execute(&task2); group.execute(&task3); group.execute(&task4); group.execute(&task5); group.executeAndWait(&task6); } /** * Perform a parallel call to functors fun1, fun2, fun3, fun4, fun5, and fun6, using the * FXThreadPool associated with the calling thread. * Return when all functors have completed. */ template void FXParallelInvoke(Functor1& fun1,const Functor2& fun2,const Functor3& fun3,const Functor4& fun4,const Functor5& fun5,const Functor6& fun6){ FXParallelInvoke(FXThreadPool::instance(),fun1,fun2,fun3,fun4,fun5,fun6); } /** * Perform a parallel call to functors fun1, fun2, fun3, fun4, fun5, fun6, and fun7, using the given FXThreadPool. * Return when all functors have completed. */ template void FXParallelInvoke(FXThreadPool* pool,const Functor1& fun1,const Functor2& fun2,const Functor3& fun3,const Functor4& fun4,const Functor5& fun5,const Functor6& fun6,const Functor7& fun7){ FXTaskGroup group(pool); FXParallelCallFunctor task1(fun1); FXParallelCallFunctor task2(fun2); FXParallelCallFunctor task3(fun3); FXParallelCallFunctor task4(fun4); FXParallelCallFunctor task5(fun5); FXParallelCallFunctor task6(fun6); FXParallelCallFunctor task7(fun7); group.execute(&task1); group.execute(&task2); group.execute(&task3); group.execute(&task4); group.execute(&task5); group.execute(&task6); group.executeAndWait(&task7); } /** * Perform a parallel call to functors fun1, fun2, fun3, fun4, fun5, fun6, and fun7, using the * FXThreadPool associated with the calling thread. * Return when all functors have completed. */ template void FXParallelInvoke(Functor1& fun1,const Functor2& fun2,const Functor3& fun3,const Functor4& fun4,const Functor5& fun5,const Functor6& fun6,const Functor7& fun7){ FXParallelInvoke(FXThreadPool::instance(),fun1,fun2,fun3,fun4,fun5,fun6,fun7); } /** * Perform a parallel call to functors fun1, fun2, fun3, fun4, fun5, fun6, fun7, and fun8, using * the given FXThreadPool. * Return when all functors have completed. */ template void FXParallelInvoke(FXThreadPool* pool,const Functor1& fun1,const Functor2& fun2,const Functor3& fun3,const Functor4& fun4,const Functor5& fun5,const Functor6& fun6,const Functor7& fun7,const Functor8& fun8){ FXTaskGroup group(pool); FXParallelCallFunctor task1(fun1); FXParallelCallFunctor task2(fun2); FXParallelCallFunctor task3(fun3); FXParallelCallFunctor task4(fun4); FXParallelCallFunctor task5(fun5); FXParallelCallFunctor task6(fun6); FXParallelCallFunctor task7(fun7); FXParallelCallFunctor task8(fun8); group.execute(&task1); group.execute(&task2); group.execute(&task3); group.execute(&task4); group.execute(&task5); group.execute(&task6); group.execute(&task7); group.executeAndWait(&task8); } /** * Perform a parallel call to functors fun1, fun2, fun3, fun4, fun5, fun6, fun7, and fun8, using the * FXThreadPool associated with the calling thread. * Return when all functors have completed. */ template void FXParallelInvoke(Functor1& fun1,const Functor2& fun2,const Functor3& fun3,const Functor4& fun4,const Functor5& fun5,const Functor6& fun6,const Functor7& fun7,const Functor8& fun8){ FXParallelInvoke(FXThreadPool::instance(),fun1,fun2,fun3,fun4,fun5,fun6,fun7,fun8); } /*******************************************************************************/ /** * FXParallelLoopFunctor is a helper for FXParallelFor. It executes a subrange of the * global indexing range on a thread provided by the FXThreadPool. */ template class FXParallelForFunctor : public FXRunnable { const Functor& functor; const Index fm; const Index to; const Index by; private: FXParallelForFunctor(const FXParallelForFunctor&); FXParallelForFunctor &operator=(const FXParallelForFunctor&); public: FXParallelForFunctor(const Functor& fun,Index f,Index t,Index b):functor(fun),fm(f),to(t),by(b){ } virtual FXint run(){ for(Index ix=fm;ix void FXParallelFor(FXThreadPool* pool,Index fm,Index to,Index by,Index nc,const Functor& fun){ const FXuval size=(sizeof(FXParallelForFunctor)+sizeof(FXulong)-1)/sizeof(FXulong); if(fm)+sizeof(FXulong)-1)/sizeof(FXulong))]; Index nits=1+(to-fm-1)/by,ni,c; if(nc>FXParallelMax) nc=FXParallelMax; if(nc>nits) nc=nits; for(c=0; c(fun,fm,fm+ni*by,by)); } group.wait(); } else{ fun(fm); } } } /** * Perform parallel for-loop executing functor fun(i) for indexes x=fm+by*i, where x void FXParallelFor(Index fm,Index to,Index by,Index nc,const Functor& fun){ FXParallelFor(FXThreadPool::instance(),fm,to,by,nc,fun); } /** * Perform parallel for loop executing functor fun(i) for indexes x=fm+by*i, where x void FXParallelFor(FXThreadPool* pool,Index fm,Index to,Index by,const Functor& fun){ FXParallelFor(pool,fm,to,by,(Index)pool->getMaximumThreads(),fun); } /** * Perform parallel for loop executing functor fun(i) for indexes x=fm+by*i, where x void FXParallelFor(Index fm,Index to,Index by,const Functor& fun){ FXParallelFor(FXThreadPool::instance(),fm,to,by,fun); } } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXParseBuffer.h000066400000000000000000000073021455751074500232760ustar00rootroot00000000000000/******************************************************************************** * * * P a r s e - B u f f e r * * * ********************************************************************************* * Copyright (C) 2013,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXPARSEBUFFER_H #define FXPARSEBUFFER_H namespace FX { /** * FXParseBuffer manages pointers to a buffer for various file format * parsers. It is intended to be subclassed for the particular syntax. * Additional subclasses are expected to override fill() and flush() to * read or write to different destinations. The default implementation * works on in-memory buffer containing the entire dataset. */ class FXAPI FXParseBuffer { public: enum Direction { Stop = 0, /// Not active Save = 1, /// Save to device Load = 2 /// Load from device }; protected: FXchar *begptr; // Begin of buffer FXchar *endptr; // End of buffer FXchar *wptr; // Write pointer FXchar *rptr; // Read pointer FXchar *sptr; // Scan pointer Direction dir; // Direction protected: FXbool need(FXival count); FXbool emit(FXchar ch,FXint count); FXbool emit(const FXchar* str,FXint count); private: FXParseBuffer(const FXParseBuffer&); FXParseBuffer &operator=(const FXParseBuffer&); public: /** * Initialize parse buffer to empty. */ FXParseBuffer(); /** * Initialize parse buffer with given size and direction. * Read pointer, scan pointer, and write pointer are set to * beginning of buffer, unless direction is Load. When direction * is Load, the write pointer is set to the end of the buffer. */ FXParseBuffer(FXchar* buffer,FXuval sz=4096,Direction d=Load); /// Open parse buffer with given size and direction FXbool open(FXchar* buffer=nullptr,FXuval sz=4096,Direction d=Load); /// Return current direction Direction direction() const { return dir; } /// Return current buffer size FXuval size() const { return endptr-begptr; } /// Read at least count bytes into buffer; return bytes available, or -1 for error virtual FXival fill(FXival count); /// Write at least count bytes from buffer; return space available, or -1 for error virtual FXival flush(FXival count); /// Close parse buffer FXbool close(); /// Clean up and close buffer virtual ~FXParseBuffer(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXPath.h000066400000000000000000000243141455751074500217700ustar00rootroot00000000000000/******************************************************************************** * * * P a t h N a m e M a n i p u l a t i o n * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXPATH_H #define FXPATH_H namespace FX { namespace FXPath { /// Options for FXPath::match enum { PathName = 1, /// No wildcard can ever match "/' NoEscape = 2, /// Backslashes don't quote special chars DotFile = 4, /// Leading "." is matched only explicitly LeadDir = 8, /// Ignore "/..." after a match CaseFold = 16 /// Compare without regard to case }; /** * Return root of absolute path; on Unix, this is just "/". On * Windows, this is "\", "\\Janes PC\" or "C:\". * Returns the empty string if the given path is not absolute. */ extern FXAPI FXString root(const FXString& file); /** * Return share name from Windows UNC filename, if any. * For example, share("\\Janes PC\Janes Documents\Document.doc") * returns "Janes PC". */ extern FXAPI FXString share(const FXString& file); /** * Return the directory part of the path name. * Note that directory("/bla/bla/") is "/bla/bla" and NOT "/bla". * However, directory("/bla/bla") is "/bla" as we expect! */ extern FXAPI FXString directory(const FXString& file); /** * Return name and extension part of the path name. * Note that name("/bla/bla/") is "" and NOT "bla". * However, name("/bla/bla") is "bla" as we expect! */ extern FXAPI FXString name(const FXString& file); /** * Return file stem, i.e. document name only. */ extern FXAPI FXString stem(const FXString& file); /** * Return extension part of the file name. * This returns the string after the last '.' in the last path-component of the * file, provided that the '.' was not the first character of the path-component. * For example, extension("/usr/share/icons/folder.png") returns "png", but the call to * extension("../path.name/.bashrc") returns "". */ extern FXAPI FXString extension(const FXString& file); /** * Return file name less the extension. */ extern FXAPI FXString stripExtension(const FXString& file); /** * Return the drive letter prefixing this file name (if any). */ extern FXAPI FXString drive(const FXString& file); /** * Perform tilde or environment variable expansion. * A prefix of the form ~ or ~user is expanded to the user's home directory. * Environment variables of the form $HOME or ${HOME} are expanded by * substituting the value of the variable, recusively up to given level. * On Windows, only environment variables of the form %HOME% are expanded. */ extern FXAPI FXString expand(const FXString& file,FXint level=4); /** * Convert a foreign path(s) or paths to local conventions, * replacing environment variables etc. */ extern FXAPI FXString convert(const FXString& path); /// Contract path based on user name and environment variable extern FXAPI FXString contract(const FXString& file,const FXString& user=FXString::null,const FXString& var=FXString::null); /** * Simplify a file path; the path will remain relative if it was relative, * or absolute if it was absolute. Also, a trailing "/" will be preserved * as this is important in other functions. Finally, returned path should * be non-empty unless the input path was empty, and pathological paths * will be fixed. */ extern FXAPI FXString simplify(const FXString& file); /// Return absolute path from current directory and file name extern FXAPI FXString absolute(const FXString& file); /// Return absolute path from base directory and file name extern FXAPI FXString absolute(const FXString& base,const FXString& file); /// Return relative path of file to the current directory extern FXAPI FXString relative(const FXString& file); /// Return relative path of file to given absolute base directory extern FXAPI FXString relative(const FXString& base,const FXString& file); /// Return path to directory above input directory name extern FXAPI FXString upLevel(const FXString& file); /// Return true if file positively inside base directory extern FXAPI FXbool isInside(const FXString& base,const FXString& file); /// Return true if file name is absolute extern FXAPI FXbool isAbsolute(const FXString& file); /// Return true if file name is relative extern FXAPI FXbool isRelative(const FXString& file); /// Return true if input directory is a top-level directory extern FXAPI FXbool isTopDirectory(const FXString& file); /// Return true if input path is a file share extern FXAPI FXbool isShare(const FXString& file); /// Return true if input path is a hidden file or directory extern FXAPI FXbool isHidden(const FXString& file); /// Return valid part of absolute path extern FXAPI FXString validPath(const FXString& file); /// Return true if path is valid extern FXAPI FXbool isValidPath(const FXString& file); /// Enquote filename to make safe for shell extern FXAPI FXString enquote(const FXString& file,FXbool force=false); /// Dequote filename to get original again extern FXAPI FXString dequote(const FXString& file); /** * Parse command string to argc and argv. * The input string may contain single- or double-quoted segments * or escape characters, as per shell rules. * Returns argc, the number of arguments identified in the input, * if successful. If input is empty (NULL pointer or only whitespace), * or syntax errors are encountered, or system is out of memory, the * function returns 0. * Memory at argv may be released by a single call to freeElms(). */ extern FXAPI FXint parseArgs(FXchar**& argv,const FXchar* command); /** * Parse command string to argc and argv. * This is a convenience version for the parseArgv() above. */ extern FXAPI FXint parseArgs(FXchar**& argv,const FXString& command); /** * Perform match of a string against a wildcard pattern. * The wildcard pattern may comprise ordinary characters or special * matching characters, as given below: * * ? Any single character. * * Zero or more of any character. * [abc] Any character from the set {a,b,c}. * [^abc] Any character BUT the ones from the set {a,b,c}. * [!abc] Any character BUT the ones from the set {a,b,c}. * [a-zA-Z] Matches single character, which must be one of a-z or A-Z. * [^a-zA-Z] Matches single character, which must be anything BUT a-z or A-Z. * [!a-zA-Z] Matches single character, which must be anything BUT a-z or A-Z. * pat1|pat2 Match sub-pattern pat1 or pat2. * pat1,pat2 Match sub-pattern pat1 or pat2. * (pat1|pat2) Match sub-pattern pat1 or pat2; patterns may be nested. * (pat1,pat2) Match sub-pattern pat1 or pat2; patterns may be nested. * * The special characters may be escaped to treat them as ordinary characters. * Matching may be influenced by a number of flags: * * PathName No wildcard can ever match / * NoEscape Backslashes don't quote special chars * DotFile Leading . is matched only explicitly, and not against wildcard * LeadDir Ignore /... after a match * CaseFold Compare without regard to case */ extern FXAPI FXbool match(const FXchar* string,const FXchar* pattern="*",FXuint flags=(NoEscape|PathName)); /** * Perform match of a string against a wildcard pattern. */ extern FXAPI FXbool match(const FXString& string,const FXchar* pattern="*",FXuint flags=(NoEscape|PathName)); /** * Perform match of a string against a wildcard pattern. */ extern FXAPI FXbool match(const FXchar* string,const FXString& pattern,FXuint flags=(NoEscape|PathName)); /** * Perform match of a string against a wildcard pattern. */ extern FXAPI FXbool match(const FXString& string,const FXString& pattern,FXuint flags=(NoEscape|PathName)); /** * Generate unique filename of the form pathnameXXX.ext, where * pathname.ext is the original input file, and XXX is a number, * possibly empty, that makes the file unique. */ extern FXAPI FXString unique(const FXString& file); /** * Search path list for this file, return full path name for first occurrence. * Each path in the pathlist is expanded first. */ extern FXAPI FXString search(const FXString& pathlist,const FXString& file); /** * Given search path list, return shortest relative path name that still * uniquely resolves to the given file name. */ extern FXAPI FXString relativize(const FXString& pathlist,const FXString& file); /** * Check if the file has an extension from the list of known executable * extensions (Windows) */ extern FXAPI FXbool hasExecExtension(const FXString& file); /** * Check if given name is controversial, i.e. reserved for other devices (Windows). */ extern FXAPI FXbool isReservedName(const FXString& file); } } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXPicker.h000066400000000000000000000057421455751074500223150ustar00rootroot00000000000000/******************************************************************************** * * * P i c k e r B u t t o n * * * ********************************************************************************* * Copyright (C) 2001,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXPICKER_H #define FXPICKER_H #ifndef FXBUTTON_H #include "FXButton.h" #endif namespace FX { /** * A Picker button allows you to identify an arbitrary location on the screen. * It generates SEL_CHANGED callbacks while the user is moving the mouse, and * a final SEL_COMMAND when a location has been identified. The void* parameter * in the callback is a pointer to FXPoint, the location, in root-coordinates, of * the place where the click took place. */ class FXAPI FXPicker : public FXButton { FXDECLARE(FXPicker) protected: FXPoint location; // Location FXbool picked; // Clicked protected: FXPicker(); private: FXPicker(const FXPicker&); FXPicker& operator=(const FXPicker&); public: long onMotion(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onHotKeyPress(FXObject*,FXSelector,void*); long onHotKeyRelease(FXObject*,FXSelector,void*); public: /// Construct picker button with text and icon FXPicker(FXComposite* p,const FXString& text,FXIcon* ic=nullptr,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=BUTTON_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXPipe.h000066400000000000000000000047301455751074500217710ustar00rootroot00000000000000/******************************************************************************** * * * P i p e C l a s s * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXPIPE_H #define FXPIPE_H #ifndef FXIODEVICE_H #include "FXIODevice.h" #endif namespace FX { /** * Pipe i/o device. */ class FXAPI FXPipe : public FXIODevice { private: FXPipe(const FXPipe&); FXPipe &operator=(const FXPipe&); public: /// Construct pipe FXPipe(){ } /// Construct pipe and attach existing handle h FXPipe(FXInputHandle h); /// Construct and open pipes with access mode m for this one and the reverse for the other FXPipe(FXPipe& other,FXuint m); /// Open pipes with access mode m for this one and the reverse for the other virtual FXbool open(FXPipe& other,FXuint m=FXIO::Reading); /// Create a named pipe (not available on Windows) static FXbool create(const FXString& file,FXuint perm=FXIO::AllReadWrite); /// Remove a named pipe (not available on Windows) static FXbool remove(const FXString& file); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXPoint.h000066400000000000000000000127671455751074500221760ustar00rootroot00000000000000/******************************************************************************** * * * P o i n t C l a s s * * * ********************************************************************************* * Copyright (C) 1994,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXPOINT_H #define FXPOINT_H #ifndef FXSIZE_H #include "FXSize.h" #endif namespace FX { /// Point class FXAPI FXPoint { public: FXshort x; FXshort y; public: /// Constructors FXPoint(){ } FXPoint(const FXSize& s):x(s.w),y(s.h){ } FXPoint(const FXPoint& p):x(p.x),y(p.y){ } FXPoint(FXshort xx,FXshort yy):x(xx),y(yy){ } /// Return a non-const reference to the ith element FXshort& operator[](FXint i){return (&x)[i];} /// Return a const reference to the ith element const FXshort& operator[](FXint i) const {return (&x)[i];} /// Assignment FXPoint& operator=(const FXPoint& p){ x=p.x; y=p.y; return *this; } /// Set value from another point FXPoint& set(const FXPoint& p){ x=p.x; y=p.y; return *this; } /// Set value from components FXPoint& set(FXshort xx,FXshort yy){ x=xx; y=yy; return *this; } /// Assignment operators FXPoint& operator*=(FXshort c){ x*=c; y*=c; return *this; } FXPoint& operator/=(FXshort c){ x/=c; y/=c; return *this; } FXPoint& operator+=(const FXPoint& p){ x+=p.x; y+=p.y; return *this; } FXPoint& operator-=(const FXPoint& p){ x-=p.x; y-=p.y; return *this; } /// Test if zero FXbool operator!() const { return x==0 && y==0; } /// Unary FXPoint operator+() const { return *this; } FXPoint operator-(){ return FXPoint(-x,-y); } }; /// Scale operators inline FXPoint operator*(const FXPoint& p,FXshort c){ return FXPoint(p.x*c,p.y*c); } inline FXPoint operator*(FXshort c,const FXPoint& p){ return FXPoint(c*p.x,c*p.y); } inline FXPoint operator/(const FXPoint& p,FXshort c){ return FXPoint(p.x/c,p.y/c); } inline FXPoint operator/(FXshort c,const FXPoint& p){ return FXPoint(c/p.x,c/p.y); } /// Addition operators inline FXPoint operator+(const FXPoint& a,const FXPoint& b){ return FXPoint(a.x+b.x,a.y+b.y); } inline FXPoint operator-(const FXPoint& a,const FXPoint& b){ return FXPoint(a.x-b.x,a.y-b.y); } /// Equality tests inline FXbool operator==(const FXPoint& a,FXshort n){ return a.x==n && a.y==n; } inline FXbool operator!=(const FXPoint& a,FXshort n){ return a.x!=n || a.y!=n; } inline FXbool operator==(FXshort n,const FXPoint& a){ return n==a.x && n==a.y; } inline FXbool operator!=(FXshort n,const FXPoint& a){ return n!=a.x || n!=a.y; } /// Equality tests inline FXbool operator==(const FXPoint& a,const FXPoint& b){ return a.x==b.x && a.y==b.y; } inline FXbool operator!=(const FXPoint& a,const FXPoint& b){ return a.x!=b.x || a.y!=b.y; } /// Inequality tests inline FXbool operator<(const FXPoint& a,FXshort n){ return a.x(const FXPoint& a,FXshort n){ return a.x>n && a.y>n; } inline FXbool operator>=(const FXPoint& a,FXshort n){ return a.x>=n && a.y>=n; } /// Inequality tests inline FXbool operator<(FXshort n,const FXPoint& a){ return n(FXshort n,const FXPoint& a){ return n>a.x && n>a.y; } inline FXbool operator>=(FXshort n,const FXPoint& a){ return n>=a.x && n>=a.y; } /// Inequality tests inline FXbool operator<(const FXPoint& a,const FXPoint& b){ return a.x(const FXPoint& a,const FXPoint& b){ return a.x>b.x && a.y>b.y; } inline FXbool operator>=(const FXPoint& a,const FXPoint& b){ return a.x>=b.x && a.y>=b.y; } /// Lowest or highest components inline FXPoint lo(const FXPoint& a,const FXPoint& b){ return FXPoint(Math::imin(a.x,b.x),Math::imin(a.y,b.y)); } inline FXPoint hi(const FXPoint& a,const FXPoint& b){ return FXPoint(Math::imax(a.x,b.x),Math::imax(a.y,b.y)); } /// Save object to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXPoint& p); /// Load object from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXPoint& p); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXPopup.h000066400000000000000000000160351455751074500222000ustar00rootroot00000000000000/******************************************************************************** * * * P o p u p W i n d o w W i d g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXPOPUP_H #define FXPOPUP_H #ifndef FXSHELL_H #include "FXShell.h" #endif namespace FX { /// Popup internal orientation enum { POPUP_VERTICAL = 0, /// Vertical orientation POPUP_HORIZONTAL = 0x00020000, /// Horizontal orientation POPUP_SHRINKWRAP = 0x00040000 /// Shrinkwrap to content }; /** * Popup window is used as a container for transitional controls * such as menu panes and other ephemeral windows. One of its * principal characteristics is that no other controls, except the * ones inside the popup are capable of interaction. Any click outside * of a popup will cause the popup to be closed. * Contents of popups may be arranged vertically (POPUP_VERTICAL) or * horizontally (POPUP_HORIZONTAL). * The special POPUP_SHRINKWRAP option causes the application to recompute * the size of the popup window based on its contents at the time it is * shown, thus permitting dynamically changing content. */ class FXAPI FXPopup : public FXShell { FXDECLARE(FXPopup) private: FXPopup *prevActive; // Popup below this one in stack FXPopup *nextActive; // Popup above this one in stack protected: FXWindow *grabowner; // Window which will get grabbed when outside FXColor baseColor; FXColor hiliteColor; FXColor shadowColor; FXColor borderColor; FXint border; protected: FXPopup(); virtual FXbool doesOverrideRedirect() const; void drawBorderRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawRaisedRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawSunkenRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawRidgeRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawGrooveRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawDoubleRaisedRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawDoubleSunkenRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawFrame(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); private: FXPopup(const FXPopup&); FXPopup &operator=(const FXPopup&); #ifdef WIN32 virtual const void* GetClass() const; #endif public: long onPaint(FXObject*,FXSelector,void*); long onFocusUp(FXObject*,FXSelector,void*); long onFocusDown(FXObject*,FXSelector,void*); long onFocusLeft(FXObject*,FXSelector,void*); long onFocusRight(FXObject*,FXSelector,void*); long onFocusNext(FXObject*,FXSelector,void*); long onFocusPrev(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onMap(FXObject*,FXSelector,void*); long onLayout(FXObject*,FXSelector,void*); long onButtonPress(FXObject*,FXSelector,void*); long onButtonRelease(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onCmdUnpost(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onCmdChoice(FXObject*,FXSelector,void*); public: enum { ID_CHOICE=FXShell::ID_LAST, ID_LAST=ID_CHOICE+1000 }; public: /// Construct popup pane FXPopup(FXWindow* owner,FXuint opts=POPUP_VERTICAL|FRAME_RAISED|FRAME_THICK,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Return the default width of this window virtual FXint getDefaultWidth(); /// Return the default height of this window virtual FXint getDefaultHeight(); /// Perform layout virtual void layout(); /// Return a pointer to the prior active popup FXPopup* getPrevActive() const { return prevActive; } /// Return a pointer to the next active popup FXPopup* getNextActive() const { return nextActive; } /// Move the focus to this window virtual void setFocus(); /// Remove the focus from this window virtual void killFocus(); /// Show this window virtual void show(); /// Hide this window virtual void hide(); /// Change frame style void setFrameStyle(FXuint style); /// Return frame style FXuint getFrameStyle() const; /// Return border width FXint getBorderWidth() const { return border; } /// Change highlight color void setHiliteColor(FXColor clr); /// Return highlight color FXColor getHiliteColor() const { return hiliteColor; } /// Change shadow color void setShadowColor(FXColor clr); /// Return shadow color FXColor getShadowColor() const { return shadowColor; } /// Change border color void setBorderColor(FXColor clr); /// Return border color FXColor getBorderColor() const { return borderColor; } /// Change base color void setBaseColor(FXColor clr); /// Return base color FXColor getBaseColor() const { return baseColor; } /// Popup the menu and grab to the given owner virtual void popup(FXWindow* grabto,FXint x,FXint y,FXint w=0,FXint h=0); /// Pop down the menu virtual void popdown(); /// Return current grab owner FXWindow* getGrabOwner(); // /// Popup the menu and grab to the given owner // virtual FXint popup(FXint x,FXint y,FXint w=0,FXint h=0); // // /// Pop down the menu // virtual void popdown(FXint value); /// Change popup orientation void setOrientation(FXuint orient); /// Return popup orientation FXuint getOrientation() const; /// Change shrinkwrap mode void setShrinkWrap(FXbool flag); /// Return shrinkwrap mode FXbool getShrinkWrap() const; /// Does save-unders virtual FXbool doesSaveUnder() const; /// Destructor virtual ~FXPopup(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXPrintDialog.h000066400000000000000000000125111455751074500233040ustar00rootroot00000000000000/******************************************************************************** * * * P r i n t J o b D i a l o g * * * ********************************************************************************* * Copyright (C) 1999,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXPRINTDIALOG_H #define FXPRINTDIALOG_H #ifndef FXDIALOGBOX_H #include "FXDialogBox.h" #endif namespace FX { class FXRadioButton; class FXComboBox; class FXListBox; class FXTextField; class FXSpinner; class FXIcon; /// Printer selection dialog class FXAPI FXPrintDialog : public FXDialogBox { FXDECLARE(FXPrintDialog) protected: FXRadioButton *sendtoprinter; FXComboBox *printername; FXRadioButton *sendtofile; FXTextField *filename; FXRadioButton *printall; FXRadioButton *printeven; FXRadioButton *printodd; FXRadioButton *printrange; FXRadioButton *firstpagefirst; FXRadioButton *lastpagefirst; FXRadioButton *printincolor; FXRadioButton *printinblacknwhite; FXRadioButton *orientportrait; FXRadioButton *orientlanscape; FXListBox *media; FXSpinner *firstpage; FXSpinner *lastpage; FXSpinner *numberofcopies; FXIcon *landscapeIcon; FXIcon *portraitIcon; FXPrinter printer; protected: FXPrintDialog(){} private: FXPrintDialog(const FXPrintDialog&); FXPrintDialog &operator=(const FXPrintDialog&); public: long onCmdToPrinter(FXObject*,FXSelector,void*); long onUpdToPrinter(FXObject*,FXSelector,void*); long onCmdToFile(FXObject*,FXSelector,void*); long onUpdToFile(FXObject*,FXSelector,void*); long onCmdBrowse(FXObject*,FXSelector,void*); long onUpdBrowse(FXObject*,FXSelector,void*); long onCmdProps(FXObject*,FXSelector,void*); long onUpdProps(FXObject*,FXSelector,void*); long onCmdPortrait(FXObject*,FXSelector,void*); long onUpdPortrait(FXObject*,FXSelector,void*); long onCmdLandscape(FXObject*,FXSelector,void*); long onUpdLandscape(FXObject*,FXSelector,void*); long onCmdPages(FXObject*,FXSelector,void*); long onUpdPages(FXObject*,FXSelector,void*); long onCmdColor(FXObject*,FXSelector,void*); long onUpdColor(FXObject*,FXSelector,void*); long onCmdGray(FXObject*,FXSelector,void*); long onUpdGray(FXObject*,FXSelector,void*); long onCmdNumCopies(FXObject*,FXSelector,void*); long onUpdNumCopies(FXObject*,FXSelector,void*); long onCmdFirstPage(FXObject*,FXSelector,void*); long onUpdFirstPage(FXObject*,FXSelector,void*); long onCmdLastPage(FXObject*,FXSelector,void*); long onUpdLastPage(FXObject*,FXSelector,void*); long onCmdCollateNormal(FXObject*,FXSelector,void*); long onUpdCollateNormal(FXObject*,FXSelector,void*); long onCmdCollateReversed(FXObject*,FXSelector,void*); long onUpdCollateReversed(FXObject*,FXSelector,void*); long onCmdFileName(FXObject*,FXSelector,void*); long onUpdFileName(FXObject*,FXSelector,void*); long onCmdPrinterName(FXObject*,FXSelector,void*); long onUpdPrinterName(FXObject*,FXSelector,void*); long onCmdAccept(FXObject*,FXSelector,void*); long onCmdMedia(FXObject*,FXSelector,void*); long onUpdMedia(FXObject*,FXSelector,void*); public: enum{ ID_TO_PRINTER=FXDialogBox::ID_LAST, ID_TO_FILE, ID_PRINTER_NAME, ID_FILE_NAME, ID_LANDSCAPE, ID_PORTRAIT, ID_MEDIA, ID_COLLATE_NORMAL, ID_COLLATE_REVERSED, ID_PAGES_ALL, ID_PAGES_EVEN, ID_PAGES_ODD, ID_PAGES_RANGE, ID_PAGES_FIRST, ID_PAGES_LAST, ID_BROWSE_FILE, ID_PROPERTIES, ID_COLOR_PRINTER, ID_GRAY_PRINTER, ID_NUM_COPIES }; public: /// Construct print dialog FXPrintDialog(FXWindow* owner,const FXString& name,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Create dialog virtual void create(); /// Set printer info void setPrinter(const FXPrinter& pr); /// Get printer info void getPrinter(FXPrinter& pr); /// Save dialog to a stream virtual void save(FXStream& store) const; /// Load dialog from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXPrintDialog(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXProcess.h000066400000000000000000000063731455751074500225170ustar00rootroot00000000000000/******************************************************************************** * * * P r o c e s s S u p p o r t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXPROCESS_H #define FXPROCESS_H namespace FX { class FXIODevice; /// Executable process class FXAPI FXProcess { private: FXProcessID pid; // Handle to process FXIODevice *input; // Input stream FXIODevice *output; // Output stream FXIODevice *errors; // Errors stream private: FXProcess(const FXProcess&); FXProcess &operator=(const FXProcess&); public: /// Create and initialize FXProcess(); /// Return handle of this process object FXProcessID id() const; /// Start subprocess FXbool start(const FXchar* exec,const FXchar *const *args,const FXchar *const *env=nullptr); /// Change input stream; handle must be Inheritable void setInputStream(FXIODevice* is){ input=is; } /// Return input stream FXIODevice* getInputStream() const { return input; } /// Change output stream; handle must be Inheritable void setOutputStream(FXIODevice* os){ output=os; } /// Return output stream FXIODevice* getOutputStream() const { return output; } /// Change error stream; handle must be Inheritable void setErrorStream(FXIODevice* es){ errors=es; } /// Return error stream FXIODevice* getErrorStream() const { return errors; } /// Get process id of calling process static FXint current(); /// Get current process handle static FXInputHandle handle(); /// Exit calling process static void exit(FXint code=0); /// Suspend process FXbool suspend(); /// Resume process FXbool resume(); /// Kill process FXbool kill(); /// Wait for child process FXbool wait(); /// Wait for child process, returning exit code FXbool wait(FXint& code); /// Delete ~FXProcess(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXProgressBar.h000066400000000000000000000125631455751074500233300ustar00rootroot00000000000000/******************************************************************************** * * * P r o g r e s s B a r W i d g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXPROGRESSBAR_H #define FXPROGRESSBAR_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { /// Progress bar styles enum { PROGRESSBAR_HORIZONTAL = 0, /// Horizontal display PROGRESSBAR_VERTICAL = 0x00008000, /// Vertical display PROGRESSBAR_PERCENTAGE = 0x00010000, /// Show percentage done PROGRESSBAR_DIAL = 0x00020000, /// Show as a dial instead of bar PROGRESSBAR_NORMAL = FRAME_SUNKEN|FRAME_THICK }; /// Progress bar widget class FXAPI FXProgressBar : public FXFrame { FXDECLARE(FXProgressBar) protected: FXuint progress; // Integer percentage number FXuint total; // Amount for completion FXint barsize; // Bar size FXFont* font; // Text font FXColor barBGColor; // Bar background color FXColor barColor; // Filled bar color FXColor textNumColor; // Text color inside bar background FXColor textAltColor; // Text color inside filled bar protected: FXProgressBar(){} void drawInterior(FXDCWindow& dc); private: FXProgressBar(const FXProgressBar&); FXProgressBar &operator=(const FXProgressBar&); public: long onPaint(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdSetLongValue(FXObject*,FXSelector,void*); long onCmdGetLongValue(FXObject*,FXSelector,void*); long onCmdSetIntRange(FXObject*,FXSelector,void*); long onCmdGetIntRange(FXObject*,FXSelector,void*); public: /// Construct progress bar FXProgressBar(FXComposite* p,FXObject* target=nullptr,FXSelector sel=0,FXuint opts=PROGRESSBAR_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Change the amount of progress void setProgress(FXuint value); /// Get current progress FXuint getProgress() const { return progress; } /// Set total amount of progress void setTotal(FXuint value); /// Return total amount of progrss FXuint getTotal() const { return total; } /// Increment progress by given amount void increment(FXuint value); /// Hide progress percentage void hideNumber(); /// Show progress percentage void showNumber(); /// Change progress bar width void setBarSize(FXint size); /// Return progress bar width FXint getBarSize() const { return barsize; } /// Change backgroundcolor void setBarBGColor(FXColor clr); /// Return background color FXColor getBarBGColor() const { return barBGColor; } /// Change bar color void setBarColor(FXColor clr); /// Return bar color FXColor getBarColor() const { return barColor; } /// Change text color void setTextColor(FXColor clr); /// Return text color FXColor getTextColor() const { return textNumColor; } /// Change alternate text color shown when bar under text void setTextAltColor(FXColor clr); /// Return alternate text color FXColor getTextAltColor() const { return textAltColor; } /// Set the text font void setFont(FXFont *fnt); /// Get the text font FXFont* getFont() const { return font; } /// Change progress bar style void setBarStyle(FXuint style); /// Return current progress bar style FXuint getBarStyle() const; /// Save progress bar to a stream virtual void save(FXStream& store) const; /// Load progress bar from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXProgressBar(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXProgressDialog.h000066400000000000000000000106661455751074500240250ustar00rootroot00000000000000/******************************************************************************** * * * P r o g r e s s D i a l o g B o x * * * ********************************************************************************* * Copyright (C) 2001,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXPROGRESSDIALOG_H #define FXPROGRESSDIALOG_H #ifndef FXDIALOGBOX_H #include "FXDialogBox.h" #endif namespace FX { /// Progress dialog options enum { PROGRESSDIALOG_NOCANCEL = 0, /// Default is no cancel button PROGRESSDIALOG_CANCEL = 0x02000000, /// Enable the cancel button PROGRESSDIALOG_NORMAL = (DECOR_TITLE|DECOR_BORDER)/// Normally with title and border }; class FXHorizontalSeparator; class FXProgressBar; class FXButton; class FXLabel; /** * A Progress Dialog is a simple dialog which is used to * keep a user informed of the progress of a lengthy operation * in a program and that the program is in fact still working. * The PROGRESSDIALOG_CANCEL option enables the display of the * cancel button in the Progress Dialog. */ class FXAPI FXProgressDialog : public FXDialogBox { FXDECLARE(FXProgressDialog) protected: FXProgressBar *progress; // Progress bar FXLabel *message; // Message FXHorizontalSeparator *separator; // Separator FXButton *cancel; // Cancel button FXbool cancelled; // User hit cancel protected: FXProgressDialog(); private: FXProgressDialog(const FXProgressDialog&); FXProgressDialog &operator=(const FXProgressDialog&); public: long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdSetLongValue(FXObject*,FXSelector,void*); long onCmdGetLongValue(FXObject*,FXSelector,void*); long onCmdSetIntRange(FXObject*,FXSelector,void*); long onCmdGetIntRange(FXObject*,FXSelector,void*); long onCmdSetStringValue(FXObject*,FXSelector,void*); long onCmdGetStringValue(FXObject*,FXSelector,void*); long onCmdCancel(FXObject*,FXSelector,void*); public: /// Construct input dialog box with given caption, icon, and prompt text FXProgressDialog(FXWindow* owner,const FXString& caption,const FXString& label,FXuint opts=PROGRESSDIALOG_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Change the progress message void setMessage(const FXString& msg); /// Get progress message FXString getMessage() const; /// Change style of the progress bar widget void setBarStyle(FXuint style); /// Get style of the progress bar widget FXuint getBarStyle() const; /// Change the amount of progress void setProgress(FXuint value); /// Get current progress FXuint getProgress() const; /// Set total amount of progress void setTotal(FXuint value); /// Return total amount of progrss FXuint getTotal() const; /// Increment progress by given amount void increment(FXuint value); /// Has operation been cancelled? FXbool isCancelled() const; /// Change cancelled flag void setCancelled(FXbool flg); /// Destroy virtual ~FXProgressDialog(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXPtrList.h000066400000000000000000000234241455751074500224760ustar00rootroot00000000000000/******************************************************************************** * * * P o i n t e r L i s t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXPTRLIST_H #define FXPTRLIST_H namespace FX { /// List of void pointers class FXAPI FXPtrList { protected: FXptr* ptr; public: /// Default constructor FXPtrList(); /// Copy constructor FXPtrList(const FXPtrList& other); /// Construct and init with single object FXPtrList(FXptr object); /// Construct and init with n copies of object FXPtrList(FXptr object,FXival n); /// Construct and init with list of objects FXPtrList(FXptr* objects,FXival n); /// Assignment operator FXPtrList& operator=(const FXPtrList& other); /// Adopt objects from other, leaving other empty FXPtrList& adopt(FXPtrList& other); /// Return number of objects FXival no() const { return *((FXival*)(ptr-1)); } /// Set number of objects FXbool no(FXival num); /// Indexing operator FXptr& operator[](FXival i){ return ptr[i]; } FXptr const& operator[](FXival i) const { return ptr[i]; } /// Indexing operator FXptr& at(FXival i){ return ptr[i]; } FXptr const& at(FXival i) const { return ptr[i]; } /// First element in list FXptr& head(){ return ptr[0]; } FXptr const& head() const { return ptr[0]; } /// Last element in list FXptr& tail(){ return ptr[no()-1]; } FXptr const& tail() const { return ptr[no()-1]; } /// Access to content array FXptr* data(){ return ptr; } const FXptr* data() const { return ptr; } /// Find object in list, searching forward; return position or -1 FXival find(FXptr object,FXival pos=0) const; /// Find object in list, searching backward; return position or -1 FXival rfind(FXptr object,FXival pos=2147483647) const; /// Assign object to list FXbool assign(FXptr object); /// Assign n copies of object to list FXbool assign(FXptr object,FXival n); /// Assign n objects to list FXbool assign(FXptr* objects,FXival n); /// Assign objects to list FXbool assign(const FXPtrList& objects); /// Insert object at certain position FXbool insert(FXival pos,FXptr object); /// Insert n copies of object at specified position FXbool insert(FXival pos,FXptr object,FXival n); /// Insert n objects at specified position FXbool insert(FXival pos,FXptr* objects,FXival n); /// Insert objects at specified position FXbool insert(FXival pos,const FXPtrList& objects); /// Prepend object FXbool prepend(FXptr object); /// Prepend n copies of object FXbool prepend(FXptr object,FXival n); /// Prepend n objects FXbool prepend(FXptr* objects,FXival n); /// Prepend objects FXbool prepend(const FXPtrList& objects); /// Append object FXbool append(FXptr object); /// Append n copies of object FXbool append(FXptr object,FXival n); /// Append n objects FXbool append(FXptr* objects,FXival n); /// Append objects FXbool append(const FXPtrList& objects); /// Replace object at position by given object FXbool replace(FXival pos,FXptr object); /// Replaces the m objects at pos with n copies of object FXbool replace(FXival pos,FXival m,FXptr object,FXival n); /// Replaces the m objects at pos with n objects FXbool replace(FXival pos,FXival m,FXptr* objects,FXival n); /// Replace the m objects at pos with objects FXbool replace(FXival pos,FXival m,const FXPtrList& objects); /// Remove object at pos FXbool erase(FXival pos); /// Remove n objects at pos FXbool erase(FXival pos,FXival n); /// Remove object FXbool remove(FXptr object); /// Push object to end FXbool push(FXptr object); /// Pop object from end FXbool pop(); /// Remove all objects FXbool clear(); /// Destructor ~FXPtrList(); }; /// List to pointers to TYPE template class FXPtrListOf : public FXPtrList { public: /// Default constructor FXPtrListOf(){} /// Copy constructor FXPtrListOf(const FXPtrListOf& src):FXPtrList(src){ } /// Construct and init with single object FXPtrListOf(TYPE* object):FXPtrList(object){ } /// Construct and init with n copies of object FXPtrListOf(TYPE* object,FXival n):FXPtrList(object,n){ } /// Construct and init with list of objects FXPtrListOf(TYPE** objects,FXival n):FXPtrList(objects,n){ } /// Assignment operator FXPtrListOf& operator=(const FXPtrListOf& src){ return reinterpret_cast&>(FXPtrList::operator=(src)); } /// Adopt objects from orig, leaving orig empty FXPtrListOf& adopt(FXPtrListOf& src){ return reinterpret_cast&>(FXPtrList::adopt(src)); } /// Indexing operator TYPE*& operator[](FXival i){ return reinterpret_cast(ptr[i]); } TYPE *const& operator[](FXival i) const { return reinterpret_cast(ptr[i]); } /// Indexing operator TYPE*& at(FXival i){ return reinterpret_cast(ptr[i]); } TYPE *const& at(FXival i) const { return reinterpret_cast(ptr[i]); } /// First element in list TYPE*& head(){ return reinterpret_cast(ptr[0]); } TYPE* const& head() const { return reinterpret_cast(ptr[0]); } /// Last element in list TYPE*& tail(){ return reinterpret_cast(ptr[no()-1]); } TYPE* const& tail() const { return reinterpret_cast(ptr[no()-1]); } /// Access to content array TYPE** data(){ return reinterpret_cast(ptr); } TYPE *const * data() const { return reinterpret_cast(ptr); } /// Find object in list, searching forward; return position or -1 FXival find(TYPE* object,FXival pos=0) const { return FXPtrList::find(object,pos); } /// Find object in list, searching backward; return position or -1 FXival rfind(TYPE* object,FXival pos=2147483647) const { return FXPtrList::rfind(object,pos); } /// Assign object to list FXbool assign(TYPE* object){ return FXPtrList::assign(object); } /// Assign n copies of object to list FXbool assign(TYPE* object,FXival n){ return FXPtrList::assign(object,n); } /// Assign n objects to list FXbool assign(TYPE** objects,FXival n){ return FXPtrList::assign(objects,n); } /// Assign objects to list FXbool assign(const FXPtrListOf& objects){ return FXPtrList::assign(objects); } /// Insert object at certain position FXbool insert(FXival pos,TYPE* object){ return FXPtrList::insert(pos,object); } /// Insert n copies of object at specified position FXbool insert(FXival pos,TYPE* object,FXival n){ return FXPtrList::insert(pos,object,n); } /// Insert n objects at specified position FXbool insert(FXival pos,TYPE** objects,FXival n){ return FXPtrList::insert(pos,objects,n); } /// Insert objects at specified position FXbool insert(FXival pos,const FXPtrListOf& objects){ return FXPtrList::insert(pos,objects); } /// Prepend object FXbool prepend(TYPE* object){ return FXPtrList::prepend(object); } /// Prepend n copies of object FXbool prepend(TYPE* object,FXival n){ return FXPtrList::prepend(object,n); } /// Prepend n objects FXbool prepend(TYPE** objects,FXival n){ return FXPtrList::prepend(objects,n); } /// Prepend objects FXbool prepend(const FXPtrListOf& objects){ return FXPtrList::prepend(objects); } /// Append object FXbool append(TYPE* object){ return FXPtrList::append(object); } /// Append n copies of object FXbool append(TYPE* object,FXival n){ return FXPtrList::append(object,n); } /// Append n objects FXbool append(TYPE** objects,FXival n){ return FXPtrList::append(objects,n); } /// Append objects FXbool append(const FXPtrListOf& objects){ return FXPtrList::append(objects); } /// Replace object at position by given object FXbool replace(FXival pos,TYPE* object){ return FXPtrList::replace(pos,object); } /// Replaces the m objects at pos with n copies of object FXbool replace(FXival pos,FXival m,TYPE* object,FXival n){ return FXPtrList::replace(pos,m,object,n); } /// Replaces the m objects at pos with n objects FXbool replace(FXival pos,FXival m,TYPE** objects,FXival n){ return FXPtrList::replace(pos,m,objects,n); } /// Replace the m objects at pos with objects FXbool replace(FXival pos,FXival m,const FXPtrListOf& objects){ return FXPtrList::replace(pos,m,objects); } /// Remove object FXbool remove(TYPE* object){ return FXPtrList::remove(object); } /// Push object to end FXbool push(TYPE* object){ return FXPtrList::push(object); } }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXPtrQueue.h000066400000000000000000000061641455751074500226510ustar00rootroot00000000000000/******************************************************************************** * * * Q u e u e O f P o i n t e r s * * * ********************************************************************************* * Copyright (C) 2006,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXPTRQUEUE_H #define FXPTRQUEUE_H namespace FX { /// Queue of void pointers class FXAPI FXPtrQueue { private: FXPtrList list; // List of pointers volatile FXival head; // Write side volatile FXival tail; // Read side private: FXPtrQueue(const FXPtrQueue&); FXPtrQueue &operator=(const FXPtrQueue&); public: /// Create initially empty queue FXPtrQueue(); /// Create queue with initial size FXPtrQueue(FXival sz); /// Change size of queue; return true if success FXbool setSize(FXival sz); /// Return size FXival getSize() const { return list.no(); } /// Return number of used slots FXival getUsed() const; /// Return number of free slots FXival getFree() const; /// Check if queue is full FXbool isFull() const; /// Check if queue is empty FXbool isEmpty() const; /// Add item to queue, return true if success FXbool push(FXptr ptr); /// Peek for item FXbool peek(FXptr& ptr); /// Remove item from queue, return true if success FXbool pop(FXptr& ptr); /// Drop item from queue, return true if success FXbool pop(); /// Destroy queue ~FXPtrQueue(); }; /// Queue of pointers to TYPE template class FXPtrQueueOf : public FXPtrQueue { public: FXPtrQueueOf(){} FXPtrQueueOf(FXuint sz):FXPtrQueue(sz){} FXbool push(TYPE* ptr){ return FXPtrQueue::push((FXptr)ptr); } FXbool peek(TYPE*& ptr){ return FXPtrQueue::peek((FXptr&)ptr); } FXbool pop(TYPE*& ptr){ return FXPtrQueue::pop((FXptr&)ptr); } }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXQuatd.h000066400000000000000000000302461455751074500221530ustar00rootroot00000000000000/******************************************************************************** * * * D o u b l e - P r e c i s i o n Q u a t e r n i o n * * * ********************************************************************************* * Copyright (C) 1994,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXQUATD_H #define FXQUATD_H namespace FX { // Forward reference class FXMat3d; /// Double-precision quaternion class FXAPI FXQuatd { public: double x; double y; double z; double w; public: /** * Default constructor; value is not initialized. */ FXQuatd(){} /** * Copy constructor. */ FXQuatd(const FXQuatd& q):x(q.x),y(q.y),z(q.z),w(q.w){} /** * Construct from array of four doubles. */ FXQuatd(const FXdouble v[]):x(v[0]),y(v[1]),z(v[2]),w(v[3]){} /** * Construct from four components. */ FXQuatd(FXdouble xx,FXdouble yy,FXdouble zz,FXdouble ww):x(xx),y(yy),z(zz),w(ww){} /** * Construct from rotation axis and angle in radians. */ FXQuatd(const FXVec3d& axis,FXdouble phi); /** * Construct quaternion from arc between two unit vectors fm and to. */ FXQuatd(const FXVec3d& fr,const FXVec3d& to); /** * Construct from euler angles yaw (z), pitch (y), and roll (x). */ FXQuatd(FXdouble roll,FXdouble pitch,FXdouble yaw); /** * Construct quaternion from three orthogonal unit vectors. */ FXQuatd(const FXVec3d& ex,const FXVec3d& ey,const FXVec3d& ez); /** * Construct quaternion from rotation vector rot, representing a rotation * by |rot| radians about a unit vector rot/|rot|. */ FXQuatd(const FXVec3d& rot); /** * Return a non-const reference to the ith element. */ FXdouble& operator[](FXint i){return (&x)[i];} /** * Return a const reference to the ith element. */ const FXdouble& operator[](FXint i) const {return (&x)[i];} /** * Assignment from other quaternion. */ FXQuatd& operator=(const FXQuatd& v){x=v.x;y=v.y;z=v.z;w=v.w;return *this;} /** * Assignment from array of four doubles. */ FXQuatd& operator=(const FXdouble v[]){x=v[0];y=v[1];z=v[2];w=v[3];return *this;} /** * Set value from another quaternion. */ FXQuatd& set(const FXQuatd& v){x=v.x;y=v.y;z=v.z;w=v.w;return *this;} /** * Set value from array of four doubles. */ FXQuatd& set(const FXdouble v[]){x=v[0];y=v[1];z=v[2];w=v[3];return *this;} /** * Set value from four components. */ FXQuatd& set(FXdouble xx,FXdouble yy,FXdouble zz,FXdouble ww){x=xx;y=yy;z=zz;w=ww;return *this;} /// Assigning operators FXQuatd& operator*=(FXdouble n){ return set(x*n,y*n,z*n,w*n); } FXQuatd& operator/=(FXdouble n){ return set(x/n,y/n,z/n,w/n); } FXQuatd& operator+=(const FXQuatd& v){ return set(x+v.x,y+v.y,z+v.z,w+v.w); } FXQuatd& operator-=(const FXQuatd& v){ return set(x-v.x,y-v.y,z-v.z,w-v.w); } FXQuatd& operator*=(const FXQuatd& b){ return set(w*b.x+x*b.w+y*b.z-z*b.y, w*b.y+y*b.w+z*b.x-x*b.z, w*b.z+z*b.w+x*b.y-y*b.x, w*b.w-x*b.x-y*b.y-z*b.z); } FXQuatd& operator/=(const FXQuatd& b){ return *this*=b.invert(); } /// Conversion operator FXdouble*(){return &x;} operator const FXdouble*() const {return &x;} /// Conversion to 3-vector, axis of rotation operator FXVec3d&(){return *reinterpret_cast(this);} operator const FXVec3d&() const {return *reinterpret_cast(this);} /// Test if zero FXbool operator!() const {return x==0.0 && y==0.0 && z==0.0 && w==0.0; } /// Unary FXQuatd operator+() const { return *this; } FXQuatd operator-() const { return FXQuatd(-x,-y,-z,-w); } /// Length and square of length FXdouble length2() const { return w*w+z*z+y*y+x*x; } FXdouble length() const { return Math::sqrt(length2()); } /// Adjust quaternion length FXQuatd& adjust(); /** * Set quaternion from axis and angle. * Quaternion represents a rotation of phi radians about unit vector axis. */ void setAxisAngle(const FXVec3d& axis,FXdouble phi); /** * Obtain axis and angle from quaternion. * Return unit vector and angle of rotation phi, in radians. * If identity quaternion (0,0,0,1), return axis as (1,0.0). */ void getAxisAngle(FXVec3d& axis,FXdouble& phi) const; /** * Set quaternion from rotation vector rot, representing a rotation by |rot| radians * about a unit vector rot/|rot|. Set to the identity quaternion (0,0,0,1) if the rotation * vector is equal to (0,0,0). */ void setRotation(const FXVec3d& rot); /** * Get rotation vector from quaternion, representing a rotation of |rot| radians * about an axis rot/|rot|. If quaternion is identity quaternion (0,0,0,1), return (0,0,0). */ FXVec3d getRotation() const; /** * Set unit quaternion to modified rodrigues parameters. * Modified Rodriques parameters are defined as MRP = tan(theta/4)*E, * where theta is rotation angle (radians), and E is unit axis of rotation. */ void setMRP(const FXVec3d& m); /** * Return modified rodrigues parameters from unit quaternion. */ FXVec3d getMRP() const; /// Set quaternion from roll (x), pitch (y), yaw (z), in that order void setRollPitchYaw(FXdouble roll,FXdouble pitch,FXdouble yaw); /// Return the roll (x), pitch (y), yaw (z) angles represented by the quaternion void getRollPitchYaw(FXdouble& roll,FXdouble& pitch,FXdouble& yaw) const; /// Set quaternion from yaw (z), pitch (y), roll (x), in that order void setYawPitchRoll(FXdouble yaw,FXdouble pitch,FXdouble roll); /// Return the yaw (z), pitch (y), roll (x) angles represented by the quaternion void getYawPitchRoll(FXdouble& yaw,FXdouble& pitch,FXdouble& roll) const; /// Set quaternion from roll (x), yaw (z), pitch (y), in that order void setRollYawPitch(FXdouble roll,FXdouble yaw,FXdouble pitch); /// Return the roll (x), yaw (z), pitch (y) angles represented by the quaternion void getRollYawPitch(FXdouble& roll,FXdouble& yaw,FXdouble& pitch) const; /// Set quaternion from pitch (y), roll (x),yaw (z), in that order void setPitchRollYaw(FXdouble pitch,FXdouble roll,FXdouble yaw); /// Return the pitch (y), roll (x),yaw (z) angles represented by the quaternion void getPitchRollYaw(FXdouble& pitch,FXdouble& roll,FXdouble& yaw) const; /// Set quaternion from pitch (y), yaw (z), roll (x), in that order void setPitchYawRoll(FXdouble pitch,FXdouble yaw,FXdouble roll); /// Return the pitch (y), yaw (z), roll (x) angles represented by the quaternion void getPitchYawRoll(FXdouble& pitch,FXdouble& yaw,FXdouble& roll) const; /// Set quaternion from yaw (z), roll (x), pitch (y), in that order void setYawRollPitch(FXdouble yaw,FXdouble roll,FXdouble pitch); /// Return the yaw (z), roll (x), pitch (y) angles represented by the quaternion void getYawRollPitch(FXdouble& yaw,FXdouble& roll,FXdouble& pitch) const; /// Set quaternion from axes void setAxes(const FXVec3d& ex,const FXVec3d& ey,const FXVec3d& ez); /// Get quaternion axes void getAxes(FXVec3d& ex,FXVec3d& ey,FXVec3d& ez) const; /// Obtain local x axis FXVec3d getXAxis() const; /// Obtain local y axis FXVec3d getYAxis() const; /// Obtain local z axis FXVec3d getZAxis() const; /// Exponentiate quaternion FXQuatd exp() const; /// Take logarithm of quaternion FXQuatd log() const; /// Power of quaternion FXQuatd pow(FXdouble t) const; /// Conjugate quaternion FXQuatd conj() const { return FXQuatd(-x,-y,-z,w); } /// Invert unit quaternion FXQuatd unitinvert() const { return FXQuatd(-x,-y,-z,w); } /// Invert quaternion FXQuatd invert() const { FXdouble m(length2()); return FXQuatd(-x/m,-y/m,-z/m,w/m); } /// Destructor ~FXQuatd(){} }; /// Scaling inline FXQuatd operator*(const FXQuatd& a,FXdouble n){return FXQuatd(a.x*n,a.y*n,a.z*n,a.w*n);} inline FXQuatd operator*(FXdouble n,const FXQuatd& a){return FXQuatd(n*a.x,n*a.y,n*a.z,n*a.w);} inline FXQuatd operator/(const FXQuatd& a,FXdouble n){return FXQuatd(a.x/n,a.y/n,a.z/n,a.w/n);} inline FXQuatd operator/(FXdouble n,const FXQuatd& a){return FXQuatd(n/a.x,n/a.y,n/a.z,n/a.w);} /// Quaternion and quaternion multiply inline FXQuatd operator*(const FXQuatd& a,const FXQuatd& b){ return FXQuatd(a.w*b.x+a.x*b.w+a.y*b.z-a.z*b.y, a.w*b.y+a.y*b.w+a.z*b.x-a.x*b.z, a.w*b.z+a.z*b.w+a.x*b.y-a.y*b.x, a.w*b.w-a.x*b.x-a.y*b.y-a.z*b.z); } inline FXQuatd operator/(const FXQuatd& a,const FXQuatd& b){ return a*b.invert(); } /// Rotation unit-quaternion and vector q . v = (q* . v . q) extern FXAPI FXVec3d operator*(const FXQuatd& q,const FXVec3d& v); /// Rotation a vector and unit-quaternion v . q = (q . v . q*) extern FXAPI FXVec3d operator*(const FXVec3d& v,const FXQuatd& q); /// Quaternion and quaternion addition inline FXQuatd operator+(const FXQuatd& a,const FXQuatd& b){ return FXQuatd(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w); } inline FXQuatd operator-(const FXQuatd& a,const FXQuatd& b){ return FXQuatd(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w); } /// Equality tests inline FXbool operator==(const FXQuatd& a,FXdouble n){return a.x==n && a.y==n && a.z==n && a.w==n;} inline FXbool operator!=(const FXQuatd& a,FXdouble n){return a.x!=n || a.y!=n || a.z!=n || a.w!=n;} inline FXbool operator==(FXdouble n,const FXQuatd& a){return n==a.x && n==a.y && n==a.z && n==a.w;} inline FXbool operator!=(FXdouble n,const FXQuatd& a){return n!=a.x || n!=a.y || n!=a.z || n!=a.w;} /// Equality tests inline FXbool operator==(const FXQuatd& a,const FXQuatd& b){ return a.x==b.x && a.y==b.y && a.z==b.z && a.w==b.w; } inline FXbool operator!=(const FXQuatd& a,const FXQuatd& b){ return a.x!=b.x || a.y!=b.y || a.z!=b.z || a.w!=b.w; } /// Construct quaternion from arc a->b on unit sphere extern FXAPI FXQuatd arc(const FXVec3d& a,const FXVec3d& b); /// Spherical lerp of unit quaternions u,v extern FXAPI FXQuatd lerp(const FXQuatd& u,const FXQuatd& v,FXdouble f); /// Derivative of spherical lerp of unit quaternions u,v extern FXAPI FXQuatd lerpdot(const FXQuatd& u,const FXQuatd& v,FXdouble f); /// Normalize quaternion such that |Q|==1 extern FXAPI FXQuatd normalize(const FXQuatd& q); /// Normalize quaternion incrementally; assume |Q| approximately 1 already extern FXAPI FXQuatd fastnormalize(const FXQuatd& q); /// Cubic hermite quaternion interpolation extern FXAPI FXQuatd hermite(const FXQuatd& q0,const FXVec3d& r0,const FXQuatd& q1,const FXVec3d& r1,FXdouble t); /// Estimate angular body rates omega from unit quaternions Q0 and Q1 separated by time dt extern FXAPI FXVec3d omegaBody(const FXQuatd& q0,const FXQuatd& q1,FXdouble dt); /// Derivative of unit quaternion q with body angular rates omega (rad/s) extern FXAPI FXQuatd quatDot(const FXQuatd& q,const FXVec3d& omega); /// Calculate angular acceleration of a body with inertial moments tensor M /// Rotation about its axes with angular rates omega, under a torque torq extern FXAPI FXVec3d omegaDot(const FXMat3d& M,const FXVec3d& omega,const FXVec3d& torq); /// Save quaternion to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXQuatd& v); /// Load quaternion from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXQuatd& v); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXQuatf.h000066400000000000000000000301401455751074500221460ustar00rootroot00000000000000/******************************************************************************** * * * S i n g l e - P r e c i s i o n Q u a t e r n i o n * * * ********************************************************************************* * Copyright (C) 1994,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXQUATF_H #define FXQUATF_H namespace FX { // Forward reference class FXMat3f; /// Single-precision quaternion class FXAPI FXQuatf { public: FXfloat x; FXfloat y; FXfloat z; FXfloat w; public: /** * Default constructor; value is not initialized. */ FXQuatf(){} /** * Copy constructor. */ FXQuatf(const FXQuatf& q):x(q.x),y(q.y),z(q.z),w(q.w){} /** * Construct from array of four floats. */ FXQuatf(const FXfloat v[]):x(v[0]),y(v[1]),z(v[2]),w(v[3]){} /** * Construct from four components. */ FXQuatf(FXfloat xx,FXfloat yy,FXfloat zz,FXfloat ww):x(xx),y(yy),z(zz),w(ww){} /** * Construct from rotation axis and angle in radians. */ FXQuatf(const FXVec3f& axis,FXfloat phi); /** * Construct quaternion from arc between two unit vectors fm and to. */ FXQuatf(const FXVec3f& fr,const FXVec3f& to); /** * Construct from euler angles yaw (z), pitch (y), and roll (x). */ FXQuatf(FXfloat roll,FXfloat pitch,FXfloat yaw); /** * Construct quaternion from three orthogonal unit vectors. */ FXQuatf(const FXVec3f& ex,const FXVec3f& ey,const FXVec3f& ez); /** * Construct quaternion from rotation vector rot, representing a rotation * by |rot| radians about a unit vector rot/|rot|. */ FXQuatf(const FXVec3f& rot); /** * Return a non-const reference to the ith element. */ FXfloat& operator[](FXint i){return (&x)[i];} /** * Return a const reference to the ith element. */ const FXfloat& operator[](FXint i) const {return (&x)[i];} /** * Assignment from other quaternion. */ FXQuatf& operator=(const FXQuatf& v){x=v.x;y=v.y;z=v.z;w=v.w;return *this;} /** * Assignment from array of four floats. */ FXQuatf& operator=(const FXfloat v[]){x=v[0];y=v[1];z=v[2];w=v[3];return *this;} /** * Set value from another quaternion. */ FXQuatf& set(const FXQuatf& v){x=v.x;y=v.y;z=v.z;w=v.w;return *this;} /** * Set value from array of four floats. */ FXQuatf& set(const FXfloat v[]){x=v[0];y=v[1];z=v[2];w=v[3];return *this;} /** * Set value from four components. */ FXQuatf& set(FXfloat xx,FXfloat yy,FXfloat zz,FXfloat ww){x=xx;y=yy;z=zz;w=ww;return *this;} /// Assigning operators FXQuatf& operator*=(FXfloat n){ return set(x*n,y*n,z*n,w*n); } FXQuatf& operator/=(FXfloat n){ return set(x/n,y/n,z/n,w/n); } FXQuatf& operator+=(const FXQuatf& v){ return set(x+v.x,y+v.y,z+v.z,w+v.w); } FXQuatf& operator-=(const FXQuatf& v){ return set(x-v.x,y-v.y,z-v.z,w-v.w); } FXQuatf& operator*=(const FXQuatf& b){ return set(w*b.x+x*b.w+y*b.z-z*b.y, w*b.y+y*b.w+z*b.x-x*b.z, w*b.z+z*b.w+x*b.y-y*b.x, w*b.w-x*b.x-y*b.y-z*b.z); } FXQuatf& operator/=(const FXQuatf& b){ return *this*=b.invert(); } /// Conversion operator FXfloat*(){return &x;} operator const FXfloat*() const {return &x;} /// Conversion to 3-vector, axis of rotation operator FXVec3f&(){return *reinterpret_cast(this);} operator const FXVec3f&() const {return *reinterpret_cast(this);} /// Test if zero FXbool operator!() const {return x==0.0f && y==0.0f && z==0.0f && w==0.0f; } /// Unary FXQuatf operator+() const { return *this; } FXQuatf operator-() const { return FXQuatf(-x,-y,-z,-w); } /// Length and square of length FXfloat length2() const { return w*w+z*z+y*y+x*x; } FXfloat length() const { return Math::sqrt(length2()); } /// Adjust quaternion length FXQuatf& adjust(); /** * Set quaternion from axis and angle. * Quaternion represents a rotation of phi radians about unit vector axis. */ void setAxisAngle(const FXVec3f& axis,FXfloat phi); /** * Obtain axis and angle from quaternion. * Return unit vector and angle of rotation phi, in radians. * If identity quaternion (0,0,0,1), return axis as (1,0.0). */ void getAxisAngle(FXVec3f& axis,FXfloat& phi) const; /** * Set quaternion from rotation vector rot, representing a rotation by |rot| radians * about a unit vector rot/|rot|. Set to the identity quaternion (0,0,0,1) if the rotation * vector is equal to (0,0,0). */ void setRotation(const FXVec3f& rot); /** * Get rotation vector from quaternion, representing a rotation of |rot| radians * about an axis rot/|rot|. If quaternion is identity quaternion (0,0,0,1), return (0,0,0). */ FXVec3f getRotation() const; /** * Set unit quaternion to modified rodrigues parameters. * Modified Rodriques parameters are defined as MRP = tan(theta/4)*E, * where theta is rotation angle (radians), and E is unit axis of rotation. */ void setMRP(const FXVec3f& m); /** * Return modified rodrigues parameters from unit quaternion. */ FXVec3f getMRP() const; /// Set quaternion from roll (x), pitch (y), yaw (z), in that order void setRollPitchYaw(FXfloat roll,FXfloat pitch,FXfloat yaw); /// Return the roll (x), pitch (y), yaw (z) angles represented by the quaternion void getRollPitchYaw(FXfloat& roll,FXfloat& pitch,FXfloat& yaw) const; /// Set quaternion from yaw (z), pitch (y), roll (x), in that order void setYawPitchRoll(FXfloat yaw,FXfloat pitch,FXfloat roll); /// Return the yaw (z), pitch (y), roll (x) angles represented by the quaternion void getYawPitchRoll(FXfloat& yaw,FXfloat& pitch,FXfloat& roll) const; /// Set quaternion from roll (x), yaw (z), pitch (y), in that order void setRollYawPitch(FXfloat roll,FXfloat yaw,FXfloat pitch); /// Return the roll (x), yaw (z), pitch (y) angles represented by the quaternion void getRollYawPitch(FXfloat& roll,FXfloat& yaw,FXfloat& pitch) const; /// Set quaternion from pitch (y), roll (x),yaw (z), in that order void setPitchRollYaw(FXfloat pitch,FXfloat roll,FXfloat yaw); /// Return the pitch (y), roll (x),yaw (z) angles represented by the quaternion void getPitchRollYaw(FXfloat& pitch,FXfloat& roll,FXfloat& yaw) const; /// Set quaternion from pitch (y), yaw (z), roll (x), in that order void setPitchYawRoll(FXfloat pitch,FXfloat yaw,FXfloat roll); /// Return the pitch (y), yaw (z), roll (x) angles represented by the quaternion void getPitchYawRoll(FXfloat& pitch,FXfloat& yaw,FXfloat& roll) const; /// Set quaternion from yaw (z), roll (x), pitch (y), in that order void setYawRollPitch(FXfloat yaw,FXfloat roll,FXfloat pitch); /// Return the yaw (z), roll (x), pitch (y) angles represented by the quaternion void getYawRollPitch(FXfloat& yaw,FXfloat& roll,FXfloat& pitch) const; /// Set quaternion from axes void setAxes(const FXVec3f& ex,const FXVec3f& ey,const FXVec3f& ez); /// Get quaternion axes void getAxes(FXVec3f& ex,FXVec3f& ey,FXVec3f& ez) const; /// Obtain local x axis FXVec3f getXAxis() const; /// Obtain local y axis FXVec3f getYAxis() const; /// Obtain local z axis FXVec3f getZAxis() const; /// Exponentiate quaternion FXQuatf exp() const; /// Take logarithm of quaternion FXQuatf log() const; /// Power of quaternion FXQuatf pow(FXfloat t) const; /// Conjugate quaternion FXQuatf conj() const { return FXQuatf(-x,-y,-z,w); } /// Invert unit quaternion FXQuatf unitinvert() const { return FXQuatf(-x,-y,-z,w); } /// Invert quaternion FXQuatf invert() const { FXfloat m(length2()); return FXQuatf(-x/m,-y/m,-z/m,w/m); } /// Destructor ~FXQuatf(){} }; /// Scaling inline FXQuatf operator*(const FXQuatf& a,FXfloat n){return FXQuatf(a.x*n,a.y*n,a.z*n,a.w*n);} inline FXQuatf operator*(FXfloat n,const FXQuatf& a){return FXQuatf(n*a.x,n*a.y,n*a.z,n*a.w);} inline FXQuatf operator/(const FXQuatf& a,FXfloat n){return FXQuatf(a.x/n,a.y/n,a.z/n,a.w/n);} inline FXQuatf operator/(FXfloat n,const FXQuatf& a){return FXQuatf(n/a.x,n/a.y,n/a.z,n/a.w);} /// Quaternion and quaternion multiply inline FXQuatf operator*(const FXQuatf& a,const FXQuatf& b){ return FXQuatf(a.w*b.x+a.x*b.w+a.y*b.z-a.z*b.y, a.w*b.y+a.y*b.w+a.z*b.x-a.x*b.z, a.w*b.z+a.z*b.w+a.x*b.y-a.y*b.x, a.w*b.w-a.x*b.x-a.y*b.y-a.z*b.z); } inline FXQuatf operator/(const FXQuatf& a,const FXQuatf& b){ return a*b.invert(); } /// Rotation unit-quaternion and vector q . v = (q* . v . q) extern FXAPI FXVec3f operator*(const FXQuatf& q,const FXVec3f& v); /// Rotation a vector and unit-quaternion v . q = (q . v . q*) extern FXAPI FXVec3f operator*(const FXVec3f& v,const FXQuatf& q); /// Quaternion and quaternion addition inline FXQuatf operator+(const FXQuatf& a,const FXQuatf& b){ return FXQuatf(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w); } inline FXQuatf operator-(const FXQuatf& a,const FXQuatf& b){ return FXQuatf(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w); } /// Equality tests inline FXbool operator==(const FXQuatf& a,FXfloat n){return a.x==n && a.y==n && a.z==n && a.w==n;} inline FXbool operator!=(const FXQuatf& a,FXfloat n){return a.x!=n || a.y!=n || a.z!=n || a.w!=n;} inline FXbool operator==(FXfloat n,const FXQuatf& a){return n==a.x && n==a.y && n==a.z && n==a.w;} inline FXbool operator!=(FXfloat n,const FXQuatf& a){return n!=a.x || n!=a.y || n!=a.z || n!=a.w;} /// Equality tests inline FXbool operator==(const FXQuatf& a,const FXQuatf& b){ return a.x==b.x && a.y==b.y && a.z==b.z && a.w==b.w; } inline FXbool operator!=(const FXQuatf& a,const FXQuatf& b){ return a.x!=b.x || a.y!=b.y || a.z!=b.z || a.w!=b.w; } /// Construct quaternion from arc a->b on unit sphere extern FXAPI FXQuatf arc(const FXVec3f& a,const FXVec3f& b); /// Spherical lerp of unit quaternions u,v extern FXAPI FXQuatf lerp(const FXQuatf& u,const FXQuatf& v,FXfloat f); /// Derivative of spherical lerp of unit quaternions u,v extern FXAPI FXQuatf lerpdot(const FXQuatf& u,const FXQuatf& v,FXfloat f); /// Normalize quaternion such that |Q|==1 extern FXAPI FXQuatf normalize(const FXQuatf& q); /// Normalize quaternion incrementally; assume |Q| approximately 1 already extern FXAPI FXQuatf fastnormalize(const FXQuatf& q); /// Cubic hermite quaternion interpolation extern FXAPI FXQuatf hermite(const FXQuatf& q0,const FXVec3f& r0,const FXQuatf& q1,const FXVec3f& r1,FXfloat t); /// Estimate angular body rates omega from unit quaternions Q0 and Q1 separated by time dt extern FXAPI FXVec3f omegaBody(const FXQuatf& q0,const FXQuatf& q1,FXfloat dt); /// Derivative of unit quaternion q with body angular rates omega (rad/s) extern FXAPI FXQuatf quatDot(const FXQuatf& q,const FXVec3f& omega); /// Calculate angular acceleration of a body with inertial moments tensor M /// Rotation about its axes with angular rates omega, under a torque torq extern FXAPI FXVec3f omegaDot(const FXMat3f& M,const FXVec3f& omega,const FXVec3f& torq); /// Save quaternion to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXQuatf& v); /// Load quaternion from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXQuatf& v); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXRASIcon.h000066400000000000000000000060121455751074500223250ustar00rootroot00000000000000/******************************************************************************** * * * S U N R A S T E R I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXRASICON_H #define FXRASICON_H #ifndef FXICON_H #include "FXIcon.h" #endif namespace FX { /// SUN Raster Image format icon class FXAPI FXRASIcon : public FXIcon { FXDECLARE(FXRASIcon) protected: FXRASIcon(){} private: FXRASIcon(const FXRASIcon&); FXRASIcon &operator=(const FXRASIcon&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct icon from memory stream formatted in SUN Raster Image format FXRASIcon(FXApp* a,const FXuchar *pix=nullptr,FXColor clr=FXRGB(192,192,192),FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in SUN Raster Image format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in SUN Raster Image format virtual FXbool loadPixels(FXStream& store); /// Destroy icon virtual ~FXRASIcon(); }; #ifndef FXLOADRAS #define FXLOADRAS /** * Check if stream contains a RAS, return true if so. */ extern FXAPI FXbool fxcheckRAS(FXStream& store); /** * Load an SUN Raster Image format file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadRAS(FXStream& store,FXColor*& data,FXint& width,FXint& height); /** * Save an SUN Raster Image format file to a stream. */ extern FXAPI FXbool fxsaveRAS(FXStream& store,const FXColor *data,FXint width,FXint height); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXRASImage.h000066400000000000000000000057651455751074500224750ustar00rootroot00000000000000/******************************************************************************** * * * S U N R A S T E R I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXRASIMAGE_H #define FXRASIMAGE_H #ifndef FXIMAGE_H #include "FXImage.h" #endif namespace FX { /// SUN Raster Image format class FXAPI FXRASImage : public FXImage { FXDECLARE(FXRASImage) protected: FXRASImage(){} private: FXRASImage(const FXRASImage&); FXRASImage &operator=(const FXRASImage&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct image from memory stream formatted in SUN Raster Image format FXRASImage(FXApp* a,const FXuchar *pix=nullptr,FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in SUN Raster Image format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in SUN Raster Image format virtual FXbool loadPixels(FXStream& store); /// Destroy icon virtual ~FXRASImage(); }; #ifndef FXLOADRAS #define FXLOADRAS /** * Check if stream contains a RAS, return true if so. */ extern FXAPI FXbool fxcheckRAS(FXStream& store); /** * Load an SUN Raster Image format file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadRAS(FXStream& store,FXColor*& data,FXint& width,FXint& height); /** * Save an SUN Raster Image format file to a stream. */ extern FXAPI FXbool fxsaveRAS(FXStream& store,const FXColor *data,FXint width,FXint height); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXRGBIcon.h000066400000000000000000000057311455751074500223210ustar00rootroot00000000000000/******************************************************************************** * * * I R I S R G B I c o n O b j e c t * * * ********************************************************************************* * Copyright (C) 2002,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXRGBICON_H #define FXRGBICON_H #ifndef FXICON_H #include "FXIcon.h" #endif namespace FX { /// IRIS RGB icon class FXAPI FXRGBIcon : public FXIcon { FXDECLARE(FXRGBIcon) protected: FXRGBIcon(){} private: FXRGBIcon(const FXRGBIcon&); FXRGBIcon &operator=(const FXRGBIcon&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct icon from memory stream formatted in IRIS-RGB format FXRGBIcon(FXApp* a,const FXuchar *pix=nullptr,FXColor clr=FXRGB(192,192,192),FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in IRIS-RGB format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in IRIS-RGB format virtual FXbool loadPixels(FXStream& store); /// Destroy icon virtual ~FXRGBIcon(); }; #ifndef FXLOADRGB #define FXLOADRGB /** * Check if stream contains a RGB, return true if so. */ extern FXAPI FXbool fxcheckRGB(FXStream& store); /** * Load an RGB (SGI IRIS RGB) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadRGB(FXStream& store,FXColor*& data,FXint& width,FXint& height); /** * Save an RGB (SGI IRIS RGB) file to a stream. */ extern FXAPI FXbool fxsaveRGB(FXStream& store,const FXColor *data,FXint width,FXint height); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXRGBImage.h000066400000000000000000000057121455751074500224520ustar00rootroot00000000000000/******************************************************************************** * * * I R I S R G B I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 2002,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXRGBIMAGE_H #define FXRGBIMAGE_H #ifndef FXIMAGE_H #include "FXImage.h" #endif namespace FX { /// IRIS RGB image class FXAPI FXRGBImage : public FXImage { FXDECLARE(FXRGBImage) protected: FXRGBImage(){} private: FXRGBImage(const FXRGBImage&); FXRGBImage &operator=(const FXRGBImage&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct image from memory stream formatted in IRIS-RGB format FXRGBImage(FXApp* a,const FXuchar *pix=nullptr,FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in IRIS-RGB format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in IRIS-RGB format virtual FXbool loadPixels(FXStream& store); /// Destroy icon virtual ~FXRGBImage(); }; #ifndef FXLOADRGB #define FXLOADRGB /** * Check if stream contains a RGB, return true if so. */ extern FXAPI FXbool fxcheckRGB(FXStream& store); /** * Load an RGB (SGI IRIS RGB) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadRGB(FXStream& store,FXColor*& data,FXint& width,FXint& height); /** * Save an RGB (SGI IRIS RGB) file to a stream. */ extern FXAPI FXbool fxsaveRGB(FXStream& store,const FXColor *data,FXint width,FXint height); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXRadioButton.h000066400000000000000000000122371455751074500233270ustar00rootroot00000000000000/******************************************************************************** * * * R a d i o B u t t o n W i d g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXRADIOBUTTON_H #define FXRADIOBUTTON_H #ifndef FXLABEL_H #include "FXLabel.h" #endif namespace FX { /// RadioButton flags enum { RADIOBUTTON_AUTOGRAY = 0x00800000, /// Automatically gray out when not updated RADIOBUTTON_AUTOHIDE = 0x01000000, /// Automatically hide when not updated RADIOBUTTON_NORMAL = JUSTIFY_NORMAL|ICON_BEFORE_TEXT }; /** * A radio button is a tri-state button. Normally, it is either * TRUE or FALSE; a third state MAYBE may be set to indicate that no selection * has been made yet by the user, or that the state is ambiguous. * When pressed, the radio button sets its state to TRUE and sends a SEL_COMMAND * to its target, and the message data set to the state of the radio button, * of the type FXbool. * A group of radio buttons can be made mutually exclusive by linking them * to a common data target. Alternatively, an application can implement a * common SEL_UPDATED handler to check and uncheck radio buttons as appropriate. */ class FXAPI FXRadioButton : public FXLabel { FXDECLARE(FXRadioButton) protected: FXColor radioColor; // Color of radio ball FXColor diskColor; // Color of radio disk FXuchar check; // Radio state FXuchar oldcheck; // Old radio state protected: FXRadioButton(); private: FXRadioButton(const FXRadioButton&); FXRadioButton &operator=(const FXRadioButton&); public: long onPaint(FXObject*,FXSelector,void*); long onUpdate(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onFocusIn(FXObject*,FXSelector,void*); long onFocusOut(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onHotKeyPress(FXObject*,FXSelector,void*); long onHotKeyRelease(FXObject*,FXSelector,void*); long onCheck(FXObject*,FXSelector,void*); long onUncheck(FXObject*,FXSelector,void*); long onUnknown(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); public: /// Construct new radio button FXRadioButton(FXComposite* p,const FXString& text,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=RADIOBUTTON_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Returns true because a radio button can receive focus virtual FXbool canFocus() const; /// Get default width virtual FXint getDefaultWidth(); /// Get default height virtual FXint getDefaultHeight(); /// Set radio button state (TRUE, FALSE or MAYBE) void setCheck(FXuchar s=true,FXbool notify=false); /// Get radio button state (TRUE, FALSE or MAYBE) FXuchar getCheck() const { return check; } /// Change radio button style void setRadioButtonStyle(FXuint style); /// Return current radio button style FXuint getRadioButtonStyle() const; /// Get the radio ball color FXColor getRadioColor() const { return radioColor; } /// Set the radio ball color void setRadioColor(FXColor clr); /// Get the radio disk color FXColor getDiskColor() const { return diskColor; } /// Set the radio disk color void setDiskColor(FXColor clr); /// Save radio button to a stream virtual void save(FXStream& store) const; /// Load radio button from a stream virtual void load(FXStream& store); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXRandom.h000066400000000000000000000057231455751074500223170ustar00rootroot00000000000000/******************************************************************************** * * * R a n d o m N u m b e r G e n e r a t o r * * * ********************************************************************************* * Copyright (C) 2007,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXRANDOM_H #define FXRANDOM_H namespace FX { /** * FXRandom provides a thread-safe random number generator with a period * of around 1.84E19. */ class FXAPI FXRandom { private: FXulong state; public: /** * Construct random generator with default seed value. */ FXRandom(); /** * Construct random generator with given seed s. * A good source of seed values may be the FXThread::time() function. */ FXRandom(FXulong s); /** * Initialize this random generator with the state of another. */ FXRandom(const FXRandom& s):state(s.state){} /** * Assignment state from another random generator. */ FXRandom& operator=(const FXRandom& s){ state=s.state; return *this; } /** * Generate next state of the random generator. */ FXulong next(); /** * Change state of random generator with new seed s. */ void seed(FXulong s); /** * Get state of random generator. */ FXulong getState() const { return state; } /** * Set state of random generator. Ensure state is not zero!. */ void setState(FXulong s){ state=s; } /** * Draw random unsigned long, uniformly distributed. */ FXulong randLong(); /** * Draw random float, uniformly distributed between 0 and 1. */ FXfloat randFloat(); /** * Draw random double, uniformly distributed between 0 and 1. */ FXdouble randDouble(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXRangeSlider.h000066400000000000000000000165461455751074500233030ustar00rootroot00000000000000/******************************************************************************** * * * S l i d e r W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXRANGERANGESLIDER_H #define FXRANGERANGESLIDER_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { /// Range Slider Control styles enum { RANGESLIDER_HORIZONTAL = 0, /// Slider shown horizontally RANGESLIDER_VERTICAL = 0x00008000, /// Slider shown vertically RANGESLIDER_ARROW_UP = 0x00010000, /// Slider has arrow head pointing up RANGESLIDER_ARROW_DOWN = 0x00020000, /// Slider has arrow head pointing down RANGESLIDER_ARROW_LEFT = RANGESLIDER_ARROW_UP, /// Slider has arrow head pointing left RANGESLIDER_ARROW_RIGHT = RANGESLIDER_ARROW_DOWN, /// Slider has arrow head pointing right RANGESLIDER_INSIDE_BAR = 0x00040000, /// Slider is inside the slot rather than overhanging RANGESLIDER_NORMAL = RANGESLIDER_HORIZONTAL }; /** * The range slider widget is a valuator widget which determines a subrange of the * given range. It has two heads, one for the lower and one for the upper range. * Two visual appearances are supported:- the sunken look, which is enabled with * the RANGESLIDER_INSIDE_BAR option and the regular look. The latter may have optional * arrows on the slider thumb. * While being moved, the slider sends a SEL_CHANGED message to its target; * at the end of the interaction, a SEL_COMMAND message is sent. * The message data represents the current slider value, a pointer to an array * of two FXint's, representing the values of the lower and upper positions. */ class FXAPI FXRangeSlider : public FXFrame { FXDECLARE(FXRangeSlider) protected: FXint headPos[2]; // Head position FXint headSize; // Head size FXint slotSize; // Slot size FXColor slotColor; // Color of slot the head moves in FXint dragPoint; // Where the head is grabbed FXint values[4]; // Slider values FXint active; // Which head is being manipulated FXint incr; // Increment when auto-sliding FXString help; // Help string FXString tip; // Tip string protected: FXRangeSlider(); void drawSliderHead(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); private: FXRangeSlider(const FXRangeSlider&); FXRangeSlider &operator=(const FXRangeSlider&); public: long onPaint(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onMouseWheel(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onMiddleBtnPress(FXObject*,FXSelector,void*); long onMiddleBtnRelease(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onAutoSlide(FXObject*,FXSelector,void*); long onCmdSetIntRange(FXObject*,FXSelector,void*); long onCmdGetIntRange(FXObject*,FXSelector,void*); long onCmdSetRealRange(FXObject*,FXSelector,void*); long onCmdGetRealRange(FXObject*,FXSelector,void*); long onCmdSetHelp(FXObject*,FXSelector,void*); long onCmdGetHelp(FXObject*,FXSelector,void*); long onCmdSetTip(FXObject*,FXSelector,void*); long onCmdGetTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); public: enum{ ID_AUTOSLIDE=FXFrame::ID_LAST, ID_LAST }; public: /// Construct a slider widget FXRangeSlider(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=RANGESLIDER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=0,FXint pr=0,FXint pt=0,FXint pb=0); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Returns true because a slider can receive focus virtual FXbool canFocus() const; /// Perform layout virtual void layout(); /// Enable the slider virtual void enable(); /// Disable the slider virtual void disable(); /// Change slider values void setValue(FXint head,FXint value,FXbool notify=false); /// Return slider value FXint getValue(FXint head) const { return values[1+head]; } /// Change the slider's range void setRange(FXint lo,FXint hi,FXbool notify=false); /// Get the slider's current range void getRange(FXint& lo,FXint& hi) const { lo=values[0]; hi=values[3]; } /// Change the slider style FXuint getSliderStyle() const; /// Get the current slider style void setSliderStyle(FXuint style); /// Get the slider's head size FXint getHeadSize() const { return headSize; } /// Change the slider's head size void setHeadSize(FXint hs); /// Get the slider's current slot size FXint getSlotSize() const { return slotSize; } /// Change the slider's slot size void setSlotSize(FXint bs); /// Get the slider's auto-increment/decrement value FXint getIncrement() const { return incr; } /// Change the slider's auto-increment/decrement value void setIncrement(FXint inc); /// Change the color of the slot the slider head moves in void setSlotColor(FXColor clr); /// Get the current slot color FXColor getSlotColor() const { return slotColor; } /// Set the help text to be displayed on the status line void setHelpText(const FXString& text){ help=text; } /// Get the current help text const FXString& getHelpText() const { return help; } /// Set the tip text to be displayed in the tooltip void setTipText(const FXString& text){ tip=text; } /// Get the current tooltip text value const FXString& getTipText() const { return tip; } /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destroy the slider virtual ~FXRangeSlider(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXRanged.h000066400000000000000000000142621455751074500222750ustar00rootroot00000000000000/******************************************************************************** * * * D o u b l e - P r e c i s i o n R a n g e C l a s s * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXRANGED_H #define FXRANGED_H namespace FX { class FXSphered; class FXMat4d; /// Bounds class FXAPI FXRanged { public: FXVec3d lower; FXVec3d upper; public: /// Default constructor; value is not initialized FXRanged(){} /// Initialize with another range FXRanged(const FXRanged& bounds):lower(bounds.lower),upper(bounds.upper){} /// Initialize with a single point FXRanged(const FXVec3d& p):lower(p),upper(p){} /// Initialize with corner points FXRanged(const FXVec3d& l,const FXVec3d& h):lower(l),upper(h){} /// Initialize with a single point FXRanged(FXdouble x,FXdouble y,FXdouble z):lower(x,y,z),upper(x,y,z){} /// Initialize with explicit values FXRanged(FXdouble xl,FXdouble xh,FXdouble yl,FXdouble yh,FXdouble zl,FXdouble zh):lower(xl,yl,zl),upper(xh,yh,zh){} /// Initialize box to fully contain the given bounding sphere FXRanged(const FXSphered& sphere); /// Assignment FXRanged& operator=(const FXRanged& bounds){ lower=bounds.lower; upper=bounds.upper; return *this; } /// Set value from another range FXRanged& set(const FXRanged& bounds){ lower=bounds.lower; upper=bounds.upper; return *this; } /// Set value from single point FXRanged& set(const FXVec3d& p){ lower=upper=p; return *this; } /// Set value from corner points FXRanged& set(const FXVec3d& l,const FXVec3d& h){ lower=l; upper=h; return *this; } /// Set value from single point FXRanged& set(FXdouble x,FXdouble y,FXdouble z){ lower.x=upper.x=x; lower.y=upper.y=y; lower.z=upper.z=z; return *this; } /// Set value from explicit values FXRanged& set(FXdouble xl,FXdouble xh,FXdouble yl,FXdouble yh,FXdouble zl,FXdouble zh){ lower.set(xl,yl,zl); upper.set(xh,yh,zh); return *this; } /// Indexing with 0..1 FXVec3d& operator[](FXint i){ return (&lower)[i]; } /// Indexing with 0..1 const FXVec3d& operator[](FXint i) const { return (&lower)[i]; } /// Comparison FXbool operator==(const FXRanged& r) const { return lower==r.lower && upper==r.upper; } FXbool operator!=(const FXRanged& r) const { return lower!=r.lower || upper!=r.upper; } /// Width of box FXdouble width() const { return upper.x-lower.x; } /// Height of box FXdouble height() const { return upper.y-lower.y; } /// Depth of box FXdouble depth() const { return upper.z-lower.z; } /// Area of box FXdouble area() const { return (width()*height()+width()*depth()+height()*depth())*2.0; } /// Volume of box FXdouble volume() const { return width()*height()*depth(); } /// Longest side FXdouble longest() const; /// Shortest side FXdouble shortest() const; /// Length of diagonal FXdouble diameter() const; /// Get radius of box FXdouble radius() const; /// Compute diagonal FXVec3d diagonal() const; /// Get center of box FXVec3d center() const; /// Test if empty FXbool empty() const; /// Test if box contains point x,y,z FXbool contains(FXdouble x,FXdouble y,FXdouble z) const; /// Test if box contains point p FXbool contains(const FXVec3d& p) const; /// Test if box properly contains another box FXbool contains(const FXRanged& bounds) const; /// Test if box properly contains sphere FXbool contains(const FXSphered& sphere) const; /// Include point FXRanged& include(FXdouble x,FXdouble y,FXdouble z); /// Include point FXRanged& include(const FXVec3d& v); /// Include given range into box FXRanged& include(const FXRanged& box); /// Include given sphere into this box FXRanged& include(const FXSphered& sphere); /// Intersect box with normalized plane ax+by+cz+w; returns -1,0,+1 FXint intersect(const FXVec4d &plane) const; /// Intersect box with ray u-v FXbool intersect(const FXVec3d& u,const FXVec3d& v) const; /// Intersect box with ray pos+lambda*dir, returning true if hit FXbool intersect(const FXVec3d& pos,const FXVec3d& dir,FXdouble hit[]) const; /// Get corner number 0..7 FXVec3d corner(FXint c) const { return FXVec3d((&lower)[c&1].x, (&lower)[(c>>1)&1].y, (&lower)[c>>2].z); } /// Transform range by 4x4 matrix FXRanged transform(const FXMat4d& mat) const; /// Destructor ~FXRanged(){} }; /// Test if boxes a and b overlap extern FXAPI FXbool overlap(const FXRanged& a,const FXRanged& b); /// Union of two boxes extern FXAPI FXRanged unite(const FXRanged& a,const FXRanged& b); /// Intersection of two boxes extern FXAPI FXRanged intersect(const FXRanged& a,const FXRanged& b); /// Save object to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXRanged& bounds); /// Load object from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXRanged& bounds); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXRangef.h000066400000000000000000000142171455751074500222770ustar00rootroot00000000000000/******************************************************************************** * * * S i n g l e - P r e c i s i o n R a n g e C l a s s * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXRANGEF_H #define FXRANGEF_H namespace FX { class FXSpheref; class FXMat4f; /// Bounds class FXAPI FXRangef { public: FXVec3f lower; FXVec3f upper; public: /// Default constructor; value is not initialized FXRangef(){} /// Initialize with another range FXRangef(const FXRangef& bounds):lower(bounds.lower),upper(bounds.upper){} /// Initialize with a single point FXRangef(const FXVec3f& p):lower(p),upper(p){} /// Initialize with corner points FXRangef(const FXVec3f& l,const FXVec3f& h):lower(l),upper(h){} /// Initialize with a single point FXRangef(FXfloat x,FXfloat y,FXfloat z):lower(x,y,z),upper(x,y,z){} /// Initialize with explicit values FXRangef(FXfloat xl,FXfloat xh,FXfloat yl,FXfloat yh,FXfloat zl,FXfloat zh):lower(xl,yl,zl),upper(xh,yh,zh){} /// Initialize box to fully contain the given bounding sphere FXRangef(const FXSpheref& sphere); /// Assignment FXRangef& operator=(const FXRangef& bounds){ lower=bounds.lower; upper=bounds.upper; return *this; } /// Set value from another range FXRangef& set(const FXRangef& bounds){ lower=bounds.lower; upper=bounds.upper; return *this; } /// Set value from single point FXRangef& set(const FXVec3f& p){ lower=upper=p; return *this; } /// Set value from corner points FXRangef& set(const FXVec3f& l,const FXVec3f& h){ lower=l; upper=h; return *this; } /// Set value from single point FXRangef& set(FXfloat x,FXfloat y,FXfloat z){ lower.x=upper.x=x; lower.y=upper.y=y; lower.z=upper.z=z; return *this; } /// Set value from explicit values FXRangef& set(FXfloat xl,FXfloat xh,FXfloat yl,FXfloat yh,FXfloat zl,FXfloat zh){ lower.set(xl,yl,zl); upper.set(xh,yh,zh); return *this; } /// Indexing with 0..1 FXVec3f& operator[](FXint i){ return (&lower)[i]; } /// Indexing with 0..1 const FXVec3f& operator[](FXint i) const { return (&lower)[i]; } /// Comparison FXbool operator==(const FXRangef& r) const { return lower==r.lower && upper==r.upper; } FXbool operator!=(const FXRangef& r) const { return lower!=r.lower || upper!=r.upper; } /// Width of box FXfloat width() const { return upper.x-lower.x; } /// Height of box FXfloat height() const { return upper.y-lower.y; } /// Depth of box FXfloat depth() const { return upper.z-lower.z; } /// Area of box FXfloat area() const { return (width()*height()+width()*depth()+height()*depth())*2.0f; } /// Volume of box FXfloat volume() const { return width()*height()*depth(); } /// Longest side FXfloat longest() const; /// Shortest side FXfloat shortest() const; /// Length of diagonal FXfloat diameter() const; /// Get radius of box FXfloat radius() const; /// Compute diagonal FXVec3f diagonal() const; /// Get center of box FXVec3f center() const; /// Test if empty FXbool empty() const; /// Test if box contains point x,y,z FXbool contains(FXfloat x,FXfloat y,FXfloat z) const; /// Test if box contains point p FXbool contains(const FXVec3f& p) const; /// Test if box properly contains another box FXbool contains(const FXRangef& bounds) const; /// Test if box properly contains sphere FXbool contains(const FXSpheref& sphere) const; /// Include point FXRangef& include(FXfloat x,FXfloat y,FXfloat z); /// Include point FXRangef& include(const FXVec3f& v); /// Include given range into box FXRangef& include(const FXRangef& box); /// Include given sphere into this box FXRangef& include(const FXSpheref& sphere); /// Intersect box with normalized plane ax+by+cz+w; returns -1,0,+1 FXint intersect(const FXVec4f& plane) const; /// Intersect box with ray u-v FXbool intersect(const FXVec3f& u,const FXVec3f& v) const; /// Intersect box with ray pos+lambda*dir, returning true if hit FXbool intersect(const FXVec3f& pos,const FXVec3f& dir,FXfloat hit[]) const; /// Get corner number 0..7 FXVec3f corner(FXint c) const { return FXVec3f((&lower)[c&1].x,(&lower)[(c>>1)&1].y,(&lower)[c>>2].z); } /// Transform range by 4x4 matrix FXRangef transform(const FXMat4f& mat) const; /// Destructor ~FXRangef(){} }; /// Test if boxes a and b overlap extern FXAPI FXbool overlap(const FXRangef& a,const FXRangef& b); /// Union of two boxes extern FXAPI FXRangef unite(const FXRangef& a,const FXRangef& b); /// Intersection of two boxes extern FXAPI FXRangef intersect(const FXRangef& a,const FXRangef& b); /// Save object to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXRangef& bounds); /// Load object from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXRangef& bounds); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXReactor.h000066400000000000000000000143271455751074500224760ustar00rootroot00000000000000/******************************************************************************** * * * R e a c t o r C l a s s * * * ********************************************************************************* * Copyright (C) 2006,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXREACTOR_H #define FXREACTOR_H namespace FX { /** * FXReactor implements the reactor pattern. * Given a list of file descriptors (handles), calling thread is blocked until * any of the following happens: * * - One or more of the file descriptors becomes active; * - A timeout occurs; * - The maximum blocking time is exceeded; * - An interrupt (signal) occurs. * - One or more of the handles develops an error and an FXFatalException * is thrown. * * Depending on what occurred, FXReactor dispatches to one of the handling * API's: dispatchHandle(), dispatchTimeout(), or dispatchSignal(). * Prior to blocking, if nothing demands immediate attention, the special * handler dispatchIdle() is called. * * If dispatchHandle(), dispatchTimeout(), dispatchSignal() or dispatchIdle() * returned true, FXReactor will return with true; otherwise, it will continue * to loop, decreasing the initial blocking time until eventually returning false * when nothing happened during the entire blocking interval. * * Each FXReactor can manage a set of signals, but note that only one single * FXReactor is allowed to manage a particular signal; other signals may be * left unassigned, or managed by other FXReactors. * * If waiting for a very long but finite amount of time, FXReactor will wake up * after at most FXReactor::maxwait, which is about 1 day. * It will continue to loop and wait for additional intervals, decreasing the initial * blocking time until eventually returning false when nothing happened. */ class FXAPI FXReactor { friend class FXEventDispatcher; private: struct Internals; private: Internals *internals; // Internals FXint sigreceived; // Most recent received signal FXint numhandles; // Number of handles FXint numwatched; // Number of watched FXint numraised; // Number of raised handles FXint current; // Current handle private: static FXReactor* volatile sigmanager[64]; private: FXReactor(const FXReactor&); FXReactor &operator=(const FXReactor&); private: static void CDECL signalhandler(FXint sig); static void CDECL signalhandlerasync(FXint sig); public: /// Modes enum { InputNone = 0, /// Inactive handle InputRead = 1, /// Read input handle InputWrite = 2, /// Write input handle InputExcept = 4 /// Except input handle }; /// Dispatch flags enum { DispatchAll = 0xffffffff, /// Dispatch all events DispatchSignals = 0x00000001, /// Dispatch signals DispatchTimers = 0x00000002, /// Dispatch timers DispatchIdle = 0x00000004, /// Dispatch idle processing DispatchEvents = 0x00000008, /// Dispatch events DispatchOther = 0x00000010 /// Dispatch other i/o }; /// Sleep no longer than this static const FXTime maxwait; public: /// Construct reactor. FXReactor(); /// Initialize reactor. virtual FXbool init(); /// Is reactor initialized. FXbool isInitialized() const { return (internals!=nullptr); } /// Dispatch if something happens within given blocking time. /// Flags control subsets of events to be dispatched (signals, timers, /// idle, and more). Default is to dispatch all events. virtual FXbool dispatch(FXTime blocking=forever,FXuint flags=DispatchAll); /// Add new handle hnd to watch-list virtual FXbool addHandle(FXInputHandle hnd,FXuint mode=InputRead); /// Remove handle hnd from watch-list virtual FXbool remHandle(FXInputHandle hnd); /// Dispatch handler for handle hnd. /// Return true if the callback returned true. virtual FXbool dispatchHandle(FXInputHandle hnd,FXuint mode,FXuint flags); /// Add (optionally asynchronous) signal sig to signal-set virtual FXbool addSignal(FXint sig,FXbool=false); /// Remove signal sig from signal-set virtual FXbool remSignal(FXint sig); /// Return true if signal sig is handled by this dispatcher. virtual FXbool hasSignal(FXint sig) const; /// Dispatch when a signal was fired; return true when handled. virtual FXbool dispatchSignal(FXint sig); /// Return time when first timer callback is due; the special /// value forever is returned when no timer is in effect. virtual FXTime nextTimeout(); /// Dispatch when timeout expires; return true when handled. virtual FXbool dispatchTimeout(FXTime due); /// Dispatch when idle; return true when handled. virtual FXbool dispatchIdle(); /// Exit reactor. virtual FXbool exit(); /// Destroy reactor object. virtual ~FXReactor(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXReadWriteLock.h000066400000000000000000000112641455751074500235730ustar00rootroot00000000000000/******************************************************************************** * * * R e a d - W r i t e L o c k C l a s s * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXREADWRITELOCK_H #define FXREADWRITELOCK_H namespace FX { /** * FXReadWriteLock allows multiple readers but only a single writer. * * FXReadWriteLock provides access to a shared region just like FXMutex, * except that threads that just read from the shared variables are not * excluding each other. When a thread tries to write, however, it can * only proceed when no other writers or readers are present. * Thus, data structures which are frequently inspected but rarely updated * can be more effectively accessed with a read/write lock than with a mutex. */ class FXAPI FXReadWriteLock { private: FXuval data[32]; private: FXReadWriteLock(const FXReadWriteLock&); FXReadWriteLock &operator=(const FXReadWriteLock&); public: /// Initialize the read/write lock FXReadWriteLock(); /// Acquire read lock for read/write lock void readLock(); /// Try to acquire read lock for read/write lock FXbool tryReadLock(); /// Unlock read lock void readUnlock(); /// Test if read locked FXbool readLocked(); /// Acquire write lock for read/write mutex void writeLock(); /// Try to acquire write lock for read/write lock FXbool tryWriteLock(); /// Unlock write mutex void writeUnlock(); /// Test if write locked FXbool writeLocked(); /// Delete the read/write lock ~FXReadWriteLock(); }; /// Scoped read lock class FXAPI FXScopedReadLock { private: FXReadWriteLock& rwlock; private: FXScopedReadLock(); FXScopedReadLock(const FXScopedReadLock&); FXScopedReadLock& operator=(const FXScopedReadLock&); public: /// Construct & lock associated read-write lock FXScopedReadLock(FXReadWriteLock& rwl):rwlock(rwl){ lock(); } /// Return reference to associated read-write lock FXReadWriteLock& readwritelock(){ return rwlock; } /// Lock read-write lock void lock(){ rwlock.readLock(); } /// Return true if succeeded locking the read-write lock FXbool trylock(){ return rwlock.tryReadLock(); } /// Return true if read-write lock is already locked FXbool locked(){ return rwlock.readLocked(); } /// Unlock mutex void unlock(){ rwlock.readUnlock(); } /// Destroy and unlock associated read-write lock ~FXScopedReadLock(){ unlock(); } }; /// Scoped write lock class FXAPI FXScopedWriteLock { private: FXReadWriteLock& rwlock; private: FXScopedWriteLock(); FXScopedWriteLock(const FXScopedWriteLock&); FXScopedWriteLock& operator=(const FXScopedWriteLock&); public: /// Construct & lock associated read-write lock FXScopedWriteLock(FXReadWriteLock& rwl):rwlock(rwl){ lock(); } /// Return reference to associated read-write lock FXReadWriteLock& readwritelock(){ return rwlock; } /// Lock read-write lock void lock(){ rwlock.writeLock(); } /// Return true if succeeded locking the read-write lock FXbool trylock(){ return rwlock.tryWriteLock(); } /// Return true if read-write lock is already locked FXbool locked(){ return rwlock.writeLocked(); } /// Unlock read-write lock void unlock(){ rwlock.writeUnlock(); } /// Destroy and unlock associated read-write lock ~FXScopedWriteLock(){ unlock(); } }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXRealSlider.h000066400000000000000000000207301455751074500231200ustar00rootroot00000000000000/******************************************************************************** * * * R e a l S l i d e r W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXREALSLIDER_H #define FXREALSLIDER_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { /// Slider Control styles enum { REALSLIDER_HORIZONTAL = 0, /// Slider shown horizontally REALSLIDER_VERTICAL = 0x00008000, /// Slider shown vertically REALSLIDER_ARROW_UP = 0x00010000, /// Slider has arrow head pointing up REALSLIDER_ARROW_DOWN = 0x00020000, /// Slider has arrow head pointing down REALSLIDER_ARROW_LEFT = REALSLIDER_ARROW_UP, /// Slider has arrow head pointing left REALSLIDER_ARROW_RIGHT = REALSLIDER_ARROW_DOWN, /// Slider has arrow head pointing right REALSLIDER_INSIDE_BAR = 0x00040000, /// Slider is inside the slot rather than overhanging REALSLIDER_TICKS_TOP = 0x00080000, /// Ticks on the top of horizontal slider REALSLIDER_TICKS_BOTTOM = 0x00100000, /// Ticks on the bottom of horizontal slider REALSLIDER_TICKS_LEFT = REALSLIDER_TICKS_TOP, /// Ticks on the left of vertical slider REALSLIDER_TICKS_RIGHT = REALSLIDER_TICKS_BOTTOM, /// Ticks on the right of vertical slider REALSLIDER_NORMAL = REALSLIDER_HORIZONTAL }; /** * The real slider widget is a valuator widget which provides simple linear value range. * Two visual appearances are supported:- the sunken look, which is enabled with * the SLIDER_INSIDE_BAR option and the regular look. The latter may have optional * arrows on the slider thumb. * While being moved, the real slider sends a SEL_CHANGED message to its target; * at the end of the interaction, a SEL_COMMAND message is sent. * The message data represents the current slider value, of type pointer to FXdouble. */ class FXAPI FXRealSlider : public FXFrame { FXDECLARE(FXRealSlider) protected: FXint headPos; // Head position FXint headSize; // Head size FXint slotSize; // Slot size FXColor slotColor; // Color of slot the head moves in FXint dragPoint; // Where on the head is grabbed FXdouble range[2]; // Reported data range FXdouble delta; // Interval between ticks FXdouble incr; // Increment when auto-sliding FXdouble gran; // Granularity FXdouble pos; // Reported data position FXString help; // Help string FXString tip; // Tip string protected: FXRealSlider(); void drawSliderHead(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawHorzTicks(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawVertTicks(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); private: FXRealSlider(const FXRealSlider&); FXRealSlider &operator=(const FXRealSlider&); public: long onPaint(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onMouseWheel(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onMiddleBtnPress(FXObject*,FXSelector,void*); long onMiddleBtnRelease(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onAutoSlide(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdSetLongValue(FXObject*,FXSelector,void*); long onCmdGetLongValue(FXObject*,FXSelector,void*); long onCmdSetRealValue(FXObject*,FXSelector,void*); long onCmdGetRealValue(FXObject*,FXSelector,void*); long onCmdSetIntRange(FXObject*,FXSelector,void*); long onCmdGetIntRange(FXObject*,FXSelector,void*); long onCmdSetRealRange(FXObject*,FXSelector,void*); long onCmdGetRealRange(FXObject*,FXSelector,void*); long onCmdSetHelp(FXObject*,FXSelector,void*); long onCmdGetHelp(FXObject*,FXSelector,void*); long onCmdSetTip(FXObject*,FXSelector,void*); long onCmdGetTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); public: enum{ ID_AUTOSLIDE=FXFrame::ID_LAST, ID_LAST }; public: /// Construct a slider widget FXRealSlider(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=REALSLIDER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=0,FXint pr=0,FXint pt=0,FXint pb=0); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Returns true because a slider can receive focus virtual FXbool canFocus() const; /// Perform layout virtual void layout(); /// Enable the slider virtual void enable(); /// Disable the slider virtual void disable(); /// Change slider value void setValue(FXdouble value,FXbool notify=false); /// Return slider value FXdouble getValue() const { return pos; } /// Change the slider's range void setRange(FXdouble lo,FXdouble hi,FXbool notify=false); /// Get the slider's current range void getRange(FXdouble& lo,FXdouble& hi) const { lo=range[0]; hi=range[1]; } /// Change the slider style FXuint getSliderStyle() const; /// Get the current slider style void setSliderStyle(FXuint style); /// Get the slider's head size FXint getHeadSize() const { return headSize; } /// Change the slider's head size void setHeadSize(FXint hs); /// Get the slider's current slot size FXint getSlotSize() const { return slotSize; } /// Change the slider's slot size void setSlotSize(FXint bs); /// Get the slider's auto-increment/decrement value FXdouble getIncrement() const { return incr; } /// Change the slider's auto-increment/decrement value void setIncrement(FXdouble inc); /// Change slider's granularity void setGranularity(FXdouble gr); /// Return slider's granularity FXdouble getGranularity() const { return gran; } /// Change the delta between ticks void setTickDelta(FXdouble dist); /// Get delta between ticks FXdouble getTickDelta() const { return delta; } /// Change the color of the slot the slider head moves in void setSlotColor(FXColor clr); /// Get the current slot color FXColor getSlotColor() const { return slotColor; } /// Set the help text to be displayed on the status line void setHelpText(const FXString& text){ help=text; } /// Get the current help text const FXString& getHelpText() const { return help; } /// Set the tip text to be displayed in the tooltip void setTipText(const FXString& text){ tip=text; } /// Get the current tooltip text value const FXString& getTipText() const { return tip; } /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destroy the slider virtual ~FXRealSlider(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXRealSpinner.h000066400000000000000000000175111455751074500233170ustar00rootroot00000000000000/******************************************************************************** * * * R e a l - V a l u e d S p i n n e r W i d g e t * * * ********************************************************************************* * Copyright (C) 2003,2022 by Bill Baxter. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXREALSPINNER_H #define FXREALSPINNER_H #ifndef FXPACKER_H #include "FXPacker.h" #endif namespace FX { /// Real Spinner Options enum { REALSPIN_NORMAL = 0, /// Normal, non-cyclic REALSPIN_CYCLIC = 0x00020000, /// Cyclic spinner REALSPIN_NOTEXT = 0x00040000, /// No text visible REALSPIN_NOMAX = 0x00080000, /// Spin all the way up to infinity REALSPIN_NOMIN = 0x00100000, /// Spin all the way down to -infinity REALSPIN_LOG = 0x00200000 /// Logarithmic rather than linear }; class FXTextField; class FXDial; /// Real Spinner control class FXAPI FXRealSpinner : public FXPacker { FXDECLARE(FXRealSpinner) protected: FXTextField *textField; // Text field FXArrowButton *upButton; // The up button FXArrowButton *downButton; // The down button FXdouble range[2]; // Reported data range FXdouble incr; // Increment FXdouble gran; // Granularity FXdouble pos; // Current position protected: FXRealSpinner(); private: FXRealSpinner(const FXRealSpinner&); FXRealSpinner& operator=(const FXRealSpinner&); public: long onUpdIncrement(FXObject*,FXSelector,void*); long onCmdIncrement(FXObject*,FXSelector,void*); long onUpdDecrement(FXObject*,FXSelector,void*); long onCmdDecrement(FXObject*,FXSelector,void*); long onChgEntry(FXObject*,FXSelector,void*); long onCmdEntry(FXObject*,FXSelector,void*); long onWheelEntry(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdSetLongValue(FXObject*,FXSelector,void*); long onCmdGetLongValue(FXObject*,FXSelector,void*); long onCmdSetIntRange(FXObject*,FXSelector,void*); long onCmdGetIntRange(FXObject*,FXSelector,void*); long onCmdSetRealValue(FXObject*,FXSelector,void*); long onCmdGetRealValue(FXObject*,FXSelector,void*); long onCmdSetRealRange(FXObject*,FXSelector,void*); long onCmdGetRealRange(FXObject*,FXSelector,void*); long onFocusSelf(FXObject*,FXSelector,void*); public: enum{ ID_INCREMENT=FXPacker::ID_LAST, ID_DECREMENT, ID_ENTRY, ID_LAST }; public: /// Construct a spinner FXRealSpinner(FXComposite *p,FXint cols,FXObject *tgt=nullptr,FXSelector sel=0,FXuint opts=REALSPIN_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Perform layout virtual void layout(); /// Disable spinner virtual void disable(); /// Enable spinner virtual void enable(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Move the focus to this window virtual void setFocus(); /// Remove the focus from this window virtual void killFocus(); /// Increment spinner void increment(FXbool notify=false); /// Increment spinner by certain amount void incrementByAmount(FXdouble amount,FXbool notify=false); /// Decrement spinner void decrement(FXbool notify=false); /// Decrement spinner by certain amount void decrementByAmount(FXdouble amount,FXbool notify=false); /// Return true if in cyclic mode FXbool isCyclic() const; /// Set to cyclic mode, i.e. wrap around at maximum/minimum void setCyclic(FXbool cyclic); /// Return true if text is visible FXbool isTextVisible() const; /// Set text visible flag void setTextVisible(FXbool flag); /// Change current value virtual void setValue(FXdouble value,FXbool notify=false); /// Return current value FXdouble getValue() const { return pos; } /// Change the spinner's range void setRange(FXdouble lo,FXdouble hi,FXbool notify=false); /// Get the spinner's current range void getRange(FXdouble& lo,FXdouble& hi) const { lo=range[0]; hi=range[1]; } /// Change spinner increment void setIncrement(FXdouble increment); /// Return spinner increment FXdouble getIncrement() const { return incr; } /// Change spinner granularity void setGranularity(FXdouble gr); /// Return spinner granularity FXdouble getGranularity() const { return gran; } /// Set the text font void setFont(FXFont *fnt); /// Get the text font FXFont *getFont() const; /// Set the status line help text for this spinner void setHelpText(const FXString& text); /// Get the status line help text for this spinner const FXString& getHelpText() const; /// Set the tool tip message for this spinner void setTipText(const FXString& text); /// Get the tool tip message for this spinner const FXString& getTipText() const; /// Change spinner style void setSpinnerStyle(FXuint style); /// Return current spinner style FXuint getSpinnerStyle() const; /// Allow editing of the text field void setEditable(FXbool edit=true); /// Return true if text field is editable FXbool isEditable() const; /// Change color of the up arrow void setUpArrowColor(FXColor clr); /// Return color of the up arrow FXColor getUpArrowColor() const; /// Change color of the down arrow void setDownArrowColor(FXColor clr); /// Return color of the the down arrow FXColor getDownArrowColor() const; /// Change text color void setTextColor(FXColor clr); /// Return text color FXColor getTextColor() const; /// Change selected background color void setSelBackColor(FXColor clr); /// Return selected background color FXColor getSelBackColor() const; /// Change selected text color void setSelTextColor(FXColor clr); /// Return selected text color FXColor getSelTextColor() const; /// Changes the cursor color void setCursorColor(FXColor clr); /// Return the cursor color FXColor getCursorColor() const; /// Change width of text field in terms of number of columns * `m' void setNumColumns(FXint cols); /// Return number of columns FXint getNumColumns() const; /// Save spinner to a stream virtual void save(FXStream& store) const; /// Load spinner from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXRealSpinner(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXRecentFiles.h000066400000000000000000000134451455751074500233020ustar00rootroot00000000000000/******************************************************************************** * * * R e c e n t F i l e s L i s t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXRECENTFILES_H #define FXRECENTFILES_H #ifndef FXOBJECT_H #include "FXObject.h" #endif namespace FX { class FXApp; /** * The Recent Files group manages a most recently used (MRU) file list by * means of the standard system registry. * When connected to a widget, like a menu command, the recent files object * updates the menu commands label to the associated recent file name; when * the menu command is invoked, the recent file object sends its target a * SEL_COMMAND message with the message data set to the associated file name, * of the type const char*. * When adding or removing file names, the recent files object automatically * updates the system registry to record these changes. * The ID_ANYFILES may be connected to a menu separator to cause automatic * hiding of the menu separator when there are no recent files. * The number of file names is typically no more than 10. * File names should not be empty. */ class FXAPI FXRecentFiles : public FXObject { FXDECLARE(FXRecentFiles) private: FXSettings *settings; // Settings database where list is kept FXObject *target; // Target object to send message FXSelector message; // Message to send FXString group; // MRU File group FXuint maxfiles; // Maximum number of files to track private: static const FXchar key[32][7]; private: FXRecentFiles(const FXRecentFiles&); FXRecentFiles &operator=(const FXRecentFiles&); public: long onCmdClear(FXObject*,FXSelector,void*); long onCmdFile(FXObject*,FXSelector,void*); long onUpdFile(FXObject*,FXSelector,void*); long onUpdAnyFiles(FXObject*,FXSelector,void*); public: enum{ ID_CLEAR, ID_ANYFILES, ID_FILE_1, ID_FILE_2, ID_FILE_3, ID_FILE_4, ID_FILE_5, ID_FILE_6, ID_FILE_7, ID_FILE_8, ID_FILE_9, ID_FILE_10, ID_FILE_11, ID_FILE_12, ID_FILE_13, ID_FILE_14, ID_FILE_15, ID_FILE_16, ID_FILE_17, ID_FILE_18, ID_FILE_19, ID_FILE_20, ID_FILE_21, ID_FILE_22, ID_FILE_23, ID_FILE_24, ID_FILE_25, ID_FILE_26, ID_FILE_27, ID_FILE_28, ID_FILE_29, ID_FILE_30, ID_FILE_31, ID_FILE_32, ID_LAST }; public: /** * Make new recent files group. * A Settings object and group name must be assigned prior to usage. */ FXRecentFiles(); /** * Make new recent files group, using settings database from application. * An optional target and message may be passed to invoke when one of the * list of files is invoked. */ FXRecentFiles(FXApp* a,const FXString& gp="Recent Files",FXObject *tgt=nullptr,FXSelector sel=0); /** * Make new recent files group, using given settings database. * An optional target and message may be passed to invoke when one of the * list of files is invoked. */ FXRecentFiles(FXSettings* st,const FXString& gp="Recent Files",FXObject *tgt=nullptr,FXSelector sel=0); /// Change settings database void setSettings(FXSettings* s){ settings=s; } /// Return settings database FXSettings* getSettings() const { return settings; } /// Change number of files we're tracking void setMaxFiles(FXuint mx); /// Return the maximum number of files being tracked FXuint getMaxFiles() const { return maxfiles; } /// Set group name void setGroupName(const FXString& name){ group=name; } /// Return group name FXString getGroupName() const { return group; } /// Change the target void setTarget(FXObject *t){ target=t; } /// Get the target FXObject *getTarget() const { return target; } /// Change the message void setSelector(FXSelector sel){ message=sel; } /// Return the message id FXSelector getSelector() const { return message; } /// Obtain the filename at index FXString getFile(FXuint index) const; /// Change the filename at index void setFile(FXuint index,const FXString& filename); /// Append a file void appendFile(const FXString& filename); /// Remove a file void removeFile(const FXString& filename); /// Clear the list of files void clear(); /// Save to a stream virtual void save(FXStream& store) const; /// Load from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXRecentFiles(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXRectangle.h000066400000000000000000000123501455751074500227750ustar00rootroot00000000000000/******************************************************************************** * * * R e c t a n g l e C l a s s * * * ********************************************************************************* * Copyright (C) 1994,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXRECTANGLE_H #define FXRECTANGLE_H #ifndef FXPOINT_H #include "FXPoint.h" #endif namespace FX { /// Rectangle class FXAPI FXRectangle { public: FXshort x; FXshort y; FXshort w; FXshort h; public: /// Constructors FXRectangle(){ } FXRectangle(FXshort xx,FXshort yy,FXshort ww,FXshort hh):x(xx),y(yy),w(ww),h(hh){ } FXRectangle(const FXRectangle& src):x(src.x),y(src.y),w(src.w),h(src.h){ } FXRectangle(const FXPoint& p,const FXSize& s):x(p.x),y(p.y),w(s.w),h(s.h){ } FXRectangle(const FXPoint& topleft,const FXPoint& bottomright):x(topleft.x),y(topleft.y),w(bottomright.x-topleft.x+1),h(bottomright.y-topleft.y+1){ } /// Test if empty FXbool empty() const { return w<=0 || h<=0; } /// Test if zero FXbool operator!() const { return x==0 && y==0 && w==0 && h==0; } /// Equality FXbool operator==(const FXRectangle& r) const { return x==r.x && y==r.y && w==r.w && h==r.h; } FXbool operator!=(const FXRectangle& r) const { return x!=r.x || y!=r.y || w!=r.w || h!=r.h; } /// Point in rectangle FXbool contains(const FXPoint& p) const { return x<=p.x && y<=p.y && p.x>(FXStream& store,FXRectangle& r); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXRefPtr.h000066400000000000000000000075601455751074500223020ustar00rootroot00000000000000/******************************************************************************** * * * R e f e r e n c e C o u n t e d O b j e c t P o i n t e r * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXREFPTR_H #define FXREFPTR_H namespace FX { /// Pointer to shared object template class FXRefPtr { private: EType* ptr; public: /// Default constructor FXRefPtr():ptr(nullptr){ } /// Construct and init FXRefPtr(EType* p):ptr(p){ if(ptr) ptr->ref(); } /// Copy constructor FXRefPtr(const FXRefPtr& org):ptr(org.ptr){ if(ptr) ptr->ref(); } /// Copy constructor from shared pointer of compatible type template FXRefPtr(FXRefPtr& org):ptr(org.ptr){ if(ptr) ptr->ref(); } /// Swap this and other, pain-free FXRefPtr& swap(FXRefPtr& other){ other.ptr=atomicSet(&ptr,other.ptr); return *this; } /// Assignment FXRefPtr& operator=(EType* src){ FXRefPtr tmp(src); swap(tmp); return *this; } /// Assignment FXRefPtr& operator=(const FXRefPtr& src){ FXRefPtr tmp(src); swap(tmp); return *this; } /// Assignment from shared pointer of compatible type template FXRefPtr& operator=(FXRefPtr& src){ FXRefPtr tmp(src); swap(tmp); return *this; } /// Conversion operators operator EType*() const { return ptr; } /// Dereference operator EType& operator*() const { return *ptr; } /// Follow pointer operator EType* operator->() const { return ptr; } /// Test for non-null operator FXbool() const { return !!ptr; } /// Test for NULL FXbool operator!() const { return !ptr; } /// Comparison operator. FXbool operator==(EType *p) const { return ptr==p; } /// Comparison operator. FXbool operator!=(EType *p) const { return ptr!=p; } /// Return pointer value EType* get() const { return ptr; } /// Clear pointer void clear(){ FXRefPtr tmp; swap(tmp); } /// Destructor ~FXRefPtr(){ if(ptr) ptr->unref(); } }; /// Serialize of reference counted pointer template FXStream& operator<<(FXStream& store,const FXRefPtr& obj){ EType *temp=obj; store << temp; return store; } /// Deserialize of reference counted pointer template FXStream& operator>>(FXStream& store,FXRefPtr& obj){ EType *temp; store >> temp; obj=temp; return store; } } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXRegion.h000066400000000000000000000071061455751074500223170ustar00rootroot00000000000000/******************************************************************************** * * * C l i p p i n g R e g i o n * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXREGION_H #define FXREGION_H namespace FX { /// Region class FXAPI FXRegion { friend class FXDC; friend class FXDCWindow; friend class FXWindow; private: void *region; public: /// Construct new empty region FXRegion(); /// Construct new region copied from region r FXRegion(const FXRegion& r); /// Construct new region from rectangle rect FXRegion(const FXRectangle& rect); /// Construct rectangle region FXRegion(FXint x,FXint y,FXint w,FXint h); /// Construct polygon region FXRegion(const FXPoint* points,FXuint npoints,FXbool winding=false); /// Assign region r to this one FXRegion &operator=(const FXRegion& r); /// Return true if region is empty FXbool empty() const; /// Return true if region contains point FXbool contains(FXint x,FXint y) const; /// Return true if region contains rectangle FXbool contains(FXint x,FXint y,FXint w,FXint h) const; /// Return bounding box FXRectangle bounds() const; /// Offset region by dx,dy FXRegion& offset(FXint dx,FXint dy); /// Return true if region equal to this one FXbool operator==(const FXRegion& r) const; /// Return true if region not equal to this one FXbool operator!=(const FXRegion& r) const; /// Union region r with this one FXRegion& operator+=(const FXRegion& r); /// Intersect region r with this one FXRegion& operator*=(const FXRegion& r); /// Subtract region r from this one FXRegion& operator-=(const FXRegion& r); /// Xor region r with this one FXRegion& operator^=(const FXRegion& r); /// Union of this region and region r FXRegion operator+(const FXRegion& r) const; /// Intersection of this region and region r FXRegion operator*(const FXRegion& r) const; /// Subtract region r from this region FXRegion operator-(const FXRegion& r) const; /// Xor of this region and region r FXRegion operator^(const FXRegion& r) const; /// Reset region to empty void reset(); /// Destroy region ~FXRegion(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXRegistry.h000066400000000000000000000134051455751074500227030ustar00rootroot00000000000000/******************************************************************************** * * * R e g i s t r y C l a s s * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXREGISTRY_H #define FXREGISTRY_H #ifndef FXSETTINGS_H #include "FXSettings.h" #endif namespace FX { /** * The Registry maintains a persistent settings database for an application. * The settings database is organized in two groups of three layers each. * Configuration data shared by all users on a system is stored in the system- * wide settings database. Configuration data for a single user is stored in * the per-user database (typically somewhere in the user's home directory). * Each group is further subdivided into three layers. * The Common layer contains configuration data shared by all FOX programs. * The Vendor layer in turn contains configuration data shared by all programs * from a particular vendor (like a suite of interoperating applications). * The Application layer contains configuration data for a particular application * only. * When an FXApp object is constructed, the application name and optional vendor * name parameters determine the names of the Application layer and Vendor layer * settings files (the name of Common layer settings file is pre-determined). * Upon startup, the application's configuration data are assembled by merging * layers from the system-wide group first, and then the layers from the per- * user group. * During this merge, per-user settings override system-wide settings, and * application settings take precedence over vendor settings, which in turn * override common settings. * Only per-user, application-layer settings are ever written:- the other settings * are rarely modified. Typically, system-wide settings are set when an * application is installed, while common per-user settings tend to be changed * by specialized applications (e.g. ControlPanel) or through installation scripts. * The Rregistry is automatically read when FXApp::init() is called, and written * back to the system when FXApp::exit() is called. */ class FXAPI FXRegistry : public FXSettings { protected: FXString applicationkey; // Application key FXString vendorkey; // Vendor key FXString systemdirs; // System-wide settings directories FXString userdir; // User settings directory FXbool ascii; // ASCII file-based registry protected: #if defined(WIN32) FXbool readFromRegistry(FXptr hroot,FXbool mark=false); FXbool writeToRegistry(FXptr hroot); FXbool readFromRegistryGroup(const FXString& group,FXptr hbase,FXbool mark=false); FXbool writeToRegistryGroup(const FXString& group,FXptr hbase); #endif private: FXRegistry(const FXRegistry&); FXRegistry &operator=(const FXRegistry&); public: /** * Construct registry object; akey and vkey must be string constants. * Regular applications SHOULD set a vendor key! */ FXRegistry(const FXString& akey=FXString::null,const FXString& vkey=FXString::null); /** * Set ASCII mode; under MS-Windows, this will switch the system to a * file-based registry system, instead of using the System Registry API. */ void setAsciiMode(FXbool asciiMode){ ascii=asciiMode; } /// Get ASCII mode FXbool getAsciiMode() const { return ascii; } /// Change application key name void setAppKey(const FXString& name){ applicationkey=name; } /// Return application key name const FXString& getAppKey() const { return applicationkey; } /// Change vendor key name void setVendorKey(const FXString& name){ vendorkey=name; } /// Return vendor key name const FXString& getVendorKey() const { return vendorkey; } /// Change search path for system-wide settings void setSystemDirectories(const FXString& dirs){ systemdirs=dirs; } /// Return search path for system-wide settings const FXString& getSystemDirectories() const { return systemdirs; } /// Change directory root for per-user settings tree void setUserDirectory(const FXString& dir){ userdir=dir; } /// Return directory root of per-user settings tree const FXString& getUserDirectory() const { return userdir; } /// Read registry virtual FXbool read(); /// Write registry virtual FXbool write(); /// File extension for settings files static const FXchar ext[]; /// File name of common settings file static const FXchar foxrc[]; /// Destructor virtual ~FXRegistry(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXReplaceDialog.h000066400000000000000000000153331455751074500235700ustar00rootroot00000000000000/******************************************************************************** * * * T e x t R e p l a c e D i a l o g * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXREPLACEDIALOG_H #define FXREPLACEDIALOG_H #ifndef FXDIALOGBOX_H #include "FXDialogBox.h" #endif namespace FX { class FXButton; class FXLabel; class FXTextField; class FXHorizontalFrame; /** * Search and Replace Dialog. * This dialog allows the user to enter a string or pattern to * search for, and a replace string to replace the matched contents with. * Some options can control the search process: case-sensitivity, regular * expression searches, and search direction (forward or backward). * For convenience, the most recent search and replace strings are remembered, * and can be quickly recalled by scrolling back in the respective entry-boxes. * The flags controlling case-sensitivity, pattern search, and search direction * are also remembered and will automatically be reinstated when the corresponding * search string is selected. * Note, the dialog does not itself perform a search, it just provided a convenient * entry box for the search and replace parameters. * A history is kept of past strings and flags that we searched; this can be quickly * recalled by using the arrow-buttons. */ class FXAPI FXReplaceDialog : public FXDialogBox { FXDECLARE(FXReplaceDialog) protected: FXLabel *searchlabel; FXTextField *searchtext; FXHorizontalFrame *searchbox; FXLabel *replacelabel; FXTextField *replacetext; FXHorizontalFrame *replacebox; FXButton *search; FXButton *replace; FXButton *replacesel; FXButton *replaceall; FXButton *cancel; FXString searchHistory[20]; // Search string history FXString replacHistory[20]; // Replace string history FXuint optionHistory[20]; // Options history FXint activeHistory; // Current active history index FXuint searchmode; // Search mode protected: static const FXchar sectionName[]; protected: FXReplaceDialog(){} void appendHistory(const FXString& pat,const FXString& sub,FXuint opt); void loadHistory(); void saveHistory(); private: FXReplaceDialog(const FXReplaceDialog&); FXReplaceDialog &operator=(const FXReplaceDialog&); public: long onUpdDir(FXObject*,FXSelector,void*); long onCmdDir(FXObject*,FXSelector,void*); long onUpdWrap(FXObject*,FXSelector,void*); long onCmdWrap(FXObject*,FXSelector,void*); long onUpdCase(FXObject*,FXSelector,void*); long onCmdCase(FXObject*,FXSelector,void*); long onUpdWords(FXObject*,FXSelector,void*); long onCmdWords(FXObject*,FXSelector,void*); long onUpdRegex(FXObject*,FXSelector,void*); long onCmdRegex(FXObject*,FXSelector,void*); long onSearchKey(FXObject*,FXSelector,void*); long onReplaceKey(FXObject*,FXSelector,void*); long onCmdSearchHistUp(FXObject*,FXSelector,void*); long onCmdSearchHistDn(FXObject*,FXSelector,void*); long onCmdReplaceHistUp(FXObject*,FXSelector,void*); long onCmdReplaceHistDn(FXObject*,FXSelector,void*); long onWheelSearch(FXObject*,FXSelector,void*); long onWheelReplace(FXObject*,FXSelector,void*); long onCmdSearch(FXObject*,FXSelector,void*); long onUpdSearch(FXObject*,FXSelector,void*); long onCmdReplace(FXObject*,FXSelector,void*); long onCmdReplaceSel(FXObject*,FXSelector,void*); long onCmdReplaceAll(FXObject*,FXSelector,void*); public: enum{ ID_SEARCH_UP=FXDialogBox::ID_LAST, ID_SEARCH_DN, ID_REPLACE_UP, ID_REPLACE_DN, ID_SEARCH, ID_SEARCH_NEXT, ID_SEARCH_PREV, ID_REPLACE, ID_REPLACE_SEL, ID_REPLACE_ALL, ID_DIR, ID_CASE, ID_WORDS, ID_REGEX, ID_WRAP, ID_SEARCH_TEXT, ID_REPLACE_TEXT, ID_LAST }; public: enum { DONE = 0, /// Cancel search SEARCH = 1, /// Search for pattern REPLACE = 2, /// Replace first occurrence REPLACE_SEL = 3, /// Replace occurrences in selection REPLACE_ALL = 4 /// Replace all occurrences }; public: /// Construct search and replace dialog box FXReplaceDialog(FXWindow* owner,const FXString& caption,FXIcon* ic=nullptr,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Set text or pattern to search for void setSearchText(const FXString& text); /// Return text or pattern the user has entered FXString getSearchText() const; /// Set replace text void setReplaceText(const FXString& text); /// Return replace text the user has entered FXString getReplaceText() const; /// Set search match mode void setSearchMode(FXuint mode){ searchmode=mode; } /// Return search mode the user has selected FXuint getSearchMode() const { return searchmode; } /// Change search text color void setSearchTextColor(FXColor clr); /// Return search text color FXColor getSearchTextColor() const; /// Change replace text color void setReplaceTextColor(FXColor clr); /// Return replace text color FXColor getReplaceTextColor() const; /// Run modal invocation of the dialog virtual FXuint execute(FXuint placement=PLACEMENT_CURSOR); /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destructor virtual ~FXReplaceDialog(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXReverseDictionary.h000066400000000000000000000121421455751074500245310ustar00rootroot00000000000000/******************************************************************************** * * * R e v e r s e D i c t i o n a r y C l a s s * * * ********************************************************************************* * Copyright (C) 2018,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef REVERSEDICTIONARY_H #define REVERSEDICTIONARY_H namespace FX { /** * The reverse dictionary class is a fast-access hash table, mapping void-pointers to * strings. Subclasses of dictionary can easily specialize the void-pointers to pointers * to particular types; to this end subclasses must overload certain API's and * perform the necessary type-casts for the proper interpretation of the stored * pointer values. * Two special key values are disallowed: NULL and the pointer value (-1L); NULL is * used to designate an unoccupied slot, while (-1L) is used to designate a formerly * occupied slot. * Note that many complex containers in TL now fit inside a pointer, and thus * these types can be used in dictionaries as well! */ class FXAPI FXReverseDictionary { protected: struct Entry { const void* key; FXString data; }; protected: Entry* table; // Hash table protected: // Change size of the table FXbool no(FXival n); // Change number of used entries void used(FXival u){ ((FXival*)table)[-2]=u; } // Change number of free entries void free(FXival f){ ((FXival*)table)[-3]=f; } // Resize the table to the given size, keeping contents FXbool resize(FXival n); public: /// Construct empty dictionary FXReverseDictionary(); /// Construct from another dictionary FXReverseDictionary(const FXReverseDictionary& other); /// Return the size of the table, including the empty slots FXival no() const { return ((FXival*)table)[-1]; } /// Return number of used slots in the table FXival used() const { return ((FXival*)table)[-2]; } /// Return number of free slots in the table FXival free() const { return ((FXival*)table)[-3]; } /// See if map is empty FXbool empty() const { return ((FXival*)table)[-1]<=1; } /// Assignment operator FXReverseDictionary& operator=(const FXReverseDictionary& other); /// Adopt dictionary from another FXReverseDictionary& adopt(FXReverseDictionary& other); /// Find position of given key, returning -1 if not found FXival find(const void* ky) const; /// Check if key is mapped FXbool has(const void* ky) const { return 0<=find(ky); } /// Return reference to slot assocated with given key FXString& at(const void* ky); /// Return constant reference to slot assocated with given key const FXString& at(const void* ky) const; /// Return reference to slot assocated with given key FXString& operator[](const void* ky){ return at(ky); } /// Return constant reference to slot assocated with given key const FXString& operator[](const void* ky) const { return at(ky); } /// Insert association with given key; return old value, if any FXString insert(const void* ky,const FXString& str=FXString::null){ FXString ret(str); return swap(ret,at(ky)); } /// Remove association with given key; return old value, if any FXString remove(const void* ky); /// Erase data at pos in the table; return old value, if any FXString erase(FXival pos); /// Return true if slot is empty. FXbool empty(FXival pos) const { return (table[pos].key==nullptr)||(table[pos].key==(const void*)-1L); } /// Return key at position pos const void* key(FXival pos) const { return table[pos].key; } /// Return reference to slot at position pos FXString& data(FXival pos){ return table[pos].data; } /// Return constant reference to slot at position pos const FXString& data(FXival pos) const { return table[pos].data; } /// Clear entire table FXbool clear(); /// Destroy table ~FXReverseDictionary(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXReverseDictionaryOf.h000066400000000000000000000102471455751074500250220ustar00rootroot00000000000000/******************************************************************************** * * * R e v e r s e D i c t i o n a r y O f P o i n t e r s T o T y p e * * * ********************************************************************************* * Copyright (C) 2018,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef REVERSEDICTIONARYOF_H #define REVERSEDICTIONARYOF_H namespace FX { /** * Dictionary of pointers to TYPE. * Two special key values are disallowed: NULL and the pointer value (-1L); NULL is * used to designate an unoccupied slot, while (-1L) is used to designate a formerly * occupied slot. */ template class FXReverseDictionaryOf : public FXReverseDictionary { public: /// Default constructor FXReverseDictionaryOf(){} /// Copy constructor FXReverseDictionaryOf(const FXReverseDictionaryOf& other):FXReverseDictionary(other){ } /// Assignment operator FXReverseDictionaryOf& operator=(const FXReverseDictionaryOf& other){ return reinterpret_cast&>(FXReverseDictionary::operator=(other)); } /// Adopt reverse dictionary from another FXReverseDictionaryOf& adopt(FXReverseDictionaryOf& other){ return reinterpret_cast&>(FXReverseDictionary::adopt(other)); } /// Find position of given key, returning -1 if not found FXival find(TYPE* ky) const { return FXReverseDictionary::find(ky); } /// Check if key is mapped FXbool has(TYPE* ky) const { return FXReverseDictionary::has(ky); } /// Return reference to slot assocated with given key FXString& at(TYPE* ky){ return FXReverseDictionary::at(ky); } /// Return constant reference to slot assocated with given key const FXString& at(TYPE* ky) const { return FXReverseDictionary::at(ky); } /// Return reference to slot assocated with given key FXString& operator[](TYPE* ky){ return FXReverseDictionary::at(ky); } /// Return constant reference to slot assocated with given key const FXString& operator[](TYPE* ky) const { return FXReverseDictionary::at(ky); } /// Insert association with given key; return old value, if any FXString insert(TYPE* ky,const FXString& str=FXString::null){ return FXReverseDictionary::insert(ky,str); } /// Remove association with given key; return old value, if any FXString remove(TYPE* ky){ return FXReverseDictionary::remove(ky); } /// Erase data at pos in the table; return old value, if any FXString erase(FXival pos){ return FXReverseDictionary::erase(pos); } /// Return key at position pos TYPE* key(FXival pos) const { return reinterpret_cast(FXReverseDictionary::key(pos)); } /// Return reference to slot at position pos FXString& data(FXival pos){ return FXReverseDictionary::data(pos); } /// Return constant reference to slot at position pos const FXString& data(FXival pos) const { return FXReverseDictionary::data(pos); } }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXRex.h000066400000000000000000000236601455751074500216350ustar00rootroot00000000000000/******************************************************************************** * * * R e g u l a r E x p r e s s i o n C l a s s * * * ********************************************************************************* * Copyright (C) 1999,2023 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXREX_H #define FXREX_H namespace FX { /** * FXRex is a regular expression class implementing a NFA matcher. * It supports capturing parentheses, non-capturing parentheses, positive or negative * lookahead, backreferences, case-insensitive matching, counted repetitions, greedy, lazy and * possessive matches, and PERL-like matching operators. * The subject string may be searched forwards or backwards, and may contain any of * 256 possible byte values. * * When parsing a regular expression pattern, the mode parameter is the bitwise OR of * a set of flags and affects the match algorithm. Passing the flag Capture enables * capturing parentheses and back references, and allows the matcher engine to return * the locations of the string matching these sub-patterns. The flag IgnoreCase enables * case-insensitive matching. * * When the flag Newline is passed, newlines are treated like normal characters, and * not line-separators. If Newline flag is not passed, character classes such as '.', * '\D', '\s', [^a-z] etc. will NOT match newlines. The flag Verbatim disables all * special character interpretation, making the entire pattern a literal string to be * matched against a string. * * When the Exact flag is passed, a match succeeds only if the entire string is matched, * i.e. the entire input presented to FXRex must match against the pattern; otherwise, * only a (possibly empty) substring of the input is matched against the pattern. * If the NotEmpty flag is passed, the pattern must match at least one character in order * to succeed, and empty matches are considered non-matching. * * If the flag Syntax will check the pattern for correct syntax only, and not generate a * matching engine; it will just reset the engine to the empty pattern; use this flag to * verify the syntax of the pattern without compiling it. * * When matching a compiled pattern, the mode parameter is the bitwise OR of a set of * flags that affects how the match is performed. Passing the flags NotBol and/or NotEol * causes the begin and end of the subject string NOT to be considered a line start or * line end. * * Patterns which cause inordinate amounts of recursion may cause FXRex to fail where * otherwise it would succeed to match. * FXRex uses no global variables, and thus multiple threads may simultaneously use it; * moreover, multiple threads may use the same instance to perform a match. */ class FXAPI FXRex { private: FXString code; private: static const FXchar *const errors[]; public: /// Regular expression flags enum { /// Flags for both parse and match mode Normal = 0, /// Normal mode (default) Unicode = 1, /// Unicode mode /// Regular expression parse flags Syntax = 2, /// Perform syntax check only Verbatim = 4, /// Literal pattern mode with no magic characters Capture = 8, /// Perform capturing parentheses IgnoreCase = 16, /// Ignore case differences Newline = 32, /// Match-any operators match newline too Exact = 64, /// Exact match to entire string (\A..\Z) NotEmpty = 128, /// A successful match must not be empty Reverse = 256, /// Reverse expression mode Words = 512, /// Match whole words (\<..\>) /// Regular expression match flags NotBol = 1024, /// Start of string is NOT begin of line NotEol = 2048 /// End of string is NOT end of line }; /// Regular expression error codes enum Error { ErrOK = 0, /// No errors ErrEmpty = 1, /// Empty pattern ErrMore = 2, /// More characters after pattern ErrParent = 3, /// Unmatched parenthesis ErrBracket = 4, /// Unmatched bracket ErrBrace = 5, /// Unmatched brace ErrRange = 6, /// Bad character range ErrEscape = 7, /// Bad escape sequence ErrCount = 8, /// Bad counted repeat ErrNoAtom = 9, /// No atom preceding repetition ErrRepeat = 10, /// Repeat following repeat ErrBackRef = 11, /// Bad backward reference ErrClass = 12, /// Bad character class ErrComplex = 13, /// Expression too complex ErrMemory = 14, /// Out of memory ErrToken = 15, /// Illegal token ErrLong = 16, /// Pattern too long ErrSupport = 17 /// Unsupported }; public: /** * Construct empty regular expression object, with the * fallback program installed. */ FXRex(); /** * Copy regular expression object from another. */ FXRex(const FXRex& orig); /// Compile expression from pattern; if error is not NULL, error code is returned FXRex(const FXchar* pattern,FXint mode=Normal,Error* error=nullptr); /// Compile expression from pattern; if error is not NULL, error code is returned FXRex(const FXString& pattern,FXint mode=Normal,Error* error=nullptr); /** * See if regular expression is empty; the regular expression * will be empty when it is unable to parse a pattern due to * a syntax error. */ FXbool empty() const { return code.empty(); } /** * Parse pattern, return error code if syntax error is found. * The parse-mode flags control the compile options, and affect how * the generated matcher behaves. * If a parse fails, an error code is returned; in this case, the * expression matcher will be set up to a fallback program. */ Error parse(const FXchar* pattern,FXint mode=Normal); Error parse(const FXString& pattern,FXint mode=Normal); /** * Perform anchored match of subject string of length len at position pos, returning true * if the pattern matches at this point. * If there is a match, the pattern and subpatterns are captured in the arrays beg[] and end[] * which must both be at least npar entries long. */ FXbool amatch(const FXchar* string,FXint len,FXint pos=0,FXint mode=Normal,FXint* beg=nullptr,FXint* end=nullptr,FXint npar=0) const; FXbool amatch(const FXString& string,FXint pos=0,FXint mode=Normal,FXint* beg=nullptr,FXint* end=nullptr,FXint npar=0) const; /** * Search subject string of length len for a pattern, returning the location where the pattern * is found relative from the start of the string, or -1 if there is no match. * In case of a successful match, the pattern and subpatterns are captured in the arrays beg[] and end[] * which must be at least npar entries long. * The string is searched forwards (or backwards) starting from position fm toward to, both of which * must lie inside the string. */ FXint search(const FXchar* string,FXint len,FXint fm,FXint to,FXint mode=Normal,FXint* beg=nullptr,FXint* end=nullptr,FXint npar=0) const; FXint search(const FXString& string,FXint fm,FXint to,FXint mode=Normal,FXint* beg=nullptr,FXint* end=nullptr,FXint npar=0) const; /** * After performing a regular expression match with capturing parentheses, * a substitution string is build from the replace string, where where "&" * is replaced by the entire matched pattern, and "\1" through "\9" are * replaced by captured expressions. The original source string and its * length, and the match arrays beg and end must be passed. * The replace string may also contain regular escape sequences to embed special * characters. */ static FXString substitute(const FXchar* string,FXint len,FXint* beg,FXint* end,const FXchar* replace,FXint npar=1); static FXString substitute(const FXchar* string,FXint len,FXint* beg,FXint* end,const FXString& replace,FXint npar=1); static FXString substitute(const FXString& string,FXint* beg,FXint* end,const FXchar* replace,FXint npar=1); static FXString substitute(const FXString& string,FXint* beg,FXint* end,const FXString& replace,FXint npar=1); /// Returns error message text for a given error code static const FXchar* getError(Error err){ return errors[err]; } /// Assign another regular expression to this one FXRex& operator=(const FXRex& orig); /// Comparison operators FXbool operator==(const FXRex& rex) const; FXbool operator!=(const FXRex& rex) const; /// Saving and loading friend FXAPI FXStream& operator<<(FXStream& store,const FXRex& s); friend FXAPI FXStream& operator>>(FXStream& store,FXRex& s); /** * Clear the expression object and reinstate the fallback program. */ void clear(); /// Delete ~FXRex(); }; // Serialization extern FXAPI FXStream& operator<<(FXStream& store,const FXRex& s); extern FXAPI FXStream& operator>>(FXStream& store,FXRex& s); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXRootWindow.h000066400000000000000000000057711455751074500232150ustar00rootroot00000000000000/******************************************************************************** * * * R o o t W i n d o w W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXROOTWINDOW_H #define FXROOTWINDOW_H #ifndef FXCOMPOSITE_H #include "FXComposite.h" #endif namespace FX { /// Root window class FXAPI FXRootWindow : public FXComposite { FXDECLARE(FXRootWindow) protected: FXRootWindow(){} #ifdef WIN32 virtual FXID GetDC() const; virtual int ReleaseDC(FXID) const; #endif private: FXRootWindow(const FXRootWindow&); FXRootWindow &operator=(const FXRootWindow&); public: /// Construct root window FXRootWindow(FXApp* a,FXVisual *vis); /// Create server-side resources virtual void create(); /// Can not attach the root window virtual void attach(FXID w); /// Can not detach the root window virtual void detach(); /// Destroy server-side resources virtual void destroy(); /// Perform layout virtual void layout(); /// Return width of the root window virtual FXint getDefaultWidth(); /// Return height of the root window virtual FXint getDefaultHeight(); /// No op virtual void recalc(); /// Root window can not be moved virtual void move(FXint x,FXint y); /// Root window can not be resized virtual void resize(FXint w,FXint h); /// Root window can not be positioned virtual void position(FXint x,FXint y,FXint w,FXint h); /// Root window can not get focus virtual void setFocus(); /// Root window can not loose virtual void killFocus(); /// Destructor virtual ~FXRootWindow(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXRuler.h000066400000000000000000000266431455751074500221740ustar00rootroot00000000000000/******************************************************************************** * * * R u l e r W i d g e t * * * ********************************************************************************* * Copyright (C) 2002,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXRULER_H #define FXRULER_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { /// Ruler options enum { RULER_NORMAL = 0, /// Default appearance (default) RULER_HORIZONTAL = 0, /// Ruler is horizontal (default) RULER_VERTICAL = 0x00008000, /// Ruler is vertical RULER_TICKS_OFF = 0, /// Tick marks off (default) RULER_TICKS_TOP = 0x00010000, /// Ticks on the top (if horizontal) RULER_TICKS_BOTTOM = 0x00020000, /// Ticks on the bottom (if horizontal) RULER_TICKS_LEFT = RULER_TICKS_TOP, /// Ticks on the left (if vertical) RULER_TICKS_RIGHT = RULER_TICKS_BOTTOM, /// Ticks on the right (if vertical) RULER_TICKS_CENTER = RULER_TICKS_TOP|RULER_TICKS_BOTTOM, /// Tickmarks centered RULER_NUMBERS = 0x00040000, /// Show numbers RULER_ARROW = 0x00080000, /// Draw small arrow for cursor position RULER_MARKERS = 0x00100000, /// Draw markers for indentation settings RULER_METRIC = 0, /// Metric subdivision (default) RULER_ENGLISH = 0x00200000, /// English subdivision RULER_MARGIN_ADJUST = 0x00400000, /// Allow margin adjustment RULER_ALIGN_CENTER = 0, /// Center document horizontally RULER_ALIGN_LEFT = 0x00800000, /// Align document to the left RULER_ALIGN_RIGHT = 0x01000000, /// Align document to the right RULER_ALIGN_TOP = RULER_ALIGN_LEFT, /// Align document to the top RULER_ALIGN_BOTTOM = RULER_ALIGN_RIGHT, /// Align document to the bottom RULER_ALIGN_STRETCH = RULER_ALIGN_LEFT|RULER_ALIGN_RIGHT, /// Stretch document to fit horizontally RULER_ALIGN_NORMAL = RULER_ALIGN_CENTER /// Normally, document is centered both ways }; class FXFont; /** * The ruler widget is placed alongside a document to measure position * and size of entities within the document, such as margins, paragraph * indents, and tickmarks. * The ruler widget sends a SEL_CHANGED when the indentation or margins * are interactively changed by the user. * If the document size exceeds the available space, it is possible to * scroll the document using setPosition(). When the document size is * less than the available space, the alignment options can be used to * center, left-adjust, or right-adjust the document. * Finally, a special option exists to stretch the document to the * available space, that is to say, the document will always be fitten * with given left and right edges subtracted from the available space. */ class FXAPI FXRuler : public FXFrame { FXDECLARE(FXRuler) protected: FXFont *font; // Font for numbers FXint documentSize; // Size of document FXint edgeSpacing; // Edge spacing around document FXint marginLower; // Lower margin FXint marginUpper; // Upper margin FXint indentFirst; // First line paragraph indent FXint indentLower; // Lower paragraph indent FXint indentUpper; // Upper paragraph indent FXdouble pixelPerTick; // Number of pixels per tick increment FXint numberTicks; // Tick increments between numbers FXint majorTicks; // Tick increments between major ticks FXint mediumTicks; // Tick increments between medium ticks FXint tinyTicks; // Tick increments between tiny ticks FXint arrowPos; // Arrow position FXColor textColor; // Color for numbers and ticks FXint shift; // Left edge of content FXint pos; // Scroll position FXint off; // Offset item was grabbed FXString tip; // Tooltip text FXString help; // Help text FXuchar mode; // Mode widget is in protected: FXRuler(); FXint picked(FXint x,FXint y); void drawLeftArrow(FXDCWindow& dc,FXint x,FXint y); void drawRightArrow(FXDCWindow& dc,FXint x,FXint y); void drawUpArrow(FXDCWindow& dc,FXint x,FXint y); void drawDownArrow(FXDCWindow& dc,FXint x,FXint y); void drawLeftMarker(FXDCWindow& dc,FXint x,FXint y); void drawRightMarker(FXDCWindow& dc,FXint x,FXint y); void drawUpMarker(FXDCWindow& dc,FXint x,FXint y); void drawDownMarker(FXDCWindow& dc,FXint x,FXint y); protected: enum{ MOUSE_NONE, // No mouse operation MOUSE_MARG_LOWER, // Drag lower margin MOUSE_MARG_UPPER, // Drag upper margin MOUSE_PARA_FIRST, // Drag first indent MOUSE_PARA_LOWER, // Drag lower indent MOUSE_PARA_UPPER // Drag upper indent }; private: FXRuler(const FXRuler&); FXRuler &operator=(const FXRuler&); public: long onPaint(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdSetHelp(FXObject*,FXSelector,void*); long onCmdGetHelp(FXObject*,FXSelector,void*); long onCmdSetTip(FXObject*,FXSelector,void*); long onCmdGetTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); public: enum{ ID_ARROW=FXFrame::ID_LAST, ID_LAST }; public: /// Construct label with given text and icon FXRuler(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=RULER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Perform layout virtual void layout(); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Set the current position void setPosition(FXint pos,FXbool notify=false); /// Return the current position FXint getPosition() const { return pos; } /// Change/return content size void setContentSize(FXint size,FXbool notify=false); FXint getContentSize() const; /// Get lower edge of document FXint getDocumentLower() const; /// Get upper edge of document FXint getDocumentUpper() const; /// Change/return document size void setDocumentSize(FXint size,FXbool notify=false); FXint getDocumentSize() const { return documentSize; } /// Change/return document edge spacing void setEdgeSpacing(FXint space,FXbool notify=false); FXint getEdgeSpacing() const { return edgeSpacing; } /// Change/return lower document margin void setMarginLower(FXint mgn,FXbool notify=false); FXint getMarginLower() const { return marginLower; } /// Change/return upper document margin void setMarginUpper(FXint mgn,FXbool notify=false); FXint getMarginUpper() const { return marginUpper; } /// Change/return first line indent void setIndentFirst(FXint ind,FXbool notify=false); FXint getIndentFirst() const { return indentFirst; } /// Change/return lower indent void setIndentLower(FXint ind,FXbool notify=false); FXint getIndentLower() const { return indentLower; } /// Change/return upper indent void setIndentUpper(FXint ind,FXbool notify=false); FXint getIndentUpper() const { return indentUpper; } /// Change/return document number placement void setNumberTicks(FXint ticks,FXbool notify=false); FXint getNumberTicks() const { return numberTicks; } /// Change/return document major ticks void setMajorTicks(FXint ticks,FXbool notify=false); FXint getMajorTicks() const { return majorTicks; } /// Change/return document medium ticks void setMediumTicks(FXint ticks,FXbool notify=false); FXint getMediumTicks() const { return mediumTicks; } /// Change/return document tiny ticks void setTinyTicks(FXint ticks,FXbool notify=false); FXint getTinyTicks() const { return tinyTicks; } /// Change/return pixel per tick spacing void setPixelPerTick(FXdouble space,FXbool notify=false); FXdouble getPixelPerTick() const { return pixelPerTick; } /// Set the text font void setFont(FXFont *fnt,FXbool notify=false); /// Get the text font FXFont* getFont() const { return font; } /// Change arrow value, relative to document position void setValue(FXint value); /// Return arrow value in document FXint getValue() const { return arrowPos; } /// Set ruler style void setRulerStyle(FXuint style); /// Get ruler style FXuint getRulerStyle() const; /// Set ruler alignment void setRulerAlignment(FXuint alignment,FXbool notify=false); /// Get ruler alignment FXuint getRulerAlignment() const; /// Get the current text color FXColor getTextColor() const { return textColor; } /// Set the current text color void setTextColor(FXColor clr); /// Set the status line help text for the ruler void setHelpText(const FXString& text){ help=text; } /// Get the status line help text for the ruler const FXString& getHelpText() const { return help; } /// Set the tool tip message for the ruler void setTipText(const FXString& text){ tip=text; } /// Get the tool tip message for the ruler const FXString& getTipText() const { return tip; } /// Save label to a stream virtual void save(FXStream& store) const; /// Load label from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXRuler(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXRulerView.h000066400000000000000000000211231455751074500230130ustar00rootroot00000000000000/******************************************************************************** * * * R u l e r V i e w W i d g e t * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXRULERVIEW_H #define FXRULERVIEW_H #ifndef FXSCROLLAREA_H #include "FXScrollArea.h" #endif namespace FX { class FXRuler; class FXFrame; /** * The Ruler View provides viewing of a document with rulers. * It is intended to be subclassed in order to draw actual contents * and provide editing behavior for the document. * The ruler view itself simply manages the geometry of the document * being edited, and coordinates the movement of the ruler displays * as the document is being scrolled. */ class FXAPI FXRulerView : public FXScrollArea { FXDECLARE(FXRulerView) protected: FXRuler *hruler; // Horizontal ruler FXRuler *vruler; // Vertical ruler FXFrame *filler; // Corner thingy FXColor docColor; // Color of document FXString tip; // Tooltip text FXString help; // Help text protected: FXRulerView(); virtual void moveContents(FXint x,FXint y); virtual void drawBackground(FXDCWindow& dc); virtual void drawContents(FXDCWindow& dc); private: FXRulerView(const FXRulerView&); FXRulerView &operator=(const FXRulerView&); public: long onPaint(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onCmdSetHelp(FXObject*,FXSelector,void*); long onCmdGetHelp(FXObject*,FXSelector,void*); long onCmdSetTip(FXObject*,FXSelector,void*); long onCmdGetTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); long onDocChanged(FXObject*,FXSelector,void*); public: enum { ID_HRULER=FXScrollArea::ID_LAST, ID_VRULER, ID_LAST }; public: /// Construct a rulerview window FXRulerView(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Return content width virtual FXint getContentWidth(); /// Return content height virtual FXint getContentHeight(); /// Return visible area x position virtual FXint getVisibleX() const; /// Return visible area y position virtual FXint getVisibleY() const; /// Return visible area width virtual FXint getVisibleWidth() const; /// Return visible area height virtual FXint getVisibleHeight() const; /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Perform layout virtual void layout(); /// Return a pointer to the horizontal ruler FXRuler* horizontalRuler() const { return hruler; } /// Return a pointer to the vertical ruler FXRuler* verticalRuler() const { return vruler; } /// Get document position X FXint getDocumentX() const; /// Get document position Y FXint getDocumentY() const; /// Set document width void setDocumentWidth(FXint w,FXbool notify=false); /// Get document width FXint getDocumentWidth() const; /// Set document height void setDocumentHeight(FXint h,FXbool notify=false); /// Get document height FXint getDocumentHeight() const; /// Set the current document color void setDocumentColor(FXColor clr); /// Get the current document color FXColor getDocumentColor() const { return docColor; } /// Change edge spacing around document void setHEdgeSpacing(FXint es,FXbool notify=false); void setVEdgeSpacing(FXint es,FXbool notify=false); /// Return edge spacing FXint getHEdgeSpacing() const; FXint getVEdgeSpacing() const; /// Change horizontal lower margin void setHMarginLower(FXint marg,FXbool notify=false); /// Change horizontal upper margin void setHMarginUpper(FXint marg,FXbool notify=false); /// Get horizontal lower margin FXint getHMarginLower() const; /// Get horizontal upper margin FXint getHMarginUpper() const; /// Change vertical lower margin void setVMarginLower(FXint marg,FXbool notify=false); /// Change vertical upper margin void setVMarginUpper(FXint marg,FXbool notify=false); /// Get vertical lower margin FXint getVMarginLower() const; /// Get vertical upper margin FXint getVMarginUpper() const; /// Set horizontal alignment; the default is RULER_ALIGN_NORMAL void setHAlignment(FXuint align,FXbool notify=false); /// Return horizontal alignment FXuint getHAlignment() const; /// Set vertical alignment; the default is RULER_ALIGN_NORMAL void setVAlignment(FXuint align,FXbool notify=false); /// Return vertical alignment FXuint getVAlignment() const; /// Set X arrow position, relative to document position void setArrowPosX(FXint x); /// Set X arrow position, relative to document position void setArrowPosY(FXint y); /// Get X arrow position in document FXint getArrowPosX() const; /// Get Y arrow position in document FXint getArrowPosY() const; /// Set the horizontal ruler font void setHRulerFont(FXFont *fnt,FXbool notify=false); /// Get the horizontal ruler font FXFont* getHRulerFont() const; /// Set the vertical ruler font void setVRulerFont(FXFont *fnt,FXbool notify=false); /// Get the vertical ruler font FXFont* getVRulerFont() const; /// Change document number placement void setHNumberTicks(FXint ticks,FXbool notify=false); void setVNumberTicks(FXint ticks,FXbool notify=false); /// Return document number placement FXint getHNumberTicks() const; FXint getVNumberTicks() const; /// Change document major ticks void setHMajorTicks(FXint ticks,FXbool notify=false); void setVMajorTicks(FXint ticks,FXbool notify=false); /// Return document major ticks FXint getHMajorTicks() const; FXint getVMajorTicks() const; /// Change document medium ticks void setHMediumTicks(FXint ticks,FXbool notify=false); void setVMediumTicks(FXint ticks,FXbool notify=false); /// Return document medium ticks FXint getHMediumTicks() const; FXint getVMediumTicks() const; /// Change document tiny ticks void setHTinyTicks(FXint ticks,FXbool notify=false); void setVTinyTicks(FXint ticks,FXbool notify=false); /// Return document tiny ticks FXint getHTinyTicks() const; FXint getVTinyTicks() const; /// Change pixel per tick spacing void setHPixelPerTick(FXdouble space,FXbool notify=false); void setVPixelPerTick(FXdouble space,FXbool notify=false); /// Return pixel per tick spacing FXdouble getHPixelPerTick() const; FXdouble getVPixelPerTick() const; /// Set ruler style void setHRulerStyle(FXuint style); void setVRulerStyle(FXuint style); /// Get ruler style FXuint getHRulerStyle() const; FXuint getVRulerStyle() const; /// Set the status line help text for the ruler view void setHelpText(const FXString& text){ help=text; } /// Get the status line help text for the ruler view const FXString& getHelpText() const { return help; } /// Set the tool tip message for the ruler view void setTipText(const FXString& text){ tip=text; } /// Get the tool tip message for the ruler view const FXString& getTipText() const { return tip; } /// Save list to a stream virtual void save(FXStream& store) const; /// Load list from a stream virtual void load(FXStream& store); /// Destroy virtual ~FXRulerView(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXRunnable.h000066400000000000000000000042331455751074500226400ustar00rootroot00000000000000/******************************************************************************** * * * R u n n a b l e C l a s s * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXRUNNABLE_H #define FXRUNNABLE_H namespace FX { /** * FXRunnable represents a generic runnable thing. It serves primarily * as a base class for FXThread and tasks in FXThreadPool. * FXRunnable must be subclassed to reimplement an overloaded run() function, * which is typically invoked by some thread. */ class FXAPI FXRunnable { public: /// Construct a runnable FXRunnable(){} /// Subclasses should overload this function to perform actual work virtual FXint run() = 0; /// Destroy a runnable virtual ~FXRunnable(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXScopedThread.h000066400000000000000000000046431455751074500234440ustar00rootroot00000000000000/******************************************************************************** * * * S c o p e d T h r e a d S u p p o r t * * * ********************************************************************************* * Copyright (C) 2013,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSCOPEDTHREAD_H #define FXSCOPEDTHREAD_H #ifndef FXTHREAD_H #include "FXThread.h" #endif namespace FX { /** * FXScopedThread is a kind of thread which automatically performs a thread * join to clean up the thread when going out of scope. * Scoped Threads should not be detached, as this would prevent a successful * join(). * Note that Scoped Thread does not forcibly terminate the thread, and thus * allows the thread function run() to conclude gracefully; calling thread * waits inside join() until thread is done. */ class FXAPI FXScopedThread : public FXThread { private: FXScopedThread(const FXScopedThread&); FXScopedThread &operator=(const FXScopedThread&); public: /// Initialize thread object FXScopedThread(); /// Destroy thread after joining it virtual ~FXScopedThread(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXScrollArea.h000066400000000000000000000151621455751074500231240ustar00rootroot00000000000000/******************************************************************************** * * * S c r o l l A r e a W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSCROLLAREA_H #define FXSCROLLAREA_H #ifndef FXCOMPOSITE_H #include "FXComposite.h" #endif namespace FX { /// Scrollbar options enum { SCROLLERS_NORMAL = 0, /// Show the scrollbars when needed HSCROLLER_ALWAYS = 0x00008000, /// Always show horizontal scrollers HSCROLLER_NEVER = 0x00010000, /// Never show horizontal scrollers VSCROLLER_ALWAYS = 0x00020000, /// Always show vertical scrollers VSCROLLER_NEVER = 0x00040000, /// Never show vertical scrollers HSCROLLING_ON = 0, /// Horizontal scrolling turned on (default) HSCROLLING_OFF = HSCROLLER_NEVER|HSCROLLER_ALWAYS, /// Horizontal scrolling turned off VSCROLLING_ON = 0, /// Vertical scrolling turned on (default) VSCROLLING_OFF = VSCROLLER_NEVER|VSCROLLER_ALWAYS, /// Vertical scrolling turned off SCROLLERS_TRACK = 0, /// Scrollers track continuously for smooth scrolling SCROLLERS_DONT_TRACK = 0x00080000 /// Scrollers don't track continuously }; class FXScrollBar; class FXScrollCorner; /** * The scroll area widget manages a content area and a viewport * area through which the content is viewed. When the content area * becomes larger than the viewport area, scrollbars are placed to * permit viewing of the entire content by scrolling the content. * Depending on the mode, scrollbars may be displayed on an as-needed * basis, always, or never. * Normally, the scroll area's size and the content's size are independent; * however, it is possible to disable scrolling in the horizontal * (vertical) direction. In this case, the content width (height) * will influence the width (height) of the scroll area widget. * For content which is time-consuming to repaint, continuous * scrolling may be turned off. * Mouse wheel in content area scrolls vertically, unless vertical * scrolling is disabled. If both directions have scrolling disabled, * mouse wheel is not processed. Subclasses may interpret wheel * events differently. */ class FXAPI FXScrollArea : public FXComposite { FXDECLARE(FXScrollArea) protected: FXScrollBar *horizontal; // Horizontal scroll bar FXScrollBar *vertical; // Vertical scroll bar FXScrollCorner *corner; // Scroll corner FXint pos_x; // X scroll position (pos_x<=0) FXint pos_y; // Y scroll position (pos_y<=0) protected: FXScrollArea(); FXScrollArea(FXComposite* p,FXuint opts,FXint x,FXint y,FXint w,FXint h); virtual void moveContents(FXint x,FXint y); FXbool startAutoScroll(FXEvent *event,FXbool onlywheninside=false); void stopAutoScroll(); void placeScrollBars(FXint vw,FXint vh); private: FXScrollArea(const FXScrollArea&); FXScrollArea &operator=(const FXScrollArea&); public: long onMouseWheel(FXObject*,FXSelector,void*); long onHScrollerChanged(FXObject*,FXSelector,void*); long onVScrollerChanged(FXObject*,FXSelector,void*); long onHScrollerDragged(FXObject*,FXSelector,void*); long onVScrollerDragged(FXObject*,FXSelector,void*); long onAutoScroll(FXObject*,FXSelector,void*); public: enum { ID_AUTOSCROLL=FXComposite::ID_LAST, ID_VSCROLLED, ID_HSCROLLED, ID_LAST }; public: /// Set the current position void setPosition(FXint x,FXint y); /// Get the current position void getPosition(FXint& x,FXint& y) const { x=pos_x; y=pos_y; } /// Return content area x position FXint getContentX() const { return pos_x; } /// Return content area y position FXint getContentY() const { return pos_y; } /// Return content area width virtual FXint getContentWidth(); /// Return content area height virtual FXint getContentHeight(); /// Return visible scroll-area x position virtual FXint getVisibleX() const; /// Return visible scroll-area y position virtual FXint getVisibleY() const; /// Return visible scroll-area width virtual FXint getVisibleWidth() const; /// Return visible scroll-area height virtual FXint getVisibleHeight() const; /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Perform layout virtual void layout(); /// Return true if horizontally scrollable FXbool isHorizontalScrollable() const; /// Return true if vertically scrollable FXbool isVerticalScrollable() const; /// Change scroll style void setScrollStyle(FXuint style); /// Return scroll style FXuint getScrollStyle() const; /// Return a pointer to the horizontal scrollbar FXScrollBar* horizontalScrollBar() const { return horizontal; } /// Return a pointer to the vertical scrollbar FXScrollBar* verticalScrollBar() const { return vertical; } /// Save to a stream virtual void save(FXStream& store) const; /// Load from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXScrollArea(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXScrollBar.h000066400000000000000000000212541455751074500227570ustar00rootroot00000000000000/******************************************************************************** * * * S c r o l l B a r W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSCROLLBAR_H #define FXSCROLLBAR_H #ifndef FXWINDOW_H #include "FXWindow.h" #endif namespace FX { /// ScrollBar styles enum { SCROLLBAR_VERTICAL = 0, /// Vertically oriented SCROLLBAR_HORIZONTAL = 0x00020000, /// Horizontally oriented SCROLLBAR_WHEELJUMP = 0x00040000 /// Mouse wheel jumps instead of sliding smoothly }; /** * The scroll bar is used when a document has a larger content than may be made * visible. The range is the total size of the document, the page size is the viewable * space available for the document. The size of the scrollbar thumb is adjusted to give * feedback of the relative sizes of each. * The scroll bar may be manipulated by the left mouse button (normal scrolling), by the * middle mouse button (same as the left mouse only the scroll position can jump to the * place where the click is made), or by the right mouse button (vernier- or fine-scrolling). * Holding down the control key while scrolling with the left or middle mouse button also * enables vernier-scrolling mode. The vernier-scrolling mode is very useful for accurate * positioning in large documents. * Finally, if the mouse sports a wheel, the scroll bar can be manipulated by means * of the mouse wheel as well. Holding down the Control-key during wheel motion * will cause the scrolling to go faster than normal. * While moving the scroll bar, a message of type SEL_CHANGED will be sent to the * target, and the message data will reflect the current position of type FXint. * At the end of the interaction, the scroll bar will send a message of type * SEL_COMMAND to notify the target of the final position. */ class FXAPI FXScrollBar : public FXWindow { FXDECLARE(FXScrollBar) protected: FXint range; // Scrollable range FXint page; // Page size FXint line; // Line size FXint pos; // Position FXint barsize; // Bar size FXint thumbsize; // Thumb size FXint thumbpos; // Thumb position FXint wheelLines; // Scroll wheel lines FXColor hiliteColor; // Hightlight color FXColor shadowColor; // Shadow color FXColor borderColor; // Border color FXColor arrowColor; // Arrow color FXint dragpoint; // Point where grabbed FXuchar mode; // Current mode of control protected: FXScrollBar(); void drawButton(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down); void drawThumb(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawLeftArrow(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down); void drawRightArrow(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down); void drawUpArrow(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down); void drawDownArrow(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXbool down); protected: enum { MODE_NONE, MODE_INC, MODE_DEC, MODE_PAGE_INC, MODE_PAGE_DEC, MODE_DRAG, MODE_FINE_DRAG }; private: FXScrollBar(const FXScrollBar&); FXScrollBar &operator=(const FXScrollBar&); public: long onPaint(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onMouseWheel(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onMiddleBtnPress(FXObject*,FXSelector,void*); long onMiddleBtnRelease(FXObject*,FXSelector,void*); long onRightBtnPress(FXObject*,FXSelector,void*); long onRightBtnRelease(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onTimeWheel(FXObject*,FXSelector,void*); long onAutoScroll(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdSetLongValue(FXObject*,FXSelector,void*); long onCmdGetLongValue(FXObject*,FXSelector,void*); long onCmdSetIntRange(FXObject*,FXSelector,void*); long onCmdGetIntRange(FXObject*,FXSelector,void*); public: enum{ ID_AUTOSCROLL=FXWindow::ID_LAST, ID_TIMEWHEEL, ID_LAST }; public: /// Construct scroll bar FXScrollBar(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=SCROLLBAR_VERTICAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Perform layout virtual void layout(); /** * Set content size range. The range must be at least 1, * but may be smaller than the viewable page size. */ void setRange(FXint r,FXbool notify=false); /// Return content size range FXint getRange() const { return range; } /** * Set the viewable page size. The page size must be at least 1, * but may be larger than the range. */ void setPage(FXint p,FXbool notify=false); /// Return viewable page size FXint getPage() const { return page; } /** * Change scroll position. The position is always greater or equal * to 0, up to the range less the page size. If the range is less * than the page size, the position will simply be equal to zero. */ void setPosition(FXint p,FXbool notify=false); /// Return current scroll position FXint getPosition() const { return pos; } /// Set scoll increment for line void setLine(FXint l); /// Return line increment FXint getLine() const { return line; } /// Change mouse wheel scroll lines void setWheelLines(FXint lines){ wheelLines=lines; } /// Return current wheel lines FXint getWheelLines() const { return wheelLines; } /// Change highlight color void setHiliteColor(FXColor clr); /// Return highlight color FXColor getHiliteColor() const { return hiliteColor; } /// Change the shadow color void setShadowColor(FXColor clr); /// Return the shadow color FXColor getShadowColor() const { return shadowColor; } /// Change the border color void setBorderColor(FXColor clr); /// Return the border color FXColor getBorderColor() const { return borderColor; } /// Change the arrow color void setArrowColor(FXColor clr); /// Return the arrow color FXColor getArrowColor() const { return arrowColor; } /// Change the scrollbar style void setScrollBarStyle(FXuint style); /// Return the scrollbar style FXuint getScrollBarStyle() const; /// Change the bar size void setBarSize(FXint size); /// Return the bar size FXint getBarSize() const { return barsize; } /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destructor virtual ~FXScrollBar(); }; /// Corner between scroll bars class FXAPI FXScrollCorner : public FXWindow { FXDECLARE(FXScrollCorner) protected: FXScrollCorner(); private: FXScrollCorner(const FXScrollCorner&); FXScrollCorner &operator=(const FXScrollCorner&); public: long onPaint(FXObject*,FXSelector,void*); public: /// Constructor FXScrollCorner(FXComposite* p); /// Can not be enabled virtual void enable(); /// Can not be disabled virtual void disable(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXScrollPane.h000066400000000000000000000063661455751074500231450ustar00rootroot00000000000000/******************************************************************************** * * * S c r o l l i n g M e n u P a n e W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSCROLLPANE_H #define FXSCROLLPANE_H #ifndef FXMENUPANE_H #include "FXMenuPane.h" #endif namespace FX { class FXArrowButton; /** * A Scroll Pane is a menu pane which provides scrolling of menu entries. * It is useful when menus are populated programmatically and it is not * known in advance how many entries will be added. */ class FXAPI FXScrollPane : public FXMenuPane { FXDECLARE(FXScrollPane) protected: FXArrowButton *dn; // Button to scroll down FXArrowButton *up; // Button to scroll up FXint visible; // Visible entries FXint top; // Top visible entry protected: FXScrollPane(); private: FXScrollPane(const FXScrollPane&); FXScrollPane &operator=(const FXScrollPane&); public: long onCmdIncrement(FXObject*,FXSelector,void*); long onCmdDecrement(FXObject*,FXSelector,void*); public: enum { ID_SCROLL_DN=FXMenuPane::ID_LAST, ID_SCROLL_UP, ID_LAST }; public: /// Construct menu pane FXScrollPane(FXWindow* owner,FXint nvis,FXuint opts=0); /// Return the default width of this window virtual FXint getDefaultWidth(); /// Return the default height of this window virtual FXint getDefaultHeight(); /// Show this window virtual void show(); /// Perform layout virtual void layout(); /// Return number of visible items FXint getNumVisible() const { return visible; } /// Change the number of visible items void setNumVisible(FXint nvis); /// Get index of top most menu item FXint getTopItem() const { return top; } /// Scroll item to top void setTopItem(FXint t); /// Destroy virtual ~FXScrollPane(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXScrollWindow.h000066400000000000000000000073171455751074500235260ustar00rootroot00000000000000/******************************************************************************** * * * S c r o l l W i n d o w W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSCROLLWINDOW_H #define FXSCROLLWINDOW_H #ifndef FXSCROLLAREA_H #include "FXScrollArea.h" #endif namespace FX { /** * The ScrollWindow widget manages one single child window and * scrolls it when the child is larger than the available area. * You can use ScrollWindow when parts of your user interface need to be * scrollable, for example when applications may need to run on small screens. * ScrollWindow normally contains only one single child window, which could * be a VerticalFrame or any other widget. It will measure this widget using * getDefaultWidth() and getDefaultHeight() and place the scrollbars when needed, * based on options like HSCROLLING_ALWAYS, etc., and the options of the child * window. * ScrollWindow observes some layout hints of its child window: LAYOUT_FIX_WIDTH, * LAYOUT_FIX_HEIGHT are observed at all times, while LAYOUT_FILL_X, LAYOUT_LEFT, * LAYOUT_RIGHT, LAYOUT_CENTER_X, as well as LAYOUT_FILL_Y, LAYOUT_TOP, LAYOUT_BOTTOM, * LAYOUT_CENTER_Y are only observed if the child window size is smaller than the * ScrollWindow's viewport size. If the content size is larger than the viewport size, * the content must be scrolled normally. * Note that this means that the child window's position is not necessarily equal to * the scroll position of the scroll window! */ class FXAPI FXScrollWindow : public FXScrollArea { FXDECLARE(FXScrollWindow) protected: FXScrollWindow(){} virtual void moveContents(FXint x,FXint y); private: FXScrollWindow(const FXScrollWindow&); FXScrollWindow &operator=(const FXScrollWindow&); public: long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onFocusSelf(FXObject*,FXSelector,void*); public: /// Construct a scroll window FXScrollWindow(FXComposite* p,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Perform layout virtual void layout(); /// Return a pointer to the contents window FXWindow* contentWindow() const; /// Return the width of the contents virtual FXint getContentWidth(); /// Return the height of the contents virtual FXint getContentHeight(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXSearchDialog.h000066400000000000000000000052061455751074500234200ustar00rootroot00000000000000/******************************************************************************** * * * T e x t S e a r c h D i a l o g * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSEARCHDIALOG_H #define FXSEARCHDIALOG_H #ifndef FXREPLACEDIALOG_H #include "FXReplaceDialog.h" #endif namespace FX { /** * Search Dialog. * This dialog allows the user to enter a search string or pattern to * search for; also, some common options such as case-sentitivity, search * direction, and whether or not to perform a regular expression match may * be entered. The most recent couple of search paraneters are remembered * for quick recall for convenience. * Note that this dialog does not actually perform a search, it just provides * an entry box for the search parameters. */ class FXAPI FXSearchDialog : public FXReplaceDialog { FXDECLARE(FXSearchDialog) protected: FXSearchDialog(){} private: FXSearchDialog(const FXSearchDialog&); FXSearchDialog &operator=(const FXSearchDialog&); public: /// Construct search dialog box FXSearchDialog(FXWindow* owner,const FXString& caption,FXIcon* ic=nullptr,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Destructor virtual ~FXSearchDialog(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXSemaQueue.h000066400000000000000000000106411455751074500227640ustar00rootroot00000000000000/******************************************************************************** * * * S e m a p h o r e Q u e u e * * * ********************************************************************************* * Copyright (C) 2006,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSEMAQUEUE_H #define FXSEMAQUEUE_H namespace FX { /** * Semaphore protected queue for a single producer and * a single consumer thread. * Producer thread will only block in push() when the queue * is full; likewise, consumer will only block in pop() if * the queue is empty. * To avoid blocking the producer, call trypush() instead. * Without timeout parameter, trypush() will return immediately * if no space is available. * When the timeout parameter is passed, the producer will wait * a finite amount of time before giving up. * Similarly, to avoid blocking the consumer, call trypop(). * Without the timeout parameter, trypop() will return immediately * if no items are available. * When the timeout parameter is passed, the consumer will wait * a finite amount of time before giving up. */ class FXAPI FXSemaQueue { private: FXPtrQueue queue; // Queue FXSemaphore free; // Free cells FXSemaphore used; // Used cells private: FXSemaQueue(const FXSemaQueue&); FXSemaQueue &operator=(const FXSemaQueue&); public: /// Create initially empty queue of given size sz FXSemaQueue(FXival sz=32); /// Return size FXival getSize() const { return queue.getSize(); } /// Add item to queue, return true if success FXbool push(FXptr ptr); /// Try push object into queue FXbool trypush(FXptr obj); /// Try push object into queue, waiting up /// to nsec for space to become available. FXbool trypush(FXptr obj,FXTime nsec); /// Remove item from queue, return true if success FXbool pop(FXptr& ptr); /// Try pop object from queue FXbool trypop(FXptr& obj); /// Try pop object from queue, waiting up /// to nsec for object to become available. FXbool trypop(FXptr& obj,FXTime nsec); /// Drop item from queue, return true if success FXbool pop(); /// Destroy queue ~FXSemaQueue(); }; // Specialize to pointers to TYPE template class FXSemaQueueOf : public FXSemaQueue { public: /// Create initially empty queue of given size sz FXSemaQueueOf(FXival sz=32):FXSemaQueue(sz){} /// Add item to queue, return true if success FXbool push(TYPE* obj){ return FXSemaQueue::push((FXptr)obj); } /// Try push object into queue, return true if success FXbool trypush(TYPE* obj){ return FXSemaQueue::trypush((FXptr)obj); } /// Try push object into queue, return true if success FXbool trypush(TYPE* obj,FXTime nsec){ return FXSemaQueue::trypush((FXptr)obj,nsec); } /// Drop item from queue, return true if success FXbool pop(TYPE*& obj){ return FXSemaQueue::pop((FXptr&)obj); } /// Try pop object from queue, return true if success FXbool trypop(TYPE*& obj){ return FXSemaQueue::trypop((FXptr&)obj); } /// Try pop object from queue, return true if success FXbool trypop(TYPE*& obj,FXTime nsec){ return FXSemaQueue::trypop((FXptr&)obj,nsec); } }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXSemaphore.h000066400000000000000000000055111455751074500230150ustar00rootroot00000000000000/******************************************************************************** * * * S e m a p h o r e C l a s s * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSEMAPHORE_H #define FXSEMAPHORE_H namespace FX { /** * A semaphore allows for protection of a resource that can * be accessed by a fixed number of simultaneous threads. * * A typical example of the use of semaphores is for a buffer containing N items. * A producer thread may freely append N items before blocking for space to become * available; a consumer thread can remove items and block only when no items are * left. Thus, two counting semaphores could be used to manage such a buffer, one * counting empty slots and one counting filled slots. As long as production and * consumption proceed at comparable rates, no thread needs to be suspended. */ class FXAPI FXSemaphore { private: FXuval data[21]; private: FXSemaphore(const FXSemaphore&); FXSemaphore& operator=(const FXSemaphore&); public: /// Initialize semaphore with given count FXSemaphore(FXint count=1); /// Decrement semaphore by 1, waiting if count is zero void wait(); /// Try decrement semaphore; return false if timed out FXbool wait(FXTime nsec); /// Try decrement semaphore, and return false if count was zero FXbool trywait(); /// Increment semaphore by 1 void post(); /// Delete semaphore ~FXSemaphore(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXSeparator.h000066400000000000000000000077601455751074500230420ustar00rootroot00000000000000/******************************************************************************** * * * S e p a r a t o r W i d g e t s * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSEPARATOR_H #define FXSEPARATOR_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { /// Separator Options enum { SEPARATOR_NONE = 0, /// Nothing visible SEPARATOR_GROOVE = 0x00008000, /// Etched-in looking groove SEPARATOR_RIDGE = 0x00010000, /// Embossed looking ridge SEPARATOR_LINE = 0x00020000 /// Simple line }; /** * A Separator widget is used to draw a horizontal or vertical divider between * groups of controls. It is purely decorative. The separator may be drawn * in various styles as determined by the SEPARATOR_NONE, SEPARATOR_GROOVE, * SEPARATOR_RIDGE, and SEPARATOR_LINE options. Since its derived from Frame, * it can also have the frame's border styles. */ class FXAPI FXSeparator : public FXFrame { FXDECLARE(FXSeparator) protected: FXSeparator(){} private: FXSeparator(const FXSeparator&); FXSeparator &operator=(const FXSeparator&); public: long onPaint(FXObject*,FXSelector,void*); public: /// Constructor FXSeparator(FXComposite* p,FXuint opts=SEPARATOR_GROOVE|LAYOUT_FILL_X,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=0,FXint pr=0,FXint pt=0,FXint pb=0); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Change separator style void setSeparatorStyle(FXuint style); /// Get separator style FXuint getSeparatorStyle() const; }; /// Horizontal separator widget class FXAPI FXHorizontalSeparator : public FXSeparator { FXDECLARE(FXHorizontalSeparator) protected: FXHorizontalSeparator(){} private: FXHorizontalSeparator(const FXHorizontalSeparator&); FXHorizontalSeparator &operator=(const FXHorizontalSeparator&); public: /// Constructor FXHorizontalSeparator(FXComposite* p,FXuint opts=SEPARATOR_GROOVE|LAYOUT_FILL_X,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=1,FXint pr=1,FXint pt=0,FXint pb=0); }; /// Vertical separator widget class FXAPI FXVerticalSeparator : public FXSeparator { FXDECLARE(FXVerticalSeparator) protected: FXVerticalSeparator(){} private: FXVerticalSeparator(const FXVerticalSeparator&); FXVerticalSeparator &operator=(const FXVerticalSeparator&); public: /// Constructor FXVerticalSeparator(FXComposite* p,FXuint opts=SEPARATOR_GROOVE|LAYOUT_FILL_Y,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=0,FXint pr=0,FXint pt=1,FXint pb=1); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXSettings.h000066400000000000000000000304041455751074500226710ustar00rootroot00000000000000/******************************************************************************** * * * S e t t i n g s C l a s s * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSETTINGS_H #define FXSETTINGS_H namespace FX { /** * The Settings class manages a key-value database. This is normally used as * part of Registry, but can also be used separately in applications that need * to maintain a key-value database in a file of their own. * String values can contain any character, and will be escaped when written * to the file. */ class FXAPI FXSettings { protected: struct Entry { FXString key; // Key FXStringDictionary data; // Value FXuint hash; // Hash of key }; protected: Entry *table; // Hash table FXbool modified; // Changed protected: // Change size of the table FXbool no(FXival n); // Change number of used entries void used(FXival u){ ((FXival*)table)[-2]=u; } // Change number of free entries void free(FXival f){ ((FXival*)table)[-3]=f; } // Resize the table to the given size, keeping contents FXbool resize(FXival n); public: /// Construct settings database. FXSettings(); /// Construct from another settings database FXSettings(const FXSettings& other); /// Return the size of the table, including the empty slots FXival no() const { return ((FXival*)table)[-1]; } /// Return number of used slots in the table FXival used() const { return ((FXival*)table)[-2]; } /// Return number of free slots in the table FXival free() const { return ((FXival*)table)[-3]; } /// See if map is empty FXbool empty() const { return ((FXival*)table)[-1]<=1; } /// Assignment operator FXSettings& operator=(const FXSettings& other); /// Adopt string dictionary from another FXSettings& adopt(FXSettings& other); /// Is it modified FXbool isModified() const { return modified; } /// Mark as changed void setModified(FXbool mdfy=true){ modified=mdfy; } /// Parse a file containing a settings database. FXbool parseFile(const FXString& filename,FXbool mrk=true); /// Unparse settings database into given file. FXbool unparseFile(const FXString& filename); /// Parse single string to populate settings FXbool parse(const FXString& string,FXbool mrk=true); /// Unparse settings to a single string FXbool unparse(FXString& string) const; /// Find position of given key, returning -1 if not found FXival find(const FXchar* ky) const; /// Find position of given key, returning -1 if not found FXival find(const FXString& ky) const { return find(ky.text()); } /// Return reference to slot assocated with given key FXStringDictionary& at(const FXchar* ky); /// Return constant reference to slot assocated with given key const FXStringDictionary& at(const FXchar* ky) const; /// Return reference to slot assocated with given key FXStringDictionary& at(const FXString& ky){ return at(ky.text()); } /// Return constant reference to slot assocated with given key const FXStringDictionary& at(const FXString& ky) const { return at(ky.text()); } /// Return reference to slot assocated with given key FXStringDictionary& operator[](const FXchar* ky){ return at(ky); } /// Return constant reference to slot assocated with given key const FXStringDictionary& operator[](const FXchar* ky) const { return at(ky); } /// Return reference to slot assocated with given key FXStringDictionary& operator[](const FXString& ky){ return at(ky); } /// Return constant reference to slot assocated with given key const FXStringDictionary& operator[](const FXString& ky) const { return at(ky); } /// Return true if slot is empty. FXbool empty(FXival pos) const { return table[pos].key.empty(); } /// Return key at position pos const FXString& key(FXival pos) const { return table[pos].key; } /// Return reference to slot at position pos FXStringDictionary& data(FXival pos){ return table[pos].data; } /// Return constant reference to slot at position pos const FXStringDictionary& data(FXival pos) const { return table[pos].data; } /// Read a formatted registry entry, using scanf-style format FXint readFormatEntry(const FXchar* section,const FXchar* name,const FXchar* fmt,...) const FX_SCANF(4,5) ; FXint readFormatEntry(const FXString& section,const FXchar* name,const FXchar* fmt,...) const FX_SCANF(4,5) ; FXint readFormatEntry(const FXString& section,const FXString& name,const FXchar* fmt,...) const FX_SCANF(4,5) ; /// Write a formatted registry entry, using printf-style format FXint writeFormatEntry(const FXchar* section,const FXchar* name,const FXchar* fmt,...) FX_PRINTF(4,5) ; FXint writeFormatEntry(const FXString& section,const FXchar* name,const FXchar* fmt,...) FX_PRINTF(4,5) ; FXint writeFormatEntry(const FXString& section,const FXString& name,const FXchar* fmt,...) FX_PRINTF(4,5) ; /// Read a string registry entry; if no value is found, the default value def is returned const FXchar* readStringEntry(const FXchar* section,const FXchar* name,const FXchar* def=nullptr) const; const FXchar* readStringEntry(const FXString& section,const FXchar* name,const FXchar* def=nullptr) const; const FXchar* readStringEntry(const FXString& section,const FXString& name,const FXchar* def=nullptr) const; /// Write a string registry entry FXbool writeStringEntry(const FXchar* section,const FXchar* name,const FXchar* val); FXbool writeStringEntry(const FXString& section,const FXchar *name,const FXchar* val); FXbool writeStringEntry(const FXString& section,const FXString& name,const FXchar* val); /// Read a integer registry entry; if no value is found, the default value def is returned FXint readIntEntry(const FXchar* section,const FXchar* name,FXint def=0) const; FXint readIntEntry(const FXString& section,const FXchar* name,FXint def=0) const; FXint readIntEntry(const FXString& section,const FXString& name,FXint def=0) const; /// Write a integer registry entry FXbool writeIntEntry(const FXchar* section,const FXchar* name,FXint val); FXbool writeIntEntry(const FXString& section,const FXchar* name,FXint val); FXbool writeIntEntry(const FXString& section,const FXString& name,FXint val); /// Read a unsigned integer registry entry; if no value is found, the default value def is returned FXuint readUIntEntry(const FXchar* section,const FXchar* name,FXuint def=0) const; FXuint readUIntEntry(const FXString& section,const FXchar* name,FXuint def=0) const; FXuint readUIntEntry(const FXString& section,const FXString& name,FXuint def=0) const; /// Write a unsigned integer registry entry FXbool writeUIntEntry(const FXchar* section,const FXchar* name,FXuint val); FXbool writeUIntEntry(const FXString& section,const FXchar* name,FXuint val); FXbool writeUIntEntry(const FXString& section,const FXString& name,FXuint val); /// Read a 64-bit long integer registry entry; if no value is found, the default value def is returned FXlong readLongEntry(const FXchar* section,const FXchar* name,FXlong def=0) const; FXlong readLongEntry(const FXString& section,const FXchar* name,FXlong def=0) const; FXlong readLongEntry(const FXString& section,const FXString& name,FXlong def=0) const; /// Write a 64-bit long integer registry entry FXbool writeLongEntry(const FXchar* section,const FXchar* name,FXlong val); FXbool writeLongEntry(const FXString& section,const FXchar* name,FXlong val); FXbool writeLongEntry(const FXString& section,const FXString& name,FXlong val); /// Read a 64-bit unsigned long integer registry entry; if no value is found, the default value def is returned FXulong readULongEntry(const FXchar* section,const FXchar* name,FXulong def=0) const; FXulong readULongEntry(const FXString& section,const FXchar* name,FXulong def=0) const; FXulong readULongEntry(const FXString& section,const FXString& name,FXulong def=0) const; /// Write a 64-bit unsigned long integer registry entry FXbool writeULongEntry(const FXchar* section,const FXchar* name,FXulong val); FXbool writeULongEntry(const FXString& section,const FXchar* name,FXulong val); FXbool writeULongEntry(const FXString& section,const FXString& name,FXulong val); /// Read a double-precision floating point registry entry; if no value is found, the default value def is returned FXdouble readRealEntry(const FXchar* section,const FXchar* name,FXdouble def=0.0) const; FXdouble readRealEntry(const FXString& section,const FXchar* name,FXdouble def=0.0) const; FXdouble readRealEntry(const FXString& section,const FXString& name,FXdouble def=0.0) const; /// Write a double-precision floating point registry entry FXbool writeRealEntry(const FXchar* section,const FXchar* name,FXdouble val); FXbool writeRealEntry(const FXString& section,const FXchar* name,FXdouble val); FXbool writeRealEntry(const FXString& section,const FXString& name,FXdouble val); /// Read a color value registry entry; if no value is found, the default value def is returned FXColor readColorEntry(const FXchar* section,const FXchar* name,FXColor def=0) const; FXColor readColorEntry(const FXString& section,const FXchar* name,FXColor def=0) const; FXColor readColorEntry(const FXString& section,const FXString& name,FXColor def=0) const; /// Write a color value entry FXbool writeColorEntry(const FXchar* section,const FXchar* name,FXColor val); FXbool writeColorEntry(const FXString& section,const FXchar* name,FXColor val); FXbool writeColorEntry(const FXString& section,const FXString& name,FXColor val); /// Read a boolean registry entry FXbool readBoolEntry(const FXchar* section,const FXchar* name,FXbool def=false) const; FXbool readBoolEntry(const FXString& section,const FXchar* name,FXbool def=false) const; FXbool readBoolEntry(const FXString& section,const FXString& name,FXbool def=false) const; /// Write a boolean value entry FXbool writeBoolEntry(const FXchar* section,const FXchar* name,FXbool val); FXbool writeBoolEntry(const FXString& section,const FXchar* name,FXbool val); FXbool writeBoolEntry(const FXString& section,const FXString& name,FXbool val); /// See if entry exists FXbool existingEntry(const FXchar* section,const FXchar* name) const; FXbool existingEntry(const FXString& section,const FXchar* name) const; FXbool existingEntry(const FXString& section,const FXString& name) const; /// See if section exists FXbool existingSection(const FXchar* section) const; FXbool existingSection(const FXString& section) const; /// Delete a registry entry void deleteEntry(const FXchar* section,const FXchar* name); void deleteEntry(const FXString& section,const FXchar* name); void deleteEntry(const FXString& section,const FXString& name); /// Delete section void deleteSection(const FXchar* section); void deleteSection(const FXString& section); /// Clear all sections void clear(); /// Cleanup ~FXSettings(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXShell.h000066400000000000000000000054741455751074500221510ustar00rootroot00000000000000/******************************************************************************** * * * S h e l l W i n d o w W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSHELL_H #define FXSHELL_H #ifndef FXCOMPOSITE_H #include "FXComposite.h" #endif namespace FX { /** * The Shell widget is used as the base class for top level windows, i.e. * windows which are direct children of the root window. */ class FXAPI FXShell : public FXComposite { FXDECLARE(FXShell) protected: FXShell(){} FXShell(FXApp* a,FXuint opts,FXint x,FXint y,FXint w,FXint h); FXShell(FXWindow* own,FXuint opts,FXint x,FXint y,FXint w,FXint h); private: FXShell(const FXShell&); FXShell &operator=(const FXShell&); public: long onLayout(FXObject*,FXSelector,void*); long onConfigure(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onFocusNext(FXObject*,FXSelector,void*); long onFocusPrev(FXObject*,FXSelector,void*); public: enum { ID_LAYOUT=FXComposite::ID_LAST, ID_LAST }; public: /// Create server-side resources virtual void create(); /// Mark this window's layout as dirty virtual void recalc(); /// Move the focus to this window virtual void setFocus(); /// Remove the focus from this window virtual void killFocus(); /// Destroy shell virtual ~FXShell(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXShutter.h000066400000000000000000000150301455751074500225250ustar00rootroot00000000000000/******************************************************************************** * * * S h u t t e r C o n t a i n e r W i d g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Charles W. Warren. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSHUTTER_H #define FXSHUTTER_H #ifndef FXVERTICALFRAME_H #include "FXVerticalFrame.h" #endif namespace FX { class FXShutter; class FXButton; class FXScrollWindow; class FXShutterItem; /** * A Shutter Item is a panel which is embedded inside a Shutter Widget. * It can contain other user interface widgets which can be added under * the content widget. The content widget is itself embedded in a scroll * window to allow unlimited room for all the contents. */ class FXAPI FXShutterItem : public FXVerticalFrame { FXDECLARE(FXShutterItem) protected: FXButton *button; FXScrollWindow *scrollWindow; FXVerticalFrame *content; protected: FXShutterItem(); private: FXShutterItem(const FXShutterItem&); FXShutterItem &operator=(const FXShutterItem&); public: long onFocusUp(FXObject*,FXSelector,void*); long onFocusDown(FXObject*,FXSelector,void*); long onCmdButton(FXObject*,FXSelector,void*); public: enum{ ID_SHUTTERITEM_BUTTON=FXVerticalFrame::ID_LAST, ID_LAST }; public: /// Constructor FXShutterItem(FXShutter *p,const FXString& text=FXString::null,FXIcon* icon=nullptr,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_SPACING,FXint pr=DEFAULT_SPACING,FXint pt=DEFAULT_SPACING,FXint pb=DEFAULT_SPACING,FXint hs=DEFAULT_SPACING,FXint vs=DEFAULT_SPACING); /// Return a pointer to the scroll window FXScrollWindow* getScrollWindow() const { return scrollWindow; } /// Return a pointer to the button for this item FXButton* getButton() const { return button; } /// Return a pointer to the contents for this item FXVerticalFrame* getContent() const { return content; } /// Set the text for this shutter item void setText(const FXString& text); /// Get the text for this item FXString getText() const; /// Set the icon for this item void setIcon(FXIcon* ic); /// Get the icon for this item FXIcon* getIcon() const; /// Set the text font void setFont(FXFont *fnt); /// Get the text font FXFont* getFont() const; /// Set the current text-justification mode. void setJustify(FXuint mode); /// Get the current text-justification mode. FXuint getJustify() const; /// Set the current icon position void setIconPosition(FXuint mode); /// Get the current icon position FXuint getIconPosition() const; /// Set the status line help text for this item void setHelpText(const FXString& text); /// Get the status line help text for this item FXString getHelpText() const; /// Set the tool tip message for this item void setTipText(const FXString& text); /// Get the tool tip message for this item FXString getTipText() const; /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destructor virtual ~FXShutterItem(); }; /** * The Shutter widget provides a set of foldable sub panels. Each subpanel * consists of a Shutter Item which contains a button and some contents. * A sub panel can be unfolded by pressing on that panel's button. */ class FXAPI FXShutter : public FXVerticalFrame { FXDECLARE(FXShutter) protected: FXint current; // Item currently open FXint closing; // Item closing down FXint closingHeight; // Height of closing item FXint heightIncrement; // Height delta protected: FXShutter(); private: FXShutter(const FXShutter&); FXShutter &operator=(const FXShutter&); public: long onFocusUp(FXObject*,FXSelector,void*); long onFocusDown(FXObject*,FXSelector,void*); long onTimeout(FXObject*,FXSelector,void*); long onOpenItem(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdOpen(FXObject*,FXSelector,void*); long onUpdOpen(FXObject*,FXSelector,void*); public: enum{ ID_SHUTTER_TIMEOUT=FXVerticalFrame::ID_LAST, ID_OPEN_SHUTTERITEM, ID_OPEN_FIRST, ID_OPEN_SECOND, ID_OPEN_THIRD, ID_OPEN_FOURTH, ID_OPEN_FIFTH, ID_OPEN_SIXTH, ID_OPEN_SEVENTH, ID_OPEN_EIGHTH, ID_OPEN_NINETH, ID_OPEN_TENTH, ID_OPEN_LAST=ID_OPEN_FIRST+100, ID_LAST }; public: /// Constructor FXShutter(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_SPACING,FXint pr=DEFAULT_SPACING,FXint pt=DEFAULT_SPACING,FXint pb=DEFAULT_SPACING,FXint hs=DEFAULT_SPACING,FXint vs=DEFAULT_SPACING); /// Perform layout virtual void layout(); /// Set the currently displayed item (panel = 0, 1, 2, ..., npanels-1) virtual void setCurrent(FXint panel,FXbool notify=false); /// Return the index of the currently displayed item FXint getCurrent() const { return current; } /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destructor virtual ~FXShutter(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXSize.h000066400000000000000000000134621455751074500220100ustar00rootroot00000000000000/******************************************************************************** * * * S i z e C l a s s * * * ********************************************************************************* * Copyright (C) 1994,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSIZE_H #define FXSIZE_H namespace FX { /// Size class FXAPI FXSize { public: FXshort w; FXshort h; public: /// Constructors FXSize(){ } FXSize(const FXSize& s):w(s.w),h(s.h){ } FXSize(FXshort ww,FXshort hh):w(ww),h(hh){ } /// Return a non-const reference to the ith element FXshort& operator[](FXint i){return (&w)[i];} /// Return a const reference to the ith element const FXshort& operator[](FXint i) const {return (&w)[i];} /// Test if empty FXbool empty() const { return w<=0 || h<=0; } /// Grow by amount FXSize& grow(FXshort margin); FXSize& grow(FXshort hormargin,FXshort vermargin); FXSize& grow(FXshort leftmargin,FXshort rightmargin,FXshort topmargin,FXshort bottommargin); /// Shrink by amount FXSize& shrink(FXshort margin); FXSize& shrink(FXshort hormargin,FXshort vermargin); FXSize& shrink(FXshort leftmargin,FXshort rightmargin,FXshort topmargin,FXshort bottommargin); /// Assignment FXSize& operator=(const FXSize& s){ w=s.w; h=s.h; return *this; } /// Set value from another size FXSize& set(const FXSize& s){ w=s.w; h=s.h; return *this; } /// Set value from components FXSize& set(FXshort ww,FXshort hh){ w=ww; h=hh; return *this; } /// Assignment operators FXSize& operator*=(FXshort c){ w*=c; h*=c; return *this; } FXSize& operator/=(FXshort c){ w/=c; h/=c; return *this; } FXSize& operator+=(const FXSize& s){ w+=s.w; h+=s.h; return *this; } FXSize& operator-=(const FXSize& s){ w-=s.w; h-=s.h; return *this; } /// Test if zero FXbool operator!() const { return w==0 && h==0; } /// Unary FXSize operator+() const { return *this; } FXSize operator-(){ return FXSize(-w,-h); } }; /// Scale operators inline FXSize operator*(const FXSize& s,FXshort c){ return FXSize(s.w*c,s.h*c); } inline FXSize operator*(FXshort c,const FXSize& s){ return FXSize(c*s.w,c*s.h); } inline FXSize operator/(const FXSize& s,FXshort c){ return FXSize(s.w/c,s.h/c); } inline FXSize operator/(FXshort c,const FXSize& s){ return FXSize(c/s.w,c/s.h); } /// Addition operators inline FXSize operator+(const FXSize& a,const FXSize& b){ return FXSize(a.w+b.w,a.h+b.h); } inline FXSize operator-(const FXSize& a,const FXSize& b){ return FXSize(a.w-b.w,a.h-b.h); } /// Equality tests inline FXbool operator==(const FXSize& a,FXshort n){ return a.w==n && a.h==n; } inline FXbool operator!=(const FXSize& a,FXshort n){ return a.w!=n || a.h!=n; } inline FXbool operator==(FXshort n,const FXSize& a){ return n==a.w && n==a.h; } inline FXbool operator!=(FXshort n,const FXSize& a){ return n!=a.w || n!=a.h; } /// Equality tests inline FXbool operator==(const FXSize& a,const FXSize& b){ return a.w==b.w && a.h==b.h; } inline FXbool operator!=(const FXSize& a,const FXSize& b){ return a.w!=b.w || a.h!=b.h; } /// Inequality tests inline FXbool operator<(const FXSize& a,FXshort n){ return a.w(const FXSize& a,FXshort n){ return a.w>n && a.h>n; } inline FXbool operator>=(const FXSize& a,FXshort n){ return a.w>=n && a.h>=n; } /// Inequality tests inline FXbool operator<(FXshort n,const FXSize& a){ return n(FXshort n,const FXSize& a){ return n>a.w && n>a.h; } inline FXbool operator>=(FXshort n,const FXSize& a){ return n>=a.w && n>=a.h; } /// Inequality tests inline FXbool operator<(const FXSize& a,const FXSize& b){ return a.w(const FXSize& a,const FXSize& b){ return a.w>b.w && a.h>b.h; } inline FXbool operator>=(const FXSize& a,const FXSize& b){ return a.w>=b.w && a.h>=b.h; } /// Lowest or highest components inline FXSize lo(const FXSize& a,const FXSize& b){ return FXSize(Math::imin(a.w,b.w),Math::imin(a.h,b.h)); } inline FXSize hi(const FXSize& a,const FXSize& b){ return FXSize(Math::imax(a.w,b.w),Math::imax(a.h,b.h)); } /// Save object to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXSize& s); /// Load object from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXSize& s); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXSlider.h000066400000000000000000000203071455751074500223140ustar00rootroot00000000000000/******************************************************************************** * * * S l i d e r W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSLIDER_H #define FXSLIDER_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { /// Slider Control styles enum { SLIDER_HORIZONTAL = 0, /// Slider shown horizontally SLIDER_VERTICAL = 0x00008000, /// Slider shown vertically SLIDER_ARROW_UP = 0x00010000, /// Slider has arrow head pointing up SLIDER_ARROW_DOWN = 0x00020000, /// Slider has arrow head pointing down SLIDER_ARROW_LEFT = SLIDER_ARROW_UP, /// Slider has arrow head pointing left SLIDER_ARROW_RIGHT = SLIDER_ARROW_DOWN, /// Slider has arrow head pointing right SLIDER_INSIDE_BAR = 0x00040000, /// Slider is inside the slot rather than overhanging SLIDER_TICKS_TOP = 0x00080000, /// Ticks on the top of horizontal slider SLIDER_TICKS_BOTTOM = 0x00100000, /// Ticks on the bottom of horizontal slider SLIDER_TICKS_LEFT = SLIDER_TICKS_TOP, /// Ticks on the left of vertical slider SLIDER_TICKS_RIGHT = SLIDER_TICKS_BOTTOM, /// Ticks on the right of vertical slider SLIDER_NORMAL = SLIDER_HORIZONTAL }; /** * The slider widget is a valuator widget which provides simple linear value range. * Two visual appearances are supported:- the sunken look, which is enabled with * the SLIDER_INSIDE_BAR option and the regular look. The latter may have optional * arrows on the slider thumb. * While being moved, the slider sends a SEL_CHANGED message to its target; * at the end of the interaction, a SEL_COMMAND message is sent. * The message data represents the current slider value, of type FXint. */ class FXAPI FXSlider : public FXFrame { FXDECLARE(FXSlider) protected: FXint headPos; // Head position FXint headSize; // Head size FXint slotSize; // Slot size FXColor slotColor; // Color of slot the head moves in FXint dragPoint; // Where the head is grabbed FXint range[2]; // Reported data range FXint delta; // Interval between ticks FXint incr; // Increment when auto-sliding FXint pos; // Reported data position FXString help; // Help string FXString tip; // Tip string protected: FXSlider(); void drawSliderHead(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawHorzTicks(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawVertTicks(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); private: FXSlider(const FXSlider&); FXSlider &operator=(const FXSlider&); public: long onPaint(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onMouseWheel(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onMiddleBtnPress(FXObject*,FXSelector,void*); long onMiddleBtnRelease(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onAutoSlide(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdSetLongValue(FXObject*,FXSelector,void*); long onCmdGetLongValue(FXObject*,FXSelector,void*); long onCmdSetRealValue(FXObject*,FXSelector,void*); long onCmdGetRealValue(FXObject*,FXSelector,void*); long onCmdSetIntRange(FXObject*,FXSelector,void*); long onCmdGetIntRange(FXObject*,FXSelector,void*); long onCmdSetRealRange(FXObject*,FXSelector,void*); long onCmdGetRealRange(FXObject*,FXSelector,void*); long onCmdSetHelp(FXObject*,FXSelector,void*); long onCmdGetHelp(FXObject*,FXSelector,void*); long onCmdSetTip(FXObject*,FXSelector,void*); long onCmdGetTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); public: enum{ ID_AUTOSLIDE=FXFrame::ID_LAST, ID_LAST }; public: /// Construct a slider widget FXSlider(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=SLIDER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=0,FXint pr=0,FXint pt=0,FXint pb=0); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Returns true because a slider can receive focus virtual FXbool canFocus() const; /// Perform layout virtual void layout(); /// Enable the slider virtual void enable(); /// Disable the slider virtual void disable(); /// Change slider value void setValue(FXint value,FXbool notify=false); /// Return slider value FXint getValue() const { return pos; } /// Change the slider's range void setRange(FXint lo,FXint hi,FXbool notify=false); /// Get the slider's current range void getRange(FXint& lo,FXint& hi) const { lo=range[0]; hi=range[1]; } /// Change the slider style FXuint getSliderStyle() const; /// Get the current slider style void setSliderStyle(FXuint style); /// Get the slider's head size FXint getHeadSize() const { return headSize; } /// Change the slider's head size void setHeadSize(FXint hs); /// Get the slider's current slot size FXint getSlotSize() const { return slotSize; } /// Change the slider's slot size void setSlotSize(FXint bs); /// Get the slider's auto-increment/decrement value FXint getIncrement() const { return incr; } /// Change the slider's auto-increment/decrement value void setIncrement(FXint inc); /// Change the delta between ticks void setTickDelta(FXint dist); /// Get delta between ticks FXint getTickDelta() const { return delta; } /// Change the color of the slot the slider head moves in void setSlotColor(FXColor clr); /// Get the current slot color FXColor getSlotColor() const { return slotColor; } /// Set the help text to be displayed on the status line void setHelpText(const FXString& text){ help=text; } /// Get the current help text const FXString& getHelpText() const { return help; } /// Set the tip text to be displayed in the tooltip void setTipText(const FXString& text){ tip=text; } /// Get the current tooltip text value const FXString& getTipText() const { return tip; } /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destroy the slider virtual ~FXSlider(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXSocket.h000066400000000000000000000041171455751074500223230ustar00rootroot00000000000000/******************************************************************************** * * * S o c k e t C l a s s * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSOCKET_H #define FXSOCKET_H #ifndef FXIODEVICE_H #include "FXIODevice.h" #endif //////////////////////////// UNDER DEVELOPMENT //////////////////////////////// namespace FX { /** * Socket i/o device. */ class FXAPI FXSocket : public FXIODevice { private: FXSocket(const FXSocket&); FXSocket &operator=(const FXSocket&); public: /// Construct socket FXSocket(){ } /// Construct file and attach existing handle h FXSocket(FXInputHandle h); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXSphered.h000066400000000000000000000126561455751074500224740ustar00rootroot00000000000000/******************************************************************************** * * * D o u b l e - P r e c i s i o n S p h e r e C l a s s * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSPHERED_H #define FXSPHERED_H namespace FX { class FXRanged; class FXMat4d; /// Spherical bounds class FXAPI FXSphered { public: FXVec3d center; FXdouble radius; public: /// Default constructor; value is not initialized FXSphered(){} /// Copy constructor FXSphered(const FXSphered& sphere):center(sphere.center),radius(sphere.radius){} /// Initialize from center and radius FXSphered(const FXVec3d& cen,FXdouble rad=0.0):center(cen),radius(rad){} /// Initialize from center and radius FXSphered(FXdouble x,FXdouble y,FXdouble z,FXdouble rad=0.0):center(x,y,z),radius(rad){} /// Initialize sphere to fully contain the given bounding box FXSphered(const FXRanged& bounds); /// Assignment FXSphered& operator=(const FXSphered& sphere){ center=sphere.center; radius=sphere.radius; return *this; } /// Set value from another sphere FXSphered& set(const FXSphered& sphere){ center=sphere.center; radius=sphere.radius; return *this; } /// Set value from center and radius FXSphered& set(const FXVec3d& cen,FXdouble rad=0.0){ center=cen; radius=rad; return *this; } /// Set value from center and radius FXSphered& set(FXdouble x,FXdouble y,FXdouble z,FXdouble rad=0.0){ center.set(x,y,z); radius=rad; return *this; } /// Comparison FXbool operator==(const FXSphered& s) const { return center==s.center && radius==s.radius;} FXbool operator!=(const FXSphered& s) const { return center!=s.center || radius!=s.radius;} /// Diameter of sphere FXdouble diameter() const { return radius*2.0; } /// Area of sphere FXdouble area() const { return radius*radius*12.5663706143591729538505735331; } /// Volume of sphere FXdouble volume() const { return radius*radius*radius*4.18879020478639098461685784437; } /// Test if empty FXbool empty() const { return radius<0.0; } /// Test if sphere contains point x,y,z FXbool contains(FXdouble x,FXdouble y,FXdouble z) const; /// Test if sphere contains point p FXbool contains(const FXVec3d& p) const; /// Test if sphere contains another box FXbool contains(const FXRanged& box) const; /// Test if sphere contains another sphere FXbool contains(const FXSphered& sphere) const; /// Include point FXSphered& include(FXdouble x,FXdouble y,FXdouble z); /// Include point FXSphered& include(const FXVec3d& p); /// Expand radius to include point FXSphered& includeInRadius(FXdouble x,FXdouble y,FXdouble z); /// Expand radius to include point FXSphered& includeInRadius(const FXVec3d& p); /// Include given range into this one FXSphered& include(const FXRanged& box); /// Expand radius to include box FXSphered& includeInRadius(const FXRanged& box); /// Include given sphere into this one FXSphered& include(const FXSphered& sphere); /// Expand radius to include sphere FXSphered& includeInRadius(const FXSphered& sphere); /// Intersect sphere with normalized plane ax+by+cz+w; returns -1,0,+1 FXint intersect(const FXVec4d& plane) const; /// Intersect sphere with ray u-v FXbool intersect(const FXVec3d& u,const FXVec3d& v) const; /// Intersect box with ray pos+lambda*dir, returning true if hit FXbool intersect(const FXVec3d& pos,const FXVec3d& dir,FXdouble hit[]) const; /// Transform sphere by 4x4 matrix FXSphered transform(const FXMat4d& mat) const; /// Destructor ~FXSphered(){} }; /// Test if box overlaps with sphere extern FXAPI FXbool overlap(const FXRanged& a,const FXSphered& b); /// Test if sphere overlaps with box extern FXAPI FXbool overlap(const FXSphered& a,const FXRanged& b); /// Test if spheres overlap extern FXAPI FXbool overlap(const FXSphered& a,const FXSphered& b); /// Save object to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXSphered& sphere); /// Load object from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXSphered& sphere); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXSpheref.h000066400000000000000000000126571455751074500224770ustar00rootroot00000000000000/******************************************************************************** * * * S i n g l e - P r e c i s i o n S p h e r e C l a s s * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSPHEREF_H #define FXSPHEREF_H namespace FX { class FXRangef; class FXMat4f; /// Spherical bounds class FXAPI FXSpheref { public: FXVec3f center; FXfloat radius; public: /// Default constructor; value is not initialized FXSpheref(){} /// Copy constructor FXSpheref(const FXSpheref& sphere):center(sphere.center),radius(sphere.radius){} /// Initialize from center and radius FXSpheref(const FXVec3f& cen,FXfloat rad=0.0f):center(cen),radius(rad){} /// Initialize from center and radius FXSpheref(FXfloat x,FXfloat y,FXfloat z,FXfloat rad=0.0f):center(x,y,z),radius(rad){} /// Initialize sphere to fully contain the given bounding box FXSpheref(const FXRangef& bounds); /// Assignment FXSpheref& operator=(const FXSpheref& sphere){ center=sphere.center; radius=sphere.radius; return *this; } /// Set value from another sphere FXSpheref& set(const FXSpheref& sphere){ center=sphere.center; radius=sphere.radius; return *this; } /// Set value from center and radius FXSpheref& set(const FXVec3f& cen,FXfloat rad=0.0f){ center=cen; radius=rad; return *this; } /// Set value from center and radius FXSpheref& set(FXfloat x,FXfloat y,FXfloat z,FXfloat rad=0.0f){ center.set(x,y,z); radius=rad; return *this; } /// Comparison FXbool operator==(const FXSpheref& s) const { return center==s.center && radius==s.radius;} FXbool operator!=(const FXSpheref& s) const { return center!=s.center || radius!=s.radius;} /// Diameter of sphere FXfloat diameter() const { return radius*2.0f; } /// Area of sphere FXfloat area() const { return radius*radius*12.5663706143591729538505735331f; } /// Volume of sphere FXfloat volume() const { return radius*radius*radius*4.18879020478639098461685784437f; } /// Test if empty FXbool empty() const { return radius<0.0f; } /// Test if sphere contains point x,y,z FXbool contains(FXfloat x,FXfloat y,FXfloat z) const; /// Test if sphere contains point p FXbool contains(const FXVec3f& p) const; /// Test if sphere properly contains another box FXbool contains(const FXRangef& box) const; /// Test if sphere properly contains another sphere FXbool contains(const FXSpheref& sphere) const; /// Include point FXSpheref& include(FXfloat x,FXfloat y,FXfloat z); /// Include point FXSpheref& include(const FXVec3f& p); /// Expand radius to include point FXSpheref& includeInRadius(FXfloat x,FXfloat y,FXfloat z); /// Expand radius to include point FXSpheref& includeInRadius(const FXVec3f& p); /// Include given range into this one FXSpheref& include(const FXRangef& box); /// Expand radius to include box FXSpheref& includeInRadius(const FXRangef& box); /// Include given sphere into this one FXSpheref& include(const FXSpheref& sphere); /// Expand radius to include sphere FXSpheref& includeInRadius(const FXSpheref& sphere); /// Intersect sphere with normalized plane ax+by+cz+w; returns -1,0,+1 FXint intersect(const FXVec4f& plane) const; /// Intersect sphere with ray u-v FXbool intersect(const FXVec3f& u,const FXVec3f& v) const; /// Intersect box with ray pos+lambda*dir, returning true if hit FXbool intersect(const FXVec3f& pos,const FXVec3f& dir,FXfloat hit[]) const; /// Transform sphere by 4x4 matrix FXSpheref transform(const FXMat4f& mat) const; /// Destructor ~FXSpheref(){} }; /// Test if box overlaps with sphere extern FXAPI FXbool overlap(const FXRangef& a,const FXSpheref& b); /// Test if sphere overlaps with box extern FXAPI FXbool overlap(const FXSpheref& a,const FXRangef& b); /// Test if spheres overlap extern FXAPI FXbool overlap(const FXSpheref& a,const FXSpheref& b); /// Save object to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXSpheref& sphere); /// Load object from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXSpheref& sphere); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXSpinLock.h000066400000000000000000000113011455751074500226060ustar00rootroot00000000000000/******************************************************************************** * * * S p i n l o c k C l a s s * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSPINLOCK_H #define FXSPINLOCK_H namespace FX { /** * FXSpinLock can be used to provide safe access to very small critical sections. * * Similar to FXMutex, a FXSpinLock provides safe access to a critical section * shared by multiple threads. Unlike FXMutex, however, a thread which is unable * to obtain the lock will not block, but spin in a tight loop until the lock can * be obtained. The advantage of FXSpinLock over FXMutex is that no operating * system calls are performed suspending and resuming the calling thread. */ class FXAPI FXSpinLock { private: volatile FXuval data[4]; private: FXSpinLock(const FXSpinLock&); FXSpinLock &operator=(const FXSpinLock&); public: /// Initialize the spinlock FXSpinLock(); /// Lock the spinlock void lock(); /// Return true if succeeded locking the spinlock FXbool trylock(); /// Return true if spinlock is already locked FXbool locked(); /// Unlock spinlock void unlock(); /// Delete the spinlock ~FXSpinLock(); }; /** * Establish a correspondence between a C++ scope and an FXSpinLock, * so that entering and leaving the scope in which the scoped lock * is defined will automatically lock and unlock the associated * spin lock. * This will typically result in much less coding, and in addition * will make the code safe from exceptions. */ class FXAPI FXScopedSpinLock { private: FXSpinLock& spn; private: FXScopedSpinLock(); FXScopedSpinLock(const FXScopedSpinLock&); FXScopedSpinLock& operator=(const FXScopedSpinLock&); public: /// Construct & lock associated spinlock FXScopedSpinLock(FXSpinLock& s):spn(s){ lock(); } /// Return reference to associated spinlock FXSpinLock& spinlock(){ return spn; } /// Lock spinlock void lock(){ spn.lock(); } /// Return true if succeeded locking the spinlock FXbool trylock(){ return spn.trylock(); } /// Return true if spinlock is already locked FXbool locked(){ return spn.locked(); } /// Unlock spin lock void unlock(){ spn.unlock(); } /// Destroy and unlock associated spinlock ~FXScopedSpinLock(){ unlock(); } }; /** * The reverse spin lock unlocks its associated FXSpinLock when entering * the scope, and automatically relocks it upon exiting the scope. * Exceptions raised while in this region will automatically relock * the spin lock upon leaving the enclosing scope. */ class FXAPI FXReverseSpinLock { private: FXSpinLock& spn; private: FXReverseSpinLock(); FXReverseSpinLock(const FXReverseSpinLock&); FXReverseSpinLock& operator=(const FXReverseSpinLock&); public: /// Construct and unlock associated spin lock FXReverseSpinLock(FXSpinLock& s):spn(s){ unlock(); } /// Return reference to associated spin lock FXSpinLock& spinlock(){ return spn; } /// Lock spin lock void lock(){ spn.lock(); } /// Return true if succeeded locking the spin lock FXbool trylock(){ return spn.trylock(); } /// Return true if spin lock is already locked FXbool locked(){ return spn.locked(); } /// Unlock spin lock void unlock(){ spn.unlock(); } /// Destroy and relock associated spin lock ~FXReverseSpinLock(){ lock(); } }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXSpinner.h000066400000000000000000000163631455751074500225170ustar00rootroot00000000000000/******************************************************************************** * * * S p i n n e r W i d g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Lyle Johnson. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSPINNER_H #define FXSPINNER_H #ifndef FXPACKER_H #include "FXPacker.h" #endif namespace FX { /// Spinner Options enum { SPIN_NORMAL = 0, /// Normal, non-cyclic SPIN_CYCLIC = 0x00020000, /// Cyclic spinner SPIN_NOTEXT = 0x00040000, /// No text visible SPIN_NOMAX = 0x00080000, /// Spin all the way up to infinity SPIN_NOMIN = 0x00100000 /// Spin all the way down to -infinity }; class FXTextField; class FXArrowButton; /// Spinner control class FXAPI FXSpinner : public FXPacker { FXDECLARE(FXSpinner) protected: FXTextField *textField; // Text field FXArrowButton *upButton; // The up button FXArrowButton *downButton; // The down button FXint range[2]; // Reported data range FXint incr; // Increment FXint pos; // Current position protected: FXSpinner(); private: FXSpinner(const FXSpinner&); FXSpinner& operator=(const FXSpinner&); public: long onUpdIncrement(FXObject*,FXSelector,void*); long onCmdIncrement(FXObject*,FXSelector,void*); long onUpdDecrement(FXObject*,FXSelector,void*); long onCmdDecrement(FXObject*,FXSelector,void*); long onChgEntry(FXObject*,FXSelector,void*); long onCmdEntry(FXObject*,FXSelector,void*); long onWheelEntry(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdSetLongValue(FXObject*,FXSelector,void*); long onCmdGetLongValue(FXObject*,FXSelector,void*); long onCmdSetIntRange(FXObject*,FXSelector,void*); long onCmdGetIntRange(FXObject*,FXSelector,void*); long onFocusSelf(FXObject*,FXSelector,void*); public: enum{ ID_INCREMENT=FXPacker::ID_LAST, ID_DECREMENT, ID_ENTRY, ID_LAST }; public: /// Construct a spinner FXSpinner(FXComposite *p,FXint cols,FXObject *tgt=nullptr,FXSelector sel=0,FXuint opts=SPIN_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Perform layout virtual void layout(); /// Disable spinner virtual void disable(); /// Enable spinner virtual void enable(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Move the focus to this window virtual void setFocus(); /// Remove the focus from this window virtual void killFocus(); /// Increment spinner void increment(FXbool notify=false); /// Increment spinner by certain amount void incrementByAmount(FXint amount,FXbool notify=false); /// Decrement spinner void decrement(FXbool notify=false); /// Decrement spinner by certain amount void decrementByAmount(FXint amount,FXbool notify=false); /// Return true if in cyclic mode FXbool isCyclic() const; /// Set to cyclic mode, i.e. wrap around at maximum/minimum void setCyclic(FXbool cyclic); /// Return true if text is visible FXbool isTextVisible() const; /// Set text visible flag void setTextVisible(FXbool flag); /// Change current value virtual void setValue(FXint value,FXbool notify=false); /// Return current value FXint getValue() const { return pos; } /// Change the spinner's range void setRange(FXint lo,FXint hi,FXbool notify=false); /// Get the spinner's current range void getRange(FXint& lo,FXint& hi) const { lo=range[0]; hi=range[1]; } /// Change spinner increment void setIncrement(FXint increment); /// Return spinner increment FXint getIncrement() const { return incr; } /// Set the text font void setFont(FXFont *fnt); /// Get the text font FXFont *getFont() const; /// Set the status line help text for this spinner void setHelpText(const FXString& text); /// Get the status line help text for this spinner const FXString& getHelpText() const; /// Set the tool tip message for this spinner void setTipText(const FXString& text); /// Get the tool tip message for this spinner const FXString& getTipText() const; /// Change spinner style void setSpinnerStyle(FXuint style); /// Return current spinner style FXuint getSpinnerStyle() const; /// Allow editing of the text field void setEditable(FXbool edit=true); /// Return true if text field is editable FXbool isEditable() const; /// Change color of the up arrow void setUpArrowColor(FXColor clr); /// Return color of the up arrow FXColor getUpArrowColor() const; /// Change color of the down arrow void setDownArrowColor(FXColor clr); /// Return color of the the down arrow FXColor getDownArrowColor() const; /// Change text color void setTextColor(FXColor clr); /// Return text color FXColor getTextColor() const; /// Change selected background color void setSelBackColor(FXColor clr); /// Return selected background color FXColor getSelBackColor() const; /// Change selected text color void setSelTextColor(FXColor clr); /// Return selected text color FXColor getSelTextColor() const; /// Changes the cursor color void setCursorColor(FXColor clr); /// Return the cursor color FXColor getCursorColor() const; /// Change width of text field in terms of number of columns * `m' void setNumColumns(FXint cols); /// Return number of columns FXint getNumColumns() const; /// Save spinner to a stream virtual void save(FXStream& store) const; /// Load spinner from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXSpinner(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXSplashWindow.h000066400000000000000000000106031455751074500235120ustar00rootroot00000000000000/******************************************************************************** * * * S p l a s h W i n d o w * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSPLASHWINDOW_H #define FXSPLASHWINDOW_H #ifndef FXTOPWINDOW_H #include "FXTopWindow.h" #endif namespace FX { /// Splash Window options enum { SPLASH_SIMPLE = 0, /// Simple rectangular splash window SPLASH_SHAPED = 0x02000000, /// Shaped splash window SPLASH_OWNS_ICON = 0x04000000, /// Splash window will own the icon and destroy it SPLASH_DESTROY = 0x08000000 /// Splash window will destroy itself when timer expires }; /** * The Splash Window is a window typically shown during startup * of an application. It comprises a large icon, which is also * used as the shape of the window if SPLASH_SHAPED is passed; * with the SPLASH_SIMPLE option the window will be simply rectangular. */ class FXAPI FXSplashWindow : public FXTopWindow { FXDECLARE(FXSplashWindow) protected: FXIcon *icon; // Really big icon FXTime delay; // Delay before hiding protected: FXSplashWindow(); private: FXSplashWindow(const FXSplashWindow&); FXSplashWindow &operator=(const FXSplashWindow&); public: long onPaint(FXObject*,FXSelector,void*); public: /** * Construct splash window; the window will be automatically hidden (or deleted * if SPLASH_DESTROY is passed) after a given delay, specified in nanoseconds). * The splash window is free floating. Use this constructor when the splash window * is to be displayed before the main window appears. */ FXSplashWindow(FXApp* ap,FXIcon* ic,FXuint opts=SPLASH_SIMPLE,FXTime ns=2000000000); /** * Construct splash window; the window will be automatically hidden (or deleted * if SPLASH_DESTROY is passed) after a given delay, specified in nanoseconds). * The splash window stays on top of its owner window, which must already have been * created previously. */ FXSplashWindow(FXWindow* ow,FXIcon* ic,FXuint opts=SPLASH_SIMPLE,FXTime ns=2000000000); /// Create virtual void create(); /// Detach virtual void detach(); /// Show splash window virtual void show(); /// Show splash window with a given placement virtual void show(FXuint placement); /// Hide splash window virtual void hide(); /// Return the default width of this window virtual FXint getDefaultWidth(); /// Return the default height of this window virtual FXint getDefaultHeight(); /// Set the icon for the splash window void setIcon(FXIcon* ic); /// Get the icon for this splash window FXIcon* getIcon() const { return icon; } /// Set or change delay in nanoseconds void setDelay(FXTime ns); /// Return delay FXTime getDelay() const { return delay; } /// Save label to a stream virtual void save(FXStream& store) const; /// Load label from a stream virtual void load(FXStream& store); /// Destroy splash window virtual ~FXSplashWindow(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXSplitter.h000066400000000000000000000125251455751074500227030ustar00rootroot00000000000000/******************************************************************************** * * * S p l i t t e r W i n d o w W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSPLITTER_H #define FXSPLITTER_H #ifndef FXCOMPOSITE_H #include "FXComposite.h" #endif namespace FX { /// Splitter options enum { SPLITTER_HORIZONTAL = 0, /// Split horizontally SPLITTER_VERTICAL = 0x00008000, /// Split vertically SPLITTER_REVERSED = 0x00010000, /// Reverse-anchored SPLITTER_TRACKING = 0x00020000, /// Track continuous during split SPLITTER_NORMAL = SPLITTER_HORIZONTAL }; /** * Splitter window is used to interactively repartition * two or more subpanels. * Space may be subdivided horizontally (SPLITTER_HORIZONTAL, which * the default) or vertically (SPLITTER_VERTICAL option). * When the splitter is itself resized, the right-most (bottom-most) * child window will be resized unless the splitter window is reversed; * if the splitter is reversed, the left-most (top-most) child window * will be resized instead. * The splitter widget sends a SEL_CHANGED to its target * during the resizing of the panels; at the end of the resize interaction, * it sends a SEL_COMMAND to signify that the resize operation is complete. * Normally, children are resizable from 0 upwards; however, if the child * in a horizontally oriented splitter has LAYOUT_FILL_X in combination with * LAYOUT_FIX_WIDTH, it will not be made smaller than its default width, * except when the child is the last visible widget (or first when the option * SPLITTER_REVERSED has been passed to the splitter). * In a vertically oriented splitter, children with LAYOUT_FILL_Y and * LAYOUT_FIX_HEIGHT behave analogously. */ class FXAPI FXSplitter : public FXComposite { FXDECLARE(FXSplitter) private: FXWindow *window; // Window being resized FXint split; // Split value FXint offset; // Mouse offset FXint barsize; // Size of the splitter bar protected: FXSplitter(); void adjustHLayout(); void adjustVLayout(); void moveHSplit(FXint amount); void moveVSplit(FXint amount); void drawHSplit(FXint pos); void drawVSplit(FXint pos); FXWindow* findHSplit(FXint pos); FXWindow* findVSplit(FXint pos); private: FXSplitter(const FXSplitter&); FXSplitter& operator=(const FXSplitter&); public: long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onFocusNext(FXObject*,FXSelector,void*); long onFocusPrev(FXObject*,FXSelector,void*); long onFocusUp(FXObject*,FXSelector,void*); long onFocusDown(FXObject*,FXSelector,void*); long onFocusLeft(FXObject*,FXSelector,void*); long onFocusRight(FXObject*,FXSelector,void*); public: /// Construct new splitter widget FXSplitter(FXComposite* p,FXuint opts=SPLITTER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Construct new splitter widget, which will notify target about size changes FXSplitter(FXComposite* p,FXObject* tgt,FXSelector sel,FXuint opts=SPLITTER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Get default width virtual FXint getDefaultWidth(); /// Get default height virtual FXint getDefaultHeight(); /// Perform layout virtual void layout(); /// Return size of the panel at index FXint getSplit(FXint index) const; /// Change the size of panel at the given index void setSplit(FXint index,FXint size); /// Change splitter style void setSplitterStyle(FXuint style); /// Return current splitter style FXuint getSplitterStyle() const; /// Change splitter bar size void setBarSize(FXint bs); /// Return current bar size FXint getBarSize() const { return barsize; } /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destroy splitter virtual ~FXSplitter(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXSpring.h000066400000000000000000000100601455751074500223270ustar00rootroot00000000000000/******************************************************************************** * * * S p r i n g C o n t a i n e r W i d g e t * * * ********************************************************************************* * Copyright (C) 2003,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSPRING_H #define FXSPRING_H #ifndef FXPACKER_H #include "FXPacker.h" #endif namespace FX { /** * The spring widgets, when properly embedded side by side in a horizontal * frame or vertical frame widget, behave like a set of connected springs * of various lengths (hence the name!). The parameters relw (or relh) * determines the length of the spring. The actual length is not really * important; the only thing that counts is the relative length of one * spring widget to that of another, although the length does determine * the default size. The special value zero may be given for relw (or relh) * to cause the spring to calculate its default width (height) normally, * just like the Packer base class does. * In a typical scenario, either the relative width or height is set to * zero, and the flag LAYOUT_FILL_X or LAYOUT_FILL_Y is passed. When * placed inside a horizontal frame, the LAYOUT_FILL_X together with * the relative widths of the springs will cause a fixed width-ratio * between the springs. * You also can mix normal controls and springs together in a horizontal * or vertical frames to provide arbitrary stretchable spacing between * widgets; in this case, the springs do not need to have any children. * Since the spring widget is derived from the packer layout manager, * it provides the same layout behavior as packer. */ class FXAPI FXSpring : public FXPacker { FXDECLARE(FXSpring) protected: FXint relWidth; // Relative width FXint relHeight; // Relative height protected: FXSpring(){} private: FXSpring(const FXSpring&); FXSpring &operator=(const FXSpring&); public: /// Construct packer layout manager FXSpring(FXComposite *p,FXuint opts=0,FXint relw=0,FXint relh=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_SPACING,FXint pr=DEFAULT_SPACING,FXint pt=DEFAULT_SPACING,FXint pb=DEFAULT_SPACING,FXint hs=DEFAULT_SPACING,FXint vs=DEFAULT_SPACING); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Change relative width void setRelativeWidth(FXint relw); /// Return relative width FXint getRelativeWidth() const { return relWidth; } /// Change relative height void setRelativeHeight(FXint relh); /// Return relative height FXint getRelativeHeight() const { return relHeight; } /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXStat.h000066400000000000000000000245651455751074500220170ustar00rootroot00000000000000/******************************************************************************** * * * F i l e S t a t i s t i c s * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSTAT_H #define FXSTAT_H namespace FX { class FXFile; /// Statistics about a file or directory class FXAPI FXStat { private: FXuint modeFlags; /// Mode bits FXuint userNumber; /// User number FXuint groupNumber; /// Group number FXuint linkCount; /// Number of links FXTime createTime; /// Create time (ns) FXTime accessTime; /// Access time (ns) FXTime modifyTime; /// Modify time (ns) FXlong fileVolume; /// File volume (device) FXlong fileIndex; /// File index (inode) FXlong fileSize; /// File size public: /// Initialize FXStat():modeFlags(0),userNumber(0),groupNumber(0),linkCount(0),createTime(0),accessTime(0),modifyTime(0),fileVolume(0),fileIndex(0),fileSize(0){ } /// Return the mode flags for this file FXuint mode() const { return modeFlags; } /// Return user number FXuint user() const { return userNumber; } /// Return group number FXuint group() const { return groupNumber; } /// Return number of links to file FXuint links() const { return linkCount; } /// Return time when file was created, in nanoseconds FXTime created() const { return createTime; } /// Return time when last accessed, in nanoseconds FXTime accessed() const { return accessTime; } /// Return time when last modified, in nanoseconds FXTime modified() const { return modifyTime; } /// Return file volume number FXlong volume() const { return fileVolume; } /// Return file index number FXlong index() const { return fileIndex; } /// Return file size in bytes FXlong size() const { return fileSize; } /// Return true if it is a hidden file (Windows-only) FXbool isHidden() const; /// Return true if input path is a directory FXbool isDirectory() const; /// Return true if it is a regular file FXbool isFile() const; /// Return true if it is a link FXbool isLink() const; /// Return true if the file sets the user id on execution FXbool isSetUid() const; /// Return true if the file sets the group id on execution FXbool isSetGid() const; /// Return true if the file has the sticky bit set FXbool isSetSticky() const; /// Return true if special device (character or block device) FXbool isDevice() const; /// Return true if character device FXbool isCharacter() const; /// Return true if block device FXbool isBlock() const; /// Return true if socket device FXbool isSocket() const; /// Return true if fifo (pipe) device FXbool isFifo() const; /// Return true if file is readable FXbool isReadable() const; /// Return true if file is writable FXbool isWritable() const; /// Return true if file is executable FXbool isExecutable() const; /// Return true if owner has read-write-execute permissions FXbool isOwnerReadWriteExecute() const; /// Return true if owner has read permissions FXbool isOwnerReadable() const; /// Return true if owner has write permissions FXbool isOwnerWritable() const; /// Return true if owner has execute permissions FXbool isOwnerExecutable() const; /// Return true if group has read-write-execute permissions FXbool isGroupReadWriteExecute() const; /// Return true if group has read permissions FXbool isGroupReadable() const; /// Return true if group has write permissions FXbool isGroupWritable() const; /// Return true if group has execute permissions FXbool isGroupExecutable() const; /// Return true if others have read-write-execute permissions FXbool isOtherReadWriteExecute() const; /// Return true if others have read permissions FXbool isOtherReadable() const; /// Return true if others have write permissions FXbool isOtherWritable() const; /// Return true if others have execute permissions FXbool isOtherExecutable() const; /// Get statistics of the file into the stat buffer info static FXbool statFile(const FXString& file,FXStat& info); /// Get statistice of the link into the stat buffer info static FXbool statLink(const FXString& file,FXStat& info); /// Get statistics of already open file into stat buffer info static FXbool stat(const FXFile& file,FXStat& info); /// Return the mode flags for this file static FXuint mode(const FXString& file); /// Change the mode flags for this file static FXbool mode(const FXString& file,FXuint perm); /// Return true if file exists static FXbool exists(const FXString& file); /// Return file size in bytes static FXlong size(const FXString& file); /// Return file volume number static FXlong volume(const FXString& file); /// Return file index number static FXlong index(const FXString& file); /// Return number of links to file static FXuint links(const FXString& file); /** * Return last modified time for this file, on filesystems * where this is supported. This is the time when any data * in the file was last modified, in nanoseconds since Epoch. */ static FXTime modified(const FXString& file); /** * Change modified time for the given file, on filesystems * where this is supported. Time is specified in nanoseconds * since Epoch. */ static FXbool modified(const FXString& file,FXTime ns); /** * Return last accessed time for this file, on filesystems * where this is supported, in nanoseconds since Epoch. */ static FXTime accessed(const FXString& file); /** * Change accessed time for the given file, on filesystems * where this is supported. Time is specified in nanoseconds * since Epoch. */ static FXbool accessed(const FXString& file,FXTime ns); /** * Return created time for this file, on filesystems * where this is supported. This is also the time when * ownership, permissions, links, and other meta-data may * have changed, in nanoseconds since Epoch. */ static FXTime created(const FXString& file); /** * Change created time for the given file, on filesystems * where this is supported. Time is specified in nanoseconds * since Epoch. */ static FXbool created(const FXString& file,FXTime ns); /// Return true if file is hidden static FXbool isHidden(const FXString& file); /// Return true if input path is a file name static FXbool isFile(const FXString& file); /// Return true if input path is a link static FXbool isLink(const FXString& file); /// Return true if input path is a directory static FXbool isDirectory(const FXString& file); /// Return true if file is readable static FXbool isReadable(const FXString& file); /// Return true if file is writable static FXbool isWritable(const FXString& file); /// Return true if file is executable static FXbool isExecutable(const FXString& file); /// Return true if owner has read-write-execute permissions static FXbool isOwnerReadWriteExecute(const FXString& file); /// Return true if owner has read permissions static FXbool isOwnerReadable(const FXString& file); /// Return true if owner has write permissions static FXbool isOwnerWritable(const FXString& file); /// Return true if owner has execute permissions static FXbool isOwnerExecutable(const FXString& file); /// Return true if group has read-write-execute permissions static FXbool isGroupReadWriteExecute(const FXString& file); /// Return true if group has read permissions static FXbool isGroupReadable(const FXString& file); /// Return true if group has write permissions static FXbool isGroupWritable(const FXString& file); /// Return true if group has execute permissions static FXbool isGroupExecutable(const FXString& file); /// Return true if others have read-write-execute permissions static FXbool isOtherReadWriteExecute(const FXString& file); /// Return true if others have read permissions static FXbool isOtherReadable(const FXString& file); /// Return true if others have write permissions static FXbool isOtherWritable(const FXString& file); /// Return true if others have execute permissions static FXbool isOtherExecutable(const FXString& file); /// Return true if the file sets the user id on execution static FXbool isSetUid(const FXString& file); /// Return true if the file sets the group id on execution static FXbool isSetGid(const FXString& file); /// Return true if the file has the sticky bit set static FXbool isSetSticky(const FXString& file); /// Return true if file is accessible for access mode m /// (FXIO::ReadOnly, FXIO::WriteOnly, FXIO::ReadWrite, FXIO::Executable, etc.) static FXbool isAccessible(const FXString& file,FXuint m=FXIO::ReadWrite); /// Obtain total amount of space on disk mounted at given path static FXbool getTotalDiskSpace(const FXString& path,FXulong& space); /// Obtain available amount of space on disk mounted at given path static FXbool getAvailableDiskSpace(const FXString& path,FXulong& space); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXStatusBar.h000066400000000000000000000061151455751074500230030ustar00rootroot00000000000000/******************************************************************************** * * * S t a t u s B a r W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSTATUSBAR_H #define FXSTATUSBAR_H #ifndef FXHORIZONTALFRAME_H #include "FXHorizontalFrame.h" #endif namespace FX { /// StatusBar options enum { STATUSBAR_WITH_DRAGCORNER = 0x00020000 /// Causes the DragCorner to be shown }; class FXDragCorner; class FXStatusLine; /// Status bar class FXAPI FXStatusBar : public FXHorizontalFrame { FXDECLARE(FXStatusBar) protected: FXDragCorner *corner; FXStatusLine *status; protected: FXStatusBar(){} private: FXStatusBar(const FXStatusBar&); FXStatusBar& operator=(const FXStatusBar&); public: /// Construct status bar with or without a drag corner FXStatusBar(FXComposite* p,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=3,FXint pr=3,FXint pt=2,FXint pb=2,FXint hs=4,FXint vs=0); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Perform layout virtual void layout(); /// Show or hide the drag corner void setCornerStyle(FXbool withcorner=true); /// Return true if drag corner shown FXbool getCornerStyle() const; /// Acess the status line widget FXStatusLine *getStatusLine() const { return status; } /// Access the drag corner widget FXDragCorner *getDragCorner() const { return corner; } /// Save status bar to a stream virtual void save(FXStream& store) const; /// Load status bar from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXStatusBar(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXStatusLine.h000066400000000000000000000114651455751074500231720ustar00rootroot00000000000000/******************************************************************************** * * * S t a t u s L i n e W i d g e t * * * ********************************************************************************* * Copyright (C) 1999,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSTATUSLINE_H #define FXSTATUSLINE_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { /** * The status line normally shows its permanent message. * A semi-permanent message can override this permanent message, for example to * indicate the application is busy or in a particular operating mode. * The status line obtains the semi-permanent message by sending its target (if any) * SEL_UPDATE message. * A ID_SETSTRINGVALUE can be used to change the status message. * When the user moves the cursor over a widget which has status-line help, the * status line can flash a very temporarily message with help about the widget. * For example, the status line may flash the "Quit Application" message when * the user moves the cursor over the Quit button. * The status line obtains the help message from the control by sending it a * ID_QUERY_HELP message with type SEL_UPDATE. * Unless the value is overridden, the status line will display the normal text, * i.e. the string set via setNormalText(). * If the message contains a newline (\n), then the part before the newline * will be displayed in the highlight color, while the part after the newline * is shown using the normal text color. */ class FXAPI FXStatusLine : public FXFrame { FXDECLARE(FXStatusLine) protected: FXString status; // Current status message FXString normal; // Normally displayed message FXFont *font; // Font FXColor textColor; // Status text color FXColor textHighlightColor; // Status text highlight color protected: FXStatusLine(); private: FXStatusLine(const FXStatusLine&); FXStatusLine& operator=(const FXStatusLine&); public: long onPaint(FXObject*,FXSelector,void*); long onUpdate(FXObject*,FXSelector,void*); long onCmdGetStringValue(FXObject*,FXSelector,void*); long onCmdSetStringValue(FXObject*,FXSelector,void*); public: /// Constructor FXStatusLine(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Change the temporary status message void setText(const FXString& text); /// Return the temporary status message FXString getText() const { return status; } /// Change the permanent status message void setNormalText(const FXString& text); /// Return the permanent status message FXString getNormalText() const { return normal; } /// Change the font void setFont(FXFont* fnt); /// Return the current font FXFont* getFont() const { return font; } /// Return the text color FXColor getTextColor() const { return textColor; } /// Change the text color void setTextColor(FXColor clr); /// Return the highlight text color FXColor getTextHighlightColor() const { return textHighlightColor; } /// Change the highlight text color void setTextHighlightColor(FXColor clr); /// Save status line to stream virtual void save(FXStream& store) const; /// Load status line from stream virtual void load(FXStream& store); /// Destroy virtual ~FXStatusLine(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXStream.h000066400000000000000000000253171455751074500223330ustar00rootroot00000000000000/******************************************************************************** * * * P e r s i s t e n t S t o r a g e S t r e a m C l a s s e s * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSTREAM_H #define FXSTREAM_H namespace FX { /// Stream data flow direction enum FXStreamDirection { FXStreamDead=0, /// Unopened stream FXStreamSave=1, /// Saving stuff to stream FXStreamLoad=2 /// Loading stuff from stream }; /// Stream status codes enum FXStreamStatus { FXStreamOK=0, /// OK FXStreamEnd=1, /// Try read past end of stream FXStreamFull=2, /// Filled up stream buffer or disk full FXStreamNoWrite=3, /// Unable to open for write FXStreamNoRead=4, /// Unable to open for read FXStreamFormat=5, /// Stream format error FXStreamUnknown=6, /// Trying to read unknown class FXStreamAlloc=7, /// Alloc failed FXStreamFailure=8 /// General failure }; /// Stream seeking enum FXWhence { FXFromStart=0, /// Seek from start position FXFromCurrent=1, /// Seek from current position FXFromEnd=2 /// Seek from end position }; /** * A stream is a way to serialize data and objects into a byte stream. * Each item of data that is saved or loaded from the stream may be byte-swapped, * thus allowing little-endian machines to read data produced on big endian ones * and vice-versa. * Data is serialized exactly as-is. There are no tags or other markers * inserted into the stream; thus, the stream may be used to save or load arbitrary * binary data. * Objects derived from FXObjects may be serialized also; whenever a reference to an * object is serialized, a table is consulted to determine if the same object has * been encountered previously; if not, the object is added to the table and then * its contents are serialized. If the object has been encountered before, only a * reference to the object is serialized. * When loading back a serialized object, new instances are constructed using * the default constructor, and subsequently the object's contents are loaded. * A special container object may be passed in which is placed in the table * as if it had been encountered before; this will cause only references to this * object to be saved. The container object is typically the top-level document * object which manages all objects contained by it. Additional objects may be * added using addObject(); these will not be actually saved or loaded. */ class FXAPI FXStream { protected: FXHash hash; // Hash table const FXObject *parent; // Parent object FXuchar *begptr; // Begin of buffer FXuchar *endptr; // End of buffer FXuchar *wrptr; // Write pointer FXuchar *rdptr; // Read pointer FXlong pos; // Position FXStreamDirection dir; // Direction of current transfer FXStreamStatus code; // Status code FXuint seq; // Sequence number FXbool owns; // Stream owns buffer FXbool swap; // Swap bytes on readin protected: /** * Write at least count bytes from the buffer; * returns number of bytes available to be written. */ virtual FXuval writeBuffer(FXuval count); /** * Read at least count bytes into the buffer; * returns number of bytes available to be read. */ virtual FXuval readBuffer(FXuval count); private: FXStream(const FXStream&); FXStream &operator=(const FXStream&); public: /** * Construct stream with given container object. The container object * is an object that will itself not be saved to or loaded from the stream, * but which may be referenced by other objects. These references will be * properly saved and restored. */ FXStream(const FXObject* cont=nullptr); /** * Open stream for reading (FXStreamLoad) or for writing (FXStreamSave). * An initial buffer size may be given, which must be at least 16 bytes. * If data is not NULL, it is expected to point to an external data buffer * of length size; otherwise stream will use an internally managed buffer. */ FXbool open(FXStreamDirection save_or_load,FXuchar* data=nullptr,FXuval size=8192UL,FXbool owned=false); /// Flush buffer virtual FXbool flush(); /// Close; return true if OK virtual FXbool close(); /// Get available buffer space FXuval getSpace() const; /// Set available buffer space void setSpace(FXuval sp); /// Set buffer ownership flag void setOwned(FXbool owned){ owns=owned; } /// Get buffer ownership flag FXbool isOwned() const { return owns; } /// Get status code FXStreamStatus status() const { return code; } /// Return true if at end of file or error FXbool eof() const { return code!=FXStreamOK; } /// Set status code void setError(FXStreamStatus err); /// Obtain stream direction FXStreamDirection direction() const { return dir; } /// Get parent object const FXObject* container() const { return parent; } /// Get position FXlong position() const { return pos; } /// Move to position relative to head, tail, or current location virtual FXbool position(FXlong offset,FXWhence whence=FXFromStart); /** * Change swap bytes flag. */ void swapBytes(FXbool s){ swap=s; } /** * Get state of the swap bytes flag. */ FXbool swapBytes() const { return swap; } /** * Set stream to big endian mode if true. Byte swapping will * be enabled if the machine native byte order is not equal to * the desired byte order. */ void setBigEndian(FXbool big); /** * Return true if big endian mode. */ FXbool isBigEndian() const; /// Save single items to stream FXStream& operator<<(const FXuchar& v); FXStream& operator<<(const FXchar& v){ return *this << reinterpret_cast(v); } FXStream& operator<<(const FXbool& v); FXStream& operator<<(const FXushort& v); FXStream& operator<<(const FXshort& v){ return *this << reinterpret_cast(v); } FXStream& operator<<(const FXuint& v); FXStream& operator<<(const FXint& v){ return *this << reinterpret_cast(v); } FXStream& operator<<(const FXfloat& v){ return *this << reinterpret_cast(v); } FXStream& operator<<(const FXdouble& v); FXStream& operator<<(const FXlong& v){ return *this << reinterpret_cast(v); } FXStream& operator<<(const FXulong& v){ return *this << reinterpret_cast(v); } /// Save arrays of items to stream FXStream& save(const FXuchar* p,FXuval n); FXStream& save(const FXchar* p,FXuval n){ return save(reinterpret_cast(p),n); } FXStream& save(const FXbool* p,FXuval n); FXStream& save(const FXushort* p,FXuval n); FXStream& save(const FXshort* p,FXuval n){ return save(reinterpret_cast(p),n); } FXStream& save(const FXuint* p,FXuval n); FXStream& save(const FXint* p,FXuval n){ return save(reinterpret_cast(p),n); } FXStream& save(const FXfloat* p,FXuval n){ return save(reinterpret_cast(p),n); } FXStream& save(const FXdouble* p,FXuval n); FXStream& save(const FXlong* p,FXuval n){ return save(reinterpret_cast(p),n); } FXStream& save(const FXulong* p,FXuval n){ return save(reinterpret_cast(p),n); } /// Load single items from stream FXStream& operator>>(FXuchar& v); FXStream& operator>>(FXchar& v){ return *this >> reinterpret_cast(v); } FXStream& operator>>(FXbool& v); FXStream& operator>>(FXushort& v); FXStream& operator>>(FXshort& v){ return *this >> reinterpret_cast(v); } FXStream& operator>>(FXuint& v); FXStream& operator>>(FXint& v){ return *this >> reinterpret_cast(v); } FXStream& operator>>(FXfloat& v){ return *this >> reinterpret_cast(v); } FXStream& operator>>(FXdouble& v); FXStream& operator>>(FXlong& v){ return *this >> reinterpret_cast(v); } FXStream& operator>>(FXulong& v){ return *this >> reinterpret_cast(v); } /// Load arrays of items from stream FXStream& load(FXuchar* p,FXuval n); FXStream& load(FXchar* p,FXuval n){ return load(reinterpret_cast(p),n); } FXStream& load(FXbool* p,FXuval n); FXStream& load(FXushort* p,FXuval n); FXStream& load(FXshort* p,FXuval n){ return load(reinterpret_cast(p),n); } FXStream& load(FXuint* p,FXuval n); FXStream& load(FXint* p,FXuval n){ return load(reinterpret_cast(p),n); } FXStream& load(FXfloat* p,FXuval n){ return load(reinterpret_cast(p),n); } FXStream& load(FXdouble* p,FXuval n); FXStream& load(FXlong* p,FXuval n){ return load(reinterpret_cast(p),n); } FXStream& load(FXulong* p,FXuval n){ return load(reinterpret_cast(p),n); } /// Save object FXStream& saveObject(const FXObject* v); /// Load object FXStream& loadObject(FXObject*& v); /// Add object without saving or loading FXStream& addObject(const FXObject* v); /// Load object template FXStream& operator>>(TYPE*& obj){ return loadObject(reinterpret_cast(obj)); } /// Save object template FXStream& operator<<(const TYPE* obj){ return saveObject(static_cast(obj)); } /// Destructor virtual ~FXStream(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXString.h000066400000000000000000000731361455751074500223500ustar00rootroot00000000000000/******************************************************************************** * * * S t r i n g O b j e c t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSTRING_H #define FXSTRING_H namespace FX { class FXStream; /** * FXString provides essential string manipulation capabilities in FOX. * Internally, all strings are stored as an array of bytes preceeded by * the length of the string; an end-of-string character is appended at the end, * but is not included in the length of the string. * An empty string is represented by unique empty-string value which comprises * a length of 0, followed by an end-of-string character. * Thus, it is ALWAYS safe to dereference FXString as it will never be NULL. * FXString can be initialized direcly from literal strings in UTF-8 encoding, * but supports automatic conversion from UTF-16 encoded ("narrow") character * strings and UTF-32 encoded ("wide") character strings. */ class FXAPI FXString { private: FXchar* str; public: static const FXchar null[]; public: /// Construct empty string FXString(); /// Construct copy of another string FXString(const FXString& s); /// Construct and init from string FXString(const FXchar* s); /// Construct and init from narrow character string FXString(const FXnchar* s); /// Construct and init from wide character string FXString(const FXwchar* s); /// Construct and init with substring FXString(const FXchar* s,FXint n); /// Construct and init with narrow character substring FXString(const FXnchar* s,FXint n); /// Construct and init with wide character substring FXString(const FXwchar* s,FXint n); /// Construct and fill with constant FXString(FXchar c,FXint n); /// Length of text in bytes FXint length() const { return *(((FXint*)str)-1); } /// Change the length of the string to len FXbool length(FXint len); /// Return wide character starting at p FXwchar wc(FXint p) const; /// Return wide character at p and advance to next FXwchar wcnxt(FXint& p) const; /// Retreat to wide character previous to p and return it FXwchar wcprv(FXint& p) const; /// Increment byte offset by one utf8 character FXint inc(FXint p) const; /// Increment byte offset by n utf8 characters FXint inc(FXint p,FXint n) const; /// Decrement byte offset by one utf8 character FXint dec(FXint p) const; /// Decrement byte offset by n utf8 characters FXint dec(FXint p,FXint n) const; /// Count number of utf8 characters FXint count() const; /// Count number of utf8 characters in subrange start...end FXint count(FXint start,FXint end) const; /// Return byte offset of utf8 character at index FXint offset(FXint indx) const; /// Return index of utf8 character at byte offset FXint index(FXint offs) const; /// Validate position to point to begin of utf8 character FXint validate(FXint p) const; /// Get text contents as pointer FXchar* text(){ return str; } /// Get text contents as const pointer const FXchar* text() const { return str; } /// See if string is empty FXbool empty() const { return (((FXint*)str)[-1]==0); } /// See if string is empty FXbool operator!() const { return (((FXint*)str)[-1]==0); } /// Return a non-const reference to the ith character FXchar& operator[](FXint i){ return str[i]; } /// Return a const reference to the ith character const FXchar& operator[](FXint i) const { return str[i]; } /// Return a non-const reference to the ith character FXchar& at(FXint i){ return str[i]; } /// Return a const reference to the ith character const FXchar& at(FXint i) const { return str[i]; } /// Return a non-const reference to the first character FXchar& head(){ return str[0]; } /// Return a const reference to the first character const FXchar& head() const { return str[0]; } /// Return a non-const reference to the last character FXchar& tail(){ return str[length()-1]; } /// Return a const reference to the last character const FXchar& tail() const { return str[length()-1]; } /// Assign a constant string to this string FXString& operator=(const FXchar* s); /// Assign a narrow character string to this string FXString& operator=(const FXnchar* s); /// Assign a wide character string to this string FXString& operator=(const FXwchar* s); /// Assign another string to this string FXString& operator=(const FXString& s); /// Append single character to this string FXString& operator+=(FXchar c); /// Append constant string after this string FXString& operator+=(const FXchar* s); /// Append narrow character string after this string FXString& operator+=(const FXnchar* s); /// Append wide characeter string after this string FXString& operator+=(const FXwchar* s); /// Append another string after this string FXString& operator+=(const FXString& s); /// Adopt string s, leaving s empty FXString& adopt(FXString& s); /// Assign character c to this string FXString& assign(FXchar c); /// Assign n characters c to this string FXString& assign(FXchar c,FXint n); /// Assign string s to this string FXString& assign(const FXchar* s); /// Assign narrow character string s to this string FXString& assign(const FXnchar* s); /// Assign wide character string s to this string FXString& assign(const FXwchar* s); /// Assign first n characters of string s to this string FXString& assign(const FXchar *s,FXint n); /// Assign first n characters of narrow character string s to this string FXString& assign(const FXnchar *s,FXint n); /// Assign first n characters of wide character string s to this string FXString& assign(const FXwchar *s,FXint n); /// Assign string s to this string FXString& assign(const FXString& s); /// Insert character at specified position FXString& insert(FXint pos,FXchar c); /// Insert n characters c at specified position FXString& insert(FXint pos,FXchar c,FXint n); /// Insert string at specified position FXString& insert(FXint pos,const FXchar* s); /// Insert narrow character string at specified position FXString& insert(FXint pos,const FXnchar* s); /// Insert wide character string at specified position FXString& insert(FXint pos,const FXwchar* s); /// Insert first n characters of string at specified position FXString& insert(FXint pos,const FXchar* s,FXint n); /// Insert first n characters of narrow character string at specified position FXString& insert(FXint pos,const FXnchar* s,FXint n); /// Insert first n characters of wide character string at specified position FXString& insert(FXint pos,const FXwchar* s,FXint n); /// Insert string at specified position FXString& insert(FXint pos,const FXString& s); /// Prepend string with input character FXString& prepend(FXchar c); /// Prepend string with n characters c FXString& prepend(FXchar c,FXint n); /// Prepend string with string s FXString& prepend(const FXchar* s); /// Prepend string with narrow character string FXString& prepend(const FXnchar* s); /// Prepend string with wide character string FXString& prepend(const FXwchar* s); /// Prepend first n characters of string s FXString& prepend(const FXchar* s,FXint n); /// Prepend first n characters of narrow character string s FXString& prepend(const FXnchar* s,FXint n); /// Prepend first n characters of wide character string s FXString& prepend(const FXwchar* s,FXint n); /// Prepend string with string s FXString& prepend(const FXString& s); /// Append character c to this string FXString& append(FXchar c); /// Append n characters c to this string FXString& append(FXchar c,FXint n); /// Append string s to this string FXString& append(const FXchar* s); /// Append narrow character string s to this string FXString& append(const FXnchar* s); /// Append wide character string s to this string FXString& append(const FXwchar* s); /// Append first n characters of string s to this string FXString& append(const FXchar* s,FXint n); /// Append first n characters of narrow character string s to this string FXString& append(const FXnchar* s,FXint n); /// Append first n characters of wide character string s to this string FXString& append(const FXwchar* s,FXint n); /// Append string s to this string FXString& append(const FXString& s); /// Replace a single character FXString& replace(FXint pos,FXchar c); /// Replace the r characters at pos with n characters c FXString& replace(FXint pos,FXint r,FXchar c,FXint n); /// Replace the r characters at pos with string s FXString& replace(FXint pos,FXint r,const FXchar* s); /// Replace the r characters at pos with narrow character string s FXString& replace(FXint pos,FXint r,const FXnchar* s); /// Replace the r characters at pos with wide character string s FXString& replace(FXint pos,FXint r,const FXwchar* s); /// Replaces the r characters at pos with first n characters of string s FXString& replace(FXint pos,FXint r,const FXchar* s,FXint n); /// Replaces the r characters at pos with first n characters of narrow character string s FXString& replace(FXint pos,FXint r,const FXnchar* s,FXint n); /// Replaces the r characters at pos with first n characters of wide character string s FXString& replace(FXint pos,FXint r,const FXwchar* s,FXint n); /// Replace the r characters at pos with string s FXString& replace(FXint pos,FXint r,const FXString& s); /// Move range of n characters from src position to dst position FXString& move(FXint dst,FXint src,FXint n); /// Remove one character FXString& erase(FXint pos); /// Remove substring FXString& erase(FXint pos,FXint n); /// Truncate string at pos FXString& trunc(FXint pos); /// Clear FXString& clear(); /// Return number of occurrences of ch in string FXint contains(FXchar ch) const; /// Return number of occurrences of string sub in string FXint contains(const FXchar* sub,FXint n) const; /// Return number of occurrences of string sub in string FXint contains(const FXchar* sub) const; /// Return number of occurrences of string sub in string FXint contains(const FXString& sub) const; /// Substitute one character by another FXString& substitute(FXchar org,FXchar sub,FXbool all=true); /// Substitute one string by another FXString& substitute(const FXchar* org,FXint olen,const FXchar *rep,FXint rlen,FXbool all=true); /// Substitute one string by another FXString& substitute(const FXchar* org,const FXchar *rep,FXbool all=true); /// Substitute one string by another FXString& substitute(const FXString& org,const FXString& rep,FXbool all=true); /// Convert to lower case FXString& lower(); /// Convert to upper case FXString& upper(); /// Simplify whitespace in string FXString& simplify(); /// Remove leading and trailing whitespace FXString& trim(); /// Remove leading whitespace FXString& trimBegin(); /// Remove trailing whitespace FXString& trimEnd(); /// Get left most part FXString left(FXint n) const; /// Get right most part FXString right(FXint n) const; /// Get some part in the middle FXString mid(FXint pos,FXint n) const; /// Return num partition(s) from a given start partition in a string separated by delimiters delim. FXString section(FXchar delim,FXint start,FXint num=1) const; /// Return num partition(s) from a given start partition in a string separated by set of delimiters from delim of size n FXString section(const FXchar* delim,FXint n,FXint start,FXint num) const; /// Return num partition(s) from a given start partition in a string separated by set of delimiters from delim. FXString section(const FXchar* delim,FXint start,FXint num=1) const; /// Return num partition(s) from a given start partition in a string separated by set of delimiters from delim. FXString section(const FXString& delim,FXint start,FXint num=1) const; /** * Return all characters before the n-th occurrence of ch, * searching from the beginning of the string. If the character * is not found, return the entire string. If n<=0, return * the empty string. */ FXString before(FXchar ch,FXint n=1) const; /** * Return all characters before the n-th occurrence of ch, * searching from the end of the string. If the character * is not found, return the empty string. If n<=0, return * the entire string. */ FXString rbefore(FXchar ch,FXint n=1) const; /** * Return all characters after the nth occurrence of ch, * searching from the beginning of the string. If the character * is not found, return the empty string. If n<=0, return * the entire string. */ FXString after(FXchar ch,FXint n=1) const; /** * Return all characters after the nth occurrence of ch, * searching from the end of the string. If the character * is not found, return the entire string. If n<=0, return * the empty string. */ FXString rafter(FXchar ch,FXint n=1) const; /// Find a character, searching forward; return position or -1 FXint find(FXchar c,FXint pos=0) const; /// Find a character, searching backward; return position or -1 FXint rfind(FXchar c,FXint pos=2147483647) const; /// Find n-th occurrence of character, searching forward; return position or -1 FXint find(FXchar c,FXint pos,FXint n) const; /// Find n-th occurrence of character, searching backward; return position or -1 FXint rfind(FXchar c,FXint pos,FXint n) const; /// Find a substring of length n, searching forward; return position or -1 FXint find(const FXchar* substr,FXint n,FXint pos) const; /// Find a substring of length n, searching backward; return position or -1 FXint rfind(const FXchar* substr,FXint n,FXint pos) const; /// Find a substring, searching forward; return position or -1 FXint find(const FXchar* substr,FXint pos=0) const; /// Find a substring, searching backward; return position or -1 FXint rfind(const FXchar* substr,FXint pos=2147483647) const; /// Find a substring, searching forward; return position or -1 FXint find(const FXString& substr,FXint pos=0) const; /// Find a substring, searching backward; return position or -1 FXint rfind(const FXString& substr,FXint pos=2147483647) const; /// Find first character in the set of size n, starting from pos; return position or -1 FXint find_first_of(const FXchar* set,FXint n,FXint pos) const; /// Find first character in the set, starting from pos; return position or -1 FXint find_first_of(const FXchar* set,FXint pos=0) const; /// Find first character in the set, starting from pos; return position or -1 FXint find_first_of(const FXString& set,FXint pos=0) const; /// Find first character, starting from pos; return position or -1 FXint find_first_of(FXchar c,FXint pos=0) const; /// Find last character in the set of size n, starting from pos; return position or -1 FXint find_last_of(const FXchar* set,FXint n,FXint pos) const; /// Find last character in the set, starting from pos; return position or -1 FXint find_last_of(const FXchar* set,FXint pos=2147483647) const; /// Find last character in the set, starting from pos; return position or -1 FXint find_last_of(const FXString& set,FXint pos=2147483647) const; /// Find last character, starting from pos; return position or -1 FXint find_last_of(FXchar c,FXint pos=2147483647) const; /// Find first character NOT in the set of size n, starting from pos; return position or -1 FXint find_first_not_of(const FXchar* set,FXint n,FXint pos) const; /// Find first character NOT in the set, starting from pos; return position or -1 FXint find_first_not_of(const FXchar* set,FXint pos=0) const; /// Find first character NOT in the set, starting from pos; return position or -1 FXint find_first_not_of(const FXString& set,FXint pos=0) const; /// Find first character NOT equal to c, starting from pos; return position or -1 FXint find_first_not_of(FXchar c,FXint pos=0) const; /// Find last character NOT in the set of size n, starting from pos; return position or -1 FXint find_last_not_of(const FXchar* set,FXint n,FXint pos) const; /// Find last character NOT in the set, starting from pos; return position or -1 FXint find_last_not_of(const FXchar* set,FXint pos=2147483647) const; /// Find last character NOT in the set, starting from pos; return position or -1 FXint find_last_not_of(const FXString& set,FXint pos=2147483647) const; /// Find last character NOT equal to c, starting from pos; return position or -1 FXint find_last_not_of(FXchar c,FXint pos=2147483647) const; /// Scan a string a-la scanf FXint scan(const FXchar* fmt,...) const FX_SCANF(2,3) ; FXint vscan(const FXchar* fmt,va_list args) const; /// Format a string a-la printf FXint format(const FXchar* fmt,...) FX_PRINTF(2,3) ; FXint vformat(const FXchar* fmt,va_list args); /// Convert to integer FXint toInt(FXint base=10,FXbool* ok=nullptr) const; /// Convert to unsigned integer FXuint toUInt(FXint base=10,FXbool* ok=nullptr) const; /// Convert to long integer FXlong toLong(FXint base=10,FXbool* ok=nullptr) const; /// Convert to unsigned long integer FXulong toULong(FXint base=10,FXbool* ok=nullptr) const; /// Convert to float FXfloat toFloat(FXbool* ok=nullptr) const; /// Convert to double FXdouble toDouble(FXbool* ok=nullptr) const; /// Convert from integer FXString& fromInt(FXint number,FXint base=10); /// Convert from unsigned integer FXString& fromUInt(FXuint number,FXint base=10); /// Convert from long integer FXString& fromLong(FXlong number,FXint base=10); /// Convert from unsigned long integer FXString& fromULong(FXulong number,FXint base=10); /// Convert from float; fmt is 0 (no exponent), 1 (force exponent), or 2 (exponent when needed) FXString& fromFloat(FXfloat number,FXint prec=6,FXint fmt=2); /// Convert from double; fmt is 0 (no exponent), 1 (force exponent), or 2 (exponent when needed) FXString& fromDouble(FXdouble number,FXint prec=6,FXint fmt=2); /** * Return a string value by converting an integer number to a string, * using the given number base, which must be between 2 and 16. */ static FXString value(FXint num,FXint base=10); static FXString value(FXuint num,FXint base=10); /** * Return a string value by converting a long integer number to a string, * using the given number base, which must be between 2 and 16. */ static FXString value(FXlong num,FXint base=10); static FXString value(FXulong num,FXint base=10); /** * Return a string value by converting real number to a string, using the given * procision and exponential notation mode, which may be 0 (never), 1 (always), * or 2 (when needed). */ static FXString value(FXfloat num,FXint prec=6,FXint fmt=2); static FXString value(FXdouble num,FXint prec=6,FXint fmt=2); /** * Return a string value from printf-like format arguments. */ static FXString value(const FXchar* fmt,...) FX_PRINTF(1,2) ; /** * Return a string value from vprintf-like format arguments. */ static FXString vvalue(const FXchar* fmt,va_list args); /// Compute hash value of string FXuint hash() const; /// Compute hash value of string static FXuint hash(const FXchar* s); /// Compute hash value of string static FXuint hash(const FXchar* s,FXint n); /// Compare static FXint compare(const FXchar* s1,const FXchar* s2); static FXint compare(const FXchar* s1,const FXString& s2); static FXint compare(const FXString& s1,const FXchar* s2); static FXint compare(const FXString& s1,const FXString& s2); /// Compare up to n static FXint compare(const FXchar* s1,const FXchar* s2,FXint n); static FXint compare(const FXchar* s1,const FXString& s2,FXint n); static FXint compare(const FXString& s1,const FXchar* s2,FXint n); static FXint compare(const FXString& s1,const FXString& s2,FXint n); /// Compare case insensitive static FXint comparecase(const FXchar* s1,const FXchar* s2); static FXint comparecase(const FXchar* s1,const FXString& s2); static FXint comparecase(const FXString& s1,const FXchar* s2); static FXint comparecase(const FXString& s1,const FXString& s2); /// Compare case insensitive up to n static FXint comparecase(const FXchar* s1,const FXchar* s2,FXint n); static FXint comparecase(const FXchar* s1,const FXString& s2,FXint n); static FXint comparecase(const FXString& s1,const FXchar* s2,FXint n); static FXint comparecase(const FXString& s1,const FXString& s2,FXint n); /// Compare with natural interpretation of decimal numbers static FXint comparenatural(const FXchar* s1,const FXchar* s2); static FXint comparenatural(const FXchar* s1,const FXString& s2); static FXint comparenatural(const FXString& s1,const FXchar* s2); static FXint comparenatural(const FXString& s1,const FXString& s2); /// Compare case insensitive with natural interpretation of decimal numbers static FXint comparenaturalcase(const FXchar* s1,const FXchar* s2); static FXint comparenaturalcase(const FXchar* s1,const FXString& s2); static FXint comparenaturalcase(const FXString& s1,const FXchar* s2); static FXint comparenaturalcase(const FXString& s1,const FXString& s2); /** * Check if the string contains special characters or leading or trailing whitespace, * or contains UTF8 if flag!=0. */ static FXbool shouldEscape(const FXchar* str,FXchar lquote='\0',FXchar rquote='\0',FXint flag=0); static FXbool shouldEscape(const FXchar* str,FXint num,FXchar lquote='\0',FXchar rquote='\0',FXint flag=0); static FXbool shouldEscape(const FXString& str,FXchar lquote='\0',FXchar rquote='\0',FXint flag=0); /** * Escape special characters. * Optionally enclose return value with left and right quotes. * Flag: 0 don't escape UTF8 multi-byte characters. * Flag: 1 escapes UTF8 multi-byte characters to a sequence of hexadecimals of the form \xXX. * Flag: 2 escapes UTF8 multi-byte characters to the form \uXXXX or \uXXXX\uYYYY. * Ill-formed UTF8 will be escaped as hexadecimals \xXX regardless even if \uXXXX is requested. * Quotes will be escaped if quoting is performed. */ static FXString escape(const FXchar* str,FXchar lquote='\0',FXchar rquote='\0',FXint flag=0); static FXString escape(const FXchar* str,FXint num,FXchar lquote='\0',FXchar rquote='\0',FXint flag=0); static FXString escape(const FXString& str,FXchar lquote='\0',FXchar rquote='\0',FXint flag=0); /** * Unescape special characters, * Optionally remove surrounding left and right quotes. * In particular, unescape \xXX to the hexadecimal character XX, \uXXXX to the multi-byte * UTF8 sequence representing unicode character XXXX, and unescape \t, \n, etc. * Handle surrogate pairs of the form \uXXXX\uYYYY properly. */ static FXString unescape(const FXchar* str,FXchar lquote='\0',FXchar rquote='\0'); static FXString unescape(const FXchar* str,FXint num,FXchar lquote='\0',FXchar rquote='\0'); static FXString unescape(const FXString& str,FXchar lquote='\0',FXchar rquote='\0'); /** * Expand tabs with the equivalent amount of spaces. * UTF8 encoded characters are counted as one column. */ static FXString detab(const FXchar* str,FXint tabcols); static FXString detab(const FXchar* str,FXint num,FXint tabcols); static FXString detab(const FXString& str,FXint tabcols); /** * Compress runs of more than 2 spaces with tabs. * UTF8 characters are counted as one column. */ static FXString entab(const FXchar* str,FXint tabcols); static FXString entab(const FXchar* str,FXint num,FXint tabcols); static FXString entab(const FXString& str,FXint tabcols); /** * Retabbify lines of text. * Given lines of text at given indent-level, insert of remove spaces or tabs to * align the text to new outdent-level, shifting over by a number of columns left-ward * or rightward. UTF8 characters are counted as one column, and trailing space will be * deleted. */ static FXString tabbify(const FXchar* str,FXint tabcols,FXint indent,FXint outdent,FXint shift,FXbool tabs); static FXString tabbify(const FXchar* str,FXint num,FXint tabcols,FXint indent,FXint outdent,FXint shift,FXbool tabs); static FXString tabbify(const FXString& str,FXint tabcols,FXint indent,FXint outdent,FXint shift,FXbool tabs); /** * Return normalized string, i.e. reordering of diacritical marks. */ static FXString normalize(const FXString& s); /** * Return normalized decomposition of string. */ static FXString decompose(const FXString& s,FXbool canonical=true); /** * Return normalized composition of string; this first performs normalized * decomposition. */ static FXString compose(const FXString& s,FXbool canonical=true); /// Swap two strings friend inline FXString& swap(FXString& dst,FXString& src); /// Saving to a stream friend FXAPI FXStream& operator<<(FXStream& store,const FXString& s); /// Load from a stream friend FXAPI FXStream& operator>>(FXStream& store,FXString& s); /// Delete ~FXString(); }; /// Swap two strings inline FXString& swap(FXString& dst,FXString& src){ FXchar* t=dst.str; dst.str=src.str; src.str=t; return dst; } /// Equality operators static inline FXbool operator==(const FXString& s1,const FXString& s2){ return FXString::compare(s1.text(),s2.text())==0; } static inline FXbool operator==(const FXString& s1,const FXchar* s2){ return FXString::compare(s1.text(),s2)==0; } static inline FXbool operator==(const FXchar* s1,const FXString& s2){ return FXString::compare(s1,s2.text())==0; } /// Inequality operators static inline FXbool operator!=(const FXString& s1,const FXString& s2){ return FXString::compare(s1.text(),s2.text())!=0; } static inline FXbool operator!=(const FXString& s1,const FXchar* s2){ return FXString::compare(s1.text(),s2)!=0; } static inline FXbool operator!=(const FXchar* s1,const FXString& s2){ return FXString::compare(s1,s2.text())!=0; } /// Lexicographic less than operators static inline FXbool operator<(const FXString& s1,const FXString& s2){ return FXString::compare(s1.text(),s2.text())<0; } static inline FXbool operator<(const FXString& s1,const FXchar* s2){ return FXString::compare(s1.text(),s2)<0; } static inline FXbool operator<(const FXchar* s1,const FXString& s2){ return FXString::compare(s1,s2.text())<0; } /// Lexicographic less than or equal operators static inline FXbool operator<=(const FXString& s1,const FXString& s2){ return FXString::compare(s1.text(),s2.text())<=0; } static inline FXbool operator<=(const FXString& s1,const FXchar* s2){ return FXString::compare(s1.text(),s2)<=0; } static inline FXbool operator<=(const FXchar* s1,const FXString& s2){ return FXString::compare(s1,s2.text())<=0; } /// Lexicographic greater than operators static inline FXbool operator>(const FXString& s1,const FXString& s2){ return FXString::compare(s1.text(),s2.text())>0; } static inline FXbool operator>(const FXString& s1,const FXchar* s2){ return FXString::compare(s1.text(),s2)>0; } static inline FXbool operator>(const FXchar* s1,const FXString& s2){ return FXString::compare(s1,s2.text())>0; } /// Lexicographic greater than or equal operators static inline FXbool operator>=(const FXString& s1,const FXString& s2){ return FXString::compare(s1.text(),s2.text())>=0; } static inline FXbool operator>=(const FXString& s1,const FXchar* s2){ return FXString::compare(s1.text(),s2)>=0; } static inline FXbool operator>=(const FXchar* s1,const FXString& s2){ return FXString::compare(s1,s2.text())>=0; } /// Concatenate FXString and FXString extern FXAPI FXString operator+(const FXString& s1,const FXString& s2); /// Concatenate FXString and a string extern FXAPI FXString operator+(const FXString& s1,const FXchar* s2); extern FXAPI FXString operator+(const FXString& s1,const FXnchar* s2); extern FXAPI FXString operator+(const FXString& s1,const FXwchar* s2); /// Concatenate string and FXString extern FXAPI FXString operator+(const FXchar* s1,const FXString& s2); extern FXAPI FXString operator+(const FXnchar* s1,const FXString& s2); extern FXAPI FXString operator+(const FXwchar* s1,const FXString& s2); /// Concatenate string and single character extern FXAPI FXString operator+(const FXString& s,FXchar c); extern FXAPI FXString operator+(FXchar c,const FXString& s); /// Saving to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXString& s); /// Load from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXString& s); /// Convert unix string to dos string extern FXAPI FXString& unixToDos(FXString& str); /// Convert dos string to unix string extern FXAPI FXString& dosToUnix(FXString& str); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXStringDictionary.h000066400000000000000000000136351455751074500243740ustar00rootroot00000000000000/******************************************************************************** * * * S t r i n g D i c t i o n a r y C l a s s * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSTRINGDICTIONARY_H #define FXSTRINGDICTIONARY_H namespace FX { /** * The dictionary class maintains a fast-access hash table of entities * indexed by a character string. */ class FXAPI FXStringDictionary { protected: struct Entry { FXString key; // Key FXString data; // Value FXuint hash; // Hash of key FXuint mark; // Mark flag }; protected: Entry* table; // Hash table protected: // Change size of the table FXbool no(FXival n); // Change number of used entries void used(FXival u){ ((FXival*)table)[-2]=u; } // Change number of free entries void free(FXival f){ ((FXival*)table)[-3]=f; } // Resize the table to the given size, keeping contents FXbool resize(FXival n); public: /// Construct empty string dictionary FXStringDictionary(); /// Construct from another string dictionary FXStringDictionary(const FXStringDictionary& other); /// Return the size of the table, including the empty slots FXival no() const { return ((FXival*)table)[-1]; } /// Return number of used slots in the table FXival used() const { return ((FXival*)table)[-2]; } /// Return number of free slots in the table FXival free() const { return ((FXival*)table)[-3]; } /// See if map is empty FXbool empty() const { return ((FXival*)table)[-1]<=1; } /// Assignment operator FXStringDictionary& operator=(const FXStringDictionary& other); /// Adopt string dictionary from another FXStringDictionary& adopt(FXStringDictionary& other); /// Find position of given key, returning -1 if not found FXival find(const FXchar* ky) const; /// Find position of given key, returning -1 if not found FXival find(const FXString& ky) const { return find(ky.text()); } /// Check if key is mapped FXbool has(const FXchar* ky) const { return 0<=find(ky); } /// Check if key is mapped FXbool has(const FXString& ky) const { return has(ky.text()); } /// Return reference to slot assocated with given key FXString& at(const FXchar* ky,FXbool mrk=false); /// Return constant reference to slot assocated with given key const FXString& at(const FXchar* ky) const; /// Return reference to slot assocated with given key FXString& at(const FXString& ky,FXbool mrk=false){ return at(ky.text(),mrk); } /// Return constant reference to slot assocated with given key const FXString& at(const FXString& ky) const { return at(ky.text()); } /// Return reference to slot assocated with given key FXString& operator[](const FXchar* ky){ return at(ky,false); } /// Return constant reference to slot assocated with given key const FXString& operator[](const FXchar* ky) const { return at(ky); } /// Return reference to slot assocated with given key FXString& operator[](const FXString& ky){ return at(ky,false); } /// Return constant reference to slot assocated with given key const FXString& operator[](const FXString& ky) const { return at(ky); } /// Insert association with given key; return reference to the string FXbool insert(const FXchar* ky,const FXchar* str,FXbool mrk=false){ at(ky,mrk)=str; return true; } /// Insert association with given key; return reference to the string FXbool insert(const FXString& ky,const FXchar* str,FXbool mrk=false){ at(ky,mrk)=str; return true; } /// Insert association with given key; return reference to the string FXbool insert(const FXString& ky,const FXString& str,FXbool mrk=false){ at(ky,mrk)=str; return true; } /// Remove association with given key FXbool remove(const FXchar* ky); /// Remove association with given key FXbool remove(const FXString& ky){ return remove(ky.text()); } /// Erase data at pos in the table FXbool erase(FXival pos); /// Return true if slot is empty. FXbool empty(FXival pos) const { return table[pos].key.empty(); } /// Return key at position pos const FXString& key(FXival pos) const { return table[pos].key; } /// Return reference to slot at position pos FXString& data(FXival pos){ return table[pos].data; } /// Return constant reference to slot at position pos const FXString& data(FXival pos) const { return table[pos].data; } /// Return mark flag of entry at position pos FXuint mark(FXival pos) const { return table[pos].mark; } /// Clear entire table FXbool clear(); /// Destroy table ~FXStringDictionary(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXSwitcher.h000066400000000000000000000103571455751074500226660ustar00rootroot00000000000000/******************************************************************************** * * * S w i t c h C o n t a i n e r W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSWITCHER_H #define FXSWITCHER_H #ifndef FXPACKER_H #include "FXPacker.h" #endif namespace FX { /// Switcher options enum { SWITCHER_HCOLLAPSE = 0x00020000, /// Collapse horizontally to width of current child SWITCHER_VCOLLAPSE = 0x00040000 /// Collapse vertically to height of current child }; /** * The Switcher layout manager automatically arranges its child * windows such that one of them is placed on top; all other * child windows are hidden. * Switcher provides a convenient method to conserve screen * real-estate by arranging several GUI panels to appear in the * same space, depending on context. * Switcher ignores all layout hints from its children:- all * children are stretched according to the switcher layout * managers own size. * When the SWITCHER_HCOLLAPSE or SWITCHER_VCOLLAPSE options * are used, Switcher's default size is based on the width or * height of the current child, instead of the maximum width * or height of all of the children. */ class FXAPI FXSwitcher : public FXPacker { FXDECLARE(FXSwitcher) protected: FXint current; protected: FXSwitcher(); private: FXSwitcher(const FXSwitcher&); FXSwitcher& operator=(const FXSwitcher&); public: long onPaint(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdOpen(FXObject*,FXSelector,void*); long onUpdOpen(FXObject*,FXSelector,void*); public: enum { ID_OPEN_FIRST=FXPacker::ID_LAST, ID_OPEN_SECOND, ID_OPEN_THIRD, ID_OPEN_FOURTH, ID_OPEN_FIFTH, ID_OPEN_SIXTH, ID_OPEN_SEVENTH, ID_OPEN_EIGHTH, ID_OPEN_NINETH, ID_OPEN_TENTH, ID_OPEN_LAST=ID_OPEN_FIRST+100, ID_LAST }; public: /// Construct a switcher layout manager FXSwitcher(FXComposite *p,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_SPACING,FXint pr=DEFAULT_SPACING,FXint pt=DEFAULT_SPACING,FXint pb=DEFAULT_SPACING); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Perform layout virtual void layout(); /// Bring the child window at index to the top void setCurrent(FXint index,FXbool notify=false); /// Return the index of the child window currently on top FXint getCurrent() const { return current; } /// Set the switcher style flags void setSwitcherStyle(FXuint style); /// Get the switcher style flags FXuint getSwitcherStyle() const; /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXSystem.h000066400000000000000000000173271455751074500223660ustar00rootroot00000000000000/******************************************************************************** * * * M i s c e l l a n e o u s S y s t e m F u n c t i o n s * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXSYSTEM_H #define FXSYSTEM_H namespace FX { namespace FXSystem { /// System Time in parts struct Time { FXint year; /// Year (e.g. 1970) FXint month; /// Month 1..12 FXint mday; /// Day of the month 1..31 FXint yday; /// Day in the year 1..366 FXint wday; /// Day of the week 0..6 FXint hour; /// Hours 0..23 FXint min; /// Minutes 0..59 FXint sec; /// Seconds 0..60 FXint nano; /// Nanoseconds 0..999999999 FXint offset; /// Seconds east of utc }; /// Compute nanoseconds since Unix Epoch from system time extern FXAPI FXTime timeFromSystemTime(const Time& st); /// Return system time from utc in nanoseconds since Unix Epoch extern FXAPI void systemTimeFromTime(Time& st,FXTime utc); /// Default formatting (mm/dd/yyyy hh:mm:ss) string used for time formatting extern FXAPI const FXchar defaultTimeFormat[]; /// ISO 8601 time format (yyyy-mm-ddThh:mm:ss+hh:mm) formatting string extern FXAPI const FXchar isoTimeFormat[]; /// Format system time to string extern FXAPI FXString systemTimeFormat(const Time& st,const FXchar* format=defaultTimeFormat); /// Parse system time from string, returning number of characters parsed extern FXAPI FXint systemTimeParse(Time& st,const FXchar* string,const FXchar* format=defaultTimeFormat); /// Parse system time from string, returning number of characters parsed extern FXAPI FXint systemTimeParse(Time& st,const FXString& string,const FXchar* format=defaultTimeFormat); /** * Returns number of days since civil 1970-01-01. Negative values indicate * days prior to 1970-01-01. * y is year, m is month of year (1..12), d is day of month (1..31). */ extern FXAPI FXlong daysFromCivil(FXint y,FXint m,FXint d); /** * Returns year/month/day in civil calendar. * z is number of days since 1970-01-01. Negative values indicate * days prior to 1970-01-01. * y is year, m is month of year (1..12), d is day of month (1..31). */ extern FXAPI void civilFromDays(FXint& y,FXint& m,FXint& d,FXlong z); /// Return leap seconds from utc in nanocseconds since Unix Epoch extern FXAPI FXival leapSeconds(FXTime utc); /// Return leap seconds from tai in nanocseconds since Unix Epoch extern FXAPI FXival leapSecondsTAI(FXTime tai); /// Return offset between standard local time zone to UTC, in nanoseconds extern FXAPI FXTime localTimeZoneOffset(); /// Return offset daylight savings time to standard time, in nanoseconds extern FXAPI FXTime daylightSavingsOffset(); /// Return 1 if daylight savings time is active at utc in nanoseconds since Unix Epoch extern FXAPI FXTime daylightSavingsActive(FXTime utc); /// Return time zone name (or daylight savings time time zone name) extern FXAPI FXString localTimeZoneName(FXbool dst=false); /// Convert NTP format (ssss:ffff) to nanoseconds since Unix Epoch extern FXAPI FXTime timeFromNTPTime(FXulong ntptime); /// Convert utc in nanoseconds since Unix Epoch to NTP (ssss:ffff) extern FXAPI FXulong ntpTimeFromTime(FXTime utc); /// Format utc in nanoseconds since Unix Epoch to date-time string using given format extern FXAPI FXString universalTime(FXTime utc,const FXchar *format=defaultTimeFormat); /// Parse date-time string to UTC nanoseconds since Unix Epoch using given format extern FXAPI FXTime universalTime(const FXchar* string,const FXchar* format=defaultTimeFormat); extern FXAPI FXTime universalTime(const FXString& string,const FXchar* format=defaultTimeFormat); /// Format utc in nanoseconds since Unix Epoch to local date-time string using given format extern FXAPI FXString localTime(FXTime utc,const FXchar *format=defaultTimeFormat); /// Parse local date-time string to UTC nanoseconds since Unix Epoch using given format extern FXAPI FXTime localTime(const FXchar* string,const FXchar* format=defaultTimeFormat); extern FXAPI FXTime localTime(const FXString& string,const FXchar* format=defaultTimeFormat); /// Get effective user id extern FXAPI FXuint user(); /// Get effective group id extern FXAPI FXuint group(); /// Return owner name from uid if available extern FXAPI FXString userName(FXuint uid); /// Return group name from gid if available extern FXAPI FXString groupName(FXuint gid); /// Get current effective user name extern FXAPI FXString currentUserName(); /// Get current effective group name extern FXAPI FXString currentGroupName(); /// Get permissions string extern FXAPI FXString modeString(FXuint mode); /// Return value of environment variable name extern FXAPI FXString getEnvironment(const FXString& name); /// Change value of environment variable name, return true if success extern FXAPI FXbool setEnvironment(const FXString& name,const FXString& value); /// Get the current working directory extern FXAPI FXString getCurrentDirectory(); /// Set the current working directory extern FXAPI FXbool setCurrentDirectory(const FXString& path); /// Return the current drive (for Win32 systems) extern FXAPI FXString getCurrentDrive(); /// Set the current drive (for Win32 systems) extern FXAPI FXbool setCurrentDrive(const FXString& prefix); /// Get executable path extern FXAPI FXString getExecPath(); /// Return known executable file extensions (Windows) extern FXAPI FXString getExecExtensions(); /// Get name of calling executable extern FXAPI FXString getExecFilename(); /// Return the home directory for the current user extern FXAPI FXString getHomeDirectory(); /// Return temporary directory extern FXAPI FXString getTempDirectory(); /// Return system directory extern FXAPI FXString getSystemDirectory(); /// Return the home directory for a given user extern FXAPI FXString getUserDirectory(const FXString& user); /// Return host name extern FXAPI FXString getHostName(); /// Determine if UTF8 locale in effect extern FXAPI FXbool localeIsUTF8(); /** * Get DLL name for given base name; for example "png" * becomes "libpng.so" on Linux, and "png.dll" on Windows. */ extern FXAPI FXString dllName(const FXString& name); } } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXTGAIcon.h000066400000000000000000000057021455751074500223200ustar00rootroot00000000000000/******************************************************************************** * * * T A R G A I c o n O b j e c t * * * ********************************************************************************* * Copyright (C) 2001,2022 by Janusz Ganczarski. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTGAICON_H #define FXTGAICON_H #ifndef FXICON_H #include "FXIcon.h" #endif namespace FX { /// TARGA image format icon class FXAPI FXTGAIcon : public FXIcon { FXDECLARE(FXTGAIcon) protected: FXTGAIcon(){} private: FXTGAIcon(const FXTGAIcon&); FXTGAIcon &operator=(const FXTGAIcon&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct icon from memory stream formatted in TARGA format FXTGAIcon(FXApp* a,const FXuchar *pix=nullptr,FXColor clr=FXRGB(192,192,192),FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in TARGA format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in TARGA format virtual FXbool loadPixels(FXStream& store); /// Destroy icon virtual ~FXTGAIcon(); }; #ifndef FXLOADTGA #define FXLOADTGA /** * Check if stream contains a TARGA, return true if so. */ extern FXAPI FXbool fxcheckTGA(FXStream& store); /** * Load an TARGA file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadTGA(FXStream& store,FXColor*& data,FXint& width,FXint& height); /** * Save an TARGA file to a stream. */ extern FXAPI FXbool fxsaveTGA(FXStream& store,const FXColor *data,FXint width,FXint height); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXTGAImage.h000066400000000000000000000056531455751074500224570ustar00rootroot00000000000000/******************************************************************************** * * * T A R G A I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 2001,2022 by Janusz Ganczarski. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTGAIMAGE_H #define FXTGAIMAGE_H #ifndef FXIMAGE_H #include "FXImage.h" #endif namespace FX { /// TARGA graphics file class FXAPI FXTGAImage : public FXImage { FXDECLARE(FXTGAImage) protected: FXTGAImage(){} private: FXTGAImage(const FXTGAImage&); FXTGAImage &operator=(const FXTGAImage&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct image from memory stream formatted in TARGA file FXTGAImage(FXApp* a,const FXuchar *pix=nullptr,FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in TARGA file virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in TARGA format virtual FXbool loadPixels(FXStream& store); /// Destroy image virtual ~FXTGAImage(); }; #ifndef FXLOADTGA #define FXLOADTGA /** * Check if stream contains a TARGA, return true if so. */ extern FXAPI FXbool fxcheckTGA(FXStream& store); /** * Load an TARGA file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadTGA(FXStream& store,FXColor*& data,FXint& width,FXint& height); /** * Save an TARGA file to a stream. */ extern FXAPI FXbool fxsaveTGA(FXStream& store,const FXColor *data,FXint width,FXint height); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXTIFIcon.h000066400000000000000000000063611455751074500223310ustar00rootroot00000000000000/******************************************************************************** * * * T I F F I c o n O b j e c t * * * ********************************************************************************* * Copyright (C) 2001,2022 Eric Gillet. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTIFICON_H #define FXTIFICON_H #ifndef FXICON_H #include "FXIcon.h" #endif namespace FX { /// TIFF Icon class class FXAPI FXTIFIcon : public FXIcon { FXDECLARE(FXTIFIcon) protected: FXushort codec; protected: FXTIFIcon(){} private: FXTIFIcon(const FXTIFIcon&); FXTIFIcon &operator=(const FXTIFIcon&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct an icon from memory stream formatted in TIFF format FXTIFIcon(FXApp *a,const FXuchar *pix=nullptr,FXColor clr=FXRGB(192,192,192),FXuint opts=0,FXint w=1,FXint h=1); /// True if format is supported static const FXbool supported; /// Set codec to save with void setCodec(FXuint c){ codec=c; } /// Get codec setting FXuint getCodec() const { return codec; } /// Save pixels into stream in TIFF format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in TIFF format virtual FXbool loadPixels(FXStream& store); /// Destroy virtual ~FXTIFIcon(); }; #ifndef FXLOADTIF #define FXLOADTIF /** * Check if stream contains a TIFF, return true if so. */ extern FXAPI FXbool fxcheckTIF(FXStream& store); /** * Load an TIFF (Tagged Image File Format) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadTIF(FXStream& store,FXColor*& data,FXint& width,FXint& height,FXushort& codec); /** * Save an TIFF (Tagged Image File Format) file to a stream. */ extern FXAPI FXbool fxsaveTIF(FXStream& store,const FXColor* data,FXint width,FXint height,FXushort codec); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXTIFImage.h000066400000000000000000000063421455751074500224620ustar00rootroot00000000000000/******************************************************************************** * * * T I F F I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 2001,2022 Eric Gillet. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTIFIMAGE_H #define FXTIFIMAGE_H #ifndef FXIMAGE_H #include "FXImage.h" #endif namespace FX { /// TIFF Image class class FXAPI FXTIFImage : public FXImage { FXDECLARE(FXTIFImage) protected: FXushort codec; protected: FXTIFImage(){} private: FXTIFImage(const FXTIFImage&); FXTIFImage &operator=(const FXTIFImage&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct an image from memory stream formatted in TIFF format FXTIFImage(FXApp *a,const FXuchar *pix=nullptr,FXuint opts=0,FXint w=1,FXint h=1); /// True if format is supported static const FXbool supported; /// Set codec to save with void setCodec(FXuint c){ codec=c; } /// Get codec setting FXuint getCodec() const { return codec; } /// Load pixels into stream in TIFF format virtual FXbool loadPixels(FXStream& store); /// Save pixels from stream in TIFF format virtual FXbool savePixels(FXStream& store) const; /// Destroy virtual ~FXTIFImage(); }; #ifndef FXLOADTIF #define FXLOADTIF /** * Check if stream contains a TIFF, return true if so. */ extern FXAPI FXbool fxcheckTIF(FXStream& store); /** * Load an TIFF (Tagged Image File Format) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadTIF(FXStream& store,FXColor*& data,FXint& width,FXint& height,FXushort& codec); /** * Save an TIFF (Tagged Image File Format) file to a stream. */ extern FXAPI FXbool fxsaveTIF(FXStream& store,const FXColor* data,FXint width,FXint height,FXushort codec); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXTabBar.h000066400000000000000000000121621455751074500222250ustar00rootroot00000000000000/******************************************************************************** * * * T a b B a r W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTABBAR_H #define FXTABBAR_H #ifndef FXPACKER_H #include "FXPacker.h" #endif namespace FX { /// Tab Book options enum { TABBOOK_TOPTABS = 0, /// Tabs on top (default) TABBOOK_BOTTOMTABS = 0x00020000, /// Tabs on bottom TABBOOK_SIDEWAYS = 0x00040000, /// Tabs on left TABBOOK_LEFTTABS = TABBOOK_SIDEWAYS|TABBOOK_TOPTABS, /// Tabs on left TABBOOK_RIGHTTABS = TABBOOK_SIDEWAYS|TABBOOK_BOTTOMTABS, /// Tabs on right TABBOOK_NORMAL = TABBOOK_TOPTABS /// Normal tabs }; /** * The tab bar layout manager arranges tab items side by side, * and raises the active tab item above the neighboring tab items. * In a the horizontal arrangement, the tab bar can have the tab * items on the top or on the bottom. In the vertical arrangement, * the tabs can be on the left or on the right. * When one of the tab items is pressed, the tab bar's setCurrent() * is called with notify=true. Thus causes the tab bar to send a * SEL_COMMAND message to its target, with the currently active * tab index in the void pointer. */ class FXAPI FXTabBar : public FXPacker { FXDECLARE(FXTabBar) protected: FXint current; // Current tab index FXint shift; // Shift amount protected: FXTabBar(){} private: FXTabBar(const FXTabBar&); FXTabBar& operator=(const FXTabBar&); public: long onPaint(FXObject*,FXSelector,void*); long onFocusNext(FXObject*,FXSelector,void*); long onFocusPrev(FXObject*,FXSelector,void*); long onFocusUp(FXObject*,FXSelector,void*); long onFocusDown(FXObject*,FXSelector,void*); long onFocusLeft(FXObject*,FXSelector,void*); long onFocusRight(FXObject*,FXSelector,void*); long onCmdOpenItem(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdOpen(FXObject*,FXSelector,void*); long onUpdOpen(FXObject*,FXSelector,void*); public: enum { ID_OPEN_ITEM=FXPacker::ID_LAST, /// Sent from one of the FXTabItems ID_OPEN_FIRST, /// Switch to panel ID_OPEN_FIRST+i ID_OPEN_SECOND, ID_OPEN_THIRD, ID_OPEN_FOURTH, ID_OPEN_FIFTH, ID_OPEN_SIXTH, ID_OPEN_SEVENTH, ID_OPEN_EIGHTH, ID_OPEN_NINETH, ID_OPEN_TENTH, ID_OPEN_LAST=ID_OPEN_FIRST+100, ID_LAST }; public: /// Construct a tab bar FXTabBar(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=TABBOOK_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_SPACING,FXint pr=DEFAULT_SPACING,FXint pt=DEFAULT_SPACING,FXint pb=DEFAULT_SPACING); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Perform layout virtual void layout(); /** * Change currently active tab item; this raises the active tab item * slightly above the neighboring tab items. If notify=true then the * tab bar will also send a SEL_COMMAND message to its target, containing * the currently active tab index in the void pointer. */ virtual void setCurrent(FXint index,FXbool notify=false); /// Return the currently active tab item FXint getCurrent() const { return current; } /// Return tab bar style FXuint getTabStyle() const; /// Change tab tab style void setTabStyle(FXuint style); /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXTabBook.h000066400000000000000000000076501455751074500224210ustar00rootroot00000000000000/******************************************************************************** * * * T a b B o o k W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTABBOOK_H #define FXTABBOOK_H #ifndef FXTABBAR_H #include "FXTabBar.h" #endif namespace FX { /** * The tab book layout manager arranges pairs of children; * the even numbered children (0,2,4,...) are usually tab items, * and are placed on the top. The odd numbered children are * usually layout managers, and are placed below; all the odd * numbered children are placed on top of each other, similar * to the switcher widget. When the user presses one of the * tab items, the tab item is raised above the neighboring tabs, * and the corresponding panel is raised to the top. * Thus, a tab book can be used to present many GUI controls * in a small space by placing several panels on top of each * other and using tab items to select the desired panel. * When one of the tab items is pressed, the tab book's setCurrent() * is called with notify=true. Thus causes the tab book to send a * SEL_COMMAND message to its target, with the currently active * tab index in the void pointer. */ class FXAPI FXTabBook : public FXTabBar { FXDECLARE(FXTabBook) protected: FXTabBook(){} private: FXTabBook(const FXTabBook&); FXTabBook& operator=(const FXTabBook&); public: long onPaint(FXObject*,FXSelector,void*); long onFocusNext(FXObject*,FXSelector,void*); long onFocusPrev(FXObject*,FXSelector,void*); long onFocusUp(FXObject*,FXSelector,void*); long onFocusDown(FXObject*,FXSelector,void*); long onFocusLeft(FXObject*,FXSelector,void*); long onFocusRight(FXObject*,FXSelector,void*); long onCmdOpenItem(FXObject*,FXSelector,void*); public: /// Construct tab book FXTabBook(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=TABBOOK_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_SPACING,FXint pr=DEFAULT_SPACING,FXint pt=DEFAULT_SPACING,FXint pb=DEFAULT_SPACING); /** * Change currently active tab item; this raises the active tab item * slightly above the neighboring tab items. If notify=true then the * tab bar will also send a SEL_COMMAND message to its target, containing * the currently active tab index in the void pointer. */ virtual void setCurrent(FXint index,FXbool notify=false); /// Perform layout virtual void layout(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXTabItem.h000066400000000000000000000075001455751074500224170ustar00rootroot00000000000000/******************************************************************************** * * * T a b I t e m W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTABITEM_H #define FXTABITEM_H #ifndef FXLABEL_H #include "FXLabel.h" #endif namespace FX { /// Tab Item orientations which affect border enum { TAB_TOP = 0, // Top side tabs TAB_LEFT = 0x00800000, // Left side tabs TAB_RIGHT = 0x01000000, // Right side tabs TAB_BOTTOM = 0x01800000, // Bottom side tabs TAB_TOP_NORMAL = JUSTIFY_NORMAL|ICON_BEFORE_TEXT|TAB_TOP|FRAME_RAISED|FRAME_THICK, TAB_BOTTOM_NORMAL= JUSTIFY_NORMAL|ICON_BEFORE_TEXT|TAB_BOTTOM|FRAME_RAISED|FRAME_THICK, TAB_LEFT_NORMAL = JUSTIFY_LEFT|JUSTIFY_CENTER_Y|ICON_BEFORE_TEXT|TAB_LEFT|FRAME_RAISED|FRAME_THICK, TAB_RIGHT_NORMAL = JUSTIFY_LEFT|JUSTIFY_CENTER_Y|ICON_BEFORE_TEXT|TAB_RIGHT|FRAME_RAISED|FRAME_THICK }; class FXTabBar; /** * A tab item is placed in a tab bar or tab book. * When selected, the tab item sends a message to its * parent, and causes itself to become the active tab, * and raised slightly above the other tabs. * In the tab book, activating a tab item also causes * the corresponding panel to be raised to the top. */ class FXAPI FXTabItem : public FXLabel { FXDECLARE(FXTabItem) protected: FXTabItem(){} private: FXTabItem(const FXTabItem&); FXTabItem& operator=(const FXTabItem&); public: long onPaint(FXObject*,FXSelector,void*); long onFocusIn(FXObject*,FXSelector,void*); long onFocusOut(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onHotKeyPress(FXObject*,FXSelector,void*); long onHotKeyRelease(FXObject*,FXSelector,void*); public: /// Construct a tab item FXTabItem(FXTabBar* p,const FXString& text,FXIcon* ic=0,FXuint opts=TAB_TOP_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Returns true because a tab item can receive focus virtual FXbool canFocus() const; /// Return current tab item orientation FXuint getTabOrientation() const; /// Change tab item orientation void setTabOrientation(FXuint style); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXTable.h000066400000000000000000001143011455751074500221170ustar00rootroot00000000000000/******************************************************************************** * * * T a b l e W i d g e t * * * ********************************************************************************* * Copyright (C) 1999,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTABLE_H #define FXTABLE_H #ifndef FXSCROLLAREA_H #include "FXScrollArea.h" #endif namespace FX { class FXIcon; class FXFont; class FXTable; class FXHeader; class FXButton; /// Default cell margin enum { DEFAULT_MARGIN = 2 }; /// Table options enum { TABLE_COL_SIZABLE = 0x00100000, /// Columns are resizable TABLE_ROW_SIZABLE = 0x00200000, /// Rows are resizable TABLE_NO_COLSELECT = 0x00400000, /// Disallow column selections TABLE_NO_ROWSELECT = 0x00800000, /// Disallow row selections TABLE_READONLY = 0x01000000 /// Table is NOT editable }; /// Position in table struct FXTablePos { FXint row; FXint col; }; /// Range of table cells struct FXTableRange { FXTablePos fm; FXTablePos to; }; /// Item in table class FXAPI FXTableItem : public FXObject { FXDECLARE(FXTableItem) friend class FXTable; protected: FXString label; FXString tip; FXIcon *icon; FXptr data; FXuint state; private: FXTableItem(const FXTableItem&); FXTableItem& operator=(const FXTableItem&); protected: FXTableItem():icon(nullptr),data(nullptr),state(0){} FXint textWidth(const FXTable* table) const; FXint textHeight(const FXTable* table) const; virtual void draw(const FXTable* table,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; virtual void drawBorders(const FXTable* table,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; virtual void drawContent(const FXTable* table,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; virtual void drawPattern(const FXTable* table,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; virtual void drawBackground(const FXTable* table,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; public: enum{ SELECTED = 0x00000001, /// Selected FOCUS = 0x00000002, /// Focus DISABLED = 0x00000004, /// Disabled DRAGGABLE = 0x00000008, /// Draggable RESERVED1 = 0x00000010, /// Reserved RESERVED2 = 0x00000020, /// Reserved ICONOWNED = 0x00000040, /// Icon owned by table item RIGHT = 0x00002000, /// Align on right (default) LEFT = 0x00004000, /// Align on left CENTER_X = 0, /// Aling centered horizontally TOP = 0x00008000, /// Align on top BOTTOM = 0x00010000, /// Align on bottom CENTER_Y = 0, /// Aling centered vertically (default) BEFORE = 0x00020000, /// Icon before the text AFTER = 0x00040000, /// Icon after the text ABOVE = 0x00080000, /// Icon above the text BELOW = 0x00100000, /// Icon below the text LBORDER = 0x00200000, /// Draw left border RBORDER = 0x00400000, /// Draw right border TBORDER = 0x00800000, /// Draw top border BBORDER = 0x01000000 /// Draw bottom border }; public: /// Construct new table item FXTableItem(const FXString& text,FXIcon* ic=nullptr,FXptr ptr=nullptr):label(text),icon(ic),data(ptr),state(RIGHT|CENTER_Y){} /// Change item's text label virtual void setText(const FXString& txt); /// Return item's text label virtual FXString getText() const { return label; } /// Change item's icon, deleting the old icon if it was owned virtual void setIcon(FXIcon* icn,FXbool owned=false); /// Return item's icon virtual FXIcon* getIcon() const { return icon; } /// Set the tool tip message for this item void setTipText(const FXString& text){ tip=text; } /// Get the tool tip message for this item const FXString& getTipText() const { return tip; } /// Change item's user data void setData(FXptr ptr){ data=ptr; } /// Get item's user data FXptr getData() const { return data; } /// Make item draw as focused virtual void setFocus(FXbool focus); /// Return true if item has focus FXbool hasFocus() const { return (state&FOCUS)!=0; } /// Select item virtual void setSelected(FXbool selected); /// Return true if this item is selected FXbool isSelected() const { return (state&SELECTED)!=0; } /// Enable or disable item virtual void setEnabled(FXbool enabled); /// Return true if this item is enabled FXbool isEnabled() const { return (state&DISABLED)==0; } /// Make item draggable virtual void setDraggable(FXbool draggable); /// Return true if this item is draggable FXbool isDraggable() const { return (state&DRAGGABLE)!=0; } /// Change item content justification virtual void setJustify(FXuint justify=RIGHT|CENTER_Y); /// Return item content justification FXuint getJustify() const { return state&(RIGHT|LEFT|TOP|BOTTOM); } /// Change item icon position virtual void setIconPosition(FXuint mode); /// Return item icon position FXuint getIconPosition() const { return state&(BEFORE|AFTER|ABOVE|BELOW); } /// Change item borders virtual void setBorders(FXuint borders=0); /// Return item borders FXuint getBorders() const { return state&(LBORDER|RBORDER|TBORDER|BBORDER); } /// Change item background stipple virtual void setStipple(FXStipplePattern pattern); /// Return item background stipple FXStipplePattern getStipple() const; /// Create input control for editing this item virtual FXWindow* getControlFor(FXTable* table); /// Set value from input control virtual void setFromControl(FXWindow* control); /// Return width of item virtual FXint getWidth(const FXTable* table) const; /// Return height of item virtual FXint getHeight(const FXTable* table) const; /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Destroy server-side resources virtual void destroy(); /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Delete item and free icon if owned virtual ~FXTableItem(); }; /// Combobox Item class FXAPI FXComboTableItem : public FXTableItem { FXDECLARE(FXComboTableItem) protected: FXString selections; private: FXComboTableItem(const FXComboTableItem&); FXComboTableItem& operator=(const FXComboTableItem&); protected: FXComboTableItem(){} public: /// Construct new table item FXComboTableItem(const FXString& text,FXIcon* ic=nullptr,void* ptr=nullptr); /// Create input control for editing this item virtual FXWindow *getControlFor(FXTable* table); /// Set value from input control virtual void setFromControl(FXWindow *control); /// Set selections as newline-separated strings void setSelections(const FXString& strings); /// Return selections const FXString& getSelections() const { return selections; } }; /** * The Table widget displays a table of items, each with a text and optional * icon. A column Header control provide captions for each column, and a row * Header control provides captions for each row. Columns are resizable by * means of the column Header control if the TABLE_COL_SIZABLE option is passed. * Likewise, rows in the table are resizable if the TABLE_ROW_SIZABLE option is * specified. An entire row (column) can be selected by clicking on the a button * in the row (column) Header control. Passing TABLE_NO_COLSELECT disables column * selection, and passing TABLE_NO_ROWSELECT disables column selection. * When setColumnRenumbering() is called, column captions are automatically renumbered * when columns are added or removed, according to the label computed by the renumbering * function. Likewise, setRowRenumbering() will cause row numbers to be recalculated * automatically when rows are added or removed. The column and row renumbering * functions to not have to be the same. Passing a NULL renumbering function will * turn automatic renumbering off; this is the default. * To disable editing of cells in the table, the TABLE_READONLY can be specified. * Cells in the table may or may not have items in them. When populating a cell * for the first time, an item will be automatically created if necessary. Thus, * a cell in the table takes no space unless it has actual contents. * Moreover, a contiguous, rectangular region of cells in the table may refer to * one single item; in that case, the item will be stretched to cover all the * cells in the region, and no grid lines will be drawn interior to the spanning * item. * The Table widget issues SEL_SELECTED or SEL_DESELECTED when cells are selected * or deselected, respectively. The table position affected is passed along as the * 3rd parameter of these messages. * Whenever the current (focus) item is changed, a SEL_CHANGED message is sent with * the new table position as a parameter. * When items are added to the table, a SEL_INSERTED message is sent, with the table * range of the newly added cells as the parameter in the message. * When items are removed from the table, a SEL_DELETED message is sent prior to the * removal of the items, and the table range of the removed cells is passed as a parameter. * A SEL_REPLACED message is sent when the contents of a cell are changed, either through * editing or by other means; the parameter is the range of affected cells. This message * is sent prior to the change. * SEL_CLICKED, SEL_DOUBLECLICKED, and SEL_TRIPLECLICKED messages are sent when a cell * is clicked, double-clicked, or triple-clicked, respectively. * A SEL_COMMAND is sent when an enabled item is clicked inside the table. */ class FXAPI FXTable : public FXScrollArea { FXDECLARE(FXTable) protected: FXHeader *colHeader; // Column header FXHeader *rowHeader; // Row header FXButton *cornerButton; // Corner button FXTableItem **cells; // Cells FXWindow *editor; // Editor widget FXFont *font; // Font FXint nrows; // Number of rows FXint ncols; // Number of columns FXint visiblerows; // Visible rows FXint visiblecols; // Visible columns FXint margintop; // Margin top FXint marginbottom; // Margin bottom FXint marginleft; // Margin left FXint marginright; // Margin right FXColor textColor; // Normal text color FXColor baseColor; // Base color FXColor hiliteColor; // Highlight color FXColor shadowColor; // Shadow color FXColor borderColor; // Border color FXColor selbackColor; // Select background color FXColor seltextColor; // Select text color FXColor gridColor; // Grid line color FXColor stippleColor; // Stipple color FXColor cellBorderColor; // Cell border color FXint cellBorderWidth; // Cell border width FXColor cellBackColor[2][2]; // Row/Column even/odd background color FXint defColWidth; // Default column width [if uniform columns] FXint defRowHeight; // Default row height [if uniform rows] FXTablePos current; // Current position FXTablePos anchor; // Anchor position FXTableRange input; // Input cell FXTableRange selection; // Range of selected cells FXString clipped; // Clipped text FXbool hgrid; // Horizontal grid lines shown FXbool vgrid; // Vertical grid lines shown FXuchar mode; // Mode widget is in FXint grabx; // Grab point x FXint graby; // Grab point y FXint rowcol; // Row or column being resized FXString help; public: static FXDragType csvType; static const FXchar csvTypeName[]; protected: FXTable(); virtual void moveContents(FXint x,FXint y); virtual void drawCell(FXDC& dc,FXint sr,FXint er,FXint sc,FXint ec); virtual void drawRange(FXDC& dc,FXint rlo,FXint rhi,FXint clo,FXint chi); virtual void drawHGrid(FXDC& dc,FXint rlo,FXint rhi,FXint clo,FXint chi); virtual void drawVGrid(FXDC& dc,FXint rlo,FXint rhi,FXint clo,FXint chi); virtual void drawContents(FXDC& dc,FXint x,FXint y,FXint w,FXint h); virtual FXTableItem* createItem(const FXString& text,FXIcon* icon,void* ptr); virtual FXWindow* getControlForItem(FXint r,FXint c); virtual void setItemFromControl(FXint r,FXint c,FXWindow* control); protected: enum { MOUSE_NONE, // Nop MOUSE_SCROLL, // Scrolling MOUSE_DRAG, // Dragging MOUSE_SELECT // Selecting }; private: FXTable(const FXTable&); FXTable& operator=(const FXTable&); public: long onPaint(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onFocusIn(FXObject*,FXSelector,void*); long onFocusOut(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onRightBtnPress(FXObject*,FXSelector,void*); long onRightBtnRelease(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onSelectionLost(FXObject*,FXSelector,void*); long onSelectionGained(FXObject*,FXSelector,void*); long onSelectionRequest(FXObject*,FXSelector,void* ptr); long onClipboardLost(FXObject*,FXSelector,void*); long onClipboardGained(FXObject*,FXSelector,void*); long onClipboardRequest(FXObject*,FXSelector,void*); long onAutoScroll(FXObject*,FXSelector,void*); long onCommand(FXObject*,FXSelector,void*); long onClicked(FXObject*,FXSelector,void*); long onDoubleClicked(FXObject*,FXSelector,void*); long onTripleClicked(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onTipTimer(FXObject*,FXSelector,void*); long onCmdToggleEditable(FXObject*,FXSelector,void*); long onUpdToggleEditable(FXObject*,FXSelector,void*); // Visual characteristics long onCmdHorzGrid(FXObject*,FXSelector,void*); long onUpdHorzGrid(FXObject*,FXSelector,void*); long onCmdVertGrid(FXObject*,FXSelector,void*); long onUpdVertGrid(FXObject*,FXSelector,void*); // Row/Column manipulations long onCmdDeleteColumn(FXObject*,FXSelector,void*); long onUpdDeleteColumn(FXObject*,FXSelector,void*); long onCmdDeleteRow(FXObject*,FXSelector,void*); long onUpdDeleteRow(FXObject*,FXSelector,void*); long onCmdInsertColumn(FXObject*,FXSelector,void*); long onUpdInsertColumn(FXObject*,FXSelector,void*); long onCmdInsertRow(FXObject*,FXSelector,void*); long onUpdInsertRow(FXObject*,FXSelector,void*); // Movement long onCmdMoveRight(FXObject*,FXSelector,void*); long onCmdMoveLeft(FXObject*,FXSelector,void*); long onCmdMoveUp(FXObject*,FXSelector,void*); long onCmdMoveDown(FXObject*,FXSelector,void*); long onCmdMoveHome(FXObject*,FXSelector,void*); long onCmdMoveEnd(FXObject*,FXSelector,void*); long onCmdMoveTop(FXObject*,FXSelector,void*); long onCmdMoveBottom(FXObject*,FXSelector,void*); long onCmdMovePageDown(FXObject*,FXSelector,void*); long onCmdMovePageUp(FXObject*,FXSelector,void*); // Mark and extend long onCmdMark(FXObject*,FXSelector,void*); long onCmdExtend(FXObject*,FXSelector,void*); // Changing Selection long onUpdSelectCell(FXObject*,FXSelector,void*); long onCmdSelectCell(FXObject*,FXSelector,void*); long onUpdSelectRow(FXObject*,FXSelector,void*); long onCmdSelectRow(FXObject*,FXSelector,void*); long onUpdSelectColumn(FXObject*,FXSelector,void*); long onCmdSelectColumn(FXObject*,FXSelector,void*); long onCmdSelectRowIndex(FXObject*,FXSelector,void*); long onCmdSelectColumnIndex(FXObject*,FXSelector,void*); long onUpdSelectAll(FXObject*,FXSelector,void*); long onCmdSelectAll(FXObject*,FXSelector,void*); long onUpdDeselectAll(FXObject*,FXSelector,void*); long onCmdDeselectAll(FXObject*,FXSelector,void*); // Manipulation Selection long onCmdCutSel(FXObject*,FXSelector,void*); long onCmdCopySel(FXObject*,FXSelector,void*); long onCmdDeleteSel(FXObject*,FXSelector,void*); long onCmdPasteSel(FXObject*,FXSelector,void*); long onUpdHaveSelection(FXObject*,FXSelector,void*); // Edit control long onCmdStartInput(FXObject*,FXSelector,void*); long onUpdStartInput(FXObject*,FXSelector,void*); long onCmdAcceptInput(FXObject*,FXSelector,void*); long onUpdAcceptInput(FXObject*,FXSelector,void*); long onCmdCancelInput(FXObject*,FXSelector,void*); public: enum { ID_HORZ_GRID=FXScrollArea::ID_LAST, ID_VERT_GRID, ID_TOGGLE_EDITABLE, ID_DELETE_COLUMN, ID_DELETE_ROW, ID_INSERT_COLUMN, ID_INSERT_ROW, ID_SELECT_COLUMN_INDEX, ID_SELECT_ROW_INDEX, ID_SELECT_COLUMN, ID_SELECT_ROW, ID_SELECT_CELL, ID_SELECT_ALL, ID_DESELECT_ALL, ID_MOVE_LEFT, ID_MOVE_RIGHT, ID_MOVE_UP, ID_MOVE_DOWN, ID_MOVE_HOME, ID_MOVE_END, ID_MOVE_TOP, ID_MOVE_BOTTOM, ID_MOVE_PAGEDOWN, ID_MOVE_PAGEUP, ID_START_INPUT, ID_CANCEL_INPUT, ID_ACCEPT_INPUT, ID_MARK, ID_EXTEND, ID_CUT_SEL, ID_COPY_SEL, ID_PASTE_SEL, ID_DELETE_SEL, ID_LAST }; public: /** * Construct a new table. * The table is initially empty, and reports a default size based on * the scroll areas's scrollbar placement policy. */ FXTable(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_MARGIN,FXint pr=DEFAULT_MARGIN,FXint pt=DEFAULT_MARGIN,FXint pb=DEFAULT_MARGIN); /// Create the server-side resources virtual void create(); /// Detach the server-side resources virtual void detach(); /// Computes content width virtual FXint getContentWidth(); /// Computes content height virtual FXint getContentHeight(); /// Return visible area x position virtual FXint getVisibleX() const; /// Return visible area y position virtual FXint getVisibleY() const; /// Return visible area width virtual FXint getVisibleWidth() const; /// Return visible area height virtual FXint getVisibleHeight() const; /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Perform layout virtual void layout(); /// Mark this window's layout as dirty virtual void recalc(); /// Table widget can receive focus virtual FXbool canFocus() const; /// Move the focus to this window virtual void setFocus(); /// Remove the focus from this window virtual void killFocus(); /// Return button in the top/left corner FXButton* getCornerButton() const { return cornerButton; } /// Return column header control FXHeader* getColumnHeader() const { return colHeader; } /// Return row header control FXHeader* getRowHeader() const { return rowHeader; } /// Change visible rows void setVisibleRows(FXint nvrows); /// return number of visible rows FXint getVisibleRows() const { return visiblerows; } /// Change visible columns void setVisibleColumns(FXint nvcols); /// Return number of visible columns FXint getVisibleColumns() const { return visiblecols; } /// Return true if table is editable FXbool isEditable() const; /// Set editable flag void setEditable(FXbool edit=true); /// Show or hide horizontal grid void showHorzGrid(FXbool on=true); /// Is horizontal grid shown FXbool isHorzGridShown() const { return hgrid; } /// Show or hide vertical grid void showVertGrid(FXbool on=true); /// Is vertical grid shown FXbool isVertGridShown() const { return vgrid; } /// Get number of rows FXint getNumRows() const { return nrows; } /// Get number of columns FXint getNumColumns() const { return ncols; } /// Change top cell margin void setMarginTop(FXint pt); /// Return top cell margin FXint getMarginTop() const { return margintop; } /// Change bottom cell margin void setMarginBottom(FXint pb); /// Return bottom cell margin FXint getMarginBottom() const { return marginbottom; } /// Change left cell margin void setMarginLeft(FXint pl); /// Return left cell margin FXint getMarginLeft() const { return marginleft; } /// Change right cell margin void setMarginRight(FXint pr); /// Return right cell margin FXint getMarginRight() const { return marginright; } /** * Start input mode for the cell at the given position. * An input control is created which is used to edit the cell; * it is filled by the original item's contents if the cell contained * an item. You can enter input mode also by sending the table an * ID_START_INPUT message. * Return true if editing of the cell has been started. */ virtual FXbool startInput(FXint row,FXint col); /** * Cancel input mode. The input control is immediately deleted * and the cell will retain its old value. You can also cancel * input mode by sending the table an ID_CANCEL_INPUT message. * Return true if editing of the cell has been cancelled. */ virtual FXbool cancelInput(); /** * End input mode and accept the new value from the control. * The item in the cell will be set to the value from the control, * and the control will be deleted. If true is passed, a SEL_REPLACED * callback will be generated to signify to the target that this call * has a new value. You can also accept the input by sending the table * an ID_ACCEPT_INPUT message. * Return true if the new value of the cell has been accepted. */ virtual FXbool acceptInput(FXbool notify=false); /** * Determine column containing x. * Returns -1 if x left of first column, and ncols if x right of last column; * otherwise, returns column in table containing x. */ FXint colAtX(FXint x) const; /** * Determine row containing y. * Returns -1 if y above first row, and nrows if y below last row; * otherwise, returns row in table containing y. */ FXint rowAtY(FXint y) const; /// Replace the item with a [possibly subclassed] item void setItem(FXint row,FXint col,FXTableItem* item,FXbool notify=false); /// Return the item at the given index FXTableItem *getItem(FXint row,FXint col) const; /// Set the table size to nr rows and nc columns; all existing items will be removed virtual void setTableSize(FXint nr,FXint nc,FXbool notify=false); /// Insert new row virtual void insertRows(FXint row,FXint nr=1,FXbool notify=false); /// Insert new column virtual void insertColumns(FXint col,FXint nc=1,FXbool notify=false); /// Remove rows of cells virtual void removeRows(FXint row,FXint nr=1,FXbool notify=false); /// Remove column of cells virtual void removeColumns(FXint col,FXint nc=1,FXbool notify=false); /// Extract item from table virtual FXTableItem* extractItem(FXint row,FXint col,FXbool notify=false); /// Clear single cell virtual void removeItem(FXint row,FXint col,FXbool notify=false); /// Clear all cells in the given range virtual void removeRange(FXint startrow,FXint endrow,FXint startcol,FXint endcol,FXbool notify=false); /// Remove all items from table virtual void clearItems(FXbool notify=false); /// Scroll to make cell at row, col fully visible virtual void makePositionVisible(FXint row,FXint col); /// Return true if item partially visible FXbool isItemVisible(FXint row,FXint col) const; /** * Change column header height mode to fixed or variable. * In variable height mode, the column header will size to * fit the contents in it. In fixed mode, the size is * explicitly set using setColumnHeaderHeight(). * The default is to determine the column header height * based on the contents, using the LAYOUT_MIN_HEIGHT option. */ void setColumnHeaderMode(FXuint hint=LAYOUT_FIX_HEIGHT); /// Return column header height mode FXuint getColumnHeaderMode() const; /** * Change row header width mode to fixed or variable. * In variable width mode, the row header will size to * fit the contents in it. In fixed mode, the size is * explicitly set using setRowHeaderWidth(). * The default is to determine the column header height * based on the contents, using the LAYOUT_MIN_WIDTH option. */ void setRowHeaderMode(FXuint hint=LAYOUT_FIX_WIDTH); /// Return row header width mode FXuint getRowHeaderMode() const; /// Set column header font void setColumnHeaderFont(FXFont* fnt); /// Return column header font FXFont* getColumnHeaderFont() const; /// Set row header font void setRowHeaderFont(FXFont* fnt); /// Return row header font FXFont* getRowHeaderFont() const; /// Change column header height void setColumnHeaderHeight(FXint h); /// Return column header height FXint getColumnHeaderHeight() const; /// Change row header width void setRowHeaderWidth(FXint w); /// Return row header width FXint getRowHeaderWidth() const; /// Get X coordinate of column FXint getColumnX(FXint col) const; /// Get Y coordinate of row FXint getRowY(FXint row) const; /// Change column width virtual void setColumnWidth(FXint col,FXint cwidth); /// Get column width FXint getColumnWidth(FXint col) const; /// Change row height virtual void setRowHeight(FXint row,FXint rheight); /// Get row height FXint getRowHeight(FXint row) const; /// Change default column width void setDefColumnWidth(FXint cwidth); /// Get default column width FXint getDefColumnWidth() const { return defColWidth; } /// Change default row height void setDefRowHeight(FXint rheight); /// Get default row height FXint getDefRowHeight() const { return defRowHeight; } /// Return minimum row height FXint getMinRowHeight(FXint row) const; /// Return minimum column width FXint getMinColumnWidth(FXint col) const; /// Fit row heights to contents void fitRowsToContents(FXint row,FXint nr=1); /// Fit column widths to contents void fitColumnsToContents(FXint col,FXint nc=1); /// Change column header text void setColumnText(FXint col,const FXString& text); /// Return text of column header at index FXString getColumnText(FXint col) const; /// Change row header text void setRowText(FXint row,const FXString& text); /// Return text of row header at index FXString getRowText(FXint row) const; /// Change column header icon void setColumnIcon(FXint col,FXIcon* icon); /// Return icon of column header at index FXIcon* getColumnIcon(FXint col) const; /// Change row header icon void setRowIcon(FXint row,FXIcon* icon); /// Return icon of row header at index FXIcon* getRowIcon(FXint row) const; /// Change column header tip text void setColumnTipText(FXint col,const FXString& text); /// Return tip text of column header at index FXString getColumnTipText(FXint col) const; /// Change row header tip text void setRowTipText(FXint row,const FXString& text); /// Return tip text of row header at index FXString getRowTipText(FXint row) const; /// Change column header icon position, e.g. FXHeaderItem::BEFORE, etc. void setColumnIconPosition(FXint col,FXuint m); /// Return icon position of column header at index FXuint getColumnIconPosition(FXint col) const; /// Change row header icon position, e.g. FXHeaderItem::BEFORE, etc. void setRowIconPosition(FXint row,FXuint m); /// Return icon position of row header at index FXuint getRowIconPosition(FXint row) const; /// Change column header justify, e.g. FXHeaderItem::RIGHT, etc. void setColumnJustify(FXint col,FXuint justify); /// Return justify of column header at index FXuint getColumnJustify(FXint col) const; /// Change row header justify, e.g. FXHeaderItem::RIGHT, etc. void setRowJustify(FXint row,FXuint justify); /// Return justify of row header at index FXuint getRowJustify(FXint row) const; /// Modify cell text void setItemText(FXint row,FXint col,const FXString& text,FXbool notify=false); /// Return cell text FXString getItemText(FXint row,FXint col) const; /// Change tool tip message for item at index void setItemTipText(FXint row,FXint col,const FXString& text); /// Get tool tip message of item at index FXString getItemTipText(FXint row,FXint col) const; /// Modify cell icon, deleting the old icon if it was owned void setItemIcon(FXint row,FXint col,FXIcon* icon,FXbool owned=false,FXbool notify=false); /// Return cell icon FXIcon* getItemIcon(FXint row,FXint col) const; /// Change cell user-data void setItemData(FXint row,FXint col,FXptr ptr); /// Return cell user-data FXptr getItemData(FXint row,FXint col) const; /** * Extract cells from given range as text, each column separated by a string cs, * and each row separated by a string rs. */ void extractText(FXchar*& text,FXint& size,FXint startrow,FXint endrow,FXint startcol,FXint endcol,const FXchar* cs="\t",const FXchar* rs="\n") const; void extractText(FXString& text,FXint startrow,FXint endrow,FXint startcol,FXint endcol,const FXchar* cs="\t",const FXchar* rs="\n") const; /** * Overlay text over given cell range; the text is interpreted as * a number of columns separated by a character from the set cs, and * a number of rows separated by a character from the set rs. * Cells outside the given cell range are unaffected. */ void overlayText(FXint startrow,FXint endrow,FXint startcol,FXint endcol,const FXchar* text,FXint size,const FXchar* cs="\t,",const FXchar* rs="\n",FXbool notify=false); void overlayText(FXint startrow,FXint endrow,FXint startcol,FXint endcol,const FXString& text,const FXchar* cs="\t,",const FXchar* rs="\n",FXbool notify=false); /** * Determine the number of rows and columns in a block of text * where columns are separated by characters from the set cs, and rows * are separated by characters from the set rs. */ void countText(FXint& nr,FXint& nc,const FXchar* text,FXint size,const FXchar* cs="\t,",const FXchar* rs="\n") const; void countText(FXint& nr,FXint& nc,const FXString& text,const FXchar* cs="\t,",const FXchar* rs="\n") const; /// Reshape existing item at row, col to span over rows fr..lr, and over columns fc..lc virtual FXbool setSpanningRange(FXint row,FXint col,FXint fr,FXint lr,FXint fc,FXint lc,FXbool notify=false); /// Return spanning range of cell at row, col, rows fr..lr and columns fc..lc void getSpanningRange(FXint row,FXint col,FXint& fr,FXint& lr,FXint& fc,FXint& lc) const; /// Return true if its a spanning cell FXbool isItemSpanning(FXint row,FXint col) const; /// Return true if its a horizontally spanning cell FXbool isItemHorizontalSpanning(FXint row,FXint col) const; /// Return true if its a vertically spanning cell FXbool isItemVerticalSpanning(FXint row,FXint col) const; /// Repaint cells between grid lines sr,er and grid lines sc,ec void updateRange(FXint sr,FXint er,FXint sc,FXint ec) const; /// Repaint cell at row, col void updateItem(FXint row,FXint col) const; /// Enable item virtual FXbool enableItem(FXint row,FXint col); /// Disable item virtual FXbool disableItem(FXint row,FXint col); /// Is item enabled and editable FXbool isItemEnabled(FXint row,FXint col) const; /** * Change item justification. Horizontal justification is controlled by passing * FXTableItem::RIGHT, FXTableItem::LEFT, or FXTableItem::CENTER_X. * Vertical justification is controlled by FXTableItem::TOP, FXTableItem::BOTTOM, * or FXTableItem::CENTER_Y. * The default is a combination of FXTableItem::RIGHT and FXTableItem::CENTER_Y. */ void setItemJustify(FXint row,FXint col,FXuint justify); /// Return item justification FXuint getItemJustify(FXint row,FXint col) const; /** * Change relative position of icon and text of item. * Passing FXTableItem::BEFORE or FXTableItem::AFTER places the icon * before or after the text, and passing FXTableItem::ABOVE or * FXTableItem::BELOW places it above or below the text, respectively. * The default is 0 which places the text on top of the icon. */ void setItemIconPosition(FXint row,FXint col,FXuint m); /// Return relative icon and text position FXuint getItemIconPosition(FXint row,FXint col) const; /** * Change item borders style. Borders on each side of the item can be turned * controlled individually using FXTableItem::LBORDER, FXTableItem::RBORDER, * FXTableItem::TBORDER and FXTableItem::BBORDER. */ void setItemBorders(FXint row,FXint col,FXuint borders); /// Return item border style FXuint getItemBorders(FXint row,FXint col) const; /// Change item background stipple style void setItemStipple(FXint row,FXint col,FXStipplePattern pat); /// return item background stipple style FXStipplePattern getItemStipple(FXint row,FXint col) const; /// Change current item virtual void setCurrentItem(FXint row,FXint col,FXbool notify=false); /// Get row number of current item FXint getCurrentRow() const { return current.row; } /// Get column number of current item FXint getCurrentColumn() const { return current.col; } /// Is item current FXbool isItemCurrent(FXint row,FXint col) const; /// Change anchor item void setAnchorItem(FXint row,FXint col); /// Get row number of anchor item FXint getAnchorRow() const { return anchor.row; } /// Get column number of anchor item FXint getAnchorColumn() const { return anchor.col; } /// Get selection start row; returns -1 if no selection FXint getSelStartRow() const { return selection.fm.row; } /// Get selection start column; returns -1 if no selection FXint getSelStartColumn() const { return selection.fm.col; } /// Get selection end row; returns -1 if no selection FXint getSelEndRow() const { return selection.to.row; } /// Get selection end column; returns -1 if no selection FXint getSelEndColumn() const { return selection.to.col; } /// Is cell selected FXbool isItemSelected(FXint row,FXint col) const; /// Are all cells in the given row selected FXbool isRowSelected(FXint row) const; /// Are all cells int the given column selected FXbool isColumnSelected(FXint col) const; /// Is anything selected FXbool isAnythingSelected() const; /// Select single cell virtual FXbool selectCell(FXint row,FXint col,FXbool notify=false); /// Select a row virtual FXbool selectRow(FXint row,FXbool notify=false); /// Select a column virtual FXbool selectColumn(FXint col,FXbool notify=false); /// Select range rows nrlo..nrhi and columns nclo..nchi virtual FXbool selectRange(FXint nrlo,FXint nrhi,FXint nclo,FXint nchi,FXbool notify=false); /// Extend selection virtual FXbool extendSelection(FXint row,FXint col,FXbool notify=false); /// Kill selection virtual FXbool killSelection(FXbool notify=false); /// Change font void setFont(FXFont* fnt); /// Return current font FXFont* getFont() const { return font; } /// Obtain colors of various parts FXColor getTextColor() const { return textColor; } FXColor getBaseColor() const { return baseColor; } FXColor getHiliteColor() const { return hiliteColor; } FXColor getShadowColor() const { return shadowColor; } FXColor getBorderColor() const { return borderColor; } FXColor getSelBackColor() const { return selbackColor; } FXColor getSelTextColor() const { return seltextColor; } FXColor getGridColor() const { return gridColor; } FXColor getStippleColor() const { return stippleColor; } FXColor getCellBorderColor() const { return cellBorderColor; } /// Change colors of various parts void setTextColor(FXColor clr); void setBaseColor(FXColor clr); void setHiliteColor(FXColor clr); void setShadowColor(FXColor clr); void setBorderColor(FXColor clr); void setSelBackColor(FXColor clr); void setSelTextColor(FXColor clr); void setGridColor(FXColor clr); void setStippleColor(FXColor clr); void setCellBorderColor(FXColor clr); /// Change cell background color for even/odd rows/columns void setCellColor(FXint row,FXint col,FXColor clr); /// Obtain cell background color for even/odd rows/columns FXColor getCellColor(FXint row,FXint col) const; /// Change cell border width void setCellBorderWidth(FXint borderwidth); /// Return cell border width FXint getCellBorderWidth() const { return cellBorderWidth; } /// Change table style void setTableStyle(FXuint style); /// Return table style FXuint getTableStyle() const; /// Set column renumbering, see FXHeader void setColumnRenumbering(FXNumberingFunc func); /// Get column renumbering FXNumberingFunc getColumnRenumbering() const; /// Set row renumbering, see FXHeader void setRowRenumbering(FXNumberingFunc func); /// Get row renumbering FXNumberingFunc getRowRenumbering() const; /// Change help text void setHelpText(const FXString& text){ help=text; } const FXString& getHelpText() const { return help; } /// Serialize virtual void save(FXStream& store) const; virtual void load(FXStream& store); virtual ~FXTable(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXTaskGroup.h000066400000000000000000000110641455751074500230110ustar00rootroot00000000000000/******************************************************************************** * * * T a s k G r o u p C l a s s * * * ********************************************************************************* * Copyright (C) 2012,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTASKGROUP_H #define FXTASKGROUP_H namespace FX { class FXThreadPool; /** * An FXTaskGroup manages a number of tasks, executing on the associated FXThreadPool. * In a typical use, an FXTaskGroup is constructed on the stack of the calling function. * If an explicit FXThreadPool is passed to the constructor of the FXTaskGroup, this is * the FXThreadPool that will be used to execute the tasks. Otherwise, an instance of * FXThreadPool will be located through a thread-local variable from the calling thread. * This thread-local variable will be set if the calling thread is a worker thread from * the FXThreadPool, or is the thread that called start() on the FXThreadPool. * Tasks managed by the FXTaskGroup may be started at any time during the FXTaskGroup's * lifetime. However, the FXTaskGroup can not be destroyed until the last task in the * group has finished execution: the FXTaskGroup's destructor will wait until all tasks * (if any) have finished executing. * The calling thread can enter the task-processing loop in the FXThreadPool; it returns * when either the tasks from this FXTaskGroup have been completed (count reaching zero), * or when the task-queue is empty (in this case another thread may still be working on * a task from the FXTaskGroup). Thus, the calling thread should block on the completion * semaphore to ensure all tasks are completed. */ class FXAPI FXTaskGroup { private: class Task : public FXRunnable { private: FXTaskGroup *taskgroup; // Backlink to taskgroup FXRunnable *runnable; // Wrapped runnable private: Task(const Task&); Task &operator=(const Task&); public: Task(FXTaskGroup* g,FXRunnable *r); virtual FXint run(); virtual ~Task(); }; private: FXThreadPool *threadpool; // Thread pool used by task group FXCompletion completion; // Completion counter private: FXTaskGroup(const FXTaskGroup&); FXTaskGroup &operator=(const FXTaskGroup&); public: /** * Create new task group, using the calling thread's associated * thread pool. */ FXTaskGroup(); /** * Create new task group, using the given thread pool. */ FXTaskGroup(FXThreadPool* p); /** * Return threadpool. */ FXThreadPool* getThreadPool() const { return threadpool; } /** * Return number of tasks. */ FXuint getRunningTasks() const { return completion.count(); } /** * Start a task in this task group. */ FXbool execute(FXRunnable* task); /** * Start task in this task group, and then enter the task-processing * loop, returning when all tasks have been completed. * Return false if unable to start the task. */ FXbool executeAndWait(FXRunnable* task); /** * Wait until all tasks of this group have finished executing, then return. * The completion semaphore is reset after being signaled by the last completed * task. */ FXbool wait(); /** * Wait for the semaphore to be signaled, then destroy the task group. */ virtual ~FXTaskGroup(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXText.h000066400000000000000000001301511455751074500220150ustar00rootroot00000000000000/******************************************************************************** * * * M u l t i - L i n e T e x t W i d g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTEXT_H #define FXTEXT_H #ifndef FXSCROLLAREA_H #include "FXScrollArea.h" #endif namespace FX { /// Text widget options enum { TEXT_READONLY = 0x00100000, /// Text is NOT editable TEXT_WORDWRAP = 0x00200000, /// Wrap at word breaks TEXT_OVERSTRIKE = 0x00400000, /// Overstrike mode TEXT_FIXEDWRAP = 0x00800000, /// Fixed wrap columns TEXT_NO_TABS = 0x01000000, /// Insert spaces for tabs TEXT_AUTOINDENT = 0x02000000, /// Autoindent TEXT_SHOWACTIVE = 0x04000000, /// Show active line TEXT_SHOWMATCH = 0x08000000, /// Show matching brace }; /// Highlight style entry struct FXHiliteStyle { FXColor normalForeColor; /// Normal text foreground color FXColor normalBackColor; /// Normal text background color FXColor selectForeColor; /// Selected text foreground color FXColor selectBackColor; /// Selected text background color FXColor hiliteForeColor; /// Highlight text foreground color FXColor hiliteBackColor; /// Highlight text background color FXColor activeBackColor; /// Active text background color FXuint style; /// Highlight text style }; /** * Text mutation callback data passed with the SEL_INSERTED, * SEL_REPLACED, and SEL_DELETED messages; both old and new * text is available on behalf of the undo system as well as * syntax highlighting. */ struct FXTextChange { FXint pos; /// Position in buffer FXint ndel; /// Number characters deleted at position FXint nins; /// Number characters inserted at position const FXchar *del; /// Text deleted at position const FXchar *ins; /// Text inserted at position }; /** * Text selection data. * A range-selection is in effect when startpos * ********************************************************************************/ #ifndef FXTEXTCODEC_H #define FXTEXTCODEC_H #ifndef FXOBJECT_H #include "FXObject.h" #endif namespace FX { /** * Abstract base class for a stateless coder/decoder. */ class FXAPI FXTextCodec : public FXObject { FXDECLARE_ABSTRACT(FXTextCodec) public: /// Construct text codec FXTextCodec(){} /// Count utf8 bytes needed to convert multi-byte characters from src virtual FXint mb2utflen(const FXchar* src,FXint nsrc) const; /// Count utf8 bytes needed to convert multi-byte characters from src FXint mb2utflen(const FXString& src) const; /// Convert multi-byte characters from src to utf8 characters at dst virtual FXint mb2utf(FXchar* dst,FXint ndst,const FXchar* src,FXint nsrc) const; /// Convert multi-byte characters from src to utf8 characters at dst FXint mb2utf(FXchar* dst,FXint ndst,const FXchar* src) const; /// Convert multi-byte characters from src to utf8 characters at dst FXint mb2utf(FXchar* dst,FXint ndst,const FXString& src) const; /// Convert multi-byte characters from src to utf8 string FXString mb2utf(const FXchar* src,FXint nsrc) const; /// Convert multi-byte characters from src to utf8 string FXString mb2utf(const FXchar* src) const; /// Convert multi-byte string to utf8 string FXString mb2utf(const FXString& src) const; /// Convert multi-byte characters from src to single wide character virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; /// Count multi-byte characters characters needed to convert utf8 from src virtual FXint utf2mblen(const FXchar* src,FXint nsrc) const; /// Count multi-byte characters characters needed to convert utf8 from src virtual FXint utf2mblen(const FXString& src) const; /// Convert utf8 characters at src to multi-byte characters at dst virtual FXint utf2mb(FXchar* dst,FXint ndst,const FXchar* src,FXint nsrc) const; /// Convert utf8 characters at src to multi-byte characters at dst FXint utf2mb(FXchar* dst,FXint ndst,const FXchar* src) const; /// Convert utf8 characters at src to multi-byte characters at dst FXint utf2mb(FXchar* dst,FXint ndst,const FXString& src) const; /// Convert utf8 characters at src to multi-byte string FXString utf2mb(const FXchar* src,FXint nsrc) const; /// Convert utf8 characters at src to multi-byte string FXString utf2mb(const FXchar* src) const; /// Convert utf8 string to multi-byte string FXString utf2mb(const FXString& src) const; /// Convert single wide character to multi-byte characters at dst virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; /** * Return the Management Information Base (MIBenum) for the character set. */ virtual FXint mibEnum() const = 0; /** * Return name of the codec. */ virtual const FXchar* name() const = 0; /** * Return the IANA mime name for this codec; this is used for example * as "text/utf-8" in drag and drop protocols. */ virtual const FXchar* mimeName() const = 0; /** * Return NULL-terminated list of aliases for this codec. */ virtual const FXchar* const* aliases() const = 0; /// Destruct codec virtual ~FXTextCodec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXTextField.h000066400000000000000000000357711455751074500227750ustar00rootroot00000000000000/******************************************************************************** * * * T e x t F i e l d W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTEXTFIELD_H #define FXTEXTFIELD_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { /// Textfield styles enum { TEXTFIELD_PASSWD = 0x00080000, /// Password mode TEXTFIELD_INTEGER = 0x00100000, /// Integer mode TEXTFIELD_REAL = 0x00200000, /// Real mode TEXTFIELD_READONLY = 0x00400000, /// NOT editable TEXTFIELD_ENTER_ONLY = 0x00800000, /// Only callback when enter hit TEXTFIELD_LIMITED = 0x01000000, /// Limit entry to given number of columns TEXTFIELD_OVERSTRIKE = 0x02000000, /// Overstrike mode TEXTFIELD_AUTOGRAY = 0x04000000, /// Automatically gray out text field when not updated TEXTFIELD_AUTOHIDE = 0x08000000, /// Automatically hide text field when not updated TEXTFIELD_NORMAL = FRAME_SUNKEN|FRAME_THICK }; /** * A text field is a single-line text entry widget. * The text field widget supports clipboard for cut-and-paste * operations. * Text input may be constrained to a certain format; the built-in * capabilities support integer and real number entry constraints; * additional constraints on the input may be implemented by intercepting * the SEL_VERIFY message; a custom handler should examine the tentative * input string passed as type const FXchar* in the message data, and return * a value of "0" if the new input is accepted. * During text entry, the text field sends a SEL_CHANGED message to its target, * with the message data set to the current text value of type const FXchar*. * When the text is accepted by hitting ENTER, the SEL_COMMAND message is sent. * The text field also sends SEL_COMMAND when the focus moves to another control. * TEXTFIELD_ENTER_ONLY can be passed to suppress this feature. Typically, this * flag is used in dialogs that close when ENTER is hit in a text field. */ class FXAPI FXTextField : public FXFrame { FXDECLARE(FXTextField) protected: FXString contents; // Edited text FXFont *font; // Text font const FXchar *delimiters; // Set of delimiters FXString clipped; // Clipped text FXString help; // Help string FXString tip; // Tooltip FXColor textColor; // Text color FXColor selbackColor; // Selected background color FXColor seltextColor; // Selected text color FXColor cursorColor; // Color of the Cursor FXuint blink; // Next cursor blink state FXint cursor; // Cursor position FXint anchor; // Anchor position FXint columns; // Number of columns visible FXint shift; // Shift amount protected: FXTextField(); FXint index(FXint x) const; FXint coord(FXint i) const; FXint leftWord(FXint pos) const; FXint rightWord(FXint pos) const; FXint wordStart(FXint pos) const; FXint wordEnd(FXint pos) const; void drawCursor(FXuint state); void paintCursor(FXDCWindow& dc) const; void eraseCursor(FXDCWindow& dc) const; void drawTextRange(FXDCWindow& dc,FXint fm,FXint to) const; void drawTextFragment(FXDCWindow& dc,FXint x,FXint y,FXint fm,FXint to) const; void drawPWDTextFragment(FXDCWindow& dc,FXint x,FXint y,FXint fm,FXint to) const; void enterText(const FXString& text,FXbool notify); FXbool deletePendingSelection(FXbool notify); private: FXTextField(const FXTextField&); FXTextField& operator=(const FXTextField&); public: long onPaint(FXObject*,FXSelector,void*); long onUpdate(FXObject*,FXSelector,void*); long onBlink(FXObject*,FXSelector,void*); long onFocusIn(FXObject*,FXSelector,void*); long onFocusOut(FXObject*,FXSelector,void*); long onFocusSelf(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onAutoScroll(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onMiddleBtnPress(FXObject*,FXSelector,void*); long onMiddleBtnRelease(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onVerify(FXObject*,FXSelector,void*); long onSelectionLost(FXObject*,FXSelector,void*); long onSelectionGained(FXObject*,FXSelector,void*); long onSelectionRequest(FXObject*,FXSelector,void* ptr); long onClipboardLost(FXObject*,FXSelector,void*); long onClipboardGained(FXObject*,FXSelector,void*); long onClipboardRequest(FXObject*,FXSelector,void*); long onCmdSetTip(FXObject*,FXSelector,void*); long onCmdGetTip(FXObject*,FXSelector,void*); long onCmdSetHelp(FXObject*,FXSelector,void*); long onCmdGetHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onUpdIsEditable(FXObject*,FXSelector,void*); long onUpdHaveSelection(FXObject*,FXSelector,void*); long onUpdHaveEditableSelection(FXObject*,FXSelector,void*); // Value access long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdSetLongValue(FXObject*,FXSelector,void*); long onCmdSetRealValue(FXObject*,FXSelector,void*); long onCmdSetStringValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); long onCmdGetLongValue(FXObject*,FXSelector,void*); long onCmdGetRealValue(FXObject*,FXSelector,void*); long onCmdGetStringValue(FXObject*,FXSelector,void*); // Cursor movement long onCmdCursorHome(FXObject*,FXSelector,void*); long onCmdCursorEnd(FXObject*,FXSelector,void*); long onCmdCursorRight(FXObject*,FXSelector,void*); long onCmdCursorLeft(FXObject*,FXSelector,void*); long onCmdCursorWordLeft(FXObject*,FXSelector,void*); long onCmdCursorWordRight(FXObject*,FXSelector,void*); // Cursor drag movement long onCmdCursorShiftHome(FXObject*,FXSelector,void*); long onCmdCursorShiftEnd(FXObject*,FXSelector,void*); long onCmdCursorShiftRight(FXObject*,FXSelector,void*); long onCmdCursorShiftLeft(FXObject*,FXSelector,void*); long onCmdCursorShiftWordLeft(FXObject*,FXSelector,void*); long onCmdCursorShiftWordRight(FXObject*,FXSelector,void*); // Inserting long onCmdInsertString(FXObject*,FXSelector,void*); long onIMEStart(FXObject*,FXSelector,void*); // Manipulation Selection long onCmdCutSel(FXObject*,FXSelector,void*); long onCmdCopySel(FXObject*,FXSelector,void*); long onCmdPasteSel(FXObject*,FXSelector,void*); long onCmdDeleteSel(FXObject*,FXSelector,void*); long onCmdPasteMiddle(FXObject*,FXSelector,void*); long onCmdSelectAll(FXObject*,FXSelector,void*); long onCmdDeselectAll(FXObject*,FXSelector,void*); // Deletion long onCmdBackspace(FXObject*,FXSelector,void*); long onCmdBackspaceWord(FXObject*,FXSelector,void*); long onCmdBackspaceBol(FXObject*,FXSelector,void*); long onCmdDeleteChar(FXObject*,FXSelector,void*); long onCmdDeleteWord(FXObject*,FXSelector,void*); long onCmdDeleteEol(FXObject*,FXSelector,void*); long onCmdDeleteAll(FXObject*,FXSelector,void*); // Control commands long onCmdToggleEditable(FXObject*,FXSelector,void*); long onUpdToggleEditable(FXObject*,FXSelector,void*); long onCmdToggleOverstrike(FXObject*,FXSelector,void*); long onUpdToggleOverstrike(FXObject*,FXSelector,void*); public: /// Default text delimiters static const FXchar textDelimiters[]; public: enum{ ID_CURSOR_HOME=FXFrame::ID_LAST, ID_CURSOR_END, ID_CURSOR_RIGHT, ID_CURSOR_LEFT, ID_CURSOR_WORD_LEFT, ID_CURSOR_WORD_RIGHT, ID_CURSOR_SHIFT_HOME, ID_CURSOR_SHIFT_END, ID_CURSOR_SHIFT_LEFT, ID_CURSOR_SHIFT_RIGHT, ID_CURSOR_SHIFT_WORD_LEFT, ID_CURSOR_SHIFT_WORD_RIGHT, ID_SELECT_ALL, ID_DESELECT_ALL, ID_CUT_SEL, ID_COPY_SEL, ID_DELETE_SEL, ID_PASTE_SEL, ID_PASTE_MIDDLE, ID_INSERT_STRING, ID_BACKSPACE, ID_BACKSPACE_WORD, ID_BACKSPACE_BOL, ID_DELETE_CHAR, ID_DELETE_WORD, ID_DELETE_EOL, ID_DELETE_ALL, ID_TOGGLE_EDITABLE, ID_TOGGLE_OVERSTRIKE, ID_BLINK, ID_AUTOSCROLL, ID_LAST }; public: /// Construct text field wide enough to display ncols columns FXTextField(FXComposite* p,FXint ncols,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=TEXTFIELD_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Create server-side resources virtual void create(); /// Perform layout virtual void layout(); /// Enable text field virtual void enable(); /// Disable text field virtual void disable(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Yes, text field may receive focus virtual FXbool canFocus() const; /// Move the focus to this window virtual void setFocus(); /// Remove the focus from this window virtual void killFocus(); /// Set editable mode void setEditable(FXbool edit=true); /// Return true if text field may be edited FXbool isEditable() const; /// Set overstrike mode void setOverstrike(FXbool over=true); /// Return true if overstrike mode in effect FXbool isOverstrike() const; /// Change the text and move cursor to end void setText(const FXString& text,FXbool notify=false); /// Replace range of bytes with text void replaceText(FXint pos,FXint m,const FXString& text,FXbool notify=false); /// Append text at the end void appendText(const FXString& text,FXbool notify=false); /// Insert text at position void insertText(FXint pos,const FXString& text,FXbool notify=false); /// Remove range of text void removeText(FXint pos,FXint m,FXbool notify=false); /// Remove all text void clearText(FXbool notify=false); /// Get entire text FXString getText() const { return contents; } /// Select all text FXbool selectAll(); /// Select len characters starting at given position pos FXbool setSelection(FXint pos,FXint len); /// Extend the selection from the anchor to the given position FXbool extendSelection(FXint pos); /// Unselect the text FXbool killSelection(); /// Get selected text FXString getSelectedText() const; /// Copy primary selection to clipboard FXbool copySelection(); /// Cut primary selection to clipboard FXbool cutSelection(FXbool notify=false); /// Delete primary selection FXbool deleteSelection(FXbool notify=false); /// Paste primary selection FXbool pasteSelection(FXbool notify=false); /// Paste clipboard FXbool pasteClipboard(FXbool notify=false); /// Return true if position pos is selected FXbool isPosSelected(FXint pos) const; /// Return true if position is fully visible FXbool isPosVisible(FXint pos) const; /// Scroll text to make the given position visible void makePositionVisible(FXint pos); /// Set cursor position void setCursorPos(FXint pos); /// Return cursor position FXint getCursorPos() const { return cursor; } /// Move cursor to position, and scroll into view void moveCursor(FXint pos); /// Move cursor to position, and extent the selection to this point void moveCursorAndSelect(FXint pos); /// Change anchor position void setAnchorPos(FXint pos); /// Return anchor position FXint getAnchorPos() const { return anchor; } /// Change text style void setTextStyle(FXuint style); /// Return text style FXuint getTextStyle() const; /// Set the text font void setFont(FXFont* fnt); /// Get the text font FXFont* getFont() const { return font; } /// Change number of visible columns void setNumColumns(FXint cols); /// Return number of visible columns FXint getNumColumns() const { return columns; } /// Change word delimiters void setDelimiters(const FXchar* delims=textDelimiters){ delimiters=delims; } /// Return word delimiters const FXchar* getDelimiters() const { return delimiters; } /** * Change text justification mode. The justify mode is a combination of * horizontal justification (JUSTIFY_LEFT, JUSTIFY_RIGHT, or JUSTIFY_CENTER_X), * and vertical justification (JUSTIFY_TOP, JUSTIFY_BOTTOM, JUSTIFY_CENTER_Y). * Note that JUSTIFY_CENTER_X can not be set from the constructor since by * default text fields are left-justified. */ void setJustify(FXuint mode); /// Return text justification mode FXuint getJustify() const; /// Change text color void setTextColor(FXColor clr); /// Return text color FXColor getTextColor() const { return textColor; } /// Change selected background color void setSelBackColor(FXColor clr); /// Return selected background color FXColor getSelBackColor() const { return selbackColor; } /// Change selected text color void setSelTextColor(FXColor clr); /// Return selected text color FXColor getSelTextColor() const { return seltextColor; } /// Changes the cursor color void setCursorColor(FXColor clr); /// Return the cursor color FXColor getCursorColor() const { return cursorColor; } /// Set the status line help text for this label void setHelpText(const FXString& text){ help=text; } /// Get the status line help text for this label const FXString& getHelpText() const { return help; } /// Set the tool tip message for this text field void setTipText(const FXString& text){ tip=text; } /// Get the tool tip message for this text field const FXString& getTipText() const { return tip; } /// Save text field to a stream virtual void save(FXStream& store) const; /// Load text field from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXTextField(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXThread.h000066400000000000000000000217241455751074500223050ustar00rootroot00000000000000/******************************************************************************** * * * T h r e a d S u p p o r t * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTHREAD_H #define FXTHREAD_H #ifndef FXRUNNABLE_H #include "FXRunnable.h" #endif namespace FX { /** * FXThread provides system-independent support for threads. * * Subclasses of FXThread must implement the run() function to implement * the desired functionality of the thread object. The thread can be * started by calling start(), passing an optional size to allocate for * the thread's stack space. * Each thread can have thread-local storage. FXThread has at least one * thread-local variable, a pointer to the FXThread object itself; this * value can be obtained at any time during the execution of the thread by * calling self(). The value of self() is automatically set when the thread * is started. * Additional thread-local variables may be obtained using FXAutoThreadStorageKey. * Initially, all signals are masked by newly started threads (only the main thread * will normally handle signals). * To reclaim the resources once the thread is completed, a call to join() must be * made, or the thread must be detached (note however that detaching the thread will * sever the association between FXThread and the thread). * The special FXThreadException may be used to terminate a thread gracefully, * and pass a return code to the corresponding join() operation. This is preferred * over the raw FXThread::exit(). * Unknown exceptions cause the program to terminate with an error. * Calling the destructor from within the thread itself (suicide) is allowed; the * thread will be detached and terminate immediately. * Calling the destructor from another thread will cancel() the thread if it is * still running. Due to the asynchronous nature of threads, it is usually not a * good idea to do this; it is recommended that subclasses call join(), and delay * the execution of the destructor until the thread has completed normally. */ class FXAPI FXThread : public FXRunnable { private: volatile FXThreadID tid; // Handle to thread volatile FXbool busy; // Thread is running public: /// Thread priority levels enum Priority { PriorityError=-1, /// Failed to get priority PriorityDefault, /// Default scheduling priority PriorityMinimum, /// Minimum scheduling priority PriorityLower, /// Lower scheduling priority PriorityMedium, /// Medium priority PriorityHigher, /// Higher scheduling priority PriorityMaximum /// Maximum scheduling priority }; /// Thread scheduling policies enum Policy { PolicyError=-1, /// Failed to get policy PolicyDefault, /// Default scheduling PolicyFifo, /// First in, first out scheduling PolicyRoundRobin /// Round-robin scheduling }; private: FXThread(const FXThread&); FXThread &operator=(const FXThread&); private: static void self(FXThread* t); private: static FXAutoThreadStorageKey selfKey; private: #if defined(WIN32) static unsigned int CALLBACK function(void*); #else static void* function(void*); #endif public: /// Initialize thread object. FXThread(); /** * Return handle of this thread object. * This handle is valid in the context of the thread which * called start(). */ FXThreadID id() const; /** * Return true if this thread is running. */ FXbool running() const; /** * Start thread; the thread is started as attached. * The thread is given stacksize for its stack; a value of * zero for stacksize will give it the default stack size. * This invokes the run() function in the context of the new * thread. */ FXbool start(FXuval stacksize=0); /** * Suspend calling thread until thread is done. The FXThreadID is * reset back to zero. */ FXbool join(); /** * Suspend calling thread until thread is done, and set code to the * return value of run() or the argument passed into exit(). The * FXThreadID is reset back to zero. * If an exception happened in the thread, return -1. */ FXbool join(FXint& code); /** * Cancel the thread, stopping it immediately, running or not. * If the calling thread is this thread, nothing happens. * It is probably better to wait until it is finished, in case the * thread currently holds mutexes. * The FXThreadID is reset back to zero after the thread has been * stopped. */ FXbool cancel(); /** * Detach thread, so that a no join() is necessary to harvest the * resources of this thread. The thread continues to run until * normal completion. */ FXbool detach(); /** * Exit the calling thread. * No destructors are invoked for objects on thread's stack; to invoke destructors, * throw an exception instead; the special FXThreadException causes graceful termination * of the calling thread with return of an exit code for join(). */ static void exit(FXint code=0); /** * Make the thread yield its time quantum. */ static void yield(); /** * Processor pause/back-off. */ static void pause(); /** * Return time in nanoseconds since Epoch (Jan 1, 1970). */ static FXTime time(); /** * Get steady time in nanoseconds since some arbitrary start time. */ static FXTime steadytime(); /** * Return time in processor ticks. */ static FXTime ticks(); /** * Make the calling thread sleep for a number of nanoseconds. */ static void sleep(FXTime nsec); /** * Wake at appointed time specified in nanoseconds since Epoch. */ static void wakeat(FXTime nsec); /** * Return pointer to the FXThread instance associated * with the calling thread; it returns NULL for the main * thread and all threads not created by FOX. */ static FXThread* self(); /** * Return thread id of calling thread. */ static FXThreadID current(); /** * Return number of available processors (cores) in the system. */ static FXint processors(); /** * Return processor index of the calling thread; returns a value * between [0 ... processors()-1] if successful, and -1 otherwise. */ static FXint processor(); /** * Generate new thread local storage key. */ static FXThreadStorageKey createStorageKey(); /** * Dispose of thread local storage key. */ static void deleteStorageKey(FXThreadStorageKey key); /** * Get thread local storage pointer using key. */ static void* getStorage(FXThreadStorageKey key); /** * Set thread local storage pointer using key. */ static void setStorage(FXThreadStorageKey key,void* ptr); /** * Set thread scheduling priority. */ FXbool priority(Priority prio); /** * Return thread scheduling priority. */ Priority priority() const; /** * Set thread scheduling policy. */ FXbool policy(Policy plcy); /** * Get thread scheduling policy. */ Policy policy() const; /** * Change thread's processor affinity, the set of * processors onto which the thread may be scheduled. */ FXbool affinity(FXulong mask); /** * Get thread's processor affinity. */ FXulong affinity() const; /** * Change thread description. */ FXbool description(const FXString& desc); /** * Return thread description, if any. */ FXString description() const; /** * Suspend thread; return true if success. */ FXbool suspend(); /** * Resume thread; return true if success. */ FXbool resume(); /** * Destroy the thread immediately, running or not. * It is probably better to wait until it is finished, in case * the thread currently holds mutexes. */ virtual ~FXThread(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXThreadPool.h000066400000000000000000000223611455751074500231350ustar00rootroot00000000000000/******************************************************************************** * * * T h r e a d P o o l * * * ********************************************************************************* * Copyright (C) 2006,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTHREADPOOL_H #define FXTHREADPOOL_H #ifndef FXRUNNABLE_H #include "FXRunnable.h" #endif namespace FX { class FXWorker; /// Task queue typedef FXLFQueueOf FXTaskQueue; /** * A Thread Pool manages execution of tasks on a number of worker-threads. * * A task executed by the thread pool is queued up until a worker-thread becomes available * to run it. * To accomodate fluctuations in workloads and minimize resources, the number of worker- * threads can be allowed to vary between a minimum and a maximum number. * Idle worker-threads which receive no assignments within a specified amount of time will * automatically terminate, thereby reduce system-resources used by the program. * By default, the minimum number of worker-threads is 1, and the maximum number of worker- * threads is equal to the number of processors in the system. * During peak workloads, when the task queue may start to fill up, and no new worker- * threads can be created, the calling thread to block until there is room in the queue * for more tasks. * However, if a non-default value is passed for the blocking-parameter to execute(), the * calling thread will be blocked for only a finite amount of time (non-zero blocking value) * or return immediately (zero blocking value). * Failure to queue up a new task will result in execute() returning a false. * The tasks which are passed to the thread pool are derived from FXRunnable. In order * to perform some useful function, subclasses of FXRunnable should overload the run() * function. * Uncaught exceptions thrown by a task are intercepted by the thread pool and rethrown * after the necessary cleanup, and cause the worker thread to end prematurely. * When the thread pool is stopped, it will wait until all tasks are finished, and then * cause all worker-threads to terminate. * The thread pool becomes associated (through a thread-local variable) with the calling * thread when start() is called; this association lasts until stop() is called. * In addition, each worker will similarly be associated with the thread pool. * Thus both the main thread as well as the worker threads can easily find the thread * pool through the member-function instance(). */ class FXAPI FXThreadPool : public FXRunnable { private: FXTaskQueue queue; // Task queue FXCompletion tasks; // Active tasks FXCompletion threads; // Active threads FXSemaphore freeslots; // Free slots in queue FXSemaphore usedslots; // Used slots in queue FXuval stacksize; // Stack size FXTime expiration; // Quit if no task within this time volatile FXuint maximum; // Maximum threads volatile FXuint minimum; // Minimum threads volatile FXuint workers; // Working threads volatile FXuint running; // Context is running private: static FXAutoThreadStorageKey reference; private: FXbool startWorker(); void runWhile(FXCompletion& comp,FXTime timeout); virtual FXint run(); private: FXThreadPool(const FXThreadPool&); FXThreadPool &operator=(const FXThreadPool&); public: /** * Construct an empty thread pool, with given task-queue size. */ FXThreadPool(FXuint sz=256); /// Return true if running FXbool active() const { return running==1; } /// Change task queue size, return true if success FXbool setSize(FXuint sz); /// Return task queue size FXuint getSize() const { return queue.getSize(); } /// Return number of tasks FXuint getRunningTasks() const { return tasks.count(); } /// Return number of threads FXuint getRunningThreads() const { return threads.count(); } /// Change minimum number of worker threads; default is 1 FXbool setMinimumThreads(FXuint n); /// Return minimum number of worker threads FXuint getMinimumThreads() const { return minimum; } /// Change maximum number of worker threads; default is #processors FXbool setMaximumThreads(FXuint n); /// Return maximum number of worker threads FXuint getMaximumThreads() const { return maximum; } /// Change expiration time for excess workers to terminate FXbool setExpiration(FXTime ns=forever); /// Get expiration time FXTime getExpiration() const { return expiration; } /// Change stack size (0 for default stack size) FXbool setStackSize(FXuval sz); /// Get stack size FXuval getStackSize() const { return stacksize; } /// Return calling thread's thread pool static FXThreadPool* instance(); /// Change calling thread's thread pool static void instance(FXThreadPool *pool); /** * Start the thread pool with an initial number of threads equal to count. * Returns the number of threads actually started. * An association will be established between the calling thread and the thread pool. * This association lasts until stop() is called. If another threadpool was already started * before by the calling thread, no new association will be established. */ FXuint start(FXuint count=0); /** * Execute a task on the thread pool by entering it into the queue. * If a spot becomes available in the task queue within the timeout interval, * add the task to the queue and return true. * Return false if the task could not be added within the given time interval. * Possibly starts additional worker threads if the maximum number of worker * threads has not yet been exceeded. */ FXbool execute(FXRunnable* task,FXTime blocking=forever); /** * Execute task on the thread pool by entering int into the queue. * If the task was successfully added, the calling thread will temporarily enter * the task-processing loop, and help out the worker-threads until all tasks * have finished processing. * Return false if the task could not be added within the given time interval. * Possibly starts additional worker threads if the maximum number of worker * threads has not yet been exceeded. */ FXbool executeAndWait(FXRunnable* task,FXTime blocking=forever); /** * Execute task on the thread pool by entering int into the queue. * If the task was successfully added, the calling thread will temporarily enter * the task-processing loop, and help out the worker-threads until the completion * becomes signaled. * Return false if the task could not be added within the given time interval. * Possibly starts additional worker threads if the maximum number of worker * threads has not yet been exceeded. */ FXbool executeAndWaitFor(FXRunnable* task,FXCompletion& comp,FXTime blocking=forever); /** * Wait until task queue becomes empty and all tasks are finished, and process tasks * to help the worker threads in the meantime. * If the thread pool was not running, return immediately with false; otherwise, * return when the queue is empty and all tasks have finished. */ FXbool wait(); /** * Wait until completion becomes signaled, and process tasks to help the worker * threads in the meantime. * If the thread pool was not running, return immediately with false; otherwise, * return when the completion becomes signaled, or when the thread pool is stopped. * Immediately return with false if the thread pool wasn't running. */ FXbool waitFor(FXCompletion& comp); /** * Stop thread pool, and block posting of any new tasks to the queue. * Enter the task-processing loop and help the worker-threads until the task queue is * empty, and all tasks have finished executing. * The association between the calling thread, established when start() was called, * will hereby be dissolved, if the calling thread was associated with this thread pool. * Return false if the thread pool wasn't running. */ FXbool stop(); /** * Stop the thread pool and then delete it. */ virtual ~FXThreadPool(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXToggleButton.h000066400000000000000000000136311455751074500235110ustar00rootroot00000000000000/******************************************************************************** * * * T o g g l e B u t t o n W i d g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTOGGLEBUTTON_H #define FXTOGGLEBUTTON_H #ifndef FXLABEL_H #include "FXLabel.h" #endif namespace FX { /// Toggle button flags enum { TOGGLEBUTTON_AUTOGRAY = 0x00800000, /// Automatically gray out when not updated TOGGLEBUTTON_AUTOHIDE = 0x01000000, /// Automatically hide toggle button when not updated TOGGLEBUTTON_TOOLBAR = 0x02000000, /// Toolbar style toggle button [flat look] TOGGLEBUTTON_KEEPSTATE= 0x04000000, /// Draw button according to state TOGGLEBUTTON_NORMAL = FRAME_RAISED|FRAME_THICK|JUSTIFY_NORMAL|ICON_BEFORE_TEXT }; /** * The toggle button provides a two-state button, which toggles between the * on and the off state each time it is pressed. For each state, the toggle * button has a unique icon and text label. * When pressed, the button widget sends a SEL_COMMAND to its target, with the * message data set to the current state of the toggle button, of the type FXbool. */ class FXAPI FXToggleButton : public FXLabel { FXDECLARE(FXToggleButton) protected: FXString altlabel; FXIcon *alticon; FXHotKey althotkey; FXint althotoff; FXString alttip; FXString althelp; FXuchar state; FXuchar down; protected: FXToggleButton(); void press(FXuchar dn); private: FXToggleButton(const FXToggleButton&); FXToggleButton& operator=(const FXToggleButton&); public: long onPaint(FXObject*,FXSelector,void*); long onUpdate(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onFocusIn(FXObject*,FXSelector,void*); long onFocusOut(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onHotKeyPress(FXObject*,FXSelector,void*); long onHotKeyRelease(FXObject*,FXSelector,void*); long onCheck(FXObject*,FXSelector,void*); long onUncheck(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); long onCmdSetValue(FXObject*,FXSelector,void*); long onCmdSetIntValue(FXObject*,FXSelector,void*); long onCmdGetIntValue(FXObject*,FXSelector,void*); public: /// Construct toggle button with two text labels, and two icons, one for each state FXToggleButton(FXComposite* p,const FXString& text1,const FXString& text2,FXIcon* icon1=nullptr,FXIcon* icon2=nullptr,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=TOGGLEBUTTON_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Returns true because a toggle button can receive focus virtual FXbool canFocus() const; /// Get default width virtual FXint getDefaultWidth(); /// Get default height virtual FXint getDefaultHeight(); /// Change alternate text and hotkey void setAltTextAndHotKey(const FXString& hotkeytext); /// Change alternate text shown when toggled void setAltText(const FXString& text); /// Return alternate text FXString getAltText() const { return altlabel; } /// Change alternate icon shown when toggled void setAltIcon(FXIcon* ic); /// Return alternate icon FXIcon* getAltIcon() const { return alticon; } /// Change toggled state void setState(FXuchar s=true,FXbool notify=false); /// Return toggled state FXuchar getState() const { return state; } /// Change alternate help text shown when toggled void setAltHelpText(const FXString& text); /// Return alternate help text FXString getAltHelpText() const { return althelp; } /// Change alternate tip text shown when toggled void setAltTipText(const FXString& text); /// Return alternate tip text FXString getAltTipText() const { return alttip; } /// Set the toggle button style flags void setToggleStyle(FXuint style); /// Get the toggle button style flags FXuint getToggleStyle() const; /// Save toggle button to a stream virtual void save(FXStream& store) const; /// Load toggle button from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXToggleButton(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXToolBar.h000066400000000000000000000066041455751074500224400ustar00rootroot00000000000000/******************************************************************************** * * * T o o l B a r W i d g e t * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTOOLBAR_H #define FXTOOLBAR_H #ifndef FXDOCKBAR_H #include "FXDockBar.h" #endif namespace FX { class FXDockSite; /** * A tool bar widget can be docked in a dock site; it automatically * adjusts its orientation based on the orientation of the dock site, * and adjusts the layout options accordingly. * See dock bar widget for more information on the docking behavior. */ class FXAPI FXToolBar : public FXDockBar { FXDECLARE(FXToolBar) protected: FXToolBar(){} private: FXToolBar(const FXToolBar&); FXToolBar &operator=(const FXToolBar&); public: long onCmdDockFlip(FXObject*,FXSelector,void*); long onUpdDockFlip(FXObject*,FXSelector,void*); public: /// Construct floatable toolbar, initially docked under parent p FXToolBar(FXComposite* p,FXComposite* q,FXuint opts=LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FILL_X,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=3,FXint pr=3,FXint pt=2,FXint pb=2,FXint hs=DEFAULT_SPACING,FXint vs=DEFAULT_SPACING); /// Construct a non-floatable toolbar FXToolBar(FXComposite* p,FXuint opts,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=2,FXint pr=3,FXint pt=3,FXint pb=2,FXint hs=DEFAULT_SPACING,FXint vs=DEFAULT_SPACING); /// Perform layout virtual void layout(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Dock and optionally flip orientation of toolbar before other window virtual void dock(FXDockSite* docksite,FXWindow* other=nullptr,FXbool notify=false); /// Dock and optionally flip orientation of toolbar virtual void dock(FXDockSite* docksite,FXint localx,FXint localy,FXbool notify=false); /// Set docking side void setDockingSide(FXuint side=LAYOUT_SIDE_TOP); /// Return docking side FXuint getDockingSide() const; }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXToolBarGrip.h000066400000000000000000000072721455751074500232640ustar00rootroot00000000000000/******************************************************************************** * * * T o o l B a r G r i p W i d g e t * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTOOLBARGRIP_H #define FXTOOLBARGRIP_H #ifndef FXDOCKHANDLER_H #include "FXDockHandler.h" #endif namespace FX { /// Tool Bar Grip styles enum { TOOLBARGRIP_SINGLE = 0, /// Single bar mode for movable toolbars TOOLBARGRIP_DOUBLE = 0x00008000 /// Double bar mode for dockable toolbars }; /** * A toolbar grip is used to move its container, a dock bar. * The grip draws either a single or double bar; it is customary * to use the single bar grip for toolbar-rearrangements only, * and use the double-bar when the toolbar needs to be floated * or docked. * The toolbar grip is automatically oriented properly by the * the toolbar widget, similar to the FXSeparator widget. * Holding the Control Key while dragging the grip will prevent * the toolbar from docking when it is near a dock site. */ class FXAPI FXToolBarGrip : public FXDockHandler { FXDECLARE(FXToolBarGrip) protected: FXColor activeColor; // Color when active protected: FXToolBarGrip(); private: FXToolBarGrip(const FXToolBarGrip&); FXToolBarGrip& operator=(const FXToolBarGrip&); public: long onPaint(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); public: /// Construct toolbar grip FXToolBarGrip(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=TOOLBARGRIP_SINGLE,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=0,FXint pr=0,FXint pt=0,FXint pb=0); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// The grip can not receive the focus virtual FXbool canFocus() const; /// Change toolbar grip to double void setDoubleBar(FXbool dbl=true); /// Return true if toolbar grip is displayed as a double bar FXbool isDoubleBar() const; /// Set the active color void setActiveColor(FXColor clr); /// Get the active color FXColor getActiveColor() const { return activeColor; } /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXToolBarShell.h000066400000000000000000000136441455751074500234320ustar00rootroot00000000000000/******************************************************************************** * * * T o o l B a r S h e l l W i d g e t * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTOOLBARSHELL_H #define FXTOOLBARSHELL_H #ifndef FXTOPWINDOW_H #include "FXTopWindow.h" #endif namespace FX { /** * A Toolbar shell is a widget floating around over the Main Window. * It typically contains an undocked tool bar. The Toolbar shell can * be resized horizontally by grabbing its sides if the widget contained * in the Toolbar shell has the LAYOUT_FIX_WIDTH option. Likewise, it * can be resized vertically if the LAYOUT_FIX_HEIGHT option is passed * to the widget contained in the Toolbar shell. If both LAYOUT_FIX_WIDTH * and LAYOUT_FIX_HEIGHT are passed to the contained widget, Toolbar shell * can also be resized by grabbing the corners. * Normally, the Toolbar shell tries to accomodate changes in its contained * widget by shrink-wrapping around it, i.e. if the contained widget changes, * the Toolbar shell will change to fit narrowly around it. */ class FXAPI FXToolBarShell : public FXTopWindow { FXDECLARE(FXToolBarShell) protected: FXColor baseColor; // Base color FXColor hiliteColor; // Highlight color FXColor shadowColor; // Shadow color FXColor borderColor; // Border color FXint border; // Border width FXint gripx; // Grip offset x FXint gripy; // Grip offset y FXint xopp; // Opposite x FXint yopp; // Opposite y FXuchar mode; // Dragging mode protected: static const FXDefaultCursor cursorType[16]; private: FXToolBarShell(const FXToolBarShell&); FXToolBarShell &operator=(const FXToolBarShell&); protected: FXToolBarShell(); FXuchar where(FXint x,FXint y) const; void drawBorderRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawRaisedRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawSunkenRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawRidgeRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawGrooveRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawDoubleRaisedRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawDoubleSunkenRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); void drawFrame(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); protected: enum { DRAG_NONE = 0, DRAG_TOP = 1, DRAG_BOTTOM = 2, DRAG_LEFT = 4, DRAG_RIGHT = 8, DRAG_TOPLEFT = (DRAG_TOP|DRAG_LEFT), DRAG_TOPRIGHT = (DRAG_TOP|DRAG_RIGHT), DRAG_BOTTOMLEFT = (DRAG_BOTTOM|DRAG_LEFT), DRAG_BOTTOMRIGHT = (DRAG_BOTTOM|DRAG_RIGHT), DRAG_WHOLE = (DRAG_TOP|DRAG_BOTTOM|DRAG_LEFT|DRAG_RIGHT) }; public: long onPaint(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onLayout(FXObject*,FXSelector,void*); public: /// Construct a toolbar shell FXToolBarShell(FXWindow* owner,FXuint opts=FRAME_RAISED|FRAME_THICK,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint hs=4,FXint vs=4); /// Create server-side resources virtual void create(); /// Perform layout virtual void layout(); /// Return the default width of this window virtual FXint getDefaultWidth(); /// Return the default height of this window virtual FXint getDefaultHeight(); /// Change frame style void setFrameStyle(FXuint style); /// Get current frame style FXuint getFrameStyle() const; /// Get border width FXint getBorderWidth() const { return border; } /// Change highlight color void setHiliteColor(FXColor clr); /// Get highlight color FXColor getHiliteColor() const { return hiliteColor; } /// Change shadow color void setShadowColor(FXColor clr); /// Get shadow color FXColor getShadowColor() const { return shadowColor; } /// Change border color void setBorderColor(FXColor clr); /// Get border color FXColor getBorderColor() const { return borderColor; } /// Change base gui color void setBaseColor(FXColor clr); /// Get base gui color FXColor getBaseColor() const { return baseColor; } /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXToolBarTab.h000066400000000000000000000116041455751074500230630ustar00rootroot00000000000000/******************************************************************************** * * * T o o l B a r T a b W i d g e t * * * ********************************************************************************* * Copyright (C) 1999,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTOOLBARTAB_H #define FXTOOLBARTAB_H #ifndef FXFRAME_H #include "FXFrame.h" #endif namespace FX { /// Tool Bar Tab styles enum { TOOLBARTAB_HORIZONTAL = 0, /// Default is for horizontal toolbar TOOLBARTAB_VERTICAL = 0x00008000 /// For vertical toolbar }; /** * A toolbar tab is used to collapse or uncollapse a sibling * widget. The sibling affected is the widget immediately following * the toolbar tab or, if the toolbar tab is the last widget in the list, * the widget immediately preceding the toolbar tab. */ class FXAPI FXToolBarTab : public FXFrame { FXDECLARE(FXToolBarTab) protected: FXColor activeColor; // Color when active FXString tip; // Tooltip FXbool collapsed; // Is collapsed flat FXbool down; // Button down protected: FXToolBarTab(); void drawUpArrow(FXDCWindow& dc); void drawDownArrow(FXDCWindow& dc); void drawRightArrow(FXDCWindow& dc); void drawLeftArrow(FXDCWindow& dc); void drawHSpeckles(FXDCWindow& dc,FXint x,FXint w); void drawVSpeckles(FXDCWindow& dc,FXint y,FXint h); private: FXToolBarTab(const FXToolBarTab&); FXToolBarTab& operator=(const FXToolBarTab&); public: long onPaint(FXObject*,FXSelector,void*); long onUpdate(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onCmdCollapse(FXObject*,FXSelector,void*); long onUpdCollapse(FXObject*,FXSelector,void*); long onCmdUncollapse(FXObject*,FXSelector,void*); long onUpdUncollapse(FXObject*,FXSelector,void*); long onCmdSetTip(FXObject*,FXSelector,void*); long onCmdGetTip(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); public: enum { ID_COLLAPSE=FXFrame::ID_LAST, ID_UNCOLLAPSE, ID_LAST }; public: /// Construct toolbar tab FXToolBarTab(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=FRAME_RAISED,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Toolbar tab can receive focus virtual FXbool canFocus() const; /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Enable the toolbar tab virtual void enable(); /// Disable the toolbar tab virtual void disable(); /// Collapse or uncollapse the toolbar void collapse(FXbool fold,FXbool notify=false); /// Return true if the toolbar is collapsed FXbool isCollapsed() const { return collapsed; } /// Change the tab style void setTabStyle(FXuint style); /// Get current tab style FXuint getTabStyle() const; /// Get the active color FXColor getActiveColor() const { return activeColor; } /// Set the active color void setActiveColor(FXColor clr); /// Set the tool tip message for the toolbar tab void setTipText(const FXString& text){ tip=text; } /// Get the tool tip message for the toolbar tab const FXString& getTipText() const { return tip; } /// Save to a stream virtual void save(FXStream& store) const; /// Load from a stream virtual void load(FXStream& store); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXToolTip.h000066400000000000000000000100621455751074500224610ustar00rootroot00000000000000/******************************************************************************** * * * T o o l T i p W i d g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTOOLTIP_H #define FXTOOLTIP_H #ifndef FXSHELL_H #include "FXShell.h" #endif namespace FX { class FXFont; /// Tooltip styles enum { TOOLTIP_PERMANENT = 0x00020000, /// Tooltip stays up indefinitely TOOLTIP_VARIABLE = 0x00040000, /// Tooltip stays up variable time, depending on the length of the string TOOLTIP_NORMAL = 0 /// Normal tooltip }; /// Hopefully Helpful Hint message class FXAPI FXToolTip : public FXShell { FXDECLARE(FXToolTip) protected: FXString label; // Text in the tip FXFont *font; // Font of the tip FXColor textColor; // Text color FXbool popped; // Is currently popped up protected: FXToolTip(); virtual FXbool doesOverrideRedirect() const; void place(FXint x,FXint y); void autoplace(); private: FXToolTip(const FXToolTip&); FXToolTip& operator=(const FXToolTip&); #ifdef WIN32 virtual const void* GetClass() const; #endif public: long onPaint(FXObject*,FXSelector,void*); long onUpdate(FXObject*,FXSelector,void*); long onTipShow(FXObject*,FXSelector,void*); long onTipHide(FXObject*,FXSelector,void*); long onCmdGetStringValue(FXObject*,FXSelector,void*); long onCmdSetStringValue(FXObject*,FXSelector,void*); public: enum { ID_TIP_SHOW=FXShell::ID_LAST, ID_TIP_HIDE, ID_LAST }; public: /// Construct a tool tip FXToolTip(FXApp* a,FXuint opts=TOOLTIP_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Display the tip virtual void show(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Set the text for this tip void setText(const FXString& text); /// Get the text for this tip FXString getText() const { return label; } /// Set the tip text font void setFont(FXFont *fnt); /// Get the tip text font FXFont* getFont() const { return font; } /// Get the current tip text color FXColor getTextColor() const { return textColor; } /// Set the current tip text color void setTextColor(FXColor clr); virtual FXbool doesSaveUnder() const; /// Save tip to a stream virtual void save(FXStream& store) const; /// Load tip from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXToolTip(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXTopWindow.h000066400000000000000000000273761455751074500230410ustar00rootroot00000000000000/******************************************************************************** * * * T o p - L e v e l W i n d o w W i d g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTOPWINDOW_H #define FXTOPWINDOW_H #ifndef FXSHELL_H #include "FXShell.h" #endif namespace FX { /// Title and border decorations enum { DECOR_NONE = 0, /// Borderless window DECOR_TITLE = 0x00020000, /// Window title DECOR_MINIMIZE = 0x00040000, /// Minimize button DECOR_MAXIMIZE = 0x00080000, /// Maximize button DECOR_CLOSE = 0x00100000, /// Close button DECOR_BORDER = 0x00200000, /// Border DECOR_SHRINKABLE = 0x00400000, /// Window can become smaller DECOR_STRETCHABLE = 0x00800000, /// Window can become larger DECOR_RESIZE = DECOR_SHRINKABLE|DECOR_STRETCHABLE, /// Resize handles DECOR_MENU = 0x01000000, /// Window menu DECOR_ALL = (DECOR_TITLE|DECOR_MINIMIZE|DECOR_MAXIMIZE|DECOR_CLOSE|DECOR_BORDER|DECOR_SHRINKABLE|DECOR_STRETCHABLE|DECOR_MENU) }; /// Initial window placement enum { PLACEMENT_DEFAULT, /// Place it at the default size and location PLACEMENT_VISIBLE, /// Place window to be fully visible PLACEMENT_CURSOR, /// Place it under the cursor position PLACEMENT_OWNER, /// Place it centered on its owner PLACEMENT_SCREEN, /// Place it centered on the screen PLACEMENT_MAXIMIZED /// Place it maximized to the screen size }; /// Special stacking orders enum { STACK_NORMAL, /// Stack normally (default) STACK_BOTTOM, /// Stack below other windows STACK_TOP /// Stack above other windows }; class FXToolBar; class FXIcon; /** * Abstract base class for all top-level windows. * TopWindows are usually managed by a Window Manager under X11 and * therefore borders and window-menus and other decorations like resize- * handles are subject to the Window Manager's interpretation of the * decoration hints. * When a TopWindow is closed, it sends a SEL_CLOSE message to its * target. The target should return 0 in response to this message if * there is no objection to proceed with the closing of the window, and * return 1 otherwise. After the SEL_CLOSE message has been sent and * no objection was raised, the window will delete itself. * When the session is closed, the window will send a SEL_SESSION_NOTIFY * message to its target, allowing the application to write any unsaved * data to the disk. If the target returns 0, then the system will proceed * to close the session. Subsequently a SEL_SESSION_CLOSED will be received * which causes the window to be closed with prejudice by calling the * function close(false). * When receiving a SEL_UPDATE, the target can update the title string * of the window, so that the title of the window reflects the name * of the document, for example. * For convenience, TopWindow provides the same layout behavior as * the Packer widget, as well as docking and undocking of toolbars. * TopWindows can be owned by other windows, or be free-floating. * Owned TopWindows will usually remain stacked on top of the owner * windows. The lifetime of an owned window should not exceed that of * the owner. */ class FXAPI FXTopWindow : public FXShell { FXDECLARE_ABSTRACT(FXTopWindow) protected: FXString title; // Window title FXIcon *icon; // Window icon (big) FXIcon *miniIcon; // Window icon (small) FXint padtop; // Top margin FXint padbottom; // Bottom margin FXint padleft; // Left margin FXint padright; // Right margin FXint hspacing; // Horizontal child spacing FXint vspacing; // Vertical child spacing protected: FXTopWindow(); void settitle(); void seticons(); void setdecorations(); FXTopWindow(FXApp* ap,const FXString& name,FXIcon *ic,FXIcon *mi,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb,FXint hs,FXint vs); FXTopWindow(FXWindow* ow,const FXString& name,FXIcon *ic,FXIcon *mi,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb,FXint hs,FXint vs); private: FXTopWindow(const FXTopWindow&); FXTopWindow& operator=(const FXTopWindow&); #ifdef WIN32 virtual const void* GetClass() const; #endif public: long onFocusUp(FXObject*,FXSelector,void*); long onFocusDown(FXObject*,FXSelector,void*); long onFocusLeft(FXObject*,FXSelector,void*); long onFocusRight(FXObject*,FXSelector,void*); long onSessionNotify(FXObject*,FXSelector,void*); long onSessionClosed(FXObject*,FXSelector,void*); long onRestore(FXObject*,FXSelector,void*); long onMaximize(FXObject*,FXSelector,void*); long onMinimize(FXObject*,FXSelector,void*); long onCmdRestore(FXObject*,FXSelector,void*); long onCmdMaximize(FXObject*,FXSelector,void*); long onCmdMinimize(FXObject*,FXSelector,void*); long onCmdFullScreen(FXObject*,FXSelector,void*); long onCmdClose(FXObject*,FXSelector,void*); long onCmdSetStringValue(FXObject*,FXSelector,void*); long onCmdGetStringValue(FXObject*,FXSelector,void*); long onCmdSetIconValue(FXObject*,FXSelector,void*); long onCmdGetIconValue(FXObject*,FXSelector,void*); public: enum { ID_RESTORE=FXShell::ID_LAST, /// Restore the window ID_MAXIMIZE, /// Maximize the window ID_MINIMIZE, /// Minimize the window ID_FULLSCREEN, /// Make the window full screen ID_CLOSE, /// Close the window ID_QUERY_DOCK, /// Toolbar asks to dock ID_LAST }; public: /// Create server-side resources virtual void create(); /// Detach the server-side resources for this window virtual void detach(); /// Destroy the server-side resources for this window virtual void destroy(); /// Perform layout virtual void layout(); /// Move the focus to this window virtual void setFocus(); /// Remove the focus from this window virtual void killFocus(); /// Show this window virtual void show(); /// Hide this window virtual void hide(); /// Show this window with given placement virtual void show(FXuint placement); /// Position the window based on placement void place(FXuint placement); /// Return the default width of this window virtual FXint getDefaultWidth(); /// Return the default height of this window virtual FXint getDefaultHeight(); /// Obtain border sizes added to our window by the window manager FXbool getWMBorders(FXint& left,FXint& right,FXint& top,FXint& bottom); /// Raise this window to the top of the stacking order virtual void raise(); /// Lower this window to the bottom of the stacking order virtual void lower(); /// Move this window to the specified position in the parent's coordinates virtual void move(FXint x,FXint y); /// Resize this window to the specified width and height virtual void resize(FXint w,FXint h); /// Move and resize this window in the parent's coordinates virtual void position(FXint x,FXint y,FXint w,FXint h); /// Flash the window to get user's attention virtual void flash(FXbool yes); /// Restore window to normal, return true if restored virtual FXbool restore(FXbool notify=false); /// Maximize window, return true if maximized virtual FXbool maximize(FXbool notify=false); /// Minimize or iconify window, return true if minimized virtual FXbool minimize(FXbool notify=false); /// Make window full screen, return true if success virtual FXbool fullScreen(FXbool notify=false); /// Special stacking order level virtual FXbool stackingOrder(FXuint order); /** * Close the window, return true if actually closed. If notify=true, the target * will receive a SEL_CLOSE message to determine if it is OK to close the window. * If the target ignores the SEL_CLOSE message or returns 0, the window will * be closed, and subsequently deleted. When the last main window has been * closed, the application will receive an ID_QUIT message and will be closed. */ virtual FXbool close(FXbool notify=false); /// Return true if maximized FXbool isMaximized() const; /// Return true if minimized FXbool isMinimized() const; /// Return true if full screen FXbool isFullScreen() const; /// Change window title void setTitle(const FXString& name); /// Return window title FXString getTitle() const { return title; } /// Change top padding void setPadTop(FXint pt); /// Get top interior padding FXint getPadTop() const { return padtop; } /// Change bottom padding void setPadBottom(FXint pb); /// Get bottom interior padding FXint getPadBottom() const { return padbottom; } /// Change left padding void setPadLeft(FXint pl); /// Get left interior padding FXint getPadLeft() const { return padleft; } /// Change right padding void setPadRight(FXint pr); /// Get right interior padding FXint getPadRight() const { return padright; } /// Return horizontal spacing between children FXint getHSpacing() const { return hspacing; } /// Return vertical spacing between children FXint getVSpacing() const { return vspacing; } /// Change horizontal spacing between children void setHSpacing(FXint hs); /// Change vertical spacing between children void setVSpacing(FXint vs); /// Change packing hints for children void setPackingHints(FXuint ph); /// Return packing hints for children FXuint getPackingHints() const; /// Change title and border decorations void setDecorations(FXuint decorations); /// Return current title and border decorations FXuint getDecorations() const; /// Return window icon FXIcon* getIcon() const { return icon; } /// Change window icon void setIcon(FXIcon* ic); /// Return window mini (title) icon FXIcon* getMiniIcon() const { return miniIcon; } /// Change window mini (title) icon void setMiniIcon(FXIcon *ic); /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destructor virtual ~FXTopWindow(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXTranslator.h000066400000000000000000000047121455751074500232250ustar00rootroot00000000000000/******************************************************************************** * * * M e s s a g e T r a n s l a t o r * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTRANSLATOR_H #define FXTRANSLATOR_H #ifndef FXOBJECT_H #include "FXObject.h" #endif //////////////////////////// UNDER DEVELOPMENT //////////////////////////////// namespace FX { /** * The translator class translates a message to another language. */ class FXAPI FXTranslator : public FXObject { FXDECLARE(FXTranslator) private: FXTranslator(const FXTranslator&); FXTranslator &operator=(const FXTranslator&); public: /// Construct translator FXTranslator(); /// Translate a string virtual const FXchar* tr(const FXchar* context,const FXchar* message,const FXchar* hint=nullptr,FXint count=-1) const FX_FORMAT(2) ; /// Save translator to a stream virtual void save(FXStream& store) const; /// Load translator from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXTranslator(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXTreeList.h000066400000000000000000000534271455751074500226360ustar00rootroot00000000000000/******************************************************************************** * * * T r e e L i s t W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTREELIST_H #define FXTREELIST_H #ifndef FXSCROLLAREA_H #include "FXScrollArea.h" #endif namespace FX { class FXIcon; class FXFont; class FXTreeList; class FXDirList; /// Tree list styles enum { TREELIST_EXTENDEDSELECT = 0, /// Extended selection mode allows for drag-selection of ranges of items TREELIST_SINGLESELECT = 0x00100000, /// Single selection mode allows up to one item to be selected TREELIST_BROWSESELECT = 0x00200000, /// Browse selection mode enforces one single item to be selected at all times TREELIST_MULTIPLESELECT = 0x00300000, /// Multiple selection mode is used for selection of individual items TREELIST_AUTOSELECT = 0x00400000, /// Automatically select under cursor TREELIST_SHOWS_LINES = 0x00800000, /// Lines shown TREELIST_SHOWS_BOXES = 0x01000000, /// Boxes to expand shown TREELIST_ROOT_BOXES = 0x02000000, /// Display root boxes also TREELIST_NORMAL = TREELIST_EXTENDEDSELECT }; /// Tree list Item class FXAPI FXTreeItem : public FXObject { FXDECLARE(FXTreeItem) friend class FXTreeList; friend class FXDirList; protected: FXTreeItem *parent; // Parent item FXTreeItem *prev; // Previous item FXTreeItem *next; // Next item FXTreeItem *first; // First child item FXTreeItem *last; // Last child item FXString label; // Text of item FXIcon *openIcon; // Icon of item FXIcon *closedIcon; // Icon of item FXptr data; // Item user data pointer FXuint state; // Item state flags FXint x,y; private: FXTreeItem(const FXTreeItem&); FXTreeItem& operator=(const FXTreeItem&); protected: FXTreeItem():parent(nullptr),prev(nullptr),next(nullptr),first(nullptr),last(nullptr),openIcon(nullptr),closedIcon(nullptr),data(nullptr),state(0),x(0),y(0){} virtual void draw(const FXTreeList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; virtual FXint hitItem(const FXTreeList* list,FXint x,FXint y) const; public: enum{ SELECTED = 1, /// Selected FOCUS = 2, /// Focus DISABLED = 4, /// Disabled OPENED = 8, /// Opened EXPANDED = 16, /// Expanded HASITEMS = 32, /// Has virtual subitems DRAGGABLE = 64, /// Draggable OPENICONOWNED = 128, /// Open icon owned by item CLOSEDICONOWNED = 256 /// Close icon owned by item }; public: /// Constructor FXTreeItem(const FXString& text,FXIcon* oi=nullptr,FXIcon* ci=nullptr,FXptr ptr=nullptr):parent(nullptr),prev(nullptr),next(nullptr),first(nullptr),last(nullptr),label(text),openIcon(oi),closedIcon(ci),data(ptr),state(0),x(0),y(0){} /// Get parent item FXTreeItem* getParent() const { return parent; } /// Get next sibling item FXTreeItem* getNext() const { return next; } /// Get previous sibling item FXTreeItem* getPrev() const { return prev; } /// Get first child item FXTreeItem* getFirst() const { return first; } /// Get last child item FXTreeItem* getLast() const { return last; } /// Get item below this one in list FXTreeItem* getBelow() const; /// Get item above this one in list FXTreeItem* getAbove() const; /// Get number of children of item FXint getNumChildren() const; /// Change item label virtual void setText(const FXString& txt); /// Get item label const FXString& getText() const { return label; } /// Change open icon, deleting the old icon if it was owned virtual void setOpenIcon(FXIcon* icn,FXbool owned=false); /// Get open icon FXIcon* getOpenIcon() const { return openIcon; } /// Change closed icon, deleting the old icon if it was owned virtual void setClosedIcon(FXIcon* icn,FXbool owned=false); /// Get closed icon FXIcon* getClosedIcon() const { return closedIcon; } /// Change item user data void setData(FXptr ptr){ data=ptr; } /// Get item user data FXptr getData() const { return data; } /// Make item draw as focused virtual void setFocus(FXbool focus); /// Return true if item has focus FXbool hasFocus() const { return (state&FOCUS)!=0; } /// Select item virtual void setSelected(FXbool selected); /// Return true if this item is selected FXbool isSelected() const { return (state&SELECTED)!=0; } /// Make item show as open virtual void setOpened(FXbool opened); /// Return true if this item is open FXbool isOpened() const { return (state&OPENED)!=0; } /// Expand or collapse item virtual void setExpanded(FXbool expanded); /// Return true if this item is expanded into sub items FXbool isExpanded() const { return (state&EXPANDED)!=0; } /// Enable or disable item virtual void setEnabled(FXbool enabled); /// Return true if this item is enabled FXbool isEnabled() const { return (state&DISABLED)==0; } /// Make item draggable virtual void setDraggable(FXbool draggable); /// Return true if this item is draggable FXbool isDraggable() const { return (state&DRAGGABLE)!=0; } /// Return true if subitems, real or imagined FXbool hasItems() const { return (state&HASITEMS)!=0; } /// Change has items flag void setHasItems(FXbool flag); /// Return true if descendent of parent item FXbool isChildOf(const FXTreeItem* item) const; /// Return true if ancestor of child item FXbool isParentOf(const FXTreeItem* item) const; /// Return tip text virtual FXString getTipText() const; /// Return width of item as drawn in list virtual FXint getWidth(const FXTreeList* list) const; /// Return height of item as drawn in list virtual FXint getHeight(const FXTreeList* list) const; /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Destroy server-side resources virtual void destroy(); /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); /// Destroy item and free icons if owned virtual ~FXTreeItem(); }; /// Tree item collate function typedef FXint (*FXTreeListSortFunc)(const FXTreeItem*,const FXTreeItem*); /** * A Tree List Widget organizes items in a hierarchical, tree-like fashion. * Subtrees can be collapsed or expanded by double-clicking on an item * or by clicking on the optional plus button in front of the item. * Each item may have a text and optional open-icon as well as a closed-icon. * The items may be connected by optional lines to show the hierarchical * relationship. * When an item's selected state changes, the treelist emits a SEL_SELECTED * or SEL_DESELECTED message. If an item is opened or closed, a message * of type SEL_OPENED or SEL_CLOSED is sent. When the subtree under an * item is expanded, a SEL_EXPANDED or SEL_COLLAPSED message is issued. * A change of the current item is signified by the SEL_CHANGED message. * In addition, the tree list sends SEL_COMMAND messages when the user * clicks on an item, and SEL_CLICKED, SEL_DOUBLECLICKED, and SEL_TRIPLECLICKED * when the user clicks once, twice, or thrice, respectively. * When items are added or removed, the tree list sends messages of the * type SEL_INSERTED or SEL_DELETED. * In each of these cases, a pointer to the item, if any, is passed in the * 3rd argument of the message. */ class FXAPI FXTreeList : public FXScrollArea { FXDECLARE(FXTreeList) protected: FXTreeItem *firstitem; // First root item FXTreeItem *lastitem; // Last root item FXTreeItem *anchoritem; // Selection anchor item FXTreeItem *currentitem; // Current item FXTreeItem *extentitem; // Selection extent FXTreeItem *viewableitem; // Visible item FXFont *font; // Font FXTreeListSortFunc sortfunc; // Item sort function FXColor textColor; // Text color FXColor selbackColor; // Selected background color FXColor seltextColor; // Selected text color FXColor lineColor; // Line color FXint treeWidth; // Tree width FXint treeHeight; // Tree height FXint visible; // Number of visible items FXint indent; // Parent to child indentation FXint grabx; // Grab point x FXint graby; // Grab point y FXString lookup; // Lookup string FXString tip; FXString help; // Help string FXbool state; // State of item protected: FXTreeList(); virtual FXTreeItem* createItem(const FXString& text,FXIcon* oi,FXIcon* ci,FXptr ptr); void sort(FXTreeItem*& f1,FXTreeItem*& t1,FXTreeItem*& f2,FXTreeItem*& t2,int n); void recompute(); private: FXTreeList(const FXTreeList&); FXTreeList& operator=(const FXTreeList&); public: long onPaint(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onRightBtnPress(FXObject*,FXSelector,void*); long onRightBtnRelease(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onTipTimer(FXObject*,FXSelector,void*); long onFocusIn(FXObject*,FXSelector,void*); long onFocusOut(FXObject*,FXSelector,void*); long onAutoScroll(FXObject*,FXSelector,void*); long onClicked(FXObject*,FXSelector,void*); long onDoubleClicked(FXObject*,FXSelector,void*); long onTripleClicked(FXObject*,FXSelector,void*); long onCommand(FXObject*,FXSelector,void*); long onLookupTimer(FXObject*,FXSelector,void*); public: static FXint ascending(const FXTreeItem*,const FXTreeItem*); static FXint descending(const FXTreeItem*,const FXTreeItem*); static FXint ascendingCase(const FXTreeItem*,const FXTreeItem*); static FXint descendingCase(const FXTreeItem*,const FXTreeItem*); public: enum { ID_LOOKUPTIMER=FXScrollArea::ID_LAST, ID_LAST }; public: /// Construct a new, initially empty tree list FXTreeList(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=TREELIST_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Perform layout virtual void layout(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Compute and return content width virtual FXint getContentWidth(); /// Return content height virtual FXint getContentHeight(); /// Recalculate layout virtual void recalc(); /// Tree list can receive focus virtual FXbool canFocus() const; /// Move the focus to this window virtual void setFocus(); /// Remove the focus from this window virtual void killFocus(); /// Return number of items FXint getNumItems() const; /// Return number of visible items FXint getNumVisible() const { return visible; } /// Change number of visible items void setNumVisible(FXint nvis); /// Return first root item FXTreeItem* getFirstItem() const { return firstitem; } /// Return last root item FXTreeItem* getLastItem() const { return lastitem; } /// Fill tree list by appending items from array of strings FXint fillItems(FXTreeItem* father,const FXchar *const *strings,FXIcon* oi=nullptr,FXIcon* ci=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Fill tree list by appending items from array of strings FXint fillItems(FXTreeItem* father,const FXString* strings,FXIcon* oi=nullptr,FXIcon* ci=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Fill tree list by appending items from newline separated strings FXint fillItems(FXTreeItem* father,const FXString& strings,FXIcon* oi=nullptr,FXIcon* ci=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Replace the original item orig with new [possibly subclassed] item FXTreeItem* setItem(FXTreeItem* orig,FXTreeItem* item,FXbool notify=false); /// Insert [possibly subclassed] item under father before other item FXTreeItem* insertItem(FXTreeItem* other,FXTreeItem* father,FXTreeItem* item,FXbool notify=false); /// Insert item with given text and optional icons, and user-data pointer under father before other item FXTreeItem* insertItem(FXTreeItem* other,FXTreeItem* father,const FXString& text,FXIcon* oi=nullptr,FXIcon* ci=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Append [possibly subclassed] item as last child of father FXTreeItem* appendItem(FXTreeItem* father,FXTreeItem* item,FXbool notify=false); /// Append item with given text and optional icons, and user-data pointer as last child of father FXTreeItem* appendItem(FXTreeItem* father,const FXString& text,FXIcon* oi=nullptr,FXIcon* ci=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Prepend [possibly subclassed] item as first child of father FXTreeItem* prependItem(FXTreeItem* father,FXTreeItem* item,FXbool notify=false); /// Prepend item with given text and optional icons, and user-data pointer as first child of father FXTreeItem* prependItem(FXTreeItem* father,const FXString& text,FXIcon* oi=nullptr,FXIcon* ci=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Move item under father before other item FXTreeItem *moveItem(FXTreeItem* other,FXTreeItem* father,FXTreeItem* item); /// Extract item FXTreeItem* extractItem(FXTreeItem* item,FXbool notify=false); /// Remove item void removeItem(FXTreeItem* item,FXbool notify=false); /// Remove items in range [fm, to] inclusively void removeItems(FXTreeItem* fm,FXTreeItem* to,FXbool notify=false); /// Remove all items from list void clearItems(FXbool notify=false); /// Return item width FXint getItemWidth(const FXTreeItem* item) const { return item->getWidth(this); } /// Return item height FXint getItemHeight(const FXTreeItem* item) const { return item->getHeight(this); } /// Get item at x,y, if any virtual FXTreeItem* getItemAt(FXint x,FXint y) const; /// Return item hit code: 0 outside, 1 icon, 2 text, 3 box FXint hitItem(const FXTreeItem* item,FXint x,FXint y) const; /// Scroll to make item visible virtual void makeItemVisible(FXTreeItem* item); /** * Search items by name, beginning from item start. If the start item * is NULL the search will start at the first, top-most item in the list. * Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control the search * direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP * to control whether the search wraps at the start or end of the list. * The option SEARCH_IGNORECASE causes a case-insensitive match. Finally, * passing SEARCH_PREFIX causes searching for a prefix of the item name. * Return NULL if no matching item is found. */ FXTreeItem* findItem(const FXString& string,FXTreeItem* start=nullptr,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; /** * Search items by associated user data, beginning from item start. If the * start item is NULL the search will start at the first, top-most item * in the list. Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control * the search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP * to control whether the search wraps at the start or end of the list. */ FXTreeItem* findItemByData(FXptr ptr,FXTreeItem* start=nullptr,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; /// Change item's text void setItemText(FXTreeItem* item,const FXString& text); /// Return item's text FXString getItemText(const FXTreeItem* item) const; /// Change item's open icon void setItemOpenIcon(FXTreeItem* item,FXIcon* icon,FXbool owned=false); /// Return item's open icon, deleting the old icon if it was owned FXIcon* getItemOpenIcon(const FXTreeItem* item) const; /// Chance item's closed icon, deleting the old icon if it was owned void setItemClosedIcon(FXTreeItem* item,FXIcon* icon,FXbool owned=false); /// Return item's closed icon FXIcon* getItemClosedIcon(const FXTreeItem* item) const; /// Change item user-data pointer void setItemData(FXTreeItem* item,void* ptr) const; /// Return item user-data pointer void* getItemData(const FXTreeItem* item) const; /// Return true if item is selected FXbool isItemSelected(const FXTreeItem* item) const; /// Return true if item is current FXbool isItemCurrent(const FXTreeItem* item) const; /// Return true if item is visible FXbool isItemVisible(const FXTreeItem* item) const; /// Return true if item opened FXbool isItemOpened(const FXTreeItem* item) const; /// Return true if item expanded FXbool isItemExpanded(const FXTreeItem* item) const; /// Return true if item is a leaf-item, i.e. has no children FXbool isItemLeaf(const FXTreeItem* item) const; /// Return true if item is enabled FXbool isItemEnabled(const FXTreeItem* item) const; /// Repaint item void updateItem(FXTreeItem* item) const; /// Enable item virtual FXbool enableItem(FXTreeItem* item); /// Disable item virtual FXbool disableItem(FXTreeItem* item); /// Select item virtual FXbool selectItem(FXTreeItem* item,FXbool notify=false); /// Deselect item virtual FXbool deselectItem(FXTreeItem* item,FXbool notify=false); /// Toggle item selection virtual FXbool toggleItem(FXTreeItem* item,FXbool notify=false); /// Extend selection from anchor item to item virtual FXbool extendSelection(FXTreeItem* item,FXbool notify=false); /// Select all items virtual FXbool selectAll(FXbool notify=false); /// Deselect all items virtual FXbool killSelection(FXbool notify=false); /// Open item virtual FXbool openItem(FXTreeItem* item,FXbool notify=false); /// Close item virtual FXbool closeItem(FXTreeItem* item,FXbool notify=false); /// Collapse tree virtual FXbool collapseTree(FXTreeItem* tree,FXbool notify=false); /// Expand tree virtual FXbool expandTree(FXTreeItem* tree,FXbool notify=false); /// Change current item virtual void setCurrentItem(FXTreeItem* item,FXbool notify=false); /// Return current item, if any FXTreeItem* getCurrentItem() const { return currentitem; } /// Change anchor item void setAnchorItem(FXTreeItem* item); /// Return anchor item, if any FXTreeItem* getAnchorItem() const { return anchoritem; } /// Sort all items recursively void sortItems(); /// Sort root items void sortRootItems(); /// Sort children of item void sortChildItems(FXTreeItem* item); /// Return sort function FXTreeListSortFunc getSortFunc() const { return sortfunc; } /// Change sort function void setSortFunc(FXTreeListSortFunc func){ sortfunc=func; } /// Change text font void setFont(FXFont* fnt); /// Return text font FXFont* getFont() const { return font; } /// Change parent-child indent amount void setIndent(FXint in); /// Return parent-child indent amount FXint getIndent() const { return indent; } /// Return normal text color FXColor getTextColor() const { return textColor; } /// Change normal text color void setTextColor(FXColor clr); /// Return selected text background FXColor getSelBackColor() const { return selbackColor; } /// Change selected text background void setSelBackColor(FXColor clr); /// Return selected text color FXColor getSelTextColor() const { return seltextColor; } /// Change selected text color void setSelTextColor(FXColor clr); /// Return line color FXColor getLineColor() const { return lineColor; } /// Change line color void setLineColor(FXColor clr); /// Return list style FXuint getListStyle() const; /// Change list style void setListStyle(FXuint style); /// Set the status line help text for this list void setHelpText(const FXString& text); /// Get the status line help text for this list const FXString& getHelpText() const { return help; } /// Save object to a stream virtual void save(FXStream& store) const; /// Load object from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXTreeList(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXTreeListBox.h000066400000000000000000000250051455751074500232760ustar00rootroot00000000000000/******************************************************************************** * * * T r e e L i s t B o x W i d g e t * * * ********************************************************************************* * Copyright (C) 1999,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTREELISTBOX_H #define FXTREELISTBOX_H #ifndef FXPACKER_H #include "FXPacker.h" #endif namespace FX { /// Tree List Box styles enum { TREELISTBOX_NORMAL = 0 /// Normal style }; class FXButton; class FXMenuButton; class FXTreeList; class FXPopup; /** * The Tree List Box behaves very much like a List Box, except that * it supports a hierarchical, tree structured display of the items. * When an item is selected it issues a SEL_COMMAND message with the * pointer to the item. While manipulating the tree list, it may send * SEL_CHANGED messages to indicate which item the cursor is hovering over. * When items are added, replaced, or removed, the list sends messages of * the type SEL_INSERTED, SEL_REPLACED, or SEL_DELETED, with the pointer to * the affected item as argument. */ class FXAPI FXTreeListBox : public FXPacker { FXDECLARE(FXTreeListBox) protected: FXButton *field; FXMenuButton *button; FXTreeList *tree; FXPopup *pane; protected: FXTreeListBox(){} private: FXTreeListBox(const FXTreeListBox&); FXTreeListBox& operator=(const FXTreeListBox&); public: long onFocusUp(FXObject*,FXSelector,void*); long onFocusDown(FXObject*,FXSelector,void*); long onFocusSelf(FXObject*,FXSelector,void*); long onMouseWheel(FXObject*,FXSelector,void*); long onFieldButton(FXObject*,FXSelector,void*); long onTreeUpdate(FXObject*,FXSelector,void*); long onTreeForward(FXObject*,FXSelector,void*); long onTreeClicked(FXObject*,FXSelector,void*); long onTreeCommand(FXObject*,FXSelector,void*); public: enum{ ID_TREE=FXPacker::ID_LAST, ID_FIELD, ID_LAST }; public: /// Construct tree list box FXTreeListBox(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=FRAME_SUNKEN|FRAME_THICK|TREELISTBOX_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Destroy server-side resources virtual void destroy(); /// Perform layout virtual void layout(); /// Enable widget virtual void enable(); /// Disable widget virtual void disable(); /// Return default with virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); /// Return number of items FXint getNumItems() const; /// Return number of visible items FXint getNumVisible() const; /// Set number of visible items to determine default height void setNumVisible(FXint nvis); /// Return first top-level item FXTreeItem* getFirstItem() const; /// Return last top-level item FXTreeItem* getLastItem() const; /// Return true if item is the current item FXbool isItemCurrent(const FXTreeItem* item) const; /// Change current item virtual void setCurrentItem(FXTreeItem* item,FXbool notify=false); /// Return current item FXTreeItem* getCurrentItem() const; /// Fill tree list box by appending items from array of strings FXint fillItems(FXTreeItem* father,const FXchar *const *strings,FXIcon* oi=nullptr,FXIcon* ci=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Fill tree list box by appending items from array of strings FXint fillItems(FXTreeItem* father,const FXString* strings,FXIcon* oi=nullptr,FXIcon* ci=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Fill tree list box by appending items from newline separated strings FXint fillItems(FXTreeItem* father,const FXString& strings,FXIcon* oi=nullptr,FXIcon* ci=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Replace the original item orig with new [possibly subclassed] item FXTreeItem* setItem(FXTreeItem* orig,FXTreeItem* item,FXbool notify=false); /// Insert [possibly subclassed] item under father before other item FXTreeItem* insertItem(FXTreeItem* other,FXTreeItem* father,FXTreeItem* item,FXbool notify=false); /// Insert item with given text and optional icons, and user-data pointer under father before other item FXTreeItem* insertItem(FXTreeItem* other,FXTreeItem* father,const FXString& text,FXIcon* oi=nullptr,FXIcon* ci=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Append [possibly subclassed] item as last child of father FXTreeItem* appendItem(FXTreeItem* father,FXTreeItem* item,FXbool notify=false); /// Append item with given text and optional icons, and user-data pointer as last child of father FXTreeItem* appendItem(FXTreeItem* father,const FXString& text,FXIcon* oi=nullptr,FXIcon* ci=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Prepend [possibly subclassed] item as first child of father FXTreeItem* prependItem(FXTreeItem* father,FXTreeItem* item,FXbool notify=false); /// Prepend item with given text and optional icons, and user-data pointer as first child of father FXTreeItem* prependItem(FXTreeItem* father,const FXString& text,FXIcon* oi=nullptr,FXIcon* ci=nullptr,FXptr ptr=nullptr,FXbool notify=false); /// Move item under father before other item FXTreeItem *moveItem(FXTreeItem* other,FXTreeItem* father,FXTreeItem* item); /// Extract item FXTreeItem* extractItem(FXTreeItem* item,FXbool notify=false); /// Remove item void removeItem(FXTreeItem* item,FXbool notify=false); /// Remove all items in range [fm...to] void removeItems(FXTreeItem* fm,FXTreeItem* to,FXbool notify=false); /// Remove all items from list void clearItems(FXbool notify=false); /** * Search items by name, beginning from item start. If the * start item is NULL the search will start at the first, top-most item * in the list. Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control * the search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP * to control whether the search wraps at the start or end of the list. * The option SEARCH_IGNORECASE causes a case-insensitive match. Finally, * passing SEARCH_PREFIX causes searching for a prefix of the item name. * Return NULL if no matching item is found. */ FXTreeItem* findItem(const FXString& string,FXTreeItem* start=nullptr,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; /** * Search items by associated user data, beginning from item start. If the * start item is NULL the search will start at the first, top-most item * in the list. Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control * the search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP * to control whether the search wraps at the start or end of the list. */ FXTreeItem* findItemByData(FXptr ptr,FXTreeItem* start=nullptr,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; /// Change item label void setItemText(FXTreeItem* item,const FXString& text); /// Return item label FXString getItemText(const FXTreeItem* item) const; /// Change item's open icon, delete old one if it was owned void setItemOpenIcon(FXTreeItem* item,FXIcon* icon,FXbool owned=false); /// Return item's open icon FXIcon* getItemOpenIcon(const FXTreeItem* item) const; /// Change item's closed icon, delete old one if it was owned void setItemClosedIcon(FXTreeItem* item,FXIcon* icon,FXbool owned=false); /// Return item's closed icon FXIcon* getItemClosedIcon(const FXTreeItem* item) const; /// Change item's user data void setItemData(FXTreeItem* item,FXptr ptr) const; /// Return item's user data FXptr getItemData(const FXTreeItem* item) const; /// Return true if item is leaf-item, i.e. has no children FXbool isItemLeaf(const FXTreeItem* item) const; /// Return true if item is enabled FXbool isItemEnabled(const FXTreeItem* item) const; /// Enable item FXbool enableItem(FXTreeItem* item); /// Disable item FXbool disableItem(FXTreeItem* item); /// Show or hide menu void showMenu(FXbool shw); /// Is the menu pane shown FXbool isMenuShown() const; /// Sort all items recursively void sortItems(); /// Sort the toplevel items with the sort function void sortRootItems(); /// Sort child items of item void sortChildItems(FXTreeItem* item); /// Change font void setFont(FXFont* fnt); /// Return font FXFont* getFont() const; /// Change list style void setListStyle(FXuint style); /// Return list style FXuint getListStyle() const; /// Change popup pane shrinkwrap mode void setShrinkWrap(FXbool flag); /// Return popup pane shrinkwrap mode FXbool getShrinkWrap() const; /// Return item sort function FXTreeListSortFunc getSortFunc() const; /// Change item sort function void setSortFunc(FXTreeListSortFunc func); /// Change help text void setHelpText(const FXString& txt); /// Return help text const FXString& getHelpText() const; /// Change tip text void setTipText(const FXString& txt); /// Return tip text const FXString& getTipText() const; /// Save object to a stream virtual void save(FXStream& store) const; /// Load object from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXTreeListBox(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXTriStateButton.h000066400000000000000000000104101455751074500240170ustar00rootroot00000000000000/******************************************************************************** * * * T r i - S t a t e B u t t o n W i d g e t * * * ********************************************************************************* * Copyright (C) 2002,2022 by Charles Warren. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXTRISTATEBUTTON_H #define FXTRISTATEBUTTON_H #ifndef FXTOGGLEBUTTON_H #include "FXToggleButton.h" #endif namespace FX { /** * The tri-state button provides a three-state button, which toggles between the * on and the off state each time it is pressed; programmatically, it may also be * switched into the MAYBE state. The MAYBE state is useful to signify an unknown * state in the application data. * Like the toggle button, it sends a SEL_COMMAND to its target, with the * message data set to the current state of the toggle button, of the type FXbool. */ class FXAPI FXTriStateButton : public FXToggleButton { FXDECLARE(FXTriStateButton) protected: FXString maybelabel; FXIcon *maybeicon; FXString maybetip; FXString maybehelp; protected: FXTriStateButton(); private: FXTriStateButton(const FXTriStateButton&); FXTriStateButton& operator=(const FXTriStateButton&); public: long onPaint(FXObject*,FXSelector,void*); long onUnknown(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); public: /// Construct tri-state toggle button with three text labels, and three icons, one for each state FXTriStateButton(FXComposite* p,const FXString& text1,const FXString& text2,const FXString& text3,FXIcon* icon1=nullptr,FXIcon* icon2=nullptr,FXIcon* icon3=nullptr,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=TOGGLEBUTTON_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); /// Create server-side resources virtual void create(); /// Detach server-side resources virtual void detach(); /// Get default width virtual FXint getDefaultWidth(); /// Get default height virtual FXint getDefaultHeight(); /// Change maybe text shown when toggled void setMaybeText(const FXString& text); /// Return maybe text FXString getMaybeText() const { return maybelabel; } /// Change maybe icon shown when toggled void setMaybeIcon(FXIcon* ic); /// Return maybe icon FXIcon* getMaybeIcon() const { return maybeicon; } /// Change maybe help text shown when toggled void setMaybeHelpText(const FXString& text); /// Return maybe help text FXString getMaybeHelpText() const { return maybehelp; } /// Change maybe tip text shown when toggled void setMaybeTipText(const FXString& text); /// Return maybe tip text FXString getMaybeTipText() const { return maybetip; } /// Save toggle button to a stream virtual void save(FXStream& store) const; /// Load toggle button from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXTriStateButton(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXURL.h000066400000000000000000000063041455751074500215350ustar00rootroot00000000000000/******************************************************************************** * * * U R L M a n i p u l a t i o n * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXURL_H #define FXURL_H namespace FX { namespace FXURL { /// Encode control characters and characters from set using %-encoding extern FXAPI FXString encode(const FXString& string,const FXchar* set=nullptr); /// Decode string containing %-encoded characters extern FXAPI FXString decode(const FXString& string); /// Parse scheme from string containing url extern FXAPI FXString scheme(const FXString& string); /// Parse username from string containing url extern FXAPI FXString username(const FXString& string); /// Parse password from string containing url extern FXAPI FXString password(const FXString& string); /// Parse hostname from string containing url extern FXAPI FXString host(const FXString& string); /// Parse port number from string containing url extern FXAPI FXint port(const FXString& string,FXint def=0); /// Parse path from string containing url extern FXAPI FXString path(const FXString& string); /// Parse query from string containing url extern FXAPI FXString query(const FXString& string); /// Parse fragment from string containing url extern FXAPI FXString fragment(const FXString& string); /// Return URL of filename extern FXAPI FXString fileToURL(const FXString& string); /// Return filename from URL, empty if url is not a local file extern FXAPI FXString fileFromURL(const FXString& string); /// Make URI list from array of filenames extern FXAPI FXString filesToURIList(const FXString* files); /// Make array of filenames from URI list extern FXAPI FXString* filesFromURIList(const FXString& urilist); } } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXUTF16Codec.h000066400000000000000000000065571455751074500226500ustar00rootroot00000000000000/******************************************************************************** * * * U T F - 1 6 T e x t C o d e c * * * ********************************************************************************* * Copyright (C) 2002,2022 by L.Johnson & J.van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXUTF16CODEC_H #define FXUTF16CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// Codec for UTF-16BE class FXAPI FXUTF16BECodec : public FXTextCodec { FXDECLARE(FXUTF16BECodec) public: FXUTF16BECodec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual FXint mibEnum() const; virtual const FXchar* const* aliases() const; virtual ~FXUTF16BECodec(){} }; /// Codec for UTF-16LE class FXAPI FXUTF16LECodec : public FXTextCodec { FXDECLARE(FXUTF16LECodec) public: FXUTF16LECodec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual FXint mibEnum() const; virtual const FXchar* const* aliases() const; virtual ~FXUTF16LECodec(){} }; /// Codec for UTF-16 class FXAPI FXUTF16Codec : public FXTextCodec { FXDECLARE(FXUTF16Codec) public: FXUTF16Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint mb2utflen(const FXchar* src,FXint nsrc) const; virtual FXint mb2utf(FXchar* dst,FXint ndst,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint utf2mblen(const FXchar* src,FXint nsrc) const; virtual FXint utf2mb(FXchar* dst,FXint ndst,const FXchar* src,FXint nsrc) const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual FXint mibEnum() const; virtual const FXchar* const* aliases() const; virtual ~FXUTF16Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXUTF32Codec.h000066400000000000000000000065611455751074500226410ustar00rootroot00000000000000/******************************************************************************** * * * U T F - 3 2 T e x t C o d e c * * * ********************************************************************************* * Copyright (C) 2002,2022 by L.Johnson & J.van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXUTF32CODEC_H #define FXUTF32CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// Codec for UTF-32BE class FXAPI FXUTF32BECodec : public FXTextCodec { FXDECLARE(FXUTF32BECodec) public: FXUTF32BECodec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual FXint mibEnum() const; virtual const FXchar* const* aliases() const; virtual ~FXUTF32BECodec(){} }; /// Codec for UTF-32LE class FXAPI FXUTF32LECodec : public FXTextCodec { FXDECLARE(FXUTF32LECodec) public: FXUTF32LECodec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual FXint mibEnum() const; virtual const FXchar* const* aliases() const; virtual ~FXUTF32LECodec(){} }; /// Codec for UTF-32 class FXAPI FXUTF32Codec : public FXTextCodec { FXDECLARE(FXUTF32Codec) public: FXUTF32Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint mb2utflen(const FXchar* src,FXint nsrc) const; virtual FXint mb2utf(FXchar* dst,FXint ndst,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual FXint utf2mblen(const FXchar* src,FXint nsrc) const; virtual FXint utf2mb(FXchar* dst,FXint ndst,const FXchar* src,FXint nsrc) const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual FXint mibEnum() const; virtual const FXchar* const* aliases() const; virtual ~FXUTF32Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXUTF8Codec.h000066400000000000000000000042151455751074500225560ustar00rootroot00000000000000/******************************************************************************** * * * U T F - 8 T e x t C o d e c * * * ********************************************************************************* * Copyright (C) 2002,2022 by L.Johnson & J.van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXUTF8CODEC_H #define FXUTF8CODEC_H #ifndef FXTEXTCODEC_H #include "FXTextCodec.h" #endif namespace FX { /// Codec for UTF-8 class FXAPI FXUTF8Codec : public FXTextCodec { public: FXUTF8Codec(){} virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const; virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const; virtual const FXchar* name() const; virtual const FXchar* mimeName() const; virtual FXint mibEnum() const; virtual const FXchar* const* aliases() const; virtual ~FXUTF8Codec(){} }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXUndoList.h000066400000000000000000000233661455751074500226430ustar00rootroot00000000000000/******************************************************************************** * * * U n d o / R e d o - a b l e C o m m a n d * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXUNDOLIST_H #define FXUNDOLIST_H #ifndef FXOBJECT_H #include "FXObject.h" #endif namespace FX { class FXUndoList; class FXCommandGroup; /** * Base class for undoable commands. Each undo records all the * information necessary to undo as well as redo a given operation. * Since commands are derived from FXObject, subclassed commands can * both send and receive messages (like ID_GETINTVALUE, for example). */ class FXAPI FXCommand : public FXObject { FXDECLARE_ABSTRACT(FXCommand) friend class FXUndoList; friend class FXCommandGroup; private: FXCommand *next; private: FXCommand(const FXCommand&); FXCommand &operator=(const FXCommand&); protected: FXCommand():next(nullptr){} public: /** * Undo this command; this should save the * information for a subsequent redo. */ virtual void undo() = 0; /** * Redo this command; this should save the * information for a subsequent undo. */ virtual void redo() = 0; /** * Return the size of the information in the undo record. * The undo list may be trimmed to limit memory usage to * a certain limit. The value returned should include * the size of the command record itself as well as any * data linked from it. */ virtual FXuint size() const; /** * Name of the undo command to be shown on a button; * for example, "Undo Delete". */ virtual FXString undoName() const; /** * Name of the redo command to be shown on a button; * for example, "Redo Delete". */ virtual FXString redoName() const; /** * Return true if this command can be merged with previous undo * commands. This is useful to combine e.g. multiple consecutive * single-character text changes into a single block change. * The default implementation returns false. */ virtual FXbool canMerge() const; /** * Called by the undo system to try and merge the new incoming command * with this command; should return true if merging was possible. * The default implementation returns false. */ virtual FXbool mergeWith(FXCommand* command); /// Delete undo command virtual ~FXCommand(){} }; /** * Group of undoable commands. A group may comprise multiple * individual actions which together undo (or redo) a larger * operation. Even larger operations may be built by nesting * multiple undo groups. */ class FXAPI FXCommandGroup : public FXCommand { FXDECLARE(FXCommandGroup) friend class FXUndoList; private: FXCommand *undolist; FXCommand *redolist; FXCommandGroup *group; private: FXCommandGroup(const FXCommandGroup&); FXCommandGroup &operator=(const FXCommandGroup&); public: /// Construct initially empty undo command group FXCommandGroup():undolist(nullptr),redolist(nullptr),group(nullptr){} /// Return true if empty FXbool empty(){ return !undolist; } /// Undo whole command group virtual void undo(); /// Redo whole command group virtual void redo(); /// Return the size of the command group virtual FXuint size() const; /// Delete undo command and sub-commands virtual ~FXCommandGroup(); }; /** * The Undo List class manages a list of undoable commands. */ class FXAPI FXUndoList : public FXCommandGroup { FXDECLARE(FXUndoList) private: FXint undocount; // Number of undo records FXint redocount; // Number of redo records FXint marker; // Marker value FXuint space; // Space taken up by all the undo records FXbool working; // Currently busy with undo or redo private: FXUndoList(const FXUndoList&); FXUndoList &operator=(const FXUndoList&); public: long onCmdUndo(FXObject*,FXSelector,void*); long onUpdUndo(FXObject*,FXSelector,void*); long onCmdRedo(FXObject*,FXSelector,void*); long onUpdRedo(FXObject*,FXSelector,void*); long onCmdClear(FXObject*,FXSelector,void*); long onUpdClear(FXObject*,FXSelector,void*); long onCmdRevert(FXObject*,FXSelector,void*); long onUpdRevert(FXObject*,FXSelector,void*); long onCmdUndoAll(FXObject*,FXSelector,void*); long onCmdRedoAll(FXObject*,FXSelector,void*); long onUpdUndoCount(FXObject*,FXSelector,void*); long onUpdRedoCount(FXObject*,FXSelector,void*); public: enum{ ID_CLEAR=FXWindow::ID_LAST, ID_REVERT, ID_UNDO, ID_REDO, ID_UNDO_ALL, ID_REDO_ALL, ID_UNDO_COUNT, ID_REDO_COUNT, ID_LAST }; public: /** * Make new empty undo list, initially unmarked. */ FXUndoList(); /** * Cut the redo list. * This is automatically invoked when a new undo command is added. */ void cut(); /** * Add new command, executing it if desired. The new command will be merged * with the previous command if merge is true and we're not at a marked position * and the commands are mergeable. Otherwise the new command will be appended * after the last undo command in the currently active undo group. * If the new command is successfully merged, it will be deleted. Furthermore, * all redo commands will be deleted since it is no longer possible to redo * from this point. */ void add(FXCommand* command,FXbool doit=false,FXbool merge=true); /** * Begin undo command sub-group. This begins a new group of commands that * are treated as a single command. Must eventually be followed by a * matching end() after recording the sub-commands. The new sub-group * will be appended to its parent group's undo list when end() is called. */ void begin(FXCommandGroup *command); /** * End undo command sub-group. If the sub-group is still empty, it will * be deleted; otherwise, the sub-group will be added as a new command * into parent group. * A matching begin() must have been called previously. */ void end(); /** * Abort the current command sub-group being compiled. All commands * already added to the sub-groups undo list will be discarded. * Intermediate command groups will be left intact. */ void abort(); /** * Undo last command. This will move the command to the redo list. */ virtual void undo(); /** * Redo next command. This will move the command back to the undo list. */ virtual void redo(); /// Undo all commands void undoAll(); /// Redo all commands void redoAll(); /// Revert to marked void revert(); /// Can we undo more commands FXbool canUndo() const; /// Can we redo more commands FXbool canRedo() const; /// Can revert to marked FXbool canRevert() const; /** * Return true if currently inside undo or redo operation; this * is useful to avoid generating another undo command while inside * an undo operation. */ FXbool busy() const { return working; } /// Current top level undo command FXCommand* current() const { return undolist; } /** * Return name of the first undo command available; if no * undo command available this will return the empty string. */ virtual FXString undoName() const; /** * Return name of the first redo command available; if no * Redo command available this will return the empty string. */ virtual FXString redoName() const; /// Number of undo records FXint undoCount() const { return undocount; } /// Number of redo records FXint redoCount() const { return redocount; } /// Size of undo information virtual FXuint size() const; /** * Clear list, and unmark all states. * All undo and redo information will be destroyed. */ void clear(); /** * Trim undo list down to at most nc commands. * Call this periodically to prevent the undo-list from growing * beyond a certain number of records. */ void trimCount(FXint nc); /** * Trim undo list down to at most size sz. * Call this periodically to prevent the undo-list from growing * beyond a certain amount of memory. */ void trimSize(FXuint sz); /** * Mark the current state of the undo list, which is initially unmarked. * There can be only one active mark at any time. Call mark() at any * time when you know the document to be "clean"; for example when you * save the document to disk. */ void mark(); /** * Unmark all states in the undo list. */ void unmark(); /** * Check if the current state was marked, if the application has returned * to the previously marked state. */ FXbool marked() const; }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXVariant.h000066400000000000000000000301511455751074500224740ustar00rootroot00000000000000/******************************************************************************** * * * V a r i a n t T y p e * * * ********************************************************************************* * Copyright (C) 2013,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXVARIANT_H #define FXVARIANT_H namespace FX { class FXString; class FXVariantMap; class FXVariantArray; /** * A Variant type can hold any kind of object, be it a boolean, integer, real, string, * or even array of Variants or dictionaries of variants. * Complex hierarchies of Variants can be loaded (and saved) using the JSON parser. * When writing Variants, dictionaries and arrays are automatically grown. When * reading Variants, non-existing dictionary entries or indexes outside arrays will read * as 0 (for numbers), the empty string, or as an empty dictionary or array. * For efficiency, you can hold references to Variants, for example to avoid repeatedly * accessing dictionaries or arrays with the same key or index. However, be aware that * adding or removing sub-items to dictionaries or arrays may cause reallocations of * existing items and thus some care must be exercised when doing this. */ class FXAPI FXVariant { public: enum Type { NullType=0, // Simple types BoolType, CharType, IntType, UIntType, LongType, ULongType, FloatType, DoubleType, PointerType, StringType, // Complex types ArrayType, MapType }; private: union Value { FXlong i; // Signed integral types FXulong u; // Unsigned integral types FXdouble d; // Floating point types FXchar* s; // Character string FXptr p; // Pointer types }; private: Value value; // Current value Type type; // Type of value private: FXbool init(Type t); public: /// Default constructor makes null type FXVariant(); /// Copy constructor FXVariant(const FXVariant& other); /// Construct and initialize with bool explicit FXVariant(FXbool val); /// Construct and initialize with char explicit FXVariant(FXchar val); /// Construct and initialize with int explicit FXVariant(FXint val); /// Construct and initialize with unsigned int explicit FXVariant(FXuint val); /// Construct and initialize with long explicit FXVariant(FXlong val); /// Construct and initialize with unsigned long explicit FXVariant(FXulong val); /// Construct and initialize with float explicit FXVariant(FXfloat val); /// Construct and initialize with double explicit FXVariant(FXdouble val); /// Construct and initialize with pointer explicit FXVariant(FXptr val); /// Construct and initialize with constant string explicit FXVariant(const FXchar *val); /// Construct and initialize with string explicit FXVariant(const FXString& val); /// Change type void setType(Type t); /// Return type Type getType() const { return type; } /// Return size of array FXival no() const; /// Change number of elements in array FXbool no(FXival n); /// Is it a null? FXbool isNull() const { return type==NullType; } /// Is it a bool? FXbool isBool() const { return type==BoolType; } /// Is it a character? FXbool isChar() const { return type==CharType; } /// Is it a int? FXbool isInt() const { return type==IntType; } /// Is it a unsigned int? FXbool isUInt() const { return type==UIntType; } /// Is it a long? FXbool isLong() const { return type==LongType; } /// Is it a unsigned long? FXbool isULong() const { return type==ULongType; } /// Is it a float? FXbool isFloat() const { return type==FloatType; } /// Is it a double? FXbool isDouble() const { return type==DoubleType; } /// Is it a integer (bool, char, ..., or long)? FXbool isInteger() const { return BoolType<=type && type<=ULongType; } /// Is it a real (float or double)? FXbool isReal() const { return FloatType<=type && type<=DoubleType; } /// Is it any kind of number? FXbool isNumber() const { return BoolType<=type && type<=DoubleType; } /// Is it a pointer? FXbool isPtr() const { return type==PointerType; } /// Is it a string? FXbool isString() const { return type==StringType; } /// Is it a array? FXbool isArray() const { return type==ArrayType; } /// Is it a map? FXbool isMap() const { return type==MapType; } /// Convert to bool; always OK FXbool toBool() const; /// Convert to pointer FXptr toPtr() const; /// Convert to int FXint toInt(FXbool* ok=nullptr) const; /// Convert to unsigned int FXuint toUInt(FXbool* ok=nullptr) const; /// Convert to long FXlong toLong(FXbool* ok=nullptr) const; /// Convert to unsigned long FXulong toULong(FXbool* ok=nullptr) const; /// Convert to float FXfloat toFloat(FXbool* ok=nullptr) const; /// Convert to double FXdouble toDouble(FXbool* ok=nullptr) const; /// Convert to char pointer const FXchar* toChars() const; /// Convert to string FXString toString(FXbool* ok=nullptr) const; /// Convert to bool operator FXbool() const { return toBool(); } /// Convert to pointer operator FXptr() const { return toPtr(); } /// Convert to char operator FXchar() const { return toInt(); } /// Convert to char operator FXuchar() const { return toUInt(); } /// Convert to short operator FXshort() const { return toInt(); } /// Convert to unsigned short operator FXushort() const { return toUInt(); } /// Convert to int operator FXint() const { return toInt(); } /// Convert to unsigned int operator FXuint() const { return toUInt(); } /// Convert to long operator FXlong() const { return toLong(); } /// Convert to unsigned long operator FXulong() const { return toULong(); } /// Convert to float operator FXfloat() const { return toFloat(); } /// Convert to double operator FXdouble() const { return toDouble(); } /// Convert to string operator FXString() const { return toString(); } /// Assign with bool FXVariant& operator=(FXbool val); /// Assign with char FXVariant& operator=(FXchar val); /// Assign with int FXVariant& operator=(FXint val); /// Assign with unsigned int FXVariant& operator=(FXuint val); /// Assign with long FXVariant& operator=(FXlong val); /// Assign with unsigned long FXVariant& operator=(FXulong val); /// Assign with float FXVariant& operator=(FXfloat val); /// Assign with double FXVariant& operator=(FXdouble val); /// Assign with pointer FXVariant& operator=(FXptr val); /// Assign with constant string FXVariant& operator=(const FXchar* val); /// Assign with string FXVariant& operator=(const FXString& val); /// Assign with variant FXVariant& operator=(const FXVariant& val); /// Assign with variant FXVariant& assign(const FXVariant& other); /// Adopt variant from another FXVariant& adopt(FXVariant& other); /// Return value of object member FXVariant& at(const FXchar* key); /// Return value of object member const FXVariant& at(const FXchar* key) const; /// Return value of object member FXVariant& operator[](const FXchar* key){ return at(key); } /// Return value of object member const FXVariant& operator[](const FXchar* key) const { return at(key); } /// Return value of object member FXVariant& at(const FXString& key); /// Return value of object member const FXVariant& at(const FXString& key) const; /// Return value of object member FXVariant& operator[](const FXString& key){ return at(key); } /// Return value of object member const FXVariant& operator[](const FXString& key) const { return at(key); } /// Return value of array member FXVariant& at(FXival idx); /// Return value of array member const FXVariant& at(FXival idx) const; /// Return value of array member FXVariant& operator[](FXint idx){ return at(idx); } const FXVariant& operator[](FXint idx) const { return at(idx); } /// Return value of array member FXVariant& operator[](FXival idx){ return at(idx); } const FXVariant& operator[](FXival idx) const { return at(idx); } /// Check if key is mapped FXbool has(const FXchar* key) const; /// Check if key is mapped FXbool has(const FXString& key) const { return has(key.text()); } /// Return the value of the variant as a pointer; variant type MUST be PointerType FXptr& asPtr(){ return value.p; } /// Return the value of the variant as a pointer; variant type MUST be PointerType const FXptr& asPtr() const { return value.p; } /// Return the value of the variant as a long; variant type MUST be LongType FXlong& asLong(){ return value.i; } /// Return the value of the variant as a long; variant type MUST be LongType const FXlong& asLong() const { return value.i; } /// Return the value of the variant as an unsigned long; variant type MUST be ULongType FXulong& asULong(){ return value.u; } /// Return the value of the variant as an unsigned long; variant type MUST be ULongType const FXulong& asULong() const { return value.u; } /// Return the value of the variant as a double; variant type MUST be DoubleType FXdouble& asDouble(){ return value.d; } /// Return the value of the variant as a double; variant type MUST be DoubleType const FXdouble& asDouble() const { return value.d; } /// Return the value of the variant as a char pointer; variant type MUST be StringType const FXchar* asChars() const { return value.s; } /// Return the value of the variant as a string-reference; variant type MUST be StringType FXString& asString(){ return *reinterpret_cast(&value.p); } /// Return the value of the variant as a const string-reference; variant type MUST be StringType const FXString& asString() const { return *reinterpret_cast(&value.p); } /// Return the value of the variant as an array-reference; variant type MUST be ArrayType FXVariantArray& asArray(){ return *reinterpret_cast(&value.p); } /// Return the value of the variant as a const array-reference; variant type MUST be ArrayType const FXVariantArray& asArray() const { return *reinterpret_cast(&value.p); } /// Return the value of the variant as an map-reference; variant type MUST be MapType FXVariantMap& asMap(){ return *reinterpret_cast(&value.p); } /// Return the value of the variant as a const map-reference; variant type MUST be MapType const FXVariantMap& asMap() const { return *reinterpret_cast(&value.p); } /// Remove variant at key from map FXbool remove(const FXchar* key); /// Remove variant at key from map FXbool remove(const FXString& key){ return remove(key.text()); } /// Erase variant at idx from array FXbool erase(FXival idx); /// Clear the data FXbool clear(); /// Default constant variant static const FXVariant null; /// Destroy ~FXVariant(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXVariantArray.h000066400000000000000000000043041455751074500234740ustar00rootroot00000000000000/******************************************************************************** * * * V a r i a n t - A r r a y * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXVARIANTARRAY_H #define FXVARIANTARRAY_H namespace FX { /// Array of variants class FXAPI FXVariantArray : public FXArray { public: /// Construct an array FXVariantArray(); /// Allocate array of n elements FXVariantArray(FXival n); /// Construct from another array FXVariantArray(const FXVariantArray& other); /// Allocate initialized with n copies of object FXVariantArray(const FXVariant& src,FXival n); /// Allocate initialized with array of n objects FXVariantArray(const FXVariant* src,FXival n); /// Destructor ~FXVariantArray(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXVariantMap.h000066400000000000000000000122111455751074500231270ustar00rootroot00000000000000/******************************************************************************** * * * V a r i a n t - M a p * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXVARIANTMAP_H #define FXVARIANTMAP_H namespace FX { /** * Variant map associates strings to variants using fast hash * table. */ class FXAPI FXVariantMap { protected: struct Entry { FXString key; // Lookup key FXVariant data; // Variant data FXuint hash; // Hash of key }; protected: Entry *table; // Hash table protected: // Change size of the table FXbool no(FXival n); // Change number of used entries void used(FXival u){ ((FXival*)table)[-2]=u; } // Change number of free entries void free(FXival f){ ((FXival*)table)[-3]=f; } // Resize the table to the given size, keeping contents FXbool resize(FXival n); public: /// Construct an empty map FXVariantMap(); /// Construct from another map FXVariantMap(const FXVariantMap& other); /// Return the size of the table, including the empty slots FXival no() const { return ((FXival*)table)[-1]; } /// Return number of used slots in the table FXival used() const { return ((FXival*)table)[-2]; } /// Return number of free slots in the table FXival free() const { return ((FXival*)table)[-3]; } /// See if map is empty FXbool empty() const { return ((FXival*)table)[-1]<=1; } /// Assignment operator FXVariantMap& operator=(const FXVariantMap& other); /// Adopt map from another map; the other map becomes empty FXVariantMap& adopt(FXVariantMap& other); /// Find slot index for key; return -1 if not found FXival find(const FXchar* ky) const; /// Find slot index for key; return -1 if not found FXival find(const FXString& ky) const { return find(ky.text()); } /// Check if key is mapped FXbool has(const FXchar* ky) const { return 0<=find(ky); } /// Check if key is mapped FXbool has(const FXString& ky) const { return has(ky.text()); } /// Return reference to variant assocated with key FXVariant& at(const FXchar* ky); /// Return constant reference to variant assocated with key const FXVariant& at(const FXchar* ky) const; /// Return reference to variant assocated with key FXVariant& at(const FXString& ky){ return at(ky.text()); } /// Return constant reference to variant assocated with key const FXVariant& at(const FXString& ky) const { return at(ky.text()); } /// Return reference to variant assocated with key FXVariant& operator[](const FXchar* ky){ return at(ky); } /// Return constant reference to variant assocated with key const FXVariant& operator[](const FXchar* ky) const { return at(ky); } /// Return reference to variant assocated with key FXVariant& operator[](const FXString& ky){ return at(ky); } /// Return constant reference to variant assocated with key const FXVariant& operator[](const FXString& ky) const { return at(ky); } /// Remove entry from the table FXbool remove(const FXchar* ky); /// Remove entry from the table FXbool remove(const FXString& ky){ return remove(ky.text()); } /// Erase entry at pos in the table FXbool erase(FXival pos); /// Return true if slot at pos is empty. FXbool empty(FXival pos) const { return table[pos].key.empty(); } /// Return key value at slot pos; may be empty! const FXString& key(FXival pos) const { return table[pos].key; } /// Return reference to data at slot s; but careful as assignment /// to empty slot is dangerous!! FXVariant& data(FXival pos){ return table[pos].data; } /// Return value at slot pos; may be empty! const FXVariant& data(FXival pos) const { return table[pos].data; } /// Clear the table FXbool clear(); /// Destructor ~FXVariantMap(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXVec2d.h000066400000000000000000000175271455751074500220470ustar00rootroot00000000000000/******************************************************************************** * * * D o u b l e - P r e c i s i o n 2 - E l e m e n t V e c t o r * * * ********************************************************************************* * Copyright (C) 1994,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXVEC2D_H #define FXVEC2D_H namespace FX { /// Double-precision 2-element vector class FXAPI FXVec2d { public: FXdouble x; FXdouble y; public: /// Default constructor; value is not initialized FXVec2d(){} /// Initialize from another vector FXVec2d(const FXVec2d& v):x(v.x),y(v.y){} /// Initialize from array of doubles FXVec2d(const FXdouble v[]):x(v[0]),y(v[1]){} /// Initialize from components FXVec2d(FXdouble xx,FXdouble yy):x(xx),y(yy){} /// Return a non-const reference to the ith element FXdouble& operator[](FXint i){return (&x)[i];} /// Return a const reference to the ith element const FXdouble& operator[](FXint i) const {return (&x)[i];} /// Assignment FXVec2d& operator=(const FXVec2d& v){x=v.x;y=v.y;return *this;} /// Assignment from array of doubles FXVec2d& operator=(const FXdouble v[]){x=v[0];y=v[1];return *this;} /// Set value from another vector FXVec2d& set(const FXVec2d& v){x=v.x;y=v.y;return *this;} /// Set value from array of doubles FXVec2d& set(const FXdouble v[]){x=v[0];y=v[1];return *this;} /// Set value from components FXVec2d& set(FXdouble xx,FXdouble yy){x=xx;y=yy;return *this;} /// Assigning operators FXVec2d& operator*=(FXdouble n){ return set(x*n,y*n); } FXVec2d& operator/=(FXdouble n){ return set(x/n,y/n); } /// Element-wise assigning operators FXVec2d& operator+=(const FXVec2d& v){ return set(x+v.x,y+v.y); } FXVec2d& operator-=(const FXVec2d& v){ return set(x-v.x,y-v.y); } FXVec2d& operator%=(const FXVec2d& v){ return set(x*v.x,y*v.y); } FXVec2d& operator/=(const FXVec2d& v){ return set(x/v.x,y/v.y); } /// Conversions operator FXdouble*(){return &x;} operator const FXdouble*() const {return &x;} /// Test if zero FXbool operator!() const { return x==0.0 && y==0.0;} /// Unary FXVec2d operator+() const { return *this; } FXVec2d operator-() const { return FXVec2d(-x,-y); } /// Length and square of length FXdouble length2() const { return y*y+x*x; } FXdouble length() const { return Math::sqrt(length2()); } /// Destructor ~FXVec2d(){} }; /// Dot product inline FXdouble operator*(const FXVec2d& a,const FXVec2d& b){ return a.x*b.x+a.y*b.y; } /// Scaling inline FXVec2d operator*(const FXVec2d& a,FXdouble n){return FXVec2d(a.x*n,a.y*n);} inline FXVec2d operator*(FXdouble n,const FXVec2d& a){return FXVec2d(n*a.x,n*a.y);} inline FXVec2d operator/(const FXVec2d& a,FXdouble n){return FXVec2d(a.x/n,a.y/n);} inline FXVec2d operator/(FXdouble n,const FXVec2d& a){return FXVec2d(n/a.x,n/a.y);} /// Vector and vector addition inline FXVec2d operator+(const FXVec2d& a,const FXVec2d& b){ return FXVec2d(a.x+b.x,a.y+b.y); } inline FXVec2d operator-(const FXVec2d& a,const FXVec2d& b){ return FXVec2d(a.x-b.x,a.y-b.y); } /// Element-wise multiply and divide inline FXVec2d operator%(const FXVec2d& a,const FXVec2d& b){ return FXVec2d(a.x*b.x,a.y*b.y); } inline FXVec2d operator/(const FXVec2d& a,const FXVec2d& b){ return FXVec2d(a.x/b.x,a.y/b.y); } /// Equality tests inline FXbool operator==(const FXVec2d& a,FXdouble n){return a.x==n && a.y==n;} inline FXbool operator!=(const FXVec2d& a,FXdouble n){return a.x!=n || a.y!=n;} inline FXbool operator==(FXdouble n,const FXVec2d& a){return n==a.x && n==a.y;} inline FXbool operator!=(FXdouble n,const FXVec2d& a){return n!=a.x || n!=a.y;} /// Equality tests inline FXbool operator==(const FXVec2d& a,const FXVec2d& b){ return a.x==b.x && a.y==b.y; } inline FXbool operator!=(const FXVec2d& a,const FXVec2d& b){ return a.x!=b.x || a.y!=b.y; } /// Inequality tests inline FXbool operator<(const FXVec2d& a,FXdouble n){return a.x(const FXVec2d& a,FXdouble n){return a.x>n && a.y>n;} inline FXbool operator>=(const FXVec2d& a,FXdouble n){return a.x>=n && a.y>=n;} /// Inequality tests inline FXbool operator<(FXdouble n,const FXVec2d& a){return n(FXdouble n,const FXVec2d& a){return n>a.x && n>a.y;} inline FXbool operator>=(FXdouble n,const FXVec2d& a){return n>=a.x && n>=a.y;} /// Inequality tests inline FXbool operator<(const FXVec2d& a,const FXVec2d& b){ return a.x(const FXVec2d& a,const FXVec2d& b){ return a.x>b.x && a.y>b.y; } inline FXbool operator>=(const FXVec2d& a,const FXVec2d& b){ return a.x>=b.x && a.y>=b.y; } /// Lowest components inline FXVec2d lo(const FXVec2d& a,const FXVec2d& b){return FXVec2d(Math::fmin(a.x,b.x),Math::fmin(a.y,b.y));} inline FXVec2d lo(const FXVec2d& a,FXdouble n){return FXVec2d(Math::fmin(a.x,n),Math::fmin(a.y,n));} inline FXVec2d lo(FXdouble n,const FXVec2d& b){return FXVec2d(Math::fmin(n,b.x),Math::fmin(n,b.y));} /// Highest components inline FXVec2d hi(const FXVec2d& a,const FXVec2d& b){return FXVec2d(Math::fmax(a.x,b.x),Math::fmax(a.y,b.y));} inline FXVec2d hi(const FXVec2d& a,FXdouble n){return FXVec2d(Math::fmax(a.x,n),Math::fmax(a.y,n));} inline FXVec2d hi(FXdouble n,const FXVec2d& b){return FXVec2d(Math::fmax(n,b.x),Math::fmax(n,b.y));} /// Clamp components of vector between lower and upper limits inline FXVec2d clamp(FXdouble lower,const FXVec2d& x,FXdouble upper){return hi(lo(x,upper),lower);} /// Clamp components of vector between lower corner and upper corner inline FXVec2d clamp(const FXVec2d& lower,const FXVec2d& x,const FXVec2d& upper){return hi(lo(x,upper),lower);} /// Return vector of absolute value of each element inline FXVec2d abs(const FXVec2d& a){return FXVec2d(Math::fabs(a.x),Math::fabs(a.y));} /// Return maximum component of vector inline FXdouble max(const FXVec2d& a){ return Math::fmax(a.x,a.y); } /// Return minimum component of vector inline FXdouble min(const FXVec2d& a){ return Math::fmin(a.x,a.y); } /// Linearly interpolate inline FXVec2d lerp(const FXVec2d& u,const FXVec2d& v,FXdouble f){return (v-u)*f+u;} /// Normalize vector extern FXAPI FXVec2d normalize(const FXVec2d& v); /// Save vector to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXVec2d& v); /// Load vector from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXVec2d& v); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXVec2f.h000066400000000000000000000174541455751074500220500ustar00rootroot00000000000000/******************************************************************************** * * * S i n g l e - P r e c i s i o n 2 - E l e m e n t V e c t o r * * * ********************************************************************************* * Copyright (C) 1994,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXVEC2F_H #define FXVEC2F_H namespace FX { /// Single-precision 2-element vector class FXAPI FXVec2f { public: FXfloat x; FXfloat y; public: /// Default constructor; value is not initialized FXVec2f(){} /// Initialize from another vector FXVec2f(const FXVec2f& v):x(v.x),y(v.y){} /// Initialize from array of floats FXVec2f(const FXfloat v[]):x(v[0]),y(v[1]){} /// Initialize from components FXVec2f(FXfloat xx,FXfloat yy):x(xx),y(yy){} /// Return a non-const reference to the ith element FXfloat& operator[](FXint i){return (&x)[i];} /// Return a const reference to the ith element const FXfloat& operator[](FXint i) const {return (&x)[i];} /// Assignment FXVec2f& operator=(const FXVec2f& v){x=v.x;y=v.y;return *this;} /// Assignment from array of floats FXVec2f& operator=(const FXfloat v[]){x=v[0];y=v[1];return *this;} /// Set value from another vector FXVec2f& set(const FXVec2f& v){x=v.x;y=v.y;return *this;} /// Set value from array of floats FXVec2f& set(const FXfloat v[]){x=v[0];y=v[1];return *this;} /// Set value from components FXVec2f& set(FXfloat xx,FXfloat yy){x=xx;y=yy;return *this;} /// Assigning operators FXVec2f& operator*=(FXfloat n){ return set(x*n,y*n); } FXVec2f& operator/=(FXfloat n){ return set(x/n,y/n); } /// Element-wise assigning operators FXVec2f& operator+=(const FXVec2f& v){ return set(x+v.x,y+v.y); } FXVec2f& operator-=(const FXVec2f& v){ return set(x-v.x,y-v.y); } FXVec2f& operator%=(const FXVec2f& v){ return set(x*v.x,y*v.y); } FXVec2f& operator/=(const FXVec2f& v){ return set(x/v.x,y/v.y); } /// Conversions operator FXfloat*(){return &x;} operator const FXfloat*() const {return &x;} /// Test if zero FXbool operator!() const { return x==0.0f && y==0.0f; } /// Unary FXVec2f operator+() const { return *this; } FXVec2f operator-() const { return FXVec2f(-x,-y); } /// Length and square of length FXfloat length2() const { return y*y+x*x; } FXfloat length() const { return Math::sqrt(length2()); } /// Destructor ~FXVec2f(){} }; /// Dot product inline FXfloat operator*(const FXVec2f& a,const FXVec2f& b){ return a.x*b.x+a.y*b.y; } /// Scaling inline FXVec2f operator*(const FXVec2f& a,FXfloat n){return FXVec2f(a.x*n,a.y*n);} inline FXVec2f operator*(FXfloat n,const FXVec2f& a){return FXVec2f(n*a.x,n*a.y);} inline FXVec2f operator/(const FXVec2f& a,FXfloat n){return FXVec2f(a.x/n,a.y/n);} inline FXVec2f operator/(FXfloat n,const FXVec2f& a){return FXVec2f(n/a.x,n/a.y);} /// Vector and vector addition inline FXVec2f operator+(const FXVec2f& a,const FXVec2f& b){ return FXVec2f(a.x+b.x,a.y+b.y); } inline FXVec2f operator-(const FXVec2f& a,const FXVec2f& b){ return FXVec2f(a.x-b.x,a.y-b.y); } /// Element-wise multiply and divide inline FXVec2f operator%(const FXVec2f& a,const FXVec2f& b){ return FXVec2f(a.x*b.x,a.y*b.y); } inline FXVec2f operator/(const FXVec2f& a,const FXVec2f& b){ return FXVec2f(a.x/b.x,a.y/b.y); } /// Equality tests inline FXbool operator==(const FXVec2f& a,FXfloat n){return a.x==n && a.y==n;} inline FXbool operator!=(const FXVec2f& a,FXfloat n){return a.x!=n || a.y!=n;} inline FXbool operator==(FXfloat n,const FXVec2f& a){return n==a.x && n==a.y;} inline FXbool operator!=(FXfloat n,const FXVec2f& a){return n!=a.x || n!=a.y;} /// Equality tests inline FXbool operator==(const FXVec2f& a,const FXVec2f& b){ return a.x==b.x && a.y==b.y; } inline FXbool operator!=(const FXVec2f& a,const FXVec2f& b){ return a.x!=b.x || a.y!=b.y; } /// Inequality tests inline FXbool operator<(const FXVec2f& a,FXfloat n){return a.x(const FXVec2f& a,FXfloat n){return a.x>n && a.y>n;} inline FXbool operator>=(const FXVec2f& a,FXfloat n){return a.x>=n && a.y>=n;} /// Inequality tests inline FXbool operator<(FXfloat n,const FXVec2f& a){return n(FXfloat n,const FXVec2f& a){return n>a.x && n>a.y;} inline FXbool operator>=(FXfloat n,const FXVec2f& a){return n>=a.x && n>=a.y;} /// Inequality tests inline FXbool operator<(const FXVec2f& a,const FXVec2f& b){ return a.x(const FXVec2f& a,const FXVec2f& b){ return a.x>b.x && a.y>b.y; } inline FXbool operator>=(const FXVec2f& a,const FXVec2f& b){ return a.x>=b.x && a.y>=b.y; } /// Lowest components inline FXVec2f lo(const FXVec2f& a,const FXVec2f& b){return FXVec2f(Math::fmin(a.x,b.x),Math::fmin(a.y,b.y));} inline FXVec2f lo(const FXVec2f& a,FXfloat n){return FXVec2f(Math::fmin(a.x,n),Math::fmin(a.y,n));} inline FXVec2f lo(FXfloat n,const FXVec2f& b){return FXVec2f(Math::fmin(n,b.x),Math::fmin(n,b.y));} /// Highest components inline FXVec2f hi(const FXVec2f& a,const FXVec2f& b){return FXVec2f(Math::fmax(a.x,b.x),Math::fmax(a.y,b.y));} inline FXVec2f hi(const FXVec2f& a,FXfloat n){return FXVec2f(Math::fmax(a.x,n),Math::fmax(a.y,n));} inline FXVec2f hi(FXfloat n,const FXVec2f& b){return FXVec2f(Math::fmax(n,b.x),Math::fmax(n,b.y));} /// Clamp components of vector between lower and upper limits inline FXVec2f clamp(FXfloat lower,const FXVec2f& x,FXfloat upper){return hi(lo(x,upper),lower);} /// Clamp components of vector between lower corner and upper corner inline FXVec2f clamp(const FXVec2f& lower,const FXVec2f& x,const FXVec2f& upper){return hi(lo(x,upper),lower);} /// Return vector of absolute value of each element inline FXVec2f abs(const FXVec2f& a){return FXVec2f(Math::fabs(a.x),Math::fabs(a.y));} /// Return maximum component of vector inline FXfloat max(const FXVec2f& a){ return Math::fmax(a.x,a.y); } /// Return minimum component of vector inline FXfloat min(const FXVec2f& a){ return Math::fmin(a.x,a.y); } /// Linearly interpolate inline FXVec2f lerp(const FXVec2f& u,const FXVec2f& v,FXfloat f){return (v-u)*f+u;} /// Normalize vector extern FXAPI FXVec2f normalize(const FXVec2f& v); /// Save vector to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXVec2f& v); /// Load vector from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXVec2f& v); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXVec3d.h000066400000000000000000000232021455751074500220330ustar00rootroot00000000000000/******************************************************************************** * * * D o u b l e - P r e c i s i o n 3 - E l e m e n t V e c t o r * * * ********************************************************************************* * Copyright (C) 1994,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXVEC3D_H #define FXVEC3D_H namespace FX { /// Double-precision 3-element vector class FXAPI FXVec3d { public: FXdouble x; FXdouble y; FXdouble z; public: /// Default constructor; value is not initialized FXVec3d(){} /// Initialize from 2-vector FXVec3d(const FXVec2d& v,FXdouble s=0.0):x(v.x),y(v.y),z(s){} /// Initialize from another vector FXVec3d(const FXVec3d& v):x(v.x),y(v.y),z(v.z){} /// Initialize from array of doubles FXVec3d(const FXdouble v[]):x(v[0]),y(v[1]),z(v[2]){} /// Initialize from components FXVec3d(FXdouble xx,FXdouble yy,FXdouble zz):x(xx),y(yy),z(zz){} /// Return a non-const reference to the ith element FXdouble& operator[](FXint i){return (&x)[i];} /// Return a const reference to the ith element const FXdouble& operator[](FXint i) const {return (&x)[i];} /// Assignment FXVec3d& operator=(const FXVec3d& v){x=v.x;y=v.y;z=v.z;return *this;} /// Assignment from array of doubles FXVec3d& operator=(const FXdouble v[]){x=v[0];y=v[1];z=v[2];return *this;} /// Set value from another vector FXVec3d& set(const FXVec3d& v){x=v.x;y=v.y;z=v.z;return *this;} /// Set from array of doubles FXVec3d& set(const FXdouble v[]){x=v[0];y=v[1];z=v[2];return *this;} /// Set value from components FXVec3d& set(FXdouble xx,FXdouble yy,FXdouble zz){x=xx;y=yy;z=zz;return *this;} /// Assigning operators FXVec3d& operator*=(FXdouble n){ return set(x*n,y*n,z*n); } FXVec3d& operator/=(FXdouble n){ return set(x/n,y/n,z/n); } /// Element-wise assigning operators FXVec3d& operator+=(const FXVec3d& v){ return set(x+v.x,y+v.y,z+v.z); } FXVec3d& operator-=(const FXVec3d& v){ return set(x-v.x,y-v.y,z-v.z); } FXVec3d& operator%=(const FXVec3d& v){ return set(x*v.x,y*v.y,z*v.z); } /// Cross product assigning operator FXVec3d& operator^=(const FXVec3d& v){ return set(y*v.z-z*v.y,z*v.x-x*v.z,x*v.y-y*v.x); } /// Conversions operator FXdouble*(){return &x;} operator const FXdouble*() const {return &x;} operator FXVec2d&(){return *reinterpret_cast(this);} operator const FXVec2d&() const {return *reinterpret_cast(this);} /// Test if zero FXbool operator!() const { return x==0.0 && y==0.0 && z==0.0; } /// Unary FXVec3d operator+() const { return *this; } FXVec3d operator-() const { return FXVec3d(-x,-y,-z); } /// Length and square of length FXdouble length2() const { return z*z+y*y+x*x; } FXdouble length() const { return Math::sqrt(length2()); } /// Destructor ~FXVec3d(){} }; /// Dot product inline FXdouble operator*(const FXVec3d& a,const FXVec3d& b){ return a.x*b.x+a.y*b.y+a.z*b.z; } /// Cross product inline FXVec3d operator^(const FXVec3d& a,const FXVec3d& b){ return FXVec3d(a.y*b.z-a.z*b.y, a.z*b.x-a.x*b.z, a.x*b.y-a.y*b.x); } /// Scaling inline FXVec3d operator*(const FXVec3d& a,FXdouble n){return FXVec3d(a.x*n,a.y*n,a.z*n);} inline FXVec3d operator*(FXdouble n,const FXVec3d& a){return FXVec3d(n*a.x,n*a.y,n*a.z);} inline FXVec3d operator/(const FXVec3d& a,FXdouble n){return FXVec3d(a.x/n,a.y/n,a.z/n);} inline FXVec3d operator/(FXdouble n,const FXVec3d& a){return FXVec3d(n/a.x,n/a.y,n/a.z);} /// Vector and vector addition inline FXVec3d operator+(const FXVec3d& a,const FXVec3d& b){ return FXVec3d(a.x+b.x,a.y+b.y,a.z+b.z); } inline FXVec3d operator-(const FXVec3d& a,const FXVec3d& b){ return FXVec3d(a.x-b.x,a.y-b.y,a.z-b.z); } /// Element-wise multiply and divide inline FXVec3d operator%(const FXVec3d& a,const FXVec3d& b){ return FXVec3d(a.x*b.x,a.y*b.y,a.z*b.z); } inline FXVec3d operator/(const FXVec3d& a,const FXVec3d& b){ return FXVec3d(a.x/b.x,a.y/b.y,a.z/b.z); } /// Equality tests inline FXbool operator==(const FXVec3d& a,FXdouble n){return a.x==n && a.y==n && a.z==n;} inline FXbool operator!=(const FXVec3d& a,FXdouble n){return a.x!=n || a.y!=n || a.z!=n;} inline FXbool operator==(FXdouble n,const FXVec3d& a){return n==a.x && n==a.y && n==a.z;} inline FXbool operator!=(FXdouble n,const FXVec3d& a){return n!=a.x || n!=a.y || n!=a.z;} /// Equality tests inline FXbool operator==(const FXVec3d& a,const FXVec3d& b){ return a.x==b.x && a.y==b.y && a.z==b.z; } inline FXbool operator!=(const FXVec3d& a,const FXVec3d& b){ return a.x!=b.x || a.y!=b.y || a.z!=b.z; } /// Inequality tests inline FXbool operator<(const FXVec3d& a,FXdouble n){return a.x(const FXVec3d& a,FXdouble n){return a.x>n && a.y>n && a.z>n;} inline FXbool operator>=(const FXVec3d& a,FXdouble n){return a.x>=n && a.y>=n && a.z>=n;} /// Inequality tests inline FXbool operator<(FXdouble n,const FXVec3d& a){return n(FXdouble n,const FXVec3d& a){return n>a.x && n>a.y && n>a.z;} inline FXbool operator>=(FXdouble n,const FXVec3d& a){return n>=a.x && n>=a.y && n>=a.z;} /// Inequality tests inline FXbool operator<(const FXVec3d& a,const FXVec3d& b){ return a.x(const FXVec3d& a,const FXVec3d& b){ return a.x>b.x && a.y>b.y && a.z>b.z; } inline FXbool operator>=(const FXVec3d& a,const FXVec3d& b){ return a.x>=b.x && a.y>=b.y && a.z>=b.z; } /// Lowest components inline FXVec3d lo(const FXVec3d& a,const FXVec3d& b){return FXVec3d(Math::fmin(a.x,b.x),Math::fmin(a.y,b.y),Math::fmin(a.z,b.z));} inline FXVec3d lo(const FXVec3d& a,FXdouble n){return FXVec3d(Math::fmin(a.x,n),Math::fmin(a.y,n),Math::fmin(a.z,n));} inline FXVec3d lo(FXdouble n,const FXVec3d& b){return FXVec3d(Math::fmin(n,b.x),Math::fmin(n,b.y),Math::fmin(n,b.z));} /// Highest components inline FXVec3d hi(const FXVec3d& a,const FXVec3d& b){return FXVec3d(Math::fmax(a.x,b.x),Math::fmax(a.y,b.y),Math::fmax(a.z,b.z));} inline FXVec3d hi(const FXVec3d& a,FXdouble n){return FXVec3d(Math::fmax(a.x,n),Math::fmax(a.y,n),Math::fmax(a.z,n));} inline FXVec3d hi(FXdouble n,const FXVec3d& b){return FXVec3d(Math::fmax(n,b.x),Math::fmax(n,b.y),Math::fmax(n,b.z));} /// Clamp components of vector between lower and upper limits inline FXVec3d clamp(FXdouble lower,const FXVec3d& x,FXdouble upper){return hi(lo(x,upper),lower);} /// Clamp components of vector between lower corner and upper corner inline FXVec3d clamp(const FXVec3d& lower,const FXVec3d& x,const FXVec3d& upper){return hi(lo(x,upper),lower);} /// Return vector of absolute value of each element inline FXVec3d abs(const FXVec3d& a){return FXVec3d(Math::fabs(a.x),Math::fabs(a.y),Math::fabs(a.z));} /// Return maximum component of vector inline FXdouble max(const FXVec3d& a){ return Math::fmax(Math::fmax(a.x,a.y),a.z); } /// Return minimum component of vector inline FXdouble min(const FXVec3d& a){ return Math::fmin(Math::fmin(a.x,a.y),a.z); } /// Linearly interpolate inline FXVec3d lerp(const FXVec3d& u,const FXVec3d& v,FXdouble f){return (v-u)*f+u;} /// Convert vector to color extern FXAPI FXColor colorFromVec3d(const FXVec3d& vec); /// Convert color to vector extern FXAPI FXVec3d colorToVec3d(FXColor clr); /// Compute normal from three points a,b,c extern FXAPI FXVec3d normal(const FXVec3d& a,const FXVec3d& b,const FXVec3d& c); /// Compute approximate normal from four points a,b,c,d extern FXAPI FXVec3d normal(const FXVec3d& a,const FXVec3d& b,const FXVec3d& c,const FXVec3d& d); /// Normalize vector extern FXAPI FXVec3d normalize(const FXVec3d& v); /// Return vector orthogonal to v extern FXAPI FXVec3d orthogonal(const FXVec3d& v); /// Rotate vector vec by unit-length axis about angle specified as (ca,sa) extern FXAPI FXVec3d rotate(const FXVec3d& vec,const FXVec3d& axis,FXdouble ca,FXdouble sa); /// Rotate vector vec by unit-length axis about angle ang extern FXAPI FXVec3d rotate(const FXVec3d& vec,const FXVec3d& axis,FXdouble ang); /// Save vector to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXVec3d& v); /// Load vector from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXVec3d& v); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXVec3f.h000066400000000000000000000232401455751074500220370ustar00rootroot00000000000000/******************************************************************************** * * * S i n g l e - P r e c i s i o n 3 - E l e m e n t V e c t o r * * * ********************************************************************************* * Copyright (C) 1994,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXVEC3F_H #define FXVEC3F_H namespace FX { /// Single-precision 3-element vector class FXAPI FXVec3f { public: FXfloat x; FXfloat y; FXfloat z; public: /// Default constructor; value is not initialized FXVec3f(){} /// Initialize from 2-vector FXVec3f(const FXVec2f& v,FXfloat s=0.0f):x(v.x),y(v.y),z(s){} /// Initialize from another vector FXVec3f(const FXVec3f& v):x(v.x),y(v.y),z(v.z){} /// Initialize from array of floats FXVec3f(const FXfloat v[]):x(v[0]),y(v[1]),z(v[2]){} /// Initialize from components FXVec3f(FXfloat xx,FXfloat yy,FXfloat zz):x(xx),y(yy),z(zz){} /// Return a non-const reference to the ith element FXfloat& operator[](FXint i){return (&x)[i];} /// Return a const reference to the ith element const FXfloat& operator[](FXint i) const {return (&x)[i];} /// Assignment FXVec3f& operator=(const FXVec3f& v){x=v.x;y=v.y;z=v.z;return *this;} /// Assignment from array of floats FXVec3f& operator=(const FXfloat v[]){x=v[0];y=v[1];z=v[2];return *this;} /// Set value from another vector FXVec3f& set(const FXVec3f& v){x=v.x;y=v.y;z=v.z;return *this;} /// Set value from array of floats FXVec3f& set(const FXfloat v[]){x=v[0];y=v[1];z=v[2];return *this;} /// Set value from components FXVec3f& set(FXfloat xx,FXfloat yy,FXfloat zz){x=xx;y=yy;z=zz;return *this;} /// Assigning operators FXVec3f& operator*=(FXfloat n){ return set(x*n,y*n,z*n); } FXVec3f& operator/=(FXfloat n){ return set(x/n,y/n,z/n); } /// Element-wise assigning operators FXVec3f& operator+=(const FXVec3f& v){ return set(x+v.x,y+v.y,z+v.z); } FXVec3f& operator-=(const FXVec3f& v){ return set(x-v.x,y-v.y,z-v.z); } FXVec3f& operator%=(const FXVec3f& v){ return set(x*v.x,y*v.y,z*v.z); } FXVec3f& operator/=(const FXVec3f& v){ return set(x/v.x,y/v.y,z/v.z); } /// Cross product assigning operator FXVec3f& operator^=(const FXVec3f& v){ return set(y*v.z-z*v.y,z*v.x-x*v.z,x*v.y-y*v.x); } /// Conversions operator FXfloat*(){return &x;} operator const FXfloat*() const {return &x;} operator FXVec2f&(){return *reinterpret_cast(this);} operator const FXVec2f&() const {return *reinterpret_cast(this);} /// Test if zero FXbool operator!() const { return x==0.0f && y==0.0f && z==0.0f; } /// Unary FXVec3f operator+() const { return *this; } FXVec3f operator-() const { return FXVec3f(-x,-y,-z); } /// Length and square of length FXfloat length2() const { return z*z+y*y+x*x; } FXfloat length() const { return Math::sqrt(length2()); } /// Destructor ~FXVec3f(){} }; /// Dot product inline FXfloat operator*(const FXVec3f& a,const FXVec3f& b){ return a.x*b.x+a.y*b.y+a.z*b.z; } /// Cross product inline FXVec3f operator^(const FXVec3f& a,const FXVec3f& b){ return FXVec3f(a.y*b.z-a.z*b.y, a.z*b.x-a.x*b.z, a.x*b.y-a.y*b.x); } /// Scaling inline FXVec3f operator*(const FXVec3f& a,FXfloat n){return FXVec3f(a.x*n,a.y*n,a.z*n);} inline FXVec3f operator*(FXfloat n,const FXVec3f& a){return FXVec3f(n*a.x,n*a.y,n*a.z);} inline FXVec3f operator/(const FXVec3f& a,FXfloat n){return FXVec3f(a.x/n,a.y/n,a.z/n);} inline FXVec3f operator/(FXfloat n,const FXVec3f& a){return FXVec3f(n/a.x,n/a.y,n/a.z);} /// Vector and vector addition inline FXVec3f operator+(const FXVec3f& a,const FXVec3f& b){ return FXVec3f(a.x+b.x,a.y+b.y,a.z+b.z); } inline FXVec3f operator-(const FXVec3f& a,const FXVec3f& b){ return FXVec3f(a.x-b.x,a.y-b.y,a.z-b.z); } /// Element-wise multiply and divide inline FXVec3f operator%(const FXVec3f& a,const FXVec3f& b){ return FXVec3f(a.x*b.x,a.y*b.y,a.z*b.z); } inline FXVec3f operator/(const FXVec3f& a,const FXVec3f& b){ return FXVec3f(a.x/b.x,a.y/b.y,a.z/b.z); } /// Equality tests inline FXbool operator==(const FXVec3f& a,FXfloat n){return a.x==n && a.y==n && a.z==n;} inline FXbool operator!=(const FXVec3f& a,FXfloat n){return a.x!=n || a.y!=n || a.z!=n;} inline FXbool operator==(FXfloat n,const FXVec3f& a){return n==a.x && n==a.y && n==a.z;} inline FXbool operator!=(FXfloat n,const FXVec3f& a){return n!=a.x || n!=a.y || n!=a.z;} /// Equality tests inline FXbool operator==(const FXVec3f& a,const FXVec3f& b){ return a.x==b.x && a.y==b.y && a.z==b.z; } inline FXbool operator!=(const FXVec3f& a,const FXVec3f& b){ return a.x!=b.x || a.y!=b.y || a.z!=b.z; } /// Inequality tests inline FXbool operator<(const FXVec3f& a,FXfloat n){return a.x(const FXVec3f& a,FXfloat n){return a.x>n && a.y>n && a.z>n;} inline FXbool operator>=(const FXVec3f& a,FXfloat n){return a.x>=n && a.y>=n && a.z>=n;} /// Inequality tests inline FXbool operator<(FXfloat n,const FXVec3f& a){return n(FXfloat n,const FXVec3f& a){return n>a.x && n>a.y && n>a.z;} inline FXbool operator>=(FXfloat n,const FXVec3f& a){return n>=a.x && n>=a.y && n>=a.z;} /// Inequality tests inline FXbool operator<(const FXVec3f& a,const FXVec3f& b){ return a.x(const FXVec3f& a,const FXVec3f& b){ return a.x>b.x && a.y>b.y && a.z>b.z; } inline FXbool operator>=(const FXVec3f& a,const FXVec3f& b){ return a.x>=b.x && a.y>=b.y && a.z>=b.z; } /// Lowest components inline FXVec3f lo(const FXVec3f& a,const FXVec3f& b){return FXVec3f(Math::fmin(a.x,b.x),Math::fmin(a.y,b.y),Math::fmin(a.z,b.z));} inline FXVec3f lo(const FXVec3f& a,FXfloat n){return FXVec3f(Math::fmin(a.x,n),Math::fmin(a.y,n),Math::fmin(a.z,n));} inline FXVec3f lo(FXfloat n,const FXVec3f& b){return FXVec3f(Math::fmin(n,b.x),Math::fmin(n,b.y),Math::fmin(n,b.z));} /// Highest components inline FXVec3f hi(const FXVec3f& a,const FXVec3f& b){return FXVec3f(Math::fmax(a.x,b.x),Math::fmax(a.y,b.y),Math::fmax(a.z,b.z));} inline FXVec3f hi(const FXVec3f& a,FXfloat n){return FXVec3f(Math::fmax(a.x,n),Math::fmax(a.y,n),Math::fmax(a.z,n));} inline FXVec3f hi(FXfloat n,const FXVec3f& b){return FXVec3f(Math::fmax(n,b.x),Math::fmax(n,b.y),Math::fmax(n,b.z));} /// Clamp components of vector between lower and upper limits inline FXVec3f clamp(FXfloat lower,const FXVec3f& x,FXfloat upper){return hi(lo(x,upper),lower);} /// Clamp components of vector between lower corner and upper corner inline FXVec3f clamp(const FXVec3f& lower,const FXVec3f& x,const FXVec3f& upper){return hi(lo(x,upper),lower);} /// Return vector of absolute value of each element inline FXVec3f abs(const FXVec3f& a){return FXVec3f(Math::fabs(a.x),Math::fabs(a.y),Math::fabs(a.z));} /// Return maximum component of vector inline FXfloat max(const FXVec3f& a){ return Math::fmax(Math::fmax(a.x,a.y),a.z); } /// Return minimum component of vector inline FXfloat min(const FXVec3f& a){ return Math::fmin(Math::fmin(a.x,a.y),a.z); } /// Linearly interpolate inline FXVec3f lerp(const FXVec3f& u,const FXVec3f& v,FXfloat f){return (v-u)*f+u;} /// Convert vector to color extern FXAPI FXColor colorFromVec3f(const FXVec3f& vec); /// Convert color to vector extern FXAPI FXVec3f colorToVec3f(FXColor clr); /// Compute normal from three points a,b,c extern FXAPI FXVec3f normal(const FXVec3f& a,const FXVec3f& b,const FXVec3f& c); /// Compute approximate normal from four points a,b,c,d extern FXAPI FXVec3f normal(const FXVec3f& a,const FXVec3f& b,const FXVec3f& c,const FXVec3f& d); /// Normalize vector extern FXAPI FXVec3f normalize(const FXVec3f& v); /// Return vector orthogonal to v extern FXAPI FXVec3f orthogonal(const FXVec3f& v); /// Rotate vector vec by unit-length axis about angle specified as (ca,sa) extern FXAPI FXVec3f rotate(const FXVec3f& vec,const FXVec3f& axis,FXfloat ca,FXfloat sa); /// Rotate vector by unit-length axis about angle ang extern FXAPI FXVec3f rotate(const FXVec3f& vector,const FXVec3f& axis,FXfloat ang); /// Save vector to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXVec3f& v); /// Load vector from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXVec3f& v); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXVec4d.h000066400000000000000000000237301455751074500220420ustar00rootroot00000000000000/******************************************************************************** * * * D o u b l e - P r e c i s i o n 4 - E l e m e n t V e c t o r * * * ********************************************************************************* * Copyright (C) 1994,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXVEC4D_H #define FXVEC4D_H namespace FX { /// Double-precision 4-element vector class FXAPI FXVec4d { public: FXdouble x; FXdouble y; FXdouble z; FXdouble w; public: /// Default constructor; value is not initialized FXVec4d(){} /// Construct with 3-vector FXVec4d(const FXVec3d& v,FXdouble s=0.0):x(v.x),y(v.y),z(v.z),w(s){} /// Initialize from another vector FXVec4d(const FXVec4d& v):x(v.x),y(v.y),z(v.z),w(v.w){} /// Initialize from array of doubles FXVec4d(const FXdouble v[]):x(v[0]),y(v[1]),z(v[2]),w(v[3]){} /// Initialize with components FXVec4d(FXdouble xx,FXdouble yy,FXdouble zz,FXdouble ww):x(xx),y(yy),z(zz),w(ww){} /// Return a non-const reference to the ith element FXdouble& operator[](FXint i){return (&x)[i];} /// Return a const reference to the ith element const FXdouble& operator[](FXint i) const {return (&x)[i];} /// Assignment FXVec4d& operator=(const FXVec4d& v){x=v.x;y=v.y;z=v.z;w=v.w;return *this;} /// Assignment from array of doubles FXVec4d& operator=(const FXdouble v[]){x=v[0];y=v[1];z=v[2];w=v[3];return *this;} /// Set value from another vector FXVec4d& set(const FXVec4d& v){x=v.x;y=v.y;z=v.z;w=v.w;return *this;} /// Set value from array of doubles FXVec4d& set(const FXdouble v[]){x=v[0];y=v[1];z=v[2];w=v[3];return *this;} /// Set value from components FXVec4d& set(FXdouble xx,FXdouble yy,FXdouble zz,FXdouble ww){x=xx;y=yy;z=zz;w=ww;return *this;} /// Assigning operators FXVec4d& operator*=(FXdouble n){ return set(x*n,y*n,z*n,w*n); } FXVec4d& operator/=(FXdouble n){ return set(x/n,y/n,z/n,w/n); } /// Element-wise assigning operators FXVec4d& operator+=(const FXVec4d& v){ return set(x+v.x,y+v.y,z+v.z,w+v.w); } FXVec4d& operator-=(const FXVec4d& v){ return set(x-v.x,y-v.y,z-v.z,w-v.w); } FXVec4d& operator%=(const FXVec4d& v){ return set(x*v.x,y*v.y,z*v.z,w*v.w); } FXVec4d& operator/=(const FXVec4d& v){ return set(x/v.x,y/v.y,z/v.z,w/v.w); } /// Conversion operator FXdouble*(){return &x;} operator const FXdouble*() const {return &x;} operator FXVec3d&(){return *reinterpret_cast(this);} operator const FXVec3d&() const {return *reinterpret_cast(this);} /// Test if zero FXbool operator!() const {return x==0.0 && y==0.0 && z==0.0 && w==0.0; } /// Unary FXVec4d operator+() const { return *this; } FXVec4d operator-() const { return FXVec4d(-x,-y,-z,-w); } /// Length and square of length FXdouble length2() const { return w*w+z*z+y*y+x*x; } FXdouble length() const { return Math::sqrt(length2()); } /// Signed distance normalized plane and point FXdouble distance(const FXVec3d& p) const; /// Return true if edge a-b crosses plane FXbool crosses(const FXVec3d& a,const FXVec3d& b) const; /// Destructor ~FXVec4d(){} }; /// Dot product inline FXdouble operator*(const FXVec4d& a,const FXVec4d& b){ return a.x*b.x+a.y*b.y+a.z*b.z+a.w*b.w; } /// Scaling inline FXVec4d operator*(const FXVec4d& a,FXdouble n){return FXVec4d(a.x*n,a.y*n,a.z*n,a.w*n);} inline FXVec4d operator*(FXdouble n,const FXVec4d& a){return FXVec4d(n*a.x,n*a.y,n*a.z,n*a.w);} inline FXVec4d operator/(const FXVec4d& a,FXdouble n){return FXVec4d(a.x/n,a.y/n,a.z/n,a.w/n);} inline FXVec4d operator/(FXdouble n,const FXVec4d& a){return FXVec4d(n/a.x,n/a.y,n/a.z,n/a.w);} /// Vector and vector addition inline FXVec4d operator+(const FXVec4d& a,const FXVec4d& b){ return FXVec4d(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w); } inline FXVec4d operator-(const FXVec4d& a,const FXVec4d& b){ return FXVec4d(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w); } /// Element-wise multiply and divide inline FXVec4d operator%(const FXVec4d& a,const FXVec4d& b){ return FXVec4d(a.x*b.x,a.y*b.y,a.z*b.z,a.w*b.w); } inline FXVec4d operator/(const FXVec4d& a,const FXVec4d& b){ return FXVec4d(a.x/b.x,a.y/b.y,a.z/b.z,a.w/b.w); } /// Equality tests inline FXbool operator==(const FXVec4d& a,FXdouble n){return a.x==n && a.y==n && a.z==n && a.w==n;} inline FXbool operator!=(const FXVec4d& a,FXdouble n){return a.x!=n || a.y!=n || a.z!=n || a.w!=n;} inline FXbool operator==(FXdouble n,const FXVec4d& a){return n==a.x && n==a.y && n==a.z && n==a.w;} inline FXbool operator!=(FXdouble n,const FXVec4d& a){return n!=a.x || n!=a.y || n!=a.z || n!=a.w;} /// Equality tests inline FXbool operator==(const FXVec4d& a,const FXVec4d& b){ return a.x==b.x && a.y==b.y && a.z==b.z && a.w==b.w; } inline FXbool operator!=(const FXVec4d& a,const FXVec4d& b){ return a.x!=b.x || a.y!=b.y || a.z!=b.z || a.w!=b.w; } /// Inequality tests inline FXbool operator<(const FXVec4d& a,FXdouble n){return a.x(const FXVec4d& a,FXdouble n){return a.x>n && a.y>n && a.z>n && a.w>n;} inline FXbool operator>=(const FXVec4d& a,FXdouble n){return a.x>=n && a.y>=n && a.z>=n && a.w>=n;} /// Inequality tests inline FXbool operator<(FXdouble n,const FXVec4d& a){return n(FXdouble n,const FXVec4d& a){return n>a.x && n>a.y && n>a.z && n>a.w;} inline FXbool operator>=(FXdouble n,const FXVec4d& a){return n>=a.x && n>=a.y && n>=a.z && n>=a.w;} /// Inequality tests inline FXbool operator<(const FXVec4d& a,const FXVec4d& b){ return a.x(const FXVec4d& a,const FXVec4d& b){ return a.x>b.x && a.y>b.y && a.z>b.z && a.w>b.w; } inline FXbool operator>=(const FXVec4d& a,const FXVec4d& b){ return a.x>=b.x && a.y>=b.y && a.z>=b.z && a.w>=b.w; } /// Lowest components inline FXVec4d lo(const FXVec4d& a,const FXVec4d& b){return FXVec4d(Math::fmin(a.x,b.x),Math::fmin(a.y,b.y),Math::fmin(a.z,b.z),Math::fmin(a.w,b.w));} inline FXVec4d lo(const FXVec4d& a,FXdouble n){return FXVec4d(Math::fmin(a.x,n),Math::fmin(a.y,n),Math::fmin(a.z,n),Math::fmin(a.w,n));} inline FXVec4d lo(FXdouble n,const FXVec4d& b){return FXVec4d(Math::fmin(n,b.x),Math::fmin(n,b.y),Math::fmin(n,b.z),Math::fmin(n,b.w));} /// Highest components inline FXVec4d hi(const FXVec4d& a,const FXVec4d& b){return FXVec4d(Math::fmax(a.x,b.x),Math::fmax(a.y,b.y),Math::fmax(a.z,b.z),Math::fmax(a.w,b.w));} inline FXVec4d hi(const FXVec4d& a,FXdouble n){return FXVec4d(Math::fmax(a.x,n),Math::fmax(a.y,n),Math::fmax(a.z,n),Math::fmax(a.w,n));} inline FXVec4d hi(FXdouble n,const FXVec4d& b){return FXVec4d(Math::fmax(n,b.x),Math::fmax(n,b.y),Math::fmax(n,b.z),Math::fmax(n,b.w));} /// Clamp components of vector between lower and upper limits inline FXVec4d clamp(FXdouble lower,const FXVec4d& x,FXdouble upper){return hi(lo(x,upper),lower);} /// Clamp components of vector between lower corner and upper corner inline FXVec4d clamp(const FXVec4d& lower,const FXVec4d& x,const FXVec4d& upper){return hi(lo(x,upper),lower);} /// Return vector of absolute value of each element inline FXVec4d abs(const FXVec4d& a){return FXVec4d(Math::fabs(a.x),Math::fabs(a.y),Math::fabs(a.z),Math::fabs(a.w));} /// Return maximum component of vector inline FXdouble max(const FXVec4d& a){ return Math::fmax(Math::fmax(a.x,a.y),Math::fmax(a.z,a.w)); } /// Return minimum component of vector inline FXdouble min(const FXVec4d& a){ return Math::fmin(Math::fmin(a.x,a.y),Math::fmin(a.z,a.w)); } /// Linearly interpolate inline FXVec4d lerp(const FXVec4d& u,const FXVec4d& v,FXdouble f){return (v-u)*f+u;} /// Compute normalized plane equation ax+by+cz+d=0 extern FXAPI FXVec4d plane(const FXVec4d& vec); /// Compute plane equation from vector and distance extern FXAPI FXVec4d plane(const FXVec3d& vec,FXdouble dist); /// Compute plane equation from vector and point on plane extern FXAPI FXVec4d plane(const FXVec3d& vec,const FXVec3d& p); /// Compute plane equation from 3 points a,b,c extern FXAPI FXVec4d plane(const FXVec3d& a,const FXVec3d& b,const FXVec3d& c); /// Convert vector to color extern FXAPI FXColor colorFromVec4d(const FXVec4d& vec); /// Convert color to vector extern FXAPI FXVec4d colorToVec4d(FXColor clr); /// Normalize vector extern FXAPI FXVec4d normalize(const FXVec4d& v); /// Save vector to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXVec4d& v); /// Load vector from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXVec4d& v); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXVec4f.h000066400000000000000000000236451455751074500220510ustar00rootroot00000000000000/******************************************************************************** * * * S i n g l e - P r e c i s i o n 4 - E l e m e n t V e c t o r * * * ********************************************************************************* * Copyright (C) 1994,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXVEC4F_H #define FXVEC4F_H namespace FX { /// Single-precision 4-element vector class FXAPI FXVec4f { public: FXfloat x; FXfloat y; FXfloat z; FXfloat w; public: /// Default constructor; value is not initialized FXVec4f(){} /// Construct with 3-vector FXVec4f(const FXVec3f& v,FXfloat s=0.0f):x(v.x),y(v.y),z(v.z),w(s){} /// Initialize from another vector FXVec4f(const FXVec4f& v):x(v.x),y(v.y),z(v.z),w(v.w){} /// Construct from array of floats FXVec4f(const FXfloat v[]):x(v[0]),y(v[1]),z(v[2]),w(v[3]){} /// Construct from components FXVec4f(FXfloat xx,FXfloat yy,FXfloat zz,FXfloat ww):x(xx),y(yy),z(zz),w(ww){} /// Return a non-const reference to the ith element FXfloat& operator[](FXint i){return (&x)[i];} /// Return a const reference to the ith element const FXfloat& operator[](FXint i) const {return (&x)[i];} /// Assignment FXVec4f& operator=(const FXVec4f& v){x=v.x;y=v.y;z=v.z;w=v.w;return *this;} /// Assignment from array of floats FXVec4f& operator=(const FXfloat v[]){x=v[0];y=v[1];z=v[2];w=v[3];return *this;} /// Set value from another vector FXVec4f& set(const FXVec4f& v){x=v.x;y=v.y;z=v.z;w=v.w;return *this;} /// Set value from array of floats FXVec4f& set(const FXfloat v[]){x=v[0];y=v[1];z=v[2];w=v[3];return *this;} /// Set value from components FXVec4f& set(FXfloat xx,FXfloat yy,FXfloat zz,FXfloat ww){x=xx;y=yy;z=zz;w=ww;return *this;} /// Assigning operators FXVec4f& operator*=(FXfloat n){ return set(x*n,y*n,z*n,w*n); } FXVec4f& operator/=(FXfloat n){ return set(x/n,y/n,z/n,w/n); } /// Element-wise assigning operators FXVec4f& operator+=(const FXVec4f& v){ return set(x+v.x,y+v.y,z+v.z,w+v.w); } FXVec4f& operator-=(const FXVec4f& v){ return set(x-v.x,y-v.y,z-v.z,w-v.w); } FXVec4f& operator%=(const FXVec4f& v){ return set(x*v.x,y*v.y,z*v.z,w*v.w); } FXVec4f& operator/=(const FXVec4f& v){ return set(x/v.x,y/v.y,z/v.z,w/v.w); } /// Conversion operator FXfloat*(){return &x;} operator const FXfloat*() const {return &x;} operator FXVec3f&(){return *reinterpret_cast(this);} operator const FXVec3f&() const {return *reinterpret_cast(this);} /// Test if zero FXbool operator!() const { return x==0.0f && y==0.0f && z==0.0f && w==0.0f; } /// Unary FXVec4f operator+() const { return *this; } FXVec4f operator-() const { return FXVec4f(-x,-y,-z,-w); } /// Length and square of length FXfloat length2() const { return w*w+z*z+y*y+x*x; } FXfloat length() const { return Math::sqrt(length2()); } /// Signed distance normalized plane and point FXfloat distance(const FXVec3f& p) const; /// Return true if edge a-b crosses plane FXbool crosses(const FXVec3f& a,const FXVec3f& b) const; /// Destructor ~FXVec4f(){} }; /// Dot product inline FXfloat operator*(const FXVec4f& a,const FXVec4f& b){ return a.x*b.x+a.y*b.y+a.z*b.z+a.w*b.w; } /// Scaling inline FXVec4f operator*(const FXVec4f& a,FXfloat n){return FXVec4f(a.x*n,a.y*n,a.z*n,a.w*n);} inline FXVec4f operator*(FXfloat n,const FXVec4f& a){return FXVec4f(n*a.x,n*a.y,n*a.z,n*a.w);} inline FXVec4f operator/(const FXVec4f& a,FXfloat n){return FXVec4f(a.x/n,a.y/n,a.z/n,a.w/n);} inline FXVec4f operator/(FXfloat n,const FXVec4f& a){return FXVec4f(n/a.x,n/a.y,n/a.z,n/a.w);} /// Vector and vector addition inline FXVec4f operator+(const FXVec4f& a,const FXVec4f& b){ return FXVec4f(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w); } inline FXVec4f operator-(const FXVec4f& a,const FXVec4f& b){ return FXVec4f(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w); } /// Element-wise multiply and divide inline FXVec4f operator%(const FXVec4f& a,const FXVec4f& b){ return FXVec4f(a.x*b.x,a.y*b.y,a.z*b.z,a.w*b.w); } inline FXVec4f operator/(const FXVec4f& a,const FXVec4f& b){ return FXVec4f(a.x/b.x,a.y/b.y,a.z/b.z,a.w/b.w); } /// Equality tests inline FXbool operator==(const FXVec4f& a,FXfloat n){return a.x==n && a.y==n && a.z==n && a.w==n;} inline FXbool operator!=(const FXVec4f& a,FXfloat n){return a.x!=n || a.y!=n || a.z!=n || a.w!=n;} inline FXbool operator==(FXfloat n,const FXVec4f& a){return n==a.x && n==a.y && n==a.z && n==a.w;} inline FXbool operator!=(FXfloat n,const FXVec4f& a){return n!=a.x || n!=a.y || n!=a.z || n!=a.w;} /// Equality tests inline FXbool operator==(const FXVec4f& a,const FXVec4f& b){ return a.x==b.x && a.y==b.y && a.z==b.z && a.w==b.w; } inline FXbool operator!=(const FXVec4f& a,const FXVec4f& b){ return a.x!=b.x || a.y!=b.y || a.z!=b.z || a.w!=b.w; } /// Inequality tests inline FXbool operator<(const FXVec4f& a,FXfloat n){return a.x(const FXVec4f& a,FXfloat n){return a.x>n && a.y>n && a.z>n && a.w>n;} inline FXbool operator>=(const FXVec4f& a,FXfloat n){return a.x>=n && a.y>=n && a.z>=n && a.w>=n;} /// Inequality tests inline FXbool operator<(FXfloat n,const FXVec4f& a){return n(FXfloat n,const FXVec4f& a){return n>a.x && n>a.y && n>a.z && n>a.w;} inline FXbool operator>=(FXfloat n,const FXVec4f& a){return n>=a.x && n>=a.y && n>=a.z && n>=a.w;} /// Inequality tests inline FXbool operator<(const FXVec4f& a,const FXVec4f& b){ return a.x(const FXVec4f& a,const FXVec4f& b){ return a.x>b.x && a.y>b.y && a.z>b.z && a.w>b.w; } inline FXbool operator>=(const FXVec4f& a,const FXVec4f& b){ return a.x>=b.x && a.y>=b.y && a.z>=b.z && a.w>=b.w; } /// Lowest components inline FXVec4f lo(const FXVec4f& a,const FXVec4f& b){return FXVec4f(Math::fmin(a.x,b.x),Math::fmin(a.y,b.y),Math::fmin(a.z,b.z),Math::fmin(a.w,b.w));} inline FXVec4f lo(const FXVec4f& a,FXfloat n){return FXVec4f(Math::fmin(a.x,n),Math::fmin(a.y,n),Math::fmin(a.z,n),Math::fmin(a.w,n));} inline FXVec4f lo(FXfloat n,const FXVec4f& b){return FXVec4f(Math::fmin(n,b.x),Math::fmin(n,b.y),Math::fmin(n,b.z),Math::fmin(n,b.w));} /// Highest components inline FXVec4f hi(const FXVec4f& a,const FXVec4f& b){return FXVec4f(Math::fmax(a.x,b.x),Math::fmax(a.y,b.y),Math::fmax(a.z,b.z),Math::fmax(a.w,b.w));} inline FXVec4f hi(const FXVec4f& a,FXfloat n){return FXVec4f(Math::fmax(a.x,n),Math::fmax(a.y,n),Math::fmax(a.z,n),Math::fmax(a.w,n));} inline FXVec4f hi(FXfloat n,const FXVec4f& b){return FXVec4f(Math::fmax(n,b.x),Math::fmax(n,b.y),Math::fmax(n,b.z),Math::fmax(n,b.w));} /// Clamp components of vector between lower and upper limits inline FXVec4f clamp(FXfloat lower,const FXVec4f& x,FXfloat upper){return hi(lo(x,upper),lower);} /// Clamp components of vector between lower corner and upper corner inline FXVec4f clamp(const FXVec4f& lower,const FXVec4f& x,const FXVec4f& upper){return hi(lo(x,upper),lower);} /// Return vector of absolute value of each element inline FXVec4f abs(const FXVec4f& a){return FXVec4f(Math::fabs(a.x),Math::fabs(a.y),Math::fabs(a.z),Math::fabs(a.w));} /// Return maximum component of vector inline FXfloat max(const FXVec4f& a){ return Math::fmax(Math::fmax(a.x,a.y),Math::fmax(a.z,a.w)); } /// Return minimum component of vector inline FXfloat min(const FXVec4f& a){ return Math::fmin(Math::fmin(a.x,a.y),Math::fmin(a.z,a.w)); } /// Linearly interpolate inline FXVec4f lerp(const FXVec4f& u,const FXVec4f& v,FXfloat f){return (v-u)*f+u;} /// Compute normalized plane equation ax+by+cz+d=0 extern FXAPI FXVec4f plane(const FXVec4f& vec); /// Compute plane equation from vector and distance extern FXAPI FXVec4f plane(const FXVec3f& vec,FXfloat dist); /// Compute plane equation from vector and point on plane extern FXAPI FXVec4f plane(const FXVec3f& vec,const FXVec3f& p); /// Compute plane equation from 3 points a,b,c extern FXAPI FXVec4f plane(const FXVec3f& a,const FXVec3f& b,const FXVec3f& c); /// Convert vector to color extern FXAPI FXColor colorFromVec4f(const FXVec4f& vec); /// Convert color to vector extern FXAPI FXVec4f colorToVec4f(FXColor clr); /// Normalize vector extern FXAPI FXVec4f normalize(const FXVec4f& v); /// Save vector to a stream extern FXAPI FXStream& operator<<(FXStream& store,const FXVec4f& v); /// Load vector from a stream extern FXAPI FXStream& operator>>(FXStream& store,FXVec4f& v); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXVerticalFrame.h000066400000000000000000000051341455751074500236170ustar00rootroot00000000000000/******************************************************************************** * * * V e r t i c a l C o n t a i n e r W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXVERTICALFRAME_H #define FXVERTICALFRAME_H #ifndef FXPACKER_H #include "FXPacker.h" #endif namespace FX { /** * Vertical frame layout manager widget is used to automatically * place child-windows vertically from top-to-bottom, or bottom-to-top, * depending on the child window's layout hints. */ class FXAPI FXVerticalFrame : public FXPacker { FXDECLARE(FXVerticalFrame) protected: FXVerticalFrame(){} private: FXVerticalFrame(const FXVerticalFrame&); FXVerticalFrame& operator=(const FXVerticalFrame&); public: /// Construct a vertical frame layout manager FXVerticalFrame(FXComposite *p,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_SPACING,FXint pr=DEFAULT_SPACING,FXint pt=DEFAULT_SPACING,FXint pb=DEFAULT_SPACING,FXint hs=DEFAULT_SPACING,FXint vs=DEFAULT_SPACING); /// Perform layout virtual void layout(); /// Return default width virtual FXint getDefaultWidth(); /// Return default height virtual FXint getDefaultHeight(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXVisual.h000066400000000000000000000142721455751074500223410ustar00rootroot00000000000000/******************************************************************************** * * * V i s u a l C l a s s * * * ********************************************************************************* * Copyright (C) 1999,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXVISUAL_H #define FXVISUAL_H #ifndef FXID_H #include "FXId.h" #endif namespace FX { class FXWindow; class FXGLContext; class FXGLCanvas; class FXImage; class FXIcon; class FXBitmap; class FXDCWindow; /// Construction options for FXVisual class enum { VISUAL_DEFAULT = 0, /// Default visual VISUAL_MONO = 1, /// Must be monochrome visual VISUAL_GRAY = 2, /// Gray scale visual VISUAL_INDEX = 4, /// Palette visual VISUAL_COLOR = 8, /// Must be true color visual VISUAL_BEST = 16, /// Best (deepest) visual VISUAL_FORCE = 32, /// Force given visual id (X11) VISUAL_OWN_COLORMAP = 64, /// Allocate private colormap VISUAL_DOUBLE_BUFFER = 128, /// Double buffered [GL Visual] VISUAL_STEREO = 256, /// Stereo buffered [GL Visual] VISUAL_NO_ACCEL = 512, /// No hardware acceleration [GL Visual] VISUAL_SWAP_COPY = 1024 /// Buffer swap by copying [GL Visual] }; /// Visual describes pixel format of a drawable class FXAPI FXVisual : public FXId { FXDECLARE(FXVisual) friend class FXApp; friend class FXWindow; friend class FXImage; friend class FXIcon; friend class FXBitmap; friend class FXDCWindow; friend class FXGLCanvas; friend class FXGLContext; protected: void *visual; // Application visual/pixel format FXID colormap; // Color map, if any FXuint maxcolors; // Maximum number of colors FXuint numcolors; // Total number of colors FXuint numred; // Number of reds FXuint numgreen; // Number of greens FXuint numblue; // Number of blues FXuint depth; // Visual depth, significant bits/pixel FXuint flags; // Visual flags FXuint hint; // Hint value FXuchar type; // Visual type FXbool freemap; // We allocated the map #ifndef WIN32 protected: void *scrollgc; // Scrolling GC void *gc; // Drawing GC FXPixel rpix[16][256]; // Mapping from red -> pixel FXPixel gpix[16][256]; // Mapping from green -> pixel FXPixel bpix[16][256]; // Mapping from blue -> pixel FXPixel lut[256]; // Color lookup table protected: void setuptruecolor(); void setupdirectcolor(); void setuppseudocolor(); void setupstaticcolor(); void setupgrayscale(); void setupstaticgray(); void setuppixmapmono(); void setupcolormap(); void* setupgc(FXbool); #endif protected: FXVisual(); private: FXVisual(const FXVisual&); FXVisual &operator=(const FXVisual&); public: /// Visual types enum { Unknown, /// Undetermined visual type Mono, /// Monochrome 1 bit/pixel Gray, /// Gray scale color Index, /// Index color Color /// True color }; public: /// Construct visual FXVisual(FXApp* a,FXuint flgs=VISUAL_DEFAULT,FXuint hnt=32); /// Get visual type FXuchar getType() const { return type; } /// Get visual or pixel format void* getVisual() const { return visual; } /// Create visual virtual void create(); /// Detach visual virtual void detach(); /// Destroy visual virtual void destroy(); /// Change option flags void setFlags(FXuint flgs){ flags=flgs; } /// Get option flags FXuint getFlags() const { return flags; } /// Change hints void setHint(FXuint hnt){ hint=hnt; } /// Get hints FXuint getHint() const { return hint; } /// Get depth, i.e. number of significant bits in color representation FXuint getDepth() const { return depth; } /// Get number of colors FXuint getNumColors() const { return numcolors; } /// Get number of reds FXuint getNumRed() const { return numred; } /// Get number of greens FXuint getNumGreen() const { return numgreen; } /// Get number of blues FXuint getNumBlue() const { return numblue; } /// Get device pixel value for color FXPixel getPixel(FXColor clr); /// Get color value for device pixel value FXColor getColor(FXPixel pix); /// Set maximum number of colors to allocate void setMaxColors(FXuint maxcols); /// Get maximum number of colors FXuint getMaxColors() const { return maxcolors; } /// Save visual information to a stream virtual void save(FXStream& store) const; /// Load visual information from a stream virtual void load(FXStream& store); /// Destructor virtual ~FXVisual(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXWEBPIcon.h000066400000000000000000000060511455751074500224400ustar00rootroot00000000000000/******************************************************************************** * * * W E B P I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 1999,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXWEBPICON_H #define FXWEBPICON_H #ifndef FXICON_H #include "FXIcon.h" #endif namespace FX { /// Google WebP Icon class class FXAPI FXWEBPIcon : public FXIcon { FXDECLARE(FXWEBPIcon) protected: FXWEBPIcon(){} private: FXWEBPIcon(const FXWEBPIcon&); FXWEBPIcon &operator=(const FXWEBPIcon&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct an icon from memory stream formatted in WEBP format FXWEBPIcon(FXApp *a,const FXuchar *pix=nullptr,FXColor clr=FXRGB(192,192,192),FXuint opts=0,FXint w=1,FXint h=1); /// True if format is supported static const FXbool supported; /// Save pixels into stream in WEBP format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in WEBP format virtual FXbool loadPixels(FXStream& store); /// Destroy virtual ~FXWEBPIcon(); }; #ifndef FXLOADWEBP #define FXLOADWEBP /** * Check if stream contains a WEBP, return true if so. */ extern FXAPI FXbool fxcheckWEBP(FXStream& store); /** * Load an WEBP image file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadWEBP(FXStream& store,FXColor*& data,FXint& width,FXint& height); /** * Save an WEBP image file to a stream. */ extern FXAPI FXbool fxsaveWEBP(FXStream& store,const FXColor* data,FXint width,FXint height,FXfloat quality); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXWEBPImage.h000066400000000000000000000060321455751074500225710ustar00rootroot00000000000000/******************************************************************************** * * * W E B P I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 1999,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXWEBPIMAGE_H #define FXWEBPIMAGE_H #ifndef FXIMAGE_H #include "FXImage.h" #endif namespace FX { /// Google WebP Image class class FXAPI FXWEBPImage : public FXImage { FXDECLARE(FXWEBPImage) protected: FXWEBPImage(){} private: FXWEBPImage(const FXWEBPImage&); FXWEBPImage &operator=(const FXWEBPImage&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct an image from memory stream formatted in WEBP format FXWEBPImage(FXApp *a,const FXuchar *pix=nullptr,FXuint opts=0,FXint w=1,FXint h=1); /// True if format is supported static const FXbool supported; /// Load pixels from stream in WEBP format virtual FXbool savePixels(FXStream& store) const; /// Save pixels into stream in WEBP format virtual FXbool loadPixels(FXStream& store); /// Destroy virtual ~FXWEBPImage(); }; #ifndef FXLOADWEBP #define FXLOADWEBP /** * Check if stream contains a WEBP, return true if so. */ extern FXAPI FXbool fxcheckWEBP(FXStream& store); /** * Load an WEBP image file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadWEBP(FXStream& store,FXColor*& data,FXint& width,FXint& height); /** * Save an WEBP image file to a stream. */ extern FXAPI FXbool fxsaveWEBP(FXStream& store,const FXColor* data,FXint width,FXint height,FXfloat quality); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXWSQueue.h000066400000000000000000000047641455751074500224410ustar00rootroot00000000000000/******************************************************************************** * * * W o r k - S t e a l i n g Q u e u e * * * ********************************************************************************* * Copyright (C) 2016,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXWSQUEUE_H #define FXWSQUEUE_H namespace FX { /// Work-stealing queue class FXAPI FXWSQueue { private: FXPtrList list; volatile FXint top; volatile FXint bot; private: FXWSQueue(const FXWSQueue&); FXWSQueue &operator=(const FXWSQueue&); public: /// Create a queue and set its size to sz FXWSQueue(FXint sz=256); /// Change size of the queue FXbool setSize(FXint sz); /// Return size FXint getSize() const { return list.no(); } /// Return number of used slots FXint getUsed() const; /// Return number of free slots FXint getFree() const; /// Check if queue is full FXbool isFull() const; /// Check if queue is empty FXbool isEmpty() const; /// Push pointer FXbool push(FXptr ptr); /// Pop pointer FXbool pop(FXptr& ptr); /// Take (steal) pointer FXbool take(FXptr& ptr); /// Delete queue virtual ~FXWSQueue(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXWindow.h000066400000000000000000000751631455751074500223530ustar00rootroot00000000000000/******************************************************************************** * * * W i n d o w O b j e c t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXWINDOW_H #define FXWINDOW_H #ifndef FXDRAWABLE_H #include "FXDrawable.h" #endif namespace FX { // Forward declarations class FXIcon; class FXBitmap; class FXCursor; class FXRegion; class FXDCWindow; class FXComposite; class FXAccelTable; class FXComposeContext; /// Layout hints for child widgets enum { LAYOUT_NORMAL = 0, /// Default layout mode LAYOUT_SIDE_TOP = 0, /// Pack on top side (default) LAYOUT_SIDE_BOTTOM = 0x00000001, /// Pack on bottom side LAYOUT_SIDE_LEFT = 0x00000002, /// Pack on left side LAYOUT_SIDE_RIGHT = LAYOUT_SIDE_LEFT|LAYOUT_SIDE_BOTTOM, /// Pack on right side LAYOUT_FILL_COLUMN = 0x00000001, /// Matrix column is stretchable LAYOUT_FILL_ROW = 0x00000002, /// Matrix row is stretchable LAYOUT_LEFT = 0, /// Stick on left (default) LAYOUT_RIGHT = 0x00000004, /// Stick on right LAYOUT_CENTER_X = 0x00000008, /// Center horizontally LAYOUT_FIX_X = LAYOUT_RIGHT|LAYOUT_CENTER_X, /// X fixed LAYOUT_TOP = 0, /// Stick on top (default) LAYOUT_BOTTOM = 0x00000010, /// Stick on bottom LAYOUT_CENTER_Y = 0x00000020, /// Center vertically LAYOUT_FIX_Y = LAYOUT_BOTTOM|LAYOUT_CENTER_Y, /// Y fixed LAYOUT_DOCK_SAME = 0, /// Dock on same galley if it fits LAYOUT_DOCK_NEXT = 0x00000040, /// Dock on next galley LAYOUT_RESERVED_1 = 0x00000080, LAYOUT_FIX_WIDTH = 0x00000100, /// Width fixed LAYOUT_FIX_HEIGHT = 0x00000200, /// height fixed LAYOUT_MIN_WIDTH = 0, /// Minimum width is the default LAYOUT_MIN_HEIGHT = 0, /// Minimum height is the default LAYOUT_FILL_X = 0x00000400, /// Stretch or shrink horizontally LAYOUT_FILL_Y = 0x00000800, /// Stretch or shrink vertically LAYOUT_FILL = LAYOUT_FILL_X|LAYOUT_FILL_Y, /// Stretch or shrink in both directions LAYOUT_EXPLICIT = LAYOUT_FIX_X|LAYOUT_FIX_Y|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT /// Explicit placement }; /// Frame border appearance styles (for subclasses) enum { FRAME_NONE = 0, /// Default is no frame FRAME_SUNKEN = 0x00001000, /// Sunken border FRAME_RAISED = 0x00002000, /// Raised border FRAME_THICK = 0x00004000, /// Thick border FRAME_GROOVE = FRAME_THICK, /// A groove or etched-in border FRAME_RIDGE = FRAME_THICK|FRAME_RAISED|FRAME_SUNKEN, /// A ridge or embossed border FRAME_LINE = FRAME_RAISED|FRAME_SUNKEN, /// Simple line border FRAME_NORMAL = FRAME_SUNKEN|FRAME_THICK /// Regular raised/thick border }; /// Packing style (for packers) enum { PACK_NORMAL = 0, /// Default is each its own size PACK_UNIFORM_HEIGHT = 0x00008000, /// Uniform height PACK_UNIFORM_WIDTH = 0x00010000 /// Uniform width }; /// Data exchange modes enum FXDNDOrigin { FROM_SELECTION = 0, /// Primary selection FROM_CLIPBOARD = 1, /// Clipboard FROM_DRAGNDROP = 2 /// Drag and drop source }; /// Drag and drop actions enum FXDragAction { DRAG_REJECT = 0, /// Reject all drop actions DRAG_ASK = 1, /// Ask DRAG_COPY = 2, /// Copy DRAG_MOVE = 3, /// Move DRAG_LINK = 4, /// Link DRAG_PRIVATE = 5, /// Private DRAG_ACCEPT = 6 /// Accept any drop action }; /** * Window is the base class for all widgets in FOX. * All widgets are organized in a tree structure, with a single root window * at the top. * Each window links to its parent window, next and previous siblings windows, * as well as its first and last child windows. A window also has an owner window, * which is the window responsible for its creation and destruction. In most cases, * the owner window will be the same as the parent window, except for top-level windows. * The focus window determines to which child keyboard messages are delegated if the * window is a composite window (i.e. if it has children). * Windows are geometrically arranged by their immediate parent window; the actual * method of placement is determined by the type of layout supported by the parent * window, as well as the window's layout hints. * The position of a window is determined relative to its immediate parent window; * A window can send a message to its target object when an event happens. */ class FXAPI FXWindow : public FXDrawable { FXDECLARE(FXWindow) friend class FXApp; private: FXWindow *parent; // Parent Window FXWindow *owner; // Owner Window FXWindow *first; // First Child FXWindow *last; // Last Child FXWindow *next; // Next Sibling FXWindow *prev; // Previous Sibling FXWindow *focus; // Focus Child FXuint wk; // Window Key protected: FXComposeContext *composeContext; // Compose context FXCursor *defaultCursor; // Normal Cursor FXCursor *dragCursor; // Cursor during drag FXAccelTable *accelTable; // Accelerator table FXObject *target; // Target object FXSelector message; // Message ID FXint xpos; // Window X Position FXint ypos; // Window Y Position FXColor backColor; // Window background color FXString tag; // Help tag FXuint flags; // Window state flags FXuint options; // Window options public: static FXDragType octetType; // Raw octet stream static FXDragType deleteType; // Delete request static FXDragType textType; // Ascii text request static FXDragType colorType; // Color request static FXDragType urilistType; // URI list request static FXDragType utf8Type; // UTF-8 text request static FXDragType utf16Type; // UTF-16 text request static FXDragType actionType; // Clipboard action static const FXDragType stringType; // Clipboard text type (pre-registered) static const FXDragType imageType; // Clipboard image type (pre-registered) protected: virtual FXbool doesOverrideRedirect() const; protected: #ifdef WIN32 virtual FXID GetDC() const; virtual int ReleaseDC(FXID) const; virtual const void* GetClass() const; #else void addColormapWindows(); void remColormapWindows(); #endif protected: FXWindow(); FXWindow(FXApp* a,FXVisual *vis); FXWindow(FXApp* a,FXWindow* own,FXuint opts,FXint x,FXint y,FXint w,FXint h); private: FXWindow(const FXWindow&); FXWindow& operator=(const FXWindow&); protected: // Window state flags enum { FLAG_SHOWN = 0x00000001, // Is shown FLAG_ENABLED = 0x00000002, // Able to receive input FLAG_UPDATE = 0x00000004, // Is subject to GUI update FLAG_DROPTARGET = 0x00000008, // Drop target FLAG_FOCUSED = 0x00000010, // Has focus FLAG_DIRTY = 0x00000020, // Needs layout FLAG_RECALC = 0x00000040, // Needs recalculation FLAG_TIP = 0x00000080, // Show tip FLAG_HELP = 0x00000100, // Show help FLAG_DEFAULT = 0x00000200, // Default widget FLAG_INITIAL = 0x00000400, // Initial widget FLAG_SHELL = 0x00000800, // Shell window FLAG_ACTIVE = 0x00001000, // Window is active FLAG_PRESSED = 0x00002000, // Button has been pressed FLAG_KEY = 0x00004000, // Keyboard key pressed FLAG_CARET = 0x00008000, // Caret is on FLAG_CHANGED = 0x00010000, // Window data changed FLAG_LASSO = 0x00020000, // Lasso mode FLAG_TRYDRAG = 0x00040000, // Tentative drag mode FLAG_DODRAG = 0x00080000, // Doing drag mode FLAG_SCROLLINSIDE = 0x00100000, // Scroll only when inside FLAG_SCROLLING = 0x00200000, // Right mouse scrolling FLAG_OWNED = 0x00400000, // Owned window handle FLAG_CURSOR = 0x00800000 // Showing cursor }; public: /// Window classes enum WindowClass { ClassNormal, /// Normal child window ClassGraphic, /// Graphics child window ClassSpecial, /// Special child window ClassRoot, /// Root window ClassShell, /// Shell window ClassPopup, /// Popup window ClassToolTip, /// Tooltip window ClassMain, /// Main application window ClassDialog, /// Dialog box window ClassToolBar, /// Toolbar window ClassSplash, /// Splash window ClassNotify, /// Notify window ClassPanel, /// Panel window ClassDesktop /// Desktop backdrop window }; public: long onPaint(FXObject*,FXSelector,void*); long onMap(FXObject*,FXSelector,void*); long onUnmap(FXObject*,FXSelector,void*); long onConfigure(FXObject*,FXSelector,void*); long onUpdate(FXObject*,FXSelector,void*); long onMotion(FXObject*,FXSelector,void*); long onMouseWheel(FXObject*,FXSelector,void*); long onEnter(FXObject*,FXSelector,void*); long onLeave(FXObject*,FXSelector,void*); long onLeftBtnPress(FXObject*,FXSelector,void*); long onLeftBtnRelease(FXObject*,FXSelector,void*); long onMiddleBtnPress(FXObject*,FXSelector,void*); long onMiddleBtnRelease(FXObject*,FXSelector,void*); long onRightBtnPress(FXObject*,FXSelector,void*); long onRightBtnRelease(FXObject*,FXSelector,void*); long onSpaceBallMotion(FXObject*,FXSelector,void*); long onSpaceBallButtonPress(FXObject*,FXSelector,void*); long onSpaceBallButtonRelease(FXObject*,FXSelector,void*); long onBeginDrag(FXObject*,FXSelector,void*); long onEndDrag(FXObject*,FXSelector,void*); long onDragged(FXObject*,FXSelector,void*); long onKeyPress(FXObject*,FXSelector,void*); long onKeyRelease(FXObject*,FXSelector,void*); long onUngrabbed(FXObject*,FXSelector,void*); long onDestroy(FXObject*,FXSelector,void*); long onFocusSelf(FXObject*,FXSelector,void*); long onFocusIn(FXObject*,FXSelector,void*); long onFocusOut(FXObject*,FXSelector,void*); long onSelectionLost(FXObject*,FXSelector,void*); long onSelectionGained(FXObject*,FXSelector,void*); long onSelectionRequest(FXObject*,FXSelector,void*); long onClipboardLost(FXObject*,FXSelector,void*); long onClipboardGained(FXObject*,FXSelector,void*); long onClipboardRequest(FXObject*,FXSelector,void*); long onDNDEnter(FXObject*,FXSelector,void*); long onDNDLeave(FXObject*,FXSelector,void*); long onDNDMotion(FXObject*,FXSelector,void*); long onDNDDrop(FXObject*,FXSelector,void*); long onDNDRequest(FXObject*,FXSelector,void*); long onQueryHelp(FXObject*,FXSelector,void*); long onQueryTip(FXObject*,FXSelector,void*); long onCmdShow(FXObject*,FXSelector,void*); long onCmdHide(FXObject*,FXSelector,void*); long onUpdToggleShown(FXObject*,FXSelector,void*); long onCmdToggleShown(FXObject*,FXSelector,void*); long onCmdRaise(FXObject*,FXSelector,void*); long onCmdLower(FXObject*,FXSelector,void*); long onCmdEnable(FXObject*,FXSelector,void*); long onCmdDisable(FXObject*,FXSelector,void*); long onUpdToggleEnabled(FXObject*,FXSelector,void*); long onCmdToggleEnabled(FXObject*,FXSelector,void*); long onCmdUpdate(FXObject*,FXSelector,void*); long onUpdYes(FXObject*,FXSelector,void*); long onCmdDelete(FXObject*,FXSelector,void*); public: enum { ID_NONE, ID_HIDE, ID_SHOW, ID_TOGGLESHOWN, ID_LOWER, ID_RAISE, ID_DELETE, ID_DISABLE, ID_ENABLE, ID_TOGGLEENABLED, ID_UNCHECK, ID_CHECK, ID_UNKNOWN, ID_UPDATE, ID_TIPTIMER, ID_SETVALUE, ID_SETINTVALUE, ID_SETLONGVALUE, ID_SETREALVALUE, ID_SETSTRINGVALUE, ID_SETICONVALUE, ID_SETINTRANGE, ID_SETREALRANGE, ID_GETINTVALUE, ID_GETLONGVALUE, ID_GETREALVALUE, ID_GETSTRINGVALUE, ID_GETICONVALUE, ID_GETINTRANGE, ID_GETREALRANGE, ID_SETHELPSTRING, ID_GETHELPSTRING, ID_SETTIPSTRING, ID_GETTIPSTRING, ID_QUERY_MENU, ID_HOTKEY, ID_ACCEL, ID_UNPOST, ID_POST, ID_MDI_TILEHORIZONTAL, ID_MDI_TILEVERTICAL, ID_MDI_CASCADE, ID_MDI_MAXIMIZE, ID_MDI_MINIMIZE, ID_MDI_RESTORE, ID_MDI_CLOSE, ID_MDI_WINDOW, ID_MDI_MENUWINDOW, ID_MDI_MENUMINIMIZE, ID_MDI_MENURESTORE, ID_MDI_MENUCLOSE, ID_MDI_NEXT, ID_MDI_PREV, ID_LAST }; public: // Predefined DND type names static const FXchar octetTypeName[]; static const FXchar deleteTypeName[]; static const FXchar textTypeName[]; static const FXchar colorTypeName[]; static const FXchar urilistTypeName[]; static const FXchar utf8TypeName[]; static const FXchar utf16TypeName[]; static const FXchar actionTypeName[]; public: /// Constructor FXWindow(FXComposite* p,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); /// Return a pointer to the parent window FXWindow* getParent() const { return parent; } /// Return a pointer to the owner window FXWindow* getOwner() const { return owner; } /// Return a pointer to the shell window FXWindow* getShell() const; /// Return a pointer to the root window FXWindow* getRoot() const; /// Return a pointer to the next (sibling) window, if any FXWindow* getNext() const { return next; } /// Return a pointer to the previous (sibling) window , if any FXWindow* getPrev() const { return prev; } /// Return a pointer to this window's first child window , if any FXWindow* getFirst() const { return first; } /// Return a pointer to this window's last child window, if any FXWindow* getLast() const { return last; } /// Return a pointer to the currently focused child window FXWindow* getFocus() const { return focus; } /// Get window class virtual WindowClass getWindowClass() const; /// Change window key void setKey(FXuint k){ wk=k; } /// Return window key FXuint getKey() const { return wk; } /// Return child window with given window key FXWindow* getChildWithKey(FXuint k) const; /// Set the message target object for this window void setTarget(FXObject *t){ target=t; } /// Get the message target object for this window, if any FXObject* getTarget() const { return target; } /// Set the message identifier for this window void setSelector(FXSelector sel){ message=sel; } /// Get the message identifier for this window FXSelector getSelector() const { return message; } /// Get this window's x-coordinate, in the parent's coordinate system FXint getX() const { return xpos; } /// Get this window's y-coordinate, in the parent's coordinate system FXint getY() const { return ypos; } /// Return the default width of this window virtual FXint getDefaultWidth(); /// Return the default height of this window virtual FXint getDefaultHeight(); /// Return width for given height virtual FXint getWidthForHeight(FXint givenheight); /// Return height for given width virtual FXint getHeightForWidth(FXint givenwidth); /// Set this window's x-coordinate, in the parent's coordinate system void setX(FXint x); /// Set this window's y-coordinate, in the parent's coordinate system void setY(FXint y); /** * Set the window width; and flag the widget as being in need of * layout by its parent. This does not immediately update the server- * side representation of the widget. */ void setWidth(FXint w); /** * Set the window height; and flag the widget as being in need of * layout by its parent. This does not immediately update the server- * side representation of the widget. */ void setHeight(FXint h); /// Set layout hints for this window void setLayoutHints(FXuint lout); /// Get layout hints for this window FXuint getLayoutHints() const; /// Return a pointer to the accelerator table FXAccelTable* getAccelTable() const { return accelTable; } /// Set the accelerator table void setAccelTable(FXAccelTable* acceltable){ accelTable=acceltable; } /// Add a hot key void addHotKey(FXHotKey code); /// Remove a hot key void remHotKey(FXHotKey code); /// Change help tag for this widget void setHelpTag(const FXString& text){ tag=text; } /// Get the help tag for this widget const FXString& getHelpTag() const { return tag; } /// Return true if window is a shell window FXbool isShell() const; /// Return true if specified window is owned by this window FXbool isOwnerOf(const FXWindow* window) const; /// Return true if specified window is ancestor of this window FXbool isChildOf(const FXWindow* window) const; /// Return true if this window contains child in its subtree FXbool containsChild(const FXWindow* child) const; /// Return the child window at specified coordinates FXWindow* getChildAt(FXint x,FXint y) const; /// Return the number of child windows for this window FXint numChildren() const; /** * Return the index (starting from zero) of the specified child window, * or -1 if the window is not a child or NULL */ FXint indexOfChild(const FXWindow *window) const; /** * Return the child window at specified index, * or NULL if the index is negative or out of range */ FXWindow* childAtIndex(FXint index) const; /// Return the common ancestor of window a and window b static FXWindow* commonAncestor(FXWindow* a,FXWindow* b); /// Return true if sibling a <= sibling b in list static FXbool before(const FXWindow *a,const FXWindow* b); /// Return true if sibling a >= sibling b in list static FXbool after(const FXWindow *a,const FXWindow* b); /// Return compose context FXComposeContext* getComposeContext() const { return composeContext; } /// Create compose context void createComposeContext(); /// Destroy compose context void destroyComposeContext(); /// Is cursor shown FXbool cursorShown() const; /// Show or hide the cursor void showCursor(FXbool flag=true); /// Set the default cursor for this window void setDefaultCursor(FXCursor* cur); /// Return the default cursor for this window FXCursor* getDefaultCursor() const { return defaultCursor; } /// Set the drag cursor for this window void setDragCursor(FXCursor* cur); /// Return the drag cursor for this window FXCursor* getDragCursor() const { return dragCursor; } /// Return the cursor position and mouse button-state FXbool getCursorPosition(FXint& x,FXint& y,FXuint& buttons) const; /// Warp the cursor to the new position FXbool setCursorPosition(FXint x,FXint y); /// Return true if the window is active FXbool isActive() const; /// Return true if this window is a control capable of receiving the focus virtual FXbool canFocus() const; /// Return true if this window has the focus FXbool hasFocus() const; /// Return true if this window is in focus chain FXbool inFocusChain() const; /// Move the focus to this window virtual void setFocus(); /// Remove the focus from this window virtual void killFocus(); /// Return true if this is the default window FXbool isDefault() const; /** * This changes the default window which responds to the Return * key in a dialog. If the flag is true, this window becomes the default * window; when the flag is false, this window will be no longer the * default window. Finally, when the flag is maybe, the default window * will revert to the initial default window. */ virtual void setDefault(FXuchar flag=true); /// Find default window among this window's children FXWindow* findDefault() const; /// Return true if this is the initial default window FXbool isInitial() const; /// Make this window the initial default window void setInitial(FXbool flag=true); /// Find inital default window among this window's children FXWindow* findInitial() const; /// Return true if this window is able to receive mouse and keyboard events FXbool isEnabled() const; /// Enable the window to receive mouse and keyboard events virtual void enable(); /// Disable the window from receiving mouse and keyboard events virtual void disable(); /// Create all of the server-side resources for this window virtual void create(); /// Attach foreign window handle to this window virtual void attach(FXID w); /// Detach the server-side resources for this window virtual void detach(); /// Destroy the server-side resources for this window virtual void destroy(); /// Set window shape by means of region virtual void setShape(const FXRegion& region); /// Set window shape by means of bitmap virtual void setShape(FXBitmap* bitmap); /// Set window shape by means of icon virtual void setShape(FXIcon* icon); /// Clear window shape virtual void clearShape(); /// Raise this window to the top of the stacking order virtual void raise(); /// Lower this window to the bottom of the stacking order virtual void lower(); /** * Move the window immediately, in the parent's coordinate system. * Update the server representation as well if the window is realized. * Perform layout of the children when necessary. */ virtual void move(FXint x,FXint y); /** * Resize the window to the specified width and height immediately, * updating the server representation as well, if the window was realized. * Perform layout of the children when necessary. */ virtual void resize(FXint w,FXint h); /** * Move and resize the window immediately, in the parent's coordinate system. * Update the server representation as well if the window is realized. * Perform layout of the children when necessary. */ virtual void position(FXint x,FXint y,FXint w,FXint h); /// Mark this window's layout as dirty for later layout virtual void recalc(); /// Perform layout immediately virtual void layout(); /// Generate a SEL_UPDATE message for the window and its children void forceRefresh(); /// Reparent this window under new father before other virtual void reparent(FXWindow* father,FXWindow *other=nullptr); /// Scroll rectangle x,y,w,h by a shift of dx,dy void scroll(FXint x,FXint y,FXint w,FXint h,FXint dx,FXint dy) const; /// Mark the specified rectangle to be repainted later void update(FXint x,FXint y,FXint w,FXint h) const; /// Mark the entire window to be repainted later void update() const; /// Process any outstanding repaint messages immediately, for the given rectangle void repaint(FXint x,FXint y,FXint w,FXint h) const; /// Process any outstanding repaint messages immediately void repaint() const; /// Return true if the window has been grabbed FXbool grabbed() const; /** * Grab the mouse to this window; future mouse events will be * reported to this window even while the cursor goes outside of this window */ void grab(); /// Release the mouse grab void ungrab(); /// Return true if active grab is in effect FXbool grabbedKeyboard() const; /// Grab keyboard device void grabKeyboard(); /// Ungrab keyboard device void ungrabKeyboard(); /// Return true if the window is shown FXbool shown() const; /// Show this window virtual void show(); /// Hide this window virtual void hide(); /// Return true if the window is composite virtual FXbool isComposite() const; /// Return true if the window is under the cursor FXbool underCursor() const; /// Return true if this window owns the primary selection FXbool hasSelection() const; /// Try to acquire the primary selection, given a list of drag types FXbool acquireSelection(const FXDragType *types,FXuint numtypes); /// Release the primary selection FXbool releaseSelection(); /// Return true if this window owns the clipboard FXbool hasClipboard() const; /// Try to acquire the clipboard, given a list of drag types FXbool acquireClipboard(const FXDragType *types,FXuint numtypes); /// Release the clipboard FXbool releaseClipboard(); /// Return true if this window is able to receive drops FXbool isDropEnabled() const; /// Enable this window to receive drops virtual void dropEnable(); /// Disable this window from receiving drops virtual void dropDisable(); /// Return true if a drag operaion has been initiated from this window FXbool isDragging() const; /// Initiate a drag operation with a list of previously registered drag types FXbool beginDrag(const FXDragType *types,FXuint numtypes); /** * When dragging, inform the drop-target of the new position and * the drag action */ FXbool handleDrag(FXint x,FXint y,FXDragAction action=DRAG_COPY); /** * Terminate the drag operation with or without actually dropping the data * Returns the action performed by the target */ FXDragAction endDrag(FXbool drop=true); /// Return true if this window is the target of a drop FXbool isDropTarget() const; /** * When being dragged over, indicate that no further SEL_DND_MOTION messages * are required while the cursor is inside the given rectangle */ void setDragRectangle(FXint x,FXint y,FXint w,FXint h,FXbool wantupdates=true) const; /** * When being dragged over, indicate we want to receive SEL_DND_MOTION messages * every time the cursor moves */ void clearDragRectangle() const; /// When being dragged over, indicate acceptance or rejection of the dragged data void acceptDrop(FXDragAction action=DRAG_ACCEPT) const; /// The target accepted our drop FXDragAction didAccept() const; /** * Sent by the drop target in response to SEL_DND_DROP. The drag action * should be the same as the action the drop target reported to the drag * source in reponse to the SEL_DND_MOTION message. * This function notifies the drag source that its part of the drop transaction * is finished, and that it is free to release any resources involved in the * drag operation. * Calling dropFinished() is advisable in cases where the drop target needs * to perform complex processing on the data received from the drag source, * prior to returning from the SEL_DND_DROP message handler. */ void dropFinished(FXDragAction action=DRAG_REJECT) const; /// When being dragged over, inquire the drag types which are being offered FXbool inquireDNDTypes(FXDNDOrigin origin,FXDragType*& types,FXuint& numtypes) const; /// When being dragged over, return true if we are offered the given drag type FXbool offeredDNDType(FXDNDOrigin origin,FXDragType type) const; /// When being dragged over, return the drag action FXDragAction inquireDNDAction() const; /** * Set DND data; the array must be allocated with allocElms() and ownership is * transferred to the system. */ FXbool setDNDData(FXDNDOrigin origin,FXDragType type,FXuchar* data,FXuint size) const; /** * Set DND data from string value. */ FXbool setDNDData(FXDNDOrigin origin,FXDragType type,const FXString& string) const; /** * Get DND data; the caller becomes the owner of the array and must free it * with freeElms(). */ FXbool getDNDData(FXDNDOrigin origin,FXDragType type,FXuchar*& data,FXuint& size) const; /** * Get DND data into string value. */ FXbool getDNDData(FXDNDOrigin origin,FXDragType type,FXString& string) const; /// Return true if window logically contains the given point virtual FXbool contains(FXint parentx,FXint parenty) const; /// Translate coordinates from fromwindow's coordinate space to this window's coordinate space void translateCoordinatesFrom(FXint& tox,FXint& toy,const FXWindow* fromwindow,FXint fromx,FXint fromy) const; /// Translate coordinates from this window's coordinate space to towindow's coordinate space void translateCoordinatesTo(FXint& tox,FXint& toy,const FXWindow* towindow,FXint fromx,FXint fromy) const; /// Set window background color virtual void setBackColor(FXColor clr); /// Get background color FXColor getBackColor() const { return backColor; } /// Does save-unders virtual FXbool doesSaveUnder() const; /** * Translate message for localization; using the current FXTranslator, * an attempt is made to translate the given message into the current * language. An optional hint may be passed to break any ties in case * more than one tranlation is possible for the given message text. * In addition, the name of the widget is passed as context name so * that translations for a single dialog may be grouped together. */ virtual const FXchar* tr(const FXchar* text,const FXchar* hint=nullptr,FXint count=-1) const FX_FORMAT(2) ; /// Save window to stream virtual void save(FXStream& store) const; /// Restore window from stream virtual void load(FXStream& store); /// Destroy window virtual ~FXWindow(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXWizard.h000066400000000000000000000114531455751074500223340ustar00rootroot00000000000000/******************************************************************************** * * * W i z a r d W i d g e t * * * ********************************************************************************* * Copyright (C) 2002,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXWIZARD_H #define FXWIZARD_H #ifndef FXDIALOGBOX_H #include "FXDialogBox.h" #endif namespace FX { class FXImage; class FXIcon; class FXImageFrame; class FXButton; class FXSwitcher; /** * A Wizard widget guides the user through a number of panels * in a predefined sequence; each step must be completed before * moving on to the next step. * For example, a Wizard may be used to install software components, * and ask various questions at each step in the installation. */ class FXAPI FXWizard : public FXDialogBox { FXDECLARE(FXWizard) protected: FXHorizontalFrame *buttons; // Button frame FXImageFrame *sidebar; // Sidebar comprising image FXButton *advance; // Advance to next stage FXButton *retreat; // Retreat to last stage FXButton *finish; // Finish panel FXButton *cancel; // Cancel button FXSwitcher *panels; // Sub panels FXIcon *finishicon; FXIcon *nexticon; FXIcon *backicon; protected: FXWizard(){} void construct(); private: FXWizard(const FXWizard&); FXWizard &operator=(const FXWizard&); public: long onUpdFinish(FXObject*,FXSelector,void*); long onCmdNext(FXObject*,FXSelector,void*); long onUpdNext(FXObject*,FXSelector,void*); long onCmdBack(FXObject*,FXSelector,void*); long onUpdBack(FXObject*,FXSelector,void*); public: enum { ID_NEXT=FXDialogBox::ID_LAST, ID_BACK, ID_LAST }; public: /// Construct free-floating Wizard FXWizard(FXApp* a,const FXString& name,FXImage *image,FXuint opts=DECOR_TITLE|DECOR_BORDER|DECOR_RESIZE,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=10,FXint pr=10,FXint pt=10,FXint pb=10,FXint hs=10,FXint vs=10); /// Construct Wizard which will always float over the owner window FXWizard(FXWindow* owner,const FXString& name,FXImage *image,FXuint opts=DECOR_TITLE|DECOR_BORDER|DECOR_RESIZE,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=10,FXint pr=10,FXint pt=10,FXint pb=10,FXint hs=10,FXint vs=10); /// Return a pointer to the button frame FXHorizontalFrame *buttonFrame() const { return buttons; } /// Return a pointer to the "Advance" button FXButton *advanceButton() const { return advance; } /// Return a pointer to the "Retreat" button FXButton *retreatButton() const { return retreat; } /// Return a pointer to the "Finish" button FXButton *finishButton() const { return finish; } /// Return a pointer to the "Cancel" button FXButton *cancelButton() const { return cancel; } /// Return the container used as parent for the subpanels FXSwitcher *getContainer() const { return panels; } /// Change the image being displayed void setImage(FXImage* img); /// Return the current image FXImage* getImage() const; /// Return number of panels FXint getNumPanels() const; /// Bring the child window at index to the top void setCurrentPanel(FXint index); /// Return the index of the child window currently on top FXint getCurrentPanel() const; /// Save to stream virtual void save(FXStream& store) const; /// Load from stream virtual void load(FXStream& store); // Destroy virtual ~FXWizard(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXWorker.h000066400000000000000000000053511455751074500223450ustar00rootroot00000000000000/******************************************************************************** * * * W o r k e r T h r e a d * * * ********************************************************************************* * Copyright (C) 2006,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXWORKER_H #define FXWORKER_H #ifndef FXTHREAD_H #include "FXThread.h" #endif namespace FX { /** * An FXWorker is a transient thread that performs an FXRunnable task. * After the worker thread finishes the execution of the task, the worker thread's * memory is automatically reclaimed. * The FXRunnable itself is not deleted; it will thus outlive the worker that runs it. * Any exceptions raised by the task are caught by the worker thread, and will * be rethrown after the worker thread's memory has been reclaimed. */ class FXAPI FXWorker : public FXThread { private: FXRunnable *runnable; private: FXWorker(const FXWorker&); FXWorker &operator=(const FXWorker&); public: /// Create worker for runnable FXWorker(FXRunnable* task=nullptr); /// Change runnable if not started yet void setRunnable(FXRunnable* task){ runnable=task; } /// Return runnable FXRunnable* getRunnable() const { return runnable; } /// Run worker virtual FXint run(); /// Create and start a worker on a given runnable. static FXWorker* execute(FXRunnable* task,FXuval stacksize=0); /// Destroy virtual ~FXWorker(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXXBMIcon.h000066400000000000000000000073411455751074500223340ustar00rootroot00000000000000/******************************************************************************** * * * X B M I c o n O b j e c t * * * ********************************************************************************* * Copyright (C) 2003,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXXBMICON_H #define FXXBMICON_H #ifndef FXICON_H #include "FXIcon.h" #endif namespace FX { /// X Bitmap icon class FXAPI FXXBMIcon : public FXIcon { FXDECLARE(FXXBMIcon) protected: FXXBMIcon(){} private: FXXBMIcon(const FXXBMIcon&); FXXBMIcon &operator=(const FXXBMIcon&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct icon from memory stream formatted in X Bitmap format FXXBMIcon(FXApp* a,const FXuchar *pixels=nullptr,const FXuchar *mask=nullptr,FXColor clr=FXRGB(192,192,192),FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in X Bitmap format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in X Bitmap format virtual FXbool loadPixels(FXStream& store); /// Destroy icon virtual ~FXXBMIcon(); }; #ifndef FXLOADXBM #define FXLOADXBM /** * Check if stream contains a XBM, return true if so. */ extern FXAPI FXbool fxcheckXBM(FXStream& store); /** * Load an XBM (X Bitmap) from pixel array and mask array. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadXBM(FXColor*& data,const FXuchar *pix,const FXuchar *msk,FXint width,FXint height); /** * Load an XBM (X Bitmap) file from a stream. * Upon successful return, the pixel array and size, and hot-spot are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadXBM(FXStream& store,FXColor*& data,FXint& width,FXint& height,FXint& hotx,FXint& hoty); /** * Save an XBM (X Bitmap) file to a stream; if the parameters hotx and hoty are set * to -1, no hotspot location is saved. */ extern FXAPI FXbool fxsaveXBM(FXStream& store,const FXColor *data,FXint width,FXint height,FXint hotx=-1,FXint hoty=-1); /** * Save a PostScript file to a stream; format the picture to the maximal * size that fits within the given margins of the indicated paper size. */ extern FXAPI FXbool fxsavePS(FXStream& store,const FXColor *data,FXint width,FXint height,FXint paperw=612,FXint paperh=792,FXint margin=35,FXbool color=true); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXXBMImage.h000066400000000000000000000073221455751074500224650ustar00rootroot00000000000000/******************************************************************************** * * * X B M I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 2003,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXXBMIMAGE_H #define FXXBMIMAGE_H #ifndef FXIMAGE_H #include "FXImage.h" #endif namespace FX { /// X Bitmap image class FXAPI FXXBMImage : public FXImage { FXDECLARE(FXXBMImage) protected: FXXBMImage(){} private: FXXBMImage(const FXXBMImage&); FXXBMImage &operator=(const FXXBMImage&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct image from memory stream formatted in X Bitmap format FXXBMImage(FXApp* a,const FXuchar *pixels=nullptr,const FXuchar *mask=nullptr,FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in X Bitmap format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in X Bitmap format virtual FXbool loadPixels(FXStream& store); /// Destroy icon virtual ~FXXBMImage(); }; #ifndef FXLOADXBM #define FXLOADXBM /** * Check if stream contains a XBM, return true if so. */ extern FXAPI FXbool fxcheckXBM(FXStream& store); /** * Load an XBM (X Bitmap) from pixel array and mask array. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadXBM(FXColor*& data,const FXuchar *pix,const FXuchar *msk,FXint width,FXint height); /** * Load an XBM (X Bitmap) file from a stream. * Upon successful return, the pixel array and size, and hot-spot are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadXBM(FXStream& store,FXColor*& data,FXint& width,FXint& height,FXint& hotx,FXint& hoty); /** * Save an XBM (X Bitmap) file to a stream; if the parameters hotx and hoty are set * to -1, no hotspot location is saved. */ extern FXAPI FXbool fxsaveXBM(FXStream& store,const FXColor *data,FXint width,FXint height,FXint hotx=-1,FXint hoty=-1); /** * Save a PostScript file to a stream; format the picture to the maximal * size that fits within the given margins of the indicated paper size. */ extern FXAPI FXbool fxsavePS(FXStream& store,const FXColor *data,FXint width,FXint height,FXint paperw=612,FXint paperh=792,FXint margin=35,FXbool color=true); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXXML.h000066400000000000000000000153551455751074500215410ustar00rootroot00000000000000/******************************************************************************** * * * X M L R e a d e r & W r i t e r * * * ********************************************************************************* * Copyright (C) 2016,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXXML_H #define FXXML_H #ifndef FXPARSEBUFFER_H #include "FXParseBuffer.h" #endif namespace FX { /** * The XML serializer loads or saves data to xml text file. */ class FXAPI FXXML : public FXParseBuffer { public: enum Error { ErrOK, /// No errors ErrEmpty, /// No data loaded ErrSave, /// Unable to save ErrLoad, /// Unable to load ErrSpace, /// Expected space ErrEquals, /// Expected equals sign '=' ErrName, /// Expected name ErrString, /// Expected string ErrToken, /// Illegal token ErrDigit, /// Expected digit ErrHexDigit, /// Expected hex digit ErrSemiColon, /// Expected semicolon ErrReference, /// Unknown reference ErrNoMatch, /// Start and end tag not matching ErrEof /// Unexpected end of file }; enum { CRLF = 0x0001, /// CRLF, LFCR, CR, LF map to LF REFS = 0x0002, /// Character references processed }; enum { UTF8 = 1, /// UTF8 encoded UTF16LE = 2, /// Little endian UTF16 encoded UTF16BE = 3, /// Big endian UTF16 encoded UTF32LE = 4, /// Little endian UTF32 encoded UTF32BE = 5 /// Big endian UTF32 encoded }; protected: class Element; // Element info protected: FXlong offset; // Position from start Element *current; // Current element instance FXint column; // Column number FXint line; // Line number FXString vers; // Version FXuint enc; // Encoding private: FXuint guess(); void spaces(); FXbool name(); FXbool match(FXchar ch); FXbool match(const FXchar* str,FXint len); Error parsestring(FXString& str); Error parsexml(); Error parseversion(); Error parseencoding(); Error parsestandalone(); Error parseelementdecl(); Error parseexternalid(); Error parseinternalsubset(); Error parsedeclarations(); Error parseprocessing(); Error parsecomment(); Error parseattribute(Element& elm); Error parsestarttag(Element& elm); Error parseendtag(Element& elm); Error parsecdata(Element& elm); Error parsecontents(Element& elm); Error parseelement(); private: static const FXchar *const errors[]; private: FXXML(const FXXML&); FXXML& operator=(const FXXML&); public: /// Called when start of document is recognized. FXCallback startDocumentCB; /// Called when start of element is recognized. FXCallback startElementCB; /// Called to pass batch of decoded characters. FXCallback charactersCB; /// Called to pass comment string. FXCallback commentCB; /// Called to pass processing instruction. FXCallback processingCB; /// Called when end of element is recognized. FXCallback endElementCB; /// Called when end of document is recognized. FXCallback endDocumentCB; public: /** * Construct XML serializer. */ FXXML(); /** * Construct XML serializer and open for direction d. * Use given buffer data of size sz, or allocate a local buffer. */ FXXML(FXchar* buffer,FXuval sz=4096,Direction d=Load); /** * Open XML stream for given direction d. * Use given buffer data of size sz, or allocate a local buffer. */ FXbool open(FXchar* buffer=nullptr,FXuval sz=4096,Direction d=Load); /** * Return size of parse buffer. */ FXuval size() const { return endptr-begptr; } /** * Return direction in effect. */ Direction direction() const { return dir; } /** * Return current line number. */ FXint getLine() const { return line; } /** * Return current column number. */ FXint getColumn() const { return column; } /** * Return offset from begin of file. */ FXlong getOffset() const { return offset; } /** * Parse the file, return error code to indicate success or * failure. */ Error parse(); /// Document start Error startDocument(); /// Element start w/no attributes Error startElement(const FXString& tag); /// Element start w/attributes Error startElement(const FXString& tag,const FXStringDictionary& atts); /// Characters Error characters(const FXString& text); /// Comment Error comment(const FXString& text); /// Processing instruction Error processing(const FXString& target,const FXString& text); /// Element end Error endElement(const FXString& tag); /// Document end Error endDocument(); /// Returns error code for given error static const FXchar* getError(Error err){ return errors[err]; } /** * Close stream and delete buffer, if owned. */ FXbool close(); /** * Decode escaped special characters from XML stream. */ static FXbool decode(FXString& dst,const FXString& src,FXuint flags=CRLF|REFS); /** * Encode special characters for inclusion into XML stream. */ static FXbool encode(FXString& dst,const FXString& src,FXuint flags=CRLF|REFS); /** * Close XML stream and clean up. */ virtual ~FXXML(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXXMLFile.h000066400000000000000000000051151455751074500223320ustar00rootroot00000000000000/******************************************************************************** * * * X M L - F i l e I / O * * * ********************************************************************************* * Copyright (C) 2016,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXXMLFILE_H #define FXXMLFILE_H #ifndef FXXML_H #include "FXXML.h" #endif namespace FX { /** * procesing XML file */ class FXAPI FXXMLFile : public FXXML { private: FXFile file; private: FXXMLFile(const FXXMLFile&); FXXMLFile& operator=(const FXXMLFile&); public: /** * Create XML file i/o object. */ FXXMLFile(); /** * Create XML file i/o object and open it. */ FXXMLFile(const FXString& filename,Direction d=Load,FXuval sz=4096); /** * Open XML file for direction d. */ FXbool open(const FXString& filename,Direction d=Load,FXuval sz=4096); /** * Read at least count bytes into buffer; return bytes available, or -1 for error. */ virtual FXival fill(FXival count); /** * Write at least count bytes from buffer; return space available, or -1 for error. */ virtual FXival flush(FXival count); /** * Close XML file and delete buffers. */ FXbool close(); /** * Close XML file. */ virtual ~FXXMLFile(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXXMLString.h000066400000000000000000000056711455751074500227300ustar00rootroot00000000000000/******************************************************************************** * * * X M L S t r i n g I / O * * * ********************************************************************************* * Copyright (C) 2016,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXXMLSTRING_H #define FXXMLSTRING_H #ifndef FXXML_H #include "FXXML.h" #endif namespace FX { /** * Serialize a variant to or from XML formatted string. */ class FXAPI FXXMLString : public FXXML { private: FXString buffer; private: FXXMLString(const FXXMLString&); FXXMLString &operator=(const FXXMLString&); public: /** * Create XML string i/o object. */ FXXMLString(); /** * Open XML string for direction d. */ FXXMLString(const FXString& string,Direction d=Load); /** * Create XML i/o object and open it. */ FXXMLString(const FXchar* string,FXuval length,Direction d=Load); /** * Open XML file for direction d. */ FXbool open(const FXString& string,Direction d=Load); /** * Open XML character string of length for direction d. */ FXbool open(const FXchar* string,FXuval length,Direction d=Load); /** * Return string. */ const FXString text() const { return buffer; } /** * Read at least count bytes into buffer; return bytes available, or -1 for error. */ virtual FXival fill(FXival count); /** * Write at least count bytes from buffer; return space available, or -1 for error. */ virtual FXival flush(FXival count); /** * Close XML file and delete buffers. */ virtual FXbool close(); /** * Close XML string. */ virtual ~FXXMLString(); }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXXPMIcon.h000066400000000000000000000063421455751074500223520ustar00rootroot00000000000000/******************************************************************************** * * * X P M I c o n O b j e c t * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXXPMICON_H #define FXXPMICON_H #ifndef FXICON_H #include "FXIcon.h" #endif namespace FX { /// X Pixmap icon class FXAPI FXXPMIcon : public FXIcon { FXDECLARE(FXXPMIcon) protected: FXXPMIcon(){} private: FXXPMIcon(const FXXPMIcon&); FXXPMIcon &operator=(const FXXPMIcon&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct icon from compiled-in X Pixmap format FXXPMIcon(FXApp* a,const FXchar **pix=nullptr,FXColor clr=FXRGB(192,192,192),FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in X Pixmap format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in X Pixmap format virtual FXbool loadPixels(FXStream& store); /// Destroy icon virtual ~FXXPMIcon(); }; #ifndef FXLOADXPM #define FXLOADXPM /** * Check if stream contains a XPM, return true if so. */ extern FXAPI FXbool fxcheckXPM(FXStream& store); /** * Load an XPM (X Pixmap) from array of strings. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadXPM(const FXchar **pix,FXColor*& data,FXint& width,FXint& height); /** * Load an XPM (X Pixmap) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadXPM(FXStream& store,FXColor*& data,FXint& width,FXint& height); /** * Save an XPM (X Pixmap) file to a stream. */ extern FXAPI FXbool fxsaveXPM(FXStream& store,const FXColor *data,FXint width,FXint height,FXbool fast=true); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXXPMImage.h000066400000000000000000000063231455751074500225030ustar00rootroot00000000000000/******************************************************************************** * * * X P M I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXXPMIMAGE_H #define FXXPMIMAGE_H #ifndef FXIMAGE_H #include "FXImage.h" #endif namespace FX { /// X Pixmap image class FXAPI FXXPMImage : public FXImage { FXDECLARE(FXXPMImage) protected: FXXPMImage(){} private: FXXPMImage(const FXXPMImage&); FXXPMImage &operator=(const FXXPMImage&); public: static const FXchar fileExt[]; static const FXchar mimeType[]; public: /// Construct image from compiled-in X Pixmap format FXXPMImage(FXApp* a,const FXchar **pix=nullptr,FXuint opts=0,FXint w=1,FXint h=1); /// Save pixels into stream in X Pixmap format virtual FXbool savePixels(FXStream& store) const; /// Load pixels from stream in X Pixmap format virtual FXbool loadPixels(FXStream& store); /// Destroy icon virtual ~FXXPMImage(); }; #ifndef FXLOADXPM #define FXLOADXPM /** * Check if stream contains a XPM, return true if so. */ extern FXAPI FXbool fxcheckXPM(FXStream& store); /** * Load an XPM (X Pixmap) from array of strings. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadXPM(const FXchar **pix,FXColor*& data,FXint& width,FXint& height); /** * Load an XPM (X Pixmap) file from a stream. * Upon successful return, the pixel array and size are returned. * If an error occurred, the pixel array is set to NULL. */ extern FXAPI FXbool fxloadXPM(FXStream& store,FXColor*& data,FXint& width,FXint& height); /** * Save an XPM (X Pixmap) file to a stream. */ extern FXAPI FXbool fxsaveXPM(FXStream& store,const FXColor *data,FXint width,FXint height,FXbool fast=true); #endif } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/FXhalf.h000066400000000000000000000073141455751074500220070ustar00rootroot00000000000000/******************************************************************************** * * * H a l f - F l o a t S u p p o r t * * * ********************************************************************************* * Copyright (C) 2008,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXHALF_H #define FXHALF_H // Some important numbers #define HALF_MIN 5.9604644775391E-08 // Smallest half number #define HALF_MAX 65504.0 // Largest half number #define HALF_EPSILON 0.00097656 // Smallest number where (1+e) != 1 namespace FX { /// Half float (16-bit float) class FXAPI FXhalf { private: FXushort v; private: static const FXushort fhb[512]; static const FXuchar fhs[512]; static const FXuint hfm[2048]; static const FXuint hfe[64]; static const FXushort hfw[64]; public: FXhalf(){} // Initialize half with half FXhalf(const FXhalf& h):v(h.v){} // Initialize half with float FXhalf(FXfloat f){ union { FXfloat f; FXuint u; } r={f}; v=fhb[(r.u>>23)&0x1ff]+((r.u&0x007fffff)>>fhs[(r.u>>23)&0x1ff]); } // Convert half to float operator FXfloat() const { union { FXuint u; FXfloat f; } r={hfm[hfw[v>>10]+(v&0x3ff)]+hfe[v>>10]}; return r.f; } // Test for zero FXbool operator!() const { return v==0; } // Unary FXhalf operator+() const { return *this; } FXhalf operator-() const { FXhalf h; h.v=v^0x8000; return h; } // Equality FXbool operator==(FXhalf h) const { return v==h.v; } FXbool operator!=(FXhalf h) const { return v!=h.v; } // Assignment FXhalf& operator=(FXhalf h){ v=h.v; return *this; } FXhalf& operator=(FXfloat f){ *this=FXhalf(f); return *this; } // Assignment operators FXhalf& operator+=(FXhalf h){ *this=FXhalf(FXfloat(*this)+FXfloat(h)); return *this; } FXhalf& operator+=(FXfloat f){ *this=FXhalf(FXfloat(*this)+f); return *this; } FXhalf& operator-=(FXhalf h){ *this=FXhalf(FXfloat(*this)-FXfloat(h)); return *this; } FXhalf& operator-=(FXfloat f){ *this=FXhalf(FXfloat(*this)-f); return *this; } FXhalf& operator*=(FXhalf h){ *this=FXhalf(FXfloat(*this)*FXfloat(h)); return *this; } FXhalf& operator*=(FXfloat f){ *this=FXhalf(FXfloat(*this)*f); return *this; } FXhalf& operator/=(FXhalf h){ *this=FXhalf(FXfloat(*this)/FXfloat(h)); return *this; } FXhalf& operator/=(FXfloat f){ *this=FXhalf(FXfloat(*this)/f); return *this; } }; } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/fx.h000066400000000000000000000212101455751074500212430ustar00rootroot00000000000000/******************************************************************************** * * * M a i n F O X I n c l u d e F i l e * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * ********************************************************************************/ #ifndef FX_H #define FX_H // Basic includes #include #include #include #include #include // Intrinsics #if defined(WIN32) #if (_MSC_VER >= 1400) // VC++ 2005 or newer #if defined(_M_IX86) || defined(_M_X64) #include #endif #endif #else #if defined(__GNUC__) || defined(__INTEL_COMPILER) #if defined(__i386__) || defined(__x86_64__) #include #endif #endif #endif // FOX defines #include "fxver.h" #include "fxdefs.h" #include "fxchar.h" #include "fxkeys.h" #include "fxmath.h" #include "fxendian.h" #include "fxascii.h" #include "fxunicode.h" #include "fxcpuid.h" // FOX classes #include "FXhalf.h" #include "FXException.h" #include "FXAtomic.h" #include "FXRefPtr.h" #include "FXElement.h" #include "FXArray.h" #include "FXHash.h" #include "FXHashOf.h" #include "FXCallback.h" #include "FXRandom.h" #include "FXMutex.h" #include "FXCondition.h" #include "FXBarrier.h" #include "FXSpinLock.h" #include "FXSemaphore.h" #include "FXCompletion.h" #include "FXReadWriteLock.h" #include "FXAutoThreadStorageKey.h" #include "FXRunnable.h" #include "FXThread.h" #include "FXScopedThread.h" #include "FXStream.h" #include "FXAutoPtr.h" #include "FXPtrList.h" #include "FXPtrQueue.h" #include "FXIO.h" #include "FXIOBuffer.h" #include "FXIODevice.h" #include "FXFile.h" #include "FXPipe.h" #include "FXSocket.h" #include "FXMappedFile.h" #include "FXFileStream.h" #include "FXMemoryStream.h" #include "FXProcess.h" #include "FXString.h" #include "FXVariant.h" #include "FXVariantArray.h" #include "FXVariantMap.h" #include "FXDictionary.h" #include "FXDictionaryOf.h" #include "FXReverseDictionary.h" #include "FXReverseDictionaryOf.h" #include "FXDLL.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXColors.h" #include "FXObject.h" #include "FXDelegator.h" #include "FXPath.h" #include "FXSystem.h" #include "FXStat.h" #include "FXDir.h" #include "FXDirVisitor.h" #include "FXDate.h" #include "FXURL.h" #include "FXStringDictionary.h" #include "FXParseBuffer.h" #include "FXJSON.h" #include "FXJSONFile.h" #include "FXJSONString.h" #include "FXINI.h" #include "FXINIFile.h" #include "FXXML.h" #include "FXXMLFile.h" #include "FXXMLString.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXObjectList.h" #include "FXAccelTable.h" #include "FXRecentFiles.h" #include "FXWorker.h" #include "FXSemaQueue.h" #include "FXLFQueue.h" #include "FXThreadPool.h" #include "FXCompletion.h" #include "FXTaskGroup.h" #include "FXParallel.h" #include "FXFont.h" #include "FXCursor.h" #include "FXVisual.h" #include "FXEvent.h" #include "FXId.h" #include "FXReactor.h" #include "FXDispatcher.h" #include "FXEventDispatcher.h" #include "FXDrawable.h" #include "FXBitmap.h" #include "FXImage.h" #include "FXIcon.h" #include "FXWindow.h" #include "FXApp.h" #include "FXMessageChannel.h" #include "FXCURCursor.h" #include "FXGIFCursor.h" #include "FXBMPImage.h" #include "FXGIFImage.h" #include "FXICOImage.h" #include "FXIFFImage.h" #include "FXJPGImage.h" #include "FXPCXImage.h" #include "FXPNGImage.h" #include "FXPPMImage.h" #include "FXRASImage.h" #include "FXRGBImage.h" #include "FXTGAImage.h" #include "FXTIFImage.h" #include "FXXBMImage.h" #include "FXXPMImage.h" #include "FXDDSImage.h" #include "FXJP2Image.h" #include "FXWEBPImage.h" #include "FXEXEImage.h" #include "FXBMPIcon.h" #include "FXGIFIcon.h" #include "FXICOIcon.h" #include "FXIFFIcon.h" #include "FXJPGIcon.h" #include "FXPCXIcon.h" #include "FXPNGIcon.h" #include "FXPPMIcon.h" #include "FXRASIcon.h" #include "FXRGBIcon.h" #include "FXTGAIcon.h" #include "FXTIFIcon.h" #include "FXXBMIcon.h" #include "FXXPMIcon.h" #include "FXDDSIcon.h" #include "FXJP2Icon.h" #include "FXWEBPIcon.h" #include "FXEXEIcon.h" #include "FXRegion.h" #include "FXDC.h" #include "FXDCWindow.h" #include "FXDCPrint.h" #include "FXIconSource.h" #include "FXIconCache.h" #include "FXFileAssociations.h" #include "FXFrame.h" #include "FXSeparator.h" #include "FXLabel.h" #include "FX7Segment.h" #include "FXDial.h" #include "FXKnob.h" #include "FXGauge.h" #include "FXColorBar.h" #include "FXColorRing.h" #include "FXColorWell.h" #include "FXColorWheel.h" #include "FXTextField.h" #include "FXButton.h" #include "FXPicker.h" #include "FXToggleButton.h" #include "FXTriStateButton.h" #include "FXCheckButton.h" #include "FXRadioButton.h" #include "FXArrowButton.h" #include "FXMenuButton.h" #include "FXComposite.h" #include "FXPacker.h" #include "FXHorizontalFrame.h" #include "FXVerticalFrame.h" #include "FXSpring.h" #include "FXMatrix.h" #include "FXSpinner.h" #include "FXRealSpinner.h" #include "FXRootWindow.h" #include "FXCanvas.h" #include "FXGroupBox.h" #include "FXShell.h" #include "FXToolTip.h" #include "FXPopup.h" #include "FXTopWindow.h" #include "FXDialogBox.h" #include "FXMainWindow.h" #include "FXMenuPane.h" #include "FXScrollPane.h" #include "FXMenuCaption.h" #include "FXMenuSeparator.h" #include "FXMenuTitle.h" #include "FXMenuCascade.h" #include "FXMenuCommand.h" #include "FXMenuCheck.h" #include "FXMenuRadio.h" #include "FXMenuBar.h" #include "FXOptionMenu.h" #include "FXSwitcher.h" #include "FXTabBar.h" #include "FXTabBook.h" #include "FXTabItem.h" #include "FXScrollBar.h" #include "FXScrollArea.h" #include "FXScrollWindow.h" #include "FXList.h" #include "FXComboBox.h" #include "FXListBox.h" #include "FXTreeList.h" #include "FXTreeListBox.h" #include "FXFoldingList.h" #include "FXBitmapView.h" #include "FXBitmapFrame.h" #include "FXImageView.h" #include "FXImageFrame.h" #include "FXHeader.h" #include "FXTable.h" #include "FXDragCorner.h" #include "FXStatusBar.h" #include "FXStatusLine.h" #include "FXChoiceBox.h" #include "FXMessageBox.h" #include "FXDirList.h" #include "FXSlider.h" #include "FXRealSlider.h" #include "FXRangeSlider.h" #include "FXSplitter.h" #include "FX4Splitter.h" #include "FXShutter.h" #include "FXIconList.h" #include "FXFileList.h" #include "FXDirBox.h" #include "FXDriveBox.h" #include "FXDirSelector.h" #include "FXDirDialog.h" #include "FXFileSelector.h" #include "FXFileDialog.h" #include "FXColorSelector.h" #include "FXColorDialog.h" #include "FXFontSelector.h" #include "FXFontDialog.h" #include "FXUndoList.h" #include "FXRex.h" #include "FXExpression.h" #include "FXText.h" #include "FXDataTarget.h" #include "FXProgressBar.h" #include "FXReplaceDialog.h" #include "FXRuler.h" #include "FXRulerView.h" #include "FXSearchDialog.h" #include "FXInputDialog.h" #include "FXProgressDialog.h" #include "FXWizard.h" #include "FXMDIButton.h" #include "FXMDIClient.h" #include "FXMDIChild.h" #include "FXDocument.h" #include "FXDockSite.h" #include "FXDockBar.h" #include "FXToolBar.h" #include "FXDockHandler.h" #include "FXDockTitle.h" #include "FXToolBarGrip.h" #include "FXToolBarShell.h" #include "FXToolBarTab.h" #include "FXPrintDialog.h" #include "FXDebugTarget.h" #include "FXCalendarView.h" #include "FXCalendar.h" #include "FXGradientBar.h" #include "FXConsole.h" #include "FXDirWatch.h" #include "FXSplashWindow.h" #ifndef FX_NO_GLOBAL_NAMESPACE using namespace FX; #endif #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/fx3d.h000066400000000000000000000051631455751074500215030ustar00rootroot00000000000000/******************************************************************************** * * * A d d i t i o n a l F O X I n c l u d e F i l e F o r 3 D * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FX3D_H #define FX3D_H // OpenGL includes #ifdef WIN32 #ifndef STRICT #define STRICT #endif #include #undef max #undef min #endif #ifdef HAVE_GL_H #ifndef GL_GLEXT_PROTOTYPES #define GL_GLEXT_PROTOTYPES 1 #endif #include #endif #ifndef GLAPIENTRY #define GLAPIENTRY #endif #ifndef GLAPI #define GLAPI #endif // Additional FOX includes #include "FXVec2f.h" #include "FXVec2d.h" #include "FXVec3f.h" #include "FXVec3d.h" #include "FXVec4f.h" #include "FXVec4d.h" #include "FXQuatf.h" #include "FXQuatd.h" #include "FXMat2f.h" #include "FXMat2d.h" #include "FXMat3f.h" #include "FXMat3d.h" #include "FXMat4f.h" #include "FXMat4d.h" #include "FXRangef.h" #include "FXRanged.h" #include "FXSpheref.h" #include "FXSphered.h" #include "FXExtentf.h" #include "FXExtentd.h" #include "FXComplexf.h" #include "FXComplexd.h" #include "FXGLVisual.h" #include "FXGLContext.h" #include "FXGLCanvas.h" #include "FXGLViewer.h" #include "FXGLObject.h" #ifndef FX_NO_GLOBAL_NAMESPACE using namespace FX; #endif #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/fxascii.h000066400000000000000000000112551455751074500222640ustar00rootroot00000000000000/******************************************************************************** * * * A S C I I C h a r a c t e r I n f o * * * ********************************************************************************* * Copyright (C) 2005,2023 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXASCII_H #define FXASCII_H /******** Generated on 2023/06/11 16:58:10 by ascii tool version 3.1.0 *********/ namespace FX { namespace Ascii { // Ascii table extern FXAPI const FXushort ascii_data[256]; // Value to ascii digit table extern FXAPI const FXchar value_to_digit[256]; // Ascii digit to valuetable extern FXAPI const FXschar digit_to_value[256]; // Numeric value of ascii digit static inline FXint digitValue(FXchar asc){ return digit_to_value[(FXuchar)asc]; } // Ascii digit of numeric value static inline FXint valueDigit(FXuchar asc){ return value_to_digit[(FXuchar)asc]; } // Has upper or lower case variant static inline FXbool hasCase(FXchar asc){ return (ascii_data[(FXuchar)asc]&0x4000)!=0; } // Is upper case static inline FXbool isUpper(FXchar asc){ return (ascii_data[(FXuchar)asc]&0x200)!=0; } // Is lower case static inline FXbool isLower(FXchar asc){ return (ascii_data[(FXuchar)asc]&0x20)!=0; } // Is title case static inline FXbool isTitle(FXchar asc){ return (ascii_data[(FXuchar)asc]&0x200)!=0; } // Is us-ascii static inline FXbool isAscii(FXchar asc){ return ((FXuchar)asc)<128; } // Is letter static inline FXbool isLetter(FXchar asc){ return (ascii_data[(FXuchar)asc]&0x2)!=0; } // Is decimal digit static inline FXbool isDigit(FXchar asc){ return (ascii_data[(FXuchar)asc]&0x8)!=0; } // Is letter or digit static inline FXbool isAlphaNumeric(FXchar asc){ return (ascii_data[(FXuchar)asc]&0x1)!=0; } // Is control character static inline FXbool isControl(FXchar asc){ return (ascii_data[(FXuchar)asc]&0x4)!=0; } // Is space static inline FXbool isSpace(FXchar asc){ return (ascii_data[(FXuchar)asc]&0x100)!=0; } // Is blank static inline FXbool isBlank(FXchar asc){ return (ascii_data[(FXuchar)asc]&0x800)!=0; } // Is punctuation character static inline FXbool isPunct(FXchar asc){ return (ascii_data[(FXuchar)asc]&0x80)!=0; } // Is graphic character static inline FXbool isGraph(FXchar asc){ return (ascii_data[(FXuchar)asc]&0x10)!=0; } // Is printing character static inline FXbool isPrint(FXchar asc){ return (ascii_data[(FXuchar)asc]&0x40)!=0; } // Is hexadecimal digit static inline FXbool isHexDigit(FXchar asc){ return (ascii_data[(FXuchar)asc]&0x400)!=0; } // Is octal digit static inline FXbool isOctDigit(FXchar asc){ return (asc&0xF8)==0x30; } // Is binary digit static inline FXbool isBinDigit(FXchar asc){ return (asc&0xFE)==0x30; } // Is word character static inline FXbool isWord(FXchar asc){ return (ascii_data[(FXuchar)asc]&0x1000)!=0; } // Is delimiter character static inline FXbool isDelim(FXchar asc){ return (ascii_data[(FXuchar)asc]&0x2000)!=0; } // Convert to upper case static inline FXchar toUpper(FXchar asc){ return ((FXuchar)(asc-'a'))<26 ? asc+'A'-'a' : asc; } // Convert to lower case static inline FXchar toLower(FXchar asc){ return ((FXuchar)(asc-'A'))<26 ? asc+'a'-'A' : asc; } // Convert to title case static inline FXchar toTitle(FXchar asc){ return ((FXuchar)(asc-'a'))<26 ? asc+'A'-'a' : asc; } } } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/fxchar.h000066400000000000000000000266151455751074500221170ustar00rootroot00000000000000/******************************************************************************** * * * U n i c o d e C h a r a c t e r E n c o d i n g S u p p o r t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCHAR_H #define FXCHAR_H namespace FX { /*************************** UTF8 Support Functions **************************/ /// Test if character c is at the start of a UTF8 sequence static inline FXbool isUTF8(FXchar c){ return (c&0xC0)!=0x80; } /// Check if c is leader of a UTF8 multi-byte sequence static inline FXbool leadUTF8(FXchar c){ return (c&0xC0)==0xC0; } /// Check if c is follower of a UTF8 multi-byte sequence static inline FXbool followUTF8(FXchar c){ return (c&0xC0)==0x80; } /// Check if c is part of multi-byte UTF8 sequence static inline FXbool seqUTF8(FXchar c){ return (c&0x80)==0x80; } /// Length of UTF8 character, in bytes static inline FXival lenUTF8(FXchar c){ return ((0xE5000000>>((c>>3)&0x1E))&3)+1; } /// Length of UTF8 character, in bytes static inline FXival wclen(const FXchar *ptr){ return lenUTF8(*ptr); } /// Return wide character from UTF8 string static inline FXwchar wc(const FXchar* ptr){ FXwchar w=(FXuchar)ptr[0]; if(0xC0<=w){ w = (w<<6) ^ (FXuchar)ptr[1] ^ 0x3080; if(0x800<=w){ w = (w<<6) ^ (FXuchar)ptr[2] ^ 0x20080; if(0x10000<=w){ w = (w<<6) ^ (FXuchar)ptr[3] ^ 0x400080; }}} return w; } /// Return wide character from 1-byte UTF8 string static inline FXwchar wc1(const FXchar* ptr){ return (FXuchar)ptr[0]; } /// Return wide character from 2-byte UTF8 string static inline FXwchar wc2(const FXchar* ptr){ return ((FXuchar)ptr[0]<<6)^((FXuchar)ptr[1])^0x3080; } /// Return wide character from 3-byte UTF8 string static inline FXwchar wc3(const FXchar* ptr){ return ((FXuchar)ptr[0]<<12)^((FXuchar)ptr[1]<<6)^((FXuchar)ptr[2])^0x0E2080; } /// Return wide character from 4-byte UTF8 string static inline FXwchar wc4(const FXchar* ptr){ return ((FXuchar)ptr[0]<<18)^((FXuchar)ptr[1]<<12)^((FXuchar)ptr[2]<<6)^((FXuchar)ptr[3])^0x3C82080; } /// Return wide character from UTF8 string, and go to next wide character static inline FXwchar wcnxt(const FXchar*& ptr){ FXwchar w=(FXuchar)*ptr++; if(0xC0<=w){ w = (w<<6) ^ (FXuchar)*ptr++ ^ 0x3080; if(0x800<=w){ w = (w<<6) ^ (FXuchar)*ptr++ ^ 0x20080; if(0x10000<=w){ w = (w<<6) ^ (FXuchar)*ptr++ ^ 0x400080; }}} return w; } /// Return wide character from UTF8 string, and go to next wide character static inline FXwchar wcnxt(FXchar*& ptr){ FXwchar w=(FXuchar)*ptr++; if(0xC0<=w){ w = (w<<6) ^ (FXuchar)*ptr++ ^ 0x3080; if(0x800<=w){ w = (w<<6) ^ (FXuchar)*ptr++ ^ 0x20080; if(0x10000<=w){ w = (w<<6) ^ (FXuchar)*ptr++ ^ 0x400080; }}} return w; } /// Go to previous wide character from UTF8 string, and return it static inline FXwchar wcprv(const FXchar*& ptr){ FXwchar w=(FXuchar)*--ptr; if(0x80<=w){ w = ((FXuchar)*--ptr<<6) ^ w ^ 0x3080; if(0x1000<=w){ w = ((FXuchar)*--ptr<<12) ^ w ^ 0xE1000; if(0x20000<=w){ w = ((FXuchar)*--ptr<<18) ^ w ^ 0x3C60000; }}} return w; } /// Go to previous wide character from UTF8 string, and return it static inline FXwchar wcprv(FXchar*& ptr){ FXwchar w=(FXuchar)*--ptr; if(0x80<=w){ w = ((FXuchar)*--ptr<<6) ^ w ^ 0x3080; if(0x1000<=w){ w = ((FXuchar)*--ptr<<12) ^ w ^ 0xE1000; if(0x20000<=w){ w = ((FXuchar)*--ptr<<18) ^ w ^ 0x3C60000; }}} return w; } /// Increment to start of next wide character in utf8 string static inline const FXchar* wcinc(const FXchar* ptr){ return (isUTF8(*++ptr) || isUTF8(*++ptr) || isUTF8(*++ptr) || ++ptr), ptr; } /// Increment to start of next wide character in utf8 string static inline FXchar* wcinc(FXchar* ptr){ return (isUTF8(*++ptr) || isUTF8(*++ptr) || isUTF8(*++ptr) || ++ptr), ptr; } /// Decrement to start of previous wide character in utf8 string static inline const FXchar* wcdec(const FXchar* ptr){ return (isUTF8(*--ptr) || isUTF8(*--ptr) || isUTF8(*--ptr) || --ptr), ptr; } /// Decrement to start of previous wide character in utf8 string static inline FXchar* wcdec(FXchar* ptr){ return (isUTF8(*--ptr) || isUTF8(*--ptr) || isUTF8(*--ptr) || --ptr), ptr; } /// Adjust ptr to point to leader of multi-byte sequence static inline const FXchar* wcstart(const FXchar* ptr){ return (isUTF8(*ptr) || isUTF8(*--ptr) || isUTF8(*--ptr) || --ptr), ptr; } /// Adjust ptr to point to leader of multi-byte sequence static inline FXchar* wcstart(FXchar* ptr){ return (isUTF8(*ptr) || isUTF8(*--ptr) || isUTF8(*--ptr) || --ptr), ptr; } /************************** UTF16 Support Functions **************************/ /// Test if character c is at start of UTF16 sequence static inline FXbool isUTF16(FXnchar c){ return (c&0xFC00)!=0xDC00; } /// Check if c is leader of a UTF16 surrogate pair sequence static inline FXbool leadUTF16(FXnchar c){ return (c&0xFC00)==0xD800; } /// Check if c is follower of a UTF16 surrogate pair sequence static inline FXbool followUTF16(FXnchar c){ return (c&0xFC00)==0xDC00; } /// Check if c is part of multi-word UTF16 sequence static inline FXbool seqUTF16(FXnchar c){ return (c&0xF800)==0xD800; } /// Length of UTF16 character, in words static inline FXival lenUTF16(FXnchar c){ return leadUTF16(c)+1; } /// Return number of words of narrow character at ptr static inline FXival wclen(const FXnchar *ptr){ return lenUTF16(*ptr); } /// Return wide character from utf16 string static inline FXwchar wc(const FXnchar* ptr){ FXwchar w=ptr[0]; if(leadUTF16(w)){ w = (w<<10) + ptr[1] - 0x35FDC00; } return w; } /// Return wide character from 1-word utf16 string static inline FXwchar wc1(const FXnchar* ptr){ return ptr[0]; } /// Return wide character from 2-word utf16 string static inline FXwchar wc2(const FXnchar* ptr){ return (ptr[0]<<10)+ptr[1]-0x35FDC00; } /// Return wide character from UTF16 string, and go to next wide character static inline FXwchar wcnxt(const FXnchar*& ptr){ FXwchar w=*ptr++; if(leadUTF16(w)){ w = (w<<10) + *ptr++ - 0x35FDC00; } return w; } /// Return wide character from UTF16 string, and go to next wide character static inline FXwchar wcnxt(FXnchar*& ptr){ FXwchar w=*ptr++; if(leadUTF16(w)){ w = (w<<10) + *ptr++ - 0x35FDC00; } return w; } /// Go to previous wide character from UTF16 string, and return it static inline FXwchar wcprv(const FXnchar*& ptr){ FXwchar w=*--ptr; if(followUTF16(w)){ w = (*--ptr<<10) + w - 0x35FDC00; } return w; } /// Go to previous wide character from UTF16 string, and return it static inline FXwchar wcprv(FXnchar*& ptr){ FXwchar w=*--ptr; if(followUTF16(w)){ w = (*--ptr<<10) + w - 0x35FDC00; } return w; } /// Safely go to begin of next utf8 character static inline const FXnchar* wcinc(const FXnchar* ptr){ return (isUTF16(*++ptr) || ++ptr), ptr; } /// Safely go to begin of next utf8 character static inline FXnchar* wcinc(FXnchar* ptr){ return (isUTF16(*++ptr) || ++ptr), ptr; } /// Safely go to begin of previous utf8 character static inline const FXnchar* wcdec(const FXnchar* ptr){ return (isUTF16(*--ptr) || --ptr), ptr; } /// Safely go to begin of previous utf8 character static inline FXnchar* wcdec(FXnchar* ptr){ return (isUTF16(*--ptr) || --ptr), ptr; } /// Adjust ptr to point to leader of surrogate pair sequence static inline const FXnchar* wcstart(const FXnchar *ptr){ return (isUTF16(*ptr) || --ptr), ptr; } /// Adjust ptr to point to leader of surrogate pair sequence static inline FXnchar* wcstart(FXnchar *ptr){ return (isUTF16(*ptr) || --ptr), ptr; } /// Test if c is a legal utf32 character static inline FXbool isUTF32(FXwchar c){ return c<0x110000; } /*********************** Measure Encoding Conversions **********************/ /// Return number of bytes for utf8 representation of wide character w static inline FXival wc2utf(FXwchar w){ return 1+(0x80<=w)+(0x800<=w)+(0x10000<=w); } /// Return number of narrow characters for utf16 representation of wide character w static inline FXival wc2nc(FXwchar w){ return 1+(0x10000<=w); } /// Return number of bytes for utf8 representation of wide character string extern FXAPI FXival wcs2utf(const FXwchar* src,FXival srclen); extern FXAPI FXival wcs2utf(const FXwchar* src); /// Return number of bytes for utf8 representation of narrow character string extern FXAPI FXival ncs2utf(const FXnchar* src,FXival srclen); extern FXAPI FXival ncs2utf(const FXnchar* src); /// Return number of wide characters for utf8 character string extern FXAPI FXival utf2wcs(const FXchar src,FXival srclen); extern FXAPI FXival utf2wcs(const FXchar *src); /// Return number of narrow characters for utf8 character string extern FXAPI FXival utf2ncs(const FXchar *src,FXival srclen); extern FXAPI FXival utf2ncs(const FXchar *src); /************************ Encoding Conversions ******************************/ /// Convert wide character to utf8 string; return number of items written to dst extern FXAPI FXival wc2utf(FXchar *dst,FXwchar w); /// Convert wide character to narrow character string; return number of items written to dst extern FXAPI FXival wc2nc(FXnchar *dst,FXwchar w); /// Convert wide character string to utf8 string; return number of items written to dst extern FXAPI FXival wcs2utf(FXchar *dst,const FXwchar* src,FXival dstlen,FXival srclen); extern FXAPI FXival wcs2utf(FXchar *dst,const FXwchar* src,FXival dstlen); /// Convert narrow character string to utf8 string; return number of items written to dst extern FXAPI FXival ncs2utf(FXchar *dst,const FXnchar* src,FXival dstlen,FXival srclen); extern FXAPI FXival ncs2utf(FXchar *dst,const FXnchar* src,FXival dstlen); /// Convert utf8 string to wide character string; return number of items written to dst extern FXAPI FXival utf2wcs(FXwchar *dst,const FXchar* src,FXival dstlen,FXival srclen); extern FXAPI FXival utf2wcs(FXwchar *dst,const FXchar* src,FXival dstlen); /// Convert utf8 string to narrow character string; return number of items written to dst extern FXAPI FXival utf2ncs(FXnchar *dst,const FXchar* src,FXival dstlen,FXival srclen); extern FXAPI FXival utf2ncs(FXnchar *dst,const FXchar* src,FXival dstlen); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/fxcpuid.h000066400000000000000000000101061455751074500222720ustar00rootroot00000000000000/******************************************************************************** * * * C P U I D S u p p o r t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXCPUID_H #define FXCPUID_H namespace FX { // Runtime CPU features check (x86/x86-64 only) enum { CPU_HAS_SSE = 0x0000001, CPU_HAS_SSE2 = 0x0000002, CPU_HAS_SSE3 = 0x0000004, CPU_HAS_SSSE3 = 0x0000008, CPU_HAS_SSE41 = 0x0000010, CPU_HAS_SSE42 = 0x0000020, CPU_HAS_AVX = 0x0000040, CPU_HAS_AVX2 = 0x0000080, CPU_HAS_FMA = 0x0000100, CPU_HAS_AES = 0x0000200, CPU_HAS_POPCNT = 0x0000400, CPU_HAS_CX8 = 0x0000800, CPU_HAS_CX16 = 0x0001000, CPU_HAS_F16 = 0x0002000, CPU_HAS_BMI1 = 0x0004000, CPU_HAS_BMI2 = 0x0008000, CPU_HAS_SSE4A = 0x0010000, CPU_HAS_ABM = 0x0020000, CPU_HAS_XOP = 0x0040000, CPU_HAS_FMA4 = 0x0080000, CPU_HAS_TBM = 0x0100000, CPU_HAS_RAND = 0x0200000 }; /** * On x86 or x86-64 processors, check the number of feature-requests * available on the current processor. If available, the largest feature * request index+1 is returned, otherwise, this function returns 0. * Extended caps levels may be obtained by passing 0x80000000 instead of * zero. */ extern FXAPI FXuint fxCPUCaps(FXuint level=0); /** * Perform processor feature request of given level. * The resulting output values are written into the array features, * in the order EAX,EBX,ECX,EDX (for x86/x86-64). * The function returns true if successful, and false if the processor * does not support feature requests, or if the feature request level * exceeds the number of levels reported by fxCPUCaps(). */ extern FXAPI FXbool fxCPUGetCaps(FXuint level,FXuint features[]); /** * Perform processor extended feature request of given level, and given count * parameter. * The resulting output values are written into the array features, * in the order EAX,EBX,ECX,EDX (for x86/x86-64). * The function returns true if successful, and false if the processor * does not support feature requests, or if the feature request level * exceeds the number of levels reported by fxCPUCaps(). */ extern FXAPI FXbool fxCPUGetXCaps(FXuint level,FXuint count,FXuint features[]); /** * Return CPU features. For example, CPU_HAS_SSE2 means the CPU has * integer vector math support. */ extern FXAPI FXuint fxCPUFeatures(); /** * Return CPU Identification. For example, on AMD processors this returns * "AuthenticAMD", while on Intel processors it returns "GenuineIntel". * Name should be at least 16 bytes, plus 1 for end-of-string. */ extern FXAPI FXbool fxCPUName(FXchar name[]); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/fxdefs.h000066400000000000000000000572071455751074500221240ustar00rootroot00000000000000/******************************************************************************** * * * FOX Definitions, Types, and Macros * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXDEFS_H #define FXDEFS_H /******************************** Definitions ********************************/ // Placement new #include // Path separator #ifdef WIN32 #define PATHSEP '\\' #define PATHSEPSTRING "\\" #define PATHLISTSEP ';' #define PATHLISTSEPSTRING ";" #define ISPATHSEP(c) ((c)=='\\' || (c)=='/') #else #define PATHSEP '/' #define PATHSEPSTRING "/" #define PATHLISTSEP ':' #define PATHLISTSEPSTRING ":" #define ISPATHSEP(c) ((c)=='/') #endif // End Of Line #ifdef WIN32 #define ENDLINE "\r\n" #else #define ENDLINE "\n" #endif // Byte order #if !defined(FOX_BIGENDIAN) #if defined(__GNUC__) #if defined(__BYTE_ORDER__) #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) #define FOX_BIGENDIAN 0 #else #define FOX_BIGENDIAN 1 #endif #else #error "FOX_BIGENDIAN macro not set" #endif #elif defined(_MSC_VER) #define FOX_BIGENDIAN 0 #else #error "FOX_BIGENDIAN macro not set" #endif #endif // Shared library support #ifdef WIN32 #if defined(__GNUC__) #define FXLOCAL #define FXEXPORT __attribute__ ((dllexport)) #define FXIMPORT __attribute__ ((dllimport)) #else #define FXLOCAL #define FXEXPORT __declspec(dllexport) #define FXIMPORT __declspec(dllimport) #endif #else #if defined(__GNUC__) && (__GNUC__ >= 4) #define FXLOCAL __attribute__((visibility("hidden"))) #define FXEXPORT __attribute__((visibility("default"))) #define FXIMPORT __attribute__((visibility("default"))) #else #define FXLOCAL #define FXEXPORT #define FXIMPORT #endif #endif // Define FXAPI for DLL builds #ifdef FOXDLL #ifdef FOXDLL_EXPORTS #define FXAPI FXEXPORT #define FXTEMPLATE_EXTERN #else #define FXAPI FXIMPORT #define FXTEMPLATE_EXTERN extern #endif #else #define FXAPI #define FXTEMPLATE_EXTERN #endif // Data alignment attribute #if defined(__GNUC__) #define __align(x) __attribute__((aligned(x))) #elif defined(_MSC_VER) #define __align(x) __declspec(align(x)) #else #define __align(x) #endif // Get alignment of pointer p to b=2^n bytes, returning 0..b-1 #define __alignment(p,b) (((FXival)(p))&((b)-1)) // Check if pointer p is aligned to b=2^n bytes #define __isaligned(p,b) (__alignment(p,b)==0) // Align pointer to b=2^n bytes #define __alignto(p,b) ((void*)((((FXival)(p))+((FXival)((b)-1)))&~((FXival)((b)-1)))) // Thread-local storage attribute #if defined(__GNUC__) #define __threadlocal __thread #elif defined(_MSC_VER) #define __threadlocal __declspec(thread) #else #define __threadlocal #endif // Non-returning function #if defined(__GNUC__) #define __noreturn __attribute__((__noreturn__)) #elif (_MSC_VER >= 1400) #define __noreturn __declspec(noreturn) #else #define __noreturn #endif // Branch prediction optimization #if (__GNUC__ >= 3) #define __likely(cond) __builtin_expect(!!(cond),1) #define __unlikely(cond) __builtin_expect(!!(cond),0) #else #define __likely(cond) (!!(cond)) #define __unlikely(cond) (!!(cond)) #endif // Unreachable part of code #if defined(__GNUC__) && (__GNUC__ >= 4) #define __unreachable() __builtin_unreachable() #elif defined(_MSC_VER) #define __unreachable() __assume(false) #else #define __unreachable() #endif // Prefetch address #if (__GNUC__ >= 4) && (defined(__i386__) || defined(__x86_64__)) #define __prefetch(addr) __builtin_prefetch((addr),0) #define __prefetchw(addr) __builtin_prefetch((addr),1) #else #define __prefetch(addr) #define __prefetchw(addr) #endif // Standard call calling sequence #ifdef WIN32 #ifndef CALLBACK #define CALLBACK __stdcall #endif #endif // C Language calling sequence #ifdef WIN32 #ifndef CDECL #define CDECL __cdecl #endif #else #ifndef CDECL #define CDECL #endif #endif // Checking printf and scanf format strings #if defined(_CC_GNU_) || defined(__GNUG__) || defined(__GNUC__) #define FX_PRINTF(fmt,arg) __attribute__((format(printf,fmt,arg))) #define FX_SCANF(fmt,arg) __attribute__((format(scanf,fmt,arg))) #define FX_FORMAT(arg) __attribute__((format_arg(arg))) #else #define FX_PRINTF(fmt,arg) #define FX_SCANF(fmt,arg) #define FX_FORMAT(arg) #endif // Word size issues #if defined(_MSC_VER) || defined(__MINGW32__) // Windows #if defined(_WIN64) #define LLP64 1 // Long longs and pointers are 64 bit #else #define ILP32 1 // Ints, longs, and pointers are 32 bit #endif #elif defined(__LP64__) || defined(_LP64) || (_MIPS_SZLONG == 64) || (__WORDSIZE == 64) #define LP64 1 // Longs and pointers are 64 bit #else #define ILP32 1 // Longs, integers, and pointers are 32 bit #endif // Suffixes for 64-bit constants #if defined(LP64) #define FXLONG(c) c ## L // Long suffix for 64 bit #define FXULONG(c) c ## UL #elif defined(_MSC_VER) && (_MSC_VER < 1900) #define FXLONG(c) c ## i64 // Special suffix for 64 bit #define FXULONG(c) c ## ui64 #else #define FXLONG(c) c ## LL // Long long suffix for 64 bit #define FXULONG(c) c ## ULL #endif // Raw event type #ifdef WIN32 struct tagMSG; #else union _XEvent; #endif namespace FX { /********************************* Typedefs **********************************/ // Forward declarations class FXObject; class FXStream; class FXString; // Streamable types; these are fixed size! typedef char FXchar; typedef signed char FXschar; typedef unsigned char FXuchar; typedef bool FXbool; typedef unsigned short FXushort; typedef short FXshort; typedef unsigned int FXuint; typedef int FXint; typedef float FXfloat; typedef double FXdouble; #if defined(WIN32) typedef unsigned int FXwchar; #if defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED) typedef unsigned short FXnchar; #elif defined(__WATCOMC__) && !defined(_WCHAR_T_DEFINED) typedef long char FXnchar; #else typedef wchar_t FXnchar; #endif #else typedef wchar_t FXwchar; typedef unsigned short FXnchar; #endif #if defined(LP64) typedef long FXlong; typedef unsigned long FXulong; #elif defined(_MSC_VER) && (_MSC_VER < 1900) typedef __int64 FXlong; typedef unsigned __int64 FXulong; #else typedef long long FXlong; typedef unsigned long long FXulong; #endif // Integral types large enough to hold value of a pointer #if defined(LP64) || defined(ILP32) // Long for LP64 and ILP32 models typedef long FXival; typedef unsigned long FXuval; #elif defined(LLP64) // Long long for LLP64 models #if defined(_MSC_VER) && (_MSC_VER < 1900) typedef __int64 FXival; typedef unsigned __int64 FXuval; #else typedef long long FXival; typedef unsigned long long FXuval; #endif #endif // Generic void pointer typedef void* FXptr; // Handle to something in server #ifdef WIN32 typedef void* FXID; #else typedef unsigned long FXID; #endif // Time since January 1, 1970 (UTC) typedef FXlong FXTime; // Pixel type (could be color index) typedef unsigned long FXPixel; // RGBA pixel value typedef FXuint FXColor; // Hot key typedef FXuint FXHotKey; // Input source handle type #ifdef WIN32 typedef void* FXInputHandle; #else typedef FXint FXInputHandle; #endif // Process handle #if defined(WIN32) typedef void* FXProcessID; #else typedef int FXProcessID; #endif // Thread ID type #if defined(WIN32) typedef void* FXThreadID; #else typedef unsigned long FXThreadID; #endif // Thread-local storage key typedef FXuval FXThreadStorageKey; // Raw event type #ifdef WIN32 typedef tagMSG FXRawEvent; #else typedef _XEvent FXRawEvent; #endif // Drag and drop data type #ifdef WIN32 typedef FXushort FXDragType; #else typedef FXID FXDragType; #endif // Third logic state: unknown/indeterminate enum { maybe=2 }; // A time in the far, far future const FXTime forever=FXLONG(9223372036854775807); // Search modes for search/replace dialogs enum { SEARCH_BACKWARD = 1, /// Search backward SEARCH_FORWARD = 2, /// Search forward SEARCH_NOWRAP = 0, /// Don't wrap (default) SEARCH_WRAP = 4, /// Wrap around to start SEARCH_EXACT = 0, /// Exact match (default) SEARCH_IGNORECASE = 8, /// Ignore case SEARCH_REGEX = 16, /// Regular expression match SEARCH_PREFIX = 32, /// Prefix of subject string SEARCH_SUFFIX = 64, /// Suffix of subject string SEARCH_WORDS = 128 /// Whole words }; /********************************** Macros ***********************************/ /// Get bit b from val #define FXBIT(val,b) (((val)>>(b))&1) /// Abolute value #define FXABS(val) (((val)>=0)?(val):-(val)) /// Return 1 if val >= 0 and -1 otherwise #define FXSGN(val) (((val)<0)?-1:1) /// Return 1 if val > 0, -1 if val < 0, and 0 otherwise #define FXSGNZ(val) ((val)<0?-1:(val)>0?1:0) /// Sign-extend bit-field of b bits to 32 bit signed integer #define FXSGNX(x,b) (((FXint)((x)<<(32-(b))))>>(32-(b))) /// Return the maximum of a or b #define FXMAX(a,b) (((a)>(b))?(a):(b)) /// Return the minimum of a or b #define FXMIN(a,b) (((a)>(b))?(b):(a)) /// Return the minimum of x, y and z #define FXMIN3(x,y,z) ((x)<(y)?FXMIN(x,z):FXMIN(y,z)) /// Return the maximum of x, y and z #define FXMAX3(x,y,z) ((x)>(y)?FXMAX(x,z):FXMAX(y,z)) /// Return the minimum of x, y, z, and w #define FXMIN4(x,y,z,w) (FXMIN(FXMIN(x,y),FXMIN(z,w))) /// Return the maximum of of x, y, z, and w #define FXMAX4(x,y,z,w) (FXMAX(FXMAX(x,y),FXMAX(z,w))) /// Return minimum and maximum of a, b #define FXMINMAX(lo,hi,a,b) ((a)<(b)?((lo)=(a),(hi)=(b)):((lo)=(b),(hi)=(a))) /// Clamp value x to range [lo..hi] #define FXCLAMP(lo,x,hi) ((x)<(lo)?(lo):((x)>(hi)?(hi):(x))) /// Swap a pair of numbers #define FXSWAP(a,b,t) ((t)=(a),(a)=(b),(b)=(t)) /// Linear interpolation between a and b, where 0<=f<=1 #define FXLERP(a,b,f) ((a)+((b)-(a))*(f)) /// Offset of member in a structure #define STRUCTOFFSET(str,member) (((char *)(&(((str *)0)->member)))-((char *)0)) /// Number of elements in a static array #define ARRAYNUMBER(array) (sizeof(array)/sizeof(array[0])) /// Container class of a member class #define CONTAINER(ptr,str,mem) ((str*)(((char*)(ptr))-STRUCTOFFSET(str,mem))) /// Make int out of two shorts #define MKUINT(l,h) ((((FX::FXuint)(l))&0xffff) | (((FX::FXuint)(h))<<16)) /// Make selector from message type and message id #define FXSEL(type,id) ((((FX::FXuint)(id))&0xffff) | (((FX::FXuint)(type))<<16)) /// Get type from selector #define FXSELTYPE(s) ((FX::FXushort)(((s)>>16)&0xffff)) /// Get ID from selector #define FXSELID(s) ((FX::FXushort)((s)&0xffff)) /// Average of two FXColor ca and FXColor cb #define FXAVGCOLOR(ca,cb) (((ca)&(cb))+((((ca)^(cb))&0xFEFEFEFE)>>1)) // Definitions for big-endian machines #if FOX_BIGENDIAN == 1 /// Make RGBA color #define FXRGBA(r,g,b,a) (((FX::FXuint)(FX::FXuchar)(a)) | ((FX::FXuint)(FX::FXuchar)(r)<<8) | ((FX::FXuint)(FX::FXuchar)(g)<<16) | ((FX::FXuint)(FX::FXuchar)(b)<<24)) /// Make RGB color #define FXRGB(r,g,b) (((FX::FXuint)(FX::FXuchar)(r)<<8) | ((FX::FXuint)(FX::FXuchar)(g)<<16) | ((FX::FXuint)(FX::FXuchar)(b)<<24) | 0x000000ff) /// Get red value from RGBA color #define FXREDVAL(rgba) ((FX::FXuchar)(((rgba)>>8)&0xff)) /// Get green value from RGBA color #define FXGREENVAL(rgba) ((FX::FXuchar)(((rgba)>>16)&0xff)) /// Get blue value from RGBA color #define FXBLUEVAL(rgba) ((FX::FXuchar)(((rgba)>>24)&0xff)) /// Get alpha value from RGBA color #define FXALPHAVAL(rgba) ((FX::FXuchar)((rgba)&0xff)) /// Get component value of RGBA color #define FXRGBACOMPVAL(rgba,comp) ((FX::FXuchar)(((rgba)>>((comp)<<3))&0xff)) /// Get RGB color from COLORREF #define FXCOLORREF2RGB(ref) (FX::FXuint)((((ref)<<8)&0xff000000) | (((ref)<<8)&0xff0000) | (((ref)<<8)&0xff00) | 0x000000ff) /// Get COLORREF from RGB color #define FXRGB2COLORREF(rgb) (FX::FXuint)((((rgb)>>8)&0xff0000) | (((rgb)>>8)&0xff00) | (((rgb)>>8)&0xff)) #endif // Definitions for little-endian machines #if FOX_BIGENDIAN == 0 /// Make RGBA color #define FXRGBA(r,g,b,a) (((FX::FXuint)(FX::FXuchar)(a)<<24) | ((FX::FXuint)(FX::FXuchar)(r)<<16) | ((FX::FXuint)(FX::FXuchar)(g)<<8) | ((FX::FXuint)(FX::FXuchar)(b))) /// Make RGB color #define FXRGB(r,g,b) (((FX::FXuint)(FX::FXuchar)(r)<<16) | ((FX::FXuint)(FX::FXuchar)(g)<<8) | ((FX::FXuint)(FX::FXuchar)(b)) | 0xff000000) /// Get red value from RGBA color #define FXREDVAL(rgba) ((FX::FXuchar)(((rgba)>>16)&0xff)) /// Get green value from RGBA color #define FXGREENVAL(rgba) ((FX::FXuchar)(((rgba)>>8)&0xff)) /// Get blue value from RGBA color #define FXBLUEVAL(rgba) ((FX::FXuchar)((rgba)&0xff)) /// Get alpha value from RGBA color #define FXALPHAVAL(rgba) ((FX::FXuchar)(((rgba)>>24)&0xff)) /// Get component value of RGBA color #define FXRGBACOMPVAL(rgba,comp) ((FX::FXuchar)(((rgba)>>((3-(comp))<<3))&0xff)) /// Get RGB color from COLORREF #define FXCOLORREF2RGB(ref) (FX::FXuint)((((ref)>>16)&0xff) | ((ref)&0xff00) | (((ref)<<16)&0xff0000) | 0xff000000) /// Get COLORREF from RGB color #define FXRGB2COLORREF(rgb) (FX::FXuint)((((rgb)<<16)&0xff0000) | ((rgb)&0xff00) | (((rgb)>>16)&0xff)) #endif /** * FXASSERT() prints out a message when the expression fails, * and nothing otherwise. Unlike assert(), FXASSERT() will not * terminate the execution of the application. * When compiling your application for release, all assertions * are compiled out; thus there is no impact on execution speed. */ #ifndef NDEBUG #define FXASSERT(exp) (__likely(exp)?((void)0):(void)FX::fxassert(#exp,__FILE__,__LINE__)) #else #define FXASSERT(exp) ((void)0) #endif /** * FXVERIFY prints out a message when the expression fails, * and nothing otherwise. * When compiling your application for release, these messages * are compiled out, but unlike FXASSERT, FXVERIFY will still execute * the expression. */ #ifndef NDEBUG #define FXVERIFY(exp) (__likely(exp)?((void)0):(void)FX::fxverify(#exp,__FILE__,__LINE__)) #else #define FXVERIFY(exp) ((void)(exp)) #endif /** * FXASSERT_STATIC performs a compile time assert (requires C++11 or newer). * When assertion (which must be const expression) fails, a compile-time * error message is generated. Thus, there is no run-time overhead whatsoever. * In addition, the condition is checked even if code is never executed. */ #if (defined(__cplusplus) && (__cplusplus >= 201103L)) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) #define FXASSERT_STATIC(expr) static_assert(expr,#expr) #else #define FXASSERT_STATIC(expr) FXASSERT(expr) #endif /** * FXTRACE() allows you to trace the execution of your application * with any amount of detail desired. * The trace topic number determines whether a trace command is * printed to the output. * When compiling your application for release, all trace statements * are compiled out, just like FXASSERT. * A statement like: FXTRACE((10,"The value of x=%d\n",x)) will * generate output only if the trace topic 10 is enabled. * Note the double parentheses! * Trace topics may be set by command line parameter "-tracetopics" * followed by a comma-separeted list of topic ranges. For example, * parameter "-tracetopics 1000:1023,0:3" selects topics 1000 through * 1023, and topics 0 through 3. */ #ifndef NDEBUG #define FXTRACE(arguments) FX::fxtrace arguments #else #define FXTRACE(arguments) ((void)0) #endif /** * Allocate a memory block of no elements of type and store a pointer * to it into the address pointed to by ptr. * Return false if size!=0 and allocation fails, true otherwise. * An allocation of a zero size block returns a NULL pointer. */ #define FXMALLOC(ptr,type,no) (FX::fxmalloc((void **)(ptr),sizeof(type)*(no))) /** * Allocate a zero-filled memory block no elements of type and store a pointer * to it into the address pointed to by ptr. * Return false if size!=0 and allocation fails, true otherwise. * An allocation of a zero size block returns a NULL pointer. */ #define FXCALLOC(ptr,type,no) (FX::fxcalloc((void **)(ptr),sizeof(type)*(no))) /** * Resize the memory block referred to by the pointer at the address ptr, to a * hold no elements of type. * Returns false if size!=0 and reallocation fails, true otherwise. * If reallocation fails, pointer is left to point to old block; a reallocation * to a zero size block has the effect of freeing it. * The ptr argument must be the address where the pointer to the allocated * block is to be stored. */ #define FXRESIZE(ptr,type,no) (FX::fxresize((void **)(ptr),sizeof(type)*(no))) /** * Allocate and initialize memory from another block. * Return false if size!=0 and source!=NULL and allocation fails, true otherwise. * An allocation of a zero size block returns a NULL pointer. * The ptr argument must be the address where the pointer to the allocated * block is to be stored. */ #define FXMEMDUP(ptr,src,type,no) (FX::fxmemdup((void **)(ptr),(const void*)(src),sizeof(type)*(no))) /** * Free a block of memory allocated with either FXMALLOC, FXCALLOC, FXRESIZE, or FXMEMDUP. * It is OK to call free a NULL pointer. The argument must be the address of the * pointer to the block to be released. The pointer is set to NULL to prevent * any further references to the block after releasing it. */ #define FXFREE(ptr) (FX::fxfree((void **)(ptr))) /********************************** Globals **********************************/ /// Aliasing cast pointer to other type template static inline to_type* alias_cast(void* ptr){ union UNI { to_type dst[1]; }; return reinterpret_cast(ptr)->dst; } /// Aliasing cast const-pointer to other type template static inline const to_type* alias_cast(const void* ptr){ union UNI { to_type dst[1]; }; return reinterpret_cast(ptr)->dst; } /// Allocate memory extern FXAPI FXbool fxmalloc(void** ptr,FXuval size); /// Allocate cleaned memory extern FXAPI FXbool fxcalloc(void** ptr,FXuval size); /// Resize memory extern FXAPI FXbool fxresize(void** ptr,FXuval size); /// Free memory, resets ptr to NULL afterward extern FXAPI void fxfree(void** ptr); /// Duplicate memory extern FXAPI FXbool fxmemdup(void** ptr,const void* src,FXuval size); /// Error output routine; will terminate program after writing message extern FXAPI __noreturn void fxerror(const FXchar* format,...) FX_PRINTF(1,2) ; /// Warning routine; will continue program after writing message extern FXAPI void fxwarning(const FXchar* format,...) FX_PRINTF(1,2) ; /// Log message to [typically] stderr extern FXAPI void fxmessage(const FXchar* format,...) FX_PRINTF(1,2) ; /// Assert failed routine:- usually not called directly but called through FXASSERT extern FXAPI void fxassert(const FXchar* expression,const FXchar* filename,unsigned int lineno); /// Verify failed routine:- usually not called directly but called through FXVERIFY extern FXAPI void fxverify(const FXchar* expression,const FXchar* filename,unsigned int lineno); /// Trace printout routine:- usually not called directly but called through FXTRACE extern FXAPI void fxtrace(FXuint level,const FXchar* format,...) FX_PRINTF(2,3) ; /// Convert string of length len to MSDOS; return new string and new length extern FXAPI FXbool fxtoDOS(FXchar*& string,FXint& len); /// Convert string of length len from MSDOS; return new string and new length extern FXAPI FXbool fxfromDOS(FXchar*& string,FXint& len); /// Duplicate string extern FXAPI FXchar *fxstrdup(const FXchar* str); /// Calculate a hash value from a string extern FXAPI FXuint fxstrhash(const FXchar* str); /// Safe string copy extern FXAPI FXival fxstrlcpy(FXchar* dst,const FXchar* src,FXival len); /// Safe string concat extern FXAPI FXival fxstrlcat(FXchar* dst,const FXchar* src,FXival len); /// Convert RGB to HSV extern FXAPI void fxrgb_to_hsv(FXfloat& h,FXfloat& s,FXfloat& v,FXfloat r,FXfloat g,FXfloat b); /// Convert HSV to RGB extern FXAPI void fxhsv_to_rgb(FXfloat& r,FXfloat& g,FXfloat& b,FXfloat h,FXfloat s,FXfloat v); /// Convert RGB to HSL extern FXAPI void fxrgb_to_hsl(FXfloat& h,FXfloat& s,FXfloat& l,FXfloat r,FXfloat g,FXfloat b); /// Convert HSL to RGB extern FXAPI void fxhsl_to_rgb(FXfloat& r,FXfloat& g,FXfloat& b,FXfloat h,FXfloat s,FXfloat l); /// Encode src to dst in base64 extern FXchar* fxencode64(FXchar* dst,FXchar* dstend,const FXchar* src,const FXchar* srcend); /// Decode src to dst from base64 extern FXchar* fxdecode64(FXchar* dst,FXchar* dstend,const FXchar* src,const FXchar* srcend); /// Encode src to dst in base85 extern FXchar* fxencode85(FXchar* dst,FXchar* dstend,const FXchar* src,const FXchar* srcend); /// Decode src to dst from base85 extern FXchar* fxdecode85(FXchar* dst,FXchar* dstend,const FXchar* src,const FXchar* srcend); /// Convert keysym to unicode character extern FXAPI FXwchar fxkeysym2ucs(FXwchar sym); /// Convert unicode character to keysym extern FXAPI FXwchar fxucs2keysym(FXwchar ucs); /// Parse geometry, a-la X11 geometry specification extern FXAPI FXint fxparsegeometry(const FXchar *string,FXint& x,FXint& y,FXint& w,FXint& h); /// True if executable with given path is a console application extern FXAPI FXbool fxisconsole(const FXchar *path); /// Version number that the library has been compiled with extern FXAPI const FXuchar fxversion[3]; /// Get trace topic setting extern FXAPI FXbool getTraceTopic(FXuint topic); /// Set trace topic on or off extern FXAPI void setTraceTopic(FXuint topic,FXbool flag=true); /// Set tracing for all topics up to and including level extern FXAPI void setTraceLevel(FXuint level,FXbool flag=true); /// Set trace topics from a string of the form: /// /// : [ ',' ]* /// /// : [':' [ ]? ]? /// /// : ':' [ ]? /// /// : [ ]* /// extern FXAPI FXbool setTraceTopics(const FXchar* topics,FXbool flag=true); /// Get operating system version string extern FXAPI FXival fxosversion(FXchar version[],FXival len); } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/fxendian.h000066400000000000000000000212341455751074500224300ustar00rootroot00000000000000/******************************************************************************** * * * B y t e S w a p p i n g S u p p o r t * * * ********************************************************************************* * Copyright (C) 2010,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXENDIAN_H #define FXENDIAN_H namespace FX { // Bit reverse in a byte static inline FXuchar reverse8(FXuchar x){ x=((x<<1)&0xAA) | ((x>>1)&0x55); x=((x<<2)&0xCC) | ((x>>2)&0x33); return (x<<4) | (x>>4); } // Bit reverse in a unsigned short static inline FXushort reverse16(FXushort x){ x=((x<<1)&0xAAAA) | ((x>>1)&0x5555); x=((x<<2)&0xCCCC) | ((x>>2)&0x3333); x=((x<<4)&0xF0F0) | ((x>>4)&0x0F0F); return (x<<8) | (x>>8); } // Bit reverse in an unsigned integer static inline FXuint reverse32(FXuint x){ x=((x<<1)&0xAAAAAAAA) | ((x>>1)&0x55555555); x=((x<<2)&0xCCCCCCCC) | ((x>>2)&0x33333333); x=((x<<4)&0xF0F0F0F0) | ((x>>4)&0x0F0F0F0F); x=((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF); return (x<<16) | (x>>16); } // Bit reverse in an unsigned long static inline FXulong reverse64(FXulong x){ x=((x<< 1)&FXULONG(0xAAAAAAAAAAAAAAAA)) | ((x>> 1)&FXULONG(0x5555555555555555)); x=((x<< 2)&FXULONG(0xCCCCCCCCCCCCCCCC)) | ((x>> 2)&FXULONG(0x3333333333333333)); x=((x<< 4)&FXULONG(0xF0F0F0F0F0F0F0F0)) | ((x>> 4)&FXULONG(0x0F0F0F0F0F0F0F0F)); x=((x<< 8)&FXULONG(0xFF00FF00FF00FF00)) | ((x>> 8)&FXULONG(0x00FF00FF00FF00FF)); x=((x<<16)&FXULONG(0xFFFF0000FFFF0000)) | ((x>>16)&FXULONG(0x0000FFFF0000FFFF)); return (x<<32) | (x>>32); } // Byte swap unsigned short static inline FXushort swap16(FXushort x){ #if ((__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8))) return __builtin_bswap16(x); #elif (_MSC_VER >= 1500) return _byteswap_ushort(x); #else return (x>>8) | (x<<8); #endif } // Byte swap unsiged int static inline FXuint swap32(FXuint x){ #if ((__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8))) return __builtin_bswap32(x); #elif (_MSC_VER >= 1500) return _byteswap_ulong(x); #else x=((x<<8)&0xFF00FF00)|((x>>8)&0x00FF00FF); return (x>>16)|(x<<16); #endif } // Byte swap unsigned long static inline FXulong swap64(FXulong x){ #if ((__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8))) return __builtin_bswap64(x); #elif (_MSC_VER >= 1500) return _byteswap_uint64(x); #else x=((x<< 8)&FXULONG(0xFF00FF00FF00FF00))|((x>> 8)&FXULONG(0x00FF00FF00FF00FF)); x=((x<<16)&FXULONG(0xFFFF0000FFFF0000))|((x>>16)&FXULONG(0x0000FFFF0000FFFF)); return (x>>32)|(x<<32); #endif } // Isolate least significant bit set static inline FXuint lsb32(FXuint x){ return FXuint(x&(-FXint(x))); } // Isolate least significant bit set static inline FXulong lsb64(FXulong x){ return FXulong(x&(-FXlong(x))); } // Isolate most significant bit set static inline FXuint msb32(FXuint x){ x|=(x>>1); x|=(x>>2); x|=(x>>4); x|=(x>>8); x|=(x>>16); return x-(x>>1); } // Isolate most significant bit set static inline FXulong msb64(FXulong x){ x|=(x>>1); x|=(x>>2); x|=(x>>4); x|=(x>>8); x|=(x>>16); x|=(x>>32); return x-(x>>1); } // Count one-bits in integer static inline FXuint pop32(FXuint x){ #if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))) return __builtin_popcount(x); #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) return __popcnt(x); #else x=x-((x>>1)&0x55555555); x=(x&0x33333333)+((x>>2)&0x33333333); return (((x+(x>>4))&0x0F0F0F0F)*0x01010101)>>24; #endif } // Count one-bits in long static inline FXulong pop64(FXulong x){ #if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))) #if defined(__LP64__) || defined(_LP64) || (__WORDSIZE == 64) return __builtin_popcountl(x); #else return __builtin_popcountll(x); #endif #elif defined(_MSC_VER) && (defined(_M_X64)) return __popcnt64(x); #else x=x-((x>>1)&FXULONG(0x5555555555555555)); x=(x&FXULONG(0x3333333333333333))+((x>>2)&FXULONG(0x3333333333333333)); return (((x+(x>>4))&FXULONG(0xf0f0f0f0f0f0f0f))*FXULONG(0x101010101010101))>>56; #endif } // Count leading zeros in non-zero integer static inline FXuint clz32(FXuint x){ #if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))) return __builtin_clz(x); #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) unsigned long result; _BitScanReverse(&result,x); return 31-result; #else FXuint f,e,d,c,b; f=(((FXint)(x-0x00010000))>>31)&16; x<<=f; e=(((FXint)(x-0x01000000))>>31)&8; x<<=e; d=(((FXint)(x-0x10000000))>>31)&4; x<<=d; c=(((FXint)(x-0x40000000))>>31)&2; x<<=c; b=(((FXint)(x-0x80000000))>>31)&1; return f+e+d+c+b; #endif } // Count leading zeros in non-zero long static inline FXulong clz64(FXulong x){ #if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))) #if defined(__LP64__) || defined(_LP64) || (__WORDSIZE == 64) return __builtin_clzl(x); #else return __builtin_clzll(x); #endif #elif defined(_MSC_VER) && defined(_M_X64) unsigned long result; _BitScanReverse64(&result,x); return 63-result; #else FXulong g,f,e,d,c,b; g=(((FXlong)(x-FXULONG(0x0000000100000000)))>>63)&32; x<<=g; f=(((FXlong)(x-FXULONG(0x0001000000000000)))>>63)&16; x<<=f; e=(((FXlong)(x-FXULONG(0x0100000000000000)))>>63)&8; x<<=e; d=(((FXlong)(x-FXULONG(0x1000000000000000)))>>63)&4; x<<=d; c=(((FXlong)(x-FXULONG(0x4000000000000000)))>>63)&2; x<<=c; b=(((FXlong)(x-FXULONG(0x8000000000000000)))>>63)&1; return g+f+e+d+c+b; #endif } // Count trailing zeros in non-zero integer static inline FXuint ctz32(FXuint x){ #if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))) return __builtin_ctz(x); #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) unsigned long result; _BitScanForward(&result,x); return result; #else return 31-clz32(x&-x); #endif } // Count trailing zeros in non-zero long static inline FXulong ctz64(FXulong x){ #if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))) #if defined(__LP64__) || defined(_LP64) || (__WORDSIZE == 64) return __builtin_ctzl(x); #else return __builtin_ctzll(x); #endif #elif defined(_MSC_VER) && defined(_M_X64) unsigned long result; _BitScanForward64(&result,x); return result; #else return FXULONG(63)-clz64(x&-x); #endif } // Roll bits left, 32-bit flavor (count<32) static inline FXuint rol32(FXuint value,FXuint count){ return (value<>(32-count)); } // Roll bits right, 32-bit flavor (count<32) static inline FXuint ror32(FXuint value,FXuint count){ return (value>>count) | (value<<(32-count)); } // Roll bits left, 64-bit flavor (count<64) static inline FXulong rol64(FXulong value,FXulong count){ return (value<>(FXULONG(64)-count)); } // Roll bits right, 64-bit flavor (count<64) static inline FXulong ror64(FXulong value,FXulong count){ return (value>>count) | (value<<(FXULONG(64)-count)); } // Shift bits left, 32-bit flavor (count<32) static inline FXuint shl32(FXuint value,FXuint count){ return (value<>count); } // Shift bits left, 64-bit flavor (count<64) static inline FXulong shl64(FXulong value,FXulong count){ return (value<>count); } } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/fxkeys.h000066400000000000000000001720721455751074500221540ustar00rootroot00000000000000/******************************************************************************** * * * F O X K e y b o a r d S y m b o l D e f i n i t i o n s * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXKEYS_H #define FXKEYS_H namespace FX { enum { // Void symbol KEY_VoidSymbol = 0, // Miscellaneous KEY_BackSpace = 0xFF08, KEY_Tab = 0xFF09, KEY_Linefeed = 0xFF0A, KEY_Clear = 0xFF0B, KEY_Return = 0xFF0D, KEY_Pause = 0xFF13, KEY_Scroll_Lock = 0xFF14, KEY_Sys_Req = 0xFF15, KEY_Escape = 0xFF1B, KEY_Delete = 0xFFFF, KEY_Multi_key = 0xFF20, // Japanese KEY_Kanji = 0xFF21, KEY_Muhenkan = 0xFF22, KEY_Henkan_Mode = 0xFF23, KEY_Henkan = 0xFF23, KEY_Romaji = 0xFF24, KEY_Hiragana = 0xFF25, KEY_Katakana = 0xFF26, KEY_Hiragana_Katakana = 0xFF27, KEY_Zenkaku = 0xFF28, KEY_Hankaku = 0xFF29, KEY_Zenkaku_Hankaku = 0xFF2A, KEY_Touroku = 0xFF2B, KEY_Massyo = 0xFF2C, KEY_Kana_Lock = 0xFF2D, KEY_Kana_Shift = 0xFF2E, KEY_Eisu_Shift = 0xFF2F, KEY_Eisu_toggle = 0xFF30, // Cursor KEY_Home = 0xFF50, KEY_Left = 0xFF51, KEY_Up = 0xFF52, KEY_Right = 0xFF53, KEY_Down = 0xFF54, KEY_Prior = 0xFF55, KEY_Page_Up = 0xFF55, KEY_Next = 0xFF56, KEY_Page_Down = 0xFF56, KEY_End = 0xFF57, KEY_Begin = 0xFF58, // Functions KEY_Select = 0xFF60, KEY_Print = 0xFF61, KEY_Execute = 0xFF62, KEY_Insert = 0xFF63, KEY_Undo = 0xFF65, KEY_Redo = 0xFF66, KEY_Menu = 0xFF67, KEY_Find = 0xFF68, KEY_Cancel = 0xFF69, KEY_Help = 0xFF6A, KEY_Break = 0xFF6B, KEY_Mode_switch = 0xFF7E, KEY_script_switch = 0xFF7E, KEY_Num_Lock = 0xFF7F, // Keypad KEY_KP_Space = 0xFF80, KEY_KP_Tab = 0xFF89, KEY_KP_Enter = 0xFF8D, KEY_KP_F1 = 0xFF91, KEY_KP_F2 = 0xFF92, KEY_KP_F3 = 0xFF93, KEY_KP_F4 = 0xFF94, KEY_KP_Home = 0xFF95, KEY_KP_Left = 0xFF96, KEY_KP_Up = 0xFF97, KEY_KP_Right = 0xFF98, KEY_KP_Down = 0xFF99, KEY_KP_Prior = 0xFF9A, KEY_KP_Page_Up = 0xFF9A, KEY_KP_Next = 0xFF9B, KEY_KP_Page_Down = 0xFF9B, KEY_KP_End = 0xFF9C, KEY_KP_Begin = 0xFF9D, KEY_KP_Insert = 0xFF9E, KEY_KP_Delete = 0xFF9F, KEY_KP_Equal = 0xFFBD, KEY_KP_Multiply = 0xFFAA, KEY_KP_Add = 0xFFAB, KEY_KP_Separator = 0xFFAC, KEY_KP_Subtract = 0xFFAD, KEY_KP_Decimal = 0xFFAE, KEY_KP_Divide = 0xFFAF, // Keypad numbers KEY_KP_0 = 0xFFB0, KEY_KP_1 = 0xFFB1, KEY_KP_2 = 0xFFB2, KEY_KP_3 = 0xFFB3, KEY_KP_4 = 0xFFB4, KEY_KP_5 = 0xFFB5, KEY_KP_6 = 0xFFB6, KEY_KP_7 = 0xFFB7, KEY_KP_8 = 0xFFB8, KEY_KP_9 = 0xFFB9, // Function keys KEY_F1 = 0xFFBE, KEY_F2 = 0xFFBF, KEY_F3 = 0xFFC0, KEY_F4 = 0xFFC1, KEY_F5 = 0xFFC2, KEY_F6 = 0xFFC3, KEY_F7 = 0xFFC4, KEY_F8 = 0xFFC5, KEY_F9 = 0xFFC6, KEY_F10 = 0xFFC7, KEY_F11 = 0xFFC8, KEY_L1 = 0xFFC8, KEY_F12 = 0xFFC9, KEY_L2 = 0xFFC9, KEY_F13 = 0xFFCA, KEY_L3 = 0xFFCA, KEY_F14 = 0xFFCB, KEY_L4 = 0xFFCB, KEY_F15 = 0xFFCC, KEY_L5 = 0xFFCC, KEY_F16 = 0xFFCD, KEY_L6 = 0xFFCD, KEY_F17 = 0xFFCE, KEY_L7 = 0xFFCE, KEY_F18 = 0xFFCF, KEY_L8 = 0xFFCF, KEY_F19 = 0xFFD0, KEY_L9 = 0xFFD0, KEY_F20 = 0xFFD1, KEY_L10 = 0xFFD1, KEY_F21 = 0xFFD2, KEY_R1 = 0xFFD2, KEY_F22 = 0xFFD3, KEY_R2 = 0xFFD3, KEY_F23 = 0xFFD4, KEY_R3 = 0xFFD4, KEY_F24 = 0xFFD5, KEY_R4 = 0xFFD5, KEY_F25 = 0xFFD6, KEY_R5 = 0xFFD6, KEY_F26 = 0xFFD7, KEY_R6 = 0xFFD7, KEY_F27 = 0xFFD8, KEY_R7 = 0xFFD8, KEY_F28 = 0xFFD9, KEY_R8 = 0xFFD9, KEY_F29 = 0xFFDA, KEY_R9 = 0xFFDA, KEY_F30 = 0xFFDB, KEY_R10 = 0xFFDB, KEY_F31 = 0xFFDC, KEY_R11 = 0xFFDC, KEY_F32 = 0xFFDD, KEY_R12 = 0xFFDD, KEY_F33 = 0xFFDE, KEY_R13 = 0xFFDE, KEY_F34 = 0xFFDF, KEY_R14 = 0xFFDF, KEY_F35 = 0xFFE0, KEY_R15 = 0xFFE0, // Modifiers KEY_Shift_L = 0xFFE1, KEY_Shift_R = 0xFFE2, KEY_Control_L = 0xFFE3, KEY_Control_R = 0xFFE4, KEY_Caps_Lock = 0xFFE5, KEY_Shift_Lock = 0xFFE6, KEY_Meta_L = 0xFFE7, KEY_Meta_R = 0xFFE8, KEY_Alt_L = 0xFFE9, KEY_Alt_R = 0xFFEA, KEY_Super_L = 0xFFEB, KEY_Super_R = 0xFFEC, KEY_Hyper_L = 0xFFED, KEY_Hyper_R = 0xFFEE, // ISO 9995 KEY_ISO_Lock = 0xFE01, KEY_ISO_Level2_Latch = 0xFE02, KEY_ISO_Level3_Shift = 0xFE03, KEY_ISO_Level3_Latch = 0xFE04, KEY_ISO_Level3_Lock = 0xFE05, KEY_ISO_Group_Shift = 0xFF7E, KEY_ISO_Group_Latch = 0xFE06, KEY_ISO_Group_Lock = 0xFE07, KEY_ISO_Next_Group = 0xFE08, KEY_ISO_Next_Group_Lock = 0xFE09, KEY_ISO_Prev_Group = 0xFE0A, KEY_ISO_Prev_Group_Lock = 0xFE0B, KEY_ISO_First_Group = 0xFE0C, KEY_ISO_First_Group_Lock = 0xFE0D, KEY_ISO_Last_Group = 0xFE0E, KEY_ISO_Last_Group_Lock = 0xFE0F, KEY_ISO_Left_Tab = 0xFE20, KEY_ISO_Move_Line_Up = 0xFE21, KEY_ISO_Move_Line_Down = 0xFE22, KEY_ISO_Partial_Line_Up = 0xFE23, KEY_ISO_Partial_Line_Down = 0xFE24, KEY_ISO_Partial_Space_Left = 0xFE25, KEY_ISO_Partial_Space_Right = 0xFE26, KEY_ISO_Set_Margin_Left = 0xFE27, KEY_ISO_Set_Margin_Right = 0xFE28, KEY_ISO_Release_Margin_Left = 0xFE29, KEY_ISO_Release_Margin_Right = 0xFE2A, KEY_ISO_Release_Both_Margins = 0xFE2B, KEY_ISO_Fast_Cursor_Left = 0xFE2C, KEY_ISO_Fast_Cursor_Right = 0xFE2D, KEY_ISO_Fast_Cursor_Up = 0xFE2E, KEY_ISO_Fast_Cursor_Down = 0xFE2F, KEY_ISO_Continuous_Underline = 0xFE30, KEY_ISO_Discontinuous_Underline = 0xFE31, KEY_ISO_Emphasize = 0xFE32, KEY_ISO_Center_Object = 0xFE33, KEY_ISO_Enter = 0xFE34, KEY_dead_grave = 0xFE50, KEY_dead_acute = 0xFE51, KEY_dead_circumflex = 0xFE52, KEY_dead_tilde = 0xFE53, KEY_dead_macron = 0xFE54, KEY_dead_breve = 0xFE55, KEY_dead_abovedot = 0xFE56, KEY_dead_diaeresis = 0xFE57, KEY_dead_abovering = 0xFE58, KEY_dead_doubleacute = 0xFE59, KEY_dead_caron = 0xFE5A, KEY_dead_cedilla = 0xFE5B, KEY_dead_ogonek = 0xFE5C, KEY_dead_iota = 0xFE5D, KEY_dead_voiced_sound = 0xFE5E, KEY_dead_semivoiced_sound = 0xFE5F, KEY_dead_belowdot = 0xFE60, KEY_First_Virtual_Screen = 0xFED0, KEY_Prev_Virtual_Screen = 0xFED1, KEY_Next_Virtual_Screen = 0xFED2, KEY_Last_Virtual_Screen = 0xFED4, KEY_Terminate_Server = 0xFED5, KEY_AccessX_Enable = 0xFE70, KEY_AccessX_Feedback_Enable = 0xFE71, KEY_RepeatKeys_Enable = 0xFE72, KEY_SlowKeys_Enable = 0xFE73, KEY_BounceKeys_Enable = 0xFE74, KEY_StickyKeys_Enable = 0xFE75, KEY_MouseKeys_Enable = 0xFE76, KEY_MouseKeys_Accel_Enable = 0xFE77, KEY_Overlay1_Enable = 0xFE78, KEY_Overlay2_Enable = 0xFE79, KEY_AudibleBell_Enable = 0xFE7A, KEY_Pointer_Left = 0xFEE0, KEY_Pointer_Right = 0xFEE1, KEY_Pointer_Up = 0xFEE2, KEY_Pointer_Down = 0xFEE3, KEY_Pointer_UpLeft = 0xFEE4, KEY_Pointer_UpRight = 0xFEE5, KEY_Pointer_DownLeft = 0xFEE6, KEY_Pointer_DownRight = 0xFEE7, KEY_Pointer_Button_Dflt = 0xFEE8, KEY_Pointer_Button1 = 0xFEE9, KEY_Pointer_Button2 = 0xFEEA, KEY_Pointer_Button3 = 0xFEEB, KEY_Pointer_Button4 = 0xFEEC, KEY_Pointer_Button5 = 0xFEED, KEY_Pointer_DblClick_Dflt = 0xFEEE, KEY_Pointer_DblClick1 = 0xFEEF, KEY_Pointer_DblClick2 = 0xFEF0, KEY_Pointer_DblClick3 = 0xFEF1, KEY_Pointer_DblClick4 = 0xFEF2, KEY_Pointer_DblClick5 = 0xFEF3, KEY_Pointer_Drag_Dflt = 0xFEF4, KEY_Pointer_Drag1 = 0xFEF5, KEY_Pointer_Drag2 = 0xFEF6, KEY_Pointer_Drag3 = 0xFEF7, KEY_Pointer_Drag4 = 0xFEF8, KEY_Pointer_Drag5 = 0xFEFD, KEY_Pointer_EnableKeys = 0xFEF9, KEY_Pointer_Accelerate = 0xFEFA, KEY_Pointer_DfltBtnNext = 0xFEFB, KEY_Pointer_DfltBtnPrev = 0xFEFC, // 3270 Terminal KEY_3270_Duplicate = 0xFD01, KEY_3270_FieldMark = 0xFD02, KEY_3270_Right2 = 0xFD03, KEY_3270_Left2 = 0xFD04, KEY_3270_BackTab = 0xFD05, KEY_3270_EraseEOF = 0xFD06, KEY_3270_EraseInput = 0xFD07, KEY_3270_Reset = 0xFD08, KEY_3270_Quit = 0xFD09, KEY_3270_PA1 = 0xFD0A, KEY_3270_PA2 = 0xFD0B, KEY_3270_PA3 = 0xFD0C, KEY_3270_Test = 0xFD0D, KEY_3270_Attn = 0xFD0E, KEY_3270_CursorBlink = 0xFD0F, KEY_3270_AltCursor = 0xFD10, KEY_3270_KeyClick = 0xFD11, KEY_3270_Jump = 0xFD12, KEY_3270_Ident = 0xFD13, KEY_3270_Rule = 0xFD14, KEY_3270_Copy = 0xFD15, KEY_3270_Play = 0xFD16, KEY_3270_Setup = 0xFD17, KEY_3270_Record = 0xFD18, KEY_3270_ChangeScreen = 0xFD19, KEY_3270_DeleteWord = 0xFD1A, KEY_3270_ExSelect = 0xFD1B, KEY_3270_CursorSelect = 0xFD1C, KEY_3270_PrintScreen = 0xFD1D, KEY_3270_Enter = 0xFD1E, // Latin 1 KEY_space = 0x0020, KEY_exclam = 0x0021, KEY_quotedbl = 0x0022, KEY_numbersign = 0x0023, KEY_dollar = 0x0024, KEY_percent = 0x0025, KEY_ampersand = 0x0026, KEY_apostrophe = 0x0027, KEY_quoteright = 0x0027, KEY_parenleft = 0x0028, KEY_parenright = 0x0029, KEY_asterisk = 0x002A, KEY_plus = 0x002B, KEY_comma = 0x002C, KEY_minus = 0x002D, KEY_period = 0x002E, KEY_slash = 0x002F, KEY_0 = 0x0030, KEY_1 = 0x0031, KEY_2 = 0x0032, KEY_3 = 0x0033, KEY_4 = 0x0034, KEY_5 = 0x0035, KEY_6 = 0x0036, KEY_7 = 0x0037, KEY_8 = 0x0038, KEY_9 = 0x0039, KEY_colon = 0x003A, KEY_semicolon = 0x003B, KEY_less = 0x003C, KEY_equal = 0x003D, KEY_greater = 0x003E, KEY_question = 0x003F, KEY_at = 0x0040, KEY_A = 0x0041, KEY_B = 0x0042, KEY_C = 0x0043, KEY_D = 0x0044, KEY_E = 0x0045, KEY_F = 0x0046, KEY_G = 0x0047, KEY_H = 0x0048, KEY_I = 0x0049, KEY_J = 0x004A, KEY_K = 0x004B, KEY_L = 0x004C, KEY_M = 0x004D, KEY_N = 0x004E, KEY_O = 0x004F, KEY_P = 0x0050, KEY_Q = 0x0051, KEY_R = 0x0052, KEY_S = 0x0053, KEY_T = 0x0054, KEY_U = 0x0055, KEY_V = 0x0056, KEY_W = 0x0057, KEY_X = 0x0058, KEY_Y = 0x0059, KEY_Z = 0x005A, KEY_bracketleft = 0x005B, KEY_backslash = 0x005C, KEY_bracketright = 0x005D, KEY_asciicircum = 0x005E, KEY_underscore = 0x005F, KEY_grave = 0x0060, KEY_quoteleft = 0x0060, KEY_a = 0x0061, KEY_b = 0x0062, KEY_c = 0x0063, KEY_d = 0x0064, KEY_e = 0x0065, KEY_f = 0x0066, KEY_g = 0x0067, KEY_h = 0x0068, KEY_i = 0x0069, KEY_j = 0x006A, KEY_k = 0x006B, KEY_l = 0x006C, KEY_m = 0x006D, KEY_n = 0x006E, KEY_o = 0x006F, KEY_p = 0x0070, KEY_q = 0x0071, KEY_r = 0x0072, KEY_s = 0x0073, KEY_t = 0x0074, KEY_u = 0x0075, KEY_v = 0x0076, KEY_w = 0x0077, KEY_x = 0x0078, KEY_y = 0x0079, KEY_z = 0x007A, KEY_braceleft = 0x007B, KEY_bar = 0x007C, KEY_braceright = 0x007D, KEY_asciitilde = 0x007E, KEY_nobreakspace = 0x00A0, KEY_exclamdown = 0x00A1, KEY_cent = 0x00A2, KEY_sterling = 0x00A3, KEY_currency = 0x00A4, KEY_yen = 0x00A5, KEY_brokenbar = 0x00A6, KEY_section = 0x00A7, KEY_diaeresis = 0x00A8, KEY_copyright = 0x00A9, KEY_ordfeminine = 0x00AA, KEY_guillemotleft = 0x00AB, KEY_notsign = 0x00AC, KEY_hyphen = 0x00AD, KEY_registered = 0x00AE, KEY_macron = 0x00AF, KEY_degree = 0x00B0, KEY_plusminus = 0x00B1, KEY_twosuperior = 0x00B2, KEY_threesuperior = 0x00B3, KEY_acute = 0x00B4, KEY_mu = 0x00B5, KEY_paragraph = 0x00B6, KEY_periodcentered = 0x00B7, KEY_cedilla = 0x00B8, KEY_onesuperior = 0x00B9, KEY_masculine = 0x00BA, KEY_guillemotright = 0x00BB, KEY_onequarter = 0x00BC, KEY_onehalf = 0x00BD, KEY_threequarters = 0x00BE, KEY_questiondown = 0x00BF, KEY_Agrave = 0x00C0, KEY_Aacute = 0x00C1, KEY_Acircumflex = 0x00C2, KEY_Atilde = 0x00C3, KEY_Adiaeresis = 0x00C4, KEY_Aring = 0x00C5, KEY_AE = 0x00C6, KEY_Ccedilla = 0x00C7, KEY_Egrave = 0x00C8, KEY_Eacute = 0x00C9, KEY_Ecircumflex = 0x00CA, KEY_Ediaeresis = 0x00CB, KEY_Igrave = 0x00CC, KEY_Iacute = 0x00CD, KEY_Icircumflex = 0x00CE, KEY_Idiaeresis = 0x00CF, KEY_ETH = 0x00D0, KEY_Eth = 0x00D0, KEY_Ntilde = 0x00D1, KEY_Ograve = 0x00D2, KEY_Oacute = 0x00D3, KEY_Ocircumflex = 0x00D4, KEY_Otilde = 0x00D5, KEY_Odiaeresis = 0x00D6, KEY_multiply = 0x00D7, KEY_Ooblique = 0x00D8, KEY_Ugrave = 0x00D9, KEY_Uacute = 0x00DA, KEY_Ucircumflex = 0x00DB, KEY_Udiaeresis = 0x00DC, KEY_Yacute = 0x00DD, KEY_THORN = 0x00DE, KEY_Thorn = 0x00DE, KEY_ssharp = 0x00DF, KEY_agrave = 0x00E0, KEY_aacute = 0x00E1, KEY_acircumflex = 0x00E2, KEY_atilde = 0x00E3, KEY_adiaeresis = 0x00E4, KEY_aring = 0x00E5, KEY_ae = 0x00E6, KEY_ccedilla = 0x00E7, KEY_egrave = 0x00E8, KEY_eacute = 0x00E9, KEY_ecircumflex = 0x00EA, KEY_ediaeresis = 0x00EB, KEY_igrave = 0x00EC, KEY_iacute = 0x00ED, KEY_icircumflex = 0x00EE, KEY_idiaeresis = 0x00EF, KEY_eth = 0x00F0, KEY_ntilde = 0x00F1, KEY_ograve = 0x00F2, KEY_oacute = 0x00F3, KEY_ocircumflex = 0x00F4, KEY_otilde = 0x00F5, KEY_odiaeresis = 0x00F6, KEY_division = 0x00F7, KEY_oslash = 0x00F8, KEY_ugrave = 0x00F9, KEY_uacute = 0x00FA, KEY_ucircumflex = 0x00FB, KEY_udiaeresis = 0x00FC, KEY_yacute = 0x00FD, KEY_thorn = 0x00FE, KEY_ydiaeresis = 0x00FF, // Latin 2 KEY_Aogonek = 0x01A1, KEY_breve = 0x01A2, KEY_Lstroke = 0x01A3, KEY_Lcaron = 0x01A5, KEY_Sacute = 0x01A6, KEY_Scaron = 0x01A9, KEY_Scedilla = 0x01AA, KEY_Tcaron = 0x01AB, KEY_Zacute = 0x01AC, KEY_Zcaron = 0x01AE, KEY_Zabovedot = 0x01AF, KEY_aogonek = 0x01B1, KEY_ogonek = 0x01B2, KEY_lstroke = 0x01B3, KEY_lcaron = 0x01B5, KEY_sacute = 0x01B6, KEY_caron = 0x01B7, KEY_scaron = 0x01B9, KEY_scedilla = 0x01BA, KEY_tcaron = 0x01BB, KEY_zacute = 0x01BC, KEY_doubleacute = 0x01BD, KEY_zcaron = 0x01BE, KEY_zabovedot = 0x01BF, KEY_Racute = 0x01C0, KEY_Abreve = 0x01C3, KEY_Lacute = 0x01C5, KEY_Cacute = 0x01C6, KEY_Ccaron = 0x01C8, KEY_Eogonek = 0x01CA, KEY_Ecaron = 0x01CC, KEY_Dcaron = 0x01CF, KEY_Dstroke = 0x01D0, KEY_Nacute = 0x01D1, KEY_Ncaron = 0x01D2, KEY_Odoubleacute = 0x01D5, KEY_Rcaron = 0x01D8, KEY_Uring = 0x01D9, KEY_Udoubleacute = 0x01DB, KEY_Tcedilla = 0x01DE, KEY_racute = 0x01E0, KEY_abreve = 0x01E3, KEY_lacute = 0x01E5, KEY_cacute = 0x01E6, KEY_ccaron = 0x01E8, KEY_eogonek = 0x01EA, KEY_ecaron = 0x01EC, KEY_dcaron = 0x01EF, KEY_dstroke = 0x01F0, KEY_nacute = 0x01F1, KEY_ncaron = 0x01F2, KEY_odoubleacute = 0x01F5, KEY_udoubleacute = 0x01FB, KEY_rcaron = 0x01F8, KEY_uring = 0x01F9, KEY_tcedilla = 0x01FE, KEY_abovedot = 0x01FF, // Latin 3 KEY_Hstroke = 0x02A1, KEY_Hcircumflex = 0x02A6, KEY_Iabovedot = 0x02A9, KEY_Gbreve = 0x02AB, KEY_Jcircumflex = 0x02AC, KEY_hstroke = 0x02B1, KEY_hcircumflex = 0x02B6, KEY_idotless = 0x02B9, KEY_gbreve = 0x02BB, KEY_jcircumflex = 0x02BC, KEY_Cabovedot = 0x02C5, KEY_Ccircumflex = 0x02C6, KEY_Gabovedot = 0x02D5, KEY_Gcircumflex = 0x02D8, KEY_Ubreve = 0x02DD, KEY_Scircumflex = 0x02DE, KEY_cabovedot = 0x02E5, KEY_ccircumflex = 0x02E6, KEY_gabovedot = 0x02F5, KEY_gcircumflex = 0x02F8, KEY_ubreve = 0x02FD, KEY_scircumflex = 0x02FE, // Latin 4 KEY_kra = 0x03A2, KEY_kappa = 0x03A2, KEY_Rcedilla = 0x03A3, KEY_Itilde = 0x03A5, KEY_Lcedilla = 0x03A6, KEY_Emacron = 0x03AA, KEY_Gcedilla = 0x03AB, KEY_Tslash = 0x03AC, KEY_rcedilla = 0x03B3, KEY_itilde = 0x03B5, KEY_lcedilla = 0x03B6, KEY_emacron = 0x03BA, KEY_gcedilla = 0x03BB, KEY_tslash = 0x03BC, KEY_ENG = 0x03BD, KEY_eng = 0x03BF, KEY_Amacron = 0x03C0, KEY_Iogonek = 0x03C7, KEY_Eabovedot = 0x03CC, KEY_Imacron = 0x03CF, KEY_Ncedilla = 0x03D1, KEY_Omacron = 0x03D2, KEY_Kcedilla = 0x03D3, KEY_Uogonek = 0x03D9, KEY_Utilde = 0x03DD, KEY_Umacron = 0x03DE, KEY_amacron = 0x03E0, KEY_iogonek = 0x03E7, KEY_eabovedot = 0x03EC, KEY_imacron = 0x03EF, KEY_ncedilla = 0x03F1, KEY_omacron = 0x03F2, KEY_kcedilla = 0x03F3, KEY_uogonek = 0x03F9, KEY_utilde = 0x03FD, KEY_umacron = 0x03FE, // Katakana KEY_overline = 0x047E, KEY_kana_fullstop = 0x04A1, KEY_kana_openingbracket = 0x04A2, KEY_kana_closingbracket = 0x04A3, KEY_kana_comma = 0x04A4, KEY_kana_conjunctive = 0x04A5, KEY_kana_middledot = 0x04A5, KEY_kana_WO = 0x04A6, KEY_kana_a = 0x04A7, KEY_kana_i = 0x04A8, KEY_kana_u = 0x04A9, KEY_kana_e = 0x04AA, KEY_kana_o = 0x04AB, KEY_kana_ya = 0x04AC, KEY_kana_yu = 0x04AD, KEY_kana_yo = 0x04AE, KEY_kana_tsu = 0x04AF, KEY_kana_tu = 0x04AF, KEY_prolongedsound = 0x04B0, KEY_kana_A = 0x04B1, KEY_kana_I = 0x04B2, KEY_kana_U = 0x04B3, KEY_kana_E = 0x04B4, KEY_kana_O = 0x04B5, KEY_kana_KA = 0x04B6, KEY_kana_KI = 0x04B7, KEY_kana_KU = 0x04B8, KEY_kana_KE = 0x04B9, KEY_kana_KO = 0x04BA, KEY_kana_SA = 0x04BB, KEY_kana_SHI = 0x04BC, KEY_kana_SU = 0x04BD, KEY_kana_SE = 0x04BE, KEY_kana_SO = 0x04BF, KEY_kana_TA = 0x04C0, KEY_kana_CHI = 0x04C1, KEY_kana_TI = 0x04C1, KEY_kana_TSU = 0x04C2, KEY_kana_TU = 0x04C2, KEY_kana_TE = 0x04C3, KEY_kana_TO = 0x04C4, KEY_kana_NA = 0x04C5, KEY_kana_NI = 0x04C6, KEY_kana_NU = 0x04C7, KEY_kana_NE = 0x04C8, KEY_kana_NO = 0x04C9, KEY_kana_HA = 0x04CA, KEY_kana_HI = 0x04CB, KEY_kana_FU = 0x04CC, KEY_kana_HU = 0x04CC, KEY_kana_HE = 0x04CD, KEY_kana_HO = 0x04CE, KEY_kana_MA = 0x04CF, KEY_kana_MI = 0x04D0, KEY_kana_MU = 0x04D1, KEY_kana_ME = 0x04D2, KEY_kana_MO = 0x04D3, KEY_kana_YA = 0x04D4, KEY_kana_YU = 0x04D5, KEY_kana_YO = 0x04D6, KEY_kana_RA = 0x04D7, KEY_kana_RI = 0x04D8, KEY_kana_RU = 0x04D9, KEY_kana_RE = 0x04DA, KEY_kana_RO = 0x04DB, KEY_kana_WA = 0x04DC, KEY_kana_N = 0x04DD, KEY_voicedsound = 0x04DE, KEY_semivoicedsound = 0x04DF, KEY_kana_switch = 0x0FF7, // Arabic KEY_Arabic_comma = 0x05AC, KEY_Arabic_semicolon = 0x05BB, KEY_Arabic_question_mark = 0x05BF, KEY_Arabic_hamza = 0x05C1, KEY_Arabic_maddaonalef = 0x05C2, KEY_Arabic_hamzaonalef = 0x05C3, KEY_Arabic_hamzaonwaw = 0x05C4, KEY_Arabic_hamzaunderalef = 0x05C5, KEY_Arabic_hamzaonyeh = 0x05C6, KEY_Arabic_alef = 0x05C7, KEY_Arabic_beh = 0x05C8, KEY_Arabic_tehmarbuta = 0x05C9, KEY_Arabic_teh = 0x05CA, KEY_Arabic_theh = 0x05CB, KEY_Arabic_jeem = 0x05CC, KEY_Arabic_hah = 0x05CD, KEY_Arabic_khah = 0x05CE, KEY_Arabic_dal = 0x05CF, KEY_Arabic_thal = 0x05D0, KEY_Arabic_ra = 0x05D1, KEY_Arabic_zain = 0x05D2, KEY_Arabic_seen = 0x05D3, KEY_Arabic_sheen = 0x05D4, KEY_Arabic_sad = 0x05D5, KEY_Arabic_dad = 0x05D6, KEY_Arabic_tah = 0x05D7, KEY_Arabic_zah = 0x05D8, KEY_Arabic_ain = 0x05D9, KEY_Arabic_ghain = 0x05DA, KEY_Arabic_tatweel = 0x05E0, KEY_Arabic_feh = 0x05E1, KEY_Arabic_qaf = 0x05E2, KEY_Arabic_kaf = 0x05E3, KEY_Arabic_lam = 0x05E4, KEY_Arabic_meem = 0x05E5, KEY_Arabic_noon = 0x05E6, KEY_Arabic_ha = 0x05E7, KEY_Arabic_heh = 0x05E7, KEY_Arabic_waw = 0x05E8, KEY_Arabic_alefmaksura = 0x05E9, KEY_Arabic_yeh = 0x05EA, KEY_Arabic_fathatan = 0x05EB, KEY_Arabic_dammatan = 0x05EC, KEY_Arabic_kasratan = 0x05ED, KEY_Arabic_fatha = 0x05EE, KEY_Arabic_damma = 0x05EF, KEY_Arabic_kasra = 0x05F0, KEY_Arabic_shadda = 0x05F1, KEY_Arabic_sukun = 0x05F2, KEY_Arabic_switch = 0xFF7E, // Cyrillic KEY_Serbian_dje = 0x06A1, KEY_Macedonia_gje = 0x06A2, KEY_Cyrillic_io = 0x06A3, KEY_Ukrainian_ie = 0x06A4, KEY_Ukranian_je = 0x06A4, KEY_Macedonia_dse = 0x06A5, KEY_Ukrainian_i = 0x06A6, KEY_Ukranian_i = 0x06A6, KEY_Ukrainian_yi = 0x06A7, KEY_Ukranian_yi = 0x06A7, KEY_Cyrillic_je = 0x06A8, KEY_Serbian_je = 0x06A8, KEY_Cyrillic_lje = 0x06A9, KEY_Serbian_lje = 0x06A9, KEY_Cyrillic_nje = 0x06AA, KEY_Serbian_nje = 0x06AA, KEY_Serbian_tshe = 0x06AB, KEY_Macedonia_kje = 0x06AC, KEY_Byelorussian_shortu = 0x06AE, KEY_Cyrillic_dzhe = 0x06AF, KEY_Serbian_dze = 0x06AF, KEY_numerosign = 0x06B0, KEY_Serbian_DJE = 0x06B1, KEY_Macedonia_GJE = 0x06B2, KEY_Cyrillic_IO = 0x06B3, KEY_Ukrainian_IE = 0x06B4, KEY_Ukranian_JE = 0x06B4, KEY_Macedonia_DSE = 0x06B5, KEY_Ukrainian_I = 0x06B6, KEY_Ukranian_I = 0x06B6, KEY_Ukrainian_YI = 0x06B7, KEY_Ukranian_YI = 0x06B7, KEY_Cyrillic_JE = 0x06B8, KEY_Serbian_JE = 0x06B8, KEY_Cyrillic_LJE = 0x06B9, KEY_Serbian_LJE = 0x06B9, KEY_Cyrillic_NJE = 0x06BA, KEY_Serbian_NJE = 0x06BA, KEY_Serbian_TSHE = 0x06BB, KEY_Macedonia_KJE = 0x06BC, KEY_Byelorussian_SHORTU = 0x06BE, KEY_Cyrillic_DZHE = 0x06BF, KEY_Serbian_DZE = 0x06BF, KEY_Cyrillic_yu = 0x06C0, KEY_Cyrillic_a = 0x06C1, KEY_Cyrillic_be = 0x06C2, KEY_Cyrillic_tse = 0x06C3, KEY_Cyrillic_de = 0x06C4, KEY_Cyrillic_ie = 0x06C5, KEY_Cyrillic_ef = 0x06C6, KEY_Cyrillic_ghe = 0x06C7, KEY_Cyrillic_ha = 0x06C8, KEY_Cyrillic_i = 0x06C9, KEY_Cyrillic_shorti = 0x06CA, KEY_Cyrillic_ka = 0x06CB, KEY_Cyrillic_el = 0x06CC, KEY_Cyrillic_em = 0x06CD, KEY_Cyrillic_en = 0x06CE, KEY_Cyrillic_o = 0x06CF, KEY_Cyrillic_pe = 0x06D0, KEY_Cyrillic_ya = 0x06D1, KEY_Cyrillic_er = 0x06D2, KEY_Cyrillic_es = 0x06D3, KEY_Cyrillic_te = 0x06D4, KEY_Cyrillic_u = 0x06D5, KEY_Cyrillic_zhe = 0x06D6, KEY_Cyrillic_ve = 0x06D7, KEY_Cyrillic_softsign = 0x06D8, KEY_Cyrillic_yeru = 0x06D9, KEY_Cyrillic_ze = 0x06DA, KEY_Cyrillic_sha = 0x06DB, KEY_Cyrillic_e = 0x06DC, KEY_Cyrillic_shcha = 0x06DD, KEY_Cyrillic_che = 0x06DE, KEY_Cyrillic_hardsign = 0x06DF, KEY_Cyrillic_YU = 0x06E0, KEY_Cyrillic_A = 0x06E1, KEY_Cyrillic_BE = 0x06E2, KEY_Cyrillic_TSE = 0x06E3, KEY_Cyrillic_DE = 0x06E4, KEY_Cyrillic_IE = 0x06E5, KEY_Cyrillic_EF = 0x06E6, KEY_Cyrillic_GHE = 0x06E7, KEY_Cyrillic_HA = 0x06E8, KEY_Cyrillic_I = 0x06E9, KEY_Cyrillic_SHORTI = 0x06EA, KEY_Cyrillic_KA = 0x06EB, KEY_Cyrillic_EL = 0x06EC, KEY_Cyrillic_EM = 0x06ED, KEY_Cyrillic_EN = 0x06EE, KEY_Cyrillic_O = 0x06EF, KEY_Cyrillic_PE = 0x06F0, KEY_Cyrillic_YA = 0x06F1, KEY_Cyrillic_ER = 0x06F2, KEY_Cyrillic_ES = 0x06F3, KEY_Cyrillic_TE = 0x06F4, KEY_Cyrillic_U = 0x06F5, KEY_Cyrillic_ZHE = 0x06F6, KEY_Cyrillic_VE = 0x06F7, KEY_Cyrillic_SOFTSIGN = 0x06F8, KEY_Cyrillic_YERU = 0x06F9, KEY_Cyrillic_ZE = 0x06FA, KEY_Cyrillic_SHA = 0x06FB, KEY_Cyrillic_E = 0x06FC, KEY_Cyrillic_SHCHA = 0x06FD, KEY_Cyrillic_CHE = 0x06FE, KEY_Cyrillic_HARDSIGN = 0x06FF, // Greek KEY_Greek_ALPHAaccent = 0x07A1, KEY_Greek_EPSILONaccent = 0x07A2, KEY_Greek_ETAaccent = 0x07A3, KEY_Greek_IOTAaccent = 0x07A4, KEY_Greek_IOTAdiaeresis = 0x07A5, KEY_Greek_OMICRONaccent = 0x07A7, KEY_Greek_UPSILONaccent = 0x07A8, KEY_Greek_UPSILONdieresis = 0x07A9, KEY_Greek_OMEGAaccent = 0x07AB, KEY_Greek_accentdieresis = 0x07AE, KEY_Greek_horizbar = 0x07AF, KEY_Greek_alphaaccent = 0x07B1, KEY_Greek_epsilonaccent = 0x07B2, KEY_Greek_etaaccent = 0x07B3, KEY_Greek_iotaaccent = 0x07B4, KEY_Greek_iotadieresis = 0x07B5, KEY_Greek_iotaaccentdieresis = 0x07B6, KEY_Greek_omicronaccent = 0x07B7, KEY_Greek_upsilonaccent = 0x07B8, KEY_Greek_upsilondieresis = 0x07B9, KEY_Greek_upsilonaccentdieresis = 0x07BA, KEY_Greek_omegaaccent = 0x07BB, KEY_Greek_ALPHA = 0x07C1, KEY_Greek_BETA = 0x07C2, KEY_Greek_GAMMA = 0x07C3, KEY_Greek_DELTA = 0x07C4, KEY_Greek_EPSILON = 0x07C5, KEY_Greek_ZETA = 0x07C6, KEY_Greek_ETA = 0x07C7, KEY_Greek_THETA = 0x07C8, KEY_Greek_IOTA = 0x07C9, KEY_Greek_KAPPA = 0x07CA, KEY_Greek_LAMDA = 0x07CB, KEY_Greek_LAMBDA = 0x07CB, KEY_Greek_MU = 0x07CC, KEY_Greek_NU = 0x07CD, KEY_Greek_XI = 0x07CE, KEY_Greek_OMICRON = 0x07CF, KEY_Greek_PI = 0x07D0, KEY_Greek_RHO = 0x07D1, KEY_Greek_SIGMA = 0x07D2, KEY_Greek_TAU = 0x07D4, KEY_Greek_UPSILON = 0x07D5, KEY_Greek_PHI = 0x07D6, KEY_Greek_CHI = 0x07D7, KEY_Greek_PSI = 0x07D8, KEY_Greek_OMEGA = 0x07D9, KEY_Greek_alpha = 0x07E1, KEY_Greek_beta = 0x07E2, KEY_Greek_gamma = 0x07E3, KEY_Greek_delta = 0x07E4, KEY_Greek_epsilon = 0x07E5, KEY_Greek_zeta = 0x07E6, KEY_Greek_eta = 0x07E7, KEY_Greek_theta = 0x07E8, KEY_Greek_iota = 0x07E9, KEY_Greek_kappa = 0x07EA, KEY_Greek_lamda = 0x07EB, KEY_Greek_lambda = 0x07EB, KEY_Greek_mu = 0x07EC, KEY_Greek_nu = 0x07ED, KEY_Greek_xi = 0x07EE, KEY_Greek_omicron = 0x07EF, KEY_Greek_pi = 0x07F0, KEY_Greek_rho = 0x07F1, KEY_Greek_sigma = 0x07F2, KEY_Greek_finalsmallsigma = 0x07F3, KEY_Greek_tau = 0x07F4, KEY_Greek_upsilon = 0x07F5, KEY_Greek_phi = 0x07F6, KEY_Greek_chi = 0x07F7, KEY_Greek_psi = 0x07F8, KEY_Greek_omega = 0x07F9, KEY_Greek_switch = 0xFF7E, // Technical KEY_leftradical = 0x08A1, KEY_topleftradical = 0x08A2, KEY_horizconnector = 0x08A3, KEY_topintegral = 0x08A4, KEY_botintegral = 0x08A5, KEY_vertconnector = 0x08A6, KEY_topleftsqbracket = 0x08A7, KEY_botleftsqbracket = 0x08A8, KEY_toprightsqbracket = 0x08A9, KEY_botrightsqbracket = 0x08AA, KEY_topleftparens = 0x08AB, KEY_botleftparens = 0x08AC, KEY_toprightparens = 0x08AD, KEY_botrightparens = 0x08AE, KEY_leftmiddlecurlybrace = 0x08AF, KEY_rightmiddlecurlybrace = 0x08B0, KEY_topleftsummation = 0x08B1, KEY_botleftsummation = 0x08B2, KEY_topvertsummationconnector = 0x08B3, KEY_botvertsummationconnector = 0x08B4, KEY_toprightsummation = 0x08B5, KEY_botrightsummation = 0x08B6, KEY_rightmiddlesummation = 0x08B7, KEY_lessthanequal = 0x08BC, KEY_notequal = 0x08BD, KEY_greaterthanequal = 0x08BE, KEY_integral = 0x08BF, KEY_therefore = 0x08C0, KEY_variation = 0x08C1, KEY_infinity = 0x08C2, KEY_nabla = 0x08C5, KEY_approximate = 0x08C8, KEY_similarequal = 0x08C9, KEY_ifonlyif = 0x08CD, KEY_implies = 0x08CE, KEY_identical = 0x08CF, KEY_radical = 0x08D6, KEY_includedin = 0x08DA, KEY_includes = 0x08DB, KEY_intersection = 0x08DC, KEY_union = 0x08DD, KEY_logicaland = 0x08DE, KEY_logicalor = 0x08DF, KEY_partialderivative = 0x08EF, KEY_function = 0x08F6, KEY_leftarrow = 0x08FB, KEY_uparrow = 0x08FC, KEY_rightarrow = 0x08FD, KEY_downarrow = 0x08FE, // Special KEY_blank = 0x09DF, KEY_soliddiamond = 0x09E0, KEY_checkerboard = 0x09E1, KEY_ht = 0x09E2, KEY_ff = 0x09E3, KEY_cr = 0x09E4, KEY_lf = 0x09E5, KEY_nl = 0x09E8, KEY_vt = 0x09E9, KEY_lowrightcorner = 0x09EA, KEY_uprightcorner = 0x09EB, KEY_upleftcorner = 0x09EC, KEY_lowleftcorner = 0x09ED, KEY_crossinglines = 0x09EE, KEY_horizlinescan1 = 0x09EF, KEY_horizlinescan3 = 0x09F0, KEY_horizlinescan5 = 0x09F1, KEY_horizlinescan7 = 0x09F2, KEY_horizlinescan9 = 0x09F3, KEY_leftt = 0x09F4, KEY_rightt = 0x09F5, KEY_bott = 0x09F6, KEY_topt = 0x09F7, KEY_vertbar = 0x09F8, // Publishing KEY_emspace = 0x0AA1, KEY_enspace = 0x0AA2, KEY_em3space = 0x0AA3, KEY_em4space = 0x0AA4, KEY_digitspace = 0x0AA5, KEY_punctspace = 0x0AA6, KEY_thinspace = 0x0AA7, KEY_hairspace = 0x0AA8, KEY_emdash = 0x0AA9, KEY_endash = 0x0AAA, KEY_signifblank = 0x0AAC, KEY_ellipsis = 0x0AAE, KEY_doubbaselinedot = 0x0AAF, KEY_onethird = 0x0AB0, KEY_twothirds = 0x0AB1, KEY_onefifth = 0x0AB2, KEY_twofifths = 0x0AB3, KEY_threefifths = 0x0AB4, KEY_fourfifths = 0x0AB5, KEY_onesixth = 0x0AB6, KEY_fivesixths = 0x0AB7, KEY_careof = 0x0AB8, KEY_figdash = 0x0ABB, KEY_leftanglebracket = 0x0ABC, KEY_decimalpoint = 0x0ABD, KEY_rightanglebracket = 0x0ABE, KEY_marker = 0x0ABF, KEY_oneeighth = 0x0AC3, KEY_threeeighths = 0x0AC4, KEY_fiveeighths = 0x0AC5, KEY_seveneighths = 0x0AC6, KEY_trademark = 0x0AC9, KEY_signaturemark = 0x0ACA, KEY_trademarkincircle = 0x0ACB, KEY_leftopentriangle = 0x0ACC, KEY_rightopentriangle = 0x0ACD, KEY_emopencircle = 0x0ACE, KEY_emopenrectangle = 0x0ACF, KEY_leftsinglequotemark = 0x0AD0, KEY_rightsinglequotemark = 0x0AD1, KEY_leftdoublequotemark = 0x0AD2, KEY_rightdoublequotemark = 0x0AD3, KEY_prescription = 0x0AD4, KEY_minutes = 0x0AD6, KEY_seconds = 0x0AD7, KEY_latincross = 0x0AD9, KEY_hexagram = 0x0ADA, KEY_filledrectbullet = 0x0ADB, KEY_filledlefttribullet = 0x0ADC, KEY_filledrighttribullet = 0x0ADD, KEY_emfilledcircle = 0x0ADE, KEY_emfilledrect = 0x0ADF, KEY_enopencircbullet = 0x0AE0, KEY_enopensquarebullet = 0x0AE1, KEY_openrectbullet = 0x0AE2, KEY_opentribulletup = 0x0AE3, KEY_opentribulletdown = 0x0AE4, KEY_openstar = 0x0AE5, KEY_enfilledcircbullet = 0x0AE6, KEY_enfilledsqbullet = 0x0AE7, KEY_filledtribulletup = 0x0AE8, KEY_filledtribulletdown = 0x0AE9, KEY_leftpointer = 0x0AEA, KEY_rightpointer = 0x0AEB, KEY_club = 0x0AEC, KEY_diamond = 0x0AED, KEY_heart = 0x0AEE, KEY_maltesecross = 0x0AF0, KEY_dagger = 0x0AF1, KEY_doubledagger = 0x0AF2, KEY_checkmark = 0x0AF3, KEY_ballotcross = 0x0AF4, KEY_musicalsharp = 0x0AF5, KEY_musicalflat = 0x0AF6, KEY_malesymbol = 0x0AF7, KEY_femalesymbol = 0x0AF8, KEY_telephone = 0x0AF9, KEY_telephonerecorder = 0x0AFA, KEY_phonographcopyright = 0x0AFB, KEY_caret = 0x0AFC, KEY_singlelowquotemark = 0x0AFD, KEY_doublelowquotemark = 0x0AFE, KEY_cursor = 0x0AFF, // APL KEY_leftcaret = 0x0BA3, KEY_rightcaret = 0x0BA6, KEY_downcaret = 0x0BA8, KEY_upcaret = 0x0BA9, KEY_overbar = 0x0BC0, KEY_downtack = 0x0BC2, KEY_upshoe = 0x0BC3, KEY_downstile = 0x0BC4, KEY_underbar = 0x0BC6, KEY_jot = 0x0BCA, KEY_quad = 0x0BCC, KEY_uptack = 0x0BCE, KEY_circle = 0x0BCF, KEY_upstile = 0x0BD3, KEY_downshoe = 0x0BD6, KEY_rightshoe = 0x0BD8, KEY_leftshoe = 0x0BDA, KEY_lefttack = 0x0BDC, KEY_righttack = 0x0BFC, // Hebrew KEY_hebrew_doublelowline = 0x0CDF, KEY_hebrew_aleph = 0x0CE0, KEY_hebrew_bet = 0x0CE1, KEY_hebrew_beth = 0x0CE1, KEY_hebrew_gimel = 0x0CE2, KEY_hebrew_gimmel = 0x0CE2, KEY_hebrew_dalet = 0x0CE3, KEY_hebrew_daleth = 0x0CE3, KEY_hebrew_he = 0x0CE4, KEY_hebrew_waw = 0x0CE5, KEY_hebrew_zain = 0x0CE6, KEY_hebrew_zayin = 0x0CE6, KEY_hebrew_chet = 0x0CE7, KEY_hebrew_het = 0x0CE7, KEY_hebrew_tet = 0x0CE8, KEY_hebrew_teth = 0x0CE8, KEY_hebrew_yod = 0x0CE9, KEY_hebrew_finalkaph = 0x0CEA, KEY_hebrew_kaph = 0x0CEB, KEY_hebrew_lamed = 0x0CEC, KEY_hebrew_finalmem = 0x0CED, KEY_hebrew_mem = 0x0CEE, KEY_hebrew_finalnun = 0x0CEF, KEY_hebrew_nun = 0x0CF0, KEY_hebrew_samech = 0x0CF1, KEY_hebrew_samekh = 0x0CF1, KEY_hebrew_ayin = 0x0CF2, KEY_hebrew_finalpe = 0x0CF3, KEY_hebrew_pe = 0x0CF4, KEY_hebrew_finalzade = 0x0CF5, KEY_hebrew_finalzadi = 0x0CF5, KEY_hebrew_zade = 0x0CF6, KEY_hebrew_zadi = 0x0CF6, KEY_hebrew_qoph = 0x0CF7, KEY_hebrew_kuf = 0x0CF7, KEY_hebrew_resh = 0x0CF8, KEY_hebrew_shin = 0x0CF9, KEY_hebrew_taw = 0x0CFA, KEY_hebrew_taf = 0x0CFA, KEY_Hebrew_switch = 0xFF7E, // Thai KEY_Thai_kokai = 0x0DA1, KEY_Thai_khokhai = 0x0DA2, KEY_Thai_khokhuat = 0x0DA3, KEY_Thai_khokhwai = 0x0DA4, KEY_Thai_khokhon = 0x0DA5, KEY_Thai_khorakhang = 0x0DA6, KEY_Thai_ngongu = 0x0DA7, KEY_Thai_chochan = 0x0DA8, KEY_Thai_choching = 0x0DA9, KEY_Thai_chochang = 0x0DAA, KEY_Thai_soso = 0x0DAB, KEY_Thai_chochoe = 0x0DAC, KEY_Thai_yoying = 0x0DAD, KEY_Thai_dochada = 0x0DAE, KEY_Thai_topatak = 0x0DAF, KEY_Thai_thothan = 0x0DB0, KEY_Thai_thonangmontho = 0x0DB1, KEY_Thai_thophuthao = 0x0DB2, KEY_Thai_nonen = 0x0DB3, KEY_Thai_dodek = 0x0DB4, KEY_Thai_totao = 0x0DB5, KEY_Thai_thothung = 0x0DB6, KEY_Thai_thothahan = 0x0DB7, KEY_Thai_thothong = 0x0DB8, KEY_Thai_nonu = 0x0DB9, KEY_Thai_bobaimai = 0x0DBA, KEY_Thai_popla = 0x0DBB, KEY_Thai_phophung = 0x0DBC, KEY_Thai_fofa = 0x0DBD, KEY_Thai_phophan = 0x0DBE, KEY_Thai_fofan = 0x0DBF, KEY_Thai_phosamphao = 0x0DC0, KEY_Thai_moma = 0x0DC1, KEY_Thai_yoyak = 0x0DC2, KEY_Thai_rorua = 0x0DC3, KEY_Thai_ru = 0x0DC4, KEY_Thai_loling = 0x0DC5, KEY_Thai_lu = 0x0DC6, KEY_Thai_wowaen = 0x0DC7, KEY_Thai_sosala = 0x0DC8, KEY_Thai_sorusi = 0x0DC9, KEY_Thai_sosua = 0x0DCA, KEY_Thai_hohip = 0x0DCB, KEY_Thai_lochula = 0x0DCC, KEY_Thai_oang = 0x0DCD, KEY_Thai_honokhuk = 0x0DCE, KEY_Thai_paiyannoi = 0x0DCF, KEY_Thai_saraa = 0x0DD0, KEY_Thai_maihanakat = 0x0DD1, KEY_Thai_saraaa = 0x0DD2, KEY_Thai_saraam = 0x0DD3, KEY_Thai_sarai = 0x0DD4, KEY_Thai_saraii = 0x0DD5, KEY_Thai_saraue = 0x0DD6, KEY_Thai_sarauee = 0x0DD7, KEY_Thai_sarau = 0x0DD8, KEY_Thai_sarauu = 0x0DD9, KEY_Thai_phinthu = 0x0DDA, KEY_Thai_maihanakat_maitho = 0x0DDE, KEY_Thai_baht = 0x0DDF, KEY_Thai_sarae = 0x0DE0, KEY_Thai_saraae = 0x0DE1, KEY_Thai_sarao = 0x0DE2, KEY_Thai_saraaimaimuan = 0x0DE3, KEY_Thai_saraaimaimalai = 0x0DE4, KEY_Thai_lakkhangyao = 0x0DE5, KEY_Thai_maiyamok = 0x0DE6, KEY_Thai_maitaikhu = 0x0DE7, KEY_Thai_maiek = 0x0DE8, KEY_Thai_maitho = 0x0DE9, KEY_Thai_maitri = 0x0DEA, KEY_Thai_maichattawa = 0x0DEB, KEY_Thai_thanthakhat = 0x0DEC, KEY_Thai_nikhahit = 0x0DED, KEY_Thai_leksun = 0x0DF0, KEY_Thai_leknung = 0x0DF1, KEY_Thai_leksong = 0x0DF2, KEY_Thai_leksam = 0x0DF3, KEY_Thai_leksi = 0x0DF4, KEY_Thai_lekha = 0x0DF5, KEY_Thai_lekhok = 0x0DF6, KEY_Thai_lekchet = 0x0DF7, KEY_Thai_lekpaet = 0x0DF8, KEY_Thai_lekkao = 0x0DF9, // Korean KEY_Hangul = 0xFF31, KEY_Hangul_Start = 0xFF32, KEY_Hangul_End = 0xFF33, KEY_Hangul_Hanja = 0xFF34, KEY_Hangul_Jamo = 0xFF35, KEY_Hangul_Romaja = 0xFF36, KEY_Hangul_Codeinput = 0xFF37, KEY_Hangul_Jeonja = 0xFF38, KEY_Hangul_Banja = 0xFF39, KEY_Hangul_PreHanja = 0xFF3A, KEY_Hangul_PostHanja = 0xFF3B, KEY_Hangul_SingleCandidate = 0xFF3C, KEY_Hangul_MultipleCandidate = 0xFF3D, KEY_Hangul_PreviousCandidate = 0xFF3E, KEY_Hangul_Special = 0xFF3F, KEY_Hangul_switch = 0xFF7E, KEY_Hangul_Kiyeog = 0x0EA1, KEY_Hangul_SsangKiyeog = 0x0EA2, KEY_Hangul_KiyeogSios = 0x0EA3, KEY_Hangul_Nieun = 0x0EA4, KEY_Hangul_NieunJieuj = 0x0EA5, KEY_Hangul_NieunHieuh = 0x0EA6, KEY_Hangul_Dikeud = 0x0EA7, KEY_Hangul_SsangDikeud = 0x0EA8, KEY_Hangul_Rieul = 0x0EA9, KEY_Hangul_RieulKiyeog = 0x0EAA, KEY_Hangul_RieulMieum = 0x0EAB, KEY_Hangul_RieulPieub = 0x0EAC, KEY_Hangul_RieulSios = 0x0EAD, KEY_Hangul_RieulTieut = 0x0EAE, KEY_Hangul_RieulPhieuf = 0x0EAF, KEY_Hangul_RieulHieuh = 0x0EB0, KEY_Hangul_Mieum = 0x0EB1, KEY_Hangul_Pieub = 0x0EB2, KEY_Hangul_SsangPieub = 0x0EB3, KEY_Hangul_PieubSios = 0x0EB4, KEY_Hangul_Sios = 0x0EB5, KEY_Hangul_SsangSios = 0x0EB6, KEY_Hangul_Ieung = 0x0EB7, KEY_Hangul_Jieuj = 0x0EB8, KEY_Hangul_SsangJieuj = 0x0EB9, KEY_Hangul_Cieuc = 0x0EBA, KEY_Hangul_Khieuq = 0x0EBB, KEY_Hangul_Tieut = 0x0EBC, KEY_Hangul_Phieuf = 0x0EBD, KEY_Hangul_Hieuh = 0x0EBE, KEY_Hangul_A = 0x0EBF, KEY_Hangul_AE = 0x0EC0, KEY_Hangul_YA = 0x0EC1, KEY_Hangul_YAE = 0x0EC2, KEY_Hangul_EO = 0x0EC3, KEY_Hangul_E = 0x0EC4, KEY_Hangul_YEO = 0x0EC5, KEY_Hangul_YE = 0x0EC6, KEY_Hangul_O = 0x0EC7, KEY_Hangul_WA = 0x0EC8, KEY_Hangul_WAE = 0x0EC9, KEY_Hangul_OE = 0x0ECA, KEY_Hangul_YO = 0x0ECB, KEY_Hangul_U = 0x0ECC, KEY_Hangul_WEO = 0x0ECD, KEY_Hangul_WE = 0x0ECE, KEY_Hangul_WI = 0x0ECF, KEY_Hangul_YU = 0x0ED0, KEY_Hangul_EU = 0x0ED1, KEY_Hangul_YI = 0x0ED2, KEY_Hangul_I = 0x0ED3, KEY_Hangul_J_Kiyeog = 0x0ED4, KEY_Hangul_J_SsangKiyeog = 0x0ED5, KEY_Hangul_J_KiyeogSios = 0x0ED6, KEY_Hangul_J_Nieun = 0x0ED7, KEY_Hangul_J_NieunJieuj = 0x0ED8, KEY_Hangul_J_NieunHieuh = 0x0ED9, KEY_Hangul_J_Dikeud = 0x0EDA, KEY_Hangul_J_Rieul = 0x0EDB, KEY_Hangul_J_RieulKiyeog = 0x0EDC, KEY_Hangul_J_RieulMieum = 0x0EDD, KEY_Hangul_J_RieulPieub = 0x0EDE, KEY_Hangul_J_RieulSios = 0x0EDF, KEY_Hangul_J_RieulTieut = 0x0EE0, KEY_Hangul_J_RieulPhieuf = 0x0EE1, KEY_Hangul_J_RieulHieuh = 0x0EE2, KEY_Hangul_J_Mieum = 0x0EE3, KEY_Hangul_J_Pieub = 0x0EE4, KEY_Hangul_J_PieubSios = 0x0EE5, KEY_Hangul_J_Sios = 0x0EE6, KEY_Hangul_J_SsangSios = 0x0EE7, KEY_Hangul_J_Ieung = 0x0EE8, KEY_Hangul_J_Jieuj = 0x0EE9, KEY_Hangul_J_Cieuc = 0x0EEA, KEY_Hangul_J_Khieuq = 0x0EEB, KEY_Hangul_J_Tieut = 0x0EEC, KEY_Hangul_J_Phieuf = 0x0EED, KEY_Hangul_J_Hieuh = 0x0EEE, KEY_Hangul_RieulYeorinHieuh = 0x0EEF, KEY_Hangul_SunkyeongeumMieum = 0x0EF0, KEY_Hangul_SunkyeongeumPieub = 0x0EF1, KEY_Hangul_PanSios = 0x0EF2, KEY_Hangul_KkogjiDalrinIeung = 0x0EF3, KEY_Hangul_SunkyeongeumPhieuf = 0x0EF4, KEY_Hangul_YeorinHieuh = 0x0EF5, KEY_Hangul_AraeA = 0x0EF6, KEY_Hangul_AraeAE = 0x0EF7, KEY_Hangul_J_PanSios = 0x0EF8, KEY_Hangul_J_KkogjiDalrinIeung = 0x0EF9, KEY_Hangul_J_YeorinHieuh = 0x0EFA, KEY_Korean_Won = 0x0EFF }; } #ifndef FX_NO_GLOBAL_NAMESPACE using namespace FX; #endif #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/fxmath.h000066400000000000000000000623171455751074500221320ustar00rootroot00000000000000/******************************************************************************** * * * M a t h F u n c t i o n s * * * ********************************************************************************* * Copyright (C) 2015,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXMATH_H #define FXMATH_H // Remove macros #undef fabs #undef fabsf #undef fmod #undef fmodf #undef ceil #undef ceilf #undef floor #undef floorf #undef round #undef roundf #undef trunc #undef truncf #undef nearbyint #undef nearbyintf #undef rint #undef rintf #undef sin #undef sinf #undef cos #undef cosf #undef tan #undef tanf #undef asin #undef asinf #undef acos #undef acosf #undef atan #undef atanf #undef atan2 #undef atan2f #undef sincos #undef sincosf #undef sinh #undef sinhf #undef cosh #undef coshf #undef tanh #undef tanhf #undef asinh #undef asinhf #undef acosh #undef acoshf #undef atanh #undef atanhf #undef pow #undef powf #undef pow10 #undef pow10f #undef exp #undef expf #undef expm1 #undef expm1f #undef exp2 #undef exp2f #undef exp10 #undef exp10f #undef log #undef logf #undef log1p #undef log1pf #undef log2 #undef log2f #undef log10 #undef log10f #undef sqrt #undef sqrtf #undef cbrt #undef cbrtf #undef sqr #undef sqrf #undef cub #undef cubf #undef max #undef min #undef fmax #undef fmaxf #undef fmin #undef fminf #undef copysign #undef copysignf #undef hypot #undef hypotf // Switch on remedial math on Windows with VC++ #if defined(WIN32) && (defined(_MSC_VER) || defined(__MINGW32__)) #define NO_CEILF #define NO_FLOORF #define NO_ROUNDF #define NO_ROUND #define NO_TRUNCF #define NO_TRUNC #define NO_NEARBYINTF #define NO_NEARBYINT #define NO_RINTF #define NO_RINT #define NO_EXPM1F #define NO_EXPM1 #define NO_EXP2F #define NO_EXP2 #define NO_EXP10F #define NO_EXP10 #define NO_POW10F #define NO_POW10 #define NO_LOG1PF #define NO_LOG1P #define NO_LOG2F #define NO_LOG2 #define NO_CBRTF #define NO_CBRT #define NO_SINHF #define NO_SINH #define NO_COSHF #define NO_COSH #define NO_TANHF #define NO_TANH #define NO_ASINHF #define NO_ASINH #define NO_ACOSHF #define NO_ACOSH #define NO_ATANHF #define NO_ATANH #define NO_FMAXF #define NO_FMAX #define NO_FMINF #define NO_FMIN #define NO_COPYSIGNF #define NO_COPYSIGN #define NO_HYPOTF #define NO_HYPOT #define NO_FDIMF #define NO_FDIM #define NO_SINCOS #define NO_SINCOSF #define NO_LRINT #define NO_LRINTF #endif // Systems below are missing these functions #if defined(__sun__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__APPLE__) #define NO_EXP10F #define NO_EXP10 #endif // Apple is missing sincos #if defined(__APPLE__) #define NO_SINCOS #define NO_SINCOSF #endif namespace FX { /********************************* Constants *********************************/ /// Pi const FXdouble PI=3.1415926535897932384626433833; /// Euler constant const FXdouble EULER=2.7182818284590452353602874713; /// Multiplier for degrees to radians const FXdouble DTOR=0.0174532925199432957692369077; /// Multiplier for radians to degrees const FXdouble RTOD=57.295779513082320876798154814; /// Feigenbaum constant const FXdouble FEIGENBAUM=4.6692016091029906718532038215; /********************************* Functions *********************************/ // FOX math functions live here namespace Math { /// Sign of single precision float point number (0..1) extern FXAPI FXint fpSign(FXfloat x); /// Sign of double precision float point number (0..1) extern FXAPI FXlong fpSign(FXdouble x); /// Signed exponent of single precision float point number (-126..128) extern FXAPI FXint fpExponent(FXfloat x); /// Signed exponent of double precision float point number (-1022..1024) extern FXAPI FXlong fpExponent(FXdouble x); /// Mantissa of single precision float point number (including hidden bit) extern FXAPI FXint fpMantissa(FXfloat x); /// Mantissa of double precision float point number (including hidden bit) extern FXAPI FXlong fpMantissa(FXdouble x); /// Single precision floating point number is finite extern FXAPI FXbool fpFinite(FXfloat x); /// Double precision floating point number is finite extern FXAPI FXbool fpFinite(FXdouble x); /// Single precision floating point number is infinite extern FXAPI FXbool fpInfinite(FXfloat x); /// Double precision floating point number is infinite extern FXAPI FXbool fpInfinite(FXdouble x); /// Single precision floating point number is NaN extern FXAPI FXbool fpNan(FXfloat x); /// Double precision floating point number is NaN extern FXAPI FXbool fpNan(FXdouble x); /// Single precision floating point number is normalized extern FXAPI FXbool fpNormal(FXfloat x); /// Double precision floating point number is normalized extern FXAPI FXbool fpNormal(FXdouble x); /// All bits of single precision floating point number extern FXAPI FXuint fpBits(FXfloat x); /// All bits of double precision floating point number extern FXAPI FXulong fpBits(FXdouble x); /// Evaluate integer (a < b) ? x : y static inline FXint iblend(FXint a,FXint b,FXint x,FXint y){ return ay)?x:y; } /// Minimum of two longs static inline FXlong imax(FXlong x,FXlong y){ return (x>y)?x:y; } /// Absolute value of integer static inline FXint iabs(FXint x){ return 00 static inline FXint iclamp(FXint x,FXint lim){ return imin(imax(x,-lim),lim); } /// Long clamp of long x to [-lim..lim], where lim>0 static inline FXlong iclamp(FXlong x,FXlong lim){ return imin(imax(x,-lim),lim); } /// Sign of integer, return -1 if x is <0, +1 if x>0, and zero otherwise static inline FXint isign(FXint x){ return (x>0)-(x<0); } /// Sign of integer, return -1 if x is <0, +1 if x>0, and zero otherwise static inline FXlong isign(FXlong x){ return (x>0)-(x<0); } /// Single precision minimum of two static inline FXfloat fmin(FXfloat x,FXfloat y){ #if defined(NO_FMINF) return (xy)?x:y; #else return ::fmaxf(x,y); #endif } /// Double precision maximum of two static inline FXdouble fmax(FXdouble x,FXdouble y){ #if defined(NO_FMAX) return (x>y)?x:y; #else return ::fmax(x,y); #endif } /// Single precision absolute value static inline FXfloat fabs(FXfloat x){ #if defined(NO_FABSF) return (x<0.0f) ? -x : x; #else return ::fabsf(x); #endif } /// Double precision absolute value static inline FXdouble fabs(FXdouble x){ return ::fabs(x); } /// Single precision clamp of number x to lie within range [lo..hi] static inline FXfloat fclamp(FXfloat lo,FXfloat x,FXfloat hi){ return Math::fmin(Math::fmax(x,lo),hi); } /// Double precision clamp of number x to lie within range [lo..hi] static inline FXdouble fclamp(FXdouble lo,FXdouble x,FXdouble hi){ return Math::fmin(Math::fmax(x,lo),hi); } /// Single precision clamp of number x to [-lim..lim], where lim>0 static inline FXfloat fclamp(FXfloat x,FXfloat lim){ return fmin(fmax(x,-lim),lim); } /// Double precision clamp of number x to [-lim..lim], where lim>0 static inline FXdouble fclamp(FXdouble x,FXdouble lim){ return fmin(fmax(x,-lim),lim); } /// Single precision positive difference static inline FXfloat fdim(FXfloat x,FXfloat y){ #if defined(NO_FDIMF) return Math::fmax(x-y,0.0f); #else return ::fdimf(x,y); #endif } /// Double precision positive difference static inline FXdouble fdim(FXdouble x,FXdouble y){ #if defined(NO_FDIM) return Math::fmax(x-y,0.0); #else return ::fdim(x,y); #endif } /// Single precision floating point remainder static inline FXfloat fmod(FXfloat x,FXfloat y){ return ::fmodf(x,y); } /// Double precision floating point remainder static inline FXdouble fmod(FXdouble x,FXdouble y){ return ::fmod(x,y); } /// Evaluate single-precision (a < b) ? x : y static inline FXfloat fblend(FXfloat a,FXfloat b,FXfloat x,FXfloat y){ return a0) static inline FXfloat stepify(FXfloat x,FXfloat s){ return Math::nearbyint(x/s)*s; } /// Stepify double precision x into multiples of step s (where s>0) static inline FXdouble stepify(FXdouble x,FXdouble s){ return Math::nearbyint(x/s)*s; } /// Single precision zig-zag function, period 1 static inline FXfloat zigzag(FXfloat x){ return Math::fabs(2.0f*(x-Math::nearbyint(x))); } /// Single precision zig-zag function, period 1 static inline FXdouble zigzag(FXdouble x){ return Math::fabs(2.0*(x-Math::nearbyint(x))); } /// Single precision sawtooth function, period 1 static inline FXfloat sawtooth(FXfloat x){ return x-Math::floor(x); } /// Single precision sawtooth function, period 1 static inline FXdouble sawtooth(FXdouble x){ return x-Math::floor(x); } /// Single precision revserse sawtooth function, period 1 static inline FXfloat rsawtooth(FXfloat x){ return Math::ceil(x)-x; } /// Single precision revserse sawtooth function, period 1 static inline FXdouble rsawtooth(FXdouble x){ return Math::ceil(x)-x; } /// Single precision sine static inline FXfloat sin(FXfloat x){ return ::sinf(x); } /// Double precision sine static inline FXdouble sin(FXdouble x){ return ::sin(x); } /// Single precision cosine static inline FXfloat cos(FXfloat x){ return ::cosf(x); } /// Double precision cosine static inline FXdouble cos(FXdouble x){ return ::cos(x); } /// Single precision tangent static inline FXfloat tan(FXfloat x){ return ::tanf(x); } /// Double precision tangent static inline FXdouble tan(FXdouble x){ return ::tan(x); } /// Single precision arc sine static inline FXfloat asin(FXfloat x){ return ::asinf(x); } /// Double precision arc sine static inline FXdouble asin(FXdouble x){ return ::asin(x); } /// Single precision arc cosine static inline FXfloat acos(FXfloat x){ return ::acosf(x); } /// Double precision arc cosine static inline FXdouble acos(FXdouble x){ return ::acos(x); } /// Single precision arc tangent static inline FXfloat atan(FXfloat x){ return ::atanf(x); } /// Double precision arc tangent static inline FXdouble atan(FXdouble x){ return ::atan(x); } /// Single precision arc tangent static inline FXfloat atan2(FXfloat y,FXfloat x){ return ::atan2f(y,x); } /// Double precision arc tangent static inline FXdouble atan2(FXdouble y,FXdouble x){ return ::atan2(y,x); } /// Single precision sincos static inline void sincos(FXfloat x,FXfloat& s,FXfloat& c){ #if defined(NO_SINCOSF) s=Math::sin(x); c=Math::cos(x); #else ::sincosf(x,&s,&c); #endif } /// Double precision sincos static inline void sincos(FXdouble x,FXdouble& s,FXdouble& c){ #if defined(NO_SINCOS) s=Math::sin(x); c=Math::cos(x); #else ::sincos(x,&s,&c); #endif } /// Single precision hyperbolic sine #if defined(NO_SINHF) extern FXAPI FXfloat sinh(FXfloat x); #else static inline FXfloat sinh(FXfloat x){ return ::sinhf(x); } #endif /// Double precision hyperbolic sine #if defined(NO_SINH) extern FXAPI FXdouble sinh(FXdouble x); #else static inline FXdouble sinh(FXdouble x){ return ::sinh(x); } #endif /// Single precision hyperbolic cosine #if defined(NO_COSHF) extern FXAPI FXfloat cosh(FXfloat x); #else static inline FXfloat cosh(FXfloat x){ return ::coshf(x); } #endif /// Double precision hyperbolic cosine #if defined(NO_COSH) extern FXAPI FXdouble cosh(FXdouble x); #else static inline FXdouble cosh(FXdouble x){ return ::cosh(x); } #endif /// Single precision hyperbolic tangent #if defined(NO_TANHF) extern FXAPI FXfloat tanh(FXfloat x); #else static inline FXfloat tanh(FXfloat x){ return ::tanhf(x); } #endif /// Double precision hyperbolic tangent #if defined(NO_TANH) extern FXAPI FXdouble tanh(FXdouble x); #else static inline FXdouble tanh(FXdouble x){ return ::tanh(x); } #endif /// Single precision hyperbolic arc sine #if defined(NO_ASINHF) extern FXAPI FXfloat asinh(FXfloat x); #else static inline FXfloat asinh(FXfloat x){ return ::asinhf(x); } #endif /// Double precision hyperbolic arc sine #if defined(NO_ASINH) extern FXAPI FXdouble asinh(FXdouble x); #else static inline FXdouble asinh(FXdouble x){ return ::asinh(x); } #endif /// Single precision hyperbolic arc cosine #if defined(NO_ACOSHF) extern FXAPI FXfloat acosh(FXfloat x); #else static inline FXfloat acosh(FXfloat x){ return ::acoshf(x); } #endif /// Double precision hyperbolic arc cosine #if defined(NO_ACOSH) extern FXAPI FXdouble acosh(FXdouble x); #else static inline FXdouble acosh(FXdouble x){ return ::acosh(x); } #endif /// Single precision hyperbolic arc tangent #if defined(NO_ATANHF) extern FXAPI FXfloat atanh(FXfloat x); #else static inline FXfloat atanh(FXfloat x){ return ::atanhf(x); } #endif /// Double precision hyperbolic arc tangent #if defined(NO_ATANH) extern FXAPI FXdouble atanh(FXdouble x); #else static inline FXdouble atanh(FXdouble x){ return ::atanh(x); } #endif /// Single precision square root static inline FXfloat sqrt(FXfloat x){ return ::sqrtf(x); } /// Double precision square root static inline FXdouble sqrt(FXdouble x){ return ::sqrt(x); } /// Safe single precision square root static inline FXfloat safesqrt(FXfloat x){ return Math::sqrt(Math::fmax(x,0.0f)); } /// Safe double precision square root static inline FXdouble safesqrt(FXdouble x){ return Math::sqrt(Math::fmax(x,0.0)); } /// Single precision cube root static inline FXfloat cbrt(FXfloat x){ #if defined(NO_CBRTF) return ::powf(x,0.333333333333333333333333333333f); #else return ::cbrtf(x); #endif } /// Double precision cube root static inline FXdouble cbrt(FXdouble x){ #if defined(NO_CBRT) return ::pow(x,0.333333333333333333333333333333); #else return ::cbrt(x); #endif } /// Single precision square static inline FXfloat sqr(FXfloat x){ return x*x; } /// Double precision square static inline FXdouble sqr(FXdouble x){ return x*x; } /// Single precision cube static inline FXfloat cub(FXfloat x){ return x*x*x; } /// Double precision cube static inline FXdouble cub(FXdouble x){ return x*x*x; } /// Single precision calculate hypothenuse sqrt(x^2+y^2) static inline FXfloat hypot(FXfloat x,FXfloat y){ #if defined(NO_HYPOTF) return Math::sqrt(Math::sqr(x)+Math::sqr(y)); #else return ::hypotf(x,y); #endif } /// Double precision calculate hypothenuse sqrt(x^2+y^2) static inline FXdouble hypot(FXdouble x,FXdouble y){ #if defined(NO_HYPOT) return Math::sqrt(Math::sqr(x)+Math::sqr(y)); #else return ::hypot(x,y); #endif } /// Linearly interpolate between u and v as f goes from 0...1 static inline FXfloat lerp(FXfloat u,FXfloat v,FXfloat f){ return (v-u)*f+u; } /// Linearly interpolate between u and v as f goes from 0...1 static inline FXdouble lerp(FXdouble u,FXdouble v,FXdouble f){ return (v-u)*f+u; } /// Smooth transition from 0 to 1 as f goes from 0...1 static inline FXfloat smoothstep(FXfloat f){ return (3.0f-2.0f*f)*f*f; } /// Smooth transition from 0 to 1 as f goes from 0...1 static inline FXdouble smoothstep(FXdouble f){ return (3.0-2.0*f)*f*f; } /// Single precision base E exponential static inline FXfloat exp(FXfloat x){ return ::expf(x); } /// Double precision base E exponential static inline FXdouble exp(FXdouble x){ return ::exp(x); } /// Single precision base E exponential - 1 static inline FXfloat expm1(FXfloat x){ #if defined(NO_EXPM1F) return ::expf(x)-1.0f; #else return ::expm1f(x); #endif } /// Double precision base E exponential - 1 static inline FXdouble expm1(FXdouble x){ #if defined(NO_EXPM1) return ::exp(x)-1.0; #else return ::expm1(x); #endif } /// Single precision power x^y static inline FXfloat pow(FXfloat x,FXfloat y){ return ::powf(x,y); } /// Double precision power x^y static inline FXdouble pow(FXdouble x,FXdouble y){ return ::pow(x,y); } /// Single precision base 2 exponential static inline FXfloat exp2(FXfloat x){ #if defined(NO_EXP2F) return Math::pow(2.0f,x); #else return ::exp2f(x); #endif } /// Double precision base 2 exponential static inline FXdouble exp2(FXdouble x){ #if defined(NO_EXP2) return Math::pow(2.0,x); #else return ::exp2(x); #endif } /// Single precision base 10 exponential static inline FXfloat exp10(FXfloat x){ #if defined(NO_EXP10F) return Math::pow(10.0f,x); #else return ::exp10f(x); #endif } /// Double precision base 10 exponential static inline FXdouble exp10(FXdouble x){ #if defined(NO_EXP10) return Math::pow(10.0,x); #else return ::exp10(x); #endif } /// Single precision 10^x static inline FXfloat pow10(FXfloat x){ return Math::exp10(x); } /// Double precision 10^x static inline FXdouble pow10(FXdouble x){ return Math::exp10(x); } /// Double precision integer power of 10 extern FXAPI FXdouble pow10i(FXint ex); /// Single precision integer power extern FXAPI FXfloat powi(FXfloat base,FXint ex); /// Double precision integer power extern FXAPI FXdouble powi(FXdouble base,FXint ex); /// Single precision natural logarithm static inline FXfloat log(FXfloat x){ return ::logf(x); } /// Double precision natural logarithm static inline FXdouble log(FXdouble x){ return ::log(x); } /// Single precision logarithm of 1+x static inline FXfloat log1p(FXfloat x){ #if defined(NO_LOG1PF) return Math::log(1.0f+x); #else return ::log1pf(x); #endif } /// Double precision logarithm of 1+x static inline FXdouble log1p(FXdouble x){ #if defined(NO_LOG1P) return Math::log(1.0+x); #else return ::log1p(x); #endif } /// Single precision base 2 logarithm static inline FXfloat log2(FXfloat x){ #if defined(NO_LOG2F) return Math::log(x)*1.442695040888963407359924681001892137f; #else return ::log2f(x); #endif } /// Double precision base 2 logarithm static inline FXdouble log2(FXdouble x){ #if defined(NO_LOG2) return Math::log(x)*1.442695040888963407359924681001892137; #else return ::log2(x); #endif } /// Single precision base 10 logarithm static inline FXfloat log10(FXfloat x){ return ::log10f(x); } /// Double precision base 10 logarithm static inline FXdouble log10(FXdouble x){ return ::log10(x); } /// Single precision error function extern FXAPI FXfloat erf(FXfloat x); /// Double precision error function extern FXAPI FXdouble erf(FXdouble x); /// Single precision complementary error function extern FXAPI FXfloat erfc(FXfloat x); /// Double precision complementary error function extern FXAPI FXdouble erfc(FXdouble x); /// Single precision inverse error function extern FXAPI FXfloat inverf(FXfloat x); /// Double precision inverse error function extern FXAPI FXdouble inverf(FXdouble x); /// Single precision inverse complementary error function extern FXAPI FXfloat inverfc(FXfloat x); /// Double precision inverse complementary error function extern FXAPI FXdouble inverfc(FXdouble x); } } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/fxunicode.h000066400000000000000000000447671455751074500226400ustar00rootroot00000000000000/******************************************************************************** * * * U N I C O D E C h a r a c t e r I n f o * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef FXUNICODE_H #define FXUNICODE_H /******* Generated on 2011/09/02 15:58:10 by unicode tool version 6.0.0 ********/ namespace FX { /// General Category enum { CatNotAssigned = 0, /// Cn Other, Not Assigned (no characters in the file have this property) CatControl = 1, /// Cc Other, Control CatFormat = 2, /// Cf Other, Format CatSurrogate = 3, /// Cs Other, Surrogate CatOther = 4, /// Co Other, Private Use CatMarkNonSpacing = 5, /// Mn Mark, Nonspacing CatMarkSpacingCombining = 6, /// Mc Mark, Spacing Combining CatMarkEnclosing = 7, /// Me Mark, Enclosing CatSeparatorSpace = 8, /// Zs Separator, Space CatSeparatorLine = 9, /// Zl Separator, Line CatSeparatorParagraph = 10, /// Zp Separator, Paragraph CatLetterUpper = 11, /// Lu Letter, Uppercase CatLetterLower = 12, /// Ll Letter, Lowercase CatLetterTitle = 13, /// Lt Letter, Titlecase CatLetterModifier = 14, /// Lm Letter, Modifier CatLetterOther = 15, /// Lo Letter, Other CatNumberLetter = 16, /// Nl Number, Letter CatNumberDecimal = 17, /// Nd Number, Decimal Digit CatNumberOther = 18, /// No Number, Other CatPunctConnector = 19, /// Pc Punctuation, Connector CatPunctDash = 20, /// Pd Punctuation, Dash CatPunctOpen = 21, /// Ps Punctuation, Open CatPunctClose = 22, /// Pe Punctuation, Close CatPunctInitial = 23, /// Pi Punctuation, Initial quote (may behave like Ps or Pe depending on usage) CatPunctFinal = 24, /// Pf Punctuation, Final quote (may behave like Ps or Pe depending on usage) CatPunctOther = 25, /// Po Punctuation, Other CatSymbolMath = 26, /// Sm Symbol, Math CatSymbolCurrency = 27, /// Sc Symbol, Currency CatSymbolModifier = 28, /// Sk Symbol, Modifier CatSymbolOther = 29 /// So Symbol, Other }; /// Bidi types enum { DirL = 0, /// Left-to-Right DirLRE = 1, /// Left-to-Right Embedding DirLRO = 2, /// Left-to-Right Override DirR = 3, /// Right-to-Left DirAL = 4, /// Right-to-Left Arabic DirRLE = 5, /// Right-to-Left Embedding DirRLO = 6, /// Right-to-Left Override DirPDF = 7, /// Pop Directional Format DirEN = 8, /// European Number DirES = 9, /// European Number Separator DirET = 10, /// European Number Terminator DirAN = 11, /// Arabic Number DirCS = 12, /// Common Number Separator DirNSM = 13, /// Non-Spacing Mark DirBN = 14, /// Boundary Neutral DirB = 15, /// Paragraph Separator DirS = 16, /// Segment Separator DirWS = 17, /// Whitespace DirON = 18 /// Other Neutrals }; /// Arabic joining types enum { JoinTypeNonJoining = 0, JoinTypeRightJoining = 1, JoinTypeDualJoining = 2, JoinTypeJoinCausing = 3, JoinTypeLeftJoining = 4, JoinTypeTransparent = 5 }; /// Arabic joining groups enum { JoinGroupNone = 0, JoinGroupAin = 1, JoinGroupAlaph = 2, JoinGroupAlef = 3, JoinGroupBeh = 4, JoinGroupBeth = 5, JoinGroupBurushaskiYehBarree = 6, JoinGroupDal = 7, JoinGroupDalathRish = 8, JoinGroupE = 9, JoinGroupFarsiYeh = 10, JoinGroupFe = 11, JoinGroupFeh = 12, JoinGroupFinalSemkath = 13, JoinGroupGaf = 14, JoinGroupGamal = 15, JoinGroupHah = 16, JoinGroupHamzaOnHehGoal = 17, JoinGroupHe = 18, JoinGroupHeh = 19, JoinGroupHehGoal = 20, JoinGroupHeth = 21, JoinGroupKaf = 22, JoinGroupKaph = 23, JoinGroupKhaph = 24, JoinGroupKnottedHeh = 25, JoinGroupLam = 26, JoinGroupLamadh = 27, JoinGroupMeem = 28, JoinGroupMim = 29, JoinGroupNoon = 30, JoinGroupNun = 31, JoinGroupNya = 32, JoinGroupPe = 33, JoinGroupQaf = 34, JoinGroupQaph = 35, JoinGroupReh = 36, JoinGroupReversedPe = 37, JoinGroupSad = 38, JoinGroupSadhe = 39, JoinGroupSeen = 40, JoinGroupSemkath = 41, JoinGroupShin = 42, JoinGroupSwashKaf = 43, JoinGroupSyriacWaw = 44, JoinGroupTah = 45, JoinGroupTaw = 46, JoinGroupTehMarbuta = 47, JoinGroupTehMarbutaGoal = 48, JoinGroupTeth = 49, JoinGroupWaw = 50, JoinGroupYeh = 51, JoinGroupYehBarree = 52, JoinGroupYehWithTail = 53, JoinGroupYudh = 54, JoinGroupYudhHe = 55, JoinGroupZain = 56, JoinGroupZhain = 57 }; /// Combining class enum { CombineOverlay = 1, /// Overlay CombineNukta = 7, /// Diacritic nukta mark CombineKanaVoicing = 8, /// Hiragana/Katakana voicing CombineVirama = 9, /// Virama CombineBelowLeftAtt = 200, /// Below left attached CombineBelowAtt = 202, /// Below attached CombineBelowRightAtt = 204, /// Below right attached CombineLeftAtt = 208, /// Left attached (reordrant around single base character) CombineRightAtt = 210, /// Right attached CombineAboveLeftAtt = 212, /// Above left attached CombineAboveAtt = 214, /// Above attached CombineAboveRightAtt = 216, /// Above right attached CombineBelowLeft = 218, /// Below left CombineBelow = 220, /// Below CombineBelowRight = 222, /// Below right CombineLeft = 224, /// Left (reordrant around single base character) CombineRight = 226, /// Right CombineAboveLeft = 228, /// Above left CombineAbove = 230, /// Above CombineAboveRight = 232, /// Above right CombineDoubleBelow = 233, /// Double below CombineDoubleAbove = 234, /// Double above CombineIotaSub = 240 /// Below (iota subscript) }; /// Decompose types enum { DecomposeNone = 0, /// Non-decomposable DecomposeCanonical = 1, /// Canonical (equivalent) DecomposeCompat = 2, /// Compatible DecomposeFont = 3, /// A font variant (e.g. a blackletter form) DecomposeNoBreak = 4, /// A no-break version of a space or hyphen DecomposeInitial = 5, /// An initial presentation form (Arabic) DecomposeMedial = 6, /// A medial presentation form (Arabic) DecomposeFinal = 7, /// A final presentation form (Arabic) DecomposeIsolated = 8, /// An isolated presentation form (Arabic) DecomposeCircle = 9, /// An encircled form DecomposeSuper = 10, /// A superscript form DecomposeSub = 11, /// A subscript form DecomposeVertical = 12, /// A vertical layout presentation form DecomposeWide = 13, /// A wide (or zenkaku) compatibility character DecomposeNarrow = 14, /// A narrow (or hankaku) compatibility character DecomposeSmall = 15, /// A small variant form (CNS compatibility) DecomposeSquare = 16, /// A CJK squared font variant DecomposeFraction = 17 /// A vulgar fraction form }; /// Line break types enum { BreakUnknown = 0, /// XX Unknown BreakMandatory = 1, /// BK Mandatory Break (after) BreakReturn = 2, /// CR Carriage Return BreakLineFeed = 3, /// LF Line Feed BreakCombMark = 4, /// CM Attached Characters and Combining Marks (no break) BreakNextLine = 5, /// NL Next Line BreakSurrogate = 6, /// SG Surrogates BreakWordJoiner = 7, /// WJ Word Joiner (no break before/after) BreakZWSpace = 8, /// ZW Zero Width Space (break opportunity) BreakGlue = 9, /// GL Non-breaking Glue (no break) BreakSpace = 10, /// SP Space BreakBoth = 11, /// B2 Break Opportunity Before and After BreakAfter = 12, /// BA Break Opportunity After BreakBefore = 13, /// BB Break Opportunity Before BreakHyphen = 14, /// HY Hyphen BreakContingent = 15, /// CB Contingent Break Opportunity BreakClosePunct = 16, /// CL Closing Punctuation (no break before) BreakCloseParen = 17, /// CP Close Parenthesis (no break before) BreakExclaim = 18, /// EX Exclamation/Interrogation (no break before) BreakInsep = 19, /// IN Inseparable BreakNonStart = 20, /// NS Non Starter BreakOpenPunct = 21, /// OP Opening Punctuation (no break after) BreakQuote = 22, /// QU Quotation BreakInfix = 23, /// IS Numeric Infix Separator (no break before or after) BreakNumeric = 24, /// NU Numeric BreakPostfix = 25, /// PO Numeric Prefix (%, etc.) BreakPrefix = 26, /// PR Numeric Postfix ($, etc.) BreakSymbol = 27, /// SY Symbols Allowing Breaks BreakAmbiguous = 28, /// AI Ordinary Alphabetic and Symbol Characters BreakAlphabetic = 29, /// AL Ordinary Alphabetic and Symbol Characters BreakHangul2 = 30, /// H2 Hangul LV BreakHangul3 = 31, /// H3 Hangul LVT BreakIdeograph = 32, /// ID Ideographic BreakJamoL = 33, /// JL BreakJamoV = 34, /// JV BreakJamoT = 35, /// JT BreakComplex = 36 /// SA Complex Context (South East Asian) }; /// Scripts enum { ScriptUnknown = 0, /// Zzzz ScriptCommon = 1, /// Zyyy ScriptInherited = 2, /// Zinh ScriptLatin = 3, /// Latn ScriptGreek = 4, /// Grek ScriptCyrillic = 5, /// Cyrl ScriptArmenian = 6, /// Armn ScriptHebrew = 7, /// Hebr ScriptArabic = 8, /// Arab ScriptSyriac = 9, /// Syrc ScriptThaana = 10, /// Thaa ScriptDevanagari = 11, /// Deva ScriptBengali = 12, /// Beng ScriptGurmukhi = 13, /// Guru ScriptGujarati = 14, /// Gujr ScriptOriya = 15, /// Orya ScriptTamil = 16, /// Taml ScriptTelugu = 17, /// Telu ScriptKannada = 18, /// Knda ScriptMalayalam = 19, /// Mlym ScriptSinhala = 20, /// Sinh ScriptThai = 21, /// Thai ScriptLao = 22, /// Laoo ScriptTibetan = 23, /// Tibt ScriptMyanmar = 24, /// Mymr ScriptGeorgian = 25, /// Geor ScriptHangul = 26, /// Hang ScriptEthiopic = 27, /// Ethi ScriptCherokee = 28, /// Cher ScriptCanadianAboriginal = 29, /// Cans ScriptOgham = 30, /// Ogam ScriptRunic = 31, /// Runr ScriptKhmer = 32, /// Khmr ScriptMongolian = 33, /// Mong ScriptHiragana = 34, /// Hira ScriptKatakana = 35, /// Kana ScriptBopomofo = 36, /// Bopo ScriptHan = 37, /// Hani ScriptYi = 38, /// Yiii ScriptOldItalic = 39, /// Ital ScriptGothic = 40, /// Goth ScriptDeseret = 41, /// Dsrt ScriptTagalog = 42, /// Tglg ScriptHanunoo = 43, /// Hano ScriptBuhid = 44, /// Buhd ScriptTagbanwa = 45, /// Tagb ScriptLimbu = 46, /// Limb ScriptTaiLe = 47, /// Tale ScriptLinearB = 48, /// Linb ScriptUgaritic = 49, /// Ugar ScriptShavian = 50, /// Shaw ScriptOsmanya = 51, /// Osma ScriptCypriot = 52, /// Cprt ScriptBraille = 53, /// Brai ScriptBuginese = 54, /// Bugi ScriptCoptic = 55, /// Copt ScriptNewTaiLue = 56, /// Talu ScriptGlagolitic = 57, /// Glag ScriptTifinagh = 58, /// Tfng ScriptSylotiNagri = 59, /// Sylo ScriptOldPersian = 60, /// Xpeo ScriptKharoshthi = 61, /// Khar ScriptBalinese = 62, /// Bali ScriptCuneiform = 63, /// Xsux ScriptPhoenician = 64, /// Phnx ScriptPhagsPa = 65, /// Phag ScriptNKo = 66, /// Nkoo ScriptSundanese = 67, /// Sund ScriptLepcha = 68, /// Lepc ScriptOlChiki = 69, /// Olck ScriptVai = 70, /// Vaii ScriptSaurashtra = 71, /// Saur ScriptKayahLi = 72, /// Kali ScriptRejang = 73, /// Rjng ScriptLycian = 74, /// Lyci ScriptCarian = 75, /// Cari ScriptLydian = 76, /// Lydi ScriptCham = 77, /// Cham ScriptTaiTham = 78, /// Lana ScriptTaiViet = 79, /// Tavt ScriptAvestan = 80, /// Avst ScriptEgyptianHieroglyphs = 81, /// Egyp ScriptSamaritan = 82, /// Samr ScriptLisu = 83, /// Lisu ScriptBamum = 84, /// Bamu ScriptJavanese = 85, /// Java ScriptMeiteiMayek = 86, /// Mtei ScriptImperialAramaic = 87, /// Armi ScriptOldSouthArabian = 88, /// Sarb ScriptInscriptionalParthian = 89, /// Prti ScriptInscriptionalPahlavi = 90, /// Phli ScriptOldTurkic = 91, /// Orkh ScriptKaithi = 92, /// Kthi ScriptBatak = 93, /// Batk ScriptBrahmi = 94, /// Brah ScriptMandaic = 95 /// Mand }; namespace Unicode { /// Character wide character category extern FXAPI FXuint charCategory(FXwchar ucs); /// Get character wide character direction extern FXAPI FXuint charDirection(FXwchar ucs); /// Get wide character symmetry extern FXAPI FXuint isSymmetric(FXwchar ucs); /// Get wide character decompose type extern FXAPI FXuint decomposeType(FXwchar ucs); /// Return number of wide characters in decomposition extern FXAPI FXuint charNumDecompose(FXwchar ucs); /// Return wide character decomposition extern FXAPI const FXwchar* charDecompose(FXwchar ucs); /// Return wide character composition from ucsa and ucsb extern FXAPI FXwchar charCompose(FXwchar ucsa,FXwchar ucsb); /// Get wide character combining type; zero means starter extern FXAPI FXuint charCombining(FXwchar ucs); /// Get numeric value of wide character (this includes hex value) extern FXAPI FXint digitValue(FXwchar ucs); /// Get linebreak type of wide character extern FXAPI FXuint lineBreakType(FXwchar ucs); /// Get mirror image of wide character or character itself extern FXAPI FXwchar mirrorImage(FXwchar ucs); /// Get wide character joining type extern FXAPI FXuint joiningType(FXwchar ucs); /// Get wide character joining group extern FXAPI FXuint joiningGroup(FXwchar ucs); /// Script type of wide character extern FXAPI FXuint scriptType(FXwchar ucs); /// Unicode character types extern FXAPI FXbool hasCase(FXwchar ucs); extern FXAPI FXbool isUpper(FXwchar ucs); extern FXAPI FXbool isLower(FXwchar ucs); extern FXAPI FXbool isTitle(FXwchar ucs); extern FXAPI FXbool isAscii(FXwchar ucs); extern FXAPI FXbool isLetter(FXwchar ucs); extern FXAPI FXbool isDigit(FXwchar ucs); extern FXAPI FXbool isAlphaNumeric(FXwchar ucs); extern FXAPI FXbool isControl(FXwchar ucs); extern FXAPI FXbool isSpace(FXwchar ucs); extern FXAPI FXbool isBlank(FXwchar ucs); extern FXAPI FXbool isPunct(FXwchar ucs); extern FXAPI FXbool isGraph(FXwchar ucs); extern FXAPI FXbool isPrint(FXwchar ucs); extern FXAPI FXbool isHexDigit(FXwchar ucs); extern FXAPI FXbool isSymbol(FXwchar ucs); extern FXAPI FXbool isMark(FXwchar ucs); extern FXAPI FXbool isSep(FXwchar ucs); /// Case conversion extern FXAPI FXwchar toUpper(FXwchar ucs); extern FXAPI FXwchar toLower(FXwchar ucs); extern FXAPI FXwchar toTitle(FXwchar ucs); } } #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/fxver.h000066400000000000000000000001731455751074500217650ustar00rootroot00000000000000#ifndef FXVER_H #define FXVER_H /// FOX version #define FOX_MAJOR 1 #define FOX_MINOR 7 #define FOX_LEVEL 83 #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/fxver.h.in000066400000000000000000000002561455751074500223740ustar00rootroot00000000000000#ifndef FXVER_H #define FXVER_H /// FOX version #define FOX_MAJOR @FOX_MAJOR_VERSION@ #define FOX_MINOR @FOX_MINOR_VERSION@ #define FOX_LEVEL @FOX_PATCH_LEVEL@ #endif gogglesmm-gogglesmm-0b8cb53/cfox/include/xincs.h000066400000000000000000000216731455751074500217670ustar00rootroot00000000000000/******************************************************************************** * * * F O X P r i v a t e I n c l u d e F i l e s * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #ifndef XINCS_H #define XINCS_H //////////////////// DO NOT INCLUDE THIS PRIVATE HEADER FILE ////////////////// // Thread safe #ifndef _POSIX_PTHREAD_SEMANTICS #define _POSIX_PTHREAD_SEMANTICS #endif // GNU extras if we can get them #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif // Use 64-bit files #ifndef WIN32 #ifndef _FILE_OFFSET_BITS #define _FILE_OFFSET_BITS 64 #endif #endif // Basic includes #include #include #include #include #include #include #include #include #include #include #include #include #include // Platform includes #if defined(WIN32) /////////////// Windows ///////////////////////////////////// // Windows 2000 is minimum now #if _WIN32_WINNT < 0x0500 #define _WIN32_WINNT 0x0500 #endif // Enforce handle types #ifndef STRICT #define STRICT 1 #endif // Skip some stuff #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #if (_MSC_VER >= 1500) #pragma warning(disable: 4251) #endif // Common headers #include // Core Windows stuff #include // Printer stuff #include #ifndef __CYGWIN__ #include #endif #include "winnt.h" #include // For _TrackMouseEvent #include #include // IME #ifdef UNICODE #include // Wide character support #endif #ifndef PROCESS_SUSPEND_RESUME #define PROCESS_SUSPEND_RESUME 0x0800 #endif #ifndef INVALID_FILE_ATTRIBUTES #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) #endif #if (_MSC_VER >= 1400) // VC++ 2005 or newer #include #endif // OpenGL includes #ifdef HAVE_GL_H #include #endif //#ifdef WIN32 //#include //#endif #ifndef GLAPIENTRY #define GLAPIENTRY #endif #ifndef GLAPI #define GLAPI #endif #ifndef GL_BGRA #define GL_BGRA GL_BGRA_EXT #endif //#ifdef HAVE_GLU_H //#include //#endif #else ////////////////////////////// Unix /////////////////////////////////////// // Common headers #include #include #include #ifdef HAVE_SYS_STATVFS_H #include #endif #ifdef HAVE_SYS_MOUNT_H #include #endif #ifdef HAVE_UNISTD_H #include #include #endif #ifdef HAVE_SYS_FILIO_H // Get FIONREAD on Solaris #include #endif #ifdef HAVE_SYS_WAIT_H #include #endif #ifdef HAVE_SYS_PARAM_H #include #endif #ifdef HAVE_DIRENT_H #include #define NAMLEN(dirent) strlen((dirent)->d_name) #else #define dirent direct #define NAMLEN(dirent) (dirent)->d_namlen #ifdef HAVE_SYS_NDIR_H #include #endif #ifdef HAVE_SYS_DIR_H #include #endif #ifdef HAVE_NDIR_H #include #endif #endif #ifdef TIME_WITH_SYS_TIME #include #include #else #ifdef HAVE_SYS_TIME_H #include #else #include #endif #endif #ifdef HAVE_SYS_SELECT_H #include #endif #ifdef HAVE_SYS_EPOLL_H #include #endif #ifdef HAVE_SYS_TIMERFD_H #include #endif #ifdef HAVE_SYS_RESOURCE_H #include #endif #ifdef HAVE_SYS_IPC_H #include #endif #ifdef HAVE_SYS_SHM_H #include #endif #ifdef HAVE_SYS_MMAN_H #include #endif #ifdef HAVE_SYS_PSTAT_H #include #endif #ifdef HAVE_SYS_INOTIFY_H #include #endif #ifdef HAVE_SYS_UTSNAME_H #include #endif #ifdef HAVE_SYS_SYSCTL_H #if !defined(__linux__) #include #endif #endif #if defined(__APPLE__) #include #endif #include #ifdef HAVE_SEMAPHORE_H #include #endif #if defined(HAVE_PTHREAD_SETAFFINITY_NP) #if defined(__FreeBSD__) #include #if __FreeBSD_version >= 702000 #include #include typedef cpuset_t cpu_set_t; #endif #endif #endif #if defined(__minix) // MINIX #ifdef sleep #undef sleep // We mean sleep not __pthread_sleep #endif #ifdef read #undef read // We mean read not __pthread_read #endif #ifdef write #undef write // We mean write not __pthread_write #endif #ifdef select #undef select // We mean select not __pthread_select #endif #endif // Dynamic library loading #ifdef HAVE_SHL_LOAD #include // HP-UX #ifndef DYNAMIC_PATH #define DYNAMIC_PATH 0 #endif #ifndef BIND_RESTRICTED #define BIND_RESTRICTED 0 #endif #else #ifdef HAVE_DLFCN_H #include // POSIX #endif #endif #ifndef RTLD_GLOBAL #define RTLD_GLOBAL 0 // Does not exist on DEC #endif #ifndef RTLD_NOLOAD // Older GLIBC libraries #define RTLD_NOLOAD 0 #endif #ifndef RTLD_NOW // for OpenBSD #define RTLD_NOW DL_LAZY #endif // SSE Intrinsics only if available and turned on #if ((defined(__GNUC__) || defined(__INTEL_COMPILER)) && (defined(__i386__) || defined(__x86_64__))) #if defined(HAVE_IMMINTRIN_H) #include #if defined(__SSE__) #define FOX_HAS_SSE #endif #if defined(__SSE2__) #define FOX_HAS_SSE2 #endif #if defined(__SSE3__) #define FOX_HAS_SSE3 #endif #if defined(__SSSE3__) #define FOX_HAS_SSSE3 #endif #if defined(__SSE4_1__) && defined(__SSE4_2__) #define FOX_HAS_SSE4 #endif #if defined(__AVX__) #define FOX_HAS_AVX #endif #if defined(__AVX2__) #define FOX_HAS_AVX2 #endif #if defined(__FMA__) #define FOX_HAS_FMA #endif #if defined(__F16C__) #define FOX_HAS_F16 #endif #endif #endif // X11 includes #include #include #include #include #include #include #include #ifdef HAVE_XSHM_H #include #endif #ifdef HAVE_XCURSOR_H #include #endif #ifdef HAVE_XFT_H #include #endif #ifdef HAVE_XSHAPE_H #include #endif #ifdef HAVE_XRANDR_H #include #endif #ifdef HAVE_XFIXES_H #include #endif #ifdef HAVE_XRENDER_H #include #endif #ifdef HAVE_XINPUT2_H #include #endif #ifndef NO_XIM #ifndef XlibSpecificationRelease // Not defined until X11R5 #define NO_XIM #elif XlibSpecificationRelease < 6 // Need at least Xlib X11R6 #define NO_XIM #endif #endif // OpenGL includes #ifdef HAVE_GL_H #ifndef SUN_OGL_NO_VERTEX_MACROS #define SUN_OGL_NO_VERTEX_MACROS #endif #ifndef HPOGL_SUPPRESS_FAST_API #define HPOGL_SUPPRESS_FAST_API #endif #ifdef HAVE_EPOXY #include #include #else #include #ifdef HAVE_GLX_H #include #endif #endif #endif //#ifdef HAVE_GLU_H //#include //#endif #endif ////////////////////////////////////////////////////////////////////////// // Maximum path length #ifndef MAXPATHLEN #if defined(PATH_MAX) #define MAXPATHLEN PATH_MAX #elif defined(_MAX_PATH) #define MAXPATHLEN _MAX_PATH #elif defined(MAX_PATH) #define MAXPATHLEN MAX_PATH #else #define MAXPATHLEN 4096 #endif #endif // Maximum host name length #ifndef MAXHOSTNAMELEN #define MAXHOSTNAMELEN 256 #endif // Some systems don't have it #ifndef SEEK_SET #define SEEK_SET 0 #endif #ifndef SEEK_CUR #define SEEK_CUR 1 #endif #ifndef SEEK_END #define SEEK_END 2 #endif // Remove crap #ifdef VOID #undef VOID #endif #endif gogglesmm-gogglesmm-0b8cb53/cfox/lib/000077500000000000000000000000001455751074500176045ustar00rootroot00000000000000gogglesmm-gogglesmm-0b8cb53/cfox/lib/CMakeLists.txt000066400000000000000000001046351455751074500223550ustar00rootroot00000000000000include(CheckIncludeFileCXX) include(CheckCXXSourceCompiles) include(CheckCXXSymbolExists) include(CMakePushCheckState) option(WITH_XIM "Compile with X Input Method support" ON) option(WITH_JPEG "Compile with JPEG support" ON) option(WITH_PNG "Compile with PNG support" ON) option(WITH_TIFF "Compile with TIFF support" ON) option(WITH_ZLIB "Compile with zlib support" ON) option(WITH_BZ2LIB "Compile with bz2lib support" ON) option(WITH_WEBP "Compile with webp support" ON) option(WITH_OPENJPEG "Compile with OpenJPEG support" ON) option(WITH_OPENGL "Compile with OpenGL support" ON) # libdir name to allow overriding to lib32 / lib64 set(CMAKE_INSTALL_LIBDIR "lib" CACHE STRING "Specify the name of the directory where libraries are meant to be installed") set(HEADERS ../include/fx3d.h ../include/FX4Splitter.h ../include/FX7Segment.h ../include/FX885910Codec.h ../include/FX885911Codec.h ../include/FX885913Codec.h ../include/FX885914Codec.h ../include/FX885915Codec.h ../include/FX885916Codec.h ../include/FX88591Codec.h ../include/FX88592Codec.h ../include/FX88593Codec.h ../include/FX88594Codec.h ../include/FX88595Codec.h ../include/FX88596Codec.h ../include/FX88597Codec.h ../include/FX88598Codec.h ../include/FX88599Codec.h ../include/FXAccelTable.h ../include/FXApp.h ../include/FXArray.h ../include/FXArrowButton.h ../include/fxascii.h ../include/FXAtomic.h ../include/FXAutoPtr.h ../include/FXAutoThreadStorageKey.h ../include/FXBarrier.h ../include/FXBitmapFrame.h ../include/FXBitmap.h ../include/FXBitmapView.h ../include/FXBMPIcon.h ../include/FXBMPImage.h ../include/FXButton.h ../include/FXBZFileStream.h ../include/FXCalendar.h ../include/FXCalendarView.h ../include/FXCallback.h ../include/FXCanvas.h ../include/FXCheckButton.h ../include/FXChoiceBox.h ../include/FXColorBar.h ../include/FXColorDialog.h ../include/FXColorList.h ../include/FXColorRing.h ../include/FXColorSelector.h ../include/FXColors.h ../include/FXColorWell.h ../include/FXColorWheel.h ../include/FXComboBox.h ../include/FXCompletion.h ../include/FXComplexd.h ../include/FXComplexf.h ../include/FXComposeContext.h ../include/FXComposite.h ../include/FXCondition.h ../include/FXConsole.h ../include/FXCP1250Codec.h ../include/FXCP1251Codec.h ../include/FXCP1252Codec.h ../include/FXCP1253Codec.h ../include/FXCP1254Codec.h ../include/FXCP1255Codec.h ../include/FXCP1256Codec.h ../include/FXCP1257Codec.h ../include/FXCP1258Codec.h ../include/FXCP437Codec.h ../include/FXCP850Codec.h ../include/FXCP852Codec.h ../include/FXCP855Codec.h ../include/FXCP856Codec.h ../include/FXCP857Codec.h ../include/FXCP860Codec.h ../include/FXCP861Codec.h ../include/FXCP862Codec.h ../include/FXCP863Codec.h ../include/FXCP864Codec.h ../include/FXCP865Codec.h ../include/FXCP866Codec.h ../include/FXCP869Codec.h ../include/FXCP874Codec.h ../include/fxchar.h ../include/fxcpuid.h ../include/FXCURCursor.h ../include/FXCursor.h ../include/FXDataTarget.h ../include/FXDate.h ../include/FXDC.h ../include/FXDCPrint.h ../include/FXDCWindow.h ../include/FXDDSIcon.h ../include/FXDDSImage.h ../include/FXDebugTarget.h ../include/fxdefs.h ../include/FXDelegator.h ../include/FXDial.h ../include/FXDialogBox.h ../include/FXDictionary.h ../include/FXDictionaryOf.h ../include/FXDirBox.h ../include/FXDirDialog.h ../include/FXDir.h ../include/FXDirList.h ../include/FXDirSelector.h ../include/FXDirVisitor.h ../include/FXDirWatch.h ../include/FXDispatcher.h ../include/FXDisplay.h ../include/FXDLL.h ../include/FXDockBar.h ../include/FXDockHandler.h ../include/FXDockSite.h ../include/FXDockTitle.h ../include/FXDocument.h ../include/FXDragCorner.h ../include/FXDrawable.h ../include/FXDriveBox.h ../include/FXElement.h ../include/fxendian.h ../include/FXEvent.h ../include/FXEventDispatcher.h ../include/FXEventLoop.h ../include/FXException.h ../include/FXEXEIcon.h ../include/FXEXEImage.h ../include/FXExpression.h ../include/FXExtentd.h ../include/FXExtentf.h ../include/FXFileAssociations.h ../include/FXFileDialog.h ../include/FXFile.h ../include/FXFileList.h ../include/FXFileProgressDialog.h ../include/FXFileSelector.h ../include/FXFileStream.h ../include/FXFoldingList.h ../include/FXFontDialog.h ../include/FXFont.h ../include/FXFontSelector.h ../include/FXFrame.h ../include/FXGauge.h ../include/FXGIFCursor.h ../include/FXGIFIcon.h ../include/FXGIFImage.h ../include/FXGLCanvas.h ../include/FXGLContext.h ../include/FXGLObject.h ../include/FXGLViewer.h ../include/FXGLVisual.h ../include/FXGradientBar.h ../include/FXGroupBox.h ../include/FXGZFileStream.h ../include/fx.h ../include/FXhalf.h ../include/FXHash.h ../include/FXHashOf.h ../include/FXHeader.h ../include/FXHorizontalFrame.h ../include/FXICOIcon.h ../include/FXICOImage.h ../include/FXIconCache.h ../include/FXIcon.h ../include/FXIconList.h ../include/FXIconSource.h ../include/FXId.h ../include/FXIFFIcon.h ../include/FXIFFImage.h ../include/FXImageFrame.h ../include/FXImage.h ../include/FXImageView.h ../include/FXINI.h ../include/FXINIFile.h ../include/FXInputDialog.h ../include/FXIOBuffer.h ../include/FXIODevice.h ../include/FXIO.h ../include/FXJP2Icon.h ../include/FXJP2Image.h ../include/FXJPGIcon.h ../include/FXJPGImage.h ../include/FXJSON.h ../include/FXJSONFile.h ../include/FXJSONString.h ../include/fxkeys.h ../include/FXKnob.h ../include/FXKOI8RCodec.h ../include/FXLabel.h ../include/FXLFQueue.h ../include/FXListBox.h ../include/FXList.h ../include/FXLocale.h ../include/FXMainWindow.h ../include/FXMat2d.h ../include/FXMat2f.h ../include/FXMat3d.h ../include/FXMat3f.h ../include/FXMat4d.h ../include/FXMat4f.h ../include/fxmath.h ../include/FXMatrix.h ../include/FXMDIButton.h ../include/FXMDIChild.h ../include/FXMDIClient.h ../include/FXMemMap.h ../include/FXMemoryStream.h ../include/FXMenuBar.h ../include/FXMenuButton.h ../include/FXMenuCaption.h ../include/FXMenuCascade.h ../include/FXMenuCheck.h ../include/FXMenuCommand.h ../include/FXMenuPane.h ../include/FXMenuRadio.h ../include/FXMenuSeparator.h ../include/FXMenuTitle.h ../include/FXMessageBox.h ../include/FXMessageChannel.h ../include/FXMetaClass.h ../include/FXMutex.h ../include/FXObject.h ../include/FXObjectList.h ../include/FXOptionMenu.h ../include/FXPacker.h ../include/FXParallel.h ../include/FXParseBuffer.h ../include/FXPath.h ../include/FXPCXIcon.h ../include/FXPCXImage.h ../include/FXPicker.h ../include/FXPipe.h ../include/FXPNGIcon.h ../include/FXPNGImage.h ../include/FXPoint.h ../include/FXPopup.h ../include/FXPPMIcon.h ../include/FXPPMImage.h ../include/FXPrintDialog.h ../include/FXProcess.h ../include/FXProgressBar.h ../include/FXProgressDialog.h ../include/FXPtrList.h ../include/FXPtrQueue.h ../include/FXQuatd.h ../include/FXQuatf.h ../include/FXRadioButton.h ../include/FXRandom.h ../include/FXRanged.h ../include/FXRangef.h ../include/FXRangeSlider.h ../include/FXRASIcon.h ../include/FXRASImage.h ../include/FXReactor.h ../include/FXReadWriteLock.h ../include/FXRealSlider.h ../include/FXRealSpinner.h ../include/FXRecentFiles.h ../include/FXRectangle.h ../include/FXRefPtr.h ../include/FXRegion.h ../include/FXRegistry.h ../include/FXReplaceDialog.h ../include/FXReverseDictionary.h ../include/FXReverseDictionaryOf.h ../include/FXRex.h ../include/FXRGBIcon.h ../include/FXRGBImage.h ../include/FXRootWindow.h ../include/FXRuler.h ../include/FXRulerView.h ../include/FXRunnable.h ../include/FXScopedThread.h ../include/FXScrollArea.h ../include/FXScrollBar.h ../include/FXScrollPane.h ../include/FXScrollWindow.h ../include/FXSearchDialog.h ../include/FXSemaphore.h ../include/FXSemaQueue.h ../include/FXSeparator.h ../include/FXSettings.h ../include/FXShell.h ../include/FXShutter.h ../include/FXSize.h ../include/FXSlider.h ../include/FXSocket.h ../include/FXSphered.h ../include/FXSpheref.h ../include/FXSpinLock.h ../include/FXSpinner.h ../include/FXSplashWindow.h ../include/FXSplitter.h ../include/FXSpring.h ../include/FXStat.h ../include/FXStatusBar.h ../include/FXStatusLine.h ../include/FXStream.h ../include/FXStringDictionary.h ../include/FXString.h ../include/FXSwitcher.h ../include/FXSystem.h ../include/FXTabBar.h ../include/FXTabBook.h ../include/FXTabItem.h ../include/FXTable.h ../include/FXTaskGroup.h ../include/FXTextCodec.h ../include/FXTextField.h ../include/FXText.h ../include/FXTGAIcon.h ../include/FXTGAImage.h ../include/FXThread.h ../include/FXThreadPool.h ../include/FXTIFIcon.h ../include/FXTIFImage.h ../include/FXToggleButton.h ../include/FXToolBarGrip.h ../include/FXToolBar.h ../include/FXToolBarShell.h ../include/FXToolBarTab.h ../include/FXToolTip.h ../include/FXTopWindow.h ../include/FXTranslator.h ../include/FXTreeListBox.h ../include/FXTreeList.h ../include/FXTriStateButton.h ../include/FXUndoList.h ../include/fxunicode.h ../include/FXURL.h ../include/FXUTF16Codec.h ../include/FXUTF32Codec.h ../include/FXUTF8Codec.h ../include/FXVariantArray.h ../include/FXVariant.h ../include/FXVariantMap.h ../include/FXVec2d.h ../include/FXVec2f.h ../include/FXVec3d.h ../include/FXVec3f.h ../include/FXVec4d.h ../include/FXVec4f.h ../include/fxver.h ../include/FXVerticalFrame.h ../include/FXVisual.h ../include/FXWEBPIcon.h ../include/FXWEBPImage.h ../include/FXWindow.h ../include/FXWizard.h ../include/FXWorker.h ../include/FXWSQueue.h ../include/FXXBMIcon.h ../include/FXXBMImage.h ../include/FXXML.h ../include/FXXMLFile.h ../include/FXXMLString.h ../include/FXXPMIcon.h ../include/FXXPMImage.h ../include/xincs.h) set(SOURCES FX4Splitter.cpp FX7Segment.cpp FX885910Codec.cpp FX885911Codec.cpp FX885913Codec.cpp FX885914Codec.cpp FX885915Codec.cpp FX885916Codec.cpp FX88591Codec.cpp FX88592Codec.cpp FX88593Codec.cpp FX88594Codec.cpp FX88595Codec.cpp FX88596Codec.cpp FX88597Codec.cpp FX88598Codec.cpp FX88599Codec.cpp FXAccelTable.cpp FXApp.cpp FXArray.cpp FXArrowButton.cpp fxascii.cpp FXAtomic.cpp FXAutoThreadStorageKey.cpp FXBarrier.cpp fxbase64.cpp fxbase85.cpp FXBitmap.cpp FXBitmapFrame.cpp FXBitmapView.cpp FXBMPIcon.cpp FXBMPImage.cpp fxbmpio.cpp FXButton.cpp FXBZFileStream.cpp FXCanvas.cpp fxchar.cpp FXCheckButton.cpp FXChoiceBox.cpp FXColorBar.cpp FXColorDialog.cpp FXColorList.cpp FXColorRing.cpp FXColors.cpp FXColorSelector.cpp FXColorWell.cpp FXColorWheel.cpp FXComboBox.cpp FXCompletion.cpp FXComplexd.cpp FXComplexf.cpp FXComposeContext.cpp fxcompose.cpp FXComposite.cpp FXCondition.cpp FXCP1250Codec.cpp FXCP1251Codec.cpp FXCP1252Codec.cpp FXCP1253Codec.cpp FXCP1254Codec.cpp FXCP1255Codec.cpp FXCP1256Codec.cpp FXCP1257Codec.cpp FXCP1258Codec.cpp FXCP437Codec.cpp FXCP850Codec.cpp FXCP852Codec.cpp FXCP855Codec.cpp FXCP856Codec.cpp FXCP857Codec.cpp FXCP860Codec.cpp FXCP861Codec.cpp FXCP862Codec.cpp FXCP863Codec.cpp FXCP864Codec.cpp FXCP865Codec.cpp FXCP866Codec.cpp FXCP869Codec.cpp FXCP874Codec.cpp fxcpuid.cpp FXCURCursor.cpp FXCursor.cpp FXDataTarget.cpp FXDate.cpp FXDC.cpp FXDCWindow.cpp FXDDSIcon.cpp FXDDSImage.cpp fxddsio.cpp FXDebugTarget.cpp FXDelegator.cpp FXDial.cpp FXDialogBox.cpp FXDictionary.cpp FXDirBox.cpp FXDir.cpp FXDirDialog.cpp FXDirList.cpp FXDirSelector.cpp FXDirVisitor.cpp FXDirWatch.cpp FXDispatcher.cpp FXDisplay.cpp FXDLL.cpp FXDockBar.cpp FXDockHandler.cpp FXDockSite.cpp FXDocument.cpp FXDragCorner.cpp FXDrawable.cpp FXDriveBox.cpp FXEventDispatcher.cpp FXEventLoop.cpp FXException.cpp FXEXEIcon.cpp FXEXEImage.cpp fxexeio.cpp FXExpression.cpp FXExtentd.cpp FXExtentf.cpp fxezquantize.cpp FXFileAssociations.cpp FXFile.cpp FXFileDialog.cpp FXFileList.cpp FXFileSelector.cpp FXFileStream.cpp FXFoldingList.cpp FXFont.cpp FXFontDialog.cpp FXFontSelector.cpp FXFrame.cpp fxfsquantize.cpp FXGIFCursor.cpp FXGIFIcon.cpp FXGIFImage.cpp fxgifio.cpp FXGLCanvas.cpp FXGLContext.cpp FXGLVisual.cpp FXGradientBar.cpp FXGroupBox.cpp FXGZFileStream.cpp FXhalf.cpp FXHash.cpp FXHeader.cpp FXHorizontalFrame.cpp FXICOIcon.cpp FXICOImage.cpp FXIconCache.cpp FXIcon.cpp FXIconList.cpp FXIconSource.cpp FXId.cpp FXIFFIcon.cpp FXIFFImage.cpp fxiffio.cpp FXImage.cpp FXImageFrame.cpp FXImageView.cpp FXINI.cpp FXINIFile.cpp FXInputDialog.cpp FXIOBuffer.cpp FXIO.cpp FXIODevice.cpp FXJP2Icon.cpp FXJP2Image.cpp fxjp2io.cpp fxjpegio.cpp FXJPGIcon.cpp FXJPGImage.cpp FXJSON.cpp FXJSONFile.cpp FXJSONString.cpp fxkeyboard.cpp fxkeysym.cpp FXKOI8RCodec.cpp FXLabel.cpp fxleaps.cpp FXLFQueue.cpp FXListBox.cpp FXList.cpp FXLocale.cpp FXMainWindow.cpp FXMappedFile.cpp fxmath.cpp FXMatrix.cpp FXMemoryStream.cpp FXMenuBar.cpp FXMenuButton.cpp FXMenuCaption.cpp FXMenuCascade.cpp FXMenuCheck.cpp FXMenuCommand.cpp FXMenuPane.cpp FXMenuRadio.cpp FXMenuSeparator.cpp FXMenuTitle.cpp FXMessageBox.cpp FXMessageChannel.cpp FXMetaClass.cpp FXMutex.cpp fxntp.cpp FXObject.cpp FXObjectList.cpp FXOptionMenu.cpp fxosver.cpp FXPacker.cpp FXParseBuffer.cpp fxparsegeometry.cpp FXPath.cpp FXPCXIcon.cpp FXPCXImage.cpp fxpcxio.cpp FXPicker.cpp FXPipe.cpp FXPNGIcon.cpp FXPNGImage.cpp fxpngio.cpp FXPoint.cpp FXPopup.cpp FXPPMIcon.cpp FXPPMImage.cpp fxppmio.cpp FXPrintDialog.cpp fxprintf.cpp fxpriv.cpp FXProcess.cpp FXProgressBar.cpp FXProgressDialog.cpp FXPtrList.cpp FXPtrQueue.cpp FXReactor.cpp FXRadioButton.cpp FXRandom.cpp FXRangeSlider.cpp FXRASIcon.cpp FXRASImage.cpp fxrasio.cpp FXReadWriteLock.cpp FXRealSlider.cpp FXRealSpinner.cpp FXRecentFiles.cpp FXRectangle.cpp FXRegion.cpp FXRegistry.cpp FXReplaceDialog.cpp FXReverseDictionary.cpp FXRex.cpp FXRGBIcon.cpp FXRGBImage.cpp fxrgbio.cpp FXRootWindow.cpp FXRuler.cpp FXRulerView.cpp fxscanf.cpp FXScopedThread.cpp FXScrollArea.cpp FXScrollBar.cpp FXScrollPane.cpp FXScrollWindow.cpp FXSearchDialog.cpp FXSemaphore.cpp FXSemaQueue.cpp FXSeparator.cpp FXSettings.cpp FXShell.cpp FXShutter.cpp FXSize.cpp FXSlider.cpp FXSpinLock.cpp FXSpinner.cpp FXSplashWindow.cpp FXSplitter.cpp FXSpring.cpp FXStat.cpp FXStatusBar.cpp FXStatusLine.cpp FXStream.cpp FXString.cpp FXStringDictionary.cpp fxstrtod.cpp fxstrtoll.cpp fxstrtoull.cpp FXSwitcher.cpp FXSystem.cpp FXSystemTime.cpp FXSystemTimeFormat.cpp FXSystemTimeParse.cpp fxtabbify.cpp FXTabBar.cpp FXTabBook.cpp FXTabItem.cpp FXTable.cpp fxtargaio.cpp FXTaskGroup.cpp FXTextCodec.cpp FXText.cpp FXTextField.cpp FXTGAIcon.cpp FXTGAImage.cpp FXThread.cpp FXThreadPool.cpp FXTIFIcon.cpp FXTIFImage.cpp fxtifio.cpp FXToggleButton.cpp FXToolBar.cpp FXToolBarGrip.cpp FXToolBarShell.cpp FXToolBarTab.cpp FXToolTip.cpp FXTopWindow.cpp FXTranslator.cpp FXTreeListBox.cpp FXTreeList.cpp FXTriStateButton.cpp FXUndoList.cpp fxunicode.cpp FXURL.cpp FXUTF16Codec.cpp FXUTF32Codec.cpp FXUTF8Codec.cpp fxutils.cpp FXVariantArray.cpp FXVariant.cpp FXVariantMap.cpp FXVec3f.cpp FXVec4f.cpp FXVerticalFrame.cpp FXVisual.cpp FXWEBPIcon.cpp FXWEBPImage.cpp fxwebpio.cpp FXWindow.cpp FXWorker.cpp FXWSQueue.cpp fxwuquantize.cpp FXXBMIcon.cpp FXXBMImage.cpp fxxbmio.cpp FXXML.cpp FXXMLFile.cpp FXXMLString.cpp FXXPMIcon.cpp FXXPMImage.cpp fxxpmio.cpp icons.cpp) set(ICONS arrownext.gif arrowprev.gif bigapp.gif bigcdrom.gif bigcomputer.gif bigdesktop.gif bigdoc.gif bigfloppy.gif bigfloppy3.gif bigfloppy5.gif bigfolder.gif bigfolderopen.gif bigharddisk.gif bignetdrive.gif bignethood.gif bookclr_gif.gif bookdel_gif.gif bookmrk_gif.gif bookset_gif.gif clearentry.gif cmymode.gif dialmode.gif dirup_gif.gif docktop.gif dockbottom.gif dockleft.gif dockright.gif dockfree.gif dockflip.gif entericon.gif erroricon.gif eyedrop.gif filecancel.gif fileaccept.gif filecopy.gif filemove.gif filehidden.gif filelink.gif filerename.gif filedelete.gif fileshown.gif foldernew.gif hammer_gif.gif gotohome.gif gotowork.gif hsvmode.gif infoicon.gif landscape.gif listmode.gif miniapp.gif minicdrom.gif minicomputer.gif minidesktop.gif minidoc.gif minifloppy.gif minifloppy3.gif minifloppy5.gif minifolder.gif minifolderopen.gif miniharddisk.gif mininetdrive.gif mininethood.gif minizipdrive.gif newfolder.bmp portrait.gif questionicon.gif redo_gif.gif rgbmode.gif searchicon.gif showbigicons.gif showdetails.gif showsmallicons.gif sorting.bmp undo_gif.gif warningicon.gif winclose.gif winmaximize.gif winminimize.gif winrestore.gif) add_library(cfox ${SOURCES}) find_package(PkgConfig) find_package(Threads) find_package(X11) find_package(Freetype) pkg_check_modules(FONTCONFIG fontconfig) if(WITH_OPENGL) find_package(OpenGL) endif() check_cxx_source_compiles( "#include int main(int argc,char *argv) { return 0; }" HAVE_IMMINTRIN_H) if(HAVE_IMMINTRIN_H) add_definitions(-DHAVE_IMMINTRIN_H) endif() check_cxx_symbol_exists(localtime_r "time.h" HAVE_LOCALTIME_R) if(HAVE_LOCALTIME_R) add_definitions(-DHAVE_LOCALTIME_R) endif() check_cxx_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME_NORT) if(NOT HAVE_CLOCK_GETTIME_NORT) cmake_push_check_state() set(CMAKE_REQUIRED_LIBRARIES -lrt) check_cxx_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME) if(HAVE_CLOCK_GETTIME) list(APPEND LIBRARIES -lrt) endif() cmake_pop_check_state() endif() cmake_push_check_state() check_include_file_cxx(dlfcn.h HAVE_DLFCN_H) if(HAVE_DLFCN_H) add_definitions(-DHAVE_DLFCN_H) endif() set(CMAKE_REQUIRED_LIBRARIES -ldl) check_cxx_symbol_exists(dlopen "dlfcn.h" HAVE_DLOPEN) if(HAVE_DLOPEN) list(APPEND LIBRARIES -ldl) endif() cmake_pop_check_state() cmake_push_check_state() set(CMAKE_REQUIRED_LIBRARIES -ldld) check_cxx_symbol_exists(shl_load "" HAVE_SHL_LOAD) if(HAVE_DLOPEN_NODL) add_definitions(-DHAVE_SHL_LOAD) list(APPEND LIBRARIES -ldld) endif() cmake_pop_check_state() check_cxx_symbol_exists(gmtime_r "time.h" HAVE_GMTIME_R) if(HAVE_GMTIME_R) add_definitions(-DHAVE_GMTIME_R) endif() check_cxx_symbol_exists(readdir_r "dirent.h" HAVE_READDIR_R) if(HAVE_READDIR_R) add_definitions(-DHAVE_READDIR_R) endif() check_cxx_symbol_exists(getpwuid_r "sys/types.h;pwd.h" HAVE_GETPWUID_R) if(HAVE_GETPWUID_R) add_definitions(-DHAVE_GETPWUID_R) endif() check_cxx_symbol_exists(getpwnam_r "sys/types.h;pwd.h" HAVE_GETPWNAM_R) if(HAVE_GETPWNAM_R) add_definitions(-DHAVE_GETPWNAM_R) endif() check_cxx_symbol_exists(getgrgid_r "sys/types.h;grp.h" HAVE_GETGRGID_R) if(HAVE_GETGRGID_R) add_definitions(-DHAVE_GETGRGID_R) endif() check_cxx_symbol_exists(uname "sys/utsname.h" HAVE_SYS_UTSNAME_H) if(HAVE_SYS_UTSNAME_H) add_definitions(-DHAVE_SYS_UTSNAME_H) endif() cmake_push_check_state() set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) set(CMAKE_REQUIRED_LIBRARIES -pthread) set(CMAKE_REQUIRED_FLAGS -pthread) check_cxx_symbol_exists(pthread_setaffinity_np "pthread.h" HAVE_PTHREAD_SETAFFINITY_NP) if(HAVE_PTHREAD_SETAFFINITY_NP) add_definitions(-DHAVE_PTHREAD_SETAFFINITY_NP) endif() cmake_pop_check_state() cmake_push_check_state() set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) check_cxx_symbol_exists(pipe2 "fcntl.h;unistd.h" HAVE_PIPE2) if(HAVE_PIPE2) add_definitions(-DHAVE_PIPE2) endif() cmake_pop_check_state() check_cxx_symbol_exists(sched_getcpu "sched.h" HAVE_SCHED_GETCPU) if(HAVE_SCHED_GETCPU) add_definitions(-DHAVE_SCHED_GETCPU) endif() check_cxx_symbol_exists(epoll_create1 "sys/epoll.h" HAVE_EPOLL_CREATE1) if(HAVE_EPOLL_CREATE1) add_definitions(-DHAVE_EPOLL_CREATE1) endif() check_cxx_symbol_exists(timerfd_create "sys/timerfd.h" HAVE_TIMERFD_CREATE) if(HAVE_TIMERFD_CREATE) add_definitions(-DHAVE_TIMERFD_CREATE) endif() check_cxx_symbol_exists(inotify_init1 "sys/inotify.h" HAVE_INOTIFY_INIT1) if(HAVE_INOTIFY_INIT1) add_definitions(-DHAVE_INOTIFY_INIT1) endif() check_cxx_symbol_exists(statvfs "sys/statvfs.h" HAVE_STATVFS) if(HAVE_STATVFS) add_definitions(-DHAVE_STATVFS) endif() if(FREETYPE_FOUND) include_directories(${FREETYPE_INCLUDE_DIRS}) endif() if(X11_XShm_FOUND) add_definitions(-DHAVE_XSHM_H) endif() if(X11_Xcursor_FOUND) add_definitions(-DHAVE_XCURSOR_H) list(APPEND LIBRARIES ${X11_Xcursor_LIB}) endif() if(X11_Xft_FOUND AND FREETYPE_FOUND AND FONTCONFIG_FOUND) add_definitions(-DHAVE_XFT_H) include_directories(${X11_Xft_INCLUDE_PATH}) list(APPEND LIBRARIES ${X11_Xft_LIB} ${FONTCONFIG_LIBRARIES} ${FREETYPE_LIBRARIES}) endif() if(X11_Xshape_FOUND) add_definitions(-DHAVE_XSHAPE_H) list(APPEND LIBRARIES ${X11_Xshape_LIB}) endif() if(X11_Xrandr_FOUND) add_definitions(-DHAVE_XRANDR_H) list(APPEND LIBRARIES ${X11_Xrandr_LIB}) endif() if(X11_Xfixes_FOUND) add_definitions(-DHAVE_XFIXES_H) list(APPEND LIBRARIES ${X11_Xfixes_LIB}) endif() if(X11_Xrender_FOUND) add_definitions(-DHAVE_XRENDER_H) list(APPEND LIBRARIES ${X11_Xrender_LIB}) endif() # check for xinput2 # find_path(X11_Xi2_INCLUDE_PATH X11/extensions/XInput2.h ${X11_INC_SEARCH_PATH}) # if (X11_Xi2_INCLUDE_PATH AND X11_Xi_LIB) # set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xi2_INCLUDE_PATH}) # list(REMOVE_DUPLICATES X11_INCLUDE_DIR) # add_definitions(-DHAVE_XINPUT2_H) # list(APPEND LIBRARIES ${X11_Xi_LIB}) #endif () # # AC_HEADER_DIRENT # This macro is obsolescent, as all current systems with directory libraries have . # New programs need not use this macro. # # Not checking for the SCO Xenix dir and x libraries. # check_cxx_source_compiles("#include \nint main(int argc,char *argv[]) { DIR * d; return 0; }" HAVE_DIRENT_H) if(HAVE_DIRENT_H) add_definitions(-DHAVE_DIRENT_H) else() check_cxx_source_compiles("#include \nint main(int argc,char *argv[]) { DIR * d; return 0; }" HAVE_SYS_NDIR_H) if(HAVE_SYS_NDIR_H) add_definitions(-DHAVE_SYS_NDIR_H) else() check_cxx_source_compiles("#include \nint main(int argc,char *argv[]) { DIR * d; return 0; }" HAVE_SYS_DIR_H) if(NOT HAVE_SYS_DIR_H) add_definitions(-DHAVE_SYS_DIR_H) else() check_cxx_source_compiles("#include \nint main(int argc,char *argv[]) { DIR * d; return 0; }" HAVE_NDIR_H) if(HAVE_NDIR_H) add_definitions(-DHAVE_NDIR_H) endif() endif() endif() endif() # # AC_HEADER_TIME # # This macro is obsolescent, as current systems can include both files when they exist. # New programs need not use this macro. # check_include_file_cxx(sys/time.h HAVE_SYS_TIME_H) if(HAVE_SYS_TIME_H) add_definitions(-DHAVE_SYS_TIME_H) check_cxx_source_compiles("#include \n#include \nint main(int arc,char * argv[]) { return 0; }" TIME_WITH_SYS_TIME) if(TIME_WITH_SYS_TIME) add_definitions(-DTIME_WITH_SYS_TIME) endif() endif() # # AC_HEADER_SYS_WAIT # # If sys/wait.h is not Posix compatible, then instead of including it, define the Posix macros with their usual interpretations. # This macro is obsolescent, as current systems are compatible with Posix. New programs need not use this macro. # New programs need not use this macro. # # cmake: only check for header file since FOX doesn't define the alternative macros check_include_file_cxx(sys/wait.h HAVE_SYS_WAIT_H) if(HAVE_SYS_WAIT_H) add_definitions(-DHAVE_SYS_WAIT_H) endif() check_include_file_cxx(semaphore.h HAVE_SEMAPHORE_H) if(HAVE_SEMAPHORE_H) add_definitions(-DHAVE_SEMAPHORE_H) endif() check_include_file_cxx(unistd.h HAVE_UNISTD_H) if(HAVE_UNISTD_H) add_definitions(-DHAVE_UNISTD_H) endif() check_include_file_cxx(sys/dir.h HAVE_SYS_DIR_H) if(HAVE_SYS_DIR_H) add_definitions(-DHAVE_SYS_DIR_H) endif() check_include_file_cxx(sys/filio.h HAVE_SYS_FILIO_H) if(HAVE_SYS_FILIO_H) add_definitions(-DHAVE_SYS_FILIO_H) endif() check_include_file_cxx(sys/mman.h HAVE_SYS_MMAN_H) if(HAVE_SYS_MMAN_H) add_definitions(-DHAVE_SYS_MMAN_H) endif() check_include_file_cxx(sys/mount.h HAVE_SYS_MOUNT_H) if(HAVE_SYS_MOUNT_H) add_definitions(-DHAVE_SYS_MOUNT_H) endif() check_include_file_cxx(sys/param.h HAVE_SYS_PARAM_H) if(HAVE_SYS_PARAM_H) add_definitions(-DHAVE_SYS_PARAM_H) endif() check_include_file_cxx(sys/select.h HAVE_SYS_SELECT_H) if(HAVE_SYS_SELECT_H) add_definitions(-DHAVE_SYS_SELECT_H) endif() check_include_file_cxx(sys/epoll.h HAVE_SYS_EPOLL_H) if(HAVE_SYS_EPOLL_H) add_definitions(-DHAVE_SYS_EPOLL_H) endif() check_include_file_cxx(sys/shm.h HAVE_SYS_SHM_H) if(HAVE_SYS_SHM_H) add_definitions(-DHAVE_SYS_SHM_H) endif() check_include_file_cxx(sys/statvfs.h HAVE_SYS_STATVFS_H) if(HAVE_SYS_STATVFS_H) add_definitions(-DHAVE_SYS_STATVFS_H) endif() check_include_file_cxx(sys/pstat.h HAVE_SYS_PSTAT_H) if(HAVE_SYS_PSTAT_H) add_definitions(-DHAVE_SYS_PSTAT_H) endif() check_include_file_cxx(sys/inotify.h HAVE_SYS_INOTIFY_H) if(HAVE_SYS_INOTIFY_H) add_definitions(-DHAVE_SYS_INOTIFY_H) endif() if(WITH_JPEG) find_package(JPEG) if(JPEG_FOUND) list(APPEND LIBRARIES ${JPEG_LIBRARIES}) add_definitions(-DHAVE_JPEG_H) endif() endif() if(WITH_PNG) find_package(PNG) if(TARGET PNG::PNG) list(APPEND LIBRARIES PNG::PNG) add_definitions(-DHAVE_PNG_H) endif() endif() if(WITH_ZLIB) find_package(ZLIB) if(TARGET ZLIB::ZLIB) list(APPEND LIBRARIES ZLIB::ZLIB) add_definitions(-DHAVE_ZLIB_H) endif() endif() if(WITH_BZ2LIB) find_package(BZip2) if(TARGET BZip2::BZip2) list(APPEND LIBRARIES BZip2::BZip2) add_definitions(-DHAVE_BZ2LIB_H) endif() endif() if(WITH_TIFF) find_package(TIFF) if(TARGET TIFF::TIFF) list(APPEND LIBRARIES TIFF::TIFF) add_definitions(-DHAVE_TIFF_H) endif() endif() if(WITH_WEBP) pkg_check_modules(WEBP libwebp) if(WEBP_FOUND) list(APPEND LIBRARIES ${WEBP_LIBRARIES}) add_definitions(-DHAVE_WEBP_H) endif() endif() if(WITH_OPENJPEG) pkg_check_modules(OPENJPEG libopenjpeg1) if(OPENJPEG_FOUND) list(APPEND LIBRARIES ${OPENJPEG_LIBRARIES}) add_definitions(-DHAVE_JP2_H) include_directories(${OPENJPEG_INCLUDE_DIRS}) else() pkg_check_modules(OPENJPEG libopenjpeg) if(OPENJPEG_FOUND) list(APPEND LIBRARIES ${OPENJPEG_LIBRARIES}) add_definitions(-DHAVE_JP2_H) include_directories(${OPENJPEG_INCLUDE_DIRS}) endif() endif() endif() if(WITH_OPENGL) pkg_check_modules(EPOXY REQUIRED epoxy) target_compile_definitions(cfox PUBLIC -DHAVE_GL_H) list(APPEND LIBRARIES ${EPOXY_LIBRARIES}) add_definitions(-DHAVE_EPOXY) endif() if(NOT WITH_XIM) add_definitions(-DNO_XIM) endif() target_include_directories(cfox PUBLIC ${PROJECT_SOURCE_DIR}/include) target_link_libraries(cfox PRIVATE ${X11_LIBRARIES} ${LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) add_custom_command( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/icons.cpp ${CMAKE_CURRENT_SOURCE_DIR}/icons.h COMMAND reswrap -nc -h -n FX -o icons.h ${ICONS} COMMAND reswrap -nc -i icons.h -n FX -o icons.cpp ${ICONS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS reswrap VERBATIM ) set_target_properties(cfox PROPERTIES VERSION ${cfox_VERSION} SOVERSION ${cfox_VERSION_PATCH}) set_target_properties(cfox PROPERTIES OUTPUT_NAME cfox-${cfox_VERSION_MAJOR}.${cfox_VERSION_MINOR}) # don't distribute for cfox # install(TARGETS cfox # ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # ) # install(FILES ${HEADERS} DESTINATION include/cfox-${cfox_VERSION_MAJOR}.${cfox_VERSION_MINOR}) gogglesmm-gogglesmm-0b8cb53/cfox/lib/FX4Splitter.cpp000066400000000000000000000471611455751074500224510ustar00rootroot00000000000000/******************************************************************************** * * * F o u r - W a y S p l i t t e r * * * ********************************************************************************* * Copyright (C) 1999,2023 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FX4Splitter.h" /* Notes: - 4Splitter always splits into four partitions. - 4Splitter determines pane sizes by split fraction, i.e. if 4Splitter resizes, each sub pane gets proportionally resized also. - Should we send SEL_CHANGED and SEL_COMMAND also when splitter arrangement was changed programmatically? - Slightly complex code which takes care of expanding subsets of panels judiciously added 2/8/2006. */ // Splitter styles #define FOURSPLITTER_MASK (FOURSPLITTER_TRACKING|FOURSPLITTER_HORIZONTAL|FOURSPLITTER_VERTICAL) // Modes #define NOWHERE 0 #define ONVERTICAL 1 #define ONHORIZONTAL 2 #define ONCENTER (ONVERTICAL|ONHORIZONTAL) using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FX4Splitter) FX4SplitterMap[]={ FXMAPFUNC(SEL_MOTION,0,FX4Splitter::onMotion), FXMAPFUNC(SEL_LEFTBUTTONPRESS,0,FX4Splitter::onLeftBtnPress), FXMAPFUNC(SEL_LEFTBUTTONRELEASE,0,FX4Splitter::onLeftBtnRelease), FXMAPFUNC(SEL_FOCUS_UP,0,FX4Splitter::onFocusUp), FXMAPFUNC(SEL_FOCUS_DOWN,0,FX4Splitter::onFocusDown), FXMAPFUNC(SEL_FOCUS_LEFT,0,FX4Splitter::onFocusLeft), FXMAPFUNC(SEL_FOCUS_RIGHT,0,FX4Splitter::onFocusRight), FXMAPFUNCS(SEL_UPDATE,FX4Splitter::ID_EXPAND_NONE,FX4Splitter::ID_EXPAND_ALL,FX4Splitter::onUpdExpand), FXMAPFUNCS(SEL_COMMAND,FX4Splitter::ID_EXPAND_NONE,FX4Splitter::ID_EXPAND_ALL,FX4Splitter::onCmdExpand), }; // Object implementation FXIMPLEMENT(FX4Splitter,FXComposite,FX4SplitterMap,ARRAYNUMBER(FX4SplitterMap)) // Make a splitter FX4Splitter::FX4Splitter(){ flags|=FLAG_ENABLED|FLAG_SHOWN; splitx=0; splity=0; barsize=4; fhor=5000; fver=5000; offx=0; offy=0; mode=NOWHERE; } // Make a splitter; it has no interior padding, and no borders FX4Splitter::FX4Splitter(FXComposite* p,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXComposite(p,opts,x,y,w,h){ defaultCursor=getApp()->getDefaultCursor(DEF_ARROW_CURSOR); dragCursor=defaultCursor; flags|=FLAG_ENABLED|FLAG_SHOWN; splitx=0; splity=0; barsize=4; fhor=5000; fver=5000; offx=0; offy=0; mode=NOWHERE; } // Make a splitter; it has no interior padding, and no borders FX4Splitter::FX4Splitter(FXComposite* p,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXComposite(p,opts,x,y,w,h){ defaultCursor=getApp()->getDefaultCursor(DEF_ARROW_CURSOR); dragCursor=defaultCursor; flags|=FLAG_ENABLED|FLAG_SHOWN; target=tgt; message=sel; splitx=0; splity=0; barsize=4; fhor=5000; fver=5000; offx=0; offy=0; mode=NOWHERE; } // Get top left child FXWindow *FX4Splitter::getTopLeft() const { return getFirst(); } // Get top right child FXWindow *FX4Splitter::getTopRight() const { return getTopLeft() ? getTopLeft()->getNext() : nullptr; } // Get bottom left child FXWindow *FX4Splitter::getBottomLeft() const { return getTopRight() ? getTopRight()->getNext() : nullptr; } // Get bottom right child FXWindow *FX4Splitter::getBottomRight() const { return getBottomLeft() ? getBottomLeft()->getNext() : nullptr; } // Get default width FXint FX4Splitter::getDefaultWidth(){ FXWindow *ptl=getTopLeft(); FXWindow *ptr=getTopRight(); FXWindow *pbl=getBottomLeft(); FXWindow *pbr=getBottomRight(); FXint tlw=0,blw=0,trw=0,brw=0,set=0; if(ptl && ptl->shown()){ tlw=ptl->getDefaultWidth(); set|=ExpandTopLeft; } if(ptr && ptr->shown()){ trw=ptr->getDefaultWidth(); set|=ExpandTopRight; } if(pbl && pbl->shown()){ blw=pbl->getDefaultWidth(); set|=ExpandBottomLeft; } if(pbr && pbr->shown()){ brw=pbr->getDefaultWidth(); set|=ExpandBottomRight; } switch(set){ // None expanded case ExpandNone: return 0; // Single panel expanded case ExpandTopLeft: return tlw; case ExpandTopRight: return trw; case ExpandBottomLeft: return blw; case ExpandBottomRight: return brw; // Two panels expanded on same row/column case ExpandTopLeft|ExpandTopRight: return tlw+trw+barsize; case ExpandBottomLeft|ExpandBottomRight: return blw+brw+barsize; case ExpandTopLeft|ExpandBottomLeft: return FXMAX(tlw,blw); case ExpandTopRight|ExpandBottomRight: return FXMAX(trw,brw); // Diagonally opposite panels expanded case ExpandTopLeft|ExpandBottomRight: return (options&FOURSPLITTER_VERTICAL)?tlw+brw+barsize:FXMAX(brw,tlw); case ExpandTopRight|ExpandBottomLeft: return (options&FOURSPLITTER_VERTICAL)?trw+blw+barsize:FXMAX(blw,trw); // Three panels expanded case ExpandTopLeft|ExpandTopRight|ExpandBottomLeft: return (options&FOURSPLITTER_VERTICAL)?FXMAX(tlw,blw)+trw+barsize:FXMAX(tlw+trw+barsize,blw); case ExpandTopLeft|ExpandTopRight|ExpandBottomRight: return (options&FOURSPLITTER_VERTICAL)?tlw+FXMAX(trw,brw)+barsize:FXMAX(tlw+trw+barsize,brw); case ExpandTopLeft|ExpandBottomLeft|ExpandBottomRight: return (options&FOURSPLITTER_VERTICAL)?FXMAX(tlw,blw)+brw+barsize:FXMAX(tlw,blw+brw+barsize); case ExpandTopRight|ExpandBottomLeft|ExpandBottomRight: return (options&FOURSPLITTER_VERTICAL)?blw+FXMAX(trw,brw)+barsize:FXMAX(trw,blw+brw+barsize); } // Default is all expanded return FXMAX(tlw,blw)+FXMAX(trw,brw)+barsize; } // Get default height FXint FX4Splitter::getDefaultHeight(){ FXWindow *ptl=getTopLeft(); FXWindow *ptr=getTopRight(); FXWindow *pbl=getBottomLeft(); FXWindow *pbr=getBottomRight(); FXint tlh=0,blh=0,trh=0,brh=0,set=0; if(ptl && ptl->shown()){ tlh=ptl->getDefaultHeight(); set|=ExpandTopLeft; } if(ptr && ptr->shown()){ trh=ptr->getDefaultHeight(); set|=ExpandTopRight; } if(pbl && pbl->shown()){ blh=pbl->getDefaultHeight(); set|=ExpandBottomLeft; } if(pbr && pbr->shown()){ brh=pbr->getDefaultHeight(); set|=ExpandBottomRight; } switch(set){ // None expanded case ExpandNone: return 0; // Single panel expanded case ExpandTopLeft: return tlh; case ExpandTopRight: return trh; case ExpandBottomLeft: return blh; case ExpandBottomRight: return brh; // Two panels expanded on same row/column case ExpandTopLeft|ExpandTopRight: return FXMAX(tlh,trh); case ExpandBottomLeft|ExpandBottomRight: return FXMAX(blh,brh); case ExpandTopLeft|ExpandBottomLeft: return tlh+blh+barsize; case ExpandTopRight|ExpandBottomRight: return trh+brh+barsize; // Diagonally opposite panels expanded case ExpandTopLeft|ExpandBottomRight: return (options&FOURSPLITTER_VERTICAL)?FXMAX(tlh,brh):tlh+brh+barsize; case ExpandTopRight|ExpandBottomLeft: return (options&FOURSPLITTER_VERTICAL)?FXMAX(trh,brh):trh+blh+barsize; // Three panels expanded case ExpandTopLeft|ExpandTopRight|ExpandBottomLeft: return (options&FOURSPLITTER_VERTICAL)?FXMAX(tlh+blh+barsize,trh):FXMAX(tlh,trh)+blh+barsize; case ExpandTopLeft|ExpandTopRight|ExpandBottomRight: return (options&FOURSPLITTER_VERTICAL)?FXMAX(tlh,trh+brh+barsize):FXMAX(tlh,trh)+brh+barsize; case ExpandTopLeft|ExpandBottomLeft|ExpandBottomRight: return (options&FOURSPLITTER_VERTICAL)?FXMAX(tlh+blh+barsize,brh):tlh+FXMAX(blh,brh)+barsize; case ExpandTopRight|ExpandBottomLeft|ExpandBottomRight: return (options&FOURSPLITTER_VERTICAL)?FXMAX(blh,trh+brh+barsize):trh+FXMAX(blh,brh)+barsize; } // Default is all expanded return FXMAX(tlh,trh)+FXMAX(blh,brh)+barsize; } // Recompute layout void FX4Splitter::layout(){ FXWindow *ptl=getTopLeft(); FXWindow *ptr=getTopRight(); FXWindow *pbl=getBottomLeft(); FXWindow *pbr=getBottomRight(); FXuint set=getExpanded(); FXint tsx,bsx,lsy,rsy; FXASSERT(0<=fhor && fhor<=10000); FXASSERT(0<=fver && fver<=10000); // Proposed split location splitx=(fhor*(width-barsize))/10000; splity=(fver*(height-barsize))/10000; // Default is all four expanded tsx=bsx=splitx; lsy=rsy=splity; switch(set){ // None expanded case ExpandNone: tsx=bsx=width; lsy=rsy=height; break; // Single panel expanded case ExpandTopLeft: tsx=bsx=width; lsy=rsy=height; break; case ExpandTopRight: tsx=bsx=-barsize; lsy=rsy=height; break; case ExpandBottomLeft: tsx=bsx=width; lsy=rsy=-barsize; break; case ExpandBottomRight: tsx=bsx=-barsize; lsy=rsy=-barsize; break; // Two panels expanded on same row/column case ExpandTopLeft|ExpandTopRight: lsy=rsy=height; break; case ExpandBottomLeft|ExpandBottomRight: lsy=rsy=-barsize; break; case ExpandTopLeft|ExpandBottomLeft: tsx=bsx=width; break; case ExpandTopRight|ExpandBottomRight: tsx=bsx=-barsize; break; // Diagonally opposite panels expanded case ExpandTopLeft|ExpandBottomRight: if(options&FOURSPLITTER_VERTICAL){ lsy=height; rsy=-barsize; } else { tsx=width; bsx=-barsize; } break; case ExpandTopRight|ExpandBottomLeft: if(options&FOURSPLITTER_VERTICAL){ lsy=-barsize; rsy=height; } else { tsx=-barsize; bsx=width; } break; // Three panels expanded case ExpandTopLeft|ExpandTopRight|ExpandBottomLeft: if(options&FOURSPLITTER_VERTICAL){ rsy=height; } else { bsx=width; } break; case ExpandTopLeft|ExpandTopRight|ExpandBottomRight: if(options&FOURSPLITTER_VERTICAL){ lsy=height; } else { bsx=-barsize; } break; case ExpandTopLeft|ExpandBottomLeft|ExpandBottomRight: if(options&FOURSPLITTER_VERTICAL){ rsy=-barsize; } else { tsx=width; } break; case ExpandTopRight|ExpandBottomLeft|ExpandBottomRight: if(options&FOURSPLITTER_VERTICAL){ lsy=-barsize; } else { tsx=-barsize; } break; } // Arrange the kids if(ptl) ptl->position(0,0,tsx,lsy); if(ptr) ptr->position(tsx+barsize,0,width-tsx-barsize,rsy); if(pbl) pbl->position(0,lsy+barsize,bsx,height-lsy-barsize); if(pbr) pbr->position(bsx+barsize,rsy+barsize,width-bsx-barsize,height-rsy-barsize); // Layout ok now flags&=~FLAG_DIRTY; } // Determine split mode FXuchar FX4Splitter::getMode(FXint x,FXint y){ FXuchar mm=ONCENTER; if(x=splitx+barsize) mm&=~ONVERTICAL; if(y>=splity+barsize) mm&=~ONHORIZONTAL; return mm; } // Move the split intelligently void FX4Splitter::moveSplit(FXint x,FXint y){ if(x<0) x=0; if(y<0) y=0; if(x>width-barsize) x=width-barsize; if(y>height-barsize) y=height-barsize; splitx=x; splity=y; } // Draw the horizontal split void FX4Splitter::drawSplit(FXint x,FXint y,FXuint m){ FXDCWindow dc(this); dc.clipChildren(false); dc.setFunction(BLT_NOT_DST); if(m&ONVERTICAL){ dc.fillRectangle(x,0,barsize,height); } if(m&ONHORIZONTAL){ dc.fillRectangle(0,y,width,barsize); } } // Adjust layout void FX4Splitter::adjustLayout(){ fhor=(width>barsize) ? (10000*splitx+(width-barsize-1))/(width-barsize) : 0; fver=(height>barsize) ? (10000*splity+(height-barsize-1))/(height-barsize) : 0; recalc(); } // Button being pressed long FX4Splitter::onLeftBtnPress(FXObject*,FXSelector,void* ptr){ FXEvent* ev=(FXEvent*)ptr; if(isEnabled()){ grab(); if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONPRESS,message),ptr)) return 1; mode=getMode(ev->win_x,ev->win_y); if(mode){ offx=ev->win_x-splitx; offy=ev->win_y-splity; if(!(options&FOURSPLITTER_TRACKING)){ drawSplit(splitx,splity,mode); } flags&=~FLAG_UPDATE; } return 1; } return 0; } // Button being released long FX4Splitter::onLeftBtnRelease(FXObject*,FXSelector,void* ptr){ FXuint f=flags; FXuint m=mode; if(isEnabled()){ ungrab(); flags|=FLAG_UPDATE; flags&=~FLAG_CHANGED; mode=NOWHERE; if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONRELEASE,message),ptr)) return 1; if(m){ if(!(options&FOURSPLITTER_TRACKING)){ drawSplit(splitx,splity,m); adjustLayout(); if(f&FLAG_CHANGED){ if(target) target->tryHandle(this,FXSEL(SEL_CHANGED,message),nullptr); } } if(f&FLAG_CHANGED){ if(target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),nullptr); } } return 1; } return 0; } // Button being released long FX4Splitter::onMotion(FXObject*,FXSelector,void* ptr){ FXEvent* ev=(FXEvent*)ptr; FXint oldsplitx=splitx; FXint oldsplity=splity; switch(mode){ case ONCENTER: moveSplit(ev->win_x-offx,ev->win_y-offy); break; case ONVERTICAL: moveSplit(ev->win_x-offx,splity); break; case ONHORIZONTAL: moveSplit(splitx,ev->win_y-offy); break; default: switch(getMode(ev->win_x,ev->win_y)){ case ONCENTER: setDefaultCursor(getApp()->getDefaultCursor(DEF_XSPLIT_CURSOR)); setDragCursor(getApp()->getDefaultCursor(DEF_XSPLIT_CURSOR)); break; case ONVERTICAL: setDefaultCursor(getApp()->getDefaultCursor(DEF_HSPLIT_CURSOR)); setDragCursor(getApp()->getDefaultCursor(DEF_HSPLIT_CURSOR)); break; case ONHORIZONTAL: setDefaultCursor(getApp()->getDefaultCursor(DEF_VSPLIT_CURSOR)); setDragCursor(getApp()->getDefaultCursor(DEF_VSPLIT_CURSOR)); break; default: setDefaultCursor(getApp()->getDefaultCursor(DEF_ARROW_CURSOR)); setDragCursor(getApp()->getDefaultCursor(DEF_ARROW_CURSOR)); break; } return 1; } if((oldsplitx!=splitx) || (oldsplity!=splity)){ flags|=FLAG_CHANGED; if(!(options&FOURSPLITTER_TRACKING)){ drawSplit(oldsplitx,oldsplity,mode); drawSplit(splitx,splity,mode); } else{ adjustLayout(); if(target) target->tryHandle(this,FXSEL(SEL_CHANGED,message),nullptr); } } return 1; } // Focus moved up long FX4Splitter::onFocusUp(FXObject*,FXSelector,void* ptr){ FXWindow *child=nullptr; if(getFocus()){ if(getFocus()==getBottomLeft()) child=getTopLeft(); else if(getFocus()==getBottomRight()) child=getTopRight(); } else{ child=getLast(); } if(child){ if(child->shown()){ if(child->handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr)) return 1; if(child->handle(this,FXSEL(SEL_FOCUS_UP,0),ptr)) return 1; } } return 0; } // Focus moved down long FX4Splitter::onFocusDown(FXObject*,FXSelector,void* ptr){ FXWindow *child=nullptr; if(getFocus()){ if(getFocus()==getTopLeft()) child=getBottomLeft(); else if(getFocus()==getTopRight()) child=getBottomRight(); } else{ child=getFirst(); } if(child){ if(child->shown()){ if(child->handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr)) return 1; if(child->handle(this,FXSEL(SEL_FOCUS_DOWN,0),ptr)) return 1; } } return 0; } // Focus moved to left long FX4Splitter::onFocusLeft(FXObject*,FXSelector,void* ptr){ FXWindow *child=nullptr; if(getFocus()){ if(getFocus()==getTopRight()) child=getTopLeft(); else if(getFocus()==getBottomRight()) child=getBottomLeft(); } else{ child=getLast(); } if(child){ if(child->shown()){ if(child->handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr)) return 1; if(child->handle(this,FXSEL(SEL_FOCUS_LEFT,0),ptr)) return 1; } } return 0; } // Focus moved to right long FX4Splitter::onFocusRight(FXObject*,FXSelector,void* ptr){ FXWindow *child=nullptr; if(getFocus()){ if(getFocus()==getTopLeft()) child=getTopRight(); else if(getFocus()==getBottomLeft()) child=getBottomRight(); } else{ child=getFirst(); } if(child){ if(child->shown()){ if(child->handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr)) return 1; if(child->handle(this,FXSEL(SEL_FOCUS_RIGHT,0),ptr)) return 1; } } return 0; } // Show the pane(s) long FX4Splitter::onCmdExpand(FXObject*,FXSelector sel,void*){ FXuint ex=FXSELID(sel)-ID_EXPAND_NONE; setExpanded(ex); return 1; } // Update show pane long FX4Splitter::onUpdExpand(FXObject* sender,FXSelector sel,void*){ FXuint ex=FXSELID(sel)-ID_EXPAND_NONE; sender->handle(this,(getExpanded()==ex)?FXSEL(SEL_COMMAND,ID_CHECK):FXSEL(SEL_COMMAND,ID_UNCHECK),nullptr); return 1; } // Change horizontal split [fraction*10000] void FX4Splitter::setHSplit(FXint s){ if(s<0) s=0; if(s>10000) s=10000; if(s!=fhor){ fhor=s; recalc(); } } // Change vertical split [fraction*10000] void FX4Splitter::setVSplit(FXint s){ if(s<0) s=0; if(s>10000) s=10000; if(s!=fver){ fver=s; recalc(); } } // Save object to stream void FX4Splitter::save(FXStream& store) const { FXComposite::save(store); store << barsize; store << fhor; store << fver; } // Load object from stream void FX4Splitter::load(FXStream& store){ FXComposite::load(store); store >> barsize; store >> fhor; store >> fver; } // Return splitter style FXuint FX4Splitter::getSplitterStyle() const { return (options&FOURSPLITTER_MASK); } // Change mode void FX4Splitter::setSplitterStyle(FXuint style){ options=(options&~FOURSPLITTER_MASK) | (style&FOURSPLITTER_MASK); } // Expand one or all of the four panes void FX4Splitter::setExpanded(FXuint set){ FXWindow *ptl=getTopLeft(); FXWindow *ptr=getTopRight(); FXWindow *pbl=getBottomLeft(); FXWindow *pbr=getBottomRight(); if(ptl){ if(set&ExpandTopLeft) ptl->show(); else ptl->hide(); } if(ptr){ if(set&ExpandTopRight) ptr->show(); else ptr->hide(); } if(pbl){ if(set&ExpandBottomLeft) pbl->show(); else pbl->hide(); } if(pbr){ if(set&ExpandBottomRight) pbr->show(); else pbr->hide(); } recalc(); } // Get set of expanded children FXuint FX4Splitter::getExpanded() const { FXWindow *ptl=getTopLeft(); FXWindow *ptr=getTopRight(); FXWindow *pbl=getBottomLeft(); FXWindow *pbr=getBottomRight(); FXuint set=0; if(ptl && ptl->shown()) set|=ExpandTopLeft; if(ptr && ptr->shown()) set|=ExpandTopRight; if(pbl && pbl->shown()) set|=ExpandBottomLeft; if(pbr && pbr->shown()) set|=ExpandBottomRight; return set; } // Change bar size void FX4Splitter::setBarSize(FXint bs){ if(bs<1) bs=1; if(bs!=barsize){ barsize=bs; recalc(); } } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FX7Segment.cpp000066400000000000000000000401561455751074500222450ustar00rootroot00000000000000/******************************************************************************** * * * 7 - S e g m e n t D i s p l a y W i d g e t * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FX7Segment.h" /* Notes: - Emulate old LED or LCD Display. - Segment numbering: 01 ----- 02 | | 04 ++ | 08 | ++ ----- 10 | | 20 ++ 100 | | ++ ----- o 80 40 - Still to add: decimal point, a few more letters. - Perhaps some control over cell spacing. */ #define JUSTIFY_MASK (JUSTIFY_HZ_APART|JUSTIFY_VT_APART) #define SEVENSEGMENT_MASK (SEVENSEGMENT_NORMAL|SEVENSEGMENT_SHADOW) using namespace FX; /*******************************************************************************/ namespace FX { const FXuint segm[]={ 0x0000, // 20 SPACE 0x0000, // 21 ! 0x0000, // 22 " 0x0000, // 23 # 0x0000, // 24 $ 0x0000, // 25 % 0x0000, // 26 & 0x0000, // 27 ' 0x0053, // 28 ( 0x0065, // 29 ) 0x0000, // 2A * 0x0000, // 2B + 0x0080, // 2C , 0x0008, // 2D - 0x0080, // 2E . 0x0000, // 2F / 0x0077, // 30 0 0x0024, // 31 1 0x005d, // 32 2 0x006d, // 33 3 0x002e, // 34 4 0x006b, // 35 5 0x007b, // 36 6 0x0025, // 37 7 0x007f, // 38 8 0x006f, // 39 9 0x0100, // 3A : 0x0100, // 3B ; 0x0000, // 3C < 0x0048, // 3D = 0x0000, // 3E > 0x0000, // 3F ? 0x0000, // 40 @ 0x003F, // 41 A 0x007A, // 42 B 0x0058, // 43 C 0x007C, // 44 D 0x005B, // 45 E 0x001B, // 46 F 0x0073, // 47 G 0x003A, // 48 H 0x0024, // 49 I 0x0064, // 4A J 0x001A, // 4B K 0x0052, // 4C L 0x0037, // 4D M 0x0038, // 4E N 0x0078, // 4F O 0x001F, // 50 P 0x002F, // 51 Q 0x0018, // 52 R 0x006B, // 53 S 0x005A, // 54 T 0x0070, // 55 U 0x0076, // 56 V 0x0076, // 57 W 0x0049, // 58 X 0x006E, // 59 Y 0x005d, // 5A Z 0x0053, // 5B [ 0x0000, // 5C 0x0065, // 5D ] 0x0000, // 5E ^ 0x0040, // 5F _ 0x0000, // 60 ` 0x003F, // 61 a 0x007A, // 62 b 0x0058, // 63 c 0x007C, // 64 d 0x005b, // 65 e 0x001B, // 66 f 0x0073, // 67 g 0x003A, // 68 h 0x0024, // 69 i 0x0064, // 6A j 0x001A, // 6B k 0x0052, // 6C l 0x0037, // 6D m 0x0038, // 6E n 0x0078, // 6F o 0x001F, // 70 p 0x002F, // 71 q 0x0018, // 72 r 0x006B, // 73 s 0x005A, // 74 t 0x0070, // 75 u 0x0076, // 76 v 0x0076, // 77 w 0x0049, // 78 x 0x006E, // 79 y 0x005d, // 7A z 0x0053, // 7B { 0x0024, // 7C | 0x0065, // 7D } 0x0001, // 7E ~ }; // map FXDEFMAP(FX7Segment) FX7SegmentMap[]={ FXMAPFUNC(SEL_PAINT,0,FX7Segment::onPaint), FXMAPFUNC(SEL_QUERY_TIP,0,FX7Segment::onQueryTip), FXMAPFUNC(SEL_QUERY_HELP,0,FX7Segment::onQueryHelp), FXMAPFUNC(SEL_COMMAND,FX7Segment::ID_SETVALUE,FX7Segment::onCmdSetValue), FXMAPFUNC(SEL_COMMAND,FX7Segment::ID_SETINTVALUE,FX7Segment::onCmdSetIntValue), FXMAPFUNC(SEL_COMMAND,FX7Segment::ID_GETINTVALUE,FX7Segment::onCmdGetIntValue), FXMAPFUNC(SEL_COMMAND,FX7Segment::ID_SETREALVALUE,FX7Segment::onCmdSetRealValue), FXMAPFUNC(SEL_COMMAND,FX7Segment::ID_GETREALVALUE,FX7Segment::onCmdGetRealValue), FXMAPFUNC(SEL_COMMAND,FX7Segment::ID_SETLONGVALUE,FX7Segment::onCmdSetLongValue), FXMAPFUNC(SEL_COMMAND,FX7Segment::ID_GETLONGVALUE,FX7Segment::onCmdGetLongValue), FXMAPFUNC(SEL_COMMAND,FX7Segment::ID_SETSTRINGVALUE,FX7Segment::onCmdSetStringValue), FXMAPFUNC(SEL_COMMAND,FX7Segment::ID_GETSTRINGVALUE,FX7Segment::onCmdGetStringValue), FXMAPFUNC(SEL_COMMAND,FX7Segment::ID_SETHELPSTRING,FX7Segment::onCmdSetHelp), FXMAPFUNC(SEL_COMMAND,FX7Segment::ID_GETHELPSTRING,FX7Segment::onCmdGetHelp), FXMAPFUNC(SEL_COMMAND,FX7Segment::ID_SETTIPSTRING,FX7Segment::onCmdSetTip), FXMAPFUNC(SEL_COMMAND,FX7Segment::ID_GETTIPSTRING,FX7Segment::onCmdGetTip), }; FXIMPLEMENT(FX7Segment,FXFrame,FX7SegmentMap,ARRAYNUMBER(FX7SegmentMap)) // For serialization FX7Segment::FX7Segment(){ flags|=FLAG_ENABLED; textColor=0; thickness=3; cellwidth=12; cellheight=18; } // Construct 7 segment display FX7Segment::FX7Segment(FXComposite* p,const FXString& text,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb):FXFrame(p,opts,x,y,w,h,pl,pr,pt,pb),label(text){ flags|=FLAG_ENABLED; textColor=getApp()->getForeColor(); thickness=3; cellwidth=12; cellheight=18; } // Get default width FXint FX7Segment::getDefaultWidth(){ FXint w=(cellwidth+2)*label.length(); if(label.length()) w-=2; return padleft+padright+(border<<1)+w; } // Get default height FXint FX7Segment::getDefaultHeight(){ return padtop+padbottom+(border<<1)+cellheight; } // Update value from a message long FX7Segment::onCmdSetValue(FXObject*,FXSelector,void *ptr){ setText((const FXchar*)ptr); return 1; } // Get value as int long FX7Segment::onCmdGetIntValue(FXObject*,FXSelector,void* ptr){ *((FXint*)ptr)=label.toInt(); return 1; } // Set value from int long FX7Segment::onCmdSetIntValue(FXObject*,FXSelector,void *ptr){ setText(FXString::value(*((FXint*)ptr))); return 1; } // Update value from a message long FX7Segment::onCmdSetLongValue(FXObject*,FXSelector,void* ptr){ setText(FXString::value(*((FXlong*)ptr))); return 1; } // Obtain value with a message long FX7Segment::onCmdGetLongValue(FXObject*,FXSelector,void* ptr){ *((FXlong*)ptr)=label.toLong(); return 1; } // Get value as double long FX7Segment::onCmdGetRealValue(FXObject*,FXSelector,void* ptr){ *((FXdouble*)ptr)=label.toDouble(); return 1; } // Set value from double long FX7Segment::onCmdSetRealValue(FXObject*,FXSelector,void* ptr){ setText(FXString::value(*((FXdouble*)ptr))); return 1; } // Get value as string long FX7Segment::onCmdGetStringValue(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getText(); return 1; } // Set value from string long FX7Segment::onCmdSetStringValue(FXObject*,FXSelector,void *ptr){ setText(*((FXString*)ptr)); return 1; } // Set help using a message long FX7Segment::onCmdSetHelp(FXObject*,FXSelector,void* ptr){ setHelpText(*((FXString*)ptr)); return 1; } // Get help using a message long FX7Segment::onCmdGetHelp(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getHelpText(); return 1; } // Set tip using a message long FX7Segment::onCmdSetTip(FXObject*,FXSelector,void* ptr){ setTipText(*((FXString*)ptr)); return 1; } // Get tip using a message long FX7Segment::onCmdGetTip(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getTipText(); return 1; } // We were asked about tip text long FX7Segment::onQueryTip(FXObject* sender,FXSelector sel,void* ptr){ if(FXFrame::onQueryTip(sender,sel,ptr)) return 1; if((flags&FLAG_TIP) && !tip.empty()){ sender->handle(this,FXSEL(SEL_COMMAND,ID_SETSTRINGVALUE),(void*)&tip); return 1; } return 0; } // We were asked about status text long FX7Segment::onQueryHelp(FXObject* sender,FXSelector sel,void* ptr){ if(FXFrame::onQueryHelp(sender,sel,ptr)) return 1; if((flags&FLAG_HELP) && !help.empty()){ sender->handle(this,FXSEL(SEL_COMMAND,ID_SETSTRINGVALUE),(void*)&help); return 1; } return 0; } // Handle repaint long FX7Segment::onPaint(FXObject*,FXSelector,void *ptr){ FXEvent *event=(FXEvent*)ptr; FXint tx,ty,tw,ch,cw; FXDCWindow dc(this,event); // Draw frame drawFrame(dc,0,0,width,height); // Draw background dc.setForeground(backColor); dc.fillRectangle(border,border,width-(border<<1),height-(border<<1)); // Non empty if(label.length()){ cw=cellwidth; ch=cellheight; tw=label.length()*(cw+2); if(label.length()) tw-=2; // Justify in x if((options&JUSTIFY_LEFT) && (options&JUSTIFY_RIGHT)){ // FIXME not good yet tx=border+padleft; tw=width-padleft-padright-(border<<1); cw=tw/label.length(); } else if(options&JUSTIFY_LEFT){ tx=border+padleft; } else if(options&JUSTIFY_RIGHT){ tx=width-padright-border-tw; } else{ tx=border+padleft+(width-padleft-padright-(border<<1)-tw)/2; } // Justify in y if((options&JUSTIFY_TOP) && (options&JUSTIFY_BOTTOM)){ ty=border+padtop; ch=height-padbottom-padtop-(border<<1); } else if(options&JUSTIFY_TOP){ ty=border+padtop; } else if(options&JUSTIFY_BOTTOM){ ty=height-padbottom-border-ch; } else{ ty=border+padtop+(height-padbottom-padtop-(border<<1)-ch)/2; } // Draw cells with shadow if(options&SEVENSEGMENT_SHADOW){ dc.setForeground(shadowColor); drawCells(dc,tx+1,ty+1,cw,ch); } // Draw cells normally dc.setForeground(textColor); drawCells(dc,tx,ty,cw,ch); } return 1; } // Draw cells void FX7Segment::drawCells(FXDCWindow &dc,FXint x,FXint y,FXint cw,FXint ch){ for(FXint c=0; c>1)-(thickness>>1)-1; points[3].x=x; points[3].y=y+(h>>1); dc.fillPolygon(points,4); } if(segments&0x04){ // Upper right points[0].x=x+w; points[0].y=y; points[1].x=x+w; points[1].y=y+(h>>1); points[2].x=x+w-thickness; points[2].y=y+(h>>1)-(thickness>>1)-1; points[3].x=x+w-thickness; points[3].y=y+thickness; dc.fillPolygon(points,4); } if(segments&0x10){ // Lower left points[0].x=x; points[0].y=y+(h>>1); points[1].x=x+thickness; points[1].y=y+(h>>1)-(thickness>>1)+thickness; points[2].x=x+thickness; points[2].y=y+h-thickness-1; points[3].x=x; points[3].y=y+h-1; dc.fillPolygon(points,4); } if(segments&0x20){ // Lower right points[0].x=x+w; points[0].y=y+(h>>1); points[1].x=x+w; points[1].y=y+h-1; points[2].x=x+w-thickness; points[2].y=y+h-thickness-1; points[3].x=x+w-thickness; points[3].y=y+(h>>1)-(thickness>>1)+thickness; dc.fillPolygon(points,4); } if(segments&0x01){ // Top points[0].x=x+1; points[0].y=y; points[1].x=x+w-1; points[1].y=y; points[2].x=x+w-thickness-1; points[2].y=y+thickness; points[3].x=x+thickness+1; points[3].y=y+thickness; dc.fillPolygon(points,4); } if(segments&0x40){ // Bottom points[0].x=x; points[0].y=y+h; points[1].x=x+w; points[1].y=y+h; points[2].x=x+w-thickness; points[2].y=y+h-thickness; points[3].x=x+thickness; points[3].y=y+h-thickness; dc.fillPolygon(points,4); } if(segments&0x08){ // Middle points[0].x=x+1; points[0].y=y+(h>>1); points[1].x=x+thickness; points[1].y=y+(h>>1)-(thickness>>1); points[2].x=x+w-thickness; points[2].y=y+(h>>1)-(thickness>>1); points[3].x=x+w-1; points[3].y=y+(h>>1); points[4].x=x+w-thickness-2; points[4].y=y+(h>>1)-(thickness>>1)+thickness; points[5].x=x+thickness+1; points[5].y=y+(h>>1)-(thickness>>1)+thickness; dc.fillPolygon(points,6); } if(segments&128){ // Decimal } if(segments&256){ // Colon dc.fillRectangle(x+(w>>1)-(thickness>>1)-1,y+(h>>1)-(thickness>>1)-thickness-1,thickness,thickness); dc.fillRectangle(x+(w>>1)-(thickness>>1)-1,y+(h>>1)-(thickness>>1)+thickness+1,thickness,thickness); } } // Change text void FX7Segment::setText(const FXString& text){ if(label!=text){ if(label.length()!=text.length()) recalc(); label=text; update(); } } // Set text color void FX7Segment::setTextColor(FXColor clr){ if(textColor!=clr){ textColor=clr; update(); } } // Get/set cell width void FX7Segment::setCellWidth(FXint w){ if(cellwidth!=w){ cellwidth=w; recalc(); update(); } } // Get/set cell height void FX7Segment::setCellHeight(FXint h){ if(cellheight!=h){ cellheight=h; recalc(); update(); } } // set segment thickness void FX7Segment::setThickness(FXint t){ if(t<1) t=1; if(!(t&1)) t|=1; if(thickness!=t){ thickness=t; recalc(); update(); } } // Change 7 segment style void FX7Segment::set7SegmentStyle(FXuint style){ FXuint opts=(options&~SEVENSEGMENT_MASK) | (style&SEVENSEGMENT_MASK); if(options!=opts){ options=opts; update(); } } // Get 7 segment FXuint FX7Segment::get7SegmentStyle() const { return (options&SEVENSEGMENT_MASK); } // Set text justify style void FX7Segment::setJustify(FXuint style){ FXuint opts=(options&~JUSTIFY_MASK) | (style&JUSTIFY_MASK); if(options!=opts){ options=opts; update(); } } // Get text justify style FXuint FX7Segment::getJustify() const { return (options&JUSTIFY_MASK); } // Save object to stream void FX7Segment::save(FXStream &store) const { FXFrame::save(store); store << label; store << textColor; store << thickness; store << cellwidth; store << cellheight; store << tip; store << help; } // Load object from stream void FX7Segment::load(FXStream &store) { FXFrame::load(store); store >> label; store >> textColor; store >> thickness; store >> cellwidth; store >> cellheight; store >> tip; store >> help; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FX885910Codec.cpp000066400000000000000000000144361455751074500222720ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FX885910Codec.h" namespace FX { FXIMPLEMENT(FX885910Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: 8859-10.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 260, 274, 290, 298, 296, 310, 167, 315, 272, 352, 358, 381, 173, 362, 330, 176, 261, 275, 291, 299, 297, 311, 183, 316, 273, 353, 359, 382, 8213, 363, 331, 256, 193, 194, 195, 196, 197, 198, 302, 268, 201, 280, 203, 278, 205, 206, 207, 208, 325, 332, 211, 212, 213, 214, 360, 216, 370, 218, 219, 220, 221, 222, 223, 257, 225, 226, 227, 228, 229, 230, 303, 269, 233, 281, 235, 279, 237, 238, 239, 240, 326, 333, 243, 244, 245, 246, 361, 248, 371, 250, 251, 252, 253, 254, 312, }; static const unsigned char reverse_plane[17]={ 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, }; static const unsigned char reverse_pages[73]={ 0, 24, 24, 24, 24, 24, 24, 24, 87, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, }; static const unsigned short reverse_block[151]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 191, 207, 223, 239, 255, 271, 285, 301, 314, 328, 344, 358, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 373, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, 328, }; static const unsigned char reverse_data[389]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 26, 26, 26, 26, 26, 26, 167, 26, 26, 26, 26, 26, 173, 26, 26, 176, 26, 26, 26, 26, 26, 26, 183, 26, 26, 26, 26, 26, 26, 26, 26, 193, 194, 195, 196, 197, 198, 26, 26, 201, 26, 203, 26, 205, 206, 207, 208, 26, 26, 211, 212, 213, 214, 26, 216, 26, 218, 219, 220, 221, 222, 223, 26, 225, 226, 227, 228, 229, 230, 26, 26, 233, 26, 235, 26, 237, 238, 239, 240, 26, 26, 243, 244, 245, 246, 26, 248, 26, 250, 251, 252, 253, 254, 26, 192, 224, 26, 26, 161, 177, 26, 26, 26, 26, 26, 26, 200, 232, 26, 26, 169, 185, 162, 178, 26, 26, 204, 236, 202, 234, 26, 26, 26, 26, 26, 26, 163, 179, 26, 26, 26, 26, 165, 181, 164, 180, 26, 26, 199, 231, 26, 26, 26, 26, 26, 26, 166, 182, 255, 26, 26, 168, 184, 26, 26, 26, 26, 26, 209, 241, 26, 26, 26, 175, 191, 210, 242, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 170, 186, 26, 26, 26, 26, 171, 187, 215, 247, 174, 190, 26, 26, 26, 26, 217, 249, 26, 26, 26, 26, 26, 26, 26, 26, 26, 172, 188, 26, 26, 26, 26, 26, 189, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FX885910Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FX885910Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FX885910Codec::mibEnum() const { return 13; } const FXchar* FX885910Codec::name() const { return "ISO-8859-10"; } const FXchar* FX885910Codec::mimeName() const { return "ISO-8859-10"; } const FXchar* const* FX885910Codec::aliases() const { static const FXchar *const list[]={"iso8859-10","ISO-8859-10","ISO_8859-10","latin6","iso-ir-157","csISOLatin6","l6",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FX885911Codec.cpp000066400000000000000000000125071455751074500222700ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FX885911Codec.h" namespace FX { FXIMPLEMENT(FX885911Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: 8859-11.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 3585, 3586, 3587, 3588, 3589, 3590, 3591, 3592, 3593, 3594, 3595, 3596, 3597, 3598, 3599, 3600, 3601, 3602, 3603, 3604, 3605, 3606, 3607, 3608, 3609, 3610, 3611, 3612, 3613, 3614, 3615, 3616, 3617, 3618, 3619, 3620, 3621, 3622, 3623, 3624, 3625, 3626, 3627, 3628, 3629, 3630, 3631, 3632, 3633, 3634, 3635, 3636, 3637, 3638, 3639, 3640, 3641, 3642, 65533, 65533, 65533, 65533, 3647, 3648, 3649, 3650, 3651, 3652, 3653, 3654, 3655, 3656, 3657, 3658, 3659, 3660, 3661, 3662, 3663, 3664, 3665, 3666, 3667, 3668, 3669, 3670, 3671, 3672, 3673, 3674, 3675, 65533, 65533, 65533, 65533, }; static const unsigned char reverse_plane[17]={ 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, }; static const unsigned char reverse_pages[68]={ 0, 11, 11, 43, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, }; static const unsigned short reverse_block[107]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 176, 192, 208, 224, 240, 256, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, }; static const unsigned char reverse_data[272]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 26, 26, 26, 26, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 26, 26, 26, 26, }; FXint FX885911Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FX885911Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FX885911Codec::mibEnum() const { return 2259; } const FXchar* FX885911Codec::name() const { return "ISO-8859-11"; } const FXchar* FX885911Codec::mimeName() const { return "ISO-8859-11"; } const FXchar* const* FX885911Codec::aliases() const { static const FXchar *const list[]={"iso8859-11","ISO-8859-11","ISO_8859-11",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FX885913Codec.cpp000066400000000000000000000143741455751074500222760ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FX885913Codec.h" namespace FX { FXIMPLEMENT(FX885913Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: 8859-13.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 8221, 162, 163, 164, 8222, 166, 167, 216, 169, 342, 171, 172, 173, 174, 198, 176, 177, 178, 179, 8220, 181, 182, 183, 248, 185, 343, 187, 188, 189, 190, 230, 260, 302, 256, 262, 196, 197, 280, 274, 268, 201, 377, 278, 290, 310, 298, 315, 352, 323, 325, 211, 332, 213, 214, 215, 370, 321, 346, 362, 220, 379, 381, 223, 261, 303, 257, 263, 228, 229, 281, 275, 269, 233, 378, 279, 291, 311, 299, 316, 353, 324, 326, 243, 333, 245, 246, 247, 371, 322, 347, 363, 252, 380, 382, 8217, }; static const unsigned char reverse_plane[17]={ 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, }; static const unsigned char reverse_pages[73]={ 0, 24, 24, 24, 24, 24, 24, 24, 87, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, }; static const unsigned short reverse_block[151]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 191, 204, 220, 233, 249, 263, 277, 293, 308, 322, 338, 352, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 374, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, }; static const unsigned char reverse_data[390]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 26, 162, 163, 164, 26, 166, 167, 26, 169, 26, 171, 172, 173, 174, 26, 176, 177, 178, 179, 26, 181, 182, 183, 26, 185, 26, 187, 188, 189, 190, 26, 26, 26, 26, 196, 197, 175, 26, 26, 201, 26, 26, 26, 26, 26, 26, 211, 26, 213, 214, 215, 168, 26, 26, 26, 220, 26, 26, 223, 26, 26, 26, 26, 228, 229, 191, 26, 26, 233, 26, 26, 26, 26, 26, 26, 243, 26, 245, 246, 247, 184, 26, 26, 26, 252, 26, 26, 26, 194, 226, 26, 26, 192, 224, 195, 227, 26, 26, 26, 26, 200, 232, 26, 26, 199, 231, 26, 26, 203, 235, 198, 230, 26, 26, 26, 26, 26, 26, 204, 236, 26, 26, 26, 26, 26, 26, 206, 238, 26, 26, 193, 225, 26, 26, 26, 26, 26, 26, 205, 237, 26, 26, 26, 207, 239, 26, 26, 26, 217, 249, 209, 241, 210, 242, 26, 26, 26, 26, 26, 212, 244, 26, 26, 26, 26, 26, 26, 170, 186, 26, 26, 218, 250, 26, 26, 26, 26, 208, 240, 26, 26, 26, 26, 26, 26, 26, 26, 219, 251, 26, 26, 26, 26, 216, 248, 26, 26, 26, 26, 26, 202, 234, 221, 253, 222, 254, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 255, 26, 26, 180, 161, 165, 26, }; FXint FX885913Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FX885913Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FX885913Codec::mibEnum() const { return 109; } const FXchar* FX885913Codec::name() const { return "ISO-8859-13"; } const FXchar* FX885913Codec::mimeName() const { return "ISO-8859-13"; } const FXchar* const* FX885913Codec::aliases() const { static const FXchar *const list[]={"iso8859-13","ISO-8859-13","ISO_8859-13",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FX885914Codec.cpp000066400000000000000000000143141455751074500222710ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FX885914Codec.h" namespace FX { FXIMPLEMENT(FX885914Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: 8859-14.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 7682, 7683, 163, 266, 267, 7690, 167, 7808, 169, 7810, 7691, 7922, 173, 174, 376, 7710, 7711, 288, 289, 7744, 7745, 182, 7766, 7809, 7767, 7811, 7776, 7923, 7812, 7813, 7777, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 372, 209, 210, 211, 212, 213, 214, 7786, 216, 217, 218, 219, 220, 221, 374, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 373, 241, 242, 243, 244, 245, 246, 7787, 248, 249, 250, 251, 252, 253, 375, 255, }; static const unsigned char reverse_plane[17]={ 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, }; static const unsigned char reverse_pages[72]={ 0, 24, 24, 24, 24, 24, 24, 56, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, }; static const unsigned short reverse_block[120]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 175, 191, 207, 223, 239, 255, 267, 283, 267, 267, 267, 267, 295, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 309, 321, 267, 267, 337, 347, 363, 267, 379, 267, 267, 267, 267, 267, 267, 393, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, }; static const unsigned char reverse_data[409]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 26, 26, 163, 26, 26, 26, 167, 26, 169, 26, 26, 26, 173, 174, 26, 26, 26, 26, 26, 26, 182, 26, 26, 26, 26, 26, 26, 26, 26, 26, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 26, 209, 210, 211, 212, 213, 214, 26, 216, 217, 218, 219, 220, 221, 26, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 26, 241, 242, 243, 244, 245, 246, 26, 248, 249, 250, 251, 252, 253, 26, 255, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 164, 165, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 178, 179, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 208, 240, 222, 254, 175, 26, 26, 26, 26, 26, 26, 26, 161, 162, 26, 26, 26, 26, 26, 26, 166, 171, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 176, 177, 180, 181, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 183, 185, 26, 26, 26, 26, 26, 26, 26, 26, 187, 191, 26, 26, 26, 26, 26, 26, 26, 26, 215, 247, 26, 26, 26, 26, 168, 184, 170, 186, 189, 190, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 172, 188, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FX885914Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FX885914Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FX885914Codec::mibEnum() const { return 110; } const FXchar* FX885914Codec::name() const { return "ISO-8859-14"; } const FXchar* FX885914Codec::mimeName() const { return "ISO-8859-14"; } const FXchar* const* FX885914Codec::aliases() const { static const FXchar *const list[]={"iso8859-14","ISO-8859-14","ISO_8859-14",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FX885915Codec.cpp000066400000000000000000000135261455751074500222760ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FX885915Codec.h" namespace FX { FXIMPLEMENT(FX885915Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: 8859-15.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 8364, 165, 352, 167, 353, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 381, 181, 182, 183, 382, 185, 186, 187, 338, 339, 376, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, }; static const unsigned char reverse_plane[17]={ 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, }; static const unsigned char reverse_pages[73]={ 0, 24, 24, 24, 24, 24, 24, 24, 78, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, }; static const unsigned short reverse_block[142]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 256, 256, 256, 256, 256, 270, 286, 294, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 309, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, }; static const unsigned char reverse_data[325]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 26, 165, 26, 167, 26, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 26, 181, 182, 183, 26, 185, 186, 187, 26, 26, 26, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 188, 189, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 166, 168, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 190, 26, 26, 26, 26, 180, 184, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 164, 26, 26, 26, }; FXint FX885915Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FX885915Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FX885915Codec::mibEnum() const { return 111; } const FXchar* FX885915Codec::name() const { return "ISO-8859-15"; } const FXchar* FX885915Codec::mimeName() const { return "ISO-8859-15"; } const FXchar* const* FX885915Codec::aliases() const { static const FXchar *const list[]={"iso8859-15","ISO-8859-15","ISO_8859-15","Latin-9","latin9",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FX885916Codec.cpp000066400000000000000000000146321455751074500222760ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FX885916Codec.h" namespace FX { FXIMPLEMENT(FX885916Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: 8859-16.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 260, 261, 321, 8364, 8222, 352, 167, 353, 169, 536, 171, 377, 173, 378, 379, 176, 177, 268, 322, 381, 8221, 182, 183, 382, 269, 537, 187, 338, 339, 376, 380, 192, 193, 194, 258, 196, 262, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 272, 323, 210, 211, 212, 336, 214, 346, 368, 217, 218, 219, 220, 280, 538, 223, 224, 225, 226, 259, 228, 263, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 273, 324, 242, 243, 244, 337, 246, 347, 369, 249, 250, 251, 252, 281, 539, 255, }; static const unsigned char reverse_plane[17]={ 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, }; static const unsigned char reverse_pages[73]={ 0, 34, 34, 34, 34, 34, 34, 34, 97, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, }; static const unsigned short reverse_block[161]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 256, 272, 282, 282, 297, 313, 329, 345, 282, 282, 282, 282, 282, 282, 282, 282, 282, 360, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 372, 282, 282, 282, 282, 282, 282, 282, 282, 387, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, }; static const unsigned char reverse_data[403]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 26, 26, 26, 26, 26, 26, 167, 26, 169, 26, 171, 26, 173, 26, 26, 176, 177, 26, 26, 26, 26, 182, 183, 26, 26, 26, 187, 26, 26, 26, 26, 192, 193, 194, 26, 196, 26, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 26, 26, 210, 211, 212, 26, 214, 26, 26, 217, 218, 219, 220, 26, 26, 223, 224, 225, 226, 26, 228, 26, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 26, 26, 242, 243, 244, 26, 246, 26, 26, 249, 250, 251, 252, 26, 26, 255, 26, 26, 195, 227, 161, 162, 197, 229, 26, 26, 26, 26, 178, 185, 26, 26, 208, 240, 26, 26, 26, 26, 26, 26, 221, 253, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 163, 179, 209, 241, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 213, 245, 188, 189, 26, 26, 26, 26, 26, 26, 215, 247, 26, 26, 26, 26, 166, 168, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 216, 248, 26, 26, 26, 26, 26, 26, 190, 172, 174, 175, 191, 180, 184, 26, 26, 26, 26, 26, 26, 26, 26, 170, 186, 222, 254, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 181, 165, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 164, 26, 26, 26, }; FXint FX885916Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FX885916Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FX885916Codec::mibEnum() const { return 112; } const FXchar* FX885916Codec::name() const { return "ISO-8859-16"; } const FXchar* FX885916Codec::mimeName() const { return "ISO-8859-16"; } const FXchar* const* FX885916Codec::aliases() const { static const FXchar *const list[]={"iso8859-16","ISO-8859-16","ISO_8859-16","latin10","iso-ir-226","l10",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FX88591Codec.cpp000066400000000000000000000123131455751074500222020ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FX88591Codec.h" namespace FX { FXIMPLEMENT(FX88591Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: 8859-1.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, }; static const unsigned char reverse_plane[17]={ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; static const unsigned char reverse_pages[65]={ 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, }; static const unsigned short reverse_block[80]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, }; static const unsigned char reverse_data[272]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FX88591Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FX88591Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FX88591Codec::mibEnum() const { return 4; } const FXchar* FX88591Codec::name() const { return "ISO-8859-1"; } const FXchar* FX88591Codec::mimeName() const { return "ISO-8859-1"; } const FXchar* const* FX88591Codec::aliases() const { static const FXchar *const list[]={"iso8859-1","ISO-8859-1","ISO_8859-1","latin1","CP819","iso-ir-100","IBM819","l1","csISOLatin1",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FX88592Codec.cpp000066400000000000000000000140241455751074500222040ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FX88592Codec.h" namespace FX { FXIMPLEMENT(FX88592Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/24/2005 from: 8859-2.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 260, 728, 321, 164, 317, 346, 167, 168, 352, 350, 356, 377, 173, 381, 379, 176, 261, 731, 322, 180, 318, 347, 711, 184, 353, 351, 357, 378, 733, 382, 380, 340, 193, 194, 258, 196, 313, 262, 199, 268, 201, 280, 203, 282, 205, 206, 270, 272, 323, 327, 211, 212, 336, 214, 215, 344, 366, 218, 368, 220, 221, 354, 223, 341, 225, 226, 259, 228, 314, 263, 231, 269, 233, 281, 235, 283, 237, 238, 271, 273, 324, 328, 243, 244, 337, 246, 247, 345, 367, 250, 369, 252, 253, 355, 729, }; static const unsigned char reverse_plane[17]={ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; static const unsigned char reverse_pages[65]={ 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, }; static const unsigned short reverse_block[110]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 191, 206, 222, 237, 251, 267, 279, 286, 301, 317, 333, 349, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 364, 372, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, }; static const unsigned char reverse_data[388]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 26, 26, 26, 164, 26, 26, 167, 168, 26, 26, 26, 26, 173, 26, 26, 176, 26, 26, 26, 180, 26, 26, 26, 184, 26, 26, 26, 26, 26, 26, 26, 193, 194, 26, 196, 26, 26, 199, 26, 201, 26, 203, 26, 205, 206, 26, 26, 26, 211, 212, 26, 214, 215, 26, 26, 218, 26, 220, 221, 26, 223, 26, 225, 226, 26, 228, 26, 26, 231, 26, 233, 26, 235, 26, 237, 238, 26, 26, 26, 243, 244, 26, 246, 247, 26, 26, 250, 26, 252, 253, 26, 26, 195, 227, 161, 177, 198, 230, 26, 26, 26, 26, 200, 232, 207, 239, 208, 240, 26, 26, 26, 26, 26, 26, 202, 234, 204, 236, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 197, 229, 26, 26, 165, 181, 26, 163, 179, 209, 241, 26, 26, 210, 242, 26, 26, 26, 26, 26, 26, 26, 213, 245, 26, 26, 192, 224, 26, 26, 216, 248, 166, 182, 26, 26, 170, 186, 169, 185, 222, 254, 171, 187, 26, 26, 26, 26, 26, 26, 26, 26, 217, 249, 219, 251, 26, 26, 26, 26, 26, 26, 26, 172, 188, 175, 191, 174, 190, 26, 26, 26, 26, 26, 26, 26, 183, 26, 26, 26, 26, 26, 26, 26, 26, 162, 255, 26, 178, 26, 189, 26, 26, }; FXint FX88592Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FX88592Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FX88592Codec::mibEnum() const { return 5; } const FXchar* FX88592Codec::name() const { return "ISO-8859-2"; } const FXchar* FX88592Codec::mimeName() const { return "ISO-8859-2"; } const FXchar* const* FX88592Codec::aliases() const { static const FXchar *const list[]={"iso8859-2","ISO-8859-2","ISO_8859-2","latin2","iso-ir-101","l2","csISOLatin2",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FX88593Codec.cpp000066400000000000000000000136261455751074500222140ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FX88593Codec.h" namespace FX { FXIMPLEMENT(FX88593Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: 8859-3.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 294, 728, 163, 164, 65533, 292, 167, 168, 304, 350, 286, 308, 173, 65533, 379, 176, 295, 178, 179, 180, 181, 293, 183, 184, 305, 351, 287, 309, 189, 65533, 380, 192, 193, 194, 65533, 196, 266, 264, 199, 200, 201, 202, 203, 204, 205, 206, 207, 65533, 209, 210, 211, 212, 288, 214, 215, 284, 217, 218, 219, 220, 364, 348, 223, 224, 225, 226, 65533, 228, 267, 265, 231, 232, 233, 234, 235, 236, 237, 238, 239, 65533, 241, 242, 243, 244, 289, 246, 247, 285, 249, 250, 251, 252, 365, 349, 729, }; static const unsigned char reverse_plane[17]={ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; static const unsigned char reverse_pages[65]={ 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, }; static const unsigned short reverse_block[110]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 253, 265, 281, 297, 303, 307, 323, 337, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 350, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, }; static const unsigned char reverse_data[366]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 26, 26, 163, 164, 26, 26, 167, 168, 26, 26, 26, 26, 173, 26, 26, 176, 26, 178, 179, 180, 181, 26, 183, 184, 26, 26, 26, 26, 189, 26, 26, 192, 193, 194, 26, 196, 26, 26, 199, 200, 201, 202, 203, 204, 205, 206, 207, 26, 209, 210, 211, 212, 26, 214, 215, 26, 217, 218, 219, 220, 26, 26, 223, 224, 225, 226, 26, 228, 26, 26, 231, 232, 233, 234, 235, 236, 237, 238, 239, 26, 241, 242, 243, 244, 26, 246, 247, 26, 249, 250, 251, 252, 26, 26, 26, 26, 26, 26, 26, 26, 198, 230, 197, 229, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 216, 248, 171, 187, 213, 245, 26, 26, 166, 182, 161, 177, 26, 26, 26, 26, 26, 26, 26, 26, 169, 185, 26, 26, 172, 188, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 222, 254, 170, 186, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 221, 253, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 175, 191, 26, 26, 26, 26, 26, 26, 26, 26, 162, 255, 26, 26, 26, 26, 26, 26, }; FXint FX88593Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FX88593Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FX88593Codec::mibEnum() const { return 6; } const FXchar* FX88593Codec::name() const { return "ISO-8859-3"; } const FXchar* FX88593Codec::mimeName() const { return "ISO-8859-3"; } const FXchar* const* FX88593Codec::aliases() const { static const FXchar *const list[]={"iso8859-3","ISO-8859-3","ISO_8859-3","latin3","iso-ir-109","l3","csISOLatin3",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FX88594Codec.cpp000066400000000000000000000141651455751074500222140ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FX88594Codec.h" namespace FX { FXIMPLEMENT(FX88594Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: 8859-4.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 260, 312, 342, 164, 296, 315, 167, 168, 352, 274, 290, 358, 173, 381, 175, 176, 261, 731, 343, 180, 297, 316, 711, 184, 353, 275, 291, 359, 330, 382, 331, 256, 193, 194, 195, 196, 197, 198, 302, 268, 201, 280, 203, 278, 205, 206, 298, 272, 325, 332, 310, 212, 213, 214, 215, 216, 370, 218, 219, 220, 360, 362, 223, 257, 225, 226, 227, 228, 229, 230, 303, 269, 233, 281, 235, 279, 237, 238, 299, 273, 326, 333, 311, 244, 245, 246, 247, 248, 371, 250, 251, 252, 361, 363, 729, }; static const unsigned char reverse_plane[17]={ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; static const unsigned char reverse_pages[65]={ 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, }; static const unsigned short reverse_block[110]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 191, 206, 222, 237, 253, 269, 283, 299, 312, 326, 342, 356, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 380, 388, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, }; static const unsigned char reverse_data[404]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 26, 26, 26, 164, 26, 26, 167, 168, 26, 26, 26, 26, 173, 26, 175, 176, 26, 26, 26, 180, 26, 26, 26, 184, 26, 26, 26, 26, 26, 26, 26, 193, 194, 195, 196, 197, 198, 26, 26, 201, 26, 203, 26, 205, 206, 26, 26, 26, 26, 212, 213, 214, 215, 216, 26, 218, 219, 220, 26, 26, 223, 26, 225, 226, 227, 228, 229, 230, 26, 26, 233, 26, 235, 26, 237, 238, 26, 26, 26, 26, 244, 245, 246, 247, 248, 26, 250, 251, 252, 26, 26, 26, 192, 224, 26, 26, 161, 177, 26, 26, 26, 26, 26, 26, 200, 232, 26, 26, 208, 240, 170, 186, 26, 26, 204, 236, 202, 234, 26, 26, 26, 26, 26, 26, 171, 187, 26, 26, 26, 26, 165, 181, 207, 239, 26, 26, 199, 231, 26, 26, 26, 26, 26, 26, 211, 243, 162, 26, 26, 166, 182, 26, 26, 26, 26, 26, 209, 241, 26, 26, 26, 189, 191, 210, 242, 26, 26, 26, 26, 26, 26, 163, 179, 26, 26, 26, 26, 26, 26, 26, 26, 169, 185, 26, 26, 26, 26, 172, 188, 221, 253, 222, 254, 26, 26, 26, 26, 217, 249, 26, 26, 26, 26, 26, 26, 26, 26, 26, 174, 190, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 183, 26, 26, 26, 26, 26, 26, 26, 26, 26, 255, 26, 178, 26, 26, 26, 26, }; FXint FX88594Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FX88594Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FX88594Codec::mibEnum() const { return 7; } const FXchar* FX88594Codec::name() const { return "ISO-8859-4"; } const FXchar* FX88594Codec::mimeName() const { return "ISO-8859-4"; } const FXchar* const* FX88594Codec::aliases() const { static const FXchar *const list[]={"iso8859-4","ISO-8859-4","ISO_8859-4","latin4","iso-ir-110","l4","csISOLatin4",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FX88595Codec.cpp000066400000000000000000000136341455751074500222150ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FX88595Codec.h" namespace FX { FXIMPLEMENT(FX88595Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: 8859-5.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 173, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 8470, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 167, 1118, 1119, }; static const unsigned char reverse_plane[17]={ 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, }; static const unsigned char reverse_pages[73]={ 0, 64, 70, 70, 70, 70, 70, 70, 117,70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, }; static const unsigned short reverse_block[181]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 189, 205, 221, 237, 253, 269, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 285, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, }; static const unsigned char reverse_data[301]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 26, 26, 26, 26, 26, 26, 253, 26, 26, 26, 26, 26, 173, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 26, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 26, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 26, 254, 255, 26, 26, 26, 26, 26, 26, 240, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FX88595Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FX88595Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FX88595Codec::mibEnum() const { return 8; } const FXchar* FX88595Codec::name() const { return "ISO-8859-5"; } const FXchar* FX88595Codec::mimeName() const { return "ISO-8859-5"; } const FXchar* const* FX88595Codec::aliases() const { static const FXchar *const list[]={"iso8859-5","ISO-8859-5","ISO_8859-5","cyrillic","iso-ir-144","csISOLatinCyrillic",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FX88596Codec.cpp000066400000000000000000000130251455751074500222100ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FX88596Codec.h" namespace FX { FXIMPLEMENT(FX88596Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: 8859-6.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 65533, 65533, 65533, 164, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 1548, 173, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 1563, 65533, 65533, 65533, 1567, 65533, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593, 1594, 65533, 65533, 65533, 65533, 65533, 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, }; static const unsigned char reverse_plane[17]={ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }; static const unsigned char reverse_pages[66]={ 0, 32, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, }; static const unsigned short reverse_block[134]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 178, 191, 207, 223, 239, 255, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, }; static const unsigned char reverse_data[271]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 26, 26, 26, 164, 26, 26, 26, 26, 26, 26, 26, 26, 173, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 172, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 187, 26, 26, 26, 191, 26, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 26, 26, 26, 26, 26, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FX88596Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FX88596Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FX88596Codec::mibEnum() const { return 9; } const FXchar* FX88596Codec::name() const { return "ISO-8859-6"; } const FXchar* FX88596Codec::mimeName() const { return "ISO-8859-6"; } const FXchar* const* FX88596Codec::aliases() const { static const FXchar *const list[]={"iso8859-6","ISO-8859-6","ISO_8859-6","arabic","iso-ir-127","ECMA-114","ASMO-708","csISOLatinArabic",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FX88597Codec.cpp000066400000000000000000000140161455751074500222120ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FX88597Codec.h" namespace FX { FXIMPLEMENT(FX88597Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: 8859-7.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 8216, 8217, 163, 8364, 8367, 166, 167, 168, 169, 890, 171, 172, 173, 65533, 8213, 176, 177, 178, 179, 900, 901, 902, 183, 904, 905, 906, 187, 908, 189, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 65533, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 65533, }; static const unsigned char reverse_plane[17]={ 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, }; static const unsigned char reverse_pages[73]={ 0, 61, 61, 61, 61, 61, 61, 61, 124,61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, }; static const unsigned short reverse_block[188]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 196, 208, 224, 240, 256, 272, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 287, 190, 190, 190, 190, 190, 190, 190, 190, 297, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, }; static const unsigned char reverse_data[313]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 26, 26, 163, 26, 26, 166, 167, 168, 169, 26, 171, 172, 173, 26, 26, 176, 177, 178, 179, 26, 26, 26, 183, 26, 26, 26, 187, 26, 189, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 170, 26, 26, 26, 26, 26, 180, 181, 182, 26, 184, 185, 186, 26, 188, 26, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 26, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 26, 26, 26, 26, 26, 175, 26, 26, 161, 162, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 164, 26, 26, 165, }; FXint FX88597Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FX88597Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FX88597Codec::mibEnum() const { return 10; } const FXchar* FX88597Codec::name() const { return "ISO-8859-7"; } const FXchar* FX88597Codec::mimeName() const { return "ISO-8859-7"; } const FXchar* const* FX88597Codec::aliases() const { static const FXchar *const list[]={"iso8859-7","ISO-8859-7","ISO_8859-7","greek","iso-ir-126","greek8","ELOT_928","ECMA-118",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FX88598Codec.cpp000066400000000000000000000136251455751074500222200ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FX88598Codec.h" namespace FX { FXIMPLEMENT(FX88598Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: 8859-8.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 65533, 162, 163, 164, 165, 166, 167, 168, 169, 215, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 247, 187, 188, 189, 190, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 8215, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 65533, 65533, 8206, 8207, 65533, }; static const unsigned char reverse_plane[17]={ 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, }; static const unsigned char reverse_pages[73]={ 0, 35, 66, 66, 66, 66, 66, 66, 130,66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, }; static const unsigned short reverse_block[194]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 191, 200, 191, 209, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 225, 241, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 252, 268, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, }; static const unsigned char reverse_data[284]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 26, 162, 163, 164, 165, 166, 167, 168, 169, 26, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 26, 187, 188, 189, 190, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 170, 26, 26, 26, 26, 26, 26, 26, 26, 186, 26, 26, 26, 26, 26, 26, 26, 26, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 253, 254, 26, 26, 26, 26, 26, 26, 26, 223, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FX88598Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FX88598Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FX88598Codec::mibEnum() const { return 11; } const FXchar* FX88598Codec::name() const { return "ISO-8859-8"; } const FXchar* FX88598Codec::mimeName() const { return "ISO-8859-8"; } const FXchar* const* FX88598Codec::aliases() const { static const FXchar *const list[]={"iso8859-8","ISO-8859-8","ISO_8859-8","hebrew","iso-ir-138","csISOLatinHebrew",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FX88599Codec.cpp000066400000000000000000000125261455751074500222200ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FX88599Codec.h" namespace FX { FXIMPLEMENT(FX88599Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: 8859-9.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 286, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 304, 350, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 287, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 305, 351, 255, }; static const unsigned char reverse_plane[17]={ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; static const unsigned char reverse_pages[65]={ 0, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, }; static const unsigned short reverse_block[86]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 256, 258, 256, 274, 256, 276, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, }; static const unsigned char reverse_data[292]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 26, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 26, 26, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 26, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 26, 26, 255, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 208, 240, 221, 253, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 222, 254, }; FXint FX88599Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FX88599Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FX88599Codec::mibEnum() const { return 12; } const FXchar* FX88599Codec::name() const { return "ISO-8859-9"; } const FXchar* FX88599Codec::mimeName() const { return "ISO-8859-9"; } const FXchar* const* FX88599Codec::aliases() const { static const FXchar *const list[]={"iso8859-9","ISO-8859-9","ISO_8859-9","latin5","iso-ir-148","l5","csISOLatin5",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXAccelTable.cpp000066400000000000000000000423421455751074500225320ustar00rootroot00000000000000/******************************************************************************** * * * A c c e l e r a t o r T a b l e C l a s s * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxchar.h" #include "fxkeys.h" #include "fxmath.h" #include "fxascii.h" #include "fxunicode.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXElement.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXObject.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXAccelTable.h" #include "fxpriv.h" /* Notes: - Routines parseAccel(), unparseAccel(), and parseHotKey() now static members of FXAccelTable. - Need to call parseAccel() is much reduced since addition of convenience functions that take a string as input; these new routines overload addAccel(), removeAccel(), hasAccel() and targetOfAccel(). - Thus, often no need to call parseAccel() directly in many cases, and much less cumbersome stuff to learn. - We need to deal with X11 unicode keysyms (with 0x01000000 flag) in some way. */ #define TOPIC_CONSTRUCT 1000 #define TOPIC_KEYBOARD 1009 #define TOPIC_ACCEL 1011 #define EMPTYSLOT 0xfffffffe // Previously used, now empty slot #define UNUSEDSLOT 0xffffffff // Unsused slot marker using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXAccelTable) FXAccelTableMap[]={ FXMAPFUNC(SEL_KEYPRESS,0,FXAccelTable::onKeyPress), FXMAPFUNC(SEL_KEYRELEASE,0,FXAccelTable::onKeyRelease), }; // Object implementation FXIMPLEMENT(FXAccelTable,FXObject,FXAccelTableMap,ARRAYNUMBER(FXAccelTableMap)) // Make empty accelerator table FXAccelTable::FXAccelTable(){ FXTRACE((TOPIC_CONSTRUCT,"%p->FXAccelTable::FXAccelTable\n",this)); allocElms(key,1); key[0].code=UNUSEDSLOT; key[0].target=nullptr; key[0].messagedn=0; key[0].messageup=0; max=0; num=0; } // Resize hash table, and rehash old stuff into it void FXAccelTable::resize(FXuint m){ FXuint p,i,c; FXAccelKey *newkey; allocElms(newkey,m+1); for(i=0; i<=m; i++){ newkey[i].code=UNUSEDSLOT; newkey[i].target=nullptr; newkey[i].messagedn=0; newkey[i].messageup=0; } for(i=0; i<=max; i++){ if((c=key[i].code)>=EMPTYSLOT) continue; p=(c*13)&m; while(newkey[p].code!=UNUSEDSLOT) p=(p+1)&m; newkey[p]=key[i]; } freeElms(key); key=newkey; max=m; } /*******************************************************************************/ // Add accelerator key combination into the accelerator table void FXAccelTable::addAccel(FXHotKey hotkey,FXObject* target,FXSelector seldn,FXSelector selup){ if(hotkey){ FXTRACE((TOPIC_ACCEL,"%p->FXAccelTable::addAccel: code=%04x state=%04x\n",this,(FXushort)hotkey,(FXushort)(hotkey>>16))); FXuint p=(hotkey*13)&max; FXuint c; FXASSERT(hotkey!=UNUSEDSLOT); FXASSERT(hotkey!=EMPTYSLOT); while((c=key[p].code)!=UNUSEDSLOT){ // Check if in table already if(c==hotkey) goto x; p=(p+1)&max; } ++num; if(max<(num<<1)) resize((max<<1)+1); FXASSERT(num<=max); p=(hotkey*13)&max; // Locate first unused or empty slot while(key[p].codeFXAccelTable::removeAccel: code=%04x state=%04x\n",this,(FXushort)hotkey,(FXushort)(hotkey>>16))); FXuint p=(hotkey*13)&max; FXuint c; FXASSERT(hotkey!=UNUSEDSLOT); FXASSERT(hotkey!=EMPTYSLOT); while((c=key[p].code)!=hotkey){ if(c==UNUSEDSLOT) return; p=(p+1)&max; } if(key[(p+1)&max].code==UNUSEDSLOT){// Last in chain key[p].code=UNUSEDSLOT; } else{ // Middle of chain key[p].code=EMPTYSLOT; } key[p].target=nullptr; key[p].messagedn=0; key[p].messageup=0; if(max>=(num<<2)) resize(max>>1); --num; FXASSERT(num<=max); } } // Parse key-combination description and remove it from the accelerator table void FXAccelTable::removeAccel(const FXString& string){ removeAccel(parseAccel(string)); } // Parse key-combination description and remove it from the accelerator table void FXAccelTable::removeAccel(const FXchar* string){ removeAccel(parseAccel(string)); } /*******************************************************************************/ // Return true if accelerator accelerator key-combination is in accelerator table FXbool FXAccelTable::hasAccel(FXHotKey hotkey) const { if(hotkey){ FXuint p=(hotkey*13)&max; FXuint c; FXASSERT(hotkey!=UNUSEDSLOT); FXASSERT(hotkey!=EMPTYSLOT); while((c=key[p].code)!=hotkey){ if(c==UNUSEDSLOT) return false; p=(p+1)&max; } return true; } return false; } // Parse key-combination description and return true if it is in the accelerator table FXbool FXAccelTable::hasAccel(const FXString& string) const { return hasAccel(parseAccel(string)); } // Parse key-combination description and return true if it is in the accelerator table FXbool FXAccelTable::hasAccel(const FXchar* string) const { return hasAccel(parseAccel(string)); } /*******************************************************************************/ // Return target object of the given accelerator key-combination FXObject* FXAccelTable::targetOfAccel(FXHotKey hotkey) const { if(hotkey){ FXuint p=(hotkey*13)&max; FXuint c; FXASSERT(hotkey!=UNUSEDSLOT); FXASSERT(hotkey!=EMPTYSLOT); while((c=key[p].code)!=hotkey){ if(c==UNUSEDSLOT) return nullptr; p=(p+1)&max; } return key[p].target; } return nullptr; } // Parse key-combination description and return its target FXObject* FXAccelTable::targetOfAccel(const FXString& string) const { return targetOfAccel(parseAccel(string)); } // Parse key-combination description and return its target FXObject* FXAccelTable::targetOfAccel(const FXchar* string) const { return targetOfAccel(parseAccel(string)); } /*******************************************************************************/ // Keyboard press; forward to accelerator target long FXAccelTable::onKeyPress(FXObject* sender,FXSelector,void* ptr){ FXTRACE((TOPIC_KEYBOARD,"%p->FXAccelTable::onKeyPress keysym=0x%04x state=%04x\n",this,((FXEvent*)ptr)->code,((FXEvent*)ptr)->state)); FXEvent* event=(FXEvent*)ptr; FXuint code=MKUINT(event->code,event->state&(SHIFTMASK|CONTROLMASK|ALTMASK)); FXuint p=(code*13)&max; FXuint c; FXASSERT(code!=UNUSEDSLOT); FXASSERT(code!=EMPTYSLOT); while((c=key[p].code)!=code){ if(c==UNUSEDSLOT) return 0; p=(p+1)&max; } if(key[p].target && key[p].messagedn){ key[p].target->tryHandle(sender,key[p].messagedn,ptr); } return 1; } // Keyboard release; forward to accelerator target long FXAccelTable::onKeyRelease(FXObject* sender,FXSelector,void* ptr){ FXTRACE((TOPIC_KEYBOARD,"%p->FXAccelTable::onKeyRelease keysym=0x%04x state=%04x\n",this,((FXEvent*)ptr)->code,((FXEvent*)ptr)->state)); FXEvent* event=(FXEvent*)ptr; FXuint code=MKUINT(event->code,event->state&(SHIFTMASK|CONTROLMASK|ALTMASK)); FXuint p=(code*13)&max; FXuint c; FXASSERT(code!=UNUSEDSLOT); FXASSERT(code!=EMPTYSLOT); while((c=key[p].code)!=code){ if(c==UNUSEDSLOT) return 0; p=(p+1)&max; } if(key[p].target && key[p].messageup){ key[p].target->tryHandle(sender,key[p].messageup,ptr); } return 1; } /*******************************************************************************/ // Parse accelerator from string, yielding modifier and key code FXHotKey FXAccelTable::parseAccel(const FXString& string){ return FXAccelTable::parseAccel(string.text()); } // Parse accelerator from string, yielding modifier and key code FXHotKey FXAccelTable::parseAccel(const FXchar* string){ const FXchar* ptr=string; FXuint code=0; FXuint mods=0; // Parse leading space while(*ptr && Ascii::isSpace(*ptr)) ptr++; // Parse modifiers while(*ptr){ // Modifier if(FXString::comparecase(ptr,"ctl",3)==0){ mods|=CONTROLMASK; ptr+=3; } else if(FXString::comparecase(ptr,"ctrl",4)==0){ mods|=CONTROLMASK; ptr+=4; } else if(FXString::comparecase(ptr,"alt",3)==0){ mods|=ALTMASK; ptr+=3; } else if(FXString::comparecase(ptr,"meta",4)==0){ mods|=METAMASK; ptr+=4; } else if(FXString::comparecase(ptr,"shift",5)==0){ mods|=SHIFTMASK; ptr+=5; } else break; // Separator if(*ptr=='+' || *ptr=='-' || Ascii::isSpace(*ptr)) ptr++; } // Test for some special keys if(FXString::comparecase(ptr,"home",4)==0){ code=KEY_Home; } else if(FXString::comparecase(ptr,"end",3)==0){ code=KEY_End; } else if(FXString::comparecase(ptr,"pgup",4)==0){ code=KEY_Page_Up; } else if(FXString::comparecase(ptr,"pgdn",4)==0){ code=KEY_Page_Down; } else if(FXString::comparecase(ptr,"left",4)==0){ code=KEY_Left; } else if(FXString::comparecase(ptr,"right",5)==0){ code=KEY_Right; } else if(FXString::comparecase(ptr,"up",2)==0){ code=KEY_Up; } else if(FXString::comparecase(ptr,"down",4)==0){ code=KEY_Down; } else if(FXString::comparecase(ptr,"ins",3)==0){ code=KEY_Insert; } else if(FXString::comparecase(ptr,"del",3)==0){ code=KEY_Delete; } else if(FXString::comparecase(ptr,"delete",6)==0){ code=KEY_Delete; } else if(FXString::comparecase(ptr,"esc",3)==0){ code=KEY_Escape; } else if(FXString::comparecase(ptr,"tab",3)==0){ code=KEY_Tab; } else if(FXString::comparecase(ptr,"return",6)==0){ code=KEY_Return; } else if(FXString::comparecase(ptr,"enter",5)==0){ code=KEY_Return; } else if(FXString::comparecase(ptr,"back",4)==0){ code=KEY_BackSpace; } else if(FXString::comparecase(ptr,"backspace",9)==0){ code=KEY_BackSpace; } else if(FXString::comparecase(ptr,"spc",3)==0){ code=KEY_space; } else if(FXString::comparecase(ptr,"space",5)==0){ code=KEY_space; } // Test for function keys else if(Ascii::toLower(*ptr)=='f' && Ascii::isDigit(*(ptr+1))){ if(Ascii::isDigit(*(ptr+2))){ code=KEY_F1+10*(*(ptr+1)-'0')+(*(ptr+2)-'0')-1; } else{ code=KEY_F1+*(ptr+1)-'0'-1; } } // Test if hexadecimal code designator else if(*ptr=='#' && Ascii::isHexDigit(*(ptr+1))){ code=Ascii::digitValue(*(ptr+1)); ptr+=2; while(Ascii::isHexDigit(*ptr)){ code=(code<<4)+Ascii::digitValue(*ptr); ptr++; } } // Test if its a single character accelerator else if(Ascii::isPrint(*ptr)){ if(mods&SHIFTMASK) code=Ascii::toUpper(*ptr)+KEY_space-' '; else code=Ascii::toLower(*ptr)+KEY_space-' '; } FXTRACE((TOPIC_ACCEL,"parseAccel(%s) = code=%04x mods=%04x\n",string,code,mods)); return MKUINT(code,mods); } /*******************************************************************************/ // Unparse hot key back into a string FXString FXAccelTable::unparseAccel(FXHotKey key){ FXuint mods=(key&0xffff0000)>>16; FXuint code=(key&0xffff); FXString s; // Handle modifier keys if(mods&CONTROLMASK) s+="Ctrl+"; if(mods&ALTMASK) s+="Alt+"; if(mods&SHIFTMASK) s+="Shift+"; if(mods&METAMASK) s+="Meta+"; // Handle some special keys switch(code){ case KEY_Home: s+="Home"; break; case KEY_End: s+="End"; break; case KEY_Page_Up: s+="PgUp"; break; case KEY_Page_Down: s+="PgDn"; break; case KEY_Left: s+="Left"; break; case KEY_Right: s+="Right"; break; case KEY_Up: s+="Up"; break; case KEY_Down: s+="Down"; break; case KEY_Insert: s+="Ins"; break; case KEY_Delete: s+="Del"; break; case KEY_Escape: s+="Esc"; break; case KEY_Tab: s+="Tab"; break; case KEY_Return: s+="Return"; break; case KEY_BackSpace: s+="Back"; break; case KEY_space: s+="Space"; break; case KEY_F1: case KEY_F2: case KEY_F3: case KEY_F4: case KEY_F5: case KEY_F6: case KEY_F7: case KEY_F8: case KEY_F9: case KEY_F10: case KEY_F11: case KEY_F12: case KEY_F13: case KEY_F14: case KEY_F15: case KEY_F16: case KEY_F17: case KEY_F18: case KEY_F19: case KEY_F20: case KEY_F21: case KEY_F22: case KEY_F23: case KEY_F24: case KEY_F25: case KEY_F26: case KEY_F27: case KEY_F28: case KEY_F29: case KEY_F30: case KEY_F31: case KEY_F32: case KEY_F33: case KEY_F34: case KEY_F35: s+=FXString::value("F%d",code-KEY_F1+1); break; default: if(Ascii::isPrint(code)){ if(mods&SHIFTMASK) s+=Ascii::toUpper(code); else s+=Ascii::toLower(code); } else{ s+=FXString::value("#%04X",code); } break; } return s; } /*******************************************************************************/ // Parse hot key from string FXHotKey parseHotKey(const FXString& string){ const FXchar* ptr=string.text(); FXuint code=0; FXuint mods=0; while(*ptr){ if(*ptr=='&'){ if(*(ptr+1)!='&'){ FXwchar w=wc(ptr+1); if(Unicode::isAlphaNumeric(w)){ mods=ALTMASK; code=fxucs2keysym(Unicode::toLower(w)); } break; } ptr++; } ptr++; } FXTRACE((TOPIC_ACCEL,"parseHotKey(%s) = code=%04x mods=%04x\n",string.text(),code,mods)); return MKUINT(code,mods); } // Obtain hot key offset in string FXint findHotKey(const FXString& string){ FXint pos=0; FXint n=0; while(pos> max; store >> num; resizeElms(key,max+1); for(FXuint i=0; i<=max; i++){ store >> key[i].code; store >> key[i].target; store >> key[i].messagedn; store >> key[i].messageup; } } // Destroy table FXAccelTable::~FXAccelTable(){ FXTRACE((TOPIC_CONSTRUCT,"%p->FXAccelTable::~FXAccelTable\n",this)); freeElms(key); key=(FXAccelKey*)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXApp.cpp000066400000000000000000006435661455751074500213120ustar00rootroot00000000000000/******************************************************************************** * * * A p p l i c a t i o n O b j e c t * * * ********************************************************************************* * Copyright (C) 1997,2023 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxchar.h" #include "fxkeys.h" #include "fxascii.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXAutoThreadStorageKey.h" #include "FXRunnable.h" #include "FXThread.h" #include "FXStream.h" #include "FXString.h" #include "FXColors.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXElement.h" #include "FXObject.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXAccelTable.h" #include "FXId.h" #include "FXVisual.h" #include "FXCursor.h" #include "FXFont.h" #include "FXDrawable.h" #include "FXBitmap.h" #include "FXImage.h" #include "FXIcon.h" #include "FXGIFIcon.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FXLabel.h" #include "FXButton.h" #include "FXComposite.h" #include "FXRootWindow.h" #include "FXShell.h" #include "FXTopWindow.h" #include "FXPopup.h" #include "FXMenuPane.h" #include "FXDialogBox.h" #include "FXMessageBox.h" #include "FXTranslator.h" #include "FXComposeContext.h" #include "fxpriv.h" /* Notes: - Major Contributions for Windows NT by Lyle Johnson. - Application should have a target to be notified of certain app-wide events, such as activation of [a window of] the application etc. - Need way to specify visual on command line (X11). - Need to be able to run event loop w/o display connection (just I/O, and timers). - Need to be able to ``detach'' from GUI more cleanly. - FXApp::exit() should be called by AFTER returning from FXApp::run(); also, FXApp::exit() should not call the global exit():- just because we're done doing GUI things does not mean we're done with the program! - When timer, signal, I/O, chore callback fires, need to go once round the event loop, because these callbacks may set a flag to break out of the event loop. This is done by letting getNextEvent() return false if it returns with NO event [The alternative would be to dispatch these events via dispatchEvent() which is currently a bit difficult]. - Event logging (journalling) and playback. We need some basic capabilities for journalling and playback of user-inputs [basically, mouse and keyboard events]. How exactly this is going to work is not entirely clear, but there are a couple of issues: - Mapping window ID's to something we can save on the file. FXWindow now generates a window-key which can identify each window by means of a kind of Dewey Decimal system. - Which events need logging? Of course, mouse buttons, motion, and keyboard, but how about enter/leave? The real mouse may be moving around too while playing back! - And what should be recorded. - Plus, some difficulty with event dispatch on Windows. - Pre- and post-dispatch hooks. In the pre-dispatch hook, the event is presented to some user-defined function (or maybe message handler) and can be inspected prior to dispatch. Returning a true or false from the pre-dispatch hook function will cause the actual dispatch to be blocked or not. Thus, the predispatch hook can act as an event filter, and events which are passed are dispatched normally. The post-dispatch hook is presented with the event AFTER it was dispatched. Either we present the event to the post-dispatch hook only when it was actually handled somewhere in the GUI, or we always present it and pass a flag that says whether it has been handled by some widget or not. The chief purpose of a post-dispatch hook is for event logging purposes. - Make sure keyboard gets dispatched to modal window [dialog or popup or whatever]. - FXInvocation into a class to its dtor will be called [just in case someone tries to throw an exception]. Having a dtor allows clean up without using a try-catch construct. - Modal modes for FXInvocation: - Non-modal for unconstrained model loops, like e.g. toplevel loop. - Modal for window, typically a dialog but generally modal for any window and its inferiors. Clicking outside the modal window will cause a beep. - Application modal, i.e. always beep no matter which window. This is useful for complete blocking of user-events while still performing layouts and repaints and so on. - Popup modal. Very similar to Modal for a window, except when clicking outside the popup stack is closed instead of issuing a beep. */ // Default maximum number of colors to allocate #define MAXCOLORS 125 // Largest number of signals on this system #define MAXSIGNALS 64 using namespace FX; /*******************************************************************************/ namespace FX { // Horizontal splitter cursor #include "hsplit.xbm" #include "hsplit_mask.xbm" // Vertical splitter cursor #include "vsplit.xbm" #include "vsplit_mask.xbm" // Cross splitter cursor #include "xsplit.xbm" #include "xsplit_mask.xbm" // Color swatch drag-and-drop cursor #include "swatch.xbm" #include "swatch_mask.xbm" // NO DROP drag-and-drop cursor #include "dontdrop.xbm" #include "dontdrop_mask.xbm" // Upper or lower side MDI resize cursor #include "resizetop.xbm" #include "resizetop_mask.xbm" // Right MDI resize cursor #include "resizetopright.xbm" #include "resizetopright_mask.xbm" // Left MDI resize cursor #include "resizetopleft.xbm" #include "resizetopleft_mask.xbm" // Left or right side MDI resize cursor #include "resizeleft.xbm" #include "resizeleft_mask.xbm" // Move cursor #include "drag.xbm" #include "drag_mask.xbm" // Drag and drop ASK #include "dndask.xbm" #include "dndask_mask.xbm" // Drag and drop COPY #include "dndcopy.xbm" #include "dndcopy_mask.xbm" // Drag and drop LINK #include "dndlink.xbm" #include "dndlink_mask.xbm" // Drag and drop MOVE #include "dndmove.xbm" #include "dndmove_mask.xbm" // Crosshair #include "crosshair.xbm" #include "crosshair_mask.xbm" // NE,NW,SE,SW corner cursors #include "ne.xbm" #include "ne_mask.xbm" #include "nw.xbm" #include "nw_mask.xbm" #include "se.xbm" #include "se_mask.xbm" #include "sw.xbm" #include "sw_mask.xbm" // Help arrow #include "helparrow.xbm" #include "helparrow_mask.xbm" // Rotate cursor #include "rotate.xbm" #include "rotate_mask.xbm" // Hand cursor #include "hand.xbm" #include "hand_mask.xbm" // Blank cursor #include "blank.xbm" #include "blank_mask.xbm" //#undef __USE_XOPEN2K /*******************************************************************************/ // Callback Record struct FXCBSpec { FXObject *target; // Receiver object FXptr data; // User data FXSelector message; // Message sent to receiver }; // Timer record struct FXTimer { FXTimer *next; // Next timeout in list FXObject *target; // Receiver object FXptr data; // User data FXSelector message; // Message sent to receiver FXTime due; // When timer is due (ns) }; // Signal record struct FXSignal { FXObject *target; // Receiver object FXSelector message; // Message sent to receiver FXbool handlerset; // Handler was already set FXbool notified; // Signal has fired }; // Idle record struct FXChore { FXChore *next; // Next chore in list FXObject *target; // Receiver object FXptr data; // User data FXSelector message; // Message sent to receiver }; // Input record struct FXInput { FXCBSpec read; // Callback spec for read FXCBSpec write; // Callback spec for write FXCBSpec excpt; // Callback spec for except }; // A repaint event record struct FXRepaint { FXRepaint *next; // Next repaint in list FXID window; // Window ID of the dirty window FXRectangle rect; // Dirty rectangle FXint area; // Area of this rectangle FXbool synth; // Synthetic expose event or real one? }; // Handles to be watched struct FXHandles { #ifdef WIN32 HANDLE hnd[MAXIMUM_WAIT_OBJECTS]; // Handle table #else fd_set hnd[3]; // Handle table #endif }; // Recursive Event Loop Invocation struct FXInvocation { FXInvocation **invocation; // Pointer to variable holding pointer to current invocation FXInvocation *upper; // Invocation above this one FXWindow *window; // Modal window (if any) FXModality modality; // Modality mode FXint code; // Return code FXbool done; // True if breaking out // Enter modal loop FXInvocation(FXInvocation** inv,FXModality mode,FXWindow* win):invocation(inv),upper(*inv),window(win),modality(mode),code(0),done(false){ *invocation=this; } // Exit modal loop ~FXInvocation(){ *invocation=upper; } }; /*******************************************************************************/ // Application object FXApp* FXApp::app=nullptr; // Copyright information const FXuchar FXApp::copyright[]="Copyright (C) 1997,2023 Jeroen van der Zijp. All Rights Reserved."; // Conversion extern FXAPI FXuint __strtoul(const FXchar *beg,const FXchar** end=nullptr,FXint base=0,FXbool* ok=nullptr); #if defined(WIN32) // Windows // 17 stipple patterns which match up exactly with the 4x4 dither kernel // Note that each scan line must be word-aligned so we pad to the right // with zeroes. static const BYTE stipple_patterns[17][16]={ {0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00, 0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00}, // 0 (white) {0xff,0x00,0xff,0x00,0xff,0x00,0x77,0x00, 0xff,0x00,0xff,0x00,0xff,0x00,0x77,0x00}, {0xff,0x00,0xdd,0x00,0xff,0x00,0x77,0x00, 0xff,0x00,0xdd,0x00,0xff,0x00,0x77,0x00}, {0xff,0x00,0xdd,0x00,0xff,0x00,0x55,0x00, 0xff,0x00,0xdd,0x00,0xff,0x00,0x55,0x00}, {0xff,0x00,0x55,0x00,0xff,0x00,0x55,0x00, 0xff,0x00,0x55,0x00,0xff,0x00,0x55,0x00}, {0xff,0x00,0x55,0x00,0xbb,0x00,0x55,0x00, 0xff,0x00,0x55,0x00,0xbb,0x00,0x55,0x00}, {0xee,0x00,0x55,0x00,0xbb,0x00,0x55,0x00, 0xee,0x00,0x55,0x00,0xbb,0x00,0x55,0x00}, {0xee,0x00,0x55,0x00,0xaa,0x00,0x55,0x00, 0xee,0x00,0x55,0x00,0xaa,0x00,0x55,0x00}, {0xaa,0x00,0x55,0x00,0xaa,0x00,0x55,0x00, 0xaa,0x00,0x55,0x00,0xaa,0x00,0x55,0x00}, // 8 (50% grey) {0xaa,0x00,0x55,0x00,0xaa,0x00,0x11,0x00, 0xaa,0x00,0x55,0x00,0xaa,0x00,0x11,0x00}, {0xaa,0x00,0x44,0x00,0xaa,0x00,0x11,0x00, 0xaa,0x00,0x44,0x00,0xaa,0x00,0x11,0x00}, {0xaa,0x00,0x44,0x00,0xaa,0x00,0x00,0x00, 0xaa,0x00,0x44,0x00,0xaa,0x00,0x00,0x00}, {0xaa,0x00,0x00,0x00,0xaa,0x00,0x00,0x00, 0xaa,0x00,0x00,0x00,0xaa,0x00,0x00,0x00}, {0xaa,0x00,0x00,0x00,0x22,0x00,0x00,0x00, 0xaa,0x00,0x00,0x00,0x22,0x00,0x00,0x00}, {0x88,0x00,0x00,0x00,0x22,0x00,0x00,0x00, 0x88,0x00,0x00,0x00,0x22,0x00,0x00,0x00}, {0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} // 16 (black) }; #else // X11 // 17 stipple patterns which match up exactly with the 4x4 dither kernel static const unsigned char stipple_patterns[17][8]={ {0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00}, // 0 (white) {0x00,0x00,0x00,0x88, 0x00,0x00,0x00,0x88}, {0x00,0x22,0x00,0x88, 0x00,0x22,0x00,0x88}, {0x00,0x22,0x00,0xaa, 0x00,0x22,0x00,0xaa}, {0x00,0xaa,0x00,0xaa, 0x00,0xaa,0x00,0xaa}, {0x00,0xaa,0x44,0xaa, 0x00,0xaa,0x44,0xaa}, {0x11,0xaa,0x44,0xaa, 0x11,0xaa,0x44,0xaa}, {0x11,0xaa,0x55,0xaa, 0x11,0xaa,0x55,0xaa}, {0x55,0xaa,0x55,0xaa, 0x55,0xaa,0x55,0xaa}, // 8 (50% grey) {0x55,0xaa,0x55,0xee, 0x55,0xaa,0x55,0xee}, {0x55,0xbb,0x55,0xee, 0x55,0xbb,0x55,0xee}, {0x55,0xbb,0x55,0xff, 0x55,0xbb,0x55,0xff}, {0x55,0xff,0x55,0xff, 0x55,0xff,0x55,0xff}, {0x55,0xff,0xdd,0xff, 0x55,0xff,0xdd,0xff}, {0x77,0xff,0xdd,0xff, 0x77,0xff,0xdd,0xff}, {0x77,0xff,0xff,0xff, 0x77,0xff,0xff,0xff}, {0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff} // 16 (black) }; // Standard-issue cross hatch pattern static const unsigned char cross_bits[] = { 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0xff, 0xff, 0xff, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0xff, 0xff, 0xff, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0xff, 0xff, 0xff, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0xff, 0xff, 0xff, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20 }; // Standard-issue diagonal cross hatch pattern static const unsigned char crossdiag_bits[] = { 0x22, 0x22, 0x14, 0x14, 0x08, 0x08, 0x14, 0x14, 0x22, 0x22, 0x41, 0x41, 0x80, 0x80, 0x41, 0x41, 0x22, 0x22, 0x14, 0x14, 0x08, 0x08, 0x14, 0x14, 0x22, 0x22, 0x41, 0x41, 0x80, 0x80, 0x41, 0x41 }; // Standard-issue diagonal hatch pattern static const unsigned char diag_bits[] = { 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x01, 0x01, 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x01, 0x01, 0x80, 0x80, 0x40, 0x40 }; // Standard-issue horizontal hatch pattern static const unsigned char hor_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // Standard-issue reverse diagonal hatch pattern static const unsigned char revdiag_bits[] = { 0x02, 0x02, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, 0x01, 0x01 }; // Standard-issue vertical hatch pattern static const unsigned char ver_bits[] = { 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20, 0x08, 0x82, 0x20 }; #endif /*******************************************************************************/ // Map FXDEFMAP(FXApp) FXAppMap[]={ FXMAPFUNC(SEL_TIMEOUT,FXApp::ID_HOVER,FXApp::onCmdHover), FXMAPFUNC(SEL_TIMEOUT,FXApp::ID_QUIT,FXApp::onCmdQuit), FXMAPFUNC(SEL_SIGNAL,FXApp::ID_QUIT,FXApp::onCmdQuit), FXMAPFUNC(SEL_CHORE,FXApp::ID_QUIT,FXApp::onCmdQuit), FXMAPFUNC(SEL_IO_READ,FXApp::ID_QUIT,FXApp::onCmdQuit), FXMAPFUNC(SEL_IO_WRITE,FXApp::ID_QUIT,FXApp::onCmdQuit), FXMAPFUNC(SEL_IO_EXCEPT,FXApp::ID_QUIT,FXApp::onCmdQuit), FXMAPFUNC(SEL_COMMAND,FXApp::ID_QUIT,FXApp::onCmdQuit), FXMAPFUNC(SEL_COMMAND,FXApp::ID_DUMP,FXApp::onCmdDump), }; // Implementation FXIMPLEMENT(FXApp,FXObject,FXAppMap,ARRAYNUMBER(FXAppMap)) /*******************************************************************************/ // Initialize application object FXApp::FXApp(const FXString& name,const FXString& vendor):registry(name,vendor){ // Initialize private platform independent data display=nullptr; // Display connection activeWindow=nullptr; // Active toplevel window cursorWindow=nullptr; // Window under the cursor mouseGrabWindow=nullptr; // Window which grabbed mouse keyboardGrabWindow=nullptr; // Window which grabbed keyboard keyWindow=nullptr; // Window in which keyboard key was pressed selectionWindow=nullptr; // Window which has the selection clipboardWindow=nullptr; // Window which has the clipboard dropWindow=nullptr; // Drag source window dragWindow=nullptr; // Drop target window refresher=nullptr; // GUI refresher pointer refresherstop=nullptr; // GUI refresher end pointer popupWindow=nullptr; // No popup windows timers=nullptr; // No timers present chores=nullptr; // No chores present repaints=nullptr; // No outstanding repaints timerrecs=nullptr; // No timer records chorerecs=nullptr; // No chore records repaintrecs=nullptr; // No repaint records invocation=nullptr; // Modal loop invocation callocElms(signals,MAXSIGNALS); // Signals array signalreceived=0; // Latest received signal callocElms(inputs,8); // Input file descriptors ninputs=8; // Number of these callocElms(handles,1); // Input handles maxhandle=-1; // Maximum handle number inputmethod=""; // Input method name inputstyle="onthespot"; // Input method style maxcolors=MAXCOLORS; // Maximum number of colors to allocate ddeData=nullptr; // Data exchange array ddeSize=0; // Data exchange array size appArgc=0; // Number of program arguments appArgv=nullptr; // Program arguments waitCount=0; // Cursor wait count windowCount=0; // Number of windows initialized=false; // Not yet initialized // Clear sticky mod state stickyMods=0; // Monochrome visual monoVisual=new FXVisual(this,VISUAL_MONO); // Default visual defaultVisual=new FXVisual(this,VISUAL_DEFAULT); // Make some cursors cursor[DEF_ARROW_CURSOR]=new FXCursor(this,CURSOR_ARROW); cursor[DEF_RARROW_CURSOR]=new FXCursor(this,CURSOR_RARROW); cursor[DEF_TEXT_CURSOR]=new FXCursor(this,CURSOR_IBEAM); // Cursors for splitter cursor[DEF_HSPLIT_CURSOR]=new FXCursor(this,hsplit_bits,hsplit_mask_bits,hsplit_width,hsplit_height,hsplit_x_hot,hsplit_y_hot); cursor[DEF_VSPLIT_CURSOR]=new FXCursor(this,vsplit_bits,vsplit_mask_bits,vsplit_width,vsplit_height,vsplit_x_hot,vsplit_y_hot); cursor[DEF_XSPLIT_CURSOR]=new FXCursor(this,xsplit_bits,xsplit_mask_bits,xsplit_width,xsplit_height,xsplit_x_hot,xsplit_y_hot); // Color swatch cursor[DEF_SWATCH_CURSOR]=new FXCursor(this,swatch_bits,swatch_mask_bits,swatch_width,swatch_height,swatch_x_hot,swatch_y_hot); // Move cursor[DEF_MOVE_CURSOR]=new FXCursor(this,drag_bits,drag_mask_bits,drag_width,drag_height,drag_x_hot,drag_y_hot); // Dragging edges/corners cursor[DEF_DRAGH_CURSOR]=new FXCursor(this,resizetop_bits,resizetop_mask_bits,resizetop_width,resizetop_height,resizetop_x_hot,resizetop_y_hot); cursor[DEF_DRAGV_CURSOR]=new FXCursor(this,resizeleft_bits,resizeleft_mask_bits,resizeleft_width,resizeleft_height,resizeleft_x_hot,resizeleft_y_hot); cursor[DEF_DRAGTR_CURSOR]=new FXCursor(this,resizetopright_bits,resizetopright_mask_bits,resizetopright_width,resizetopright_height,resizetopright_x_hot,resizetopright_y_hot); cursor[DEF_DRAGTL_CURSOR]=new FXCursor(this,resizetopleft_bits,resizetopleft_mask_bits,resizetopleft_width,resizetopleft_height,resizetopleft_x_hot,resizetopleft_y_hot); // DND actions cursor[DEF_DNDSTOP_CURSOR]=new FXCursor(this,dontdrop_bits,dontdrop_mask_bits,dontdrop_width,dontdrop_height,dontdrop_x_hot,dontdrop_y_hot); cursor[DEF_DNDASK_CURSOR]=new FXCursor(this,dndask_bits,dndask_mask_bits,dndask_width,dndask_height,dndcopy_x_hot,dndask_y_hot); cursor[DEF_DNDCOPY_CURSOR]=new FXCursor(this,dndcopy_bits,dndcopy_mask_bits,dndcopy_width,dndcopy_height,dndcopy_x_hot,dndcopy_y_hot); cursor[DEF_DNDMOVE_CURSOR]=new FXCursor(this,dndmove_bits,dndmove_mask_bits,dndmove_width,dndmove_height,dndmove_x_hot,dndmove_y_hot); cursor[DEF_DNDLINK_CURSOR]=new FXCursor(this,dndlink_bits,dndlink_mask_bits,dndlink_width,dndlink_height,dndlink_x_hot,dndlink_y_hot); // Crosshairs cursor[DEF_CROSSHAIR_CURSOR]=new FXCursor(this,crosshair_bits,crosshair_mask_bits,crosshair_width,crosshair_height,crosshair_x_hot,crosshair_y_hot); // NE,NW,SE,SW corners cursor[DEF_CORNERNE_CURSOR]=new FXCursor(this,ne_bits,ne_mask_bits,ne_width,ne_height,ne_x_hot,ne_y_hot); cursor[DEF_CORNERNW_CURSOR]=new FXCursor(this,nw_bits,nw_mask_bits,nw_width,nw_height,nw_x_hot,nw_y_hot); cursor[DEF_CORNERSE_CURSOR]=new FXCursor(this,se_bits,se_mask_bits,se_width,se_height,se_x_hot,se_y_hot); cursor[DEF_CORNERSW_CURSOR]=new FXCursor(this,sw_bits,sw_mask_bits,sw_width,sw_height,sw_x_hot,sw_y_hot); // Help arrow cursor cursor[DEF_HELP_CURSOR]=new FXCursor(this,helparrow_bits,helparrow_mask_bits,helparrow_width,helparrow_height,helparrow_x_hot,helparrow_y_hot); // Hand cursor cursor[DEF_HAND_CURSOR]=new FXCursor(this,hand_bits,hand_mask_bits,hand_width,hand_height,hand_x_hot,hand_y_hot); // Rotate cursor[DEF_ROTATE_CURSOR]=new FXCursor(this,rotate_bits,rotate_mask_bits,rotate_width,rotate_height,rotate_x_hot,rotate_y_hot); // Blank cursor cursor[DEF_BLANK_CURSOR]=new FXCursor(this,blank_bits,blank_mask_bits,blank_width,blank_height,blank_x_hot,blank_y_hot); // Wait cursor cursor[DEF_WAIT_CURSOR]=new FXCursor(this,CURSOR_WATCH); // Set current wait cursor waitCursor=cursor[DEF_WAIT_CURSOR]; // Root window root=new FXRootWindow(this,defaultVisual); #if defined(WIN32) // MS-Windows specific inits // DDE ddeTargets=0; // Data exchange to get list of types ddeAtom=0; // Data exchange atom ddeDelete=0; // Data exchange delete request ddeTypeList=nullptr; // Data types list available ddeNumTypes=0; // Number of data types ddeAction=DRAG_REJECT; // Drag and drop action requested ansAction=DRAG_REJECT; // Drag and drop action suggested // SELECTION xselTypeList=nullptr; // List of primary selection types xselNumTypes=0; // How many types in list // XDND xdndFinishPending=false; // XDND waiting for drop-confirmation xdndAware=0; // XDND awareness atom xdndTypes=nullptr; xdndSource=0; // XDND drag source window xdndTarget=0; // XDND drop target window xdndStatusPending=false; // XDND waiting for status feedback xdndStatusReceived=false; // XDND received at least one status xdndFinishSent=false; // XDND finish sent xdndRect.x=0; // XDND motion rectangle xdndRect.y=0; xdndRect.w=0; xdndRect.h=0; #else // X Window specific inits wmDeleteWindow=0; // Window Manager stuff wmSaveYourself=0; wmQuitApp=0; wmProtocols=0; wmMotifHints=0; wmTakeFocus=0; wmClientMachine=0; wmState=0; wmNetState=0; wmNetIconName=0; wmNetWindowName=0; wmNetSupported=0; // Extended Window Manager stuff wmNetHidden=0; wmNetShaded=0; wmNetHMaximized=0; wmNetVMaximized=0; wmNetFullScreen=0; wmNetBelowOthers=0; wmNetAboveOthers=0; wmNetNeedAttention=0; wmNetMoveResize=0; wmNetRestack=0; wmNetPing=0; wmNetProcessId=0; wmNetWindowType=0; wmWindowRole=0; // Window Role wmClientLeader=0; // Client leader wmClientId=0; // Session management id embedAtom=0; // XEMBED support embedInfoAtom=0; // XEMBED info support timestampAtom=0; // Server time // DDE ddeTargets=0; // Data exchange to get list of types ddeAtom=0; // Data exchange atom ddeDelete=0; // Data exchange delete request ddeTypeList=nullptr; // Data types list available ddeNumTypes=0; // Number of data types ddeAction=DRAG_REJECT; // Drag and drop action requested ansAction=DRAG_REJECT; // Drag and drop action suggested // CLIPBOARD xcbSelection=0; // Clipboard selection atom xcbTypeList=nullptr; // List of clipboard types xcbNumTypes=0; // How many types clipped // SELECTION xselTypeList=nullptr; // List of primary selection types xselNumTypes=0; // How many types in list // XDND xdndTypeList=nullptr; // List of XDND types xdndNumTypes=0; // How many types in list xdndProxy=0; // XDND proxy atom xdndAware=0; // XDND awareness atom xdndEnter=0; // XDND Message types xdndLeave=0; xdndPosition=0; xdndStatus=0; xdndDrop=0; xdndFinished=0; xdndSelection=0; xdndTypes=0; // XDND type list atom xdndActions=0; // XDND action list atom xdndActionList[DRAG_REJECT]=0; // XDND Reject xdndActionList[DRAG_ASK]=0; // XDND Ask action xdndActionList[DRAG_COPY]=0; // XDND Copy action xdndActionList[DRAG_MOVE]=0; // XDND Move action xdndActionList[DRAG_LINK]=0; // XDND Link action xdndActionList[DRAG_PRIVATE]=0; // XDND Private action xdndSource=0; // XDND drag source window xdndTarget=0; // XDND drop target window xdndProxyTarget=0; // XDND window to set messages to xdndStatusPending=false; // XDND waiting for status feedback xdndStatusReceived=false; // XDND received at least one status xdndWantUpdates=true; // XDND target always wants new positions xdndFinishSent=false; // XDND finish sent xdndRect.x=0; // XDND motion rectangle xdndRect.y=0; xdndRect.w=0; xdndRect.h=0; xrrScreenChange=0; // Xrandr event xfxFixesSelection=0; // Xfixes event xInputOpcode=0; // XInput2 Opcode xsbDevice=0; // Space ball device xim=nullptr; // Input method stuff // Miscellaneous stuff shmi=true; shmp=true; xrender=false; synchronize=false; #endif // Timing constants typingSpeed=1000000000; clickSpeed=400000000; scrollSpeed=80000000; scrollDelay=600000000; blinkSpeed=500000000; animSpeed=20000000; menuPause=400000000; toolTipPause=800000000; toolTipTime=2000000000; autoHideDelay=2000000000; // Miscellaneous settings dragDelta=6; wheelLines=10; scrollBarSize=15; // Make font #if defined(HAVE_XFT_H) normalFont=new FXFont(this,"Sans,90"); #else normalFont=new FXFont(this,"helvetica,90"); #endif // We delete the stock font stockFont=normalFont; // Default translator translator=new FXTranslator; // Init colors borderColor=FXRGB(0,0,0); baseColor=FXRGB(212,208,200); hiliteColor=makeHiliteColor(baseColor); shadowColor=makeShadowColor(baseColor); backColor=FXRGB(255,255,255); foreColor=FXRGB(0,0,0); selforeColor=FXRGB(255,255,255); selbackColor=FXRGB(10,36,106); tipforeColor=FXRGB(0,0,0); tipbackColor=FXRGB(255,255,225); selMenuTextColor=FXRGB(255,255,255); selMenuBackColor=FXRGB(10,36,106); // Pointer to FXApp app=this; } /*******************************************************************************/ // Change application name void FXApp::setAppName(const FXString& name){ registry.setAppKey(name); } // Get application name const FXString& FXApp::getAppName() const { return registry.getAppKey(); } // Change vendor name void FXApp::setVendorName(const FXString& name){ registry.setVendorKey(name); } // Get vendor name const FXString& FXApp::getVendorName() const { return registry.getVendorKey(); } // Return true if input method support FXbool FXApp::hasInputMethod() const { #if defined(WIN32) return true; #else return xim!=nullptr; #endif } // Change default visual void FXApp::setDefaultVisual(FXVisual* vis){ if(!vis){ fxerror("%s::setDefaultVisual: NULL visual.\n",getClassName()); } defaultVisual=vis; } // Set root Window void FXApp::setRootWindow(FXRootWindow* rt){ if(!rt){ fxerror("%s::setRootWindow: NULL root window.\n",getClassName()); } if(root->getFirst()){ fxerror("%s::setRootWindow: already have windows.\n",getClassName()); } if(rt->getVisual()!=root->getVisual()){ fxerror("%s::setRootWindow: has different visual.\n",getClassName()); } root=rt; } // Return window at the end of the focus chain FXWindow *FXApp::getFocusWindow() const { FXWindow *result=getActiveWindow(); if(result){ while(result->getFocus()){ result=result->getFocus(); } } return result; } #if 0 FXWindow* FXApp::getForegroundWindow() const { FXWindow *win=nullptr; #ifdef WIN32 unsigned long n,i; Atom type; unsigned char *prop; int format; if(Success==XGetWindowProperty((Display*)display,XDefaultRootWindow((Display*)display),wmNetActiveWindow,0,1,false,XA_WINDOW,&type,&format,&n,&i,&prop)){ if(type==XA_WINDOW && format==32){ win=findWindowWithId(*((Window*)prop)); } XFree(prop); } #else FXWindow *win=findWindowWithId((FXID)GetForegroundWindow()); #endif return win; } #endif // Find window from id FXWindow* FXApp::findWindowWithId(FXID xid) const { return (FXWindow*)hash.at((FXptr)xid); } // Find window from root x,y, starting from given window FXWindow* FXApp::findWindowAt(FXint rx,FXint ry,FXID window) const { if(initialized){ #if defined(WIN32) POINT point; FXID child; if(!window) window=(FXID)GetDesktopWindow(); while(1){ point.x=rx; point.y=ry; ScreenToClient((HWND)window,&point); child=ChildWindowFromPointEx((HWND)window,point,CWP_SKIPINVISIBLE|CWP_SKIPTRANSPARENT); // Suggested by "PelleBert" if(!child || child==window) break; window=child; } #else Window rootwin=XDefaultRootWindow((Display*)display); Window child; int wx,wy; if(!window) window=rootwin; while(1){ if(!XTranslateCoordinates((Display*)display,rootwin,window,rx,ry,&wx,&wy,&child)) return nullptr; if(child==None) break; window=child; } #endif return findWindowWithId(window); } return nullptr; } // Change normal font void FXApp::setNormalFont(FXFont* font){ if(!font){ fxerror("%s::setNormalFont: NULL font.\n",getClassName()); } normalFont=font; } /*******************************************************************************/ // Begin of wait-cursor block; wait-cursor blocks may be nested. void FXApp::beginWaitCursor(){ if(initialized){ if(waitCount==0){ if(!waitCursor->id()){ fxerror("%s::beginWaitCursor: wait cursor not created yet.\n",getClassName()); } #if defined(WIN32) SetCursor((HCURSOR)waitCursor->id()); #else FXWindow* child; FXASSERT(display); child=getRootWindow()->getFirst(); while(child){ if(child->id()){ XDefineCursor((Display*)display,child->id(),waitCursor->id()); if(child->getFirst()){child=child->getFirst();continue;} } while(!child->getNext()&&child->getParent()){child=child->getParent();} child=child->getNext(); } if(mouseGrabWindow){ XChangeActivePointerGrab((Display*)display,(ButtonPressMask|ButtonReleaseMask|PointerMotionMask|EnterWindowMask|LeaveWindowMask),waitCursor->id(),CurrentTime); } XFlush((Display*)display); #endif } waitCount++; } } // End of wait-cursor block void FXApp::endWaitCursor(){ if(initialized){ if(waitCount==0) return; waitCount--; if(waitCount==0){ if(!waitCursor->id()){ fxerror("%s::endWaitCursor: wait cursor not created yet.\n",getClassName()); } #if defined(WIN32) if(cursorWindow){ SetCursor((HCURSOR)cursorWindow->getDefaultCursor()->id()); } #else FXWindow* child; child=getRootWindow()->getFirst(); while(child){ if(child->id()){ XDefineCursor((Display*)display,child->id(),child->getDefaultCursor()->id()); if(child->getFirst()){child=child->getFirst();continue;} } while(!child->getNext()&&child->getParent()){child=child->getParent();} child=child->getNext(); } if(mouseGrabWindow){ XChangeActivePointerGrab((Display*)display,(ButtonPressMask|ButtonReleaseMask|PointerMotionMask|EnterWindowMask|LeaveWindowMask),mouseGrabWindow->getDragCursor()->id(),CurrentTime); } XFlush((Display*)display); #endif } } } // Change to a new wait cursor void FXApp::setWaitCursor(FXCursor *cur){ if(initialized){ if(cur==nullptr){ fxerror("%s::setWaitCursor: NULL wait cursor.\n",getClassName()); } if(waitCursor!=cur){ waitCursor=cur; if(waitCount){ if(!waitCursor->id()){ fxerror("%s::setWaitCursor: wait cursor not created yet.\n",getClassName()); } #if defined(WIN32) SetCursor((HCURSOR)waitCursor->id()); #else FXWindow* child; child=getRootWindow()->getFirst(); while(child){ if(child->id()){ XDefineCursor((Display*)display,child->id(),waitCursor->id()); if(child->getFirst()){child=child->getFirst();continue;} } while(!child->getNext()&&child->getParent()){child=child->getParent();} child=child->getNext(); } XFlush((Display*)display); #endif } } } } // Change default cursor void FXApp::setDefaultCursor(FXDefaultCursor which,FXCursor* cur){ if(!cur){ fxerror("%s::setDefaultCursor: NULL default cursor.\n",getClassName()); } cursor[which]=cur; } /*******************************************************************************/ // Register DND type FXDragType FXApp::registerDragType(const FXString& name) const { if(initialized){ #if defined(WIN32) return RegisterClipboardFormatA(name.text()); #else return (FXDragType)XInternAtom((Display*)display,name.text(),0); #endif } return 0; } // Get name of registered drag type FXString FXApp::getDragTypeName(FXDragType type) const { if(initialized){ FXString result; #if defined(WIN32) if(0xC000<=type && type<=0xFFFF){ FXchar buffer[256]; GetClipboardFormatNameA(type,buffer,sizeof(buffer)); result.assign(buffer); } else{ result.assign("WIN32_DEFAULT_TYPE"); } #else FXchar *name=XGetAtomName((Display*)display,type); result.assign(name); XFree(name); #endif return result; } return FXString::null; } /*******************************************************************************/ // Change message translator void FXApp::setTranslator(FXTranslator* trans){ translator=trans; } #if defined(WIN32) // WIN32 // Trick to find module handle of FOX library static HINSTANCE GetOwnModuleHandle(){ MEMORY_BASIC_INFORMATION mbi; VirtualQuery((const void*)GetOwnModuleHandle,&mbi,sizeof(mbi)); return (HINSTANCE)mbi.AllocationBase; } // Open Input devices void FXApp::openInputDevices(){ #if 0 //(_WIN32_WINNT >= 0x0501) RAWINPUTDEVICELIST *devlist; RID_DEVICE_INFO devinfo; RAWINPUTDEVICE dev; FXuint num_devices; FXchar devname[256]; FXuint i; FXuint bc; // Get the number of attached raw input devices GetRawInputDeviceList(nullptr,&num_devices,sizeof(RAWINPUTDEVICELIST)); if(0error_code==BadWindow && eev->request_code==25) return 0; // WM_TAKE_FOCUS causes sporadic errors for X_SetInputFocus if(eev->request_code==42) return 0; // Get error codes XGetErrorText(dpy,eev->error_code,buf,sizeof(buf)); // Print out meaningful warning fxwarning("X Error: code %d major %d minor %d: %s.\n",eev->error_code,eev->request_code,eev->minor_code,buf); return 1; } // Fatal error (e.g. lost connection) static int xfatalerrorhandler(Display*){ fxerror("X Fatal error.\n"); return 1; } // Input method was created; unregister the callback, and initialize it void FXApp::imcreatecallback(void*,FXApp* a,void*){ #ifndef NO_XIM XIMCallback ximcallback; fxwarning("Warning: input method server restarted.\n"); XUnregisterIMInstantiateCallback((Display*)app->getDisplay(),nullptr,nullptr,nullptr,(XIDProc)imcreatecallback,(XPointer)a); a->xim=XOpenIM((Display*)app->display,nullptr,nullptr,nullptr); if(a->xim){ ximcallback.callback=(XIMProc)imdestroycallback; ximcallback.client_data=(XPointer)a; XSetIMValues((XIM)a->xim,XNDestroyCallback,&ximcallback,nullptr); } #endif } // Input method was deleted; set callback to recreate it when the IM restarts. void FXApp::imdestroycallback(void*,FXApp* a,void*){ #ifndef NO_XIM fxwarning("Warning: input method server terminated.\n"); XRegisterIMInstantiateCallback((Display*)a->getDisplay(),nullptr,nullptr,nullptr,(XIDProc)imcreatecallback,(XPointer)a); a->xim=nullptr; #endif } // Open Input devices void FXApp::openInputDevices(){ #if defined(HAVE_XINPUT2_H) int majoropcode,eventbase,errorbase,ndevices; if(XQueryExtension((Display*)display,"XInputExtension",&majoropcode,&eventbase,&errorbase)){ int majorversion=XI_2_Major,minorversion=XI_2_Minor; FXTRACE((100,"XInputExtension maj:%d, evt:%d, err:%d\n",majoropcode,eventbase,errorbase)); if(XIQueryVersion((Display*)display,&majorversion,&minorversion)==Success){ FXTRACE((100,"XInput2 ver:%d.%d\n",majorversion,minorversion)); unsigned char maskbits[4]={0,0,0,0}; XIEventMask eventmask={XIAllDevices,sizeof(maskbits),maskbits}; XISetMask(eventmask.mask,XI_DeviceChanged); XISetMask(eventmask.mask,XI_HierarchyChanged); XISetMask(eventmask.mask,XI_PropertyEvent); XISelectEvents((Display*)display,XDefaultRootWindow((Display*)display),&eventmask,1); XIDeviceInfo *devices=XIQueryDevice((Display*)display,XIAllDevices,&ndevices); if(devices){ for(FXint i=0; i(windowTypeAtoms),14,0,wmWindowTypes); // Session management wmWindowRole=XInternAtom((Display*)display,"WM_WINDOW_ROLE",0); wmClientLeader=XInternAtom((Display*)display,"WM_CLIENT_LEADER",0); wmClientId=XInternAtom((Display*)display,"SM_CLIENT_ID",0); // XEMBED support embedAtom=XInternAtom((Display*)display,"_XEMBED",0); embedInfoAtom=XInternAtom((Display*)display,"_XEMBED_INFO",0); timestampAtom=XInternAtom((Display*)display,"FOX_TIMESTAMP_PROP",0); // DDE property ddeAtom=(FXID)XInternAtom((Display*)display,"_FOX_DDE",0); ddeDelete=(FXID)XInternAtom((Display*)display,"DELETE",0); ddeTargets=(FXID)XInternAtom((Display*)display,"TARGETS",0); ddeIncr=(FXID)XInternAtom((Display*)display,"INCR",0); // Clipboard xcbSelection=(FXID)XInternAtom((Display*)display,"CLIPBOARD",0); // XDND protocol awareness xdndProxy=(FXID)XInternAtom((Display*)display,"XdndProxy",0); xdndAware=(FXID)XInternAtom((Display*)display,"XdndAware",0); // XDND Messages xdndEnter=(FXID)XInternAtom((Display*)display,"XdndEnter",0); xdndLeave=(FXID)XInternAtom((Display*)display,"XdndLeave",0); xdndPosition=(FXID)XInternAtom((Display*)display,"XdndPosition",0); xdndStatus=(FXID)XInternAtom((Display*)display,"XdndStatus",0); xdndDrop=(FXID)XInternAtom((Display*)display,"XdndDrop",0); xdndFinished=(FXID)XInternAtom((Display*)display,"XdndFinished",0); // XDND Selection atom xdndSelection=(FXID)XInternAtom((Display*)display,"XdndSelection",0); // XDND Types list xdndTypes=(FXID)XInternAtom((Display*)display,"XdndTypeList",0); // XDND Action list xdndActions=(FXID)XInternAtom((Display*)display,"XdndActionList",0); // XDND Actions xdndActionList[DRAG_REJECT]=None; xdndActionList[DRAG_ASK]=(FXID)XInternAtom((Display*)display,"XdndActionAsk",0); xdndActionList[DRAG_COPY]=(FXID)XInternAtom((Display*)display,"XdndActionCopy",0); xdndActionList[DRAG_MOVE]=(FXID)XInternAtom((Display*)display,"XdndActionMove",0); xdndActionList[DRAG_LINK]=(FXID)XInternAtom((Display*)display,"XdndActionLink",0); xdndActionList[DRAG_PRIVATE]=(FXID)XInternAtom((Display*)display,"XdndActionPrivate",0); // Standard stipples stipples[STIPPLE_0]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)stipple_patterns[STIPPLE_0],8,8); stipples[STIPPLE_1]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)stipple_patterns[STIPPLE_1],8,8); stipples[STIPPLE_2]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)stipple_patterns[STIPPLE_2],8,8); stipples[STIPPLE_3]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)stipple_patterns[STIPPLE_3],8,8); stipples[STIPPLE_4]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)stipple_patterns[STIPPLE_4],8,8); stipples[STIPPLE_5]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)stipple_patterns[STIPPLE_5],8,8); stipples[STIPPLE_6]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)stipple_patterns[STIPPLE_6],8,8); stipples[STIPPLE_7]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)stipple_patterns[STIPPLE_7],8,8); stipples[STIPPLE_8]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)stipple_patterns[STIPPLE_8],8,8); stipples[STIPPLE_9]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)stipple_patterns[STIPPLE_9],8,8); stipples[STIPPLE_10]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)stipple_patterns[STIPPLE_10],8,8); stipples[STIPPLE_11]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)stipple_patterns[STIPPLE_11],8,8); stipples[STIPPLE_12]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)stipple_patterns[STIPPLE_12],8,8); stipples[STIPPLE_13]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)stipple_patterns[STIPPLE_13],8,8); stipples[STIPPLE_14]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)stipple_patterns[STIPPLE_14],8,8); stipples[STIPPLE_15]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)stipple_patterns[STIPPLE_15],8,8); stipples[STIPPLE_16]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)stipple_patterns[STIPPLE_16],8,8); // Hatch patterns stipples[STIPPLE_HORZ]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)hor_bits,24,24); stipples[STIPPLE_VERT]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)ver_bits,24,24); stipples[STIPPLE_CROSS]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)cross_bits,24,24); stipples[STIPPLE_DIAG]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)diag_bits,16,16); stipples[STIPPLE_REVDIAG]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)revdiag_bits,16,16); stipples[STIPPLE_CROSSDIAG]=(FXID)XCreateBitmapFromData((Display*)display,XDefaultRootWindow((Display*)display),(const char*)crossdiag_bits,16,16); // Preregister some drag types FXWindow::octetType=(FXDragType)XInternAtom((Display*)display,FXWindow::octetTypeName,0); FXWindow::deleteType=(FXDragType)XInternAtom((Display*)display,FXWindow::deleteTypeName,0); FXWindow::textType=(FXDragType)XInternAtom((Display*)display,FXWindow::textTypeName,0); FXWindow::colorType=(FXDragType)XInternAtom((Display*)display,FXWindow::colorTypeName,0); FXWindow::urilistType=(FXDragType)XInternAtom((Display*)display,FXWindow::urilistTypeName,0); FXWindow::utf8Type=(FXDragType)XInternAtom((Display*)display,FXWindow::utf8TypeName,0); FXWindow::utf16Type=(FXDragType)XInternAtom((Display*)display,FXWindow::utf16TypeName,0); FXWindow::actionType=(FXDragType)XInternAtom((Display*)display,FXWindow::actionTypeName,0); #endif // Open input devices openInputDevices(); // Clear sticky mod state stickyMods=0; // Lock the global mutex appMutex.lock(); // We have been initialized initialized=true; } return true; } // Close display FXbool FXApp::closeDisplay(){ if(initialized){ // What's going on FXTRACE((100,"%s::closeDisplay: closing display.\n",getClassName())); // Destroy widgets destroy(); // Close input devices closeInputDevices(); #if defined(WIN32) // MS-Windows // Atoms created using GlobalCreateAtom() are reference-counted by // the system; calling GlobalDeleteAtom() here just decrements the // reference count but doesn't necessarily free the memory. GlobalDeleteAtom(ddeTargets); GlobalDeleteAtom(xdndAware); // Free standard stipples DeleteObject(stipples[STIPPLE_0]); DeleteObject(stipples[STIPPLE_1]); DeleteObject(stipples[STIPPLE_2]); DeleteObject(stipples[STIPPLE_3]); DeleteObject(stipples[STIPPLE_4]); DeleteObject(stipples[STIPPLE_5]); DeleteObject(stipples[STIPPLE_6]); DeleteObject(stipples[STIPPLE_7]); DeleteObject(stipples[STIPPLE_8]); DeleteObject(stipples[STIPPLE_9]); DeleteObject(stipples[STIPPLE_10]); DeleteObject(stipples[STIPPLE_11]); DeleteObject(stipples[STIPPLE_12]); DeleteObject(stipples[STIPPLE_13]); DeleteObject(stipples[STIPPLE_14]); DeleteObject(stipples[STIPPLE_15]); DeleteObject(stipples[STIPPLE_16]); #else // X11 // Free standard stipples XFreePixmap((Display*)display,stipples[STIPPLE_0]); XFreePixmap((Display*)display,stipples[STIPPLE_1]); XFreePixmap((Display*)display,stipples[STIPPLE_2]); XFreePixmap((Display*)display,stipples[STIPPLE_3]); XFreePixmap((Display*)display,stipples[STIPPLE_4]); XFreePixmap((Display*)display,stipples[STIPPLE_5]); XFreePixmap((Display*)display,stipples[STIPPLE_6]); XFreePixmap((Display*)display,stipples[STIPPLE_7]); XFreePixmap((Display*)display,stipples[STIPPLE_8]); XFreePixmap((Display*)display,stipples[STIPPLE_9]); XFreePixmap((Display*)display,stipples[STIPPLE_10]); XFreePixmap((Display*)display,stipples[STIPPLE_11]); XFreePixmap((Display*)display,stipples[STIPPLE_12]); XFreePixmap((Display*)display,stipples[STIPPLE_13]); XFreePixmap((Display*)display,stipples[STIPPLE_14]); XFreePixmap((Display*)display,stipples[STIPPLE_15]); XFreePixmap((Display*)display,stipples[STIPPLE_16]); // Free hatch patterns XFreePixmap((Display*)display,stipples[STIPPLE_HORZ]); XFreePixmap((Display*)display,stipples[STIPPLE_VERT]); XFreePixmap((Display*)display,stipples[STIPPLE_CROSS]); XFreePixmap((Display*)display,stipples[STIPPLE_DIAG]); XFreePixmap((Display*)display,stipples[STIPPLE_REVDIAG]); XFreePixmap((Display*)display,stipples[STIPPLE_CROSSDIAG]); // Close input method #ifndef NO_XIM if(xim){XCloseIM((XIM)xim);} #endif // Close display XCloseDisplay((Display*)display); #endif // Clear it display=nullptr; // Unlock the global mutex appMutex.unlock(); // We are no longer initialized initialized=false; } return true; } /*******************************************************************************/ // Add deadline in nanoseconds FXptr FXApp::addDeadline(FXObject* tgt,FXSelector sel,FXTime due,FXptr ptr){ FXptr result=nullptr; FXTimer *t,**tt; for(tt=&timers; (t=*tt)!=nullptr; tt=&t->next){ if(t->target==tgt && t->message==sel){ *tt=t->next; result=t->data; goto a; } } if(timerrecs){ t=timerrecs; timerrecs=t->next; } else{ t=new FXTimer; } a:t->data=ptr; t->target=tgt; t->message=sel; t->due=due; for(tt=&timers; *tt && ((*tt)->due < t->due); tt=&(*tt)->next){} t->next=*tt; *tt=t; return result; } // Add timeout in nanoseconds FXptr FXApp::addTimeout(FXObject* tgt,FXSelector sel,FXTime ns,FXptr ptr){ return addDeadline(tgt,sel,FXThread::time()+ns,ptr); } // Check if timeout identified by tgt and sel has been set FXbool FXApp::hasTimeout(FXObject* tgt,FXSelector sel) const { for(FXTimer *t=timers; t; t=t->next){ if(t->target==tgt && (sel==0 || t->message==sel)) return true; } return false; } // Remove timeout(s) identified by tgt and sel from the list FXptr FXApp::removeTimeout(FXObject* tgt,FXSelector sel){ FXptr result=nullptr; FXTimer **tt=&timers; FXTimer *t; while((t=*tt)!=nullptr){ if(t->target==tgt && (sel==0 || t->message==sel)){ *tt=t->next; result=t->data; t->next=timerrecs; timerrecs=t; continue; } tt=&t->next; } return result; } // Return the remaining time, in nanoseconds FXTime FXApp::remainingTimeout(FXObject *tgt,FXSelector sel) const { for(FXTimer *t=timers; t; t=t->next){ if(t->target==tgt && (sel==0 || t->message==sel)){ FXTime now=FXThread::time(); return t->due>now ? t->due-now : 0L; } } return forever; } /*******************************************************************************/ // Signal handler; note this is a single write operation // which can not be interrupted by another handler! void FXApp::signalhandler(int sig){ app->signals[sig].notified=true; app->signalreceived=sig; } // This signal handler is potentially dangerous as it dispatches // the message to the target right here in the handler; you probably // want to use this one only in ``desperate'' situations. void FXApp::immediatesignalhandler(int sig){ if(app->signals[sig].target) app->signals[sig].target->handle(app,FXSEL(SEL_SIGNAL,app->signals[sig].message),(void*)(FXival)sig); } // Add a signal message void FXApp::addSignal(FXint sig,FXObject* tgt,FXSelector sel,FXbool immediate,FXuint flags){ void (CDECL *handler)(int); if(sig<0 || MAXSIGNALSnext){ if(c->target==tgt && c->message==sel){ *cc=c->next; result=c->data; goto a; } } if(chorerecs){ c=chorerecs; chorerecs=c->next; } else{ c=new FXChore; } a:c->data=ptr; c->target=tgt; c->message=sel; for(cc=&chores; *cc; cc=&(*cc)->next){} c->next=nullptr; *cc=c; return result; } // Remove chore(s) identified by tgt and sel from the list FXptr FXApp::removeChore(FXObject* tgt,FXSelector sel){ FXptr result=nullptr; FXChore **cc=&chores; FXChore *c; while((c=*cc)!=nullptr){ if(c->target==tgt && (sel==0 || c->message==sel)){ *cc=c->next; result=c->data; c->next=chorerecs; chorerecs=c; continue; } cc=&c->next; } return result; } // Check if chore identified by tgt and sel has been set FXbool FXApp::hasChore(FXObject* tgt,FXSelector sel) const { for(FXChore *c=chores; c; c=c->next){ if(c->target==tgt && (sel==0 || c->message==sel)) return true; } return false; } /*******************************************************************************/ // Add input FXbool FXApp::addInput(FXObject *tgt,FXSelector sel,FXInputHandle fd,FXuint mode,FXptr ptr){ if(mode==INPUT_NONE) return false; #if defined(WIN32) FXint in; if(fd==INVALID_HANDLE_VALUE || fd==nullptr) return false; for(in=0; in<=maxhandle; in++){ // See if existing handle if(handles->hnd[in]==fd) goto r; // If existing handle, just replace callbacks } if(maxhandle+1>=MAXIMUM_WAIT_OBJECTS) return false; if(maxhandle+1>=ninputs){ // Grow table of callbacks resizeElms(inputs,ninputs+1); clearElms(&inputs[ninputs],1); ninputs=ninputs+1; } in=++maxhandle; // One more handle handles->hnd[in]=fd; r:FXASSERT(in=FD_SETSIZE) return false; if(fd>=ninputs){ // Grow table of callbacks resizeElms(inputs,fd+1); clearElms(&inputs[ninputs],fd+1-ninputs); ninputs=fd+1; } FXASSERT(inputs); FXASSERT(fdhnd[0]); } if(mode&INPUT_WRITE){ inputs[fd].write.target=tgt; inputs[fd].write.message=sel; inputs[fd].write.data=ptr; FD_SET(fd,&handles->hnd[1]); } if(mode&INPUT_EXCEPT){ inputs[fd].excpt.target=tgt; inputs[fd].excpt.message=sel; inputs[fd].excpt.data=ptr; FD_SET(fd,&handles->hnd[2]); } if(fd>maxhandle) maxhandle=fd; #endif return true; } // Remove input FXbool FXApp::removeInput(FXInputHandle fd,FXuint mode){ if(mode==INPUT_NONE) return false; #if defined(WIN32) FXint in; if(fd==INVALID_HANDLE_VALUE || fd==nullptr) return false; for(in=0; in<=maxhandle; in++){ // See if existing handle if(handles->hnd[in]==fd) goto r; } return false; // Handle didn't exist, so nothing to remove r:if(mode&INPUT_READ){ inputs[in].read.target=nullptr; inputs[in].read.message=0; inputs[in].read.data=nullptr; } if(mode&INPUT_WRITE){ inputs[in].write.target=nullptr; inputs[in].write.message=0; inputs[in].write.data=nullptr; } if(mode&INPUT_EXCEPT){ inputs[in].excpt.target=nullptr; inputs[in].excpt.message=0; inputs[in].excpt.data=nullptr; } if(!inputs[in].read.target && !inputs[in].write.target && !inputs[in].excpt.target){ // Removed them all handles->hnd[in]=handles->hnd[maxhandle]; // Compact handle table inputs[in]=inputs[maxhandle]; maxhandle--; } #else if(fd<0 || fd>maxhandle) return false; if(mode&INPUT_READ){ inputs[fd].read.target=nullptr; inputs[fd].read.message=0; inputs[fd].read.data=nullptr; FD_CLR(fd,&handles->hnd[0]); } if(mode&INPUT_WRITE){ inputs[fd].write.target=nullptr; inputs[fd].write.message=0; inputs[fd].write.data=nullptr; FD_CLR(fd,&handles->hnd[1]); } if(mode&INPUT_EXCEPT){ inputs[fd].excpt.target=nullptr; inputs[fd].excpt.message=0; inputs[fd].excpt.data=nullptr; FD_CLR(fd,&handles->hnd[2]); } if(maxhandle==fd){ while(maxhandle>=0 && !FD_ISSET(maxhandle,&handles->hnd[0]) && !FD_ISSET(maxhandle,&handles->hnd[1]) && !FD_ISSET(maxhandle,&handles->hnd[2])){ --maxhandle; } } #endif return true; } /*******************************************************************************/ // Generate SEL_LEAVE void FXApp::leaveWindow(FXWindow *window,FXWindow *ancestor){ if(window && window->getParent() && window!=ancestor){ event.type=SEL_LEAVE; window->translateCoordinatesFrom(event.win_x,event.win_y,root,event.root_x,event.root_y); if(window->handle(this,FXSEL(SEL_LEAVE,0),&event)) refresh(); cursorWindow=window->getParent(); leaveWindow(window->getParent(),ancestor); } } // Generate SEL_ENTER void FXApp::enterWindow(FXWindow *window,FXWindow *ancestor){ if(window && window->getParent() && window!=ancestor){ enterWindow(window->getParent(),ancestor); event.type=SEL_ENTER; window->translateCoordinatesFrom(event.win_x,event.win_y,root,event.root_x,event.root_y); cursorWindow=window; if(window->handle(this,FXSEL(SEL_ENTER,0),&event)) refresh(); } } /*******************************************************************************/ #if !defined(WIN32) // Smart rectangle compositing algorithm void FXApp::addRepaint(FXID win,FXint x,FXint y,FXint w,FXint h,FXbool synth){ FXint px,py,pw,ph,newarea,area; FXRepaint *r,**pr; area=w*h; w+=x; h+=y; do{ // Find overlap with outstanding rectangles for(r=repaints,pr=&repaints; r; pr=&r->next,r=r->next){ if(r->window==win){ // Tentatively conglomerate rectangles px=FXMIN(x,r->rect.x); py=FXMIN(y,r->rect.y); pw=FXMAX(w,r->rect.w); ph=FXMAX(h,r->rect.h); newarea=(pw-px)*(ph-py); // New area bigger than sum; forget about it if(newarea > area+r->area) continue; // Take old paintrect out of the list *pr=r->next; r->next=repaintrecs; repaintrecs=r; // New rectangle synth|=r->synth; // Synthethic is preserved! area=newarea; x=px; y=py; w=pw; h=ph; break; } } } while(r); // Get rectangle, recycled if possible if(repaintrecs){ r=repaintrecs; repaintrecs=r->next; } else{ r=new FXRepaint; } // Fill it r->window=win; r->rect.x=x; r->rect.y=y; r->rect.w=w; r->rect.h=h; r->area=area; r->synth=synth; r->next=nullptr; *pr=r; } // Remove repaints by dispatching them void FXApp::removeRepaints(FXID win,FXint x,FXint y,FXint w,FXint h){ FXRepaint *r,**rr; XEvent ev; w+=x; h+=y; // Flush the buffer and wait till the X server catches up; // resulting events, if any, are buffered in the client. XSync((Display*)display,false); // Fish out the expose events and compound them while(XCheckMaskEvent((Display*)display,ExposureMask,&ev)){ if(ev.xany.type==NoExpose) continue; addRepaint(ev.xexpose.window,ev.xexpose.x,ev.xexpose.y,ev.xexpose.width,ev.xexpose.height,false); } // Then process events pertaining to window win and overlapping // with the given rectangle; other events are left in the queue. rr=&repaints; while((r=*rr)!=nullptr){ if(!win || (win==r->window && xrect.w && yrect.h && r->rect.xrect.ynext; ev.xany.type=Expose; ev.xexpose.window=r->window; ev.xexpose.x=r->rect.x; ev.xexpose.y=r->rect.y; ev.xexpose.width=r->rect.w-r->rect.x; ev.xexpose.height=r->rect.h-r->rect.y; r->next=repaintrecs; repaintrecs=r; dispatchEvent(ev); continue; } rr=&r->next; } // Flush the buffer again XFlush((Display*)display); } // Scroll repaint rectangles; some slight trickyness here:- the // rectangles don't just move, they stretch in the scroll direction // This means the original dirty area will remain part of the area to // be painted. void FXApp::scrollRepaints(FXID win,FXint dx,FXint dy){ FXRepaint *r; for(r=repaints; r; r=r->next){ if(r->window==win){ if(dx>0) r->rect.w+=dx; else r->rect.x+=dx; if(dy>0) r->rect.h+=dy; else r->rect.y+=dy; } } } #endif /*******************************************************************************/ #ifndef WIN32 // Get an event FXbool FXApp::getNextEvent(FXRawEvent& ev,FXTime blocking){ XEvent e; // Assume non-event a:ev.xany.type=0; // If a timer is due, handle it if(timers && timers->due<=FXThread::time()){ FXTimer* t=timers; timers=t->next; t->next=timerrecs; timerrecs=t; if(t->target && t->target->tryHandle(this,FXSEL(SEL_TIMEOUT,t->message),t->data)) refresh(); return false; } // Check non-immediate signals that may have fired if(signalreceived){ FXint sig=signalreceived; FXint nxt=MAXSIGNALS; signals[sig].notified=false; while(--nxt && !signals[nxt].notified){} signalreceived=nxt; if(signals[sig].target && signals[sig].target->tryHandle(this,FXSEL(SEL_SIGNAL,signals[sig].message),(void*)(FXival)sig)) refresh(); return false; } // Are there no events already queued up? if(!initialized || !XEventsQueued((Display*)display,QueuedAfterFlush)){ #if defined(__USE_XOPEN2K) struct timespec delta; #else struct timeval delta; #endif fd_set readfds; fd_set writefds; fd_set exceptfds; int maxfds; int nfds=0; // Prepare fd's to check maxfds=maxhandle; readfds=handles->hnd[0]; writefds=handles->hnd[1]; exceptfds=handles->hnd[2]; // Add connection to display if its open if(initialized){ FD_SET(ConnectionNumber((Display*)display),&readfds); if(ConnectionNumber((Display*)display)>maxfds) maxfds=ConnectionNumber((Display*)display); } // Do a quick poll for any ready events or inputs #if defined(__USE_XOPEN2K) delta.tv_nsec=0; delta.tv_sec=0; nfds=pselect(maxfds+1,&readfds,&writefds,&exceptfds,&delta,nullptr); #else delta.tv_usec=0; delta.tv_sec=0; nfds=select(maxfds+1,&readfds,&writefds,&exceptfds,&delta); #endif // Nothing to do, so perform idle processing if(nfds==0){ // Release the expose events if(repaints){ FXRepaint *r=repaints; ev.xany.type=Expose; ev.xexpose.window=r->window; ev.xexpose.send_event=r->synth; ev.xexpose.x=r->rect.x; ev.xexpose.y=r->rect.y; ev.xexpose.width=r->rect.w-r->rect.x; ev.xexpose.height=r->rect.h-r->rect.y; repaints=r->next; r->next=repaintrecs; repaintrecs=r; return true; } // Do our chores :-) if(chores){ FXChore *c=chores; chores=c->next; c->next=chorerecs; chorerecs=c; if(c->target && c->target->tryHandle(this,FXSEL(SEL_CHORE,c->message),c->data)) refresh(); } // GUI updating:- walk the whole widget tree, stop after updating refresherstop if(refresher){ if(refresher->getFirst()){ refresher=refresher->getFirst(); } else{ while(refresher->getParent()){ if(refresher->getNext()){ refresher=refresher->getNext(); break; } refresher=refresher->getParent(); } } refresher->handle(this,FXSEL(SEL_UPDATE,0),nullptr); if(refresher!=refresherstop) return false; refresher=refresherstop=nullptr; } // There are more chores to do if(chores) return false; // We're not blocking if(blocking<=0) return false; // Now, block till timeout, i/o, or event maxfds=maxhandle; readfds=handles->hnd[0]; writefds=handles->hnd[1]; exceptfds=handles->hnd[2]; // Add connection to display if its open if(initialized){ FD_SET(ConnectionNumber((Display*)display),&readfds); if(ConnectionNumber((Display*)display)>maxfds) maxfds=ConnectionNumber((Display*)display); } // If there are timers, we block only for a little while. if(timers || blockingdue-FXThread::time())tryHandle(this,FXSEL(SEL_IO_READ,in.read.message),in.read.data)) refresh(); } if(FD_ISSET(fff,&writefds)){ if(in.write.target && in.write.target->tryHandle(this,FXSEL(SEL_IO_WRITE,in.write.message),in.write.data)) refresh(); } if(FD_ISSET(fff,&exceptfds)){ if(in.excpt.target && in.excpt.target->tryHandle(this,FXSEL(SEL_IO_EXCEPT,in.excpt.message),in.excpt.data)) refresh(); } } } // If there is no event, we're done if(!initialized || !FD_ISSET(ConnectionNumber((Display*)display),&readfds) || !XEventsQueued((Display*)display,QueuedAfterReading)) return false; } // Get an event XNextEvent((Display*)display,&ev); #if 0 // Event was filtered by input method; get next one if(xim && XFilterEvent(&ev,None)){ goto a; } if(xim && getFocusWindow() && XFilterEvent(&ev,(Window)getFocusWindow()->id())){ // FIXME goto a; } #endif // Passing in focuswindow to XFilterEvent just didn't work on Gnome3 with either scim or ibus if(xim && getFocusWindow() && XFilterEvent(&ev,None)){ // [Patch from Roland Baudin] FIXME but also need to deal with keyboard grabs return false; } // Event was repaint event; get next one if(ev.xany.type==Expose || ev.xany.type==GraphicsExpose){ addRepaint((FXID)ev.xexpose.window,ev.xexpose.x,ev.xexpose.y,ev.xexpose.width,ev.xexpose.height,false); goto a; } // Compress motion events if(ev.xany.type==MotionNotify){ while(XPending((Display*)display)){ XPeekEvent((Display*)display,&e); if((e.xany.type!=MotionNotify) || (ev.xmotion.window!=e.xmotion.window) || (ev.xmotion.state!=e.xmotion.state)) break; XNextEvent((Display*)display,&ev); } } // Compress wheel events else if((ev.xany.type==ButtonPress) && (ev.xbutton.button==Button4 || ev.xbutton.button==Button5)){ FXint ticks=1; while(XPending((Display*)display)){ XPeekEvent((Display*)display,&e); if((e.xany.type!=ButtonPress && e.xany.type!=ButtonRelease) || (ev.xany.window!=e.xany.window) || (ev.xbutton.button!=e.xbutton.button)) break; ticks+=(e.xany.type==ButtonPress); XNextEvent((Display*)display,&ev); } ev.xbutton.subwindow=(Window)ticks; // Stick it here for later } // Compress configure events else if(ev.xany.type==ConfigureNotify){ while(XCheckTypedWindowEvent((Display*)display,ev.xconfigure.window,ConfigureNotify,&e)){ ev.xconfigure.width=e.xconfigure.width; ev.xconfigure.height=e.xconfigure.height; if(e.xconfigure.send_event){ ev.xconfigure.x=e.xconfigure.x; ev.xconfigure.y=e.xconfigure.y; } } } // Regular event return true; } /*******************************************************************************/ // Peek for event FXbool FXApp::peekEvent(){ if(initialized){ #if defined(__USE_XOPEN2K) struct timespec delta; #else struct timeval delta; #endif fd_set readfds; fd_set writefds; fd_set exceptfds; int maxfds; int nfds; // Outstanding repaints if(repaints) return true; // Still need GUI update if(refresher) return true; // Outstanding chores if(chores) return true; // Timers are due? if(timers){ if(timers->due <= FXThread::time()) return true; } // Events queued up in client already (Shouldn't this not be QueuedAlready?) if(XEventsQueued((Display*)display,QueuedAfterFlush)) return true; // Prepare fd's to watch FD_ZERO(&readfds); FD_ZERO(&writefds); FD_ZERO(&exceptfds); FD_SET(ConnectionNumber((Display*)display),&readfds); // Add other inputs... maxfds=ConnectionNumber((Display*)display); // Do a quick poll for any ready events #if defined(__USE_XOPEN2K) delta.tv_nsec=0; delta.tv_sec=0; nfds=pselect(maxfds+1,&readfds,&writefds,&exceptfds,&delta,nullptr); #else delta.tv_usec=0; delta.tv_sec=0; nfds=select(maxfds+1,&readfds,&writefds,&exceptfds,&delta); #endif // Interrupt if(nfds<0 && errno!=EAGAIN && errno!=EINTR){ fxerror("Application terminated: interrupt or lost connection errno=%d\n",errno); } // I/O activity if((nfds>0) && FD_ISSET(ConnectionNumber((Display*)display),&readfds)){ if(XEventsQueued((Display*)display,QueuedAfterReading)) return true; } } return false; } /*******************************************************************************/ // Translate key code to utf8 text FXString translateKeyEvent(FXRawEvent& event){ char buffer[40]; KeySym sym; FXwchar w; XLookupString(&event.xkey,buffer,sizeof(buffer),&sym,nullptr); w=fxkeysym2ucs(sym); return FXString(&w,1); } // Get keysym; interprets the modifiers! static FXuint keysym(FXRawEvent& event){ KeySym sym=KEY_VoidSymbol; char buffer[40]; XLookupString(&event.xkey,buffer,sizeof(buffer),&sym,nullptr); return sym; } /* // Translate key code to utf8 text FXString translateKeyEvent(XEvent& event,XIC xic){ char buffer[40]; KeySym sym; Status s; int n; FXString result; FXwchar w=0; #ifndef NO_XIM if(xic){ n=XmbLookupString((XIC)xic,&event.xkey,buffer,sizeof(buffer),&sym,&s); if(s!=XLookupChars && s!=XLookupBoth) n=0; // FIXME decode buffer based on XLocaleOfIM(XIMOfIC((XIC)xic)) buffer[n]=0; FXTRACE((100,"XLocaleOfIM=%s\n",XLocaleOfIM(XIMOfIC((XIC)xic)))); result.assign(buffer,n); } else{ #endif n=XLookupString(&event.xkey,buffer,sizeof(buffer),&sym,nullptr); w=fxkeysym2ucs(sym); result.assign(&w,1); #ifndef NO_XIM } #endif return result; } */ /* KeyCode keycode=XKeysymToKeycode((Display*)display,keysym); char keys[32]; if(keycode==NoSymbol) return false; XQueryKeymap((Display*)display,keys); return (keys[keycode>>3]>>(keycode&7))&1; */ #if 0 The XIHierarchyEvent has a couple of interesting fields: typedef struct { int type; /* GenericEvent */ unsigned long serial; /* # of last request processed by server */ Bool send_event; /* true if this came from a SendEvent request */ Display *display; /* Display the event was read from */ int extension; /* XI extension offset */ int evtype; /* XI_DeviceHierarchyChangedNotify */ Time time; int flags; int num_devices; XIHierarchyInfo *info; } XIHierarchyEvent; The first couple of fields are standard. The flags field lists all changes that occurred, a combination of: XIMasterAdded A new master device has been created. XIMasterRemoved A master device has been deleted. XISlaveAdded A new slave device has been added (e.g. plugged in). XISlaveRemoved A slave device has been removed (e.g. unplugged). XISlaveAttached A slave device has been attached to a master device. XISlaveDetached A slave device has been detached (set floating). XIDeviceEnabled A device has been enabled (i.e. it may send events now)). XIDeviceDisabled A device has been disabled (i.e. it will not send events until enabled again). The info field contains the details for all devices currently present and those removed with this change. Each info->flags states what happened to this particular device. For example, one could search for the slave device that just got removed by searching for the XISlaveRemoved flag. if (!(ev.flags & XISlaveRemoved)) { printf("No slave device removed.\n"); return; } for (i = 0; i < ev.num_devices; i++) { if (info[i].flags & XISlaveRemoved) { printf("Device %d has been removed.\n", info[i].deviceid); } } With this information, it is possible to keep track of the device hierarchy at all times and adjust the user interface as necessary. #endif #if 0 if(ev.type==xsbBallMotion){ // FIXME consecutive xsbBallMotion events should be compressed! static int axis_data[6]; static Window prevwindow=0; Window pw; XDeviceMotionEvent& sbe=(XDeviceMotionEvent&)ev; event.type=SEL_SPACEBALLMOTION; event.time=sbe.time; //event.win_x=sbe.x; //event.win_y=sbe.y; //event.root_x=sbe.x_root; //event.root_y=sbe.y_root; event.values[0]=sbe.axis_data[0]-axis_data[0]; event.values[1]=sbe.axis_data[1]-axis_data[1]; event.values[2]=sbe.axis_data[2]-axis_data[2]; event.values[3]=sbe.axis_data[3]-axis_data[3]; event.values[4]=sbe.axis_data[4]-axis_data[4]; event.values[5]=sbe.axis_data[5]-axis_data[5]; // FXTRACE((1,"values: %+3d %+3d %+3d %+3d %+3d %+3d\n",sbe.axis_data[0],sbe.axis_data[1],sbe.axis_data[2],sbe.axis_data[3],sbe.axis_data[4],sbe.axis_data[5])); axis_data[0]=sbe.axis_data[0]; axis_data[1]=sbe.axis_data[1]; axis_data[2]=sbe.axis_data[2]; axis_data[3]=sbe.axis_data[3]; axis_data[4]=sbe.axis_data[4]; axis_data[5]=sbe.axis_data[5]; pw=prevwindow; prevwindow=ev.xmotion.window; if(pw!=ev.xmotion.window) return false; // if((FXABS(event.values[0])>400) || (FXABS(event.values[1])>400) || (FXABS(event.values[2])>400) || (FXABS(event.values[3])>400) || (FXABS(event.values[4])>400) || (FXABS(event.values[5])>400)) return false; //FXTRACE((1,"spaceballmotion\n")); //FXTRACE((1,"state : %08x axes_count=%d first_axis=%d\n",sbe.device_state,sbe.axes_count,sbe.first_axis)); // FXTRACE((1,"values: %+3d %+3d %+3d %+3d %+3d %+3d\n",sbe.axis_data[0],sbe.axis_data[1],sbe.axis_data[2],sbe.axis_data[3],sbe.axis_data[4],sbe.axis_data[5])); // FIXME // Dispatch to grab window if(mouseGrabWindow){ window->translateCoordinatesTo(event.win_x,event.win_y,mouseGrabWindow,event.win_x,event.win_y); if(mouseGrabWindow->handle(this,FXSEL(event.type,0),&event)) refresh(); } // Dispatch if inside model window // FIXME doesSaveUnder test should go away else if(!invocation || invocation->modality==MODAL_FOR_NONE || (invocation->window && invocation->window->isOwnerOf(window)) || window->getShell()->doesSaveUnder()){ if(window->handle(this,FXSEL(event.type,0),&event)) refresh(); } } else if(ev.type==xsbButtonPress){ event.type=SEL_SPACEBALLBUTTONPRESS; event.time=ev.xmotion.time; event.win_x=ev.xmotion.x; event.win_y=ev.xmotion.y; event.root_x=ev.xmotion.x_root; event.root_y=ev.xmotion.y_root; // Dispatch to grab window if(mouseGrabWindow){ window->translateCoordinatesTo(event.win_x,event.win_y,mouseGrabWindow,event.win_x,event.win_y); if(mouseGrabWindow->handle(this,FXSEL(event.type,0),&event)) refresh(); } // Dispatch if inside model window // FIXME doesSaveUnder test should go away else if(!invocation || invocation->modality==MODAL_FOR_NONE || (invocation->window && invocation->window->isOwnerOf(window)) || window->getShell()->doesSaveUnder()){ if(window->handle(this,FXSEL(event.type,0),&event)) refresh(); } } else if(ev.type==xsbButtonRelease){ event.type=SEL_SPACEBALLBUTTONRELEASE; event.time=ev.xmotion.time; event.win_x=ev.xmotion.x; event.win_y=ev.xmotion.y; event.root_x=ev.xmotion.x_root; event.root_y=ev.xmotion.y_root; // Dispatch to grab window if(mouseGrabWindow){ window->translateCoordinatesTo(event.win_x,event.win_y,mouseGrabWindow,event.win_x,event.win_y); if(mouseGrabWindow->handle(this,FXSEL(event.type,0),&event)) refresh(); } // Dispatch if inside model window // FIXME doesSaveUnder test should go away else if(!invocation || invocation->modality==MODAL_FOR_NONE || (invocation->window && invocation->window->isOwnerOf(window)) || window->getShell()->doesSaveUnder()){ if(window->handle(this,FXSEL(event.type,0),&event)) refresh(); } } // Enable extra events when input extension supported #if defined(HAVE_XINPUT2_H) /* if(1){ unsigned char maskbits[4]={0,0,0,0}; XIEventMask eventmask={11,sizeof(maskbits),maskbits}; XISetMask(eventmask.mask,XI_Enter); XISetMask(eventmask.mask,XI_Leave); XISetMask(eventmask.mask,XI_FocusIn); XISetMask(eventmask.mask,XI_FocusOut); XISetMask(eventmask.mask,XI_PropertyEvent); if(isEnabled()){ // XISetMask(eventmask.mask,XI_KeyPress); // XISetMask(eventmask.mask,XI_KeyRelease); // XISetMask(eventmask.mask,XI_ButtonPress); // XISetMask(eventmask.mask,XI_ButtonRelease); // XISetMask(eventmask.mask,XI_Motion); } XISelectEvents((Display*)getApp()->getDisplay(),xid,&eventmask,1); //XIGrabModifiers modifiers[]={{0,0},{0,0x10},{0,0x1},{0,0x11}}; //int nmods=sizeof(modifiers)/sizeof(modifiers[0]); //XIGrabButton((Display*)getApp()->getDisplay(),eventmask.deviceid,1,xid,None,GrabModeAsync,GrabModeAsync,False,&eventmask,nmods,modifiers); //XIUngrabButton((Display*)getApp()->getDisplay(),eventmask.deviceid,1,xid,nmods-2,&modifiers[2]); //XIGrabKeycode((Display*)getApp()->getDisplay(),eventmask.deviceid, 24, xid, GrabModeAsync, GrabModeAsync,False, &eventmask, nmods, modifiers); //XIUngrabKeycode((Display*)getApp()->getDisplay(),eventmask.deviceid, 24, xid, nmods - 2, &modifiers[2]); } */ #endif #endif #if defined(HAVE_XINPUT2_H) static void print_hierarchychangedevent(XIHierarchyEvent *event){ const char *use; int i; FXTRACE((100," Changes happened: %s %s %s %s %s %s %s %s\n",(event->flags & XIMasterAdded) ? "[new master]" : "",(event->flags & XIMasterRemoved) ? "[master removed]" : "",(event->flags & XISlaveAdded) ? "[new slave]" : "",(event->flags & XISlaveRemoved) ? "[slave removed]" : "",(event->flags & XISlaveAttached) ? "[slave attached]" : "",(event->flags & XISlaveDetached) ? "[slave detached]" : "",(event->flags & XIDeviceEnabled) ? "[device enabled]" : "",(event->flags & XIDeviceDisabled) ? "[device disabled]" : "")); for(i=0; inum_info; i++){ switch(event->info[i].use){ case XIMasterPointer: use = "master pointer"; break; case XIMasterKeyboard: use = "master keyboard"; break; case XISlavePointer: use = "slave pointer"; break; case XISlaveKeyboard: use = "slave keyboard"; break; case XIFloatingSlave: use = "floating slave"; break; default: use=""; break; } FXTRACE((100," device %d [%s (%d)] is %s\n",event->info[i].deviceid,use,event->info[i].attachment,(event->info[i].enabled) ? "enabled" : "disabled")); if(event->info[i].flags){ FXTRACE((100," changes: %s %s %s %s %s %s %s %s\n",(event->info[i].flags & XIMasterAdded) ? "[new master]" : "",(event->info[i].flags & XIMasterRemoved) ? "[master removed]" : "",(event->info[i].flags & XISlaveAdded) ? "[new slave]" : "",(event->info[i].flags & XISlaveRemoved) ? "[slave removed]" : "",(event->info[i].flags & XISlaveAttached) ? "[slave attached]" : "",(event->info[i].flags & XISlaveDetached) ? "[slave detached]" : "",(event->info[i].flags & XIDeviceEnabled) ? "[device enabled]" : "",(event->info[i].flags & XIDeviceDisabled) ? "[device disabled]" : "")); } } } static void print_deviceevent(XIDeviceEvent* event){ double *val; int i; FXTRACE((100," device: %d (%d)\n", event->deviceid, event->sourceid)); FXTRACE((100," detail: %d\n", event->detail)); FXTRACE((100," flags: %s\n", (event->flags & XIKeyRepeat) ? "repeat" : "")); FXTRACE((100," root: %.2f/%.2f\n", event->root_x, event->root_y)); FXTRACE((100," event: %.2f/%.2f\n", event->event_x, event->event_y)); FXTRACE((100," buttons:")); for(i=0; ibuttons.mask_len*8; i++){ if(XIMaskIsSet(event->buttons.mask,i)) FXTRACE((100," %d", i)); } FXTRACE((100,"\n")); FXTRACE((100," modifiers: locked %#x latched %#x base %#x effective: %#x\n",event->mods.locked, event->mods.latched,event->mods.base, event->mods.effective)); FXTRACE((100," group: locked %#x latched %#x base %#x effective: %#x\n",event->group.locked, event->group.latched,event->group.base, event->group.effective)); FXTRACE((100," valuators:")); val = event->valuators.values; for(i=0; ivaluators.mask_len*8; i++){ if(XIMaskIsSet(event->valuators.mask,i)) FXTRACE((100," %.2f", *val++)); } FXTRACE((100,"\n")); FXTRACE((100," windows: root 0x%lx event 0x%lx child 0x%ld\n",event->root, event->event, event->child)); } static void print_rawevent(XIRawEvent *event){ int i; double *val, *raw_val; FXTRACE((100," device: %d\n", event->deviceid)); FXTRACE((100," detail: %d\n", event->detail)); FXTRACE((100," valuators:\n")); val = event->valuators.values; raw_val = event->raw_values; for (i = 0; i < event->valuators.mask_len * 8; i++){ if (XIMaskIsSet(event->valuators.mask, i)) FXTRACE((100," %2d: %.2f (%.2f)\n", i, *val++, *raw_val++)); } FXTRACE((100,"\n")); } #endif // Dispatch event to widget FXbool FXApp::dispatchEvent(FXRawEvent& ev){ const FXTime milliseconds=1000000; FXWindow *window,*ancestor,*focuswin; Atom answer; FXuint state; XEvent se; Window tmp; // Get window window=findWindowWithId(ev.xany.window); // Workaround XInput2 #ifdef HAVE_XINPUT2_H if(ev.xany.type==GenericEvent) window=getRootWindow(); #endif // Was one of our windows, so dispatch if(window){ switch(ev.xany.type){ // Repaint event case GraphicsExpose: case Expose: event.type=SEL_PAINT; event.rect.x=ev.xexpose.x; event.rect.y=ev.xexpose.y; event.rect.w=ev.xexpose.width; event.rect.h=ev.xexpose.height; event.synthetic=ev.xexpose.send_event; window->handle(this,FXSEL(SEL_PAINT,0),&event); return true; case NoExpose: return true; // Keymap Notify case KeymapNotify: //memcpy(keystate,ev.xkeymap.key_vector,32); return true; // Keyboard case KeyPress: // [Patch from Roland Baudin] FIXME should this go? #if 0 #ifndef NO_XIM focuswin=getFocusWindow(); if((ev.xkey.keycode!=0) && focuswin && focuswin->getComposeContext()){ Window w; XGetICValues((XIC)focuswin->getComposeContext()->id(),XNFocusWindow,&w,nullptr); if((focuswin->id()!=w) && XFilterEvent(&ev,(Window)focuswin->id())){ return true; } } #endif #endif case KeyRelease: event.type=SEL_KEYPRESS+ev.xkey.type-KeyPress; event.time=ev.xkey.time; event.win_x=ev.xkey.x; event.win_y=ev.xkey.y; event.root_x=ev.xkey.x_root; event.root_y=ev.xkey.y_root; // Translate to keysym; must interpret modifiers! event.code=keysym(ev); // XModifierKeymap *XGetModifierMapping((Display*)display); // Translate to string on KeyPress if(ev.xkey.type==KeyPress){ // FXTRACE((100,"getFocusWindow()=%s\n",getFocusWindow()?getFocusWindow()->getClassName():"nil")); focuswin=getFocusWindow(); if(focuswin && focuswin->getComposeContext()) event.text=focuswin->getComposeContext()->translateEvent(ev); else event.text=translateKeyEvent(ev); } // Clear string on KeyRelease else{ event.text.clear(); } // Mouse buttons and modifiers but no wheel buttons event.state=ev.xkey.state&~(Button4Mask|Button5Mask); // Fix modifier state if(ev.xkey.type==KeyPress){ if(event.code==KEY_Shift_L) event.state|=SHIFTMASK; else if(event.code==KEY_Shift_R) event.state|=SHIFTMASK; else if(event.code==KEY_Control_L) event.state|=CONTROLMASK; else if(event.code==KEY_Control_R) event.state|=CONTROLMASK; else if(event.code==KEY_F13) event.state|=METAMASK; // Key between Ctrl and Alt (on most keyboards) else if(event.code==KEY_Alt_L) event.state|=ALTMASK; else if(event.code==KEY_Alt_R) event.state|=ALTMASK; // FIXME do we need ALTGR flag instead/in addition? else if(event.code==KEY_Num_Lock) event.state|=NUMLOCKMASK; else if(event.code==KEY_Caps_Lock) event.state|=CAPSLOCKMASK; else if(event.code==KEY_Scroll_Lock) event.state|=SCROLLLOCKMASK; else if(event.code==KEY_Super_L) event.state|=METAMASK; else if(event.code==KEY_Super_R) event.state|=METAMASK; else{ stickyMods=event.state&(SHIFTMASK|CONTROLMASK|METAMASK|ALTMASK); } } else{ if(event.code==KEY_Shift_L) event.state&=~SHIFTMASK; else if(event.code==KEY_Shift_R) event.state&=~SHIFTMASK; else if(event.code==KEY_Control_L) event.state&=~CONTROLMASK; else if(event.code==KEY_Control_R) event.state&=~CONTROLMASK; else if(event.code==KEY_F13) event.state&=~METAMASK; // Key between Ctrl and Alt (on most keyboards) else if(event.code==KEY_Alt_L) event.state&=~ALTMASK; else if(event.code==KEY_Alt_R) event.state&=~ALTMASK; // FIXME do we need ALTGR flag instead/in addition? else if(event.code==KEY_Num_Lock) event.state&=~NUMLOCKMASK; else if(event.code==KEY_Caps_Lock) event.state&=~CAPSLOCKMASK; else if(event.code==KEY_Scroll_Lock) event.state&=~SCROLLLOCKMASK; else if(event.code==KEY_Super_L) event.state&=~METAMASK; else if(event.code==KEY_Super_R) event.state&=~METAMASK; else{ event.state|=stickyMods; stickyMods=0; } } FXTRACE((100,"%s code=%04x state=%04x stickyMods=%04x text=\"%s\"\n",(event.type==SEL_KEYPRESS)?"SEL_KEYPRESS":"SEL_KEYRELEASE",event.code,event.state,stickyMods,event.text.text())); // Keyboard grabbed by specific window if(keyboardGrabWindow){ if(keyboardGrabWindow->handle(this,FXSEL(event.type,0),&event)) refresh(); return true; } // // Try popup window // if(popupWindow){ // if(popupWindow->handle(this,FXSEL(event.type,0),&event)) refresh(); // return true; // } // Remember window for later if(ev.xkey.type==KeyPress) keyWindow=activeWindow; // Dispatch to key window if(keyWindow){ // FIXME doesSaveUnder test should go away // Dispatch if not in a modal loop or in a modal loop for a window containing the focus window if(!invocation || invocation->modality==MODAL_FOR_NONE || (invocation->window && invocation->window->isOwnerOf(keyWindow)) || keyWindow->getShell()->doesSaveUnder()){ if(keyWindow->handle(this,FXSEL(event.type,0),&event)) refresh(); if(inputstyle[1]!='o'){ // not root mode focuswin=getFocusWindow(); if(focuswin && focuswin->getComposeContext()){ focuswin->handle(this,FXSEL(SEL_IME_START,0),nullptr); } } return true; } // Beep if outside modal if(ev.xany.type==KeyPress) beep(); } return true; // Motion case MotionNotify: event.type=SEL_MOTION; event.time=ev.xmotion.time; event.win_x=ev.xmotion.x; event.win_y=ev.xmotion.y; event.root_x=ev.xmotion.x_root; event.root_y=ev.xmotion.y_root; event.code=0; // Mouse buttons and modifiers but no wheel buttons event.state=(ev.xmotion.state&~(Button4Mask|Button5Mask)) | stickyMods; // Moved more that delta if((FXABS(event.root_x-event.rootclick_x)>=dragDelta) || (FXABS(event.root_y-event.rootclick_y)>=dragDelta)) event.moved=1; // Dispatch to grab window if(mouseGrabWindow){ window->translateCoordinatesTo(event.win_x,event.win_y,mouseGrabWindow,event.win_x,event.win_y); if(mouseGrabWindow->handle(this,FXSEL(SEL_MOTION,0),&event)) refresh(); } // FIXME doesSaveUnder test should go away // Dispatch if inside model window else if(!invocation || invocation->modality==MODAL_FOR_NONE || (invocation->window && invocation->window->isOwnerOf(window)) || window->getShell()->doesSaveUnder()){ if(window->handle(this,FXSEL(SEL_MOTION,0),&event)) refresh(); } // Remember last mouse event.last_x=event.win_x; event.last_y=event.win_y; return true; // Button case ButtonPress: case ButtonRelease: event.time=ev.xbutton.time; event.win_x=ev.xbutton.x; event.win_y=ev.xbutton.y; event.root_x=ev.xbutton.x_root; event.root_y=ev.xbutton.y_root; // Mouse buttons and modifiers but no wheel buttons event.state=(ev.xmotion.state&~(Button4Mask|Button5Mask)) | stickyMods; // Mouse Wheel if(ev.xbutton.button==Button4 || ev.xbutton.button==Button5){ event.type=SEL_MOUSEWHEEL; event.code=((ev.xbutton.button==Button4)?120:-120)*ev.xbutton.subwindow; // Dispatch to grab window if(mouseGrabWindow){ window->translateCoordinatesTo(event.win_x,event.win_y,mouseGrabWindow,event.win_x,event.win_y); if(mouseGrabWindow->handle(this,FXSEL(SEL_MOUSEWHEEL,0),&event)) refresh(); return true; } // Dispatch to window under cursor // FIXME doesSaveUnder test should go away while(window && (!invocation || invocation->modality==MODAL_FOR_NONE || (invocation->window && invocation->window->isOwnerOf(window)) || window->getShell()->doesSaveUnder())){ if(window->handle(this,FXSEL(SEL_MOUSEWHEEL,0),&event)){ refresh(); break; } window=window->getParent(); } return true; } // Mouse Button event.code=ev.xbutton.button; if(ev.xbutton.type==ButtonPress){ // Mouse button press if(ev.xbutton.button==Button1){ event.type=SEL_LEFTBUTTONPRESS; event.state|=LEFTBUTTONMASK; } if(ev.xbutton.button==Button2){ event.type=SEL_MIDDLEBUTTONPRESS; event.state|=MIDDLEBUTTONMASK; } if(ev.xbutton.button==Button3){ event.type=SEL_RIGHTBUTTONPRESS; event.state|=RIGHTBUTTONMASK; } if(!event.moved && (event.code==event.click_button) && (milliseconds*(event.time-event.click_time)translateCoordinatesTo(event.win_x,event.win_y,mouseGrabWindow,event.win_x,event.win_y); if(mouseGrabWindow->handle(this,FXSEL(event.type,0),&event)) refresh(); } // Dispatch if inside model window // FIXME doesSaveUnder test should go away else if(!invocation || invocation->modality==MODAL_FOR_NONE || (invocation->window && invocation->window->isOwnerOf(window)) || window->getShell()->doesSaveUnder()){ if(window->handle(this,FXSEL(event.type,0),&event)) refresh(); } // Beep if outside modal window else{ if(ev.xany.type==ButtonPress) beep(); } // Remember last mouse event.last_x=event.win_x; event.last_y=event.win_y; return true; // Crossing case EnterNotify: event.time=ev.xcrossing.time; if(cursorWindow!=window){ if(ev.xcrossing.mode==NotifyGrab || ev.xcrossing.mode==NotifyUngrab || (ev.xcrossing.mode==NotifyNormal && ev.xcrossing.detail!=NotifyInferior)){ ancestor=FXWindow::commonAncestor(window,cursorWindow); event.root_x=ev.xcrossing.x_root; event.root_y=ev.xcrossing.y_root; event.code=ev.xcrossing.mode; leaveWindow(cursorWindow,ancestor); enterWindow(window,ancestor); } } return true; // Crossing case LeaveNotify: event.time=ev.xcrossing.time; if(cursorWindow==window){ if(ev.xcrossing.mode==NotifyGrab || ev.xcrossing.mode==NotifyUngrab || (ev.xcrossing.mode==NotifyNormal && ev.xcrossing.detail!=NotifyInferior)){ event.root_x=ev.xcrossing.x_root; event.root_y=ev.xcrossing.y_root; event.code=ev.xcrossing.mode; FXASSERT(cursorWindow==window); leaveWindow(window,window->getParent()); } } return true; // Focus change on shell window case FocusIn: case FocusOut: window=window->getShell(); if(ev.xfocus.type==FocusOut && activeWindow==window){ event.type=SEL_FOCUSOUT; if(window->handle(this,FXSEL(SEL_FOCUSOUT,0),&event)) refresh(); activeWindow=nullptr; if(inputstyle[1]!='o'){ // not root mode focuswin=getFocusWindow(); if(focuswin && focuswin->getComposeContext()){ focuswin->handle(this,FXSEL(SEL_IME_END,0),nullptr); } } } if(ev.xfocus.type==FocusIn && activeWindow!=window){ event.type=SEL_FOCUSIN; if(window->handle(this,FXSEL(SEL_FOCUSIN,0),&event)) refresh(); activeWindow=window; if(inputstyle[1]!='o'){ // not root mode focuswin=getFocusWindow(); if(focuswin && focuswin->getComposeContext()){ focuswin->handle(this,FXSEL(SEL_IME_START,0),nullptr); } } } return true; // Map case MapNotify: event.type=SEL_MAP; if(window->handle(this,FXSEL(SEL_MAP,0),&event)) refresh(); return true; // Unmap case UnmapNotify: event.type=SEL_UNMAP; if(window->handle(this,FXSEL(SEL_UNMAP,0),&event)) refresh(); return true; // Create case CreateNotify: event.type=SEL_CREATE; if(window->handle(this,FXSEL(SEL_CREATE,0),&event)) refresh(); return true; // Destroy case DestroyNotify: event.type=SEL_DESTROY; if(window->handle(this,FXSEL(SEL_DESTROY,0),&event)) refresh(); return true; // Configure case ConfigureNotify: event.type=SEL_CONFIGURE; // According to the ICCCM, if its synthetic, the coordinates are relative // to root window; otherwise, they're relative to the parent; so we use // the old coordinates if its not a synthetic configure notify if(window->getShell()==window && !ev.xconfigure.send_event){ ev.xconfigure.x=window->getX(); ev.xconfigure.y=window->getY(); } event.rect.x=ev.xconfigure.x; event.rect.y=ev.xconfigure.y; event.rect.w=ev.xconfigure.width; event.rect.h=ev.xconfigure.height; event.synthetic=ev.xconfigure.send_event; if(window->handle(this,FXSEL(SEL_CONFIGURE,0),&event)) refresh(); return true; // Circulate case CirculateNotify: event.type=SEL_RAISED+(ev.xcirculate.place&1); if(window->handle(this,FXSEL(event.type,0),&event)) refresh(); return true; // Selection Clear case SelectionClear: if(ev.xselectionclear.selection==XA_PRIMARY){ // We lost the primary selection if the new selection owner is different from selectionWindow if(selectionWindow && selectionWindow->id()!=XGetSelectionOwner((Display*)display,XA_PRIMARY)){ event.type=SEL_SELECTION_LOST; event.time=ev.xselectionclear.time; if(selectionWindow->handle(this,FXSEL(SEL_SELECTION_LOST,0),&event)) refresh(); selectionWindow=nullptr; } freeElms(xselTypeList); xselNumTypes=0; } else if(ev.xselectionclear.selection==xcbSelection){ // We lost the clipboard selection if the new clipboard owner is different from clipboardWindow if(clipboardWindow && clipboardWindow->id()!=XGetSelectionOwner((Display*)display,xcbSelection)){ event.time=ev.xselectionclear.time; event.type=SEL_CLIPBOARD_LOST; if(clipboardWindow->handle(this,FXSEL(SEL_CLIPBOARD_LOST,0),&event)) refresh(); clipboardWindow=nullptr; } freeElms(xcbTypeList); xcbNumTypes=0; } return true; // Selection Request case SelectionRequest: answer=None; FXTRACE((100,"Request selection (%ld) from requestor=%ld\n",ev.xselectionrequest.selection,ev.xselectionrequest.requestor)); if(ev.xselectionrequest.selection==XA_PRIMARY){ if(selectionWindow){ if(ev.xselectionrequest.target==ddeTargets){ // Request for TYPES FXTRACE((100,"Window %ld being requested by window %ld for SELECTION TYPES; sending %d types\n",ev.xselectionrequest.owner,ev.xselectionrequest.requestor,xselNumTypes)); answer=fxsendtypes((Display*)display,ev.xselectionrequest.requestor,ev.xselectionrequest.property,xselTypeList,xselNumTypes); } else{ // Request for DATA event.type=SEL_SELECTION_REQUEST; event.time=ev.xselectionrequest.time; event.target=ev.xselectionrequest.target; ddeData=nullptr; ddeSize=0; selectionWindow->handle(this,FXSEL(SEL_SELECTION_REQUEST,0),&event); FXTRACE((100,"Window %ld being requested by window %ld for SELECTION DATA of type %ld; sending %d bytes\n",ev.xselectionrequest.owner,ev.xselectionrequest.requestor,ev.xselectionrequest.target,ddeSize)); answer=fxsenddata((Display*)display,ev.xselectionrequest.requestor,ev.xselectionrequest.property,ev.xselectionrequest.target,ddeData,ddeSize); freeElms(ddeData); ddeData=nullptr; ddeSize=0; } } } else if(ev.xselectionrequest.selection==xcbSelection){ if(clipboardWindow){ if(ev.xselectionrequest.target==ddeTargets){ // Request for TYPES FXTRACE((100,"Window %ld being requested by window %ld for CLIPBOARD TYPES; sending %d types\n",ev.xselectionrequest.owner,ev.xselectionrequest.requestor,xcbNumTypes)); answer=fxsendtypes((Display*)display,ev.xselectionrequest.requestor,ev.xselectionrequest.property,xcbTypeList,xcbNumTypes); } else{ // Request for DATA event.type=SEL_CLIPBOARD_REQUEST; event.time=ev.xselectionrequest.time; event.target=ev.xselectionrequest.target; ddeData=nullptr; ddeSize=0; clipboardWindow->handle(this,FXSEL(SEL_CLIPBOARD_REQUEST,0),&event); FXTRACE((100,"Window %ld being requested by window %ld for CLIPBOARD DATA of type %ld; sending %d bytes\n",ev.xselectionrequest.owner,ev.xselectionrequest.requestor,ev.xselectionrequest.target,ddeSize)); answer=fxsenddata((Display*)display,ev.xselectionrequest.requestor,ev.xselectionrequest.property,ev.xselectionrequest.target,ddeData,ddeSize); freeElms(ddeData); ddeData=nullptr; ddeSize=0; } } } else if(ev.xselectionrequest.selection==xdndSelection){ if(dragWindow){ if(ev.xselectionrequest.target==ddeTargets){ // Request for TYPES FXTRACE((100,"Window %ld being requested by window %ld for XDND TYPES; sending %d types\n",ev.xselectionrequest.owner,ev.xselectionrequest.requestor,xdndNumTypes)); answer=fxsendtypes((Display*)display,ev.xselectionrequest.requestor,ev.xselectionrequest.property,xdndTypeList,xdndNumTypes); } else{ // Request for DATA event.type=SEL_DND_REQUEST; event.time=ev.xselectionrequest.time; event.target=ev.xselectionrequest.target; ddeData=nullptr; ddeSize=0; dragWindow->handle(this,FXSEL(SEL_DND_REQUEST,0),&event); FXTRACE((100,"Window %ld being requested by window %ld for XDND DATA of type %ld; sending %d bytes\n",ev.xselectionrequest.owner,ev.xselectionrequest.requestor,ev.xselectionrequest.target,ddeSize)); answer=fxsenddata((Display*)display,ev.xselectionrequest.requestor,ev.xselectionrequest.property,ev.xselectionrequest.target,ddeData,ddeSize); freeElms(ddeData); ddeData=nullptr; ddeSize=0; } } } FXTRACE((100,"Sending back response to requestor=%ld\n",ev.xselectionrequest.requestor)); fxsendreply((Display*)display,ev.xselectionrequest.requestor,ev.xselectionrequest.selection,answer,ev.xselectionrequest.target,ev.xselectionrequest.time); return true; // Selection Notify case SelectionNotify: return true; // Client message case ClientMessage: // WM_PROTOCOLS if(ev.xclient.message_type==wmProtocols){ if((FXID)ev.xclient.data.l[0]==wmDeleteWindow){ // WM_DELETE_WINDOW FXTRACE((100,"WM_DELETE_WINDOW\n")); event.type=SEL_CLOSE; if(!invocation || invocation->modality==MODAL_FOR_NONE || (invocation->window && invocation->window->isOwnerOf(window))){ if(window->handle(this,FXSEL(SEL_CLOSE,0),&event)) refresh(); } else{ beep(); } } else if((FXID)ev.xclient.data.l[0]==wmSaveYourself){ // WM_SAVE_YOURSELF FXTRACE((100,"WM_SAVE_YOURSELF\n")); //XSetCommand((Display*)display,ev.xany.window,(char**)appArgv,appArgc); //XChangeProperty((Display*)display,ev.xany.window,wmCommand,XA_STRING,8,PropModeReplace,(unsigned char*)"",0); event.type=SEL_SESSION_NOTIFY; return !window->handle(this,FXSEL(SEL_SESSION_NOTIFY,0),&event); // Return 1 if OK to terminate /* case WM_ENDSESSION: // Session will now end for sure event.type=SEL_SESSION_CLOSED; if(wParam) window->handle(this,FXSEL(SEL_SESSION_CLOSED,0),&event); return 0; */ } else if((FXID)ev.xclient.data.l[0]==wmQuitApp){ // WM_QUIT_APP FXTRACE((100,"WM_QUIT_APP\n")); event.type=SEL_CLOSE; if(!invocation || invocation->modality==MODAL_FOR_NONE || (invocation->window && invocation->window->isOwnerOf(window))){ if(window->handle(this,FXSEL(SEL_CLOSE,0),&event)) refresh(); } else{ beep(); } } else if((FXID)ev.xclient.data.l[0]==wmTakeFocus){ // WM_TAKE_FOCUS if(invocation && invocation->window && invocation->window->id()) ev.xclient.window=invocation->window->id(); // Assign focus to innermost modal dialog, even when trying to focus // on another window; these other windows are dead to inputs anyway. // XSetInputFocus causes a spurious BadMatch error; we ignore this in xerrorhandler XSetInputFocus((Display*)display,ev.xclient.window,RevertToParent,ev.xclient.data.l[1]); } else if((FXID)ev.xclient.data.l[0]==wmNetPing){ // NET_WM_PING FXTRACE((100,"NET_WM_PING %ld\n",ev.xclient.data.l[1])); se.xclient.type=ClientMessage; se.xclient.display=(Display*)display; // This lets a window manager know that se.xclient.message_type=wmProtocols; // we're still alive after having received se.xclient.format=32; // a WM_DELETE_WINDOW message se.xclient.window=XDefaultRootWindow((Display*)display); se.xclient.data.l[0]=ev.xclient.data.l[0]; se.xclient.data.l[1]=ev.xclient.data.l[1]; se.xclient.data.l[2]=ev.xclient.data.l[2]; se.xclient.data.l[3]=0; se.xclient.data.l[4]=0; XSendEvent((Display*)display,se.xclient.window,False,SubstructureRedirectMask|SubstructureNotifyMask,&se); } } // XDND Enter from source else if(ev.xclient.message_type==xdndEnter){ FXint ver=(ev.xclient.data.l[1]>>24)&255; FXTRACE((100,"DNDEnter from remote window %ld (ver %d)\n",ev.xclient.data.l[0],ver)); if(ver>XDND_PROTOCOL_VERSION) return true; xdndSource=ev.xclient.data.l[0]; // Now we're talking to this guy if(ddeTypeList){freeElms(ddeTypeList);ddeNumTypes=0;} if(ev.xclient.data.l[1]&1){ fxrecvtypes((Display*)display,xdndSource,xdndTypes,ddeTypeList,ddeNumTypes,false); } else{ allocElms(ddeTypeList,3); ddeNumTypes=0; if(ev.xclient.data.l[2]){ddeTypeList[0]=ev.xclient.data.l[2];ddeNumTypes++;} if(ev.xclient.data.l[3]){ddeTypeList[1]=ev.xclient.data.l[3];ddeNumTypes++;} if(ev.xclient.data.l[4]){ddeTypeList[2]=ev.xclient.data.l[4];ddeNumTypes++;} } } // XDND Leave from source else if(ev.xclient.message_type==xdndLeave){ FXTRACE((100,"DNDLeave from remote window %ld\n",ev.xclient.data.l[0])); if(xdndSource!=(FXID)ev.xclient.data.l[0]) return true; // We're not talking to this guy if(dropWindow){ event.type=SEL_DND_LEAVE; if(dropWindow->handle(this,FXSEL(SEL_DND_LEAVE,0),&event)) refresh(); dropWindow=nullptr; } if(ddeTypeList){freeElms(ddeTypeList);ddeNumTypes=0;} xdndSource=0; } // XDND Position from source else if(ev.xclient.message_type==xdndPosition){ if(xdndSource!=(FXID)ev.xclient.data.l[0]) return true; // We're not talking to this guy event.time=ev.xclient.data.l[3]; event.root_x=((FXuint)ev.xclient.data.l[2])>>16; event.root_y=((FXuint)ev.xclient.data.l[2])&0xffff; // Search from target window down; there may be another window // (like e.g. the dragged shape window) right under the cursor. // Note this is the target window, not the proxy target.... window=findWindowAt(event.root_x,event.root_y,ev.xclient.window); if((FXID)ev.xclient.data.l[4]==xdndActionList[DRAG_ASK]) ddeAction=DRAG_ASK; else if((FXID)ev.xclient.data.l[4]==xdndActionList[DRAG_MOVE]) ddeAction=DRAG_MOVE; else if((FXID)ev.xclient.data.l[4]==xdndActionList[DRAG_COPY]) ddeAction=DRAG_COPY; else if((FXID)ev.xclient.data.l[4]==xdndActionList[DRAG_LINK]) ddeAction=DRAG_LINK; else if((FXID)ev.xclient.data.l[4]==xdndActionList[DRAG_PRIVATE]) ddeAction=DRAG_PRIVATE; else ddeAction=DRAG_COPY; FXTRACE((100,"DNDPosition from remote window %ld action %d\n",ev.xclient.data.l[0],ddeAction)); ansAction=DRAG_REJECT; xdndWantUpdates=true; xdndRect.x=event.root_x; xdndRect.y=event.root_y; xdndRect.w=1; xdndRect.h=1; if(window!=dropWindow){ if(dropWindow){ event.type=SEL_DND_LEAVE; if(dropWindow->handle(this,FXSEL(SEL_DND_LEAVE,0),&event)) refresh(); } dropWindow=nullptr; if(window && window->isDropEnabled()){ dropWindow=window; event.type=SEL_DND_ENTER; if(dropWindow->handle(this,FXSEL(SEL_DND_ENTER,0),&event)) refresh(); } } if(dropWindow){ event.type=SEL_DND_MOTION; XTranslateCoordinates((Display*)display,XDefaultRootWindow((Display*)display),dropWindow->id(),event.root_x,event.root_y,&event.win_x,&event.win_y,&tmp); if(dropWindow->handle(this,FXSEL(SEL_DND_MOTION,0),&event)) refresh(); event.last_x=event.win_x; event.last_y=event.win_y; } se.xclient.type=ClientMessage; se.xclient.display=(Display*)display; se.xclient.message_type=xdndStatus; se.xclient.format=32; se.xclient.window=xdndSource; se.xclient.data.l[0]=ev.xclient.window; // Proxy Target window se.xclient.data.l[1]=0; if(ansAction!=DRAG_REJECT) se.xclient.data.l[1]|=1; // Target accepted if(xdndWantUpdates) se.xclient.data.l[1]|=2; // Target wants continuous position updates se.xclient.data.l[2]=MKUINT(xdndRect.y,xdndRect.x); se.xclient.data.l[3]=MKUINT(xdndRect.h,xdndRect.w); se.xclient.data.l[4]=xdndActionList[ansAction]; // Drag and Drop Action accepted XSendEvent((Display*)display,xdndSource,True,NoEventMask,&se); } // XDND Drop from source else if(ev.xclient.message_type==xdndDrop){ FXTRACE((100,"DNDDrop from remote window %ld\n",ev.xclient.data.l[0])); if(xdndSource!=(FXID)ev.xclient.data.l[0]) return true; // We're not talking to this guy xdndFinishSent=false; event.type=SEL_DND_DROP; event.time=ev.xclient.data.l[2]; // Perform drop operation on drop window if(!dropWindow || !dropWindow->handle(this,FXSEL(SEL_DND_DROP,0),&event)) ansAction=DRAG_REJECT; // Didn't sent finish yet if(!xdndFinishSent){ se.xclient.type=ClientMessage; se.xclient.display=(Display*)display; se.xclient.message_type=xdndFinished; se.xclient.format=32; se.xclient.window=xdndSource; se.xclient.data.l[0]=ev.xclient.window; // Proxy Target window se.xclient.data.l[1]=(ansAction==DRAG_REJECT)?0:1; // Bit #0 means accepted se.xclient.data.l[2]=xdndActionList[ansAction]; // Drag and Drop Action accepted se.xclient.data.l[3]=0; se.xclient.data.l[4]=0; XSendEvent((Display*)display,xdndSource,True,NoEventMask,&se); } // Clean up if(ddeTypeList){freeElms(ddeTypeList);ddeNumTypes=0;} dropWindow=nullptr; xdndSource=0; refresh(); } // XDND Status from target else if(ev.xclient.message_type==xdndStatus){ // We ignore ev.xclient.data.l[0], because some other // toolkits, e.g. Qt, do not place the proper value there; // the proper value is xdndTarget, NOT xdndProxyTarget or None //if(xdndTarget!=(FXID)ev.xclient.data.l[0]) return true; // We're not talking to this guy ansAction=DRAG_REJECT; if(ev.xclient.data.l[1]&1){ if((FXID)ev.xclient.data.l[4]==xdndActionList[DRAG_ASK]) ansAction=DRAG_ASK; else if((FXID)ev.xclient.data.l[4]==xdndActionList[DRAG_MOVE]) ansAction=DRAG_MOVE; else if((FXID)ev.xclient.data.l[4]==xdndActionList[DRAG_COPY]) ansAction=DRAG_COPY; else if((FXID)ev.xclient.data.l[4]==xdndActionList[DRAG_LINK]) ansAction=DRAG_LINK; else if((FXID)ev.xclient.data.l[4]==xdndActionList[DRAG_PRIVATE]) ansAction=DRAG_PRIVATE; } xdndWantUpdates=ev.xclient.data.l[1]&2; xdndRect.x=((FXuint)ev.xclient.data.l[2])>>16; xdndRect.y=((FXuint)ev.xclient.data.l[2])&0xffff; xdndRect.w=((FXuint)ev.xclient.data.l[3])>>16; xdndRect.h=((FXuint)ev.xclient.data.l[3])&0xffff; xdndStatusReceived=true; xdndStatusPending=false; FXTRACE((100,"DNDStatus from remote window %ld action=%d rect=%d,%d,%d,%d updates=%d\n",ev.xclient.data.l[0],ansAction,xdndRect.x,xdndRect.y,xdndRect.w,xdndRect.h,xdndWantUpdates)); } return true; // Property change case PropertyNotify: FXTRACE((200,"PropertyNotify %ld\n",ev.xproperty.atom)); // Update window position after minimize/maximize/restore whatever if(ev.xproperty.atom==wmState || ev.xproperty.atom==wmNetState){ unsigned long n,i; Atom type; unsigned char *prop; int format; if(Success==XGetWindowProperty((Display*)display,ev.xproperty.window,ev.xproperty.atom,0,10,false,AnyPropertyType,&type,&format,&n,&i,&prop)){ event.type=SEL_RESTORE; event.time=ev.xproperty.time; if(format==32){ for(i=0; ihandle(this,FXSEL(event.type,0),&event)) refresh(); } } return true; // Keyboard mapping case MappingNotify: FXTRACE((100,"MappingNotify\n")); if(ev.xmapping.request!=MappingPointer) XRefreshKeyboardMapping(&ev.xmapping); return true; // Visibility notification case VisibilityNotify: FXTRACE((200,"VisibilityNotify window=%ld %s\n",ev.xvisibility.window,(ev.xvisibility.state==VisibilityUnobscured)?"VisibilityUnobscured":(ev.xvisibility.state==VisibilityPartiallyObscured)?"VisibilityPartiallyObscured":"VisibilityFullyObscured")); return true; #if defined(HAVE_XINPUT2_H) case GenericEvent: FXTRACE((100,"GenericEvent\n")); if(ev.xcookie.extension==xInputOpcode && XGetEventData((Display*)display,&ev.xcookie)){ FXTRACE((100,"XInput2 type: %d\n",ev.xcookie.evtype)); switch(ev.xcookie.evtype){ case XI_ButtonPress: case XI_ButtonRelease: case XI_Motion: case XI_KeyPress: case XI_KeyRelease: print_deviceevent((XIDeviceEvent*)ev.xcookie.data); break; case XI_RawKeyPress: case XI_RawKeyRelease: case XI_RawButtonPress: case XI_RawButtonRelease: case XI_RawMotion: print_rawevent((XIRawEvent*)ev.xcookie.data); break; case XI_HierarchyChanged: print_hierarchychangedevent((XIHierarchyEvent*)ev.xcookie.data); break; case XI_DeviceChanged: // print_devicechangedevent(display,cookie->data); break; } XFreeEventData((Display*)display,&ev.xcookie); } return true; #endif // Other events default: #if defined(HAVE_XRANDR_H) if(ev.type==xrrScreenChange){ XRRUpdateConfiguration(&ev); root->setWidth(root->getDefaultWidth()); root->setHeight(root->getDefaultHeight()); //int screen=XRRRootToScreen((Display*)display,ev.xany.window); FXTRACE((100,"RRScreenChangeNotify w=%d h=%d\n",DisplayWidth((Display*)display,DefaultScreen((Display*)display)),DisplayHeight((Display*)display,DefaultScreen((Display*)display)))); // FIXME This should be a SEL_CONFIGURE for the root window, eventually } #endif #if defined(HAVE_XFIXES_H) if(ev.type==xfxFixesSelection){ FXTRACE((100,"XFixesSelectionNotifyEvent window=%lu owner=%lu selection=%lu\n",((XFixesSelectionNotifyEvent*)&ev)->window,((XFixesSelectionNotifyEvent*)&ev)->owner,((XFixesSelectionNotifyEvent*)&ev)->selection)); } #endif return true; } } return false; } #else // Get an event FXbool FXApp::getNextEvent(FXRawEvent& msg,FXTime blocking){ FXint allinputs; DWORD signaled; // Set to no-op just in case msg.message=0; // If a timer is due, handle it if(timers && timers->due<=FXThread::time()){ FXTimer* t=timers; timers=t->next; t->next=timerrecs; timerrecs=t; if(t->target && t->target->tryHandle(this,FXSEL(SEL_TIMEOUT,t->message),t->data)) refresh(); return false; } // Check non-immediate signals that may have fired if(signalreceived){ FXint sig=signalreceived; FXint nxt=MAXSIGNALS; signals[sig].notified=false; while(--nxt && !signals[nxt].notified); signalreceived=nxt; if(signals[sig].target && signals[sig].target->tryHandle(this,FXSEL(SEL_SIGNAL,signals[sig].message),(void*)(FXival)sig)) refresh(); return false; } // Peek for messages; this marks the message queue as unsignalled, i.e. // MsgWaitForMultipleObjects would block even if there are unhandled events; // the fix is to call MsgWaitForMultipleObjects only AFTER having ascertained // that there are NO unhandled events queued up. if(PeekMessage(&msg,nullptr,0,0,PM_REMOVE)) return true; // Poll to see if any waitable objects are signalled allinputs=maxhandle+1; signaled=MsgWaitForMultipleObjects(allinputs,handles->hnd,false,0,QS_ALLINPUT); // signaled=MsgWaitForMultipleObjectsEx(allinputs,handles,0,QS_ALLINPUT, MWMO_ALERTABLE); // No objects were signalled, so perform background tasks now if(signaled==WAIT_TIMEOUT){ // Do our chores :-) if(chores){ FXChore *c=chores; chores=c->next; c->next=chorerecs; chorerecs=c; if(c->target && c->target->tryHandle(this,FXSEL(SEL_CHORE,c->message),c->data)) refresh(); } // GUI updating:- walk the whole widget tree, stop after updating refresherstop if(refresher){ if(refresher->getFirst()){ refresher=refresher->getFirst(); } else{ while(refresher->getParent()){ if(refresher->getNext()){ refresher=refresher->getNext(); break; } refresher=refresher->getParent(); } } refresher->handle(this,FXSEL(SEL_UPDATE,0),nullptr); if(refresher!=refresherstop) return false; refresher=refresherstop=nullptr; } // There are more chores to do if(chores) return false; // No updates or chores pending, so return at this point if not blocking if(blocking<=0) return false; // One more call to PeekMessage here because the preceding idle // processing may have caused some more messages to be posted to // our message queue:- a call to MsgWaitForMultipleObjects when // there are events already in the queue would NOT immediately fall // through but block until the next event comes in. if(PeekMessage(&msg,nullptr,0,0,PM_REMOVE)) return true; // If there are timers, block only a little time allinputs=maxhandle+1; if(timers || blockingdue-FXThread::time())hnd,false,delta,QS_ALLINPUT); //signaled=MsgWaitForMultipleObjectsEx(allinputs,handles,delta,QS_ALLINPUT,MWMO_ALERTABLE); // Enter critical section appMutex.lock(); } // No timers, so block indefinitely else{ // Exit critical section appMutex.unlock(); // Now we will block... signaled=MsgWaitForMultipleObjects(allinputs,handles->hnd,false,INFINITE,QS_ALLINPUT); //signaled=MsgWaitForMultipleObjectsEx(allinputs,handles,INFINITE,QS_ALLINPUT,MWMO_ALERTABLE); // Enter critical section appMutex.lock(); } } // Timed out, so do timeouts if(signaled==WAIT_TIMEOUT) return false; // Signallable object was signalled if(WAIT_OBJECT_0<=signaled && signaledhnd[i]; if((i==(FXint)(signaled-WAIT_OBJECT_0)) || (WaitForSingleObject(fff,0)==WAIT_OBJECT_0)){ FXInput in=inputs[i]; if(in.read.target && in.read.target->tryHandle(this,FXSEL(SEL_IO_READ,in.read.message),in.read.data)) refresh(); if(in.write.target && in.write.target->tryHandle(this,FXSEL(SEL_IO_WRITE,in.write.message),in.write.data)) refresh(); if(in.excpt.target && in.excpt.target->tryHandle(this,FXSEL(SEL_IO_EXCEPT,in.excpt.message),in.excpt.data)) refresh(); } } } // Got message from the GUI? if(signaled!=WAIT_OBJECT_0+allinputs) return false; // Get the event; this used to be GetMessage(&msg,NULL,0,0), // but for some reason, this occasionally blocks even though we // have tried to make sure an event was indeed available. // The new code will always fall through, with an event if there // is one, or without one if despite our efforts above there wasn't. // Thanks to Hodju Petri for this suggestion. return PeekMessage(&msg,nullptr,0,0,PM_REMOVE)!=0; } // Peek for event FXbool FXApp::peekEvent(){ if(initialized){ MSG msg; // Still need GUI update if(refresher) return true; // Outstanding chores if(chores) return true; // Timers are due? if(timers){ if(timers->due <= FXThread::time()) return true; } // Other events due? return PeekMessage(&msg,nullptr,0,0,PM_NOREMOVE)!=0; } return false; } // Dispatch event to widget FXbool FXApp::dispatchEvent(FXRawEvent& msg){ TranslateMessage(&msg); DispatchMessage(&msg); return true; } #endif /*******************************************************************************/ // Flush pending repaints void FXApp::flush(FXbool sync){ if(initialized){ #if defined(WIN32) GdiFlush(); #else if(sync) XSync((Display*)display,false); else XFlush((Display*)display); #endif } } // Force GUI refresh of every widget in this application void FXApp::forceRefresh(){ getRootWindow()->forceRefresh(); } // Schedule a future refresh; if we were in the middle of // one, we continue with the current cycle until we wrap // around to the current widget about to be updated. void FXApp::refresh(){ if(!refresher) refresher=root; refresherstop=refresher; } // Paint all windows marked for repainting void FXApp::repaint(){ if(initialized){ #if defined(WIN32) for(FXWindow *top=getRootWindow()->getFirst(); top; top=top->getNext()){ RedrawWindow((HWND)top->id(),nullptr,nullptr,RDW_ERASENOW|RDW_UPDATENOW|RDW_ALLCHILDREN); } #else removeRepaints(0,0,0,0,0); #endif } } // Run application FXint FXApp::run(){ FXInvocation inv(&invocation,MODAL_FOR_NONE,nullptr); FXTRACE((100,"Start run\n")); while(!inv.done){ runOneEvent(); } FXTRACE((100,"End run\n")); return inv.code; } // Run till some flag becomes non-zero FXint FXApp::runUntil(FXuint& condition){ FXInvocation inv(&invocation,MODAL_FOR_NONE,nullptr); FXTRACE((100,"Start runUntil\n")); while(!inv.done && condition==0){ runOneEvent(); } FXTRACE((100,"End runUntil\n")); return condition; } // Run event loop while events are available FXint FXApp::runWhileEvents(FXTime blocking){ FXInvocation inv(&invocation,MODAL_FOR_NONE,nullptr); FXTRACE((100,"Start runWhileEvents\n")); while(!inv.done && runOneEvent(blocking)) blocking=1000; FXTRACE((100,"End runWhileEvents\n")); return !inv.done; } // Run event loop while events are available FXint FXApp::runModalWhileEvents(FXWindow* window,FXTime blocking){ FXInvocation inv(&invocation,MODAL_FOR_WINDOW,window); FXTRACE((100,"Start runModalWhileEvents\n")); while(!inv.done && runOneEvent(blocking)) blocking=1000; FXTRACE((100,"End runModalWhileEvents\n")); return !inv.done; } // Perform one event dispatch FXbool FXApp::runOneEvent(FXTime blocking){ FXRawEvent ev; if(getNextEvent(ev,blocking)){ dispatchEvent(ev); return true; } return false; } // Run modal event loop, blocking events to all windows, until stopModal is called. FXint FXApp::runModal(){ FXInvocation inv(&invocation,MODAL_FOR_WINDOW,nullptr); FXTRACE((100,"Start runModal\n")); while(!inv.done){ runOneEvent(); } FXTRACE((100,"End runModal\n")); return inv.code; } // Run modal for window FXint FXApp::runModalFor(FXWindow* window){ FXInvocation inv(&invocation,MODAL_FOR_WINDOW,window); FXTRACE((100,"Start runModalFor\n")); while(!inv.done){ runOneEvent(); } FXTRACE((100,"End runModalFor\n")); return inv.code; } // Run modal while window is shown, or until stopModal is called FXint FXApp::runModalWhileShown(FXWindow* window){ FXInvocation inv(&invocation,MODAL_FOR_WINDOW,window); FXTRACE((100,"Start runModalWhileShown\n")); while(!inv.done && window->shown()){ runOneEvent(); } FXTRACE((100,"End runModalWhileShown\n")); return inv.code; } // Run popup menu FXint FXApp::runPopup(FXWindow* window){ FXInvocation inv(&invocation,MODAL_FOR_POPUP,window); FXTRACE((100,"Start runPopup\n")); while(!inv.done && window->shown()){ runOneEvent(); } FXTRACE((100,"End runPopup\n")); return inv.code; } // Test if the window is involved in a modal invocation FXbool FXApp::isModal(FXWindow *window) const { FXInvocation* inv; for(inv=invocation; inv; inv=inv->upper){ if(inv->window==window && inv->modality!=MODAL_FOR_NONE) return true; } return false; } // Return current modal window, if any FXWindow* FXApp::getModalWindow() const { return invocation ? invocation->window : nullptr; } // Return mode of current modal loop FXModality FXApp::getModality() const { return invocation ? invocation->modality : MODAL_FOR_NONE; } // Break out of topmost event loop, closing all nested loops also void FXApp::stop(FXint value){ FXInvocation* inv; for(inv=invocation; inv; inv=inv->upper){ inv->done=true; inv->code=0; if(inv->upper==nullptr){ inv->code=value; return; } } } // Break out of modal loop matching window, and all deeper ones void FXApp::stopModal(FXWindow* window,FXint value){ FXInvocation* inv; if(isModal(window)){ for(inv=invocation; inv; inv=inv->upper){ inv->done=true; inv->code=0; if(inv->window==window && inv->modality!=MODAL_FOR_NONE){ inv->code=value; return; } } } } // Break out of innermost modal loop, and all deeper non-modal ones void FXApp::stopModal(FXint value){ FXInvocation* inv; for(inv=invocation; inv; inv=inv->upper){ inv->done=true; inv->code=0; if(inv->modality!=MODAL_FOR_NONE){ inv->code=value; return; } } } // Obtain system color and translate to FXColor #if defined(WIN32) static FXColor getSystemColor(FXuint which){ DWORD dwColor=GetSysColor(which); return FXRGB(GetRValue(dwColor),GetGValue(dwColor),GetBValue(dwColor)); } #endif // Obtain system font and translate to FXFontDesc #if defined(WIN32) static void getSystemFont(FXFontDesc& fontdesc){ NONCLIENTMETRICS ncm; memset(&ncm,0,sizeof(NONCLIENTMETRICS)); ncm.cbSize=sizeof(NONCLIENTMETRICS); #if (WINVER >= 0x0600) // Fix from: Daniel Stine OSVERSIONINFO osvi; // Adjust size based on operating system version memset(&osvi,0,sizeof(osvi)); // So get run-time operating system version first osvi.dwOSVersionInfoSize=sizeof(osvi); // if headers include new member iPaddedBorderWidth GetVersionEx(&osvi); // in NONCLIENTMETRICS struct if(osvi.dwMajorVersion<6) ncm.cbSize-=sizeof(ncm.iPaddedBorderWidth); #endif SystemParametersInfo(SPI_GETNONCLIENTMETRICS,sizeof(NONCLIENTMETRICS),&ncm,0); #if defined(UNICODE) ncs2utf(fontdesc.face,ncm.lfMenuFont.lfFaceName,sizeof(fontdesc.face),LF_FACESIZE); #else fxstrlcpy(fontdesc.face,ncm.lfMenuFont.lfFaceName,sizeof(fontdesc.face)); #endif fontdesc.face[sizeof(fontdesc.face)-1]='\0'; HDC hDC=CreateCompatibleDC(nullptr); fontdesc.size=-10*MulDiv(ncm.lfMenuFont.lfHeight,72,GetDeviceCaps(hDC,LOGPIXELSY)); DeleteDC(hDC); fontdesc.weight=(FXushort)ncm.lfMenuFont.lfWeight/10; fontdesc.slant=ncm.lfMenuFont.lfItalic?FXFont::Italic:FXFont::Straight; fontdesc.encoding=FONTENCODING_DEFAULT; fontdesc.setwidth=0; fontdesc.flags=0; } #endif // Initialize application and optionally open display void FXApp::init(int& argc,char** argv,FXbool connect){ const FXchar *fontspec=nullptr; const FXchar *style=nullptr; const FXchar *dpy=":0.0"; const FXchar *str=nullptr; FXuint maxcols=0; FXint i,j; // Verify implementation invariants FXASSERT_STATIC(sizeof(FXuchar)==1); FXASSERT_STATIC(sizeof(FXchar)==1); FXASSERT_STATIC(sizeof(FXushort)==2); FXASSERT_STATIC(sizeof(FXshort)==2); FXASSERT_STATIC(sizeof(FXuint)==4); FXASSERT_STATIC(sizeof(FXnchar)==2); FXASSERT_STATIC(sizeof(FXwchar)==4); FXASSERT_STATIC(sizeof(FXint)==4); FXASSERT_STATIC(sizeof(FXulong)==8); FXASSERT_STATIC(sizeof(FXlong)==8); FXASSERT_STATIC(sizeof(FXfloat)==4); FXASSERT_STATIC(sizeof(FXdouble)==8); FXASSERT_STATIC(sizeof(FXival)==sizeof(void*)); FXASSERT_STATIC(sizeof(FXuval)==sizeof(void*)); FXASSERT_STATIC(sizeof(FXString)==sizeof(void*)); // Check arguments if(argc<1 || argv==nullptr || argv[0]==nullptr){ fxerror("%s::init: bad arguments.\n",getClassName()); } // Initialize locale; follow locale settings except // for numerical stuff where we need it to behave normally; // we no longer care about LC_CTYPE since we have our own. setlocale(LC_ALL,""); setlocale(LC_NUMERIC,"C"); // Try locate display #ifndef WIN32 if((str=getenv("DISPLAY"))!=nullptr) dpy=str; #endif // System-wide configuration search paths if((str=getenv("XDG_CONFIG_DIRS"))!=nullptr){ registry.setSystemDirectories(str); } // Per-user configuration path if((str=getenv("XDG_CONFIG_HOME"))!=nullptr){ registry.setUserDirectory(str); } // If set, force FOXDIR for system-wide path if((str=getenv("FOXDIR"))!=nullptr){ registry.setSystemDirectories(str); } //fxisconsole(argv[0]); // Parse out FOX args i=j=1; while(j=argc){ fxwarning("%s:init: missing argument for -display.\n",getClassName()); ::exit(1); } dpy=argv[j++]; continue; } // Set input method if(FXString::compare(argv[j],"-im")==0){ if(++j>=argc){ fxwarning("%s:init: missing argument for -im.\n",getClassName()); ::exit(1); } inputmethod=argv[j++]; continue; } // Input style if(FXString::compare(argv[j],"-is")==0){ if(++j>=argc){ fxwarning("%s:init: missing argument for -is.\n",getClassName()); ::exit(1); } style=argv[j++]; continue; } #endif // Set trace level if(FXString::compare(argv[j],"-tracelevel")==0){ if(++j>=argc){ fxwarning("%s:init: missing argument for -tracelevel.\n",getClassName()); ::exit(1); } setTraceLevel(__strtoul(argv[j++])); continue; } // Set trace level if(FXString::compare(argv[j],"-tracetopics")==0){ if(++j>=argc){ fxwarning("%s:init: missing argument for -tracetopics.\n",getClassName()); ::exit(1); } setTraceTopics(argv[j++]); continue; } // Set per-user configuration directory if(FXString::compare(argv[j],"-config")==0){ if(++j>=argc){ fxwarning("%s:init: missing argument for -config.\n",getClassName()); ::exit(1); } registry.setUserDirectory(argv[j++]); continue; } // Set ascii based registery (Windows) if(FXString::compare(argv[j],"-ascii")==0){ registry.setAsciiMode(true); j++; continue; } // Set maximum number of colors if(FXString::compare(argv[j],"-maxcolors")==0){ if(++j>=argc){ fxwarning("%s:init: missing argument for -maxcolors.\n",getClassName()); ::exit(1); } maxcols=__strtoul(argv[j++]); if(maxcols<2 || maxcols>256){ fxwarning("%s::init: expected value between 2 and 256.\n",getClassName()); ::exit(1); } continue; } // Copy program arguments argv[i++]=argv[j++]; } // Adjust argment count argv[i]=nullptr; argc=i; // Remember arguments appArgv=argv; appArgc=argc; // Log message FXTRACE((100,"%s::init %d.%d.%d\n",getClassName(),FOX_MAJOR,FOX_MINOR,FOX_LEVEL)); // Read the registry registry.read(); #if defined(WIN32) // Get font face and metrics FXFontDesc fontdesc; getSystemFont(fontdesc); normalFont->setFontDesc(fontdesc); // Read colors from system baseColor=getSystemColor(COLOR_3DFACE); hiliteColor=getSystemColor(COLOR_3DHILIGHT); shadowColor=getSystemColor(COLOR_3DSHADOW); backColor=getSystemColor(COLOR_WINDOW); borderColor=getSystemColor(COLOR_WINDOWFRAME); foreColor=getSystemColor(COLOR_BTNTEXT); selforeColor=getSystemColor(COLOR_HIGHLIGHTTEXT); selbackColor=getSystemColor(COLOR_HIGHLIGHT); tipforeColor=getSystemColor(COLOR_INFOTEXT); tipbackColor=getSystemColor(COLOR_INFOBK); // Windows XP or later OSVERSIONINFO osvi; osvi.dwOSVersionInfoSize=sizeof(OSVERSIONINFO); GetVersionEx((OSVERSIONINFO*)&osvi); // Flat looking menus // if((osvi.dwMajorVersion>5) || (osvi.dwMajorVersion==5 && osvi.dwMinorVersion>=1)){ // FIXME // selMenuTextColor=getSystemColor(COLOR_HIGHLIGHT); // selMenuBackColor=getSystemColor(COLOR_MENUHILIGHT); // //selMenuBackColor=getSystemColor(COLOR_MENUTEXT); // Menu text // //selMenuBackColor=getSystemColor(COLOR_MENU); // Menu background // } // else{ selMenuTextColor=getSystemColor(COLOR_HIGHLIGHTTEXT); selMenuBackColor=getSystemColor(COLOR_HIGHLIGHT); // } // Get wheel lines SystemParametersInfo(SPI_GETWHEELSCROLLLINES,0,&wheelLines,0); #endif // Parse font and change default font if set fontspec=registry.readStringEntry("SETTINGS","normalfont",nullptr); if(fontspec){ normalFont->setFont(fontspec); } // Load timing constants typingSpeed=registry.readLongEntry("SETTINGS","typingspeed",typingSpeed); clickSpeed=registry.readLongEntry("SETTINGS","clickspeed",clickSpeed); scrollSpeed=registry.readLongEntry("SETTINGS","scrollspeed",scrollSpeed); scrollDelay=registry.readLongEntry("SETTINGS","scrolldelay",scrollDelay); blinkSpeed=registry.readLongEntry("SETTINGS","blinkspeed",blinkSpeed); animSpeed=registry.readLongEntry("SETTINGS","animspeed",animSpeed); menuPause=registry.readLongEntry("SETTINGS","menupause",menuPause); toolTipPause=registry.readLongEntry("SETTINGS","tippause",toolTipPause); toolTipTime=registry.readLongEntry("SETTINGS","tiptime",toolTipTime); autoHideDelay=registry.readLongEntry("SETTINGS","autohide",autoHideDelay); // Load miscellaneous settings dragDelta=registry.readIntEntry("SETTINGS","dragdelta",dragDelta); wheelLines=registry.readIntEntry("SETTINGS","wheellines",wheelLines); scrollBarSize=registry.readIntEntry("SETTINGS","scrollbarsize",scrollBarSize); // Load colors settings borderColor=registry.readColorEntry("SETTINGS","bordercolor",borderColor); baseColor=registry.readColorEntry("SETTINGS","basecolor",baseColor); hiliteColor=registry.readColorEntry("SETTINGS","hilitecolor",hiliteColor); shadowColor=registry.readColorEntry("SETTINGS","shadowcolor",shadowColor); backColor=registry.readColorEntry("SETTINGS","backcolor",backColor); foreColor=registry.readColorEntry("SETTINGS","forecolor",foreColor); selforeColor=registry.readColorEntry("SETTINGS","selforecolor",selforeColor); selbackColor=registry.readColorEntry("SETTINGS","selbackcolor",selbackColor); tipforeColor=registry.readColorEntry("SETTINGS","tipforecolor",tipforeColor); tipbackColor=registry.readColorEntry("SETTINGS","tipbackcolor",tipbackColor); selMenuTextColor=registry.readColorEntry("SETTINGS","selmenutextcolor",selforeColor); selMenuBackColor=registry.readColorEntry("SETTINGS","selmenubackcolor",selbackColor); // Maximum number of colors to allocate maxcolors=registry.readUIntEntry("SETTINGS","maxcolors",maxcolors); // Command line takes precedence if(maxcols) maxcolors=maxcols; // Read input method style if not set from command line inputstyle=registry.readStringEntry("SETTINGS","inputstyle",inputstyle); // Command line takes precedence if(style) inputstyle=style; // Set maximum number of colors in default visual to be nice to legacy // Motif applications which don't handle color allocation gracefully. getRootWindow()->getVisual()->setMaxColors(maxcolors); // Open display; this also applies any system-defined settings. // We only override settings if NOT set from our own registry, since // it is possible that we don't open the display until later, so we // can't simply overwrite system-defined settings after opening the // display here. if(connect){ if(!openDisplay(dpy)){ fxwarning("%s::openDisplay: unable to open display %s\n",getClassName(),dpy); ::exit(1); } } } // Exit application and close display void FXApp::exit(FXint code){ FXTRACE((100,"%s::exit\n",getClassName())); // Close the display closeDisplay(); // Write the registry registry.write(); // Exit the program stop(code); } // Create application's windows void FXApp::create(){ FXTRACE((100,"%s::create\n",getClassName())); // Create visuals monoVisual->create(); defaultVisual->create(); // Create default font normalFont->create(); stockFont->create(); // Create wait cursor waitCursor->create(); // Create stock cursors cursor[DEF_ARROW_CURSOR]->create(); cursor[DEF_RARROW_CURSOR]->create(); cursor[DEF_TEXT_CURSOR]->create(); cursor[DEF_HSPLIT_CURSOR]->create(); cursor[DEF_VSPLIT_CURSOR]->create(); cursor[DEF_XSPLIT_CURSOR]->create(); cursor[DEF_SWATCH_CURSOR]->create(); cursor[DEF_MOVE_CURSOR]->create(); cursor[DEF_DRAGH_CURSOR]->create(); cursor[DEF_DRAGV_CURSOR]->create(); cursor[DEF_DRAGTL_CURSOR]->create(); cursor[DEF_DRAGTR_CURSOR]->create(); cursor[DEF_DNDSTOP_CURSOR]->create(); cursor[DEF_DNDASK_CURSOR]->create(); cursor[DEF_DNDCOPY_CURSOR]->create(); cursor[DEF_DNDMOVE_CURSOR]->create(); cursor[DEF_DNDLINK_CURSOR]->create(); cursor[DEF_CROSSHAIR_CURSOR]->create(); cursor[DEF_CORNERNE_CURSOR]->create(); cursor[DEF_CORNERNW_CURSOR]->create(); cursor[DEF_CORNERSE_CURSOR]->create(); cursor[DEF_CORNERSW_CURSOR]->create(); cursor[DEF_HELP_CURSOR]->create(); cursor[DEF_HAND_CURSOR]->create(); cursor[DEF_ROTATE_CURSOR]->create(); cursor[DEF_BLANK_CURSOR]->create(); cursor[DEF_WAIT_CURSOR]->create(); // Create all windows root->create(); } // Detach application's windows void FXApp::detach(){ FXTRACE((100,"%s::detach\n",getClassName())); root->detach(); // Detach default font normalFont->detach(); stockFont->detach(); // Detach wait cursor waitCursor->detach(); // Detach stock cursors cursor[DEF_ARROW_CURSOR]->detach(); cursor[DEF_RARROW_CURSOR]->detach(); cursor[DEF_TEXT_CURSOR]->detach(); cursor[DEF_HSPLIT_CURSOR]->detach(); cursor[DEF_VSPLIT_CURSOR]->detach(); cursor[DEF_XSPLIT_CURSOR]->detach(); cursor[DEF_SWATCH_CURSOR]->detach(); cursor[DEF_MOVE_CURSOR]->detach(); cursor[DEF_DRAGH_CURSOR]->detach(); cursor[DEF_DRAGV_CURSOR]->detach(); cursor[DEF_DRAGTL_CURSOR]->detach(); cursor[DEF_DRAGTR_CURSOR]->detach(); cursor[DEF_DNDSTOP_CURSOR]->detach(); cursor[DEF_DNDASK_CURSOR]->detach(); cursor[DEF_DNDCOPY_CURSOR]->detach(); cursor[DEF_DNDMOVE_CURSOR]->detach(); cursor[DEF_DNDLINK_CURSOR]->detach(); cursor[DEF_CROSSHAIR_CURSOR]->detach(); cursor[DEF_CORNERNE_CURSOR]->detach(); cursor[DEF_CORNERNW_CURSOR]->detach(); cursor[DEF_CORNERSE_CURSOR]->detach(); cursor[DEF_CORNERSW_CURSOR]->detach(); cursor[DEF_HELP_CURSOR]->detach(); cursor[DEF_HAND_CURSOR]->detach(); cursor[DEF_ROTATE_CURSOR]->detach(); cursor[DEF_BLANK_CURSOR]->detach(); cursor[DEF_WAIT_CURSOR]->detach(); // Detach visuals monoVisual->detach(); defaultVisual->detach(); } // Destroy application's windows void FXApp::destroy(){ FXTRACE((100,"%s::destroy\n",getClassName())); root->destroy(); // Destroy default font normalFont->destroy(); stockFont->destroy(); // Destroy wait cursor waitCursor->destroy(); // Destroy stock cursors cursor[DEF_ARROW_CURSOR]->destroy(); cursor[DEF_RARROW_CURSOR]->destroy(); cursor[DEF_TEXT_CURSOR]->destroy(); cursor[DEF_HSPLIT_CURSOR]->destroy(); cursor[DEF_VSPLIT_CURSOR]->destroy(); cursor[DEF_XSPLIT_CURSOR]->destroy(); cursor[DEF_SWATCH_CURSOR]->destroy(); cursor[DEF_MOVE_CURSOR]->destroy(); cursor[DEF_DRAGH_CURSOR]->destroy(); cursor[DEF_DRAGV_CURSOR]->destroy(); cursor[DEF_DRAGTL_CURSOR]->destroy(); cursor[DEF_DRAGTR_CURSOR]->destroy(); cursor[DEF_DNDSTOP_CURSOR]->destroy(); cursor[DEF_DNDASK_CURSOR]->destroy(); cursor[DEF_DNDCOPY_CURSOR]->destroy(); cursor[DEF_DNDMOVE_CURSOR]->destroy(); cursor[DEF_DNDLINK_CURSOR]->destroy(); cursor[DEF_CROSSHAIR_CURSOR]->destroy(); cursor[DEF_CORNERNE_CURSOR]->destroy(); cursor[DEF_CORNERNW_CURSOR]->destroy(); cursor[DEF_CORNERSE_CURSOR]->destroy(); cursor[DEF_CORNERSW_CURSOR]->destroy(); cursor[DEF_HELP_CURSOR]->destroy(); cursor[DEF_HAND_CURSOR]->destroy(); cursor[DEF_ROTATE_CURSOR]->destroy(); cursor[DEF_BLANK_CURSOR]->destroy(); cursor[DEF_WAIT_CURSOR]->destroy(); // Destroy visuals monoVisual->destroy(); defaultVisual->destroy(); } // Generates SEL_LEAVE event when cursor is not inside ancestor of // cursorWindow anymore. Note that cursor may still be phyisally inside // the borders of the cursorWindow's shell but is considered outside if // another window obscures it. This mechanism replaces the dysfunctional // and unreliable TrackMouseEvent method. long FXApp::onCmdHover(FXObject*,FXSelector,void*){ FXint x,y; FXuint buttons; FXWindow *window; if(!mouseGrabWindow && cursorWindow && cursorWindow!=root){ root->getCursorPosition(x,y,buttons); if((window=findWindowAt(x,y))==nullptr || !window->getShell()->containsChild(cursorWindow)){ event.type=SEL_LEAVE; event.root_x=x; event.root_y=y; leaveWindow(cursorWindow,root); return 0; } } addTimeout(this,ID_HOVER,200000000); return 0; } #if defined(WIN32) // This window procedure is a static member function of class FXApp. // Its sole purpose is to forward the message info on to FXApp::dispatchEvent(). FXival CALLBACK FXApp::wndproc(FXID hwnd,FXuint iMsg,FXuval wParam,FXival lParam){ return app->dispatchEvent(hwnd,iMsg,wParam,lParam); } #ifndef WM_SYNCPAINT #define WM_SYNCPAINT 0x0088 #endif // Translate to string on KeyPress FXString translateKeyEvent(FXuint,FXuval wParam,FXival lParam){ FXnchar buffer[20]; BYTE keystate[256]; int n; GetKeyboardState(keystate); n=ToUnicodeEx(wParam,HIWORD(lParam)&(KF_EXTENDED|KF_UP|0xFF),keystate,buffer,20,0,GetKeyboardLayout(0)); if(n<=0) n=0; return FXString(buffer,n); } // Message dispatching FXival FXApp::dispatchEvent(FXID hwnd,FXuint iMsg,FXuval wParam,FXival lParam){ const FXTime milliseconds=1000000; FXWindow *window,*ancestor,*win,*focuswin; static HWND lastmovehwnd=0; static LPARAM lastmovelParam=0; POINT ptRoot, pt; DWORD dwpts; PAINTSTRUCT ps; FXuint state; HANDLE hMap; HANDLE answer; if(!IsWindow((HWND)hwnd)) return DefWindowProc((HWND)hwnd,iMsg,wParam,lParam); // Get window window=findWindowWithId(hwnd); if(window==0 && iMsg!=WM_CREATE) return DefWindowProc((HWND)hwnd,iMsg,wParam,lParam); // Translate Win32 message to FOX message type switch(iMsg){ // Repaint event case WM_PAINT: event.type=SEL_PAINT; event.synthetic=1; // FIXME when is it non-synthetic? BeginPaint((HWND)hwnd,&ps); event.rect.x=(FXshort)ps.rcPaint.left; event.rect.y=(FXshort)ps.rcPaint.top; event.rect.w=(FXshort)(ps.rcPaint.right-ps.rcPaint.left); event.rect.h=(FXshort)(ps.rcPaint.bottom-ps.rcPaint.top); window->handle(this,FXSEL(SEL_PAINT,0),&event); EndPaint((HWND)hwnd,&ps); return 0; // Start Input Method Editor case WM_IME_STARTCOMPOSITION: focuswin=getFocusWindow(); if(inputstyle[1]!='o'){ // not root mode if(focuswin && focuswin->getComposeContext()) focuswin->handle(this,FXSEL(SEL_IME_START,0),nullptr); else return 0; } // on-the-spot mode if(inputstyle[1]=='n') return 0; // other mode return DefWindowProc((HWND)hwnd,iMsg,wParam,lParam); // End Input Method Editor case WM_IME_ENDCOMPOSITION: focuswin=getFocusWindow(); if(inputstyle[1]!='o'){ // not root mode if(focuswin && focuswin->getComposeContext()) focuswin->handle(this,FXSEL(SEL_IME_END,0),nullptr); else return 0; } // on-the-spot mode if(inputstyle[1]=='n') return 0; // other mode return DefWindowProc((HWND)hwnd,iMsg,wParam,lParam); // Character Input from Input Method Editor case WM_IME_CHAR: // ignore this message, coming after WM_IME_COMPOSITION // because IME string is handled in WM_IME_COMPOSITION message return 0; // Keyboard case WM_IME_COMPOSITION: if((inputstyle[1]!='n') && !(lParam&GCS_RESULTSTR)){ focuswin=getFocusWindow(); if(focuswin && focuswin->getComposeContext()) return DefWindowProc((HWND)hwnd,iMsg,wParam,lParam); else return 0; } // else keep going case WM_KEYDOWN: case WM_SYSKEYDOWN: case WM_KEYUP: case WM_SYSKEYUP: FXTRACE((100,"%s virtkey=%c [0x%04x] hi=0x%04x rc=%d\n",iMsg==WM_KEYDOWN?"WM_KEYDOWN":iMsg==WM_KEYUP?"WM_KEYUP":iMsg==WM_SYSKEYDOWN?"WM_SYSKEYDOWN":"WM_SYSKEYUP",wParam,wParam,HIWORD(lParam),LOWORD(lParam))); event.type=((iMsg==WM_KEYUP)||(iMsg==WM_SYSKEYUP)) ? SEL_KEYRELEASE : SEL_KEYPRESS; event.time=GetMessageTime(); dwpts=GetMessagePos(); event.root_x=pt.x=((int)(short)LOWORD(dwpts)); event.root_y=pt.y=((int)(short)HIWORD(dwpts)); ScreenToClient((HWND)hwnd,&pt); event.win_x=pt.x; event.win_y=pt.y; event.state=fxmodifierkeys(); // Translate to keysym event.code=wkbMapKeyCode(iMsg,wParam,lParam);// FIXME not all codes match with those of X11 // Translate to string on KeyPress if(event.type==SEL_KEYPRESS){ focuswin=getFocusWindow(); if( (iMsg==WM_IME_COMPOSITION) && (lParam&GCS_RESULTSTR) && focuswin && focuswin->getComposeContext()){ FXRawEvent ev; ev.hwnd=(HWND)hwnd; ev.message=iMsg; ev.wParam=wParam; ev.lParam=lParam; event.text=focuswin->getComposeContext()->translateEvent(ev); } else{ event.text=translateKeyEvent(iMsg,wParam,lParam); } } // Clear string on KeyRelease else{ event.text.clear(); } /* Alt key seems to repeat. */ // Fix modifier state if(event.type==SEL_KEYPRESS){ if(event.code==KEY_Shift_L) event.state|=SHIFTMASK; else if(event.code==KEY_Shift_R) event.state|=SHIFTMASK; else if(event.code==KEY_Control_L) event.state|=CONTROLMASK; else if(event.code==KEY_Control_R) event.state|=CONTROLMASK; else if(event.code==KEY_F13) event.state|=METAMASK; // Key between Ctrl and Alt (on most keyboards) else if(event.code==KEY_Alt_L) event.state|=ALTMASK; else if(event.code==KEY_Alt_R) event.state|=ALTMASK; // FIXME do we need ALTGR flag instead/in addition? else if(event.code==KEY_Num_Lock) event.state|=NUMLOCKMASK; else if(event.code==KEY_Caps_Lock) event.state|=CAPSLOCKMASK; else if(event.code==KEY_Scroll_Lock) event.state|=SCROLLLOCKMASK; else if(event.code==KEY_Super_L) event.state|=METAMASK; else if(event.code==KEY_Super_R) event.state|=METAMASK; else{ stickyMods=event.state&(SHIFTMASK|CONTROLMASK|METAMASK|ALTMASK); } } else{ if(event.code==KEY_Shift_L) event.state&=~SHIFTMASK; else if(event.code==KEY_Shift_R) event.state&=~SHIFTMASK; else if(event.code==KEY_Control_L) event.state&=~CONTROLMASK; else if(event.code==KEY_Control_R) event.state&=~CONTROLMASK; else if(event.code==KEY_F13) event.state&=~METAMASK; // Key between Ctrl and Alt (on most keyboards) else if(event.code==KEY_Alt_L) event.state&=~ALTMASK; else if(event.code==KEY_Alt_R) event.state&=~ALTMASK; // FIXME do we need ALTGR flag instead/in addition? else if(event.code==KEY_Num_Lock) event.state&=~NUMLOCKMASK; else if(event.code==KEY_Caps_Lock) event.state&=~CAPSLOCKMASK; else if(event.code==KEY_Scroll_Lock) event.state&=~SCROLLLOCKMASK; else if(event.code==KEY_Super_L) event.state&=~METAMASK; else if(event.code==KEY_Super_R) event.state&=~METAMASK; else{ event.state|=stickyMods; stickyMods=0; } } FXTRACE((100,"%s code=%04x state=%04x stickyMods=%04x text=\"%s\"\n",(event.type==SEL_KEYPRESS)?"SEL_KEYPRESS":"SEL_KEYRELEASE",event.code,event.state,stickyMods,event.text.text())); // Keyboard grabbed by specific window if(keyboardGrabWindow){ if(keyboardGrabWindow->handle(this,FXSEL(event.type,0),&event)) refresh(); return 0; } // Remember window for later if(event.type==SEL_KEYPRESS) keyWindow=activeWindow; // Dispatch to key window if(keyWindow){ // FIXME doesSaveUnder test should go away // Dispatch if not in a modal loop or in a modal loop for a window containing the focus window if(!invocation || invocation->modality==MODAL_FOR_NONE || (invocation->window && invocation->window->isOwnerOf(keyWindow)) || keyWindow->getShell()->doesSaveUnder()){ if(keyWindow->handle(this,FXSEL(event.type,0),&event)) refresh(); if((iMsg==WM_IME_COMPOSITION) && (inputstyle[1]!='n')){ // it is possible that undetermined IME characters remain if(inputstyle[1]!='o'){ focuswin=getFocusWindow(); if(focuswin){ focuswin->handle(this,FXSEL(SEL_IME_START,0),nullptr); } } return DefWindowProc((HWND)hwnd,iMsg,wParam,lParam); } return 0; } // Beep if outside modal if(event.type==SEL_KEYPRESS) beep(); } return 0; // The grab might be broken; in FOX, we ignore this!! case WM_CANCELMODE: //FXTRACE((100,"WM_CANCELMODE\n")); return 0; // Capture changed case WM_CAPTURECHANGED: //FXTRACE((100,"WM_CAPTURECHANGED\n")); // FIXME send SEL_UNGRABBED? return 0; // Motion case WM_MOUSEMOVE: event.time=GetMessageTime(); pt.x=ptRoot.x=(int)((short)LOWORD(lParam)); pt.y=ptRoot.y=(int)((short)HIWORD(lParam)); ClientToScreen((HWND)hwnd,&ptRoot); event.root_x=ptRoot.x; event.root_y=ptRoot.y; event.state=fxmodifierkeys(); //FXTRACE((100,"WM_MOUSEMOVE hwnd=%d x=%d y=%d \n",hwnd,event.root_x,event.root_y)); // Reset hover timer addTimeout(this,ID_HOVER,200000000); // Set moved flag if((FXABS(event.root_x-event.rootclick_x)>=dragDelta) || (FXABS(event.root_y-event.rootclick_y)>=dragDelta)) event.moved=1; // Was grabbed if(mouseGrabWindow){ // Translate to grab window's coordinate system root->translateCoordinatesTo(event.win_x,event.win_y,mouseGrabWindow,event.root_x,event.root_y); // Moved out of/into rectangle of grabbed window if(0<=event.win_x && event.win_xgetWidth() && 0<=event.win_y && event.win_ygetHeight()){ window=mouseGrabWindow; } else{ window=mouseGrabWindow->getParent(); } } // Switched windows if(cursorWindow!=window){ ancestor=FXWindow::commonAncestor(window,cursorWindow); event.code=CROSSINGNORMAL; leaveWindow(cursorWindow,ancestor); enterWindow(window,ancestor); refresh(); } // Suppress spurious `tickling' motion events if(hwnd==lastmovehwnd && lParam==lastmovelParam) return 0; // Was still grabbed, but possibly new grab window! if(mouseGrabWindow){ // Translate to grab window's coordinate system root->translateCoordinatesTo(event.win_x,event.win_y,mouseGrabWindow,event.root_x,event.root_y); // Set event data event.type=SEL_MOTION; event.code=0; // Dispatch to grab-window if(mouseGrabWindow->handle(this,FXSEL(SEL_MOTION,0),&event)) refresh(); } // FIXME Does window still exist? // Was not grabbed else if(!invocation || invocation->modality==MODAL_FOR_NONE || (invocation->window && invocation->window->isOwnerOf(window)) || window->getShell()->doesSaveUnder()){ // FIXME doesSaveUnder test should go away // Set event data event.type=SEL_MOTION; event.code=0; event.win_x=pt.x; event.win_y=pt.y; // Dispatch to window under cursor if(window->handle(this,FXSEL(SEL_MOTION,0),&event)) refresh(); } // Update most recent mouse position event.last_x=pt.x; event.last_y=pt.y; // Remember this for tickling test lastmovehwnd=(HWND)hwnd; lastmovelParam=lParam; return 0; // Button case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: event.time=GetMessageTime(); event.win_x=pt.x=(int)((short)LOWORD(lParam)); event.win_y=pt.y=(int)((short)HIWORD(lParam)); ClientToScreen((HWND)hwnd,&pt); event.root_x=pt.x; event.root_y=pt.y; event.state=fxmodifierkeys(); // Get the state of the modifier keys and mouse buttons if(iMsg==WM_LBUTTONDOWN || iMsg==WM_MBUTTONDOWN || iMsg==WM_RBUTTONDOWN){ if(iMsg==WM_LBUTTONDOWN){ event.type=SEL_LEFTBUTTONPRESS; event.code=LEFTBUTTON; } if(iMsg==WM_MBUTTONDOWN){ event.type=SEL_MIDDLEBUTTONPRESS; event.code=MIDDLEBUTTON; } if(iMsg==WM_RBUTTONDOWN){ event.type=SEL_RIGHTBUTTONPRESS; event.code=RIGHTBUTTON; } if(!event.moved && (event.code==event.click_button) && (milliseconds*(event.time-event.click_time)translateCoordinatesTo(event.win_x,event.win_y,mouseGrabWindow,event.win_x,event.win_y); if(mouseGrabWindow->handle(this,FXSEL(event.type,0),&event)) refresh(); } // FIXME doesSaveUnder test should go away else if(!invocation || invocation->modality==MODAL_FOR_NONE || (invocation->window && invocation->window->isOwnerOf(window)) || window->getShell()->doesSaveUnder()){ if(window->handle(this,FXSEL(event.type,0),&event)) refresh(); } else if(iMsg==WM_LBUTTONDOWN || iMsg==WM_MBUTTONDOWN || iMsg==WM_RBUTTONDOWN){ beep(); } event.last_x=event.win_x; event.last_y=event.win_y; return 0; // Mouse wheel case WM_MOUSEWHEEL: event.type=SEL_MOUSEWHEEL; event.time=GetMessageTime(); event.root_x=pt.x=(int)((short)LOWORD(lParam)); event.root_y=pt.y=(int)((short)HIWORD(lParam)); event.code=(int)((short)HIWORD(wParam)); event.state=fxmodifierkeys(); // Get the state of the modifier keys and mouse buttons window=findWindowAt(event.root_x,event.root_y); if(window){ ScreenToClient((HWND)window->id(),&pt); event.win_x=pt.x; event.win_y=pt.y; if(mouseGrabWindow){ window->translateCoordinatesTo(event.win_x,event.win_y,mouseGrabWindow,event.win_x,event.win_y); if(mouseGrabWindow->handle(this,FXSEL(SEL_MOUSEWHEEL,0),&event)) refresh(); } else{ // FIXME doesSaveUnder test should go away while(window && (!invocation || invocation->modality==MODAL_FOR_NONE || (invocation->window && invocation->window->isOwnerOf(window)) || window->getShell()->doesSaveUnder())){ if(window->handle(this,FXSEL(SEL_MOUSEWHEEL,0),&event)){ refresh(); break; } window=window->getParent(); } } } return 0; // Focus case WM_SETFOCUS: SendMessage((HWND)window,WM_NCACTIVATE,1,123456); // Suggestion from: Frank De prins case WM_KILLFOCUS: window=window->getShell(); if(iMsg==WM_KILLFOCUS && activeWindow==window){ event.type=SEL_FOCUSOUT; if(window->handle(this,FXSEL(SEL_FOCUSOUT,0),&event)) refresh(); activeWindow=nullptr; } if(iMsg==WM_SETFOCUS && activeWindow!=window){ event.type=SEL_FOCUSIN; if(window->handle(this,FXSEL(SEL_FOCUSIN,0),&event)) refresh(); activeWindow=window; } return 0; // Map or Unmap case WM_SHOWWINDOW: if(wParam){ event.type=SEL_MAP; if(window->handle(this,FXSEL(SEL_MAP,0),&event)) refresh(); } else{ event.type=SEL_UNMAP; if(window->handle(this,FXSEL(SEL_UNMAP,0),&event)) refresh(); } return DefWindowProc((HWND)hwnd,iMsg,wParam,lParam); // Create case WM_CREATE: event.type=SEL_CREATE; window=(FXWindow*)(((LPCREATESTRUCT)lParam)->lpCreateParams); hash.insert((FXptr)hwnd,window); if(window->handle(this,FXSEL(SEL_CREATE,0),&event)) refresh(); return 0; // Close case WM_CLOSE: ////// Semantics: SEL_CLOSE is a suggestion that the window be closed; ////// SEL_DESTROY is a notify that destruction has already taken place. ////// Thus, a toplevel window gets a close, and MAY decide not to be closed; ////// If it thinks its OK to close, it gets a SEL_DESTROY also. event.type=SEL_CLOSE; if(!invocation || invocation->modality==MODAL_FOR_NONE || (invocation->window && invocation->window->isOwnerOf(window))){ if(window->handle(this,FXSEL(SEL_CLOSE,0),&event)) refresh(); } else{ beep(); } return 0; // Destroy case WM_DESTROY: event.type=SEL_DESTROY; if(window->handle(this,FXSEL(SEL_DESTROY,0),&event)) refresh(); return 0; // Configure (size) case WM_SIZE: switch(wParam){ case SIZE_MINIMIZED: // Send SEL_MINIMIZE to window if not yet minimized if(!IsIconic((HWND)hwnd)){ event.type=SEL_MINIMIZE; if(window->handle(this,FXSEL(SEL_MINIMIZE,0),&event)) refresh(); } break; case SIZE_MAXIMIZED: // Send SEL_MAXIMIZE to window if not yet maximized if(!IsZoomed((HWND)hwnd)){ event.type=SEL_MAXIMIZE; if(window->handle(this,FXSEL(SEL_MAXIMIZE,0),&event)) refresh(); } event.type=SEL_CONFIGURE; event.rect.x=window->getX(); event.rect.y=window->getY(); event.rect.w=LOWORD(lParam); event.rect.h=HIWORD(lParam); if(window->handle(this,FXSEL(SEL_CONFIGURE,0),&event)) refresh(); break; case SIZE_RESTORED: // Send SEL_RESTORE to window if maximized or minimized if(IsZoomed((HWND)hwnd) || IsIconic((HWND)hwnd)){ event.type=SEL_RESTORE; if(window->handle(this,FXSEL(SEL_RESTORE,0),&event)) refresh(); } case SIZE_MAXHIDE: case SIZE_MAXSHOW: event.type=SEL_CONFIGURE; event.rect.x=window->getX(); event.rect.y=window->getY(); event.rect.w=LOWORD(lParam); event.rect.h=HIWORD(lParam); if(window->handle(this,FXSEL(SEL_CONFIGURE,0),&event)) refresh(); break; } return 0; // Configure (move) case WM_MOVE: event.type=SEL_CONFIGURE; event.rect.x=(short)LOWORD(lParam); event.rect.y=(short)HIWORD(lParam); event.rect.w=window->getWidth(); event.rect.h=window->getHeight(); if(window->handle(this,FXSEL(SEL_CONFIGURE,0),&event)) refresh(); return 0; // Configure position and size case WM_WINDOWPOSCHANGED: return DefWindowProc((HWND)hwnd,iMsg,wParam,lParam); // Lost clipboard ownership case WM_DESTROYCLIPBOARD: if(clipboardWindow){ event.time=GetMessageTime(); event.type=SEL_CLIPBOARD_LOST; if(clipboardWindow->handle(this,FXSEL(SEL_CLIPBOARD_LOST,0),&event)) refresh(); clipboardWindow=nullptr; } return 0; // Safeguard it in the clipboard case WM_RENDERALLFORMATS: if(clipboardWindow){ OpenClipboard((HWND)hwnd); EmptyClipboard(); UINT iFormat=0; while((iFormat=EnumClipboardFormats(iFormat))!=0){ event.type=SEL_CLIPBOARD_REQUEST; event.time=GetMessageTime(); event.target=iFormat; if(clipboardWindow->handle(this,FXSEL(SEL_CLIPBOARD_REQUEST,0),&event)) refresh(); FXTRACE((100,"Window %d being requested for CLIPBOARD DATA of type %d\n",hwnd,wParam)); } CloseClipboard(); } return 0; // We're asked to provide certain format to the clipboard case WM_RENDERFORMAT: if(clipboardWindow){ event.type=SEL_CLIPBOARD_REQUEST; event.time=GetMessageTime(); event.target=(FXDragType)wParam; clipboardWindow->handle(this,FXSEL(SEL_CLIPBOARD_REQUEST,0),&event); FXTRACE((100,"Window %d being requested for CLIPBOARD DATA of type %d\n",hwnd,wParam)); } return 0; // Change the cursor based on the window case WM_SETCURSOR: if(waitCount){ SetCursor((HCURSOR)waitCursor->id()); // Show wait cursor return 0; } if(!mouseGrabWindow && window->getDefaultCursor() && (LOWORD(lParam)==HTCLIENT)){ SetCursor((HCURSOR)window->getDefaultCursor()->id()); // Show default cursor return 0; } return DefWindowProc((HWND)hwnd,iMsg,wParam,lParam); case WM_PALETTECHANGED: // Suggested by Boris Kogan if((HWND)wParam==hwnd) break; case WM_QUERYNEWPALETTE: if(window->getVisual()->colormap){ HDC hdc=GetDC((HWND)hwnd); HPALETTE paletteold=SelectPalette(hdc,(HPALETTE)window->getVisual()->colormap,false); UINT nchanged=RealizePalette(hdc); if(nchanged) InvalidateRect((HWND)hwnd,nullptr,true); SelectPalette(hdc,paletteold,true); ReleaseDC((HWND)hwnd,hdc); return nchanged; } return 0; case WM_QUERYENDSESSION: // Session will end if this app thinks its OK event.type=SEL_SESSION_NOTIFY; return !window->handle(this,FXSEL(SEL_SESSION_NOTIFY,0),&event); // Return 1 if OK to terminate case WM_ENDSESSION: // Session will now end for sure event.type=SEL_SESSION_CLOSED; if(wParam) window->handle(this,FXSEL(SEL_SESSION_CLOSED,0),&event); return 0; case WM_STYLECHANGING: case WM_SIZING: case WM_MOVING: return 0; case WM_ERASEBKGND: // Do nothing, erasing background causes flashing return 1; case WM_ACTIVATE: //FXTRACE((100,"WM_ACTIVATE %d\n",LOWORD(wParam))); if(window->isMemberOf(FXMETACLASS(FXTopWindow)) && activeWindow && activeWindow!=window){ // Suggestion from: Frank De prins SendMessage((HWND)activeWindow->id(),WM_NCACTIVATE,0,123456); } return DefWindowProc((HWND)hwnd,iMsg,wParam,lParam); case WM_GETMINMAXINFO: if(window->id() && window->shown() &&window->isMemberOf(FXMETACLASS(FXTopWindow))){ RECT rect; //FXTRACE((100,"WM_GETMINMAXINFO ptMaxSize=%d,%d ptMinTrackSize=%d,%d ptMaxTrackSize=%d,%d\n",((MINMAXINFO*)lParam)->ptMaxSize.x,((MINMAXINFO*)lParam)->ptMaxSize.y,((MINMAXINFO*)lParam)->ptMinTrackSize.x,((MINMAXINFO*)lParam)->ptMinTrackSize.y,((MINMAXINFO*)lParam)->ptMaxTrackSize.x,((MINMAXINFO*)lParam)->ptMaxTrackSize.y)); if(!(((FXTopWindow*)window)->getDecorations()&DECOR_SHRINKABLE)){ if(!(((FXTopWindow*)window)->getDecorations()&DECOR_STRETCHABLE)){ // Cannot change at all SetRect(&rect,0,0,window->getWidth(),window->getHeight()); //SetRect(&rect,0,0,window->getDefaultWidth(),window->getDefaultHeight()); AdjustWindowRectEx(&rect,GetWindowLong((HWND)hwnd,GWL_STYLE),false,GetWindowLong((HWND)hwnd,GWL_EXSTYLE)); ((MINMAXINFO*)lParam)->ptMinTrackSize.x=((MINMAXINFO*)lParam)->ptMaxTrackSize.x=rect.right-rect.left; ((MINMAXINFO*)lParam)->ptMinTrackSize.y=((MINMAXINFO*)lParam)->ptMaxTrackSize.y=rect.bottom-rect.top; } else{ // Cannot get smaller than default SetRect(&rect,0,0,window->getDefaultWidth(),window->getDefaultHeight()); AdjustWindowRectEx(&rect,GetWindowLong((HWND)hwnd,GWL_STYLE),false,GetWindowLong((HWND)hwnd,GWL_EXSTYLE)); ((MINMAXINFO*)lParam)->ptMinTrackSize.x=rect.right-rect.left; ((MINMAXINFO*)lParam)->ptMinTrackSize.y=rect.bottom-rect.top; } } else if(!(((FXTopWindow*)window)->getDecorations()&DECOR_STRETCHABLE)){ // Cannot get larger than default SetRect(&rect,0,0,window->getDefaultWidth(),window->getDefaultHeight()); AdjustWindowRectEx(&rect,GetWindowLong((HWND)hwnd,GWL_STYLE),false,GetWindowLong((HWND)hwnd,GWL_EXSTYLE)); ((MINMAXINFO*)lParam)->ptMaxTrackSize.x=rect.right-rect.left; ((MINMAXINFO*)lParam)->ptMaxTrackSize.y=rect.bottom-rect.top; } //FXTRACE((100,"width=%d height=%d\n",window->getWidth(),window->getHeight())); //FXTRACE((100,"WM_GETMINMAXINFO ptMaxSize=%d,%d ptMinTrackSize=%d,%d ptMaxTrackSize=%d,%d\n",((MINMAXINFO*)lParam)->ptMaxSize.x,((MINMAXINFO*)lParam)->ptMaxSize.y,((MINMAXINFO*)lParam)->ptMinTrackSize.x,((MINMAXINFO*)lParam)->ptMinTrackSize.y,((MINMAXINFO*)lParam)->ptMaxTrackSize.x,((MINMAXINFO*)lParam)->ptMaxTrackSize.y)); } return 0; case WM_INITMENU: // Patch from Robin Wilson case WM_SYSCOMMAND: // This pops down the menupane when clicking in non-client area for(win=getRootWindow()->getFirst(); win; win=win->getNext()){ // FIXME don't we already know popupWindow? if(win->shown() && win->isMemberOf(FXMETACLASS(FXMenuPane)) && window->containsChild(win->getOwner())) window->killFocus(); } return DefWindowProc((HWND)hwnd,iMsg,wParam,lParam); #if 0 case WM_ENTERSIZEMOVE: if(!repostimer){ repostimer=SetTimer((HWND)hwnd,1,10 /* lower doesn't work :( */,nullptr); return 0; } return DefWindowProc((HWND)hwnd,iMsg,wParam,lParam); case WM_EXITSIZEMOVE: if(repostimer){ KillTimer((HWND)hwnd,1); repostimer=0; return 0; } return DefWindowProc((HWND)hwnd,iMsg,wParam,lParam); case WM_TIMER: if(repostimer){ doIdleProcessing(); return 0; } return DefWindowProc((HWND)hwnd,iMsg,wParam,lParam); #endif case WM_INPUT: //event.type=SEL_SPACEBALLMOTION; //if(window->handle(this,FXSEL(event.type,0),(void *)lParam)) refresh(); return 0; case WM_TIMER: // added by msh 2/DEC/99 case WM_ENTERSIZEMOVE: case WM_EXITSIZEMOVE: case WM_ENTERMENULOOP: case WM_MENUCHAR: case WM_MENUSELECT: case WM_EXITMENULOOP: case WM_DISPLAYCHANGE: // added by msh 2/DEC/99 case WM_ENTERIDLE: // 24/NOV/99 md case WM_NCCREATE: case WM_NCDESTROY: case WM_PARENTNOTIFY: case WM_SETTEXT: case WM_GETTEXT: case WM_QUERYOPEN: case WM_ENABLE: case WM_MOUSEACTIVATE: case WM_CHILDACTIVATE: case WM_SYNCPAINT: case WM_NCPAINT: case WM_NCHITTEST: case WM_NCMOUSEMOVE: case WM_NCCALCSIZE: case WM_NCLBUTTONDOWN: case WM_NCLBUTTONUP: case WM_WINDOWPOSCHANGING: // Leave whatever placement is suggested case WM_STYLECHANGED: case WM_MOUSELEAVE: // We no longer use TrackMouseEvent it is not reliable return DefWindowProc((HWND)hwnd,iMsg,wParam,lParam); case WM_NCACTIVATE: // Suggestion from: Frank De prins if(lParam!=123456) wParam=1; return DefWindowProc((HWND)hwnd,iMsg,wParam,lParam); case WM_ACTIVATEAPP: // Suggestion from: Frank De prins SendMessage((HWND)hwnd,WM_NCACTIVATE,wParam,123456); return DefWindowProc((HWND)hwnd,iMsg,wParam,lParam); case WM_DROPFILES: //char ListFileName[MAX_PATH]; //HDROP hDropInfo=(HDROP)WParam; //DragQueryFile(hDropInfo,0,ListFileName,sizeof(ListFileName)-1); //numfiles = DragQueryFile(hDropInfo, (DWORD)(-1), (LPSTR)nullptr, 0); //for (fileindex=0; fileindexhandle(this,FXSEL(SEL_DND_LEAVE,0),&event)) refresh(); dropWindow=nullptr; } if(ddeTypeList){freeElms(ddeTypeList);ddeNumTypes=0;} xdndSource=0; return 0; case WM_DND_DROP: FXTRACE((100,"DNDDrop from remote window %d\n",lParam)); if(xdndSource!=(FXID)lParam) return 0; xdndFinishSent=false; event.type=SEL_DND_DROP; event.time=GetMessageTime(); // Perform drop operation on drop window if(!dropWindow || !dropWindow->handle(this,FXSEL(SEL_DND_DROP,0),&event)) ansAction=DRAG_REJECT; // Didn't sent finish yet if(!xdndFinishSent){ PostMessage((HWND)xdndSource,WM_DND_FINISH_REJECT+ansAction,0,(LPARAM)hwnd); } if(ddeTypeList){freeElms(ddeTypeList);ddeNumTypes=0;} dropWindow=nullptr; xdndSource=0; refresh(); return 0; case WM_DND_POSITION_REJECT: case WM_DND_POSITION_ASK: case WM_DND_POSITION_COPY: case WM_DND_POSITION_MOVE: case WM_DND_POSITION_LINK: case WM_DND_POSITION_PRIVATE: if(xdndSource!=(FXID)lParam) return 0; event.time=GetMessageTime(); event.root_x=(int)((short)LOWORD(wParam)); event.root_y=(int)((short)HIWORD(wParam)); win=findWindowAt(event.root_x,event.root_y); ddeAction=(FXDragAction)(iMsg-WM_DND_POSITION_REJECT); // Action encoded in message FXTRACE((100,"DNDPosition from remote window %d action %d\n",lParam,ddeAction)); ansAction=DRAG_REJECT; xdndRect.x=event.root_x; xdndRect.y=event.root_y; xdndRect.w=1; xdndRect.h=1; if(win!=dropWindow){ if(dropWindow){ event.type=SEL_DND_LEAVE; if(dropWindow->handle(this,FXSEL(SEL_DND_LEAVE,0),&event)) refresh(); } dropWindow=nullptr; if(win && win->isDropEnabled()){ dropWindow=win; event.type=SEL_DND_ENTER; if(dropWindow->handle(this,FXSEL(SEL_DND_ENTER,0),&event)) refresh(); } } if(dropWindow){ pt.x=event.root_x; pt.y=event.root_y; ScreenToClient((HWND)dropWindow->id(),&pt); event.win_x=pt.x; event.win_y=pt.y; event.type=SEL_DND_MOTION; if(dropWindow->handle(this,FXSEL(SEL_DND_MOTION,0),&event)) refresh(); event.last_x=event.win_x; event.last_y=event.win_y; } FXTRACE((100,"accepting %d\n",ansAction)); PostMessage((HWND)xdndSource,WM_DND_STATUS_REJECT+ansAction,MAKELONG(xdndRect.x,xdndRect.y),MAKELONG(xdndRect.w,xdndRect.h)); return 0; case WM_DND_STATUS_REJECT: case WM_DND_STATUS_ASK: case WM_DND_STATUS_COPY: case WM_DND_STATUS_MOVE: case WM_DND_STATUS_LINK: case WM_DND_STATUS_PRIVATE: ansAction=(FXDragAction)(iMsg-WM_DND_STATUS_REJECT); xdndRect.x=(int)((short)LOWORD(wParam)); xdndRect.y=(int)((short)HIWORD(wParam)); xdndRect.w=(int)((short)LOWORD(lParam)); xdndRect.h=(int)((short)HIWORD(lParam)); xdndStatusReceived=true; xdndStatusPending=false; FXTRACE((100,"DNDStatus from remote window action=%d rect x=%d y=%d w=%d h=%d\n",ansAction,xdndRect.x,xdndRect.y,xdndRect.w,xdndRect.h)); return 0; case WM_DND_REQUEST: answer=0; if(dragWindow){ event.type=SEL_DND_REQUEST; event.time=GetMessageTime(); event.target=(FXDragType)wParam; ddeData=nullptr; ddeSize=0; dragWindow->handle(this,FXSEL(SEL_DND_REQUEST,0),&event); FXTRACE((100,"Window %d being requested by window %d for XDND DATA of type %d; sending %d bytes\n",hwnd,lParam,wParam,ddeSize)); answer=fxsenddata((HWND)lParam,ddeData,ddeSize); freeElms(ddeData); ddeData=nullptr; ddeSize=0; } FXTRACE((100,"sending handle %d from window %d to %d\n",answer,hwnd,lParam)); PostMessage((HWND)lParam,WM_DND_REPLY,(WPARAM)answer,(LPARAM)hwnd); return 0; case WM_COPYDATA: return window->handle(this,FXSEL(SEL_COPYDATA,0),(void*)lParam); } return DefWindowProc((HWND)hwnd,iMsg,wParam,lParam); } #endif // Handle quit long FXApp::onCmdQuit(FXObject*,FXSelector,void*){ exit(0); return 1; } /*******************************************************************************/ // Return key state FXbool FXApp::getKeyState(FXuint keysym) const { #if defined(WIN32) return GetKeyState(keysym)!=0; #else KeyCode keycode=XKeysymToKeycode((Display*)display,keysym); char keys[32]; if(keycode==NoSymbol) return false; XQueryKeymap((Display*)display,keys); return (keys[keycode>>3]>>(keycode&7))&1; #endif } // Beep void FXApp::beep(){ if(initialized){ FXTRACE((100,"Beep\n")); #if defined(WIN32) MessageBeep(0); #else XBell((Display*)display,0); #endif } } // Dump widgets long FXApp::onCmdDump(FXObject*,FXSelector,void*){ dumpWidgets(); return 1; } // Dump widget information void FXApp::dumpWidgets() const { FXWindow *w=getRootWindow(); FXObject *t; FXint lev=0; FXchar s; while(w){ t=w->getTarget(); s=w->shown()?'+':'-'; if(t){ fxmessage("%*c%s (%p): wk=%d id=%lu target=%s (%p) sel=%d x=%d y=%d w=%d h=%d\n",lev*2,s,w->getClassName(),w,w->getKey(),w->id(),t->getClassName(),t,w->getSelector(),w->getX(),w->getY(),w->getWidth(),w->getHeight()); } else{ fxmessage("%*c%s (%p): wk=%d id=%lu x=%d y=%d w=%d h=%d\n",lev*2,s,w->getClassName(),w,w->getKey(),w->id(),w->getX(),w->getY(),w->getWidth(),w->getHeight()); } if(w->getFirst()){ w=w->getFirst(); lev++; continue; } while(!w->getNext() && w->getParent()){ w=w->getParent(); lev--; if(lev==1) fxmessage("\n"); } w=w->getNext(); } } // Save to stream void FXApp::save(FXStream& store) const { FXObject::save(store); store << clickSpeed; store << animSpeed; store << scrollSpeed; store << blinkSpeed; store << menuPause; store << toolTipPause; store << toolTipTime; store << autoHideDelay; store << dragDelta; store << borderColor; store << baseColor; store << hiliteColor; store << shadowColor; store << backColor; store << foreColor; store << selforeColor; store << selbackColor; store << tipforeColor; store << tipbackColor; store << selMenuTextColor; store << selMenuBackColor; } // Load from stream void FXApp::load(FXStream& store){ FXObject::load(store); store >> clickSpeed; store >> animSpeed; store >> scrollSpeed; store >> blinkSpeed; store >> menuPause; store >> toolTipPause; store >> toolTipTime; store >> autoHideDelay; store >> dragDelta; store >> borderColor; store >> baseColor; store >> hiliteColor; store >> shadowColor; store >> backColor; store >> foreColor; store >> selforeColor; store >> selbackColor; store >> tipforeColor; store >> tipbackColor; store >> selMenuTextColor; store >> selMenuBackColor; } // Change typing speed void FXApp::setTypingSpeed(FXTime speed){ typingSpeed=speed; } // Change double-click speed void FXApp::setClickSpeed(FXTime speed){ clickSpeed=speed; } // Change scroll speed void FXApp::setScrollSpeed(FXTime speed){ scrollSpeed=speed; } // Change scroll delay void FXApp::setScrollDelay(FXTime delay){ scrollDelay=delay; } // Change cursor blink speed void FXApp::setBlinkSpeed(FXTime speed){ blinkSpeed=speed; } // Change animation speed void FXApp::setAnimSpeed(FXTime speed){ animSpeed=speed; } // Change menu popup delay void FXApp::setMenuPause(FXTime pause){ menuPause=pause; } // Change tooltip popup pause void FXApp::setToolTipPause(FXTime pause){ toolTipPause=pause; } // Change tooltip visibility time void FXApp::setToolTipTime(FXTime time){ toolTipTime=time; } // Change autohide delay time void FXApp::setAutoHideDelay(FXTime time){ autoHideDelay=time; } // Change drag delta void FXApp::setDragDelta(FXint delta){ dragDelta=delta; } // Change mouse wheel lines void FXApp::setWheelLines(FXint lines){ wheelLines=lines; } // Change scroll bar size void FXApp::setScrollBarSize(FXint size){ scrollBarSize=size; } // Change border color void FXApp::setBorderColor(FXColor color){ borderColor=color; } // Change base color void FXApp::setBaseColor(FXColor color){ baseColor=color; } // Change highlight color void FXApp::setHiliteColor(FXColor color){ hiliteColor=color; } // Change shadow color void FXApp::setShadowColor(FXColor color){ shadowColor=color; } // Change background color void FXApp::setBackColor(FXColor color){ backColor=color; } // Change foreground color void FXApp::setForeColor(FXColor color){ foreColor=color; } // Change selected foreground color void FXApp::setSelforeColor(FXColor color){ selforeColor=color; } // Change selected background color void FXApp::setSelbackColor(FXColor color){ selbackColor=color; } // Change tip foreground color void FXApp::setTipforeColor(FXColor color){ tipforeColor=color; } // Change tip background color void FXApp::setTipbackColor(FXColor color){ tipbackColor=color; } // Change selected menu text color void FXApp::setSelMenuTextColor(FXColor color){ selMenuTextColor=color; } // Change selected menu back color void FXApp::setSelMenuBackColor(FXColor color){ selMenuBackColor=color; } // Virtual destructor FXApp::~FXApp(){ FXRepaint *r; FXTimer *t; FXChore *c; // Close display closeDisplay(); // Delete root window & its children delete root; // Delete visuals delete defaultVisual; delete monoVisual; // Delete stock font only delete stockFont; // Delete cursors delete cursor[DEF_ARROW_CURSOR]; delete cursor[DEF_RARROW_CURSOR]; delete cursor[DEF_TEXT_CURSOR]; delete cursor[DEF_HSPLIT_CURSOR]; delete cursor[DEF_VSPLIT_CURSOR]; delete cursor[DEF_XSPLIT_CURSOR]; delete cursor[DEF_SWATCH_CURSOR]; delete cursor[DEF_MOVE_CURSOR]; delete cursor[DEF_DRAGH_CURSOR]; delete cursor[DEF_DRAGV_CURSOR]; delete cursor[DEF_DRAGTR_CURSOR]; delete cursor[DEF_DRAGTL_CURSOR]; delete cursor[DEF_DNDSTOP_CURSOR]; delete cursor[DEF_DNDASK_CURSOR]; delete cursor[DEF_DNDCOPY_CURSOR]; delete cursor[DEF_DNDMOVE_CURSOR]; delete cursor[DEF_DNDLINK_CURSOR]; delete cursor[DEF_CROSSHAIR_CURSOR]; delete cursor[DEF_CORNERNE_CURSOR]; delete cursor[DEF_CORNERNW_CURSOR]; delete cursor[DEF_CORNERSE_CURSOR]; delete cursor[DEF_CORNERSW_CURSOR]; delete cursor[DEF_HELP_CURSOR]; delete cursor[DEF_HAND_CURSOR]; delete cursor[DEF_ROTATE_CURSOR]; delete cursor[DEF_BLANK_CURSOR]; delete cursor[DEF_WAIT_CURSOR]; // Delete translator delete translator; // Free inputs and handles freeElms(inputs); freeElms(handles); // Free signals list freeElms(signals); // Free left-over dde data freeElms(ddeData); ddeSize=0; // Free left-over selection type data #if defined(WIN32) freeElms(xselTypeList); freeElms(ddeTypeList); #else freeElms(xselTypeList); freeElms(xcbTypeList); freeElms(xdndTypeList); freeElms(ddeTypeList); #endif // Remove outstanding repaints while(repaints){ r=repaints; repaints=repaints->next; delete r; } // Free recycled repaint records while(repaintrecs){ r=repaintrecs; repaintrecs=repaintrecs->next; delete r; } // Kill outstanding timers while(timers){ t=timers; timers=timers->next; delete t; } // Free recycled timer records while(timerrecs){ t=timerrecs; timerrecs=timerrecs->next; delete t; } // Kill outstanding chores while(chores){ c=chores; chores=chores->next; delete c; } // Free recycled chore records while(chorerecs){ c=chorerecs; chorerecs=chorerecs->next; delete c; } // Thrash dangling pointers root=(FXRootWindow*)-1L; defaultVisual=(FXVisual*)-1L; monoVisual=(FXVisual*)-1L; normalFont=(FXFont*)-1L; stockFont=(FXFont*)-1L; waitCursor=(FXCursor*)-1L; signals=(FXSignal*)-1L; // Zap cursors cursor[DEF_ARROW_CURSOR]=(FXCursor*)-1L; cursor[DEF_RARROW_CURSOR]=(FXCursor*)-1L; cursor[DEF_TEXT_CURSOR]=(FXCursor*)-1L; cursor[DEF_HSPLIT_CURSOR]=(FXCursor*)-1L; cursor[DEF_VSPLIT_CURSOR]=(FXCursor*)-1L; cursor[DEF_XSPLIT_CURSOR]=(FXCursor*)-1L; cursor[DEF_SWATCH_CURSOR]=(FXCursor*)-1L; cursor[DEF_MOVE_CURSOR]=(FXCursor*)-1L; cursor[DEF_DRAGH_CURSOR]=(FXCursor*)-1L; cursor[DEF_DRAGV_CURSOR]=(FXCursor*)-1L; cursor[DEF_DRAGTL_CURSOR]=(FXCursor*)-1L; cursor[DEF_DRAGTR_CURSOR]=(FXCursor*)-1L; cursor[DEF_DNDSTOP_CURSOR]=(FXCursor*)-1L; cursor[DEF_DNDASK_CURSOR]=(FXCursor*)-1L; cursor[DEF_DNDCOPY_CURSOR]=(FXCursor*)-1L; cursor[DEF_DNDMOVE_CURSOR]=(FXCursor*)-1L; cursor[DEF_DNDLINK_CURSOR]=(FXCursor*)-1L; cursor[DEF_CROSSHAIR_CURSOR]=(FXCursor*)-1L; cursor[DEF_CORNERNE_CURSOR]=(FXCursor*)-1L; cursor[DEF_CORNERNW_CURSOR]=(FXCursor*)-1L; cursor[DEF_CORNERSE_CURSOR]=(FXCursor*)-1L; cursor[DEF_CORNERSW_CURSOR]=(FXCursor*)-1L; cursor[DEF_HELP_CURSOR]=(FXCursor*)-1L; cursor[DEF_HAND_CURSOR]=(FXCursor*)-1L; cursor[DEF_ROTATE_CURSOR]=(FXCursor*)-1L; cursor[DEF_BLANK_CURSOR]=(FXCursor*)-1L; cursor[DEF_WAIT_CURSOR]=(FXCursor*)-1L; // Do this last app=nullptr; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXArray.cpp000066400000000000000000000070101455751074500216220ustar00rootroot00000000000000/******************************************************************************** * * * G e n e r i c A r r a y * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXElement.h" #include "FXArray.h" /* Notes: - FXArrayBase manages the gory details of the buffer representation: an item count followed by the items themselves. - The chosen representation allows an empty array to take up very minimal space only; basically, just a pointer to the memory buffer. - The buffer pointer is never NULL; thus its always safe to reference the buffer pointer. - Alignment is assumed to be 8 for 64-bit systems and 4 for 32-bit systems, same as malloc() returns. - Note sizeof(FXival) == sizeof(FXptr). */ // Special empty array value #define EMPTY (const_cast((const void*)(__array__empty__+1))) using namespace FX; /*******************************************************************************/ namespace FX { // Empty array value extern const FXival __array__empty__[]; const FXival __array__empty__[2]={0,0}; // Copying empty array uses same empty-array pointer regardless of // subclass; if array is non-empty, subclass does the actual copying. FXArrayBase::FXArrayBase():ptr(EMPTY){ } // Resize the array to num elements of size sz; if size becomes zero, // substitute special empty-array pointer again which contains zero // elements of any type. FXbool FXArrayBase::resize(FXival num,FXival sz){ FXival old=*(((FXival*)ptr)-1); if(__likely(old!=num)){ FXptr p; if(0 * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FXArrowButton.h" /* Notes: - Automatic mode works by simply hovering cursor over arrow button; it is used for scrolling menus. - Possible interactions between auto mode and manual pressing.. */ // Justification #define JUSTIFY_MASK (JUSTIFY_HZ_APART|JUSTIFY_VT_APART) // Arrow styles #define ARROW_MASK (ARROW_UP|ARROW_DOWN|ARROW_LEFT|ARROW_RIGHT|ARROW_AUTO|ARROW_REPEAT|ARROW_AUTOGRAY|ARROW_AUTOHIDE|ARROW_TOOLBAR) using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXArrowButton) FXArrowButtonMap[]={ FXMAPFUNC(SEL_UPDATE,0,FXArrowButton::onUpdate), FXMAPFUNC(SEL_PAINT,0,FXArrowButton::onPaint), FXMAPFUNC(SEL_ENTER,0,FXArrowButton::onEnter), FXMAPFUNC(SEL_LEAVE,0,FXArrowButton::onLeave), FXMAPFUNC(SEL_TIMEOUT,FXArrowButton::ID_AUTO,FXArrowButton::onAuto), FXMAPFUNC(SEL_TIMEOUT,FXArrowButton::ID_REPEAT,FXArrowButton::onRepeat), FXMAPFUNC(SEL_LEFTBUTTONPRESS,0,FXArrowButton::onLeftBtnPress), FXMAPFUNC(SEL_LEFTBUTTONRELEASE,0,FXArrowButton::onLeftBtnRelease), FXMAPFUNC(SEL_QUERY_TIP,0,FXArrowButton::onQueryTip), FXMAPFUNC(SEL_QUERY_HELP,0,FXArrowButton::onQueryHelp), FXMAPFUNC(SEL_UNGRABBED,0,FXArrowButton::onUngrabbed), FXMAPFUNC(SEL_KEYPRESS,0,FXArrowButton::onKeyPress), FXMAPFUNC(SEL_KEYRELEASE,0,FXArrowButton::onKeyRelease), FXMAPFUNC(SEL_KEYPRESS,FXArrowButton::ID_HOTKEY,FXArrowButton::onHotKeyPress), FXMAPFUNC(SEL_KEYRELEASE,FXArrowButton::ID_HOTKEY,FXArrowButton::onHotKeyRelease), FXMAPFUNC(SEL_COMMAND,FXArrowButton::ID_SETHELPSTRING,FXArrowButton::onCmdSetHelp), FXMAPFUNC(SEL_COMMAND,FXArrowButton::ID_GETHELPSTRING,FXArrowButton::onCmdGetHelp), FXMAPFUNC(SEL_COMMAND,FXArrowButton::ID_SETTIPSTRING,FXArrowButton::onCmdSetTip), FXMAPFUNC(SEL_COMMAND,FXArrowButton::ID_GETTIPSTRING,FXArrowButton::onCmdGetTip), }; // Object implementation FXIMPLEMENT(FXArrowButton,FXFrame,FXArrowButtonMap,ARRAYNUMBER(FXArrowButtonMap)) // For deserialization FXArrowButton::FXArrowButton(){ flags|=FLAG_ENABLED; arrowColor=0; arrowSize=9; state=false; fired=false; } // Make a text button FXArrowButton::FXArrowButton(FXComposite* p,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb):FXFrame(p,opts,x,y,w,h,pl,pr,pt,pb){ flags|=FLAG_ENABLED; target=tgt; message=sel; arrowColor=getApp()->getForeColor(); arrowSize=9; state=false; fired=false; } // Get default size FXint FXArrowButton::getDefaultWidth(){ return padleft+padright+arrowSize+(border<<1); } FXint FXArrowButton::getDefaultHeight(){ return padtop+padbottom+arrowSize+(border<<1); } // Enable the window void FXArrowButton::enable(){ if(!(flags&FLAG_ENABLED)){ FXFrame::enable(); update(); } } // Disable the window void FXArrowButton::disable(){ if(flags&FLAG_ENABLED){ FXFrame::disable(); update(); } } // Set button state void FXArrowButton::setState(FXbool s){ if(state!=s){ state=s; update(); } } // If window can have focus FXbool FXArrowButton::canFocus() const { return true; } // Implement auto-hide or auto-gray modes long FXArrowButton::onUpdate(FXObject* sender,FXSelector sel,void* ptr){ if(!FXFrame::onUpdate(sender,sel,ptr)){ if(options&ARROW_AUTOHIDE){if(shown()){hide();recalc();}} if(options&ARROW_AUTOGRAY){disable();} } return 1; } // Press automatically long FXArrowButton::onAuto(FXObject*,FXSelector,void*){ setState(true); getApp()->addTimeout(this,ID_REPEAT,getApp()->getScrollSpeed()); flags&=~FLAG_UPDATE; fired=false; return 1; } // Entered button long FXArrowButton::onEnter(FXObject* sender,FXSelector sel,void* ptr){ FXFrame::onEnter(sender,sel,ptr); if(isEnabled()){ if(flags&FLAG_PRESSED){ setState(true); } else if(options&ARROW_AUTO){ if(options&ARROW_REPEAT) getApp()->addTimeout(this,ID_AUTO,getApp()->getScrollDelay()); } if(options&ARROW_TOOLBAR) update(); } return 1; } // Left button long FXArrowButton::onLeave(FXObject* sender,FXSelector sel,void* ptr){ FXFrame::onLeave(sender,sel,ptr); if(isEnabled()){ if(flags&FLAG_PRESSED){ setState(false); } else if(options&ARROW_AUTO){ setState(false); if(options&ARROW_REPEAT) getApp()->removeTimeout(this,ID_AUTO); flags|=FLAG_UPDATE; fired=false; } if(options&ARROW_TOOLBAR) update(); } return 1; } // Pressed mouse button long FXArrowButton::onLeftBtnPress(FXObject*,FXSelector,void* ptr){ handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr); flags&=~FLAG_TIP; if(isEnabled() && !(flags&FLAG_PRESSED)){ grab(); if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONPRESS,message),ptr)) return 1; setState(true); getApp()->removeTimeout(this,ID_AUTO); if(options&ARROW_REPEAT) getApp()->addTimeout(this,ID_REPEAT,getApp()->getScrollDelay()); flags|=FLAG_PRESSED; flags&=~FLAG_UPDATE; fired=false; return 1; } return 0; } // Released mouse button long FXArrowButton::onLeftBtnRelease(FXObject*,FXSelector,void* ptr){ FXbool click=(!fired && state); if(isEnabled() && (flags&FLAG_PRESSED)){ ungrab(); flags|=FLAG_UPDATE; flags&=~FLAG_PRESSED; fired=false; getApp()->removeTimeout(this,ID_REPEAT); if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONRELEASE,message),ptr)) return 1; setState(false); if(click && target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXuval)1); return 1; } return 0; } // Lost the grab for some reason long FXArrowButton::onUngrabbed(FXObject* sender,FXSelector sel,void* ptr){ FXFrame::onUngrabbed(sender,sel,ptr); setState(false); getApp()->removeTimeout(this,ID_REPEAT); flags&=~FLAG_PRESSED; flags|=FLAG_UPDATE; fired=false; return 1; } // Repeat a click automatically long FXArrowButton::onRepeat(FXObject*,FXSelector,void*){ getApp()->addTimeout(this,ID_REPEAT,getApp()->getScrollSpeed()); if(state && target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXuval)1); fired=true; return 1; } // Key Press long FXArrowButton::onKeyPress(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; flags&=~FLAG_TIP; if(isEnabled()){ if(target && target->tryHandle(this,FXSEL(SEL_KEYPRESS,message),ptr)) return 1; if(!(flags&FLAG_PRESSED) && (event->code==KEY_space || event->code==KEY_KP_Space)){ setState(true); getApp()->removeTimeout(this,ID_AUTO); if(options&ARROW_REPEAT) getApp()->addTimeout(this,ID_REPEAT,getApp()->getScrollDelay()); flags|=FLAG_PRESSED; flags&=~FLAG_UPDATE; fired=false; return 1; } } return 0; } // Key Release long FXArrowButton::onKeyRelease(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; FXbool click=(!fired && state); if(isEnabled()){ if(target && target->tryHandle(this,FXSEL(SEL_KEYRELEASE,message),ptr)) return 1; if((flags&FLAG_PRESSED) && (event->code==KEY_space || event->code==KEY_KP_Space)){ setState(false); flags|=FLAG_UPDATE; flags&=~FLAG_PRESSED; fired=false; getApp()->removeTimeout(this,ID_REPEAT); if(click && target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXuval)1); return 1; } } return 0; } // Hot key combination pressed long FXArrowButton::onHotKeyPress(FXObject*,FXSelector,void* ptr){ flags&=~FLAG_TIP; handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr); if(isEnabled() && !(flags&FLAG_PRESSED)){ setState(true); getApp()->removeTimeout(this,ID_AUTO); if(options&ARROW_REPEAT) getApp()->addTimeout(this,ID_REPEAT,getApp()->getScrollDelay()); flags|=FLAG_PRESSED; flags&=~FLAG_UPDATE; fired=false; } return 1; } // Hot key combination released long FXArrowButton::onHotKeyRelease(FXObject*,FXSelector,void*){ FXbool click=(!fired && state); if(isEnabled() && (flags&FLAG_PRESSED)){ setState(false); flags|=FLAG_UPDATE; flags&=~FLAG_PRESSED; fired=false; getApp()->removeTimeout(this,ID_REPEAT); if(click && target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXuval)1); } return 1; } // Set help using a message long FXArrowButton::onCmdSetHelp(FXObject*,FXSelector,void* ptr){ setHelpText(*((FXString*)ptr)); return 1; } // Get help using a message long FXArrowButton::onCmdGetHelp(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getHelpText(); return 1; } // Set tip using a message long FXArrowButton::onCmdSetTip(FXObject*,FXSelector,void* ptr){ setTipText(*((FXString*)ptr)); return 1; } // Get tip using a message long FXArrowButton::onCmdGetTip(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getTipText(); return 1; } // We were asked about tip text long FXArrowButton::onQueryTip(FXObject* sender,FXSelector sel,void* ptr){ if(FXFrame::onQueryTip(sender,sel,ptr)) return 1; if((flags&FLAG_TIP) && !tip.empty()){ sender->handle(this,FXSEL(SEL_COMMAND,ID_SETSTRINGVALUE),(void*)&tip); return 1; } return 0; } // We were asked about status text long FXArrowButton::onQueryHelp(FXObject* sender,FXSelector sel,void* ptr){ if(FXFrame::onQueryHelp(sender,sel,ptr)) return 1; if((flags&FLAG_HELP) && !help.empty()){ sender->handle(this,FXSEL(SEL_COMMAND,ID_SETSTRINGVALUE),(void*)&help); return 1; } return 0; } // Handle repaint long FXArrowButton::onPaint(FXObject*,FXSelector,void* ptr){ FXEvent *ev=(FXEvent*)ptr; FXDCWindow dc(this,ev); FXPoint points[3]; FXint xx,yy,ww,hh,q; // With borders if(options&(FRAME_RAISED|FRAME_SUNKEN)){ // Toolbar style if(options&ARROW_TOOLBAR){ // Enabled and cursor inside, and up if(isEnabled() && underCursor() && !state){ dc.setForeground(backColor); dc.fillRectangle(border,border,width-border*2,height-border*2); if(options&FRAME_THICK) drawDoubleRaisedRectangle(dc,0,0,width,height); else drawRaisedRectangle(dc,0,0,width,height); } // Enabled and cursor inside and down else if(isEnabled() && state){ dc.setForeground(hiliteColor); dc.fillRectangle(border,border,width-border*2,height-border*2); if(options&FRAME_THICK) drawDoubleSunkenRectangle(dc,0,0,width,height); else drawSunkenRectangle(dc,0,0,width,height); } // Disabled or unchecked or not under cursor else{ dc.setForeground(backColor); dc.fillRectangle(0,0,width,height); } } // Normal style else{ // Draw sunken if enabled and pressed if(isEnabled() && state){ dc.setForeground(hiliteColor); dc.fillRectangle(border,border,width-border*2,height-border*2); if(options&FRAME_THICK) drawDoubleSunkenRectangle(dc,0,0,width,height); else drawSunkenRectangle(dc,0,0,width,height); } // Draw in up state if disabled or up else{ dc.setForeground(backColor); dc.fillRectangle(border,border,width-border*2,height-border*2); if(options&FRAME_THICK) drawDoubleRaisedRectangle(dc,0,0,width,height); else drawRaisedRectangle(dc,0,0,width,height); } } } // No borders else{ if(isEnabled() && state){ dc.setForeground(hiliteColor); dc.fillRectangle(0,0,width,height); } else{ dc.setForeground(backColor); dc.fillRectangle(0,0,width,height); } } // Compute size of the arrows.... ww=width-padleft-padright-(border<<1); hh=height-padtop-padbottom-(border<<1); if(options&(ARROW_UP|ARROW_DOWN)){ q=(ww-1)|1; if((q>>1)>hh) q=(hh<<1)-1; ww=q; hh=q>>1; } else{ q=(hh-1)|1; if((q>>1)>ww) q=(ww<<1)-1; ww=q>>1; hh=q; } if(options&JUSTIFY_LEFT) xx=padleft+border; else if(options&JUSTIFY_RIGHT) xx=width-ww-padright-border; else xx=(width-ww)/2; if(options&JUSTIFY_TOP) yy=padtop+border; else if(options&JUSTIFY_BOTTOM) yy=height-hh-padbottom-border; else yy=(height-hh)/2; if(state){ ++xx; ++yy; } if(isEnabled()) dc.setForeground(arrowColor); else dc.setForeground(shadowColor); // NB Size of arrow should stretch if(options&ARROW_UP){ points[0].x=xx+(ww>>1); points[0].y=yy-1; points[1].x=xx; points[1].y=yy+hh; points[2].x=xx+ww; points[2].y=yy+hh; dc.fillPolygon(points,3); } else if(options&ARROW_DOWN){ points[0].x=xx+1; points[0].y=yy; points[1].x=xx+ww-1; points[1].y=yy; points[2].x=xx+(ww>>1); points[2].y=yy+hh; dc.fillPolygon(points,3); } else if(options&ARROW_LEFT){ points[0].x=xx+ww; points[0].y=yy; points[1].x=xx+ww; points[1].y=yy+hh-1; points[2].x=xx; points[2].y=yy+(hh>>1); dc.fillPolygon(points,3); } else if(options&ARROW_RIGHT){ points[0].x=xx; points[0].y=yy; points[1].x=xx; points[1].y=yy+hh-1; points[2].x=xx+ww; points[2].y=yy+(hh>>1); dc.fillPolygon(points,3); } return 1; } // Set arrow style void FXArrowButton::setArrowStyle(FXuint style){ FXuint opts=(options&~ARROW_MASK) | (style&ARROW_MASK); if(options!=opts){ options=opts; update(); } } // Get arrow style FXuint FXArrowButton::getArrowStyle() const { return (options&ARROW_MASK); } // Set default arrow size void FXArrowButton::setArrowSize(FXint size){ if(size!=arrowSize){ arrowSize=size; recalc(); } } // Set text color void FXArrowButton::setArrowColor(FXColor clr){ if(clr!=arrowColor){ arrowColor=clr; update(); } } // Set text justify style void FXArrowButton::setJustify(FXuint style){ FXuint opts=(options&~JUSTIFY_MASK) | (style&JUSTIFY_MASK); if(options!=opts){ options=opts; update(); } } // Get text justify style FXuint FXArrowButton::getJustify() const { return (options&JUSTIFY_MASK); } // Save object to stream void FXArrowButton::save(FXStream& store) const { FXFrame::save(store); store << arrowColor; store << arrowSize; } // Load object from stream void FXArrowButton::load(FXStream& store){ FXFrame::load(store); store >> arrowColor; store >> arrowSize; } // Kill the timer FXArrowButton::~FXArrowButton(){ getApp()->removeTimeout(this,ID_AUTO); getApp()->removeTimeout(this,ID_REPEAT); } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXAtomic.cpp000066400000000000000000001037161455751074500217720ustar00rootroot00000000000000/******************************************************************************** * * * A t o m i c O p e r a t i o n s * * * ********************************************************************************* * Copyright (C) 2006,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXAtomic.h" /* Notes: - THIS LIBRARY REQUIRES LOCKING PRIMITIVES NOT PRESENT ON OLDER MACHINES. In the x86 world, you're good on PentiumPro or newer. - Code intended to run on ancient hardware CAN NOT use features only present on modern processors; you should write your software to use operating-system provided locking features such as mutexes and semaphores instead! - You can test using atomicsAvailable() to see if these primitives are atomic. - The API's are function calls rather than inlines in the header files because naive programmers don't specify "submodel" options and may not get the inten- ded code generation compared to what FOX was compiled with. The problem is compilers tend to generate code for trailing-edge processor targets unless told to do otherwise. - We generate locking primitives using in-line assembly in preference to the GCC builtins, whenever possible. Just because the version of GCC has the builtins doesn't mean it'll generate them since that depends on submodel options being set properly! - For optimal performance, keep your atomic variables in their own cache-line; threads monitoring atomic variables (e.g. spinlocks) will cause bus traffic whenever shared cachelines are updated, even if its not the variable itself but something close to it in the same cacheline. */ // New __atomic_XXX() builtins are available #if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))) #define HAVE_BUILTIN_ATOMIC 1 #endif // Older __sync_XXX() builtins are available #if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 1))) #define HAVE_BUILTIN_SYNC 1 #endif // Can we use inline-assembly #if (defined(__GNUC__) || defined(__INTEL_COMPILER)) #define HAVE_INLINE_ASSEMBLY 1 #endif using namespace FX; namespace FX { /*******************************************************************************/ // Atomics are available FXbool atomicsAvailable(){ #if defined(WIN32) && (_MSC_VER >= 1500) return true; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__)) return true; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__x86_64__)) return true; #elif defined(HAVE_BUILTIN_ATOMIC) return true; #elif defined(HAVE_BUILTIN_SYNC) return true; #else return false; #endif } // Load/store fence void atomicThreadFence(){ #if defined(WIN32) && (_MSC_VER >= 1500) _ReadWriteBarrier(); #elif defined(HAVE_BUILTIN_ATOMIC) __atomic_thread_fence(__ATOMIC_SEQ_CST); #elif defined(HAVE_BUILTIN_SYNC) __sync_synchronize(); #endif } /*******************************************************************************/ // Atomic read; necessary as it serializes reads and writes prior to this one FXint atomicRead(volatile FXint* ptr){ #if defined(WIN32) && (_MSC_VER >= 1500) return _InterlockedCompareExchange((volatile LONG*)ptr,0,0); #elif defined(HAVE_BUILTIN_ATOMIC) return __atomic_load_n(ptr,__ATOMIC_SEQ_CST); #elif defined(HAVE_BUILTIN_SYNC) return __sync_val_compare_and_swap(ptr,0,0); #elif (defined(HAVE_INLINE_ASSEMBLY) && (defined(__i386__) || defined(__x86_64__))) FXint ret=0; __asm__ __volatile__("lock\n\t" "cmpxchgl %2, (%1)\n\t" : "=a"(ret) : "r"(ptr), "r"(ret), "a"(ret) : "memory", "cc"); return ret; #else return *ptr; #endif } // Atomic write, ensure visibility of written variable void atomicWrite(volatile FXint* ptr,FXint v){ #if defined(WIN32) && (_MSC_VER >= 1500) *ptr=v; _ReadWriteBarrier(); #elif defined(HAVE_BUILTIN_ATOMIC) __atomic_store_n(ptr,v,__ATOMIC_SEQ_CST); #elif defined(HAVE_BUILTIN_SYNC) *ptr=v; __sync_synchronize(); #elif (defined(HAVE_INLINE_ASSEMBLY) && (defined(__i386__) || defined(__x86_64__))) *ptr=v; __asm__ __volatile__("mfence\n\t" : : : "memory"); #else *ptr=v; #endif } // Atomically set variable at ptr to v, and return its old contents FXint atomicSet(volatile FXint* ptr,FXint v){ #if defined(WIN32) && (_MSC_VER >= 1500) return _InterlockedExchange((volatile LONG*)ptr,v); #elif (defined(HAVE_INLINE_ASSEMBLY) && (defined(__i386__) || defined(__x86_64__))) FXint ret=v; __asm__ __volatile__("xchgl %0, (%1)\n\t" : "=r"(ret) : "r"(ptr), "0"(ret) : "memory", "cc"); return ret; #elif defined(HAVE_BUILTIN_SYNC) return __sync_lock_test_and_set(ptr,v); #else FXint ret=*ptr; *ptr=v; return ret; #endif } // Atomically add v to variable at ptr, and return its old contents FXint atomicAdd(volatile FXint* ptr,FXint v){ #if defined(WIN32) && (_MSC_VER >= 1500) return _InterlockedExchangeAdd((volatile LONG*)ptr,v); #elif (defined(HAVE_INLINE_ASSEMBLY) && (defined(__i386__) || defined(__x86_64__))) FXint ret=v; __asm__ __volatile__ ("lock\n\t" "xaddl %0, (%1)\n\t" : "=r"(ret) : "r"(ptr), "0"(ret) : "memory", "cc"); return ret; #elif defined(HAVE_BUILTIN_SYNC) return __sync_fetch_and_add(ptr,v); #else FXint ret=*ptr; *ptr+=v; return ret; #endif } // Atomically compare variable at ptr against expect, setting it to v if equal; returns the old value at ptr FXint atomicCas(volatile FXint* ptr,FXint expect,FXint v){ #if defined(WIN32) && (_MSC_VER >= 1500) return _InterlockedCompareExchange((volatile LONG*)ptr,(LONG)v,(LONG)expect); #elif (defined(HAVE_INLINE_ASSEMBLY) && (defined(__i386__) || defined(__x86_64__))) FXint ret; __asm__ __volatile__("lock\n\t" "cmpxchgl %2, (%1)\n\t" : "=a"(ret) : "r"(ptr), "r"(v), "a"(expect) : "memory", "cc"); return ret; #elif defined(HAVE_BUILTIN_SYNC) return __sync_val_compare_and_swap(ptr,expect,v); #else FXint ret=*ptr; if(*ptr==expect){ *ptr=v; } return ret; #endif } // Atomically compare variable at ptr against expect, setting it to v if equal and return true, or false otherwise FXbool atomicBoolCas(volatile FXint* ptr,FXint expect,FXint v){ #if defined(WIN32) && (_MSC_VER >= 1500) return (_InterlockedCompareExchange((volatile LONG*)ptr,(LONG)v,(LONG)expect)==(LONG)expect); #elif (defined(HAVE_INLINE_ASSEMBLY) && (defined(__i386__) || defined(__x86_64__))) FXbool ret; __asm__ __volatile__ ("lock\n\t" "cmpxchgl %2, (%1)\n\t" "sete %%al\n\t" "andl $1, %%eax\n\t" : "=a"(ret) : "r"(ptr), "r"(v), "a"(expect) : "memory", "cc"); return ret; #elif defined(HAVE_BUILTIN_SYNC) return __sync_bool_compare_and_swap(ptr,expect,v); #else if(*ptr==expect){ *ptr=v; return true; } return false; #endif } /*******************************************************************************/ // Atomically set variable at ptr to v, and return its old contents FXlong atomicSet(volatile FXlong* ptr,FXlong v){ #if defined(WIN32) && (_MSC_VER >= 1800) return _InterlockedExchange64((volatile LONG64*)ptr,v); #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__) && (defined(__PIC__) || defined(__PIE__))) FXlong ret; __asm__ __volatile__ ("xchgl %%esi, %%ebx\n\t" "1:\n\t" "lock\n\t" "cmpxchg8b (%1)\n\t" "jnz 1b\n\t" "xchgl %%esi, %%ebx\n\t" : "=A"(ret) : "D"(ptr), "S"((FXint)v), "c"((FXint)(v>>32)), "A"(*ptr) : "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__)) FXlong ret; __asm__ __volatile__ ("1:\n\t" "lock\n\t" "cmpxchg8b (%1)\n\t" "jnz 1b\n\t" : "=A"(ret) : "D"(ptr), "b"((FXint)v), "c"((FXint)(v>>32)), "A"(*ptr) : "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__x86_64__)) FXlong ret; __asm__ __volatile__("xchgq %0,(%1)\n\t" : "=r"(ret) : "r"(ptr), "0"(v) : "memory", "cc"); return ret; #elif defined(HAVE_BUILTIN_ATOMIC) return __atomic_exchange_n(ptr,v,__ATOMIC_SEQ_CST); #elif defined(HAVE_BUILTIN_SYNC) return __sync_lock_test_and_set(ptr,v); #else FXlong ret=*ptr; *ptr=v; return ret; #endif } // Atomically add v to variable at ptr, and return its old contents FXlong atomicAdd(volatile FXlong* ptr,FXlong v){ #if defined(WIN32) && (_MSC_VER >= 1800) return _InterlockedExchangeAdd64((volatile LONG64*)ptr,v); #elif defined(HAVE_BUILTIN_ATOMIC) return __atomic_fetch_add(ptr,v,__ATOMIC_SEQ_CST); #elif defined(HAVE_BUILTIN_SYNC) return __sync_fetch_and_add(ptr,v); #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__) && (defined(__PIC__) || defined(__PIE__))) FXuint inclo=v; FXuint inchi=(v>>32); FXlong ret; __asm __volatile("movl %%ebx, %%esi\n\t" "1:\n\t" "movl %2, %%ebx\n\t" "movl %3, %%ecx\n\t" "addl %%eax, %%ebx\n\t" "addc %%edx, %%ecx\n\t" "lock\n\t" "cmpxchg8b (%1)\n\t" "jnz 1b\n\t" "movl %%esi, %%ebx\n\t" : "=A"(ret) : "D"(ptr), "m"(inclo), "m"(inchi), "A"(*ptr) : "esi", "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__)) FXuint inclo=v; FXuint inchi=(v>>32); FXlong ret; __asm __volatile("1:\n\t" "movl %2, %%ebx\n\t" "movl %3, %%ecx\n\t" "addl %%eax, %%ebx\n\t" "addc %%edx, %%ecx\n\t" "lock\n\t" "cmpxchg8b (%1)\n\t" "jnz 1b\n\t" : "=A"(ret) : "D"(ptr), "m"(inclo), "m"(inchi), "A"(*ptr) : "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__x86_64__)) FXlong ret; __asm__ __volatile__ ("lock\n\t" "xaddq %0,(%1)\n\t" : "=r"(ret) : "r"(ptr), "0"(v) : "memory", "cc"); return ret; #else FXlong ret=*ptr; *ptr+=v; return ret; #endif } // Atomically compare variable at ptr against expect, setting it to v if equal; returns the old value at ptr FXlong atomicCas(volatile FXlong* ptr,FXlong expect,FXlong v){ #if defined(WIN32) && (_MSC_VER >= 1800) return _InterlockedCompareExchange64((volatile LONG64*)ptr,v,expect); #elif defined(HAVE_BUILTIN_SYNC) return __sync_val_compare_and_swap(ptr,expect,v); #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__) && (defined(__PIC__) || defined(__PIE__))) FXlong ret; __asm__ __volatile__ ("xchgl %%esi, %%ebx\n\t" "lock\n\t" "cmpxchg8b (%1)\n\t" "movl %%esi, %%ebx\n\t" : "=A"(ret) : "D"(ptr), "S"((FXuint)v), "c"((FXuint)(v>>32)), "A"(expect) : "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__)) FXlong ret; __asm__ __volatile__ ("lock\n\t" "cmpxchg8b (%1)\n\t" : "=A"(ret) : "D"(ptr), "b"((FXuint)v), "c"((FXuint)(v>>32)), "A"(expect) : "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__x86_64__)) FXlong ret; __asm__ __volatile__("lock\n\t" "cmpxchgq %2,(%1)\n\t" : "=a"(ret) : "r"(ptr), "r"(v), "a"(expect) : "memory", "cc"); return ret; #else FXlong ret=*ptr; if(*ptr==expect){ *ptr=v; } return ret; #endif } // Atomically compare variable at ptr against expect, setting it to v if equal and return true, or false otherwise FXbool atomicBoolCas(volatile FXlong* ptr,FXlong expect,FXlong v){ #if defined(WIN32) && (_MSC_VER >= 1800) return (_InterlockedCompareExchange64((volatile LONG64*)ptr,v,expect)==expect); #elif defined(HAVE_BUILTIN_SYNC) return __sync_bool_compare_and_swap(ptr,expect,v); #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__) && (defined(__PIC__) || defined(__PIE__))) FXbool ret; __asm__ __volatile__ ("xchgl %%esi, %%ebx\n\t" "lock\n\t" "cmpxchg8b (%1)\n\t" "setz %%al\n\t" "andl $1, %%eax\n\t" "xchgl %%esi, %%ebx\n\t" : "=A"(ret) : "D"(ptr), "S"((FXuint)v), "c"((FXuint)(v>>32)), "A"(expect) : "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__)) FXbool ret; __asm__ __volatile__ ("lock\n\t" "cmpxchg8b (%1)\n\t" "setz %%al\n\t" "andl $1, %%eax\n\t" : "=a"(ret) : "D"(ptr), "b"((FXuint)v), "c"((FXuint)(v>>32)), "A"(expect) : "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__x86_64__)) FXbool ret; __asm__ __volatile__ ("lock\n\t" "cmpxchgq %2,(%1)\n\t" "sete %%al\n\t" "andq $1, %%rax\n\t" : "=a"(ret) : "r"(ptr), "r"(v), "a"(expect) : "memory", "cc"); return ret; #else if(*ptr==expect){ *ptr=v; return true; } return false; #endif } /*******************************************************************************/ // Atomically set variable at ptr to v, and return its old contents FXulong atomicSet(volatile FXulong* ptr,FXulong v){ #if defined(WIN32) && (_MSC_VER >= 1800) return _InterlockedExchange64((volatile LONG64*)ptr,v); #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__) && (defined(__PIC__) || defined(__PIE__))) FXulong ret; __asm__ __volatile__ ("xchgl %%esi, %%ebx\n\t" "1:\n\t" "lock\n\t" "cmpxchg8b (%1)\n\t" "jnz 1b\n\t" "xchgl %%esi, %%ebx\n\t" : "=A"(ret) : "D"(ptr), "S"((FXuint)v), "c"((FXuint)(v>>32)), "A"(*ptr) : "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__)) FXulong ret; __asm__ __volatile__ ("1:\n\t" "lock\n\t" "cmpxchg8b (%1)\n\t" "jnz 1b\n\t" : "=A"(ret) : "D"(ptr), "b"((FXuint)v), "c"((FXuint)(v>>32)), "A"(*ptr) : "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__x86_64__)) FXulong ret; __asm__ __volatile__("xchgq %0,(%1)\n\t" : "=r"(ret) : "r"(ptr), "0"(v) : "memory", "cc"); return ret; #elif defined(HAVE_BUILTIN_ATOMIC) return __atomic_exchange_n(ptr,v,__ATOMIC_SEQ_CST); #elif defined(HAVE_BUILTIN_SYNC) return __sync_lock_test_and_set(ptr,v); #else FXulong ret=*ptr; *ptr=v; return ret; #endif } // Atomically add v to variable at ptr, and return its old contents FXulong atomicAdd(volatile FXulong* ptr,FXulong v){ #if defined(WIN32) && (_MSC_VER >= 1800) return _InterlockedExchangeAdd64((volatile LONG64*)ptr,v); #elif defined(HAVE_BUILTIN_ATOMIC) return __atomic_fetch_add(ptr,v,__ATOMIC_SEQ_CST); #elif defined(HAVE_BUILTIN_SYNC) return __sync_fetch_and_add(ptr,v); #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__) && (defined(__PIC__) || defined(__PIE__))) FXuint inclo=v; FXuint inchi=(v>>32); FXulong ret; __asm __volatile("movl %%ebx, %%esi\n\t" "1:\n\t" "movl %2, %%ebx\n\t" "movl %3, %%ecx\n\t" "addl %%eax, %%ebx\n\t" "addc %%edx, %%ecx\n\t" "lock\n\t" "cmpxchg8b (%1)\n\t" "jnz 1b\n\t" "movl %%esi, %%ebx\n\t" : "=A"(ret) : "D"(ptr), "m"(inclo), "m"(inchi), "A"(*ptr) : "esi", "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__)) FXuint inclo=v; FXuint inchi=(v>>32); FXulong ret; __asm __volatile("1:\n\t" "movl %2, %%ebx\n\t" "movl %3, %%ecx\n\t" "addl %%eax, %%ebx\n\t" "addc %%edx, %%ecx\n\t" "lock\n\t" "cmpxchg8b (%1)\n\t" "jnz 1b\n\t" : "=A"(ret) : "D"(ptr), "m"(inclo), "m"(inchi), "A"(*ptr) : "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__x86_64__)) FXulong ret; __asm__ __volatile__ ("lock\n\t" "xaddq %0,(%1)\n\t" : "=r"(ret) : "r"(ptr), "0"(v) : "memory", "cc"); return ret; #else FXulong ret=*ptr; *ptr+=v; return ret; #endif } // Atomically compare variable at ptr against expect, setting it to v if equal; returns the old value at ptr FXulong atomicCas(volatile FXulong* ptr,FXulong expect,FXulong v){ #if defined(WIN32) && (_MSC_VER >= 1800) return _InterlockedCompareExchange64((volatile LONG64*)ptr,v,expect); #elif defined(HAVE_BUILTIN_SYNC) return __sync_val_compare_and_swap(ptr,expect,v); #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__) && (defined(__PIC__) || defined(__PIE__))) FXulong ret; __asm__ __volatile__ ("xchgl %%esi, %%ebx\n\t" "lock\n\t" "cmpxchg8b (%1)\n\t" "movl %%esi, %%ebx\n\t" : "=A"(ret) : "D"(ptr), "S"((FXuint)v), "c"((FXuint)(v>>32)), "A"(expect) : "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__)) FXulong ret; __asm__ __volatile__ ("lock\n\t" "cmpxchg8b (%1)\n\t" : "=A"(ret) : "D"(ptr), "b"((FXuint)v), "c"((FXuint)(v>>32)), "A"(expect) : "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__x86_64__)) FXulong ret; __asm__ __volatile__("lock\n\t" "cmpxchgq %2,(%1)\n\t" : "=a"(ret) : "r"(ptr), "r"(v), "a"(expect) : "memory", "cc"); return ret; #else FXulong ret=*ptr; if(*ptr==expect){ *ptr=v; } return ret; #endif } // Atomically compare variable at ptr against expect, setting it to v if equal and return true, or false otherwise FXbool atomicBoolCas(volatile FXulong* ptr,FXulong expect,FXulong v){ #if defined(WIN32) && (_MSC_VER >= 1800) return (_InterlockedCompareExchange64((volatile LONG64*)ptr,v,expect)==expect); #elif defined(HAVE_BUILTIN_SYNC) return __sync_bool_compare_and_swap(ptr,expect,v); #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__) && (defined(__PIC__) || defined(__PIE__))) FXbool ret; __asm__ __volatile__ ("xchgl %%esi, %%ebx\n\t" "lock\n\t" "cmpxchg8b (%1)\n\t" "setz %%al\n\t" "andl $1, %%eax\n\t" "xchgl %%esi, %%ebx\n\t" : "=A"(ret) : "D"(ptr), "S"((FXuint)v), "c"((FXuint)(v>>32)), "A"(expect) : "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__)) FXbool ret; __asm__ __volatile__ ("lock\n\t" "cmpxchg8b (%1)\n\t" "setz %%al\n\t" "andl $1, %%eax\n\t" : "=a"(ret) : "D"(ptr), "b"((FXuint)v), "c"((FXuint)(v>>32)), "A"(expect) : "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__x86_64__)) FXbool ret; __asm__ __volatile__ ("lock\n\t" "cmpxchgq %2,(%1)\n\t" "sete %%al\n\t" "andq $1, %%rax\n\t" : "=a"(ret) : "r"(ptr), "r"(v), "a"(expect) : "memory", "cc"); return ret; #else if(*ptr==expect){ *ptr=v; return true; } return false; #endif } /*******************************************************************************/ // Atomic read; necessary as it serializes reads and writes prior to this one FXuint atomicRead(volatile FXuint* ptr){ #if defined(WIN32) && (_MSC_VER >= 1500) return _InterlockedCompareExchange((volatile LONG*)ptr,0,0); #elif defined(HAVE_BUILTIN_ATOMIC) return __atomic_load_n(ptr,__ATOMIC_SEQ_CST); #elif defined(HAVE_BUILTIN_SYNC) return __sync_val_compare_and_swap(ptr,0,0); #elif (defined(HAVE_INLINE_ASSEMBLY) && (defined(__i386__) || defined(__x86_64__))) FXuint ret=0; __asm__ __volatile__("lock\n\t" "cmpxchgl %2, (%1)\n\t" : "=a"(ret) : "r"(ptr), "r"(ret), "a"(ret) : "memory", "cc"); return ret; #else return *ptr; #endif } // Atomic write, ensure visibility of written variable void atomicWrite(volatile FXuint* ptr,FXuint v){ #if defined(WIN32) && (_MSC_VER >= 1500) *ptr=v; _ReadWriteBarrier(); #elif defined(HAVE_BUILTIN_ATOMIC) __atomic_store_n(ptr,v,__ATOMIC_SEQ_CST); #elif defined(HAVE_BUILTIN_SYNC) *ptr=v; __sync_synchronize(); #elif (defined(HAVE_INLINE_ASSEMBLY) && (defined(__i386__) || defined(__x86_64__))) *ptr=v; __asm__ __volatile__("mfence\n\t" : : : "memory"); #else *ptr=v; #endif } // Atomically set variable at ptr to v, and return its old contents FXuint atomicSet(volatile FXuint* ptr,FXuint v){ #if defined(WIN32) && (_MSC_VER >= 1500) return _InterlockedExchange((volatile LONG*)ptr,v); #elif (defined(HAVE_INLINE_ASSEMBLY) && (defined(__i386__) || defined(__x86_64__))) FXuint ret=v; __asm__ __volatile__("xchgl %0, (%1)\n\t" : "=r"(ret) : "r"(ptr), "0"(ret) : "memory", "cc"); return ret; #elif defined(HAVE_BUILTIN_SYNC) return __sync_lock_test_and_set(ptr,v); #else FXuint ret=*ptr; *ptr=v; return ret; #endif } // Atomically add v to variable at ptr, and return its old contents FXuint atomicAdd(volatile FXuint* ptr,FXuint v){ #if defined(WIN32) && (_MSC_VER >= 1500) return _InterlockedExchangeAdd((volatile LONG*)ptr,v); #elif (defined(HAVE_INLINE_ASSEMBLY) && (defined(__i386__) || defined(__x86_64__))) FXuint ret=v; __asm__ __volatile__ ("lock\n\t" "xaddl %0, (%1)\n\t" : "=r"(ret) : "r"(ptr), "0"(ret) : "memory", "cc"); return ret; #elif defined(HAVE_BUILTIN_SYNC) return __sync_fetch_and_add(ptr,v); #else FXuint ret=*ptr; *ptr+=v; return ret; #endif } // Atomically compare variable at ptr against expect, setting it to v if equal; returns the old value at ptr FXuint atomicCas(volatile FXuint* ptr,FXuint expect,FXuint v){ #if defined(WIN32) && ((_MSC_VER >= 1500)) return _InterlockedCompareExchange((volatile LONG*)ptr,(LONG)v,(LONG)expect); #elif (defined(HAVE_INLINE_ASSEMBLY) && (defined(__i386__) || defined(__x86_64__))) FXuint ret; __asm__ __volatile__("lock\n\t" "cmpxchgl %2, (%1)\n\t" : "=a"(ret) : "r"(ptr), "r"(v), "a"(expect) : "memory", "cc"); return ret; #elif defined(HAVE_BUILTIN_SYNC) return __sync_val_compare_and_swap(ptr,expect,v); #else FXuint ret=*ptr; if(*ptr==expect){ *ptr=v; } return ret; #endif } // Atomically compare variable at ptr against expect, setting it to v if equal and return true, or false otherwise FXbool atomicBoolCas(volatile FXuint* ptr,FXuint expect,FXuint v){ #if defined(WIN32) && ((_MSC_VER >= 1500)) return (_InterlockedCompareExchange((volatile LONG*)ptr,(LONG)v,(LONG)expect)==(LONG)expect); #elif (defined(HAVE_INLINE_ASSEMBLY) && (defined(__i386__) || defined(__x86_64__))) FXbool ret; __asm__ __volatile__ ("lock\n\t" "cmpxchgl %2, (%1)\n\t" "sete %%al\n\t" "andl $1, %%eax\n\t" : "=a"(ret) : "r"(ptr), "r"(v), "a"(expect) : "memory", "cc"); return ret; #elif defined(HAVE_BUILTIN_SYNC) return __sync_bool_compare_and_swap(ptr,expect,v); #else if(*ptr==expect){ *ptr=v; return true; } return false; #endif } /*******************************************************************************/ // Atomic read; necessary as it serializes reads and writes prior to this one FXptr atomicRead(volatile FXptr* ptr){ #if defined(WIN32) && defined(_WIN64) && (_MSC_VER >= 1500) return (FXptr)_InterlockedCompareExchange64((LONGLONG*)ptr,0,0); #elif defined(WIN32) && (MSC_VER >=1500) return (FXptr)_InterlockedCompareExchange((LONG*)ptr,0,0); #elif defined(HAVE_BUILTIN_ATOMIC) return __atomic_load_n(ptr,__ATOMIC_SEQ_CST); #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__)) FXptr ret=0; __asm__ __volatile__("lock\n\t" "cmpxchgl %2, (%1)\n\t" : "=a"(ret) : "r"(ptr), "r"(ret), "a"(ret) : "memory", "cc"); return ret; #elif ((defined(__GNUC__) || defined(__INTEL_COMPILER)) && defined(__x86_64__)) FXptr ret=0; __asm__ __volatile__("lock\n\t" "cmpxchgq %2, (%1)\n\t" : "=a"(ret) : "r"(ptr), "r"(ret), "a"(ret) : "memory", "cc"); return ret; #elif defined(HAVE_BUILTIN_SYNC) return __sync_val_compare_and_swap(ptr,0,0); #else return *ptr; #endif } // Atomic write, ensure visibility of written variable void atomicWrite(volatile FXptr* ptr,FXptr v){ #if defined(WIN32) && (_MSC_VER >= 1500) *ptr=v; _ReadWriteBarrier(); #elif defined(HAVE_BUILTIN_ATOMIC) __atomic_store_n(ptr,v,__ATOMIC_SEQ_CST); #elif defined(HAVE_BUILTIN_SYNC) *ptr=v; __sync_synchronize(); #elif (defined(HAVE_INLINE_ASSEMBLY) && (defined(__i386__) || defined(__x86_64__))) *ptr=v; __asm__ __volatile__("mfence\n\t" : : : "memory"); #else *ptr=v; #endif } // Atomically set pointer variable at ptr to v, and return its old contents FXptr atomicSet(volatile FXptr* ptr,FXptr v){ #if (defined(WIN32) && (_MSC_VER >= 1700)) return (FXptr)_InterlockedExchangePointer(ptr,v); #elif (defined(WIN32) && defined(_WIN64) && (_MSC_VER >= 1500)) FXptr result; do{ // Stop-gap measure: VC++ 2008 doesn't have _InterlockedExchangePointer() result=*ptr; // Only important for 64-bit; on 32-bit we just use _InterlockedExchange() } while(_InterlockedCompareExchange64((LONGLONG*)ptr,(LONGLONG)v,(LONGLONG)result)!=(LONG)result); return result; #elif (defined(WIN32) && (_MSC_VER >= 1500)) return (FXptr)_InterlockedExchange((LONG*)ptr,(LONG)v); #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__)) FXptr ret=v; __asm__ __volatile__("xchgl %0, (%1)\n\t" : "=r"(ret) : "r"(ptr), "0"(ret) : "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__x86_64__)) FXptr ret=v; __asm__ __volatile__("xchgq %0, (%1)\n\t" : "=r"(ret) : "r"(ptr), "0"(ret) : "memory", "cc"); return ret; #elif defined(HAVE_BUILTIN_SYNC) return __sync_lock_test_and_set(ptr,v); #else FXptr ret=*ptr; *ptr=v; return ret; #endif } // _M_X64 // Atomically add v to pointer variable at ptr, and return its old contents FXptr atomicAdd(volatile FXptr* ptr,FXival v){ #if (defined(WIN32) && defined(_WIN64) && (_MSC_VER >= 1500)) return (FXptr)_InterlockedExchangeAdd64((volatile LONGLONG*)ptr,(LONGLONG)v); #elif (defined(WIN32) && (_MSC_VER >= 1600)) return (FXptr)_InterlockedExchangeAdd((volatile LONG*)ptr,(LONG)v); #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__)) FXptr ret=(void*)v; __asm__ __volatile__ ("lock\n\t" "xaddl %0, (%1)\n\t" : "=r"(ret) : "r"(ptr), "0"(ret) : "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__x86_64__)) FXptr ret=(FXptr)v; __asm__ __volatile__ ("lock\n\t" "xaddq %0, (%1)\n\t" : "=r"(ret) : "r"(ptr), "0" (ret) : "memory", "cc"); return ret; #elif defined(HAVE_BUILTIN_SYNC) return __sync_fetch_and_add(ptr,(FXptr)v); #else FXptr ret=*ptr; *((unsigned char**)ptr)+=v; return ret; #endif } // Atomically compare pointer variable at ptr against expect, setting it to v if equal; returns the old value at ptr FXptr atomicCas(volatile FXptr* ptr,FXptr expect,FXptr v){ #if defined(WIN32) && defined(_WIN64) && (_MSC_VER >= 1500) return (FXptr)_InterlockedCompareExchange64((volatile LONGLONG*)ptr,(LONGLONG)v,(LONGLONG)expect); #elif defined(WIN32) && (MSC_VER >=1500) return (FXptr)_InterlockedCompareExchange((volatile LONG*)ptr,(LONG)v,(LONG)expect); #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__)) FXptr ret; __asm__ __volatile__("lock\n\t" "cmpxchgl %2, (%1)\n\t" : "=a"(ret) : "r"(ptr), "r"(v), "a"(expect) : "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__x86_64__)) FXptr ret; __asm__ __volatile__("lock\n\t" "cmpxchgq %2, (%1)\n\t" : "=a"(ret) : "r"(ptr), "r"(v), "a"(expect) : "memory", "cc"); return ret; #elif defined(HAVE_BUILTIN_SYNC) return __sync_val_compare_and_swap(ptr,expect,v); #else FXptr ret=*ptr; if(*ptr==expect){ *ptr=v; } return ret; #endif } // Atomically compare pointer variable at ptr against expect, setting it to v if equal and return true, or false otherwise FXbool atomicBoolCas(volatile FXptr* ptr,FXptr expect,FXptr v){ #if defined(WIN32) && defined(_WIN64) && (_MSC_VER >= 1500) return (_InterlockedCompareExchange64((volatile LONGLONG*)ptr,(LONGLONG)v,(LONGLONG)expect)==(LONGLONG)expect); #elif defined(WIN32) && (MSC_VER >=1500) return (_InterlockedCompareExchange((volatile LONG*)ptr,(LONG)v,(LONG)expect)==(LONG)expect); #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__)) FXbool ret; __asm__ __volatile__ ("lock\n\t" "cmpxchgl %2, (%1)\n\t" "sete %%al\n\t" "andl $1, %%eax\n\t" : "=a"(ret) : "r"(ptr), "r"(v), "a"(expect) : "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__x86_64__)) FXbool ret; __asm__ __volatile__ ("lock\n\t" "cmpxchgq %2, (%1)\n\t" "sete %%al\n\t" "andq $1, %%rax\n\t" : "=a"(ret) : "r"(ptr), "r"(v), "a"(expect) : "memory", "cc"); return ret; #elif defined(HAVE_BUILTIN_SYNC) return __sync_bool_compare_and_swap(ptr,expect,v); #else if(*ptr==expect){ *ptr=v; return true; } return false; #endif } // Atomically compare pair of variables at ptr against (cmpa,cmpb), setting them to (a,b) if equal and return true, or false otherwise FXbool atomicBoolDCas(FXptr volatile* ptr,FXptr cmpa,FXptr cmpb,FXptr a,FXptr b){ #if (defined(WIN32) && defined(_WIN64) && (_MSC_VER >= 1500)) LONGLONG duet[2]={(LONGLONG)a,(LONGLONG)b}; return !!(_InterlockedCompareExchange128((volatile LONGLONG*)ptr,(LONGLONG)cmpb,(LONGLONG)cmpa,duet)); #elif (defined(WIN32) && (_MSC_VER >= 1500)) LONGLONG ab=(((LONGLONG)(FXuval)a)|((LONGLONG)(FXuval)b)<<32); LONGLONG compab=(((LONGLONG)(FXuval)cmpa)|((LONGLONG)(FXuval)cmpb)<<32); return (_InterlockedCompareExchange64((volatile LONGLONG*)ptr,ab,compab)==compab); #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__) && (defined(__PIC__) || defined(__PIE__))) FXbool ret; __asm__ __volatile__ ("xchgl %%esi, %%ebx\n\t" "lock\n\t" "cmpxchg8b (%1)\n\t" "setz %%al\n\t" "andl $1, %%eax\n\t" "xchgl %%esi, %%ebx\n\t" : "=a"(ret) : "D"(ptr), "a"(cmpa), "d"(cmpb), "S"(a), "c"(b) : "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__i386__)) FXbool ret; __asm__ __volatile__ ("lock\n\t" "cmpxchg8b (%1)\n\t" "setz %%al\n\t" "andl $1, %%eax\n\t" : "=a"(ret) : "D"(ptr), "a"(cmpa), "d"(cmpb), "b"(a), "c"(b) : "memory", "cc"); return ret; #elif (defined(HAVE_INLINE_ASSEMBLY) && defined(__x86_64__)) FXbool ret; __asm__ __volatile__ ("lock\n\t" "cmpxchg16b (%1)\n\t" "setz %%al\n\t" "andq $1, %%rax\n\t" : "=a"(ret) : "r"(ptr), "a"(cmpa), "d"(cmpb), "b"(a), "c"(b) : "memory", "cc"); return ret; /* #elif (defined(HAVE_BUILTIN_SYNC) && defined(__LP64__)) __uint128_t expectab=((__uint128_t)(FXuval)cmpa) | (((__uint128_t)(FXuval)cmpb)<<64); __uint128_t ab=((__uint128_t)(FXuval)a) | (((__uint128_t)(FXuval)b)<<64); return __sync_bool_compare_and_swap((__uint128_t*)ptr,expectab,ab); #elif (defined(HAVE_BUILTIN_SYNC) && !defined(__LP64__)) __uint64_t expectab=((__uint64_t)(FXuval)cmpa) | (((__uint64_t)(FXuval)cmpb)<<32); __uint64_t ab=((__uint64_t)(FXuval)a) | (((__uint64_t)(FXuval)b)<<32); return __sync_bool_compare_and_swap((__uint64_t*)ptr,expectab,ab); */ #else static __align(64) volatile FXint locks[256]={ 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, // Each spinlock lives in its own cacheline 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0 }; FXint which=(((FXuval)ptr)>>2)&0xF0; // Avoid contention by associating different lock based on address while(atomicSet(&locks[which],1)){ // Spinlock to ensure access to variable } if(ptr[0]==cmpa && ptr[1]==cmpb){ // Change if equal ptr[0]=a; ptr[1]=b; atomicThreadFence(); // Memory fence to ensure visibility prior to releasing lock locks[which]=0; // Free spinlock return true; } locks[which]=0; // Free spinlock return false; #endif } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXAutoThreadStorageKey.cpp000066400000000000000000000064201455751074500246060ustar00rootroot00000000000000/******************************************************************************** * * * T h r e a d - L o c a l S t o r a g e C l a s s * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXException.h" #include "FXAutoThreadStorageKey.h" /* Notes: - Automatically generate thread-local storage keys in a global constructor; clean them up automatically as well using a global destructor. */ using namespace FX; /*******************************************************************************/ namespace FX { // Automatically acquire a thread-local storage key FXAutoThreadStorageKey::FXAutoThreadStorageKey(){ #if defined(WIN32) FXASSERT_STATIC(sizeof(FXThreadStorageKey)>=sizeof(DWORD)); if((value=(FXThreadStorageKey)TlsAlloc())==TLS_OUT_OF_INDEXES){ throw FXMemoryException("FXAutoThreadStorageKey::FXAutoThreadStorageKey: out of memory\n"); } #else FXASSERT_STATIC(sizeof(FXThreadStorageKey)>=sizeof(pthread_key_t)); pthread_key_t key; if(pthread_key_create(&key,nullptr)!=0){ throw FXMemoryException("FXAutoThreadStorageKey::FXAutoThreadStorageKey: out of memory\n"); } value=(FXThreadStorageKey)key; #endif } // Set thread local storage associated with this key void FXAutoThreadStorageKey::set(FXptr ptr) const { #if defined(WIN32) TlsSetValue((DWORD)value,ptr); #else pthread_setspecific((pthread_key_t)value,ptr); #endif } // Get thread local storage associated with this key FXptr FXAutoThreadStorageKey::get() const { #if defined(WIN32) return TlsGetValue((DWORD)value); #else return pthread_getspecific((pthread_key_t)value); #endif } // Automatically release a thread-local storage key FXAutoThreadStorageKey::~FXAutoThreadStorageKey(){ #if defined(WIN32) TlsFree((DWORD)value); #else pthread_key_delete((pthread_key_t)value); #endif } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXBMPIcon.cpp000066400000000000000000000066221455751074500220030ustar00rootroot00000000000000/******************************************************************************** * * * B M P I c o n O b j e c t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXMemoryStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXObject.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXBMPIcon.h" /* Notes: - BMP does not support alpha in the file format. - You can also let the system guess a transparancy color based on the corners. - If that doesn't work, you can force a specific transparency color. */ using namespace FX; /*******************************************************************************/ namespace FX { // Suggested file extension const FXchar FXBMPIcon::fileExt[]="bmp"; // Suggested mime type const FXchar FXBMPIcon::mimeType[]="image/bmp"; // Object implementation FXIMPLEMENT(FXBMPIcon,FXIcon,nullptr,0) // Initialize nicely FXBMPIcon::FXBMPIcon(FXApp* a,const FXuchar *pix,FXColor clr,FXuint opts,FXint w,FXint h):FXIcon(a,nullptr,clr,opts,w,h){ if(pix){ FXMemoryStream ms(FXStreamLoad,const_cast(pix)); loadPixels(ms); } } // Save object to stream FXbool FXBMPIcon::savePixels(FXStream& store) const { if(fxsaveBMP(store,data,width,height)){ return true; } return false; } // Load object from stream FXbool FXBMPIcon::loadPixels(FXStream& store){ FXColor *pixels; FXint w,h; if(fxloadBMP(store,pixels,w,h)){ setData(pixels,IMAGE_OWNED,w,h); if(options&IMAGE_ALPHAGUESS) setTransparentColor(guesstransp()); if(options&IMAGE_THRESGUESS) setThresholdValue(guessthresh()); return true; } return false; } // Clean up FXBMPIcon::~FXBMPIcon(){ } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXBMPImage.cpp000066400000000000000000000060711455751074500221330ustar00rootroot00000000000000/******************************************************************************** * * * B M P I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXMemoryStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXBMPImage.h" /* Notes: - Only free image if owned! */ using namespace FX; /*******************************************************************************/ namespace FX { // Suggested file extension const FXchar FXBMPImage::fileExt[]="bmp"; // Suggested mime type const FXchar FXBMPImage::mimeType[]="image/bmp"; // Object implementation FXIMPLEMENT(FXBMPImage,FXImage,nullptr,0) // Initialize FXBMPImage::FXBMPImage(FXApp* a,const FXuchar *pix,FXuint opts,FXint w,FXint h):FXImage(a,nullptr,opts,w,h){ if(pix){ FXMemoryStream ms(FXStreamLoad,const_cast(pix)); loadPixels(ms); } } // Save pixel data only FXbool FXBMPImage::savePixels(FXStream& store) const { if(fxsaveBMP(store,data,width,height)){ return true; } return false; } // Load pixel data only FXbool FXBMPImage::loadPixels(FXStream& store){ FXColor *pixels; FXint w,h; if(fxloadBMP(store,pixels,w,h)){ setData(pixels,IMAGE_OWNED,w,h); return true; } return false; } // Clean up FXBMPImage::~FXBMPImage(){ } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXBZFileStream.cpp000066400000000000000000000142041455751074500230360ustar00rootroot00000000000000/******************************************************************************** * * * B Z F i l e S t r e a m C l a s s e s * * * ********************************************************************************* * Copyright (C) 1999,2022 by Lyle Johnson. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXElement.h" #include "FXStream.h" #include "FXString.h" #include "FXObject.h" #include "FXFile.h" #include "FXBZFileStream.h" #ifdef HAVE_BZ2LIB_H #include /* Notes: - Very basic compressed file I/O only. - Updated for new stream classes 2003/07/08. - Updated for use with FXFile 2005/09/03. */ #define BLOCKSIZE100K 1 // Block size x 100,000 bytes #define VERBOSITY 0 // For tracing in bzip library #define WORKFACTOR 0 // See bzip2 documentation #define BUFFERSIZE 8192 // Size of the buffer /*******************************************************************************/ namespace FX { // Used during compression struct BZBlock { bz_stream stream; char buffer[BUFFERSIZE]; }; // Create BZIP2 file stream FXBZFileStream::FXBZFileStream(const FXObject* cont):FXFileStream(cont),bz(nullptr),ac(0){ } // Create and open BZIP2 file stream FXBZFileStream::FXBZFileStream(const FXString& filename,FXStreamDirection save_or_load,FXuval size):bz(nullptr),ac(0){ open(filename,save_or_load,size); } // Save to a file FXuval FXBZFileStream::writeBuffer(FXuval){ FXival m,n; int bzerror; if(dir!=FXStreamSave){fxerror("FXBZFileStream::writeBuffer: wrong stream direction.\n");} FXASSERT(begptr<=rdptr); FXASSERT(rdptr<=wrptr); FXASSERT(wrptr<=endptr); while(rdptrstream.next_in=(char*)rdptr; bz->stream.avail_in=wrptr-rdptr; bz->stream.next_out=bz->buffer; bz->stream.avail_out=BUFFERSIZE; bzerror=BZ2_bzCompress(&bz->stream,ac); if(bzerrorstream.next_out-bz->buffer; n=file.writeBlock(bz->buffer,m); if(nstream.next_in; if(bzerror==BZ_STREAM_END) break; // Finished all data if(bzerror==BZ_RUN_OK && ac==BZ_FLUSH) break; // Flushed all data } if(rdptrstream.avail_in<=0){ // Read more input n=file.readBlock(bz->buffer,BUFFERSIZE); if(n<=0) break; bz->stream.next_in=bz->buffer; bz->stream.avail_in=n; } bz->stream.next_out=(char*)wrptr; bz->stream.avail_out=endptr-wrptr; bzerror=BZ2_bzDecompress(&bz->stream); if(bzerrorstream.next_out; if(bzerror==BZ_STREAM_END) break; // Hit end of file } return wrptr-rdptr; } // Try open file stream FXbool FXBZFileStream::open(const FXString& filename,FXStreamDirection save_or_load,FXuval size){ if(FXFileStream::open(filename,save_or_load,size)){ if(callocElms(bz,1)){ int bzerror; bz->stream.next_in=nullptr; bz->stream.avail_in=0; bz->stream.next_out=nullptr; bz->stream.avail_out=0; ac=BZ_RUN; if(save_or_load==FXStreamLoad){ bzerror=BZ2_bzDecompressInit(&bz->stream,VERBOSITY,0); if(bzerror==BZ_OK) return true; code=FXStreamNoRead; } else{ bzerror=BZ2_bzCompressInit(&bz->stream,BLOCKSIZE100K,VERBOSITY,WORKFACTOR); if(bzerror==BZ_OK) return true; code=FXStreamNoWrite; } freeElms(bz); } FXFileStream::close(); } return false; } // Flush buffer FXbool FXBZFileStream::flush(){ FXbool result; int action=ac; if(ac!=BZ_FINISH) ac=BZ_FLUSH; result=FXStream::flush(); ac=action; return result; } // Close file stream FXbool FXBZFileStream::close(){ if(dir){ if(dir==FXStreamLoad){ FXFileStream::close(); BZ2_bzDecompressEnd(&bz->stream); } else{ ac=BZ_FINISH; FXFileStream::close(); BZ2_bzCompressEnd(&bz->stream); } freeElms(bz); return true; } return false; } // Destructor FXBZFileStream::~FXBZFileStream(){ close(); } } #endif gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXBarrier.cpp000066400000000000000000000067421455751074500221450ustar00rootroot00000000000000/******************************************************************************** * * * B a r r i e r C l a s s * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXMutex.h" #include "FXCondition.h" #include "FXBarrier.h" /* Notes: - Barrier synchronization primitive. - Not using POSIX barriers, since they lack a few important features: o Ability to adjust threshold on the fly. o Obtain current threshold value. o Unconditionally release all threads. - Ability to change threshold is necessary to adjust number of threads based on working conditions. For example, on busy machine one could reduce number of threads working on a parallel problem until system load drops below some level. - To release all blocked threads in case a program can't wait for all threads to clock. - Many scenarios are possible, and often necessary. */ using namespace FX; namespace FX { /*******************************************************************************/ // Initialize the barrier with initial threshold thr FXBarrier::FXBarrier(FXuint thr):generation(0),thresh(FXMAX(thr,1)),count(0){ } // Wait for all threads to hit the barrier FXbool FXBarrier::wait(){ FXScopedMutex locker(mutex); FXuint gen=generation; if(++count>=thresh){ count=0; generation++; condition.broadcast(); return true; } while(gen==generation){ condition.wait(mutex); } return false; } // Change threshold, possibly releasing all waiting threads FXbool FXBarrier::threshold(FXuint thr){ FXScopedMutex locker(mutex); thresh=FXMAX(thr,1); if(count>=thresh){ count=0; generation++; condition.broadcast(); return true; } return false; } // Release all waiting threads unconditionally FXbool FXBarrier::release(){ FXScopedMutex locker(mutex); if(count){ count=0; generation++; condition.broadcast(); return true; } return false; } // Delete the barrier FXBarrier::~FXBarrier(){ } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXBitmap.cpp000066400000000000000000000610501455751074500217640ustar00rootroot00000000000000/******************************************************************************** * * * B i t m a p O b j e c t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxendian.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXException.h" #include "FXElement.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXVisual.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FXBitmap.h" /* Note: - Try eliminate temp copy:- slap pixels into XImage directly, if possible... - Perhaps enforce system-native padding necessary for the above. - Our bitmap data is 01234567, i.e. LS-BIT first; byte order ditto. - Issue: should FXBitmap return the DC for drawing onto the X-Server resident pixmap, or the client-side image bits? My idea is it should be the latter: - Allows even richer set of drawing primitives, as everything is drawn in software. - Very useful to generate off-screen renderings, e.g. during printing. - Allows for building and running true-color drawing programs on low-end graphics hardware. - The only drawback I can see is it will be a fairly large implementation effort... - The scale, mirror, rotate and crop API's have been contributed by Marc Cartright, . - The XBM format maps 1 to black instead of white; perhaps this should be reversed. */ // Changable bitmap options #define BITMAP_MASK (BITMAP_KEEP|BITMAP_SHMI|BITMAP_SHMP) using namespace FX; /*******************************************************************************/ namespace FX { // Object implementation FXIMPLEMENT(FXBitmap,FXDrawable,nullptr,0) // For deserialization FXBitmap::FXBitmap(){ data=nullptr; bytewidth=0; options=0; } // Initialize FXBitmap::FXBitmap(FXApp* a,const FXuchar *pix,FXuint opts,FXint w,FXint h):FXDrawable(a,w,h){ FXTRACE((100,"FXBitmap::FXBitmap %p\n",this)); FXASSERT((opts&~(BITMAP_OWNED|BITMAP_MASK))==0); visual=getApp()->getMonoVisual(); data=const_cast(pix); bytewidth=(width+7)>>3; options=opts; if(!data && (options&BITMAP_OWNED)){ if(!callocElms(data,height*bytewidth)){ throw FXMemoryException("unable to construct bitmap"); } } } // Create bitmap void FXBitmap::create(){ if(!xid){ if(getApp()->isInitialized()){ FXTRACE((100,"%s::create %p\n",getClassName(),this)); // Initialize visual visual->create(); #if defined(WIN32) xid=CreateBitmap(FXMAX(width,1),FXMAX(height,1),1,1,nullptr); #else xid=XCreatePixmap((Display*)getApp()->getDisplay(),XDefaultRootWindow((Display*)getApp()->getDisplay()),FXMAX(width,1),FXMAX(height,1),1); #endif // Were we successful? if(!xid){ throw FXImageException("unable to create bitmap"); } // Render pixels render(); // If we're not keeping the pixel buffer, release it if(!(options&BITMAP_KEEP)) release(); } } } // Release the client-side buffer, free it if it was owned. void FXBitmap::release(){ if(options&BITMAP_OWNED){ options&=~BITMAP_OWNED; freeElms(data); } data=nullptr; } // Detach bitmap void FXBitmap::detach(){ visual->detach(); if(xid){ FXTRACE((100,"%s::detach %p\n",getClassName(),this)); xid=0; } } // Destroy bitmap void FXBitmap::destroy(){ if(xid){ if(getApp()->isInitialized()){ FXTRACE((100,"%s::destroy %p\n",getClassName(),this)); #if defined(WIN32) DeleteObject(xid); #else XFreePixmap((Display*)getApp()->getDisplay(),xid); #endif } xid=0; } } #if defined(WIN32) // WINDOWS struct BITMAPINFO256 { BITMAPINFOHEADER bmiHeader; RGBQUAD bmiColors[256]; }; // Restore client-side pixel buffer from bitmap void FXBitmap::restore(){ if(xid){ FXTRACE((100,"%s::restore image %p\n",getClassName(),this)); // Check for legal size if(width<1 || height<1){ fxerror("%s::restore: illegal image size %dx%d.\n",getClassName(),width,height); } // Make array for data if needed if(!data){ if(!callocElms(data,height*bytewidth)){ throw FXMemoryException("unable to restore image"); } options|=BITMAP_OWNED; } // Got local buffer to receive into if(data){ FXuchar *pixels,*p,*q;; FXint x,y; // Bytes per line, rounded to nearest DWORD FXint bytes_per_line=((width+31)&~31)>>3; // Set up the bitmap info BITMAPINFO256 bmi; bmi.bmiHeader.biSize=sizeof(BITMAPINFOHEADER); bmi.bmiHeader.biWidth=width; bmi.bmiHeader.biHeight=-height; // Negative heights means upside down! bmi.bmiHeader.biPlanes=1; bmi.bmiHeader.biBitCount=1; bmi.bmiHeader.biCompression=BI_RGB; bmi.bmiHeader.biSizeImage=0; bmi.bmiHeader.biXPelsPerMeter=0; bmi.bmiHeader.biYPelsPerMeter=0; bmi.bmiHeader.biClrUsed=0; bmi.bmiHeader.biClrImportant=0; bmi.bmiColors[0].rgbBlue=0; bmi.bmiColors[0].rgbGreen=0; bmi.bmiColors[0].rgbRed=0; bmi.bmiColors[0].rgbReserved=0; bmi.bmiColors[1].rgbBlue=255; bmi.bmiColors[1].rgbGreen=255; bmi.bmiColors[1].rgbRed=255; bmi.bmiColors[1].rgbReserved=0; // DIB format pads to multiples of 4 bytes... if(!allocElms(pixels,height*bytes_per_line)){ throw FXImageException("unable to restore image"); } // Make device context HDC hdcmem=::CreateCompatibleDC(nullptr); if(!GetDIBits(hdcmem,(HBITMAP)xid,0,height,pixels,(BITMAPINFO*)&bmi,DIB_RGB_COLORS)){ throw FXImageException("unable to restore image"); } // Fill our own data from pixels for(y=0,p=pixels,q=data; y>3; // Set up the bitmap info BITMAPINFO256 bmi; bmi.bmiHeader.biSize=sizeof(BITMAPINFOHEADER); bmi.bmiHeader.biWidth=width; bmi.bmiHeader.biHeight=-height; // Negative heights means upside down! bmi.bmiHeader.biPlanes=1; bmi.bmiHeader.biBitCount=1; bmi.bmiHeader.biCompression=0; bmi.bmiHeader.biSizeImage=0; bmi.bmiHeader.biXPelsPerMeter=0; bmi.bmiHeader.biYPelsPerMeter=0; bmi.bmiHeader.biClrUsed=0; bmi.bmiHeader.biClrImportant=0; bmi.bmiColors[0].rgbBlue=0; bmi.bmiColors[0].rgbGreen=0; bmi.bmiColors[0].rgbRed=0; bmi.bmiColors[0].rgbReserved=0; bmi.bmiColors[1].rgbBlue=255; bmi.bmiColors[1].rgbGreen=255; bmi.bmiColors[1].rgbRed=255; bmi.bmiColors[1].rgbReserved=0; // Fill temp array if(!callocElms(pixels,height*bytes_per_line)){ throw FXMemoryException("unable to render bitmap"); } // Fill pixels from our own data for(y=0,p=pixels,q=data; ygetDisplay(),xid,0,0,width,height,1,XYPixmap); if(!xim){ throw FXImageException("unable to restore image"); } // Should have succeeded FXASSERT(xim); FXTRACE((150,"bm width = %d\n",xim->width)); FXTRACE((150,"bm height = %d\n",xim->height)); FXTRACE((150,"bm format = %s\n",xim->format==XYBitmap?"XYBitmap":xim->format==XYPixmap?"XYPixmap":"ZPixmap")); FXTRACE((150,"bm byte_order = %s\n",(xim->byte_order==MSBFirst)?"MSBFirst":"LSBFirst")); FXTRACE((150,"bm bitmap_unit = %d\n",xim->bitmap_unit)); FXTRACE((150,"bm bitmap_bit_order = %s\n",(xim->bitmap_bit_order==MSBFirst)?"MSBFirst":"LSBFirst")); FXTRACE((150,"bm bitmap_pad = %d\n",xim->bitmap_pad)); FXTRACE((150,"bm bitmap_unit = %d\n",xim->bitmap_unit)); FXTRACE((150,"bm depth = %d\n",xim->depth)); FXTRACE((150,"bm bytes_per_line = %d\n",xim->bytes_per_line)); FXTRACE((150,"bm bits_per_pixel = %d\n",xim->bits_per_pixel)); // Grab pixels from image for(y=0; y>3)]|=1<<(x&7); } } // Destroy image XDestroyImage(xim); } } } // Render into pixmap void FXBitmap::render(){ if(xid){ XImage *xim=nullptr; int size; FXuchar *pix; int i; XGCValues values; GC gc; FXTRACE((100,"%s::render bitmap %p\n",getClassName(),this)); // Fill with pixels if there is data if(data && 0getDisplay(),xid,GCForeground|GCBackground,&values); // Create image to transfer pixels xim=XCreateImage((Display*)getApp()->getDisplay(),(Visual*)visual->visual,1,XYBitmap,0,nullptr,width,height,8,(width+7)>>3); if(!xim){ throw FXImageException("unable to render bitmap"); } // Try create temp pixel store if(!allocElms(xim->data,xim->bytes_per_line*height)){ throw FXMemoryException("unable to render bitmap"); } FXTRACE((150,"bm width = %d\n",xim->width)); FXTRACE((150,"bm height = %d\n",xim->height)); FXTRACE((150,"bm format = %s\n",xim->format==XYBitmap?"XYBitmap":xim->format==XYPixmap?"XYPixmap":"ZPixmap")); FXTRACE((150,"bm byte_order = %s\n",(xim->byte_order==MSBFirst)?"MSBFirst":"LSBFirst")); FXTRACE((150,"bm bitmap_unit = %d\n",xim->bitmap_unit)); FXTRACE((150,"bm bitmap_bit_order = %s\n",(xim->bitmap_bit_order==MSBFirst)?"MSBFirst":"LSBFirst")); FXTRACE((150,"bm bitmap_pad = %d\n",xim->bitmap_pad)); FXTRACE((150,"bm bitmap_unit = %d\n",xim->bitmap_unit)); FXTRACE((150,"bm depth = %d\n",xim->depth)); FXTRACE((150,"bm bytes_per_line = %d\n",xim->bytes_per_line)); FXTRACE((150,"bm bits_per_pixel = %d\n",xim->bits_per_pixel)); // Render bits into server-formatted bitmap size=xim->bytes_per_line*height; pix=(FXuchar*)xim->data; // Most significant bit first if(xim->bitmap_bit_order==MSBFirst){ for(i=0; igetDisplay(),xid,gc,xim,0,0,0,0,width,height); freeElms(xim->data); XDestroyImage(xim); XFreeGC((Display*)getApp()->getDisplay(),gc); } } } #endif // Resize bitmap to the specified width and height; the contents become undefined void FXBitmap::resize(FXint w,FXint h){ FXint bw; if(w<1) w=1; if(h<1) h=1; FXTRACE((100,"%s::resize(%d,%d)\n",getClassName(),w,h)); bw=(w+7)>>3; if(xid){ #if defined(WIN32) // Delete old bitmap DeleteObject(xid); // Create a bitmap compatible with current display xid=CreateBitmap(w,h,1,1,nullptr); if(!xid){ throw FXImageException("unable to resize bitmap"); } #else // Free old pixmap XFreePixmap((Display*)getApp()->getDisplay(),xid); // Make new pixmap xid=XCreatePixmap((Display*)getApp()->getDisplay(),XDefaultRootWindow((Display*)getApp()->getDisplay()),w,h,1); if(!xid){ throw FXImageException("unable to resize bitmap"); } #endif } // Resize data array; only do the work if the new // array is a different size as measured in bytes! if(data){ if(!(options&BITMAP_OWNED)){ // Need to own array if(!allocElms(data,h*bw)){ throw FXMemoryException("unable to resize bitmap"); } options|=BITMAP_OWNED; } else if(h*bw!=height*bytewidth){ if(!resizeElms(data,h*bw)){ throw FXMemoryException("unable to resize bitmap"); } } } // Remember new size bytewidth=bw; width=w; height=h; } // Fill bitmap with uniform value void FXBitmap::fill(FXbool color){ if(data){ memset(data,0-color,height*bytewidth); } } // Rescale pixels to the specified width and height; just nearest // neighbor; there ain't no such thing as anti-aliasing in bitmaps! void FXBitmap::scale(FXint w,FXint h){ if(w<1) w=1; if(h<1) h=1; FXTRACE((100,"%s::scale(%d,%d)\n",getClassName(),w,h)); if(w!=width || h!=height){ if(data){ FXuchar *q,*p,bits; FXint xs=(width<<16)/w; FXint ys=(height<<16)/h; FXint bw=bytewidth; FXint i,j,x,y,xx; FXuchar *interim; // Copy to old buffer if(!dupElms(interim,data,height*bytewidth)){ throw FXMemoryException("unable to scale bitmap"); } // Resize the pixmap and target buffer resize(w,h); // Scale the bitmap i=0; y=ys>>1; p=data; do{ j=0; x=xs>>1; q=interim+(y>>16)*bw; bits=0; do{ xx=x>>16; bits|=((q[xx>>3]>>(xx&7))&1)<<(j&7); if((j&7)==7){ *p++=bits; bits=0; } x+=xs; } while(++j1){ // Mirror vertically paa=data; pbb=data+bytewidth*(height-1); do{ pa=paa; paa+=bytewidth; pb=pbb; pbb-=bytewidth; do{ t=*pa; *pa++=*pb; *pb++=t; } while(pa1){ // Mirror horizontally paa=data; pbb=data+bytewidth*height; do{ pa=paa; pb=line+bytewidth; do{ *--pb=*paa++; // Gnarly! } while(line> sb; *pa++=reverse8(t); } while(pa1 && height>1){ if(data){ FXuchar *p,*q,bits; FXint bw=bytewidth; FXint i,j,x; FXuchar *olddata; if(!dupElms(olddata,data,bytewidth*height)){ throw FXMemoryException("unable to rotate bitmap"); } switch(degrees){ case 90: resize(height,width); i=height-1; p=data; do{ j=0; q=olddata+(i>>3); bits=0; do{ bits|=((q[0]>>(i&7))&1)<<(j&7); if((j&7)==7){ *p++=bits; bits=0; } q+=bw; } while(++j=0); break; case 180: // FIXME works but not as fast as it could be i=height-1; p=data; q=olddata+(height-1)*bw; do{ j=0; bits=0; x=width-1; do{ bits|=((q[x>>3]>>(x&7))&1)<<(j&7); if((j&7)==7){ *p++=bits; bits=0; } x--; } while(++j=0); break; case 270: resize(height,width); i=0; p=data; do{ j=0; q=olddata+(i>>3)+(width-1)*bw; bits=0; do{ bits|=((q[0]>>(i&7))&1)<<(j&7); if((j&7)==7){ *p++=bits; bits=0; } q-=bw; } while(++j=width || y>=height || x+w<=0 || y+h<=0){ fxerror("%s::crop: bad arguments.\n",getClassName()); } FXTRACE((100,"%s::crop(%d,%d,%d,%d)\n",getClassName(),x,y,w,h)); if(data){ FXuchar *pnn,*poo,*yyy,*pn,*po,*xx; FXint oldbw=bytewidth; FXint newbw=(w+7)>>3; FXint cpybw; FXint ow=width; FXint oh=height; FXint nw=w; FXint nh=h; FXint cw; FXint ch; FXint sh; FXuint t; FXuchar *olddata; if(!allocElms(olddata,oh*bytewidth+1)){ throw FXMemoryException("unable to crop bitmap"); } memcpy(olddata,data,oh*bytewidth); resize(w,h); pnn=data; yyy=data+newbw*nh; do{ *pnn++=0-color; // 1 -> 0xff, 0 -> 0xff } while(pnn= 0 pnn=data; poo=olddata+oldbw*y; ch=FXMIN(oh,y+nh)-y; } pnn+=(-x)>>3; sh=8-((-x)&7); FXASSERT(cw>0); FXASSERT(ch>0); yyy=pnn+newbw*ch; cpybw=((cw-x+7)>>3)-((-x)>>3); //FXTRACE((1,"ow=%d oh=%d nw=%d nh=%d cw=%d ch=%d sh=%d cpybw=%d\n",ow,oh,nw,nh,cw,ch,sh,cpybw)); do{ pn=pnn; po=poo; xx=pnn+cpybw; t=(0-color)&0xff; do{ t|=(*po++)<<8; *pn++=t>>sh; t>>=8; } while(pn= 0 cw=FXMIN(ow,x+nw)-x; if(y<0){ // y < 0 pnn=data-newbw*y; poo=olddata; ch=FXMIN(oh,y+nh); } else{ // y >= 0 pnn=data; poo=olddata+oldbw*y; ch=FXMIN(oh,y+nh)-y; } poo+=x>>3; sh=x&7; FXASSERT(cw>0); FXASSERT(ch>0); yyy=pnn+newbw*ch; cpybw=(cw+7)>>3; do{ pn=pnn; po=poo; xx=pnn+cpybw; do{ t=*po++; t|=*po<<8; *pn++=t>>sh; } while(pn> options; store >> haspixels; if(haspixels) loadPixels(store); } // Clean up FXBitmap::~FXBitmap(){ FXTRACE((100,"FXBitmap::~FXBitmap %p\n",this)); destroy(); if(options&BITMAP_OWNED){freeElms(data);} data=(FXuchar*)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXBitmapFrame.cpp000066400000000000000000000130071455751074500227360ustar00rootroot00000000000000/******************************************************************************** * * * I m a g e F r a m e W i d g e t * * * ********************************************************************************* * Copyright (C) 2001,2022 by H. J. Daniel III. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FXAccelTable.h" #include "FXBitmap.h" #include "FXBitmapFrame.h" /* Notes: - Hacked around so as to support padding also. - Fixed layout to center image if frame is larger. - Fixed serialization also. - Now supports various justification modes */ #define JUSTIFY_MASK (JUSTIFY_HZ_APART|JUSTIFY_VT_APART) using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXBitmapFrame) FXBitmapFrameMap[]={ FXMAPFUNC(SEL_PAINT,0,FXBitmapFrame::onPaint), }; // Object implementation FXIMPLEMENT(FXBitmapFrame,FXFrame,FXBitmapFrameMap,ARRAYNUMBER(FXBitmapFrameMap)) // Deserialization FXBitmapFrame::FXBitmapFrame(){ bitmap=nullptr; onColor=0; offColor=0; } // Construct it FXBitmapFrame::FXBitmapFrame(FXComposite* p,FXBitmap *bmp,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb): FXFrame(p,opts,x,y,w,h,pl,pr,pt,pb){ bitmap=bmp; onColor=FXRGB(0,0,0); offColor=backColor; } // Create it all void FXBitmapFrame::create(){ FXFrame::create(); if(bitmap) bitmap->create(); } // Get default width FXint FXBitmapFrame::getDefaultWidth(){ FXint w=0; if(bitmap) w=bitmap->getWidth(); return w+padleft+padright+(border<<1); } // Get default height FXint FXBitmapFrame::getDefaultHeight(){ FXint h=0; if(bitmap) h=bitmap->getHeight(); return h+padtop+padbottom+(border<<1); } // Draw the image long FXBitmapFrame::onPaint(FXObject*,FXSelector,void* ptr){ FXEvent *ev=(FXEvent*)ptr; FXDCWindow dc(this,ev); FXint imgx,imgy,imgw,imgh; dc.setForeground(backColor); if(bitmap){ imgw=bitmap->getWidth(); imgh=bitmap->getHeight(); if(options&JUSTIFY_LEFT) imgx=padleft+border; else if(options&JUSTIFY_RIGHT) imgx=width-padright-border-imgw; else imgx=border+padleft+(width-padleft-padright-(border<<1)-imgw)/2; if(options&JUSTIFY_TOP) imgy=padtop+border; else if(options&JUSTIFY_BOTTOM) imgy=height-padbottom-border-imgh; else imgy=border+padtop+(height-padbottom-padtop-(border<<1)-imgh)/2; dc.fillRectangle(border,border,imgx-border,height-(border<<1)); dc.fillRectangle(imgx+imgw,border,width-border-imgx-imgw,height-(border<<1)); dc.fillRectangle(imgx,border,imgw,imgy-border); dc.fillRectangle(imgx,imgy+imgh,imgw,height-border-imgy-imgh); dc.setForeground(onColor); dc.setBackground(offColor); dc.drawBitmap(bitmap,imgx,imgy); } else{ dc.fillRectangle(border,border,width-(border<<1),height-(border<<1)); } drawFrame(dc,0,0,width,height); return 1; } // Change image void FXBitmapFrame::setBitmap(FXBitmap* bmp){ bitmap=bmp; recalc(); update(); } // Set on color void FXBitmapFrame::setOnColor(FXColor clr){ if(clr!=onColor){ onColor=clr; update(); } } // Set off color void FXBitmapFrame::setOffColor(FXColor clr){ if(clr!=offColor){ offColor=clr; update(); } } // Set text justify style void FXBitmapFrame::setJustify(FXuint style){ FXuint opts=(options&~JUSTIFY_MASK) | (style&JUSTIFY_MASK); if(options!=opts){ options=opts; update(); } } // Get text justify style FXuint FXBitmapFrame::getJustify() const { return (options&JUSTIFY_MASK); } // Save data void FXBitmapFrame::save(FXStream& store) const { FXFrame::save(store); store << bitmap; } // Load data void FXBitmapFrame::load(FXStream& store){ FXFrame::load(store); store >> bitmap; } // Destructor FXBitmapFrame::~FXBitmapFrame(){ bitmap=(FXBitmap*)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXBitmapView.cpp000066400000000000000000000164551455751074500226300ustar00rootroot00000000000000/******************************************************************************** * * * B i t m a p V i e w W i d g e t * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXMutex.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FXAccelTable.h" #include "FXBitmap.h" #include "FXComposite.h" #include "FXCanvas.h" #include "FXButton.h" #include "FXScrollBar.h" #include "FXBitmapView.h" /* Notes: - Should implement DND drags/drops, cut/paste - Right-mouse scroll. */ #define MOUSE_NONE 0 // None in effect #define MOUSE_SCROLL 1 // Scrolling mode using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXBitmapView) FXBitmapViewMap[]={ FXMAPFUNC(SEL_PAINT,0,FXBitmapView::onPaint), FXMAPFUNC(SEL_MOTION,0,FXBitmapView::onMotion), FXMAPFUNC(SEL_RIGHTBUTTONPRESS,0,FXBitmapView::onRightBtnPress), FXMAPFUNC(SEL_RIGHTBUTTONRELEASE,0,FXBitmapView::onRightBtnRelease), }; // Object implementation FXIMPLEMENT(FXBitmapView,FXScrollArea,FXBitmapViewMap,ARRAYNUMBER(FXBitmapViewMap)) // Deserialization FXBitmapView::FXBitmapView(){ flags|=FLAG_ENABLED; bitmap=nullptr; onColor=0; offColor=0; grabx=0; graby=0; } // Construct and init FXBitmapView::FXBitmapView(FXComposite* p,FXBitmap* bmp,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXScrollArea(p,opts,x,y,w,h){ flags|=FLAG_ENABLED; target=tgt; message=sel; bitmap=bmp; onColor=FXRGB(0,0,0); offColor=backColor; grabx=0; graby=0; } // Create window void FXBitmapView::create(){ FXScrollArea::create(); if(bitmap) bitmap->create(); } // Detach window void FXBitmapView::detach(){ FXScrollArea::detach(); if(bitmap) bitmap->detach(); } // Can have focus FXbool FXBitmapView::canFocus() const { return true; } // Determine content width of scroll area FXint FXBitmapView::getContentWidth(){ return bitmap ? bitmap->getWidth() : 1; } // Determine content height of scroll area FXint FXBitmapView::getContentHeight(){ return bitmap ? bitmap->getHeight() : 1; } // Recalculate layout void FXBitmapView::layout(){ // Place scroll bars placeScrollBars(width,height); // Repaint update(); // Not dirty flags&=~FLAG_DIRTY; } // Draw visible part of bitmap long FXBitmapView::onPaint(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; FXDCWindow dc(this,event); FXint xx,yy,ww,hh,vw,vh,xl,xr,yt,yb; vw=getVisibleWidth(); vh=getVisibleHeight(); if(bitmap){ ww=bitmap->getWidth(); hh=bitmap->getHeight(); xx=pos_x; yy=pos_y; if(wwvw) xr=vw; if(yt<0) yt=0; if(yb>vh) yb=vh; dc.fillRectangle(0,0,xr,yt); dc.fillRectangle(0,yt,xl,vh-yt); dc.fillRectangle(xr,0,vw-xr,yb); dc.fillRectangle(xl,yb,vw-xl,vh-yb); } else{ dc.setForeground(backColor); dc.fillRectangle(0,0,vw,vh); } return 1; } // Pressed right button long FXBitmapView::onRightBtnPress(FXObject*,FXSelector,void* ptr){ FXEvent* ev=(FXEvent*)ptr; flags&=~FLAG_TIP; handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr); if(isEnabled()){ grab(); if(target && target->tryHandle(this,FXSEL(SEL_RIGHTBUTTONPRESS,message),ptr)) return 1; flags&=~FLAG_UPDATE; flags|=FLAG_PRESSED|FLAG_SCROLLING; grabx=ev->win_x-pos_x; graby=ev->win_y-pos_y; return 1; } return 0; } // Released right button long FXBitmapView::onRightBtnRelease(FXObject*,FXSelector,void* ptr){ if(isEnabled()){ ungrab(); flags&=~(FLAG_PRESSED|FLAG_SCROLLING); flags|=FLAG_UPDATE; if(target && target->tryHandle(this,FXSEL(SEL_RIGHTBUTTONRELEASE,message),ptr)) return 1; return 1; } return 0; } // Handle real or simulated mouse motion long FXBitmapView::onMotion(FXObject*,FXSelector,void* ptr){ FXEvent* ev=(FXEvent*)ptr; if(flags&FLAG_SCROLLING){ setPosition(ev->win_x-grabx,ev->win_y-graby); return 1; } return 0; } // Change bitmap void FXBitmapView::setBitmap(FXBitmap* bmp){ bitmap=bmp; recalc(); update(); } // Set on color void FXBitmapView::setOnColor(FXColor clr){ if(clr!=onColor){ onColor=clr; update(); } } // Set off color void FXBitmapView::setOffColor(FXColor clr){ if(clr!=offColor){ offColor=clr; update(); } } // Set the current alignment. void FXBitmapView::setAlignment(FXuint mode){ FXuint opts=(options&~(BITMAPVIEW_LEFT|BITMAPVIEW_RIGHT|BITMAPVIEW_TOP|BITMAPVIEW_BOTTOM)) | (mode&(BITMAPVIEW_LEFT|BITMAPVIEW_RIGHT|BITMAPVIEW_TOP|BITMAPVIEW_BOTTOM)); if(options!=opts){ options=opts; update(); } } // Get the current alignment. FXuint FXBitmapView::getAlignment() const { return (options&(BITMAPVIEW_LEFT|BITMAPVIEW_RIGHT|BITMAPVIEW_TOP|BITMAPVIEW_BOTTOM)); } // Save object to stream void FXBitmapView::save(FXStream& store) const { FXScrollArea::save(store); store << bitmap; } // Load object from stream void FXBitmapView::load(FXStream& store){ FXScrollArea::load(store); store >> bitmap; } // Destroy FXBitmapView::~FXBitmapView(){ bitmap=(FXBitmap*)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXButton.cpp000066400000000000000000000353701455751074500220310ustar00rootroot00000000000000/******************************************************************************** * * * B u t t o n O b j e c t s * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FXIcon.h" #include "FXShell.h" #include "FXButton.h" /* Notes: - Use flags for button instead of a whole integer - Add ``flat'' toolbar style also - Need check-style also (stay in when pressed, pop out when unpressed). - Who owns the icon(s)? - Arrow buttons should auto-repeat with a timer of some kind - "&Label\tTooltip\tHelptext\thttp://server/application/helponitem.html" - CheckButton should send SEL_COMMAND. - Default button mode:- should somehow get focus. - Add button multiple-click translations elsewhere - Button should be able to behave like a check (radio) button. - Need to draw ``around'' the icon etc. So it doesn't flash to background. */ // Button styles #define BUTTON_MASK (BUTTON_AUTOGRAY|BUTTON_AUTOHIDE|BUTTON_TOOLBAR|BUTTON_DEFAULT|BUTTON_INITIAL) using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXButton) FXButtonMap[]={ FXMAPFUNC(SEL_UPDATE,0,FXButton::onUpdate), FXMAPFUNC(SEL_PAINT,0,FXButton::onPaint), FXMAPFUNC(SEL_ENTER,0,FXButton::onEnter), FXMAPFUNC(SEL_LEAVE,0,FXButton::onLeave), FXMAPFUNC(SEL_FOCUSIN,0,FXButton::onFocusIn), FXMAPFUNC(SEL_FOCUSOUT,0,FXButton::onFocusOut), FXMAPFUNC(SEL_UNGRABBED,0,FXButton::onUngrabbed), FXMAPFUNC(SEL_LEFTBUTTONPRESS,0,FXButton::onLeftBtnPress), FXMAPFUNC(SEL_LEFTBUTTONRELEASE,0,FXButton::onLeftBtnRelease), FXMAPFUNC(SEL_KEYPRESS,0,FXButton::onKeyPress), FXMAPFUNC(SEL_KEYRELEASE,0,FXButton::onKeyRelease), FXMAPFUNC(SEL_KEYPRESS,FXButton::ID_HOTKEY,FXButton::onHotKeyPress), FXMAPFUNC(SEL_KEYRELEASE,FXButton::ID_HOTKEY,FXButton::onHotKeyRelease), FXMAPFUNC(SEL_COMMAND,FXButton::ID_CHECK,FXButton::onCheck), FXMAPFUNC(SEL_COMMAND,FXButton::ID_UNCHECK,FXButton::onUncheck), FXMAPFUNC(SEL_COMMAND,FXButton::ID_SETVALUE,FXButton::onCmdSetValue), FXMAPFUNC(SEL_COMMAND,FXButton::ID_SETINTVALUE,FXButton::onCmdSetIntValue), FXMAPFUNC(SEL_COMMAND,FXButton::ID_GETINTVALUE,FXButton::onCmdGetIntValue), }; // Object implementation FXIMPLEMENT(FXButton,FXLabel,FXButtonMap,ARRAYNUMBER(FXButtonMap)) // Deserialization FXButton::FXButton(){ state=STATE_UP; } // Construct and init FXButton::FXButton(FXComposite* p,const FXString& text,FXIcon* ic,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb):FXLabel(p,text,ic,opts,x,y,w,h,pl,pr,pt,pb){ target=tgt; message=sel; state=STATE_UP; if(options&BUTTON_INITIAL){ setInitial(true); setDefault(true); } } // If window can have focus FXbool FXButton::canFocus() const { return true; } // Set focus to this widget void FXButton::setFocus(){ FXLabel::setFocus(); if(options&BUTTON_DEFAULT) setDefault(true); update(); } // Kill focus to this widget void FXButton::killFocus(){ FXLabel::killFocus(); if(options&BUTTON_DEFAULT) setDefault(maybe); update(); } // Make widget drawn as default void FXButton::setDefault(FXuchar flag){ FXLabel::setDefault(flag); update(); } // Set button state void FXButton::setState(FXuint s){ if(state!=s){ state=s; update(); } } // Update value from a message long FXButton::onCmdSetValue(FXObject*,FXSelector,void* ptr){ setState((FXuint)(FXuval)ptr); return 1; } // Update value from a message long FXButton::onCmdSetIntValue(FXObject*,FXSelector,void* ptr){ setState(*((FXint*)ptr)); return 1; } // Obtain value from text field long FXButton::onCmdGetIntValue(FXObject*,FXSelector,void* ptr){ *((FXint*)ptr)=getState(); return 1; } // Check the menu button long FXButton::onCheck(FXObject*,FXSelector,void*){ setState(STATE_ENGAGED); return 1; } // Check the menu button long FXButton::onUncheck(FXObject*,FXSelector,void*){ setState(STATE_UP); return 1; } // Implement auto-hide or auto-gray modes long FXButton::onUpdate(FXObject* sender,FXSelector sel,void* ptr){ if(!FXLabel::onUpdate(sender,sel,ptr)){ if(options&BUTTON_AUTOHIDE){if(shown()){hide();recalc();}} if(options&BUTTON_AUTOGRAY){disable();} } return 1; } // Gained focus long FXButton::onFocusIn(FXObject* sender,FXSelector sel,void* ptr){ FXLabel::onFocusIn(sender,sel,ptr); update(); return 1; } // Lost focus long FXButton::onFocusOut(FXObject* sender,FXSelector sel,void* ptr){ FXLabel::onFocusOut(sender,sel,ptr); update(); return 1; } // Entered button long FXButton::onEnter(FXObject* sender,FXSelector sel,void* ptr){ FXLabel::onEnter(sender,sel,ptr); if(isEnabled()){ if((flags&FLAG_PRESSED) && (state!=STATE_ENGAGED)) setState(STATE_DOWN); if(options&BUTTON_TOOLBAR) update(); } return 1; } // Left button long FXButton::onLeave(FXObject* sender,FXSelector sel,void* ptr){ FXLabel::onLeave(sender,sel,ptr); if(isEnabled()){ if((flags&FLAG_PRESSED) && (state!=STATE_ENGAGED)) setState(STATE_UP); if(options&BUTTON_TOOLBAR) update(); } return 1; } // Pressed mouse button long FXButton::onLeftBtnPress(FXObject*,FXSelector,void* ptr){ handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr); flags&=~FLAG_TIP; if(isEnabled() && !(flags&FLAG_PRESSED)){ grab(); if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONPRESS,message),ptr)) return 1; if(state!=STATE_ENGAGED) setState(STATE_DOWN); flags|=FLAG_PRESSED; flags&=~FLAG_UPDATE; return 1; } return 0; } // Released mouse button long FXButton::onLeftBtnRelease(FXObject*,FXSelector,void* ptr){ FXbool click=(state==STATE_DOWN); if(isEnabled() && (flags&FLAG_PRESSED)){ ungrab(); flags|=FLAG_UPDATE; flags&=~FLAG_PRESSED; if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONRELEASE,message),ptr)) return 1; if(state!=STATE_ENGAGED) setState(STATE_UP); if(click && target){ target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXuval)1); } return 1; } return 0; } // Lost the grab for some reason long FXButton::onUngrabbed(FXObject* sender,FXSelector sel,void* ptr){ FXLabel::onUngrabbed(sender,sel,ptr); if(state!=STATE_ENGAGED) setState(STATE_UP); flags&=~FLAG_PRESSED; flags|=FLAG_UPDATE; return 1; } // Key Press long FXButton::onKeyPress(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; flags&=~FLAG_TIP; if(isEnabled()){ if(target && target->tryHandle(this,FXSEL(SEL_KEYPRESS,message),ptr)) return 1; if(!(flags&FLAG_PRESSED) && ((event->code==KEY_space || event->code==KEY_KP_Space) || (isDefault() && (event->code==KEY_Return || event->code==KEY_KP_Enter)))){ if(state!=STATE_ENGAGED) setState(STATE_DOWN); flags|=FLAG_PRESSED; flags&=~FLAG_UPDATE; return 1; } } return 0; } // Key Release long FXButton::onKeyRelease(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; FXbool click=(state==STATE_DOWN); if(isEnabled()){ if(target && target->tryHandle(this,FXSEL(SEL_KEYRELEASE,message),ptr)) return 1; if((flags&FLAG_PRESSED) && ((event->code==KEY_space || event->code==KEY_KP_Space) || (isDefault() && (event->code==KEY_Return || event->code==KEY_KP_Enter)))){ if(state!=STATE_ENGAGED) setState(STATE_UP); flags|=FLAG_UPDATE; flags&=~FLAG_PRESSED; if(click && target){ target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXuval)1); } return 1; } } return 0; } // Hot key combination pressed long FXButton::onHotKeyPress(FXObject*,FXSelector,void* ptr){ flags&=~FLAG_TIP; handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr); if(isEnabled() && !(flags&FLAG_PRESSED)){ if(state!=STATE_ENGAGED) setState(STATE_DOWN); flags&=~FLAG_UPDATE; flags|=FLAG_PRESSED; } return 1; } // Hot key combination released long FXButton::onHotKeyRelease(FXObject*,FXSelector,void*){ FXuint click=(state==STATE_DOWN); if(isEnabled() && (flags&FLAG_PRESSED)){ if(state!=STATE_ENGAGED) setState(STATE_UP); flags|=FLAG_UPDATE; flags&=~FLAG_PRESSED; if(click && target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXuval)1); } return 1; } // Handle repaint long FXButton::onPaint(FXObject*,FXSelector,void* ptr){ FXint tw=0,th=0,iw=0,ih=0,tx,ty,ix,iy; FXEvent *ev=(FXEvent*)ptr; // Start drawing FXDCWindow dc(this,ev); // Got a border at all? if(options&(FRAME_RAISED|FRAME_SUNKEN)){ // Toolbar style if(options&BUTTON_TOOLBAR){ // Enabled and cursor inside, and up if(isEnabled() && underCursor() && (state==STATE_UP)){ dc.setForeground(backColor); dc.fillRectangle(border,border,width-border*2,height-border*2); if(options&FRAME_THICK) drawDoubleRaisedRectangle(dc,0,0,width,height); else drawRaisedRectangle(dc,0,0,width,height); } // Enabled and cursor inside and down else if(isEnabled() && underCursor() && (state==STATE_DOWN)){ dc.setForeground(backColor); dc.fillRectangle(border,border,width-border*2,height-border*2); if(options&FRAME_THICK) drawDoubleSunkenRectangle(dc,0,0,width,height); else drawSunkenRectangle(dc,0,0,width,height); } // Enabled and checked else if(isEnabled() && (state==STATE_ENGAGED)){ dc.setForeground(hiliteColor); dc.fillRectangle(border,border,width-border*2,height-border*2); if(options&FRAME_THICK) drawDoubleSunkenRectangle(dc,0,0,width,height); else drawSunkenRectangle(dc,0,0,width,height); } // Disabled or unchecked or not under cursor else{ dc.setForeground(backColor); dc.fillRectangle(0,0,width,height); } } // Normal style else{ // Default if(isDefault()){ // Draw in up state if disabled or up if(!isEnabled() || (state==STATE_UP)){ dc.setForeground(backColor); dc.fillRectangle(border+1,border+1,width-border*2-1,height-border*2-1); if(options&FRAME_THICK) drawDoubleRaisedRectangle(dc,1,1,width-1,height-1); else drawRaisedRectangle(dc,1,1,width-1,height-1); } // Draw sunken if enabled and either checked or pressed else{ if(state==STATE_ENGAGED) dc.setForeground(hiliteColor); else dc.setForeground(backColor); dc.fillRectangle(border,border,width-border*2-1,height-border*2-1); if(options&FRAME_THICK) drawDoubleSunkenRectangle(dc,0,0,width-1,height-1); else drawSunkenRectangle(dc,0,0,width-1,height-1); } // Black default border drawBorderRectangle(dc,0,0,width,height); } // Non-Default else{ // Draw in up state if disabled or up if(!isEnabled() || (state==STATE_UP)){ dc.setForeground(backColor); dc.fillRectangle(border,border,width-border*2,height-border*2); if(options&FRAME_THICK) drawDoubleRaisedRectangle(dc,0,0,width,height); else drawRaisedRectangle(dc,0,0,width,height); } // Draw sunken if enabled and either checked or pressed else{ if(state==STATE_ENGAGED) dc.setForeground(hiliteColor); else dc.setForeground(backColor); dc.fillRectangle(border,border,width-border*2,height-border*2); if(options&FRAME_THICK) drawDoubleSunkenRectangle(dc,0,0,width,height); else drawSunkenRectangle(dc,0,0,width,height); } } } } // No borders else{ if(isEnabled() && (state==STATE_ENGAGED)){ dc.setForeground(hiliteColor); dc.fillRectangle(0,0,width,height); } else{ dc.setForeground(backColor); dc.fillRectangle(0,0,width,height); } } // Place text & icon if(!label.empty()){ tw=labelWidth(label); th=labelHeight(label); } if(icon){ iw=icon->getWidth(); ih=icon->getHeight(); } just_x(tx,ix,tw,iw); just_y(ty,iy,th,ih); // Shift a bit when pressed if(state && (options&(FRAME_RAISED|FRAME_SUNKEN))){ ++tx; ++ty; ++ix; ++iy; } // Draw enabled state if(isEnabled()){ if(icon){ dc.drawIcon(icon,ix,iy); } if(!label.empty()){ dc.setFont(font); dc.setForeground(textColor); drawLabel(dc,label,hotoff,tx,ty,tw,th); } if(hasFocus()){ dc.drawFocusRectangle(border+1,border+1,width-2*border-2,height-2*border-2); } } // Draw grayed-out state else{ if(icon){ dc.drawIconSunken(icon,ix,iy); } if(!label.empty()){ dc.setFont(font); dc.setForeground(hiliteColor); drawLabel(dc,label,hotoff,tx+1,ty+1,tw,th); dc.setForeground(shadowColor); drawLabel(dc,label,hotoff,tx,ty,tw,th); } } return 1; } // Set button style void FXButton::setButtonStyle(FXuint style){ FXuint opts=(options&~BUTTON_MASK) | (style&BUTTON_MASK); if(options!=opts){ options=opts; update(); } } // Get button style FXuint FXButton::getButtonStyle() const { return (options&BUTTON_MASK); } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP1250Codec.cpp000066400000000000000000000152211455751074500223170ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP1250Codec.h" namespace FX { FXIMPLEMENT(FXCP1250Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP1250.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 8364, 65533, 8218, 65533, 8222, 8230, 8224, 8225, 65533, 8240, 352, 8249, 346, 356, 381, 377, 65533, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 65533, 8482, 353, 8250, 347, 357, 382, 378, 160, 711, 728, 321, 164, 260, 166, 167, 168, 169, 350, 171, 172, 173, 174, 379, 176, 177, 731, 322, 180, 181, 182, 183, 184, 261, 351, 187, 317, 733, 318, 380, 340, 193, 194, 258, 196, 313, 262, 199, 268, 201, 280, 203, 282, 205, 206, 270, 272, 323, 327, 211, 212, 336, 214, 215, 344, 366, 218, 368, 220, 221, 354, 223, 341, 225, 226, 259, 228, 314, 263, 231, 269, 233, 281, 235, 283, 237, 238, 271, 273, 324, 328, 243, 244, 337, 246, 247, 345, 367, 250, 369, 252, 253, 355, 729, }; static const unsigned char reverse_plane[17]={ 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, }; static const unsigned char reverse_pages[73]={ 0, 46, 46, 46, 46, 46, 46, 46, 109,46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, }; static const unsigned short reverse_block[173]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 175, 190, 206, 221, 235, 251, 128, 263, 278, 294, 310, 326, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 341, 349, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 363, 379, 395, 128, 128, 128, 128, 128, 128, 406, 128, 128, 128, 128, 128, 128, 128, 420, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[436]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 160, 26, 26, 26, 164, 26, 166, 167, 168, 169, 26, 171, 172, 173, 174, 26, 176, 177, 26, 26, 180, 181, 182, 183, 184, 26, 26, 187, 26, 26, 26, 26, 193, 194, 26, 196, 26, 26, 199, 26, 201, 26, 203, 26, 205, 206, 26, 26, 26, 211, 212, 26, 214, 215, 26, 26, 218, 26, 220, 221, 26, 223, 26, 225, 226, 26, 228, 26, 26, 231, 26, 233, 26, 235, 26, 237, 238, 26, 26, 26, 243, 244, 26, 246, 247, 26, 26, 250, 26, 252, 253, 26, 26, 195, 227, 165, 185, 198, 230, 26, 26, 26, 26, 200, 232, 207, 239, 208, 240, 26, 26, 26, 26, 26, 26, 202, 234, 204, 236, 26, 26, 26, 26, 26, 26, 26, 26, 26, 197, 229, 26, 26, 188, 190, 26, 163, 179, 209, 241, 26, 26, 210, 242, 26, 26, 26, 26, 26, 26, 26, 213, 245, 26, 26, 192, 224, 26, 26, 216, 248, 140, 156, 26, 26, 170, 186, 138, 154, 222, 254, 141, 157, 26, 26, 26, 26, 26, 26, 26, 26, 217, 249, 219, 251, 26, 26, 26, 26, 26, 26, 26, 143, 159, 175, 191, 142, 158, 26, 26, 26, 26, 26, 26, 26, 161, 26, 26, 26, 26, 26, 26, 26, 26, 162, 255, 26, 178, 26, 189, 26, 26, 26, 150, 151, 26, 26, 26, 145, 146, 130, 26, 147, 148, 132, 26, 134, 135, 149, 26, 26, 26, 133, 26, 26, 26, 26, 26, 26, 26, 26, 26, 137, 26, 26, 26, 26, 26, 26, 26, 26, 139, 155, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 128, 26, 26, 26, 153, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP1250Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP1250Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP1250Codec::mibEnum() const { return 2250; } const FXchar* FXCP1250Codec::name() const { return "windows-1250"; } const FXchar* FXCP1250Codec::mimeName() const { return "windows-1250"; } const FXchar* const* FXCP1250Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp1250","windows-1250","cp1250","latin2",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP1251Codec.cpp000066400000000000000000000146151455751074500223260ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP1251Codec.h" namespace FX { FXIMPLEMENT(FXCP1251Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP1251.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 1026, 1027, 8218, 1107, 8222, 8230, 8224, 8225, 8364, 8240, 1033, 8249, 1034, 1036, 1035, 1039, 1106, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 65533, 8482, 1113, 8250, 1114, 1116, 1115, 1119, 160, 1038, 1118, 1032, 164, 1168, 166, 167, 1025, 169, 1028, 171, 172, 173, 174, 1031, 176, 177, 1030, 1110, 1169, 181, 182, 183, 1105, 8470, 1108, 187, 1112, 1029, 1109, 1111, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, }; static const unsigned char reverse_plane[17]={ 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, }; static const unsigned char reverse_pages[73]={ 0, 64, 74, 74, 74, 74, 74, 74, 137,74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, }; static const unsigned short reverse_block[201]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 175, 191, 207, 223, 239, 255, 128, 128, 128, 271, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 284, 300, 316, 128, 128, 128, 128, 128, 128, 327, 128, 128, 128, 128, 128, 128, 340, 354, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[370]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 160, 26, 26, 26, 164, 26, 166, 167, 26, 169, 26, 171, 172, 173, 174, 26, 176, 177, 26, 26, 26, 181, 182, 183, 26, 26, 26, 187, 26, 26, 26, 26, 168, 128, 129, 170, 189, 178, 175, 163, 138, 140, 142, 141, 26, 161, 143, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 26, 184, 144, 131, 186, 190, 179, 191, 188, 154, 156, 158, 157, 26, 162, 159, 165, 180, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 150, 151, 26, 26, 26, 145, 146, 130, 26, 147, 148, 132, 26, 134, 135, 149, 26, 26, 26, 133, 26, 26, 26, 26, 26, 26, 26, 26, 26, 137, 26, 26, 26, 26, 26, 26, 26, 26, 139, 155, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 136, 26, 26, 26, 26, 26, 26, 185, 26, 26, 26, 26, 26, 26, 26, 26, 26, 153, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP1251Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP1251Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP1251Codec::mibEnum() const { return 2251; } const FXchar* FXCP1251Codec::name() const { return "windows-1251"; } const FXchar* FXCP1251Codec::mimeName() const { return "windows-1251"; } const FXchar* const* FXCP1251Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp1251","windows-1251","cp1251",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP1252Codec.cpp000066400000000000000000000145041455751074500223240ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP1252Codec.h" namespace FX { FXIMPLEMENT(FXCP1252Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP1252.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 8364, 65533, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 352, 8249, 338, 65533, 381, 65533, 65533, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 353, 8250, 339, 65533, 382, 376, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, }; static const unsigned char reverse_plane[17]={ 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, }; static const unsigned char reverse_pages[73]={ 0, 46, 46, 46, 46, 46, 46, 46, 109,46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, }; static const unsigned short reverse_block[173]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 176, 192, 208, 224, 128, 128, 128, 128, 128, 240, 256, 264, 128, 279, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 289, 296, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 309, 325, 341, 128, 128, 128, 128, 128, 128, 352, 128, 128, 128, 128, 128, 128, 128, 366, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[382]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 26, 26, 140, 156, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 138, 154, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 159, 26, 26, 26, 26, 142, 158, 26, 26, 131, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 136, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 152, 26, 26, 26, 150, 151, 26, 26, 26, 145, 146, 130, 26, 147, 148, 132, 26, 134, 135, 149, 26, 26, 26, 133, 26, 26, 26, 26, 26, 26, 26, 26, 26, 137, 26, 26, 26, 26, 26, 26, 26, 26, 139, 155, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 128, 26, 26, 26, 153, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP1252Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP1252Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP1252Codec::mibEnum() const { return 2252; } const FXchar* FXCP1252Codec::name() const { return "windows-1252"; } const FXchar* FXCP1252Codec::mimeName() const { return "windows-1252"; } const FXchar* const* FXCP1252Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp1252","windows-1252","cp1252",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP1253Codec.cpp000066400000000000000000000142241455751074500223240ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP1253Codec.h" namespace FX { FXIMPLEMENT(FXCP1253Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP1253.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 8364, 65533, 8218, 402, 8222, 8230, 8224, 8225, 65533, 8240, 65533, 8249, 65533, 65533, 65533, 65533, 65533, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 65533, 8482, 65533, 8250, 65533, 65533, 65533, 65533, 160, 901, 902, 163, 164, 165, 166, 167, 168, 169, 65533, 171, 172, 173, 174, 8213, 176, 177, 178, 179, 900, 181, 182, 183, 904, 905, 906, 187, 908, 189, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 65533, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 65533, }; static const unsigned char reverse_plane[17]={ 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, }; static const unsigned char reverse_pages[73]={ 0, 61, 61, 61, 61, 61, 61, 61, 124,61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, }; static const unsigned short reverse_block[188]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 174, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 186, 202, 218, 234, 250, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 265, 281, 297, 128, 128, 128, 128, 128, 128, 308, 128, 128, 128, 128, 128, 128, 128, 322, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[338]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 160, 26, 26, 163, 164, 165, 166, 167, 168, 169, 26, 171, 172, 173, 174, 26, 176, 177, 178, 179, 26, 181, 182, 183, 26, 26, 26, 187, 26, 189, 26, 26, 131, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 180, 161, 162, 26, 184, 185, 186, 26, 188, 26, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 26, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 26, 26, 26, 150, 151, 175, 26, 26, 145, 146, 130, 26, 147, 148, 132, 26, 134, 135, 149, 26, 26, 26, 133, 26, 26, 26, 26, 26, 26, 26, 26, 26, 137, 26, 26, 26, 26, 26, 26, 26, 26, 139, 155, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 128, 26, 26, 26, 153, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP1253Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP1253Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP1253Codec::mibEnum() const { return 2253; } const FXchar* FXCP1253Codec::name() const { return "windows-1253"; } const FXchar* FXCP1253Codec::mimeName() const { return "windows-1253"; } const FXchar* const* FXCP1253Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp1253","windows-1253","cp1253",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP1254Codec.cpp000066400000000000000000000147671455751074500223410ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP1254Codec.h" namespace FX { FXIMPLEMENT(FXCP1254Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP1254.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 8364, 65533, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 352, 8249, 338, 65533, 65533, 65533, 65533, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 353, 8250, 339, 65533, 65533, 376, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 286, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 304, 350, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 287, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 305, 351, 255, }; static const unsigned char reverse_plane[17]={ 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, }; static const unsigned char reverse_pages[73]={ 0, 46, 46, 46, 46, 46, 46, 46, 109,46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, }; static const unsigned short reverse_block[173]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 176, 192, 208, 224, 128, 240, 128, 256, 128, 270, 286, 294, 128, 308, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 318, 325, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 338, 354, 370, 128, 128, 128, 128, 128, 128, 381, 128, 128, 128, 128, 128, 128, 128, 395, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[411]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 26, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 26, 26, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 26, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 26, 26, 255, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 208, 240, 221, 253, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 140, 156, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 222, 254, 138, 154, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 159, 26, 26, 26, 26, 26, 26, 26, 131, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 136, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 152, 26, 26, 26, 150, 151, 26, 26, 26, 145, 146, 130, 26, 147, 148, 132, 26, 134, 135, 149, 26, 26, 26, 133, 26, 26, 26, 26, 26, 26, 26, 26, 26, 137, 26, 26, 26, 26, 26, 26, 26, 26, 139, 155, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 128, 26, 26, 26, 153, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP1254Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP1254Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP1254Codec::mibEnum() const { return 2254; } const FXchar* FXCP1254Codec::name() const { return "windows-1254"; } const FXchar* FXCP1254Codec::mimeName() const { return "windows-1254"; } const FXchar* const* FXCP1254Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp1254","windows-1254","cp1254",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP1255Codec.cpp000066400000000000000000000150631455751074500223300ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP1255Codec.h" namespace FX { FXIMPLEMENT(FXCP1255Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP1255.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 8364, 65533, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 65533, 8249, 65533, 65533, 65533, 65533, 65533, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 65533, 8250, 65533, 65533, 65533, 65533, 160, 161, 162, 163, 8362, 165, 166, 167, 168, 169, 215, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 247, 187, 188, 189, 190, 191, 1456, 1457, 1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 65533, 1467, 1468, 1469, 1470, 1471, 1472, 1473, 1474, 1475, 1520, 1521, 1522, 1523, 1524, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 65533, 65533, 8206, 8207, 65533, }; static const unsigned char reverse_plane[17]={ 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, }; static const unsigned char reverse_pages[73]={ 0, 46, 78, 78, 78, 78, 78, 78, 142,78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, }; static const unsigned short reverse_block[206]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 128, 176, 128, 185, 128, 128, 128, 128, 128, 128, 128, 128, 128, 199, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 209, 216, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 232, 248, 264, 280, 296, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 301, 317, 333, 349, 128, 128, 128, 128, 128, 128, 360, 128, 128, 128, 128, 128, 128, 128, 374, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[390]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 160, 161, 162, 163, 26, 165, 166, 167, 168, 169, 26, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 26, 187, 188, 189, 190, 191, 26, 26, 26, 26, 26, 26, 26, 170, 26, 26, 26, 26, 26, 26, 26, 26, 186, 26, 26, 26, 26, 26, 26, 26, 26, 131, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 136, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 152, 26, 26, 26, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 26, 203, 204, 205, 206, 207, 208, 209, 210, 211, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 26, 26, 26, 26, 26, 212, 213, 214, 215, 216, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 253, 254, 26, 26, 26, 150, 151, 26, 26, 26, 145, 146, 130, 26, 147, 148, 132, 26, 134, 135, 149, 26, 26, 26, 133, 26, 26, 26, 26, 26, 26, 26, 26, 26, 137, 26, 26, 26, 26, 26, 26, 26, 26, 139, 155, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 164, 26, 128, 26, 26, 26, 153, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP1255Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP1255Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP1255Codec::mibEnum() const { return 2255; } const FXchar* FXCP1255Codec::name() const { return "windows-1255"; } const FXchar* FXCP1255Codec::mimeName() const { return "windows-1255"; } const FXchar* const* FXCP1255Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp1255","windows-1255","cp1255",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP1256Codec.cpp000066400000000000000000000165131455751074500223320ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP1256Codec.h" namespace FX { FXIMPLEMENT(FXCP1256Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP1256.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 8364, 1662, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 1657, 8249, 338, 1670, 1688, 1672, 1711, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 1705, 8482, 1681, 8250, 339, 8204, 8205, 1722, 160, 1548, 162, 163, 164, 165, 166, 167, 168, 169, 1726, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 1563, 187, 188, 189, 190, 1567, 1729, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 215, 1591, 1592, 1593, 1594, 1600, 1601, 1602, 1603, 224, 1604, 226, 1605, 1606, 1607, 1608, 231, 232, 233, 234, 235, 1609, 1610, 238, 239, 1611, 1612, 1613, 1614, 244, 1615, 1616, 247, 1617, 249, 1618, 251, 252, 8206, 8207, 1746, }; static const unsigned char reverse_plane[17]={ 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, }; static const unsigned char reverse_pages[73]={ 0, 45, 91, 91, 91, 91, 91, 91, 155,91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, }; static const unsigned short reverse_block[219]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 128, 175, 191, 207, 128, 128, 128, 128, 128, 221, 128, 128, 128, 235, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 245, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 252, 265, 281, 297, 313, 329, 128, 336, 351, 366, 375, 391, 406, 420, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 424, 440, 456, 472, 128, 128, 128, 128, 128, 128, 483, 128, 128, 128, 128, 128, 128, 128, 497, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[513]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 160, 26, 162, 163, 164, 165, 166, 167, 168, 169, 26, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 26, 187, 188, 189, 190, 26, 26, 26, 26, 26, 26, 26, 215, 26, 26, 26, 26, 26, 26, 26, 26, 224, 26, 226, 26, 26, 26, 26, 231, 232, 233, 234, 235, 26, 26, 238, 239, 26, 26, 26, 26, 244, 26, 26, 247, 26, 249, 26, 251, 252, 26, 26, 26, 140, 156, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 131, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 136, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 161, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 186, 26, 26, 26, 191, 26, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 216, 217, 218, 219, 26, 26, 26, 26, 26, 220, 221, 222, 223, 225, 227, 228, 229, 230, 236, 237, 240, 241, 242, 243, 245, 246, 248, 250, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 138, 26, 26, 26, 26, 129, 26, 26, 26, 26, 26, 26, 141, 26, 143, 26, 26, 26, 26, 26, 26, 26, 154, 26, 26, 26, 26, 26, 26, 142, 26, 26, 26, 26, 26, 26, 26, 26, 26, 152, 26, 26, 26, 26, 26, 144, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 159, 26, 26, 26, 170, 26, 192, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 255, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 157, 158, 253, 254, 26, 26, 26, 150, 151, 26, 26, 26, 145, 146, 130, 26, 147, 148, 132, 26, 134, 135, 149, 26, 26, 26, 133, 26, 26, 26, 26, 26, 26, 26, 26, 26, 137, 26, 26, 26, 26, 26, 26, 26, 26, 139, 155, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 128, 26, 26, 26, 153, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP1256Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP1256Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP1256Codec::mibEnum() const { return 2256; } const FXchar* FXCP1256Codec::name() const { return "windows-1256"; } const FXchar* FXCP1256Codec::mimeName() const { return "windows-1256"; } const FXchar* const* FXCP1256Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp1256","windows-1256","cp1256",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP1257Codec.cpp000066400000000000000000000153331455751074500223320ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP1257Codec.h" namespace FX { FXIMPLEMENT(FXCP1257Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP1257.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 8364, 65533, 8218, 65533, 8222, 8230, 8224, 8225, 65533, 8240, 65533, 8249, 65533, 168, 711, 184, 65533, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 65533, 8482, 65533, 8250, 65533, 175, 731, 65533, 160, 65533, 162, 163, 164, 65533, 166, 167, 216, 169, 342, 171, 172, 173, 174, 198, 176, 177, 178, 179, 180, 181, 182, 183, 248, 185, 343, 187, 188, 189, 190, 230, 260, 302, 256, 262, 196, 197, 280, 274, 268, 201, 377, 278, 290, 310, 298, 315, 352, 323, 325, 211, 332, 213, 214, 215, 370, 321, 346, 362, 220, 379, 381, 223, 261, 303, 257, 263, 228, 229, 281, 275, 269, 233, 378, 279, 291, 311, 299, 316, 353, 324, 326, 243, 333, 245, 246, 247, 371, 322, 347, 363, 252, 380, 382, 729, }; static const unsigned char reverse_plane[17]={ 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, }; static const unsigned char reverse_pages[73]={ 0, 46, 46, 46, 46, 46, 46, 46, 109,46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, }; static const unsigned short reverse_block[173]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 175, 188, 204, 217, 233, 247, 261, 277, 292, 306, 322, 336, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 351, 359, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 372, 388, 404, 128, 128, 128, 128, 128, 128, 415, 128, 128, 128, 128, 128, 128, 128, 429, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[445]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 160, 26, 162, 163, 164, 26, 166, 167, 141, 169, 26, 171, 172, 173, 174, 157, 176, 177, 178, 179, 180, 181, 182, 183, 143, 185, 26, 187, 188, 189, 190, 26, 26, 26, 26, 196, 197, 175, 26, 26, 201, 26, 26, 26, 26, 26, 26, 211, 26, 213, 214, 215, 168, 26, 26, 26, 220, 26, 26, 223, 26, 26, 26, 26, 228, 229, 191, 26, 26, 233, 26, 26, 26, 26, 26, 26, 243, 26, 245, 246, 247, 184, 26, 26, 26, 252, 26, 26, 26, 194, 226, 26, 26, 192, 224, 195, 227, 26, 26, 26, 26, 200, 232, 26, 26, 199, 231, 26, 26, 203, 235, 198, 230, 26, 26, 26, 26, 26, 26, 204, 236, 26, 26, 26, 26, 26, 26, 206, 238, 26, 26, 193, 225, 26, 26, 26, 26, 26, 26, 205, 237, 26, 26, 26, 207, 239, 26, 26, 26, 217, 249, 209, 241, 210, 242, 26, 26, 26, 26, 26, 212, 244, 26, 26, 26, 26, 26, 26, 170, 186, 26, 26, 218, 250, 26, 26, 26, 26, 208, 240, 26, 26, 26, 26, 26, 26, 26, 26, 219, 251, 26, 26, 26, 26, 216, 248, 26, 26, 26, 26, 26, 202, 234, 221, 253, 222, 254, 26, 26, 26, 26, 26, 26, 26, 142, 26, 26, 26, 26, 26, 26, 26, 26, 26, 255, 26, 158, 26, 26, 26, 26, 150, 151, 26, 26, 26, 145, 146, 130, 26, 147, 148, 132, 26, 134, 135, 149, 26, 26, 26, 133, 26, 26, 26, 26, 26, 26, 26, 26, 26, 137, 26, 26, 26, 26, 26, 26, 26, 26, 139, 155, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 128, 26, 26, 26, 153, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP1257Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP1257Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP1257Codec::mibEnum() const { return 2257; } const FXchar* FXCP1257Codec::name() const { return "windows-1257"; } const FXchar* FXCP1257Codec::mimeName() const { return "windows-1257"; } const FXchar* const* FXCP1257Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp1257","windows-1257","cp1257","microsoft-cp1257",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP1258Codec.cpp000066400000000000000000000154441455751074500223360ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP1258Codec.h" namespace FX { FXIMPLEMENT(FXCP1258Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP1258.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 8364, 65533, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 65533, 8249, 338, 65533, 65533, 65533, 65533, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 65533, 8250, 339, 65533, 65533, 376, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 258, 196, 197, 198, 199, 200, 201, 202, 203, 768, 205, 206, 207, 272, 209, 777, 211, 212, 416, 214, 215, 216, 217, 218, 219, 220, 431, 771, 223, 224, 225, 226, 259, 228, 229, 230, 231, 232, 233, 234, 235, 769, 237, 238, 239, 273, 241, 803, 243, 244, 417, 246, 247, 248, 249, 250, 251, 252, 432, 8363, 255, }; static const unsigned char reverse_plane[17]={ 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, }; static const unsigned char reverse_pages[73]={ 0, 51, 51, 51, 51, 51, 51, 51, 114,51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, }; static const unsigned short reverse_block[178]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 176, 192, 208, 224, 240, 256, 128, 128, 128, 270, 128, 278, 128, 292, 308, 324, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 334, 341, 128, 128, 357, 128, 370, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 383, 399, 415, 128, 128, 128, 128, 128, 128, 426, 128, 128, 128, 128, 128, 128, 128, 440, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[456]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 26, 196, 197, 198, 199, 200, 201, 202, 203, 26, 205, 206, 207, 26, 209, 26, 211, 212, 26, 214, 215, 216, 217, 218, 219, 220, 26, 26, 223, 224, 225, 226, 26, 228, 229, 230, 231, 232, 233, 234, 235, 26, 237, 238, 239, 26, 241, 26, 243, 244, 26, 246, 247, 248, 249, 250, 251, 252, 26, 26, 255, 26, 26, 195, 227, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 208, 240, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 140, 156, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 159, 26, 26, 26, 26, 26, 26, 26, 131, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 213, 245, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 221, 253, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 136, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 152, 26, 26, 26, 204, 236, 26, 222, 26, 26, 26, 26, 26, 210, 26, 26, 26, 26, 26, 26, 242, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 150, 151, 26, 26, 26, 145, 146, 130, 26, 147, 148, 132, 26, 134, 135, 149, 26, 26, 26, 133, 26, 26, 26, 26, 26, 26, 26, 26, 26, 137, 26, 26, 26, 26, 26, 26, 26, 26, 139, 155, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 254, 128, 26, 26, 26, 153, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP1258Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP1258Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP1258Codec::mibEnum() const { return 2258; } const FXchar* FXCP1258Codec::name() const { return "windows-1258"; } const FXchar* FXCP1258Codec::mimeName() const { return "windows-1258"; } const FXchar* const* FXCP1258Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp1258","windows-1258","cp1258",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP437Codec.cpp000066400000000000000000000172011455751074500222450ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP437Codec.h" namespace FX { FXIMPLEMENT(FXCP437Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP437.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 199, 252, 233, 226, 228, 224, 229, 231, 234, 235, 232, 239, 238, 236, 196, 197, 201, 230, 198, 244, 246, 242, 251, 249, 255, 214, 220, 162, 163, 165, 8359, 402, 225, 237, 243, 250, 241, 209, 170, 186, 191, 8976, 172, 189, 188, 161, 171, 187, 9617, 9618, 9619, 9474, 9508, 9569, 9570, 9558, 9557, 9571, 9553, 9559, 9565, 9564, 9563, 9488, 9492, 9524, 9516, 9500, 9472, 9532, 9566, 9567, 9562, 9556, 9577, 9574, 9568, 9552, 9580, 9575, 9576, 9572, 9573, 9561, 9560, 9554, 9555, 9579, 9578, 9496, 9484, 9608, 9604, 9612, 9616, 9600, 945, 223, 915, 960, 931, 963, 181, 964, 934, 920, 937, 948, 8734, 966, 949, 8745, 8801, 177, 8805, 8804, 8992, 8993, 247, 8776, 176, 8729, 183, 8730, 8319, 178, 9632, 160, }; static const unsigned char reverse_plane[17]={ 0, 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, }; static const unsigned char reverse_pages[74]={ 0, 61, 61, 61, 61, 61, 61, 61, 118,169,61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, }; static const unsigned short reverse_block[233]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 176, 191, 207, 223, 128, 128, 128, 128, 128, 128, 128, 128, 128, 239, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 252, 265, 280, 296, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 303, 128, 128, 319, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 327, 342, 128, 352, 128, 367, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 383, 399, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 415, 431, 444, 457, 128, 473, 489, 128, 505, 521, 537, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[553]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 255, 173, 155, 156, 26, 157, 26, 26, 26, 26, 166, 174, 170, 26, 26, 26, 248, 241, 253, 26, 26, 230, 26, 250, 26, 26, 167, 175, 172, 171, 26, 168, 26, 26, 26, 26, 142, 143, 146, 128, 26, 144, 26, 26, 26, 26, 26, 26, 165, 26, 26, 26, 26, 153, 26, 26, 26, 26, 26, 154, 26, 26, 225, 133, 160, 131, 26, 132, 134, 145, 135, 138, 130, 136, 137, 141, 161, 140, 139, 26, 164, 149, 162, 147, 26, 148, 246, 26, 151, 163, 150, 129, 26, 26, 152, 26, 26, 159, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 226, 26, 26, 26, 26, 233, 26, 26, 26, 26, 26, 26, 26, 228, 26, 26, 232, 26, 26, 234, 26, 26, 26, 26, 26, 26, 224, 26, 26, 235, 238, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 227, 26, 26, 229, 231, 26, 237, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 252, 26, 26, 26, 26, 26, 26, 26, 158, 26, 26, 26, 26, 26, 26, 26, 26, 26, 249, 251, 26, 26, 26, 236, 26, 26, 26, 26, 26, 26, 26, 26, 26, 239, 26, 26, 26, 26, 26, 26, 26, 26, 247, 26, 26, 26, 26, 26, 26, 26, 240, 26, 26, 243, 242, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 169, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 244, 245, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 196, 26, 179, 26, 26, 26, 26, 26, 26, 26, 26, 26, 218, 26, 26, 26, 191, 26, 26, 26, 192, 26, 26, 26, 217, 26, 26, 26, 195, 26, 26, 26, 26, 180, 26, 26, 26, 26, 26, 26, 26, 194, 26, 26, 26, 26, 193, 26, 26, 26, 26, 26, 26, 26, 197, 26, 26, 26, 205, 186, 213, 214, 201, 184, 183, 187, 212, 211, 200, 190, 189, 188, 198, 199, 204, 181, 182, 185, 209, 210, 203, 207, 208, 202, 216, 215, 206, 26, 26, 26, 223, 26, 26, 26, 220, 26, 26, 26, 219, 26, 26, 26, 221, 26, 26, 26, 222, 176, 177, 178, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 254, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP437Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP437Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP437Codec::mibEnum() const { return 2011; } const FXchar* FXCP437Codec::name() const { return "IBM437"; } const FXchar* FXCP437Codec::mimeName() const { return "IBM437"; } const FXchar* const* FXCP437Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp437","IBM437","cp437","csPC8CodePage437",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP850Codec.cpp000066400000000000000000000152411455751074500222460ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP850Codec.h" namespace FX { FXIMPLEMENT(FXCP850Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP850.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 199, 252, 233, 226, 228, 224, 229, 231, 234, 235, 232, 239, 238, 236, 196, 197, 201, 230, 198, 244, 246, 242, 251, 249, 255, 214, 220, 248, 163, 216, 215, 402, 225, 237, 243, 250, 241, 209, 170, 186, 191, 174, 172, 189, 188, 161, 171, 187, 9617, 9618, 9619, 9474, 9508, 193, 194, 192, 169, 9571, 9553, 9559, 9565, 162, 165, 9488, 9492, 9524, 9516, 9500, 9472, 9532, 227, 195, 9562, 9556, 9577, 9574, 9568, 9552, 9580, 164, 240, 208, 202, 203, 200, 305, 205, 206, 207, 9496, 9484, 9608, 9604, 166, 204, 9600, 211, 223, 212, 210, 245, 213, 181, 254, 222, 218, 219, 217, 253, 221, 175, 180, 173, 177, 8215, 190, 182, 167, 247, 184, 176, 168, 183, 185, 179, 178, 9632, 160, }; static const unsigned char reverse_plane[17]={ 0, 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, }; static const unsigned char reverse_pages[74]={ 0, 26, 26, 26, 26, 26, 26, 26, 89, 137,26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; static const unsigned short reverse_block[201]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 176, 192, 208, 224, 128, 128, 128, 240, 128, 128, 128, 128, 128, 254, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 263, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 279, 295, 308, 321, 128, 337, 353, 128, 369, 384, 400, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[416]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 255, 173, 189, 156, 207, 190, 221, 245, 249, 184, 166, 174, 170, 240, 169, 238, 248, 241, 253, 252, 239, 230, 244, 250, 247, 251, 167, 175, 172, 171, 243, 168, 183, 181, 182, 199, 142, 143, 146, 128, 212, 144, 210, 211, 222, 214, 215, 216, 209, 165, 227, 224, 226, 229, 153, 158, 157, 235, 233, 234, 154, 237, 232, 225, 133, 160, 131, 198, 132, 134, 145, 135, 138, 130, 136, 137, 141, 161, 140, 139, 208, 164, 149, 162, 147, 228, 148, 246, 155, 151, 163, 150, 129, 236, 231, 152, 26, 213, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 159, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 242, 26, 26, 26, 26, 26, 26, 26, 26, 196, 26, 179, 26, 26, 26, 26, 26, 26, 26, 26, 26, 218, 26, 26, 26, 191, 26, 26, 26, 192, 26, 26, 26, 217, 26, 26, 26, 195, 26, 26, 26, 26, 180, 26, 26, 26, 26, 26, 26, 26, 194, 26, 26, 26, 26, 193, 26, 26, 26, 26, 26, 26, 26, 197, 26, 26, 26, 205, 186, 26, 26, 201, 26, 26, 187, 26, 26, 200, 26, 26, 188, 26, 26, 204, 26, 26, 185, 26, 26, 203, 26, 26, 202, 26, 26, 206, 26, 26, 26, 223, 26, 26, 26, 220, 26, 26, 26, 219, 26, 26, 26, 26, 26, 26, 26, 176, 177, 178, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 254, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP850Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP850Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP850Codec::mibEnum() const { return 2009; } const FXchar* FXCP850Codec::name() const { return "IBM850"; } const FXchar* FXCP850Codec::mimeName() const { return "IBM850"; } const FXchar* const* FXCP850Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp850","IBM850","cp850","850","csPC850Multilingual",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP852Codec.cpp000066400000000000000000000157241455751074500222560ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP852Codec.h" namespace FX { FXIMPLEMENT(FXCP852Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP852.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 199, 252, 233, 226, 228, 367, 263, 231, 322, 235, 336, 337, 238, 377, 196, 262, 201, 313, 314, 244, 246, 317, 318, 346, 347, 214, 220, 356, 357, 321, 215, 269, 225, 237, 243, 250, 260, 261, 381, 382, 280, 281, 172, 378, 268, 351, 171, 187, 9617, 9618, 9619, 9474, 9508, 193, 194, 282, 350, 9571, 9553, 9559, 9565, 379, 380, 9488, 9492, 9524, 9516, 9500, 9472, 9532, 258, 259, 9562, 9556, 9577, 9574, 9568, 9552, 9580, 164, 273, 272, 270, 203, 271, 327, 205, 206, 283, 9496, 9484, 9608, 9604, 354, 366, 9600, 211, 223, 212, 323, 324, 328, 352, 353, 340, 218, 341, 368, 253, 221, 355, 180, 173, 733, 731, 711, 728, 167, 247, 184, 176, 168, 729, 369, 344, 345, 9632, 160, }; static const unsigned char reverse_plane[17]={ 0, 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, }; static const unsigned char reverse_pages[74]={ 0, 46, 46, 46, 46, 46, 46, 46, 46, 94, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, }; static const unsigned short reverse_block[158]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 175, 190, 206, 221, 235, 251, 128, 263, 278, 294, 310, 326, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 341, 349, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 365, 381, 394, 407, 128, 423, 439, 128, 455, 470, 486, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[502]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 255, 26, 26, 26, 207, 26, 26, 245, 249, 26, 26, 174, 170, 240, 26, 26, 248, 26, 26, 26, 239, 26, 26, 26, 247, 26, 26, 175, 26, 26, 26, 26, 181, 182, 26, 142, 26, 26, 128, 26, 144, 26, 211, 26, 214, 215, 26, 26, 26, 224, 226, 26, 153, 158, 26, 26, 233, 26, 154, 237, 26, 225, 26, 160, 131, 26, 132, 26, 26, 135, 26, 130, 26, 137, 26, 161, 140, 26, 26, 26, 162, 147, 26, 148, 246, 26, 26, 163, 26, 129, 236, 26, 26, 198, 199, 164, 165, 143, 134, 26, 26, 26, 26, 172, 159, 210, 212, 209, 208, 26, 26, 26, 26, 26, 26, 168, 169, 183, 216, 26, 26, 26, 26, 26, 26, 26, 26, 26, 145, 146, 26, 26, 149, 150, 26, 157, 136, 227, 228, 26, 26, 213, 229, 26, 26, 26, 26, 26, 26, 26, 138, 139, 26, 26, 232, 234, 26, 26, 252, 253, 151, 152, 26, 26, 184, 173, 230, 231, 221, 238, 155, 156, 26, 26, 26, 26, 26, 26, 26, 26, 222, 133, 235, 251, 26, 26, 26, 26, 26, 26, 26, 141, 171, 189, 190, 166, 167, 26, 26, 26, 26, 26, 26, 26, 243, 26, 26, 26, 26, 26, 26, 26, 26, 244, 250, 26, 242, 26, 241, 26, 26, 196, 26, 179, 26, 26, 26, 26, 26, 26, 26, 26, 26, 218, 26, 26, 26, 191, 26, 26, 26, 192, 26, 26, 26, 217, 26, 26, 26, 195, 26, 26, 26, 26, 180, 26, 26, 26, 26, 26, 26, 26, 194, 26, 26, 26, 26, 193, 26, 26, 26, 26, 26, 26, 26, 197, 26, 26, 26, 205, 186, 26, 26, 201, 26, 26, 187, 26, 26, 200, 26, 26, 188, 26, 26, 204, 26, 26, 185, 26, 26, 203, 26, 26, 202, 26, 26, 206, 26, 26, 26, 223, 26, 26, 26, 220, 26, 26, 26, 219, 26, 26, 26, 26, 26, 26, 26, 176, 177, 178, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 254, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP852Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP852Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP852Codec::mibEnum() const { return 2010; } const FXchar* FXCP852Codec::name() const { return "IBM852"; } const FXchar* FXCP852Codec::mimeName() const { return "IBM852"; } const FXchar* const* FXCP852Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp852","IBM852","cp852","852","csPCp852","microsoft-cp852",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP855Codec.cpp000066400000000000000000000155171455751074500222610ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP855Codec.h" namespace FX { FXIMPLEMENT(FXCP855Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP855.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 1106, 1026, 1107, 1027, 1105, 1025, 1108, 1028, 1109, 1029, 1110, 1030, 1111, 1031, 1112, 1032, 1113, 1033, 1114, 1034, 1115, 1035, 1116, 1036, 1118, 1038, 1119, 1039, 1102, 1070, 1098, 1066, 1072, 1040, 1073, 1041, 1094, 1062, 1076, 1044, 1077, 1045, 1092, 1060, 1075, 1043, 171, 187, 9617, 9618, 9619, 9474, 9508, 1093, 1061, 1080, 1048, 9571, 9553, 9559, 9565, 1081, 1049, 9488, 9492, 9524, 9516, 9500, 9472, 9532, 1082, 1050, 9562, 9556, 9577, 9574, 9568, 9552, 9580, 164, 1083, 1051, 1084, 1052, 1085, 1053, 1086, 1054, 1087, 9496, 9484, 9608, 9604, 1055, 1103, 9600, 1071, 1088, 1056, 1089, 1057, 1090, 1058, 1091, 1059, 1078, 1046, 1074, 1042, 1100, 1068, 8470, 173, 1099, 1067, 1079, 1047, 1096, 1064, 1101, 1069, 1097, 1065, 1095, 1063, 167, 9632, 160, }; static const unsigned char reverse_plane[17]={ 0, 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, }; static const unsigned char reverse_pages[74]={ 0, 64, 70, 70, 70, 70, 70, 70, 117,165,70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, }; static const unsigned short reverse_block[229]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 158, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 173, 189, 205, 221, 237, 253, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 269, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 285, 301, 314, 327, 128, 343, 359, 128, 375, 390, 406, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[422]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 255, 26, 26, 26, 207, 26, 26, 253, 26, 26, 26, 174, 26, 240, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 175, 26, 26, 26, 26, 133, 129, 131, 135, 137, 139, 141, 143, 145, 147, 149, 151, 26, 153, 155, 161, 163, 236, 173, 167, 169, 234, 244, 184, 190, 199, 209, 211, 213, 215, 221, 226, 228, 230, 232, 171, 182, 165, 252, 246, 250, 159, 242, 238, 248, 157, 224, 160, 162, 235, 172, 166, 168, 233, 243, 183, 189, 198, 208, 210, 212, 214, 216, 225, 227, 229, 231, 170, 181, 164, 251, 245, 249, 158, 241, 237, 247, 156, 222, 26, 132, 128, 130, 134, 136, 138, 140, 142, 144, 146, 148, 150, 26, 152, 154, 26, 26, 26, 26, 26, 26, 239, 26, 26, 26, 26, 26, 26, 26, 26, 26, 196, 26, 179, 26, 26, 26, 26, 26, 26, 26, 26, 26, 218, 26, 26, 26, 191, 26, 26, 26, 192, 26, 26, 26, 217, 26, 26, 26, 195, 26, 26, 26, 26, 180, 26, 26, 26, 26, 26, 26, 26, 194, 26, 26, 26, 26, 193, 26, 26, 26, 26, 26, 26, 26, 197, 26, 26, 26, 205, 186, 26, 26, 201, 26, 26, 187, 26, 26, 200, 26, 26, 188, 26, 26, 204, 26, 26, 185, 26, 26, 203, 26, 26, 202, 26, 26, 206, 26, 26, 26, 223, 26, 26, 26, 220, 26, 26, 26, 219, 26, 26, 26, 26, 26, 26, 26, 176, 177, 178, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 254, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP855Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP855Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP855Codec::mibEnum() const { return 2046; } const FXchar* FXCP855Codec::name() const { return "IBM855"; } const FXchar* FXCP855Codec::mimeName() const { return "IBM855"; } const FXchar* const* FXCP855Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp855","IBM855","cp855","855","csIBM855",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP856Codec.cpp000066400000000000000000000153041455751074500222540ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP856Codec.h" namespace FX { FXIMPLEMENT(FXCP856Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP856.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 65533, 163, 65533, 215, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 174, 172, 189, 188, 65533, 171, 187, 9617, 9618, 9619, 9474, 9508, 65533, 65533, 65533, 169, 9571, 9553, 9559, 9565, 162, 165, 9488, 9492, 9524, 9516, 9500, 9472, 9532, 65533, 65533, 9562, 9556, 9577, 9574, 9568, 9552, 9580, 164, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 9496, 9484, 9608, 9604, 166, 65533, 9600, 65533, 65533, 65533, 65533, 65533, 65533, 181, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 175, 180, 173, 177, 8215, 190, 182, 167, 247, 184, 176, 168, 183, 185, 179, 178, 9632, 160, }; static const unsigned char reverse_plane[17]={ 0, 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, }; static const unsigned char reverse_pages[74]={ 0, 35, 66, 66, 66, 66, 66, 66, 129,177,66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, }; static const unsigned short reverse_block[241]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 128, 175, 128, 184, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 200, 216, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 227, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 243, 259, 272, 285, 128, 301, 317, 128, 333, 348, 364, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[380]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 255, 26, 189, 156, 207, 190, 221, 245, 249, 184, 26, 174, 170, 240, 169, 238, 248, 241, 253, 252, 239, 230, 244, 250, 247, 251, 26, 175, 172, 171, 243, 26, 26, 26, 26, 26, 26, 26, 158, 26, 26, 26, 26, 26, 26, 26, 26, 246, 26, 26, 26, 26, 26, 26, 26, 26, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 26, 26, 26, 26, 26, 26, 26, 242, 26, 26, 26, 26, 26, 26, 26, 26, 196, 26, 179, 26, 26, 26, 26, 26, 26, 26, 26, 26, 218, 26, 26, 26, 191, 26, 26, 26, 192, 26, 26, 26, 217, 26, 26, 26, 195, 26, 26, 26, 26, 180, 26, 26, 26, 26, 26, 26, 26, 194, 26, 26, 26, 26, 193, 26, 26, 26, 26, 26, 26, 26, 197, 26, 26, 26, 205, 186, 26, 26, 201, 26, 26, 187, 26, 26, 200, 26, 26, 188, 26, 26, 204, 26, 26, 185, 26, 26, 203, 26, 26, 202, 26, 26, 206, 26, 26, 26, 223, 26, 26, 26, 220, 26, 26, 26, 219, 26, 26, 26, 26, 26, 26, 26, 176, 177, 178, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 254, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP856Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP856Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP856Codec::mibEnum() const { return 5; } const FXchar* FXCP856Codec::name() const { return "IBM856"; } const FXchar* FXCP856Codec::mimeName() const { return "IBM856"; } const FXchar* const* FXCP856Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp856","IBM856","cp856","856","csIBM856","microsoft-cp856",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP857Codec.cpp000066400000000000000000000144451455751074500222620ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP857Codec.h" namespace FX { FXIMPLEMENT(FXCP857Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP857.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 199, 252, 233, 226, 228, 224, 229, 231, 234, 235, 232, 239, 238, 305, 196, 197, 201, 230, 198, 244, 246, 242, 251, 249, 304, 214, 220, 248, 163, 216, 350, 351, 225, 237, 243, 250, 241, 209, 286, 287, 191, 174, 172, 189, 188, 161, 171, 187, 9617, 9618, 9619, 9474, 9508, 193, 194, 192, 169, 9571, 9553, 9559, 9565, 162, 165, 9488, 9492, 9524, 9516, 9500, 9472, 9532, 227, 195, 9562, 9556, 9577, 9574, 9568, 9552, 9580, 164, 186, 170, 202, 203, 200, 65533, 205, 206, 207, 9496, 9484, 9608, 9604, 166, 204, 9600, 211, 223, 212, 210, 245, 213, 181, 65533, 215, 218, 219, 217, 236, 255, 175, 180, 173, 177, 65533, 190, 182, 167, 247, 184, 176, 168, 183, 185, 179, 178, 9632, 160, }; static const unsigned char reverse_plane[17]={ 0, 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, }; static const unsigned char reverse_pages[74]={ 0, 22, 22, 22, 22, 22, 22, 22, 22, 70, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, }; static const unsigned short reverse_block[134]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 176, 192, 208, 224, 128, 240, 128, 256, 128, 258, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 274, 290, 303, 316, 128, 332, 348, 128, 364, 379, 395, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[411]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 255, 173, 189, 156, 207, 190, 221, 245, 249, 184, 209, 174, 170, 240, 169, 238, 248, 241, 253, 252, 239, 230, 244, 250, 247, 251, 208, 175, 172, 171, 243, 168, 183, 181, 182, 199, 142, 143, 146, 128, 212, 144, 210, 211, 222, 214, 215, 216, 26, 165, 227, 224, 226, 229, 153, 232, 157, 235, 233, 234, 154, 26, 26, 225, 133, 160, 131, 198, 132, 134, 145, 135, 138, 130, 136, 137, 236, 161, 140, 139, 26, 164, 149, 162, 147, 228, 148, 246, 155, 151, 163, 150, 129, 26, 26, 237, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 166, 167, 152, 141, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 158, 159, 196, 26, 179, 26, 26, 26, 26, 26, 26, 26, 26, 26, 218, 26, 26, 26, 191, 26, 26, 26, 192, 26, 26, 26, 217, 26, 26, 26, 195, 26, 26, 26, 26, 180, 26, 26, 26, 26, 26, 26, 26, 194, 26, 26, 26, 26, 193, 26, 26, 26, 26, 26, 26, 26, 197, 26, 26, 26, 205, 186, 26, 26, 201, 26, 26, 187, 26, 26, 200, 26, 26, 188, 26, 26, 204, 26, 26, 185, 26, 26, 203, 26, 26, 202, 26, 26, 206, 26, 26, 26, 223, 26, 26, 26, 220, 26, 26, 26, 219, 26, 26, 26, 26, 26, 26, 26, 176, 177, 178, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 254, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP857Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP857Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP857Codec::mibEnum() const { return 2047; } const FXchar* FXCP857Codec::name() const { return "IBM857"; } const FXchar* FXCP857Codec::mimeName() const { return "IBM857"; } const FXchar* const* FXCP857Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp857","IBM857","cp857","857","csIBM857",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP860Codec.cpp000066400000000000000000000166651455751074500222620ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP860Codec.h" namespace FX { FXIMPLEMENT(FXCP860Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP860.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 199, 252, 233, 226, 227, 224, 193, 231, 234, 202, 232, 205, 212, 236, 195, 194, 201, 192, 200, 244, 245, 242, 218, 249, 204, 213, 220, 162, 163, 217, 8359, 211, 225, 237, 243, 250, 241, 209, 170, 186, 191, 210, 172, 189, 188, 161, 171, 187, 9617, 9618, 9619, 9474, 9508, 9569, 9570, 9558, 9557, 9571, 9553, 9559, 9565, 9564, 9563, 9488, 9492, 9524, 9516, 9500, 9472, 9532, 9566, 9567, 9562, 9556, 9577, 9574, 9568, 9552, 9580, 9575, 9576, 9572, 9573, 9561, 9560, 9554, 9555, 9579, 9578, 9496, 9484, 9608, 9604, 9612, 9616, 9600, 945, 223, 915, 960, 931, 963, 181, 964, 934, 920, 937, 948, 8734, 966, 949, 8745, 8801, 177, 8805, 8804, 8992, 8993, 247, 8776, 176, 8729, 183, 8730, 8319, 178, 9632, 160, }; static const unsigned char reverse_plane[17]={ 0, 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, }; static const unsigned char reverse_pages[74]={ 0, 61, 61, 61, 61, 61, 61, 61, 118,169,61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, }; static const unsigned short reverse_block[233]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 176, 191, 207, 222, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 235, 248, 263, 279, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 286, 128, 128, 302, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 310, 325, 128, 335, 128, 350, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 366, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 382, 398, 411, 424, 128, 440, 456, 128, 472, 488, 504, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[520]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 255, 173, 155, 156, 26, 26, 26, 26, 26, 26, 166, 174, 170, 26, 26, 26, 248, 241, 253, 26, 26, 230, 26, 250, 26, 26, 167, 175, 172, 171, 26, 168, 145, 134, 143, 142, 26, 26, 26, 128, 146, 144, 137, 26, 152, 139, 26, 26, 165, 169, 159, 140, 153, 26, 26, 26, 157, 150, 26, 154, 26, 26, 225, 133, 160, 131, 132, 26, 26, 26, 135, 138, 130, 136, 26, 141, 161, 26, 26, 164, 149, 162, 147, 148, 26, 246, 26, 151, 163, 26, 129, 26, 26, 26, 226, 26, 26, 26, 26, 233, 26, 26, 26, 26, 26, 26, 26, 228, 26, 26, 232, 26, 26, 234, 26, 26, 26, 26, 26, 26, 224, 26, 26, 235, 238, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 227, 26, 26, 229, 231, 26, 237, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 252, 26, 26, 26, 26, 26, 26, 26, 158, 26, 26, 26, 26, 26, 26, 26, 26, 26, 249, 251, 26, 26, 26, 236, 26, 26, 26, 26, 26, 26, 26, 26, 26, 239, 26, 26, 26, 26, 26, 26, 26, 26, 247, 26, 26, 26, 26, 26, 26, 26, 240, 26, 26, 243, 242, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 244, 245, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 196, 26, 179, 26, 26, 26, 26, 26, 26, 26, 26, 26, 218, 26, 26, 26, 191, 26, 26, 26, 192, 26, 26, 26, 217, 26, 26, 26, 195, 26, 26, 26, 26, 180, 26, 26, 26, 26, 26, 26, 26, 194, 26, 26, 26, 26, 193, 26, 26, 26, 26, 26, 26, 26, 197, 26, 26, 26, 205, 186, 213, 214, 201, 184, 183, 187, 212, 211, 200, 190, 189, 188, 198, 199, 204, 181, 182, 185, 209, 210, 203, 207, 208, 202, 216, 215, 206, 26, 26, 26, 223, 26, 26, 26, 220, 26, 26, 26, 219, 26, 26, 26, 221, 26, 26, 26, 222, 176, 177, 178, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 254, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP860Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP860Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP860Codec::mibEnum() const { return 2048; } const FXchar* FXCP860Codec::name() const { return "IBM860"; } const FXchar* FXCP860Codec::mimeName() const { return "IBM860"; } const FXchar* const* FXCP860Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp860","IBM860","cp860","860","csIBM860",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP861Codec.cpp000066400000000000000000000172071455751074500222540ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP861Codec.h" namespace FX { FXIMPLEMENT(FXCP861Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP861.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 199, 252, 233, 226, 228, 224, 229, 231, 234, 235, 232, 208, 240, 222, 196, 197, 201, 230, 198, 244, 246, 254, 251, 221, 253, 214, 220, 248, 163, 216, 8359, 402, 225, 237, 243, 250, 193, 205, 211, 218, 191, 8976, 172, 189, 188, 161, 171, 187, 9617, 9618, 9619, 9474, 9508, 9569, 9570, 9558, 9557, 9571, 9553, 9559, 9565, 9564, 9563, 9488, 9492, 9524, 9516, 9500, 9472, 9532, 9566, 9567, 9562, 9556, 9577, 9574, 9568, 9552, 9580, 9575, 9576, 9572, 9573, 9561, 9560, 9554, 9555, 9579, 9578, 9496, 9484, 9608, 9604, 9612, 9616, 9600, 945, 223, 915, 960, 931, 963, 181, 964, 934, 920, 937, 948, 8734, 966, 949, 8745, 8801, 177, 8805, 8804, 8992, 8993, 247, 8776, 176, 8729, 183, 8730, 8319, 178, 9632, 160, }; static const unsigned char reverse_plane[17]={ 0, 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, }; static const unsigned char reverse_pages[74]={ 0, 61, 61, 61, 61, 61, 61, 61, 118,169,61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, }; static const unsigned short reverse_block[233]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 176, 192, 208, 224, 128, 128, 128, 128, 128, 128, 128, 128, 128, 239, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 252, 265, 280, 296, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 303, 128, 128, 319, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 327, 342, 128, 352, 128, 367, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 383, 399, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 415, 431, 444, 457, 128, 473, 489, 128, 505, 521, 537, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[553]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 255, 173, 26, 156, 26, 26, 26, 26, 26, 26, 26, 174, 170, 26, 26, 26, 248, 241, 253, 26, 26, 230, 26, 250, 26, 26, 26, 175, 172, 171, 26, 168, 26, 164, 26, 26, 142, 143, 146, 128, 26, 144, 26, 26, 26, 165, 26, 26, 139, 26, 26, 166, 26, 26, 153, 26, 157, 26, 167, 26, 154, 151, 141, 225, 133, 160, 131, 26, 132, 134, 145, 135, 138, 130, 136, 137, 26, 161, 26, 26, 140, 26, 26, 162, 147, 26, 148, 246, 155, 26, 163, 150, 129, 152, 149, 26, 26, 159, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 226, 26, 26, 26, 26, 233, 26, 26, 26, 26, 26, 26, 26, 228, 26, 26, 232, 26, 26, 234, 26, 26, 26, 26, 26, 26, 224, 26, 26, 235, 238, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 227, 26, 26, 229, 231, 26, 237, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 252, 26, 26, 26, 26, 26, 26, 26, 158, 26, 26, 26, 26, 26, 26, 26, 26, 26, 249, 251, 26, 26, 26, 236, 26, 26, 26, 26, 26, 26, 26, 26, 26, 239, 26, 26, 26, 26, 26, 26, 26, 26, 247, 26, 26, 26, 26, 26, 26, 26, 240, 26, 26, 243, 242, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 169, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 244, 245, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 196, 26, 179, 26, 26, 26, 26, 26, 26, 26, 26, 26, 218, 26, 26, 26, 191, 26, 26, 26, 192, 26, 26, 26, 217, 26, 26, 26, 195, 26, 26, 26, 26, 180, 26, 26, 26, 26, 26, 26, 26, 194, 26, 26, 26, 26, 193, 26, 26, 26, 26, 26, 26, 26, 197, 26, 26, 26, 205, 186, 213, 214, 201, 184, 183, 187, 212, 211, 200, 190, 189, 188, 198, 199, 204, 181, 182, 185, 209, 210, 203, 207, 208, 202, 216, 215, 206, 26, 26, 26, 223, 26, 26, 26, 220, 26, 26, 26, 219, 26, 26, 26, 221, 26, 26, 26, 222, 176, 177, 178, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 254, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP861Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP861Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP861Codec::mibEnum() const { return 2049; } const FXchar* FXCP861Codec::name() const { return "IBM861"; } const FXchar* FXCP861Codec::mimeName() const { return "IBM861"; } const FXchar* const* FXCP861Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp861","IBM861","cp861","861","cp-is","csIBM861",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP862Codec.cpp000066400000000000000000000176241455751074500222600ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP862Codec.h" namespace FX { FXIMPLEMENT(FXCP862Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP862.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 162, 163, 165, 8359, 402, 225, 237, 243, 250, 241, 209, 170, 186, 191, 8976, 172, 189, 188, 161, 171, 187, 9617, 9618, 9619, 9474, 9508, 9569, 9570, 9558, 9557, 9571, 9553, 9559, 9565, 9564, 9563, 9488, 9492, 9524, 9516, 9500, 9472, 9532, 9566, 9567, 9562, 9556, 9577, 9574, 9568, 9552, 9580, 9575, 9576, 9572, 9573, 9561, 9560, 9554, 9555, 9579, 9578, 9496, 9484, 9608, 9604, 9612, 9616, 9600, 945, 223, 915, 960, 931, 963, 181, 964, 934, 920, 937, 948, 8734, 966, 949, 8745, 8801, 177, 8805, 8804, 8992, 8993, 247, 8776, 176, 8729, 183, 8730, 8319, 178, 9632, 160, }; static const unsigned char reverse_plane[17]={ 0, 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, }; static const unsigned char reverse_pages[74]={ 0, 61, 92, 92, 92, 92, 92, 92, 149,200,92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, }; static const unsigned short reverse_block[264]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 128, 176, 192, 207, 128, 128, 128, 128, 128, 128, 128, 128, 128, 221, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 234, 247, 262, 278, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 294, 310, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 321, 128, 128, 337, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 345, 360, 128, 370, 128, 385, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 401, 417, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 433, 449, 462, 475, 128, 491, 507, 128, 523, 539, 555, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[571]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 255, 173, 155, 156, 26, 157, 26, 26, 26, 26, 166, 174, 170, 26, 26, 26, 248, 241, 253, 26, 26, 230, 26, 250, 26, 26, 167, 175, 172, 171, 26, 168, 26, 165, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 225, 26, 160, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 161, 26, 26, 164, 26, 162, 26, 26, 26, 246, 26, 26, 163, 26, 26, 26, 26, 26, 159, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 226, 26, 26, 26, 26, 233, 26, 26, 26, 26, 26, 26, 26, 228, 26, 26, 232, 26, 26, 234, 26, 26, 26, 26, 26, 26, 224, 26, 26, 235, 238, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 227, 26, 26, 229, 231, 26, 237, 26, 26, 26, 26, 26, 26, 26, 26, 26, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 252, 26, 26, 26, 26, 26, 26, 26, 158, 26, 26, 26, 26, 26, 26, 26, 26, 26, 249, 251, 26, 26, 26, 236, 26, 26, 26, 26, 26, 26, 26, 26, 26, 239, 26, 26, 26, 26, 26, 26, 26, 26, 247, 26, 26, 26, 26, 26, 26, 26, 240, 26, 26, 243, 242, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 169, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 244, 245, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 196, 26, 179, 26, 26, 26, 26, 26, 26, 26, 26, 26, 218, 26, 26, 26, 191, 26, 26, 26, 192, 26, 26, 26, 217, 26, 26, 26, 195, 26, 26, 26, 26, 180, 26, 26, 26, 26, 26, 26, 26, 194, 26, 26, 26, 26, 193, 26, 26, 26, 26, 26, 26, 26, 197, 26, 26, 26, 205, 186, 213, 214, 201, 184, 183, 187, 212, 211, 200, 190, 189, 188, 198, 199, 204, 181, 182, 185, 209, 210, 203, 207, 208, 202, 216, 215, 206, 26, 26, 26, 223, 26, 26, 26, 220, 26, 26, 26, 219, 26, 26, 26, 221, 26, 26, 26, 222, 176, 177, 178, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 254, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP862Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP862Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP862Codec::mibEnum() const { return 2013; } const FXchar* FXCP862Codec::name() const { return "IBM862"; } const FXchar* FXCP862Codec::mimeName() const { return "IBM862"; } const FXchar* const* FXCP862Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp862","IBM862","cp862","862","csPC862LatinHebrew",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP863Codec.cpp000066400000000000000000000172361455751074500222600ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP863Codec.h" namespace FX { FXIMPLEMENT(FXCP863Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP863.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 199, 252, 233, 226, 194, 224, 182, 231, 234, 235, 232, 239, 238, 8215, 192, 167, 201, 200, 202, 244, 203, 207, 251, 249, 164, 212, 220, 162, 163, 217, 219, 402, 166, 180, 243, 250, 168, 184, 179, 175, 206, 8976, 172, 189, 188, 190, 171, 187, 9617, 9618, 9619, 9474, 9508, 9569, 9570, 9558, 9557, 9571, 9553, 9559, 9565, 9564, 9563, 9488, 9492, 9524, 9516, 9500, 9472, 9532, 9566, 9567, 9562, 9556, 9577, 9574, 9568, 9552, 9580, 9575, 9576, 9572, 9573, 9561, 9560, 9554, 9555, 9579, 9578, 9496, 9484, 9608, 9604, 9612, 9616, 9600, 945, 223, 915, 960, 931, 963, 181, 964, 934, 920, 937, 948, 8734, 966, 949, 8745, 8801, 177, 8805, 8804, 8992, 8993, 247, 8776, 176, 8729, 183, 8730, 8319, 178, 9632, 160, }; static const unsigned char reverse_plane[17]={ 0, 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, }; static const unsigned char reverse_pages[74]={ 0, 61, 61, 61, 61, 61, 61, 61, 124,175,61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, }; static const unsigned short reverse_block[239]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 176, 192, 208, 224, 128, 128, 128, 128, 128, 128, 128, 128, 128, 238, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 251, 264, 279, 295, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 304, 128, 128, 128, 128, 128, 312, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 328, 343, 128, 353, 128, 368, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 384, 400, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 416, 432, 445, 458, 128, 474, 490, 128, 506, 522, 538, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[554]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 255, 26, 155, 156, 152, 26, 160, 143, 164, 26, 26, 174, 170, 26, 26, 167, 248, 241, 253, 166, 161, 230, 134, 250, 165, 26, 26, 175, 172, 171, 173, 26, 142, 26, 132, 26, 26, 26, 26, 128, 145, 144, 146, 148, 26, 26, 168, 149, 26, 26, 26, 26, 153, 26, 26, 26, 26, 157, 26, 158, 154, 26, 26, 225, 133, 26, 131, 26, 26, 26, 26, 135, 138, 130, 136, 137, 26, 26, 140, 139, 26, 26, 26, 162, 147, 26, 26, 246, 26, 151, 163, 150, 129, 26, 26, 26, 159, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 226, 26, 26, 26, 26, 233, 26, 26, 26, 26, 26, 26, 26, 228, 26, 26, 232, 26, 26, 234, 26, 26, 26, 26, 26, 26, 224, 26, 26, 235, 238, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 227, 26, 26, 229, 231, 26, 237, 26, 26, 26, 26, 26, 26, 26, 26, 26, 141, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 252, 26, 26, 26, 26, 26, 26, 26, 26, 26, 249, 251, 26, 26, 26, 236, 26, 26, 26, 26, 26, 26, 26, 26, 26, 239, 26, 26, 26, 26, 26, 26, 26, 26, 247, 26, 26, 26, 26, 26, 26, 26, 240, 26, 26, 243, 242, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 169, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 244, 245, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 196, 26, 179, 26, 26, 26, 26, 26, 26, 26, 26, 26, 218, 26, 26, 26, 191, 26, 26, 26, 192, 26, 26, 26, 217, 26, 26, 26, 195, 26, 26, 26, 26, 180, 26, 26, 26, 26, 26, 26, 26, 194, 26, 26, 26, 26, 193, 26, 26, 26, 26, 26, 26, 26, 197, 26, 26, 26, 205, 186, 213, 214, 201, 184, 183, 187, 212, 211, 200, 190, 189, 188, 198, 199, 204, 181, 182, 185, 209, 210, 203, 207, 208, 202, 216, 215, 206, 26, 26, 26, 223, 26, 26, 26, 220, 26, 26, 26, 219, 26, 26, 26, 221, 26, 26, 26, 222, 176, 177, 178, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 254, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP863Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP863Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP863Codec::mibEnum() const { return 2050; } const FXchar* FXCP863Codec::name() const { return "IBM863"; } const FXchar* FXCP863Codec::mimeName() const { return "IBM863"; } const FXchar* const* FXCP863Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp863","IBM863","cp863","863","csIBM863",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP864Codec.cpp000066400000000000000000000177701455751074500222640ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP864Codec.h" namespace FX { FXIMPLEMENT(FXCP864Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP864.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 1642, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 176, 183, 8729, 8730, 9618, 9472, 9474, 9532, 9508, 9516, 9500, 9524, 9488, 9484, 9492, 9496, 946, 8734, 966, 177, 189, 188, 8776, 171, 187, 65271, 65272, 65533, 65533, 65275, 65276, 65533, 160, 173, 65154, 163, 164, 65156, 65533, 65533, 65166, 65167, 65173, 65177, 1548, 65181, 65185, 65189, 1632, 1633, 1634, 1635, 1636, 1637, 1638, 1639, 1640, 1641, 65233, 1563, 65201, 65205, 65209, 1567, 162, 65152, 65153, 65155, 65157, 65226, 65163, 65165, 65169, 65171, 65175, 65179, 65183, 65187, 65191, 65193, 65195, 65197, 65199, 65203, 65207, 65211, 65215, 65217, 65221, 65227, 65231, 166, 172, 247, 215, 65225, 1600, 65235, 65239, 65243, 65247, 65251, 65255, 65259, 65261, 65263, 65267, 65213, 65228, 65230, 65229, 65249, 65149, 1617, 65253, 65257, 65260, 65264, 65266, 65232, 65237, 65269, 65270, 65245, 65241, 65265, 9632, 65533, }; static const unsigned char reverse_plane[17]={ 0, 64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64, }; static const unsigned char reverse_pages[128]={ 0, 61, 100,100,100,100,100,100,131,179,100,100,100,100,100,100, 100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100, 100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100, 100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,206, 100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100, 100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100, 100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100, 100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100, }; static const unsigned short reverse_block[270]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 128, 174, 128, 183, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 197, 207, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 214, 227, 128, 128, 243, 258, 274, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 285, 128, 128, 300, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 316, 332, 345, 358, 128, 128, 128, 128, 128, 372, 388, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 391, 407, 423, 439, 455, 471, 487, 503, 519, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[535]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 26, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 160, 26, 192, 163, 164, 26, 219, 26, 26, 26, 26, 151, 220, 161, 26, 26, 128, 147, 26, 26, 26, 26, 26, 129, 26, 26, 26, 152, 149, 148, 26, 26, 26, 26, 26, 26, 26, 222, 26, 26, 26, 26, 26, 26, 26, 26, 221, 26, 26, 26, 26, 26, 26, 26, 26, 144, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 146, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 172, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 187, 26, 26, 26, 191, 224, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 241, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 37, 26, 26, 26, 26, 26, 26, 26, 26, 26, 130, 131, 26, 26, 26, 145, 26, 26, 26, 26, 26, 26, 26, 26, 150, 26, 26, 26, 26, 26, 26, 26, 133, 26, 134, 26, 26, 26, 26, 26, 26, 26, 26, 26, 141, 26, 26, 26, 140, 26, 26, 26, 142, 26, 26, 26, 143, 26, 26, 26, 138, 26, 26, 26, 26, 136, 26, 26, 26, 26, 26, 26, 26, 137, 26, 26, 26, 26, 139, 26, 26, 26, 26, 26, 26, 26, 135, 26, 26, 26, 132, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 254, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 240, 26, 26, 193, 194, 162, 195, 165, 196, 26, 26, 26, 26, 26, 198, 26, 199, 168, 169, 26, 200, 26, 201, 26, 170, 26, 202, 26, 171, 26, 203, 26, 173, 26, 204, 26, 174, 26, 205, 26, 175, 26, 206, 26, 207, 26, 208, 26, 209, 26, 210, 26, 188, 26, 211, 26, 189, 26, 212, 26, 190, 26, 213, 26, 235, 26, 214, 26, 215, 26, 26, 26, 216, 26, 26, 26, 223, 197, 217, 236, 238, 237, 218, 247, 186, 26, 225, 26, 248, 26, 226, 26, 252, 26, 227, 26, 251, 26, 228, 26, 239, 26, 229, 26, 242, 26, 230, 26, 243, 26, 231, 244, 232, 26, 233, 245, 253, 246, 234, 26, 249, 250, 153, 154, 26, 26, 157, 158, 26, 26, 26, }; FXint FXCP864Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP864Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP864Codec::mibEnum() const { return 2051; } const FXchar* FXCP864Codec::name() const { return "IBM864"; } const FXchar* FXCP864Codec::mimeName() const { return "IBM864"; } const FXchar* const* FXCP864Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp864","IBM864","cp864","csIBM864",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP865Codec.cpp000066400000000000000000000171771455751074500222660ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP865Codec.h" namespace FX { FXIMPLEMENT(FXCP865Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP865.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 199, 252, 233, 226, 228, 224, 229, 231, 234, 235, 232, 239, 238, 236, 196, 197, 201, 230, 198, 244, 246, 242, 251, 249, 255, 214, 220, 248, 163, 216, 8359, 402, 225, 237, 243, 250, 241, 209, 170, 186, 191, 8976, 172, 189, 188, 161, 171, 164, 9617, 9618, 9619, 9474, 9508, 9569, 9570, 9558, 9557, 9571, 9553, 9559, 9565, 9564, 9563, 9488, 9492, 9524, 9516, 9500, 9472, 9532, 9566, 9567, 9562, 9556, 9577, 9574, 9568, 9552, 9580, 9575, 9576, 9572, 9573, 9561, 9560, 9554, 9555, 9579, 9578, 9496, 9484, 9608, 9604, 9612, 9616, 9600, 945, 223, 915, 960, 931, 963, 181, 964, 934, 920, 937, 948, 8734, 966, 949, 8745, 8801, 177, 8805, 8804, 8992, 8993, 247, 8776, 176, 8729, 183, 8730, 8319, 178, 9632, 160, }; static const unsigned char reverse_plane[17]={ 0, 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, }; static const unsigned char reverse_pages[74]={ 0, 61, 61, 61, 61, 61, 61, 61, 118,169,61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, }; static const unsigned short reverse_block[233]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 176, 191, 207, 223, 128, 128, 128, 128, 128, 128, 128, 128, 128, 239, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 252, 265, 280, 296, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 303, 128, 128, 319, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 327, 342, 128, 352, 128, 367, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 383, 399, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 415, 431, 444, 457, 128, 473, 489, 128, 505, 521, 537, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[553]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 255, 173, 26, 156, 175, 26, 26, 26, 26, 26, 166, 174, 170, 26, 26, 26, 248, 241, 253, 26, 26, 230, 26, 250, 26, 26, 167, 26, 172, 171, 26, 168, 26, 26, 26, 26, 142, 143, 146, 128, 26, 144, 26, 26, 26, 26, 26, 26, 165, 26, 26, 26, 26, 153, 26, 157, 26, 26, 26, 154, 26, 26, 225, 133, 160, 131, 26, 132, 134, 145, 135, 138, 130, 136, 137, 141, 161, 140, 139, 26, 164, 149, 162, 147, 26, 148, 246, 155, 151, 163, 150, 129, 26, 26, 152, 26, 26, 159, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 226, 26, 26, 26, 26, 233, 26, 26, 26, 26, 26, 26, 26, 228, 26, 26, 232, 26, 26, 234, 26, 26, 26, 26, 26, 26, 224, 26, 26, 235, 238, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 227, 26, 26, 229, 231, 26, 237, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 252, 26, 26, 26, 26, 26, 26, 26, 158, 26, 26, 26, 26, 26, 26, 26, 26, 26, 249, 251, 26, 26, 26, 236, 26, 26, 26, 26, 26, 26, 26, 26, 26, 239, 26, 26, 26, 26, 26, 26, 26, 26, 247, 26, 26, 26, 26, 26, 26, 26, 240, 26, 26, 243, 242, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 169, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 244, 245, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 196, 26, 179, 26, 26, 26, 26, 26, 26, 26, 26, 26, 218, 26, 26, 26, 191, 26, 26, 26, 192, 26, 26, 26, 217, 26, 26, 26, 195, 26, 26, 26, 26, 180, 26, 26, 26, 26, 26, 26, 26, 194, 26, 26, 26, 26, 193, 26, 26, 26, 26, 26, 26, 26, 197, 26, 26, 26, 205, 186, 213, 214, 201, 184, 183, 187, 212, 211, 200, 190, 189, 188, 198, 199, 204, 181, 182, 185, 209, 210, 203, 207, 208, 202, 216, 215, 206, 26, 26, 26, 223, 26, 26, 26, 220, 26, 26, 26, 219, 26, 26, 26, 221, 26, 26, 26, 222, 176, 177, 178, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 254, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP865Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP865Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP865Codec::mibEnum() const { return 2052; } const FXchar* FXCP865Codec::name() const { return "IBM865"; } const FXchar* FXCP865Codec::mimeName() const { return "IBM865"; } const FXchar* const* FXCP865Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp865","IBM865","cp865","865","csIBM865",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP866Codec.cpp000066400000000000000000000156111455751074500222560ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP866Codec.h" namespace FX { FXIMPLEMENT(FXCP866Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP866.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 9617, 9618, 9619, 9474, 9508, 9569, 9570, 9558, 9557, 9571, 9553, 9559, 9565, 9564, 9563, 9488, 9492, 9524, 9516, 9500, 9472, 9532, 9566, 9567, 9562, 9556, 9577, 9574, 9568, 9552, 9580, 9575, 9576, 9572, 9573, 9561, 9560, 9554, 9555, 9579, 9578, 9496, 9484, 9608, 9604, 9612, 9616, 9600, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1025, 1105, 1028, 1108, 1031, 1111, 1038, 1118, 176, 8729, 183, 8730, 8470, 164, 9632, 160, }; static const unsigned char reverse_plane[17]={ 0, 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, }; static const unsigned char reverse_pages[74]={ 0, 64, 70, 70, 70, 70, 70, 70, 117,165,70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, }; static const unsigned short reverse_block[229]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 175, 191, 207, 223, 239, 255, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 270, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 277, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 293, 309, 322, 335, 128, 351, 367, 128, 383, 399, 415, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[431]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 255, 26, 26, 26, 253, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 248, 26, 26, 26, 26, 26, 26, 250, 26, 26, 26, 26, 26, 26, 26, 26, 240, 26, 26, 242, 26, 26, 244, 26, 26, 26, 26, 26, 26, 246, 26, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 26, 241, 26, 26, 243, 26, 26, 245, 26, 26, 26, 26, 26, 26, 247, 26, 26, 26, 26, 26, 26, 252, 26, 26, 26, 26, 26, 26, 26, 26, 26, 249, 251, 26, 26, 26, 26, 26, 196, 26, 179, 26, 26, 26, 26, 26, 26, 26, 26, 26, 218, 26, 26, 26, 191, 26, 26, 26, 192, 26, 26, 26, 217, 26, 26, 26, 195, 26, 26, 26, 26, 180, 26, 26, 26, 26, 26, 26, 26, 194, 26, 26, 26, 26, 193, 26, 26, 26, 26, 26, 26, 26, 197, 26, 26, 26, 205, 186, 213, 214, 201, 184, 183, 187, 212, 211, 200, 190, 189, 188, 198, 199, 204, 181, 182, 185, 209, 210, 203, 207, 208, 202, 216, 215, 206, 26, 26, 26, 223, 26, 26, 26, 220, 26, 26, 26, 219, 26, 26, 26, 221, 26, 26, 26, 222, 176, 177, 178, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 254, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP866Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP866Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP866Codec::mibEnum() const { return 2086; } const FXchar* FXCP866Codec::name() const { return "IBM866"; } const FXchar* FXCP866Codec::mimeName() const { return "IBM866"; } const FXchar* const* FXCP866Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp866","IBM866","cp866","866","csIBM866",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP869Codec.cpp000066400000000000000000000154351455751074500222650ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP869Codec.h" namespace FX { FXIMPLEMENT(FXCP869Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP869.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 65533, 65533, 65533, 65533, 65533, 65533, 902, 65533, 183, 172, 166, 8216, 8217, 904, 8213, 905, 906, 938, 908, 65533, 65533, 910, 939, 169, 911, 178, 179, 940, 163, 941, 942, 943, 970, 912, 972, 973, 913, 914, 915, 916, 917, 918, 919, 189, 920, 921, 171, 187, 9617, 9618, 9619, 9474, 9508, 922, 923, 924, 925, 9571, 9553, 9559, 9565, 926, 927, 9488, 9492, 9524, 9516, 9500, 9472, 9532, 928, 929, 9562, 9556, 9577, 9574, 9568, 9552, 9580, 931, 932, 933, 934, 935, 936, 937, 945, 946, 947, 9496, 9484, 9608, 9604, 948, 949, 9600, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 963, 962, 964, 900, 173, 177, 965, 966, 967, 167, 968, 901, 176, 168, 969, 971, 944, 974, 9632, 160, }; static const unsigned char reverse_plane[17]={ 0, 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, }; static const unsigned char reverse_pages[74]={ 0, 61, 61, 61, 61, 61, 61, 61, 124,172,61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, }; static const unsigned short reverse_block[236]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 160, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 174, 190, 206, 222, 238, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 253, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 269, 285, 298, 311, 128, 327, 343, 128, 359, 374, 390, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[406]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 255, 26, 26, 156, 26, 26, 138, 245, 249, 151, 26, 174, 137, 240, 26, 26, 248, 241, 153, 154, 26, 26, 26, 136, 26, 26, 26, 175, 26, 171, 26, 26, 26, 26, 239, 247, 134, 26, 141, 143, 144, 26, 146, 26, 149, 152, 161, 164, 165, 166, 167, 168, 169, 170, 172, 173, 181, 182, 183, 184, 189, 190, 198, 199, 26, 207, 208, 209, 210, 211, 212, 213, 145, 150, 155, 157, 158, 159, 252, 214, 215, 216, 221, 222, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 237, 236, 238, 242, 243, 244, 246, 250, 160, 251, 162, 163, 253, 26, 26, 26, 26, 26, 142, 26, 26, 139, 140, 26, 26, 26, 26, 26, 26, 196, 26, 179, 26, 26, 26, 26, 26, 26, 26, 26, 26, 218, 26, 26, 26, 191, 26, 26, 26, 192, 26, 26, 26, 217, 26, 26, 26, 195, 26, 26, 26, 26, 180, 26, 26, 26, 26, 26, 26, 26, 194, 26, 26, 26, 26, 193, 26, 26, 26, 26, 26, 26, 26, 197, 26, 26, 26, 205, 186, 26, 26, 201, 26, 26, 187, 26, 26, 200, 26, 26, 188, 26, 26, 204, 26, 26, 185, 26, 26, 203, 26, 26, 202, 26, 26, 206, 26, 26, 26, 223, 26, 26, 26, 220, 26, 26, 26, 219, 26, 26, 26, 26, 26, 26, 26, 176, 177, 178, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 254, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, }; FXint FXCP869Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP869Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP869Codec::mibEnum() const { return 2054; } const FXchar* FXCP869Codec::name() const { return "IBM869"; } const FXchar* FXCP869Codec::mimeName() const { return "IBM869"; } const FXchar* const* FXCP869Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp869","IBM869","cp869","869","cp-gr","csIBM869",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCP874Codec.cpp000066400000000000000000000134071455751074500222560ustar00rootroot00000000000000#include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXTextCodec.h" #include "FXCP874Codec.h" namespace FX { FXIMPLEMENT(FXCP874Codec,FXTextCodec,nullptr,0) //// Created by codec tool on 03/25/2005 from: CP874.TXT //// static const unsigned short forward_data[256]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 8364, 65533, 65533, 65533, 65533, 8230, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 160, 3585, 3586, 3587, 3588, 3589, 3590, 3591, 3592, 3593, 3594, 3595, 3596, 3597, 3598, 3599, 3600, 3601, 3602, 3603, 3604, 3605, 3606, 3607, 3608, 3609, 3610, 3611, 3612, 3613, 3614, 3615, 3616, 3617, 3618, 3619, 3620, 3621, 3622, 3623, 3624, 3625, 3626, 3627, 3628, 3629, 3630, 3631, 3632, 3633, 3634, 3635, 3636, 3637, 3638, 3639, 3640, 3641, 3642, 65533, 65533, 65533, 65533, 3647, 3648, 3649, 3650, 3651, 3652, 3653, 3654, 3655, 3656, 3657, 3658, 3659, 3660, 3661, 3662, 3663, 3664, 3665, 3666, 3667, 3668, 3669, 3670, 3671, 3672, 3673, 3674, 3675, 65533, 65533, 65533, 65533, }; static const unsigned char reverse_plane[17]={ 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, }; static const unsigned char reverse_pages[73]={ 0, 11, 11, 43, 11, 11, 11, 11, 106,11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, }; static const unsigned short reverse_block[170]={ 0, 16, 32, 48, 64, 80, 96, 112, 128, 128, 144, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 159, 175, 191, 207, 223, 239, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 252, 266, 128, 128, 128, 128, 128, 128, 128, 273, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, }; static const unsigned char reverse_data[289]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 160, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 26, 26, 26, 26, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 26, 26, 26, 26, 150, 151, 26, 26, 26, 145, 146, 26, 26, 147, 148, 26, 26, 149, 26, 26, 26, 133, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 128, 26, 26, 26, }; FXint FXCP874Codec::mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const { if(nsrc<1) return -1; wc=forward_data[(FXuchar)src[0]]; return 1; } FXint FXCP874Codec::wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const { if(ndst<1) return -1; dst[0]=reverse_data[reverse_block[reverse_pages[reverse_plane[wc>>16]+((wc>>10)&63)]+((wc>>4)&63)]+(wc&15)]; return 1; } FXint FXCP874Codec::mibEnum() const { return 5; } const FXchar* FXCP874Codec::name() const { return "IBM874"; } const FXchar* FXCP874Codec::mimeName() const { return "IBM874"; } const FXchar* const* FXCP874Codec::aliases() const { static const FXchar *const list[]={"microsoft-cp874","IBM874","cp874","874",nullptr}; return list; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCURCursor.cpp000066400000000000000000000062041455751074500223770ustar00rootroot00000000000000/******************************************************************************** * * * C U R C u r s o r O b j e c t * * * ********************************************************************************* * Copyright (C) 2001,2022 by Sander Jansen. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXElement.h" #include "FXStream.h" #include "FXMemoryStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXCURCursor.h" /* Notes: - Tossed old code now that FXCursor has an RGBA representation. */ using namespace FX; /*******************************************************************************/ namespace FX { // Suggested file extension const FXchar FXCURCursor::fileExt[]="cur"; // Object implementation FXIMPLEMENT(FXCURCursor,FXCursor,nullptr,0) // Constructor FXCURCursor::FXCURCursor(FXApp* a,const FXuchar *pix):FXCursor(a,nullptr,0,0,0,0){ if(pix){ FXMemoryStream ms(FXStreamLoad,const_cast(pix)); fxloadICO(ms,data,width,height,hotx,hoty); options|=CURSOR_OWNED; } } // Save pixel data only, in CUR format FXbool FXCURCursor::savePixels(FXStream& store) const { if(fxsaveICO(store,data,width,height,hotx,hoty)){ return true; } return false; } // Load cursor mask and image FXbool FXCURCursor::loadPixels(FXStream & store){ if(options&CURSOR_OWNED){freeElms(data);} if(fxloadICO(store,data,width,height,hotx,hoty)){ options|=CURSOR_OWNED; return true; } return false; } // Destroy FXCURCursor::~FXCURCursor(){ } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCalendar.cpp000066400000000000000000000347251455751074500222720ustar00rootroot00000000000000/******************************************************************************** * * * B a s e C a l e n d a r W i d g e t * * * ********************************************************************************* * Copyright (C) 2006,2022 by Sander Jansen. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxascii.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXObjectList.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FXFrame.h" #include "FXLabel.h" #include "FXComposite.h" #include "FXPacker.h" #include "FXButton.h" #include "FXArrowButton.h" #include "FXMenuButton.h" #include "FXToolTip.h" #include "FXOptionMenu.h" #include "FXHorizontalFrame.h" #include "FXFont.h" #include "FXDate.h" #include "FXPopup.h" #include "FXCalendarView.h" #include "FXCalendar.h" /* Notes: - Most of calendar is implemented in FXCalendarView */ #define CALENDAR_MASK (CALENDAR_SINGLESELECT|CALENDAR_BROWSESELECT|CALENDAR_WEEKNUMBERS|CALENDAR_STATIC|CALENDAR_HIDEOTHER) using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXCalendar) FXCalendarMap[]={ FXMAPFUNC(SEL_REPLACED,FXCalendar::ID_CALENDAR,FXCalendar::onCmdDate), FXMAPFUNCS(SEL_COMMAND,FXCalendar::ID_MONTH_START,FXCalendar::ID_MONTH_END,FXCalendar::onCmdMonth), FXMAPFUNC(SEL_COMMAND,FXCalendar::ID_NEXTYEAR,FXCalendar::onCmdNextYear), FXMAPFUNC(SEL_COMMAND,FXCalendar::ID_PREVYEAR,FXCalendar::onCmdPrevYear), FXMAPFUNC(SEL_COMMAND,FXCalendar::ID_NEXTMONTH,FXCalendar::onCmdNextMonth), FXMAPFUNC(SEL_COMMAND,FXCalendar::ID_PREVMONTH,FXCalendar::onCmdPrevMonth), FXMAPFUNC(SEL_COMMAND,FXCalendar::ID_MONTH,FXCalendar::onCmdSelectMonth), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_SETVALUE,FXCalendar::onFwdToView), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_SETINTVALUE,FXCalendar::onFwdToView), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_GETINTVALUE,FXCalendar::onFwdToView), FXMAPFUNC(SEL_COMMAND,FXCalendar::ID_CALENDAR,FXCalendar::onFwdToTarget), FXMAPFUNC(SEL_CHANGED,FXCalendar::ID_CALENDAR,FXCalendar::onFwdToTarget), FXMAPFUNC(SEL_UPDATE,FXCalendar::ID_CALENDAR,FXCalendar::onFwdToTarget), }; // Implementation FXIMPLEMENT(FXCalendar,FXPacker,FXCalendarMap,ARRAYNUMBER(FXCalendarMap)); FXCalendar::FXCalendar(){ flags|=FLAG_ENABLED; } // Construct and initialize calendar widget FXCalendar::FXCalendar(FXComposite *p,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXPacker(p,opts,x,y,w,h,0,0,0,0,0,0){ flags|=FLAG_ENABLED; target=tgt; message=sel; // Caption above calendar frame=new FXHorizontalFrame(this,LAYOUT_SIDE_TOP|LAYOUT_FILL_X,0,0,0,0,0,0,0,0,0,0); // Popup for months monthpopup=new FXPopup(this); months[ 0]=new FXOption(monthpopup,tr(FXDate::monthName( 1)),nullptr,this,ID_MONTH_START+ 0,OPTIONMENU_NOGLYPH|LAYOUT_LEFT|JUSTIFY_CENTER_X|ICON_AFTER_TEXT); months[ 1]=new FXOption(monthpopup,tr(FXDate::monthName( 2)),nullptr,this,ID_MONTH_START+ 1,OPTIONMENU_NOGLYPH|LAYOUT_LEFT|JUSTIFY_CENTER_X|ICON_AFTER_TEXT); months[ 2]=new FXOption(monthpopup,tr(FXDate::monthName( 3)),nullptr,this,ID_MONTH_START+ 2,OPTIONMENU_NOGLYPH|LAYOUT_LEFT|JUSTIFY_CENTER_X|ICON_AFTER_TEXT); months[ 3]=new FXOption(monthpopup,tr(FXDate::monthName( 4)),nullptr,this,ID_MONTH_START+ 3,OPTIONMENU_NOGLYPH|LAYOUT_LEFT|JUSTIFY_CENTER_X|ICON_AFTER_TEXT); months[ 4]=new FXOption(monthpopup,tr(FXDate::monthName( 5)),nullptr,this,ID_MONTH_START+ 4,OPTIONMENU_NOGLYPH|LAYOUT_LEFT|JUSTIFY_CENTER_X|ICON_AFTER_TEXT); months[ 5]=new FXOption(monthpopup,tr(FXDate::monthName( 6)),nullptr,this,ID_MONTH_START+ 5,OPTIONMENU_NOGLYPH|LAYOUT_LEFT|JUSTIFY_CENTER_X|ICON_AFTER_TEXT); months[ 6]=new FXOption(monthpopup,tr(FXDate::monthName( 7)),nullptr,this,ID_MONTH_START+ 6,OPTIONMENU_NOGLYPH|LAYOUT_LEFT|JUSTIFY_CENTER_X|ICON_AFTER_TEXT); months[ 7]=new FXOption(monthpopup,tr(FXDate::monthName( 8)),nullptr,this,ID_MONTH_START+ 7,OPTIONMENU_NOGLYPH|LAYOUT_LEFT|JUSTIFY_CENTER_X|ICON_AFTER_TEXT); months[ 8]=new FXOption(monthpopup,tr(FXDate::monthName( 9)),nullptr,this,ID_MONTH_START+ 8,OPTIONMENU_NOGLYPH|LAYOUT_LEFT|JUSTIFY_CENTER_X|ICON_AFTER_TEXT); months[ 9]=new FXOption(monthpopup,tr(FXDate::monthName(10)),nullptr,this,ID_MONTH_START+ 9,OPTIONMENU_NOGLYPH|LAYOUT_LEFT|JUSTIFY_CENTER_X|ICON_AFTER_TEXT); months[10]=new FXOption(monthpopup,tr(FXDate::monthName(11)),nullptr,this,ID_MONTH_START+10,OPTIONMENU_NOGLYPH|LAYOUT_LEFT|JUSTIFY_CENTER_X|ICON_AFTER_TEXT); months[11]=new FXOption(monthpopup,tr(FXDate::monthName(12)),nullptr,this,ID_MONTH_START+11,OPTIONMENU_NOGLYPH|LAYOUT_LEFT|JUSTIFY_CENTER_X|ICON_AFTER_TEXT); // Month selector arrows[0]=new FXArrowButton(frame,this,ID_PREVMONTH,ARROW_LEFT|ARROW_REPEAT|ARROW_TOOLBAR|FRAME_RAISED|LAYOUT_FILL_Y,0,0,0,0,2,2,4,4); month=new FXOptionMenu(frame,monthpopup,OPTIONMENU_NOGLYPH|OPTIONMENU_TOOLBAR|FRAME_RAISED|JUSTIFY_CENTER_X|JUSTIFY_CENTER_Y|LAYOUT_CENTER_Y,0,0,0,0); month->setTarget(this); month->setSelector(ID_MONTH); arrows[1]=new FXArrowButton(frame,this,ID_NEXTMONTH,ARROW_RIGHT|ARROW_REPEAT|ARROW_TOOLBAR|FRAME_RAISED|LAYOUT_FILL_Y,0,0,0,0,2,2,4,4); // Year selector arrows[2]=new FXArrowButton(frame,this,ID_NEXTYEAR,ARROW_RIGHT|ARROW_REPEAT|ARROW_TOOLBAR|FRAME_RAISED|LAYOUT_FILL_Y|LAYOUT_RIGHT,0,0,0,0,2,2,4,4); year=new FXLabel(frame,"0000",nullptr,LAYOUT_RIGHT|LAYOUT_CENTER_Y); arrows[3]=new FXArrowButton(frame,this,ID_PREVYEAR,ARROW_LEFT|ARROW_REPEAT|ARROW_TOOLBAR|FRAME_RAISED|LAYOUT_FILL_Y|LAYOUT_RIGHT,0,0,0,0,2,2,4,4); // Main widget view=new FXCalendarView(this,this,ID_CALENDAR,(options&CALENDAR_MASK)|LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_SIDE_BOTTOM); // Fix the options if(options&FRAME_SUNKEN && !(options&FRAME_RAISED)){ if(options&FRAME_THICK) frame->setFrameStyle(FRAME_RAISED|FRAME_THICK); else frame->setFrameStyle(FRAME_RAISED); } else{ frame->setFrameStyle(FRAME_NONE); } } // Create X window void FXCalendar::create(){ FXDate date(view->getCurrentDate()); FXPacker::create(); year->setText(FXString::value(date.year())); month->setCurrentNo(date.month()-1); } // Enable the window void FXCalendar::enable(){ FXPacker::enable(); view->enable(); year->enable(); month->enable(); arrows[0]->enable(); arrows[1]->enable(); arrows[2]->enable(); arrows[3]->enable(); } // Disable the window void FXCalendar::disable(){ FXPacker::disable(); view->disable(); year->disable(); month->disable(); arrows[0]->disable(); arrows[1]->disable(); arrows[2]->disable(); arrows[3]->disable(); } // Set date void FXCalendar::setCurrentDate(FXDate date,FXbool notify){ view->setCurrentDate(date,notify); } // Get the current date FXDate FXCalendar::getCurrentDate() const { return view->getCurrentDate(); } // Set the current month void FXCalendar::setCurrentMonth(FXint mo,FXbool notify){ view->setCurrentMonth(mo,notify); } // Return the current month shown FXint FXCalendar::getCurrentMonth() const { return view->getCurrentMonth(); } // Set the Calendar Style void FXCalendar::setCalendarStyle(FXuint style){ view->setCalendarStyle(style); } // Get the Calendar Style FXuint FXCalendar::getCalendarStyle() const { return view->getCalendarStyle(); } // Set the first day of the week [0 -> 6] void FXCalendar::setFirstDay(FXint d){ view->setFirstDay(d); view->update(); } // Get the first day of the week [0 -> 6] FXint FXCalendar::getFirstDay() const { return view->getFirstDay(); } // Change the Frame Style void FXCalendar::setFrameStyle(FXuint s){ FXPacker::setFrameStyle(s); if(options&FRAME_SUNKEN && !(options&FRAME_RAISED)){ if(options&FRAME_THICK) frame->setFrameStyle(FRAME_RAISED|FRAME_THICK); else frame->setFrameStyle(FRAME_RAISED); } else{ frame->setFrameStyle(FRAME_NONE); } } // Set the back color void FXCalendar::setBackColor(FXColor c){ FXPacker::setBackColor(c); view->setBackColor(c); } // Get the back color FXColor FXCalendar::getBackColor() const { return view->getBackColor(); } // Set the display color of titles void FXCalendar::setTitleColor(FXColor c){ view->setTitleColor(c); } // Get the display color of titles FXColor FXCalendar::getTitleColor() const { return view->getTitleColor(); } // Set the display color of titles void FXCalendar::setTitleBackColor(FXColor c){ view->setTitleBackColor(c); } // Get the display color of titles FXColor FXCalendar::getTitleBackColor() const { return view->getTitleBackColor(); } // Set the display color of non-weekend days void FXCalendar::setDayColor(FXColor c){ view->setDayColor(c); } // Get the display color of non-weekend days FXColor FXCalendar::getDayColor() const { return view->getDayColor(); } // Set the display color of non-weekend days not in the current month void FXCalendar::setOtherDayColor(FXColor c){ view->setOtherDayColor(c); } // Get the display color of non-weekend days not in the current month FXColor FXCalendar::getOtherDayColor() const { return view->getOtherDayColor(); } // Set the display color of today void FXCalendar::setTodayColor(FXColor c){ view->setTodayColor(c); } // Get the display color of today FXColor FXCalendar::getTodayColor() const { return view->getTodayColor(); } // Set the display color of days in the weekend void FXCalendar::setWeekendColor(FXColor c){ view->setWeekendColor(c); } // Get the display color of days in the weekend FXColor FXCalendar::getWeekendColor() const { return view->getWeekendColor(); } // Set the display color of days in the weekend not in the current month void FXCalendar::setOtherWeekendColor(FXColor c){ view->setOtherWeekendColor(c); } // Get the display color of days in the weekend not in the current month FXColor FXCalendar::getOtherWeekendColor() const { return view->getOtherWeekendColor(); } // Set font used by the header void FXCalendar::setHeaderFont(FXFont *fnt){ year->setFont(fnt); months[0]->setFont(fnt); months[1]->setFont(fnt); months[2]->setFont(fnt); months[3]->setFont(fnt); months[4]->setFont(fnt); months[5]->setFont(fnt); months[6]->setFont(fnt); months[7]->setFont(fnt); months[8]->setFont(fnt); months[9]->setFont(fnt); months[10]->setFont(fnt); months[11]->setFont(fnt); } // Get font used by the header FXFont* FXCalendar::getHeaderFont() const { return year->getFont(); } // Set font used by the calendar void FXCalendar::setCalendarFont(FXFont *fnt){ view->setFont(fnt); } // Get font used by the calendar FXFont* FXCalendar::getCalendarFont() const { return view->getFont(); } // Switch date long FXCalendar::onCmdDate(FXObject*,FXSelector,void* ptr){ FXDate date((FXuint)(FXival)(ptr)); year->setText(FXString::value(date.year())); month->setCurrentNo(view->getCurrentMonth()-1); if(target) target->tryHandle(this,FXSEL(SEL_CHANGED,message),ptr); return 1; } // Switch month long FXCalendar::onCmdMonth(FXObject*,FXSelector sel,void*){ view->setCurrentMonth((FXSELID(sel)-ID_MONTH_START)+1,true); return 1; } // Select month long FXCalendar::onCmdSelectMonth(FXObject*,FXSelector,void*ptr){ view->setCurrentMonth(1+(FXint)(FXival)(ptr),true); return 1; } // Go to next year long FXCalendar::onCmdNextYear(FXObject*,FXSelector,void*){ FXDate date=view->getCurrentDate(); date.addYears(1); view->setCurrentDate(date,true); return 1; } // Go to previous year long FXCalendar::onCmdPrevYear(FXObject*,FXSelector,void*){ FXDate date=view->getCurrentDate(); date.addYears(-1); view->setCurrentDate(date,true); return 1; } // Go to next month long FXCalendar::onCmdNextMonth(FXObject*,FXSelector,void*){ FXDate date=view->getCurrentDate(); date.addMonths(1); view->setCurrentDate(date,true); return 1; } // Go to previous month long FXCalendar::onCmdPrevMonth(FXObject*,FXSelector,void*){ FXDate date=view->getCurrentDate(); date.addMonths(-1); view->setCurrentDate(date,true); return 1; } // Forward to calendar view long FXCalendar::onFwdToView(FXObject*sender,FXSelector sel,void*ptr){ return view->handle(sender,sel,ptr); } // Forward from calendar view long FXCalendar::onFwdToTarget(FXObject*,FXSelector sel,void* ptr){ return target && target->tryHandle(this,FXSEL(FXSELTYPE(sel),message),ptr); } // Destroy FXCalendar::~FXCalendar(){ delete monthpopup; view=(FXCalendarView*)-1L; year=(FXLabel*)-1L; month=(FXOptionMenu*)-1L; monthpopup=(FXPopup*)-1L; frame=(FXHorizontalFrame*)-1L; months[0]=(FXOption*)-1L; months[1]=(FXOption*)-1L; months[2]=(FXOption*)-1L; months[3]=(FXOption*)-1L; months[4]=(FXOption*)-1L; months[5]=(FXOption*)-1L; months[6]=(FXOption*)-1L; months[7]=(FXOption*)-1L; months[8]=(FXOption*)-1L; months[9]=(FXOption*)-1L; months[10]=(FXOption*)-1L; months[11]=(FXOption*)-1L; arrows[0]=(FXArrowButton*)-1L; arrows[1]=(FXArrowButton*)-1L; arrows[2]=(FXArrowButton*)-1L; arrows[3]=(FXArrowButton*)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCalendarView.cpp000066400000000000000000000541301455751074500231150ustar00rootroot00000000000000/******************************************************************************** * * * B a s e C a l e n d a r W i d g e t * * * ********************************************************************************* * Copyright (C) 2006,2022 by Sander Jansen. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxascii.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXColors.h" #include "FXSize.h" #include "FXPoint.h" #include "FXObjectList.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FXFont.h" #include "FXDate.h" #include "FXCalendarView.h" /* Notes: - ISO8601 weeknumbers are implemented for weeks starting at monday and ending at sunday */ #define SELECT_MASK (CALENDAR_SINGLESELECT|CALENDAR_BROWSESELECT) #define CALENDAR_MASK (CALENDAR_SINGLESELECT|CALENDAR_BROWSESELECT|CALENDAR_WEEKNUMBERS|CALENDAR_STATIC|CALENDAR_HIDEOTHER) using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXCalendarView) FXCalendarViewMap[]={ FXMAPFUNC(SEL_PAINT,0,FXCalendarView::onPaint), FXMAPFUNC(SEL_LEFTBUTTONPRESS,0,FXCalendarView::onLeftBtnPress), FXMAPFUNC(SEL_LEFTBUTTONRELEASE,0,FXCalendarView::onLeftBtnRelease), FXMAPFUNC(SEL_KEYPRESS,0,FXCalendarView::onKeyPress), FXMAPFUNC(SEL_FOCUSIN,0,FXCalendarView::onFocusIn), FXMAPFUNC(SEL_FOCUSOUT,0,FXCalendarView::onFocusOut), FXMAPFUNC(SEL_CLICKED,0,FXCalendarView::onClicked), FXMAPFUNC(SEL_DOUBLECLICKED,0,FXCalendarView::onDoubleClicked), FXMAPFUNC(SEL_TRIPLECLICKED,0,FXCalendarView::onTripleClicked), FXMAPFUNC(SEL_COMMAND,0,FXCalendarView::onCommand), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_SETVALUE,FXCalendarView::onCmdSetValue), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_SETINTVALUE,FXCalendarView::onCmdSetIntValue), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_GETINTVALUE,FXCalendarView::onCmdGetIntValue), }; // Implementation FXIMPLEMENT(FXCalendarView,FXWindow,FXCalendarViewMap,ARRAYNUMBER(FXCalendarViewMap)) // For serialization FXCalendarView::FXCalendarView(){ flags|=FLAG_SHOWN|FLAG_ENABLED; font=(FXFont*)-1L; } // Construct and initialize FXCalendarView::FXCalendarView(FXComposite *p,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXWindow(p,opts,x,y,w,h){ flags|=FLAG_SHOWN|FLAG_ENABLED; font=getApp()->getNormalFont(); target=tgt; message=sel; has_selection=false; selected=current=FXDate::localDate(); firstday=FXDate::Sun; // Sunday // Setup Default Colors todayColor=FXRGB(0,180,0); titleColor=getApp()->getBackColor(); titleBackColor=getApp()->getShadowColor(); dayColor=getApp()->getForeColor(); otherDayColor=getApp()->getShadowColor(); weekendColor=FXRGB(180,0,0); otherWeekendColor=makeHiliteColor(FXRGB(200,100,100)); backColor=getApp()->getBackColor(); // Update for date updateview(false); } // Create X window void FXCalendarView::create(){ FXWindow::create(); font->create(); } // Detach window void FXCalendarView::detach(){ FXWindow::detach(); font->detach(); } // Enable the window void FXCalendarView::enable(){ if(!(flags&FLAG_ENABLED)){ FXWindow::enable(); update(); } } // Disable the window void FXCalendarView::disable(){ if(flags&FLAG_ENABLED){ FXWindow::disable(); update(); } } // Set the Calendar Style void FXCalendarView::setCalendarStyle(FXuint style){ FXuint opts=((style^options)&CALENDAR_MASK)^options; if(options!=opts){ options=opts; recalc(); layout(); update(); } } // Get the Calendar Style FXuint FXCalendarView::getCalendarStyle() const{ return (options&CALENDAR_MASK); } // Set the display color of titles void FXCalendarView::setTitleColor(FXColor clr){ if(titleColor!=clr){ titleColor=clr; update(); } } // Set the display background color of titles void FXCalendarView::setTitleBackColor(FXColor clr){ if(titleBackColor!=clr){ titleBackColor=clr; update(); } } // Set the display color of non-weekend days void FXCalendarView::setDayColor(FXColor clr){ if(dayColor!=clr){ dayColor=clr; update(); } } // Set the display color of non-weekend days not in the current month void FXCalendarView::setOtherDayColor(FXColor clr){ if(otherDayColor!=clr){ otherDayColor=clr; update(); } } // Set the display color of today void FXCalendarView::setTodayColor(FXColor clr){ if(todayColor!=clr){ todayColor=clr; update(); } } // Set the display color of days in the weekend void FXCalendarView::setWeekendColor(FXColor clr){ if(weekendColor!=clr){ weekendColor=clr; update(); } } // Set the display color of days in the weekend not in the current month void FXCalendarView::setOtherWeekendColor(FXColor clr){ if(otherWeekendColor!=clr){ otherWeekendColor=clr; update(); } } // Compute default width FXint FXCalendarView::getDefaultWidth(){ FXint cw=0,tw,i; FXString text; for(i=0; i<7; i++){ text=tr(FXDate::dayNameShort(i)); tw=font->getTextWidth(text); if(tw>cw) cw=tw; } if(options&CALENDAR_WEEKNUMBERS){ text=tr("Wk"); tw=font->getTextWidth(text); if(tw>cw) cw=tw; return (cw+4)*8; } return (cw+4)*7; } // Compute default height FXint FXCalendarView::getDefaultHeight(){ return (font->getFontHeight()+4)*7; } // Into focus chain void FXCalendarView::setFocus(){ FXWindow::setFocus(); setDefault(true); flags&=~FLAG_UPDATE; } // Out of focus chain void FXCalendarView::killFocus(){ FXWindow::killFocus(); setDefault(maybe); flags|=FLAG_UPDATE; } // Set focus on given date void FXCalendarView::moveFocus(FXDate f){ if((options&CALENDAR_STATIC) && f.month()!=month) return; setCurrentDate(f,true); } // Get date at x,y if any FXbool FXCalendarView::getDateAt(FXint x,FXint y,FXDate& date) const { FXint ncols=(options&CALENDAR_WEEKNUMBERS)?8:7; FXint nrows=7; FXint cw=width/ncols; FXint ch=height/nrows; FXint cwr=width%ncols; FXint chr=height%nrows; FXint col=0,row=0,xx=0,yy=0; FXint columnwidth[8]; FXint rowheight[7]; FXint i,e; // Calculate column widths for(i=e=0; i=ncols){ columnwidth[i]++; e-=ncols; } } // Calculate row heights for(i=e=0; i=nrows){ rowheight[i]++; e-=nrows; } } // Filter out obvious cases (clicked on headers) if(ygetTextWidth("88",2); FXint fontheight=font->getFontHeight(); FXint i=0,c=0,r=0,e=0; FXint xx=0,yy=0; FXint columnwidth[8]; // Width of each column FXint columnoffset[8]; // Text Offset in each column FXint rowheight[7]; // Height of each column FXString text; FXDate pd=ds; // The acual painting FXDCWindow dc(this,(FXEvent*)ptr); // Calculate column widths for(i=0,e=0; i=ncols){ columnwidth[i]++; e-=ncols; } columnoffset[i]=(columnwidth[i]-textwidth)/2; } // Calculate row heights for(i=0,e=0; i=nrows){ rowheight[i]++; e-=nrows; } } // Paint backgrounds if(isEnabled()){ dc.setForeground(backColor); } else{ dc.setForeground(getApp()->getBaseColor()); } dc.fillRectangle(0,rowheight[0],width,height-rowheight[0]); dc.setForeground(titleBackColor); dc.fillRectangle(0,0,width,rowheight[0]); // Paint separator between week numbers and days if(options&CALENDAR_WEEKNUMBERS) { dc.setForeground(getApp()->getForeColor()); dc.fillRectangle(columnwidth[0]-1,0,1,height); } // Paint header dc.setForeground(titleColor); dc.setFont(font); // Week number caption if(options&CALENDAR_WEEKNUMBERS){ text=tr("Wk"); dc.drawText((columnwidth[0]-font->getTextWidth(text))/2,(rowheight[0]-fontheight)/2+font->getFontAscent(),text); xx+=columnwidth[0]; } // Day of week captions for(c=firstday,i=coloffset; cgetTextWidth(text))/2,(rowheight[0]-fontheight)/2+font->getFontAscent(),text); xx+=columnwidth[i]; } // Next row yy+=rowheight[0]; // Paint days dc.setForeground(getApp()->getForeColor()); for(r=1; rgetTextWidth(text)-columnoffset[0],yy+(rowheight[r]-fontheight)/2+font->getFontAscent(),text); xx+=columnwidth[0]; } for(c=coloffset; cgetSelbackColor()); } else{ dc.setForeground(getApp()->getShadowColor()); } dc.fillRectangle(xx,yy,columnwidth[c],rowheight[r]); dc.setForeground(getApp()->getSelforeColor()); } else{ if(pd==now){ dc.setForeground(todayColor); } else{ if(pd.dayOfWeek()==0 || pd.dayOfWeek()==6){ if(pd.month()==month) dc.setForeground(weekendColor); else dc.setForeground(otherWeekendColor); } else{ if(pd.month()==month) dc.setForeground(dayColor); else dc.setForeground(otherDayColor); } } } // Draw Text dc.drawText(xx+columnwidth[c]-font->getTextWidth(text)-columnoffset[c],yy+(rowheight[r]-fontheight)/2+font->getFontAscent(),text); if(hasFocus() && current==pd){ dc.drawFocusRectangle(xx,yy,columnwidth[c],rowheight[r]); } ++pd; // Next day xx+=columnwidth[c]; // Next column } // Next Row yy+=rowheight[r]; } return 1; } // Pressed left button long FXCalendarView::onLeftBtnPress(FXObject*,FXSelector,void* ptr){ FXEvent* ev=(FXEvent*)ptr; flags&=~FLAG_TIP; handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr); if(isEnabled()){ grab(); if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONPRESS,message),ptr)) return 1; flags&=~FLAG_UPDATE; FXDate cd; if(getDateAt(ev->click_x,ev->click_y,cd)){ if(((options&CALENDAR_STATIC) || (options&CALENDAR_HIDEOTHER)) && cd.month()!=month){ flags|=FLAG_PRESSED; return 1; } setCurrentDate(cd,true); if((options&SELECT_MASK)==CALENDAR_SINGLESELECT){ if(has_selection && current==selected) state=true; else state=false; selectDate(cd,true); } } flags|=FLAG_PRESSED; return 1; } return 0; } // If window can have focus FXbool FXCalendarView::canFocus() const { return true; } // Gained focus long FXCalendarView::onFocusIn(FXObject* sender,FXSelector sel,void* ptr){ FXWindow::onFocusIn(sender,sel,ptr); markdirty(current); return 1; } // Lost focus long FXCalendarView::onFocusOut(FXObject* sender,FXSelector sel,void* ptr){ FXWindow::onFocusOut(sender,sel,ptr); markdirty(current); return 1; } // Released left button long FXCalendarView::onLeftBtnRelease(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; if(isEnabled()){ ungrab(); flags|=FLAG_UPDATE; flags&=~FLAG_PRESSED; if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONRELEASE,message),ptr)) return 1; if((options&SELECT_MASK)==CALENDAR_SINGLESELECT){ if(state){ killSelection(true); } } // Generate clicked callbacks if(event->click_count==1){ handle(this,FXSEL(SEL_CLICKED,0),(void*)(FXuval)current.getJulian()); } else if(event->click_count==2){ handle(this,FXSEL(SEL_DOUBLECLICKED,0),(void*)(FXuval)current.getJulian()); } else if(event->click_count==3){ handle(this,FXSEL(SEL_TRIPLECLICKED,0),(void*)(FXuval)current.getJulian()); } handle(this,FXSEL(SEL_COMMAND,0),(void*)(FXuval)current.getJulian()); return 1; } return 0; } // Command message long FXCalendarView::onCommand(FXObject*,FXSelector,void* ptr){ return target && target->tryHandle(this,FXSEL(SEL_COMMAND,message),ptr); } // Clicked in list long FXCalendarView::onClicked(FXObject*,FXSelector,void* ptr){ return target && target->tryHandle(this,FXSEL(SEL_CLICKED,message),ptr); } // Double clicked in list; ptr may or may not point to an item long FXCalendarView::onDoubleClicked(FXObject*,FXSelector,void* ptr){ return target && target->tryHandle(this,FXSEL(SEL_DOUBLECLICKED,message),ptr); } // Triple clicked in list; ptr may or may not point to an item long FXCalendarView::onTripleClicked(FXObject*,FXSelector,void* ptr){ return target && target->tryHandle(this,FXSEL(SEL_TRIPLECLICKED,message),ptr); } // Update value from a message long FXCalendarView::onCmdSetValue(FXObject*,FXSelector,void* ptr){ setCurrentDate(FXDate((FXuint)(FXuval)ptr)); return 1; } // Obtain value from list long FXCalendarView::onCmdGetIntValue(FXObject*,FXSelector,void* ptr){ *((FXuint*)ptr)=getCurrentDate().getJulian(); return 1; } // Update value from a message long FXCalendarView::onCmdSetIntValue(FXObject*,FXSelector,void* ptr){ setCurrentDate(FXDate(*((FXuint*)ptr))); return 1; } // Key pressed long FXCalendarView::onKeyPress(FXObject*sender,FXSelector sel,void* ptr){ FXEvent* event=(FXEvent*)ptr; FXDate date=current; flags&=~FLAG_TIP; // Bounce to focus widget if(getFocus() && getFocus()->handle(sender,sel,ptr)) return 1; if(!isEnabled()) return 0; // Try target first if(target && target->tryHandle(this,FXSEL(SEL_KEYPRESS,message),ptr)) return 1; // Eat keystroke switch(event->code){ case KEY_Up: case KEY_KP_Up: moveFocus(current-7); return 1; break; case KEY_Down: case KEY_KP_Down: moveFocus(current+7); return 1; break; case KEY_Right: case KEY_KP_Right: moveFocus(current+1); return 1; break; case KEY_Left: case KEY_KP_Left: moveFocus(current-1); return 1; break; case KEY_space: case KEY_Return: case KEY_KP_Enter: if(has_selection && current==selected) killSelection(true); else selectDate(current); return 1; break; case KEY_Page_Down: case KEY_KP_Page_Down: date.addMonths(1); setCurrentDate(date,true); return 1; break; case KEY_Page_Up: case KEY_KP_Page_Up: date.addMonths(-1); setCurrentDate(date,true); return 1; break; case KEY_Home: case KEY_KP_Home: setCurrentDate(FXDate::localDate(),true); return 1; break; case KEY_End: case KEY_KP_End: if(has_selection) setCurrentDate(selected,true); else getApp()->beep(); return 1; break; } return 0; } // Mark as dirty void FXCalendarView::markdirty(FXDate d){ if(xid){ FXint ncols = ((options&CALENDAR_WEEKNUMBERS) ? 8 : 7); FXint nrows = 7; FXint cw = width / ncols; FXint ch = height / nrows; FXint cwr = width % ncols; FXint chr = height % nrows; FXint days = d-ds; FXint col = (days%7) + ((options&CALENDAR_WEEKNUMBERS) ? 1 : 0); FXint row = (days/7) + 1; FXint xx=0,yy=0,ww=0,hh=0,i=0,e=0; // Calculate xx for(i=0,e=0; i=ncols){ xx++; e-=ncols; } } // Calculate ww ww=cw; e+=cwr; if(e>=ncols){ ww++; e-=ncols; } // Calculate yy for(i=0,e=0; i=nrows){ yy++; e-=nrows; } } // Calculate hh hh=ch; e+=chr; if(e>=nrows){ hh++; e-=nrows; } update(xx,yy,ww,hh); } } // Update view void FXCalendarView::updateview(FXbool notify){ FXDate ms=(current-(current.day()-1)); month=current.month(); ds=ms-(7-(firstday-ms.dayOfWeek()))%7; if(target && notify) target->tryHandle(this,FXSEL(SEL_REPLACED,message),(void*)(FXival)current.getJulian()); } // Set the current month; current day will be properly updated for the choosen month void FXCalendarView::setCurrentMonth(FXint m,FXbool notify){ if(m<1 || m>12){ fxerror("%s::setCurrentMonth: Invalid month argument.\n",getClassName()); } if(month!=m){ // Set a new current date FXint day=current.day(); current.setDate(current.year(),m,1); if(current.daysInMonth()>day) current.setDate(current.year(),m,day); else current.setDate(current.year(),m,current.daysInMonth()); // Update the GUI and do the same as setCurrentDate would do. // Don't call setCurrentDate since it wouldn't update the complete view. updateview(); update(0,0,width,height); // Notify item change if(notify && target){ target->tryHandle(this,FXSEL(SEL_CHANGED,message),(void*)(FXival)current.getJulian()); } // In browse select mode, select this item if((options&SELECT_MASK)==CALENDAR_BROWSESELECT){ selectDate(current,notify); } } } // Get the selected date, if any FXbool FXCalendarView::getSelectedDate(FXDate& date) const { if(((options&SELECT_MASK)==CALENDAR_SINGLESELECT)){ if(has_selection){ date=selected; return true; } return false; } else{ date=selected; return true; } } // Select Date void FXCalendarView::selectDate(FXDate d,FXbool notify){ if(d!=selected || !has_selection){ has_selection=true; // Within the current month view if((selected>=ds) && (selected<=(ds+41))){ markdirty(selected); } // Within the current month view if((d.month()==month) && (d.year()==selected.year())){ selected=d; markdirty(selected); } else{ selected=d; updateview(); update(0,0,width,height); } if(notify && target){ target->tryHandle(this,FXSEL(SEL_SELECTED,message),(void*)(FXival)selected.getJulian()); } } } // Deselect Date void FXCalendarView::killSelection(FXbool notify){ if(((options&SELECT_MASK)==CALENDAR_SINGLESELECT) && has_selection){ has_selection=false; if(notify && target){ target->tryHandle(this,FXSEL(SEL_DESELECTED,message),(void*)(FXival)selected.getJulian()); } markdirty(selected); } } // Set Date void FXCalendarView::setCurrentDate(FXDate d,FXbool notify){ if(d!=current){ // Update View and repaint everyting if(d(ds+41) || (((options&CALENDAR_HIDEOTHER) || ((options&SELECT_MASK)==CALENDAR_BROWSESELECT)) && d.month()!=month)){ current=d; updateview(); update(0,0,width,height); } // Within the current month view. just mark fields used dirty else{ markdirty(current); markdirty(d); current=d; } // Notify item change if(notify && target){ target->tryHandle(this,FXSEL(SEL_CHANGED,message),(void*)(FXival)current.getJulian()); } } // In browse select mode, select this item if((options&SELECT_MASK)==CALENDAR_BROWSESELECT){ selectDate(current,notify); } } // Set the first day of the week [0...6] void FXCalendarView::setFirstDay(FXint d){ if(d<0 || d>6){ fxerror("%s::setFirstDay: invalid day argument.\n",getClassName()); } if(firstday!=d){ firstday=d; updateview(); update(); } } // Change the font void FXCalendarView::setFont(FXFont *fnt){ if(!fnt){ fxerror("%s::setFont: NULL font specified.\n",getClassName()); } if(font!=fnt){ font=fnt; recalc(); update(); } } // Destroy it FXCalendarView::~FXCalendarView(){ font=(FXFont*)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCanvas.cpp000066400000000000000000000056141455751074500217670ustar00rootroot00000000000000/******************************************************************************** * * * C a n v a s W i n d o w O b j e c t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXCanvas.h" using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXCanvas) FXCanvasMap[]={ FXMAPFUNC(SEL_PAINT,0,FXCanvas::onPaint) }; // Object implementation FXIMPLEMENT(FXCanvas,FXWindow,FXCanvasMap,ARRAYNUMBER(FXCanvasMap)) // For serialization FXCanvas::FXCanvas(){ flags|=FLAG_ENABLED|FLAG_SHOWN; } // Make a canvas FXCanvas::FXCanvas(FXComposite* p,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXWindow(p,opts,x,y,w,h){ flags|=FLAG_ENABLED|FLAG_SHOWN; backColor=getApp()->getBackColor(); target=tgt; message=sel; } // It can be focused on FXbool FXCanvas::canFocus() const { return true; } // Canvas is an object drawn by another long FXCanvas::onPaint(FXObject*,FXSelector,void* ptr){ return target && target->handle(this,FXSEL(SEL_PAINT,message),ptr); } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCheckButton.cpp000066400000000000000000000326221455751074500227640ustar00rootroot00000000000000/******************************************************************************** * * * C h e c k B u t t o n O b j e c t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FXCheckButton.h" /* Notes: - Works as intended. */ #define CHECKBUTTON_MASK (CHECKBUTTON_AUTOGRAY|CHECKBUTTON_AUTOHIDE|CHECKBUTTON_PLUS) using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXCheckButton) FXCheckButtonMap[]={ FXMAPFUNC(SEL_UPDATE,0,FXCheckButton::onUpdate), FXMAPFUNC(SEL_PAINT,0,FXCheckButton::onPaint), FXMAPFUNC(SEL_ENTER,0,FXCheckButton::onEnter), FXMAPFUNC(SEL_LEAVE,0,FXCheckButton::onLeave), FXMAPFUNC(SEL_FOCUSIN,0,FXCheckButton::onFocusIn), FXMAPFUNC(SEL_FOCUSOUT,0,FXCheckButton::onFocusOut), FXMAPFUNC(SEL_UNGRABBED,0,FXCheckButton::onUngrabbed), FXMAPFUNC(SEL_LEFTBUTTONPRESS,0,FXCheckButton::onLeftBtnPress), FXMAPFUNC(SEL_LEFTBUTTONRELEASE,0,FXCheckButton::onLeftBtnRelease), FXMAPFUNC(SEL_KEYPRESS,0,FXCheckButton::onKeyPress), FXMAPFUNC(SEL_KEYRELEASE,0,FXCheckButton::onKeyRelease), FXMAPFUNC(SEL_KEYPRESS,FXWindow::ID_HOTKEY,FXCheckButton::onHotKeyPress), FXMAPFUNC(SEL_KEYRELEASE,FXWindow::ID_HOTKEY,FXCheckButton::onHotKeyRelease), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_CHECK,FXCheckButton::onCheck), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_UNCHECK,FXCheckButton::onUncheck), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_UNKNOWN,FXCheckButton::onUnknown), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_SETVALUE,FXCheckButton::onCmdSetValue), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_SETINTVALUE,FXCheckButton::onCmdSetIntValue), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_GETINTVALUE,FXCheckButton::onCmdGetIntValue), }; // Object implementation FXIMPLEMENT(FXCheckButton,FXLabel,FXCheckButtonMap,ARRAYNUMBER(FXCheckButtonMap)) // Deserialization FXCheckButton::FXCheckButton(){ checkColor=0; boxColor=0; check=false; oldcheck=false; } // Make a check button FXCheckButton::FXCheckButton(FXComposite* p,const FXString& text,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb):FXLabel(p,text,nullptr,opts,x,y,w,h,pl,pr,pt,pb){ checkColor=getApp()->getForeColor(); boxColor=getApp()->getBackColor(); target=tgt; message=sel; check=false; oldcheck=false; } // If window can have focus FXbool FXCheckButton::canFocus() const { return true; } // Get default width FXint FXCheckButton::getDefaultWidth(){ FXint tw=0,s=0,w; if(!label.empty()){ tw=labelWidth(label); s=4; } if(!(options&(ICON_AFTER_TEXT|ICON_BEFORE_TEXT))) w=FXMAX(tw,13); else w=tw+13+s; return padleft+padright+w+(border<<1); } // Get default height FXint FXCheckButton::getDefaultHeight(){ FXint th=0,h; if(!label.empty()){ th=labelHeight(label); } if(!(options&(ICON_ABOVE_TEXT|ICON_BELOW_TEXT))) h=FXMAX(th,13); else h=th+13; return padtop+padbottom+h+(border<<1); } // Check button void FXCheckButton::setCheck(FXuchar state,FXbool notify){ if(check!=state){ check=state; update(); if(notify && target){target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXuval)check);} } } // Change state to checked long FXCheckButton::onCheck(FXObject*,FXSelector,void*){ setCheck(true); return 1; } // Change state to unchecked long FXCheckButton::onUncheck(FXObject*,FXSelector,void*){ setCheck(false); return 1; } // Change state to indeterminate long FXCheckButton::onUnknown(FXObject*,FXSelector,void*){ setCheck(maybe); return 1; } // Update value from a message long FXCheckButton::onCmdSetValue(FXObject*,FXSelector,void* ptr){ setCheck((FXuchar)(FXuval)ptr); return 1; } // Update value from a message long FXCheckButton::onCmdSetIntValue(FXObject*,FXSelector,void* ptr){ setCheck((FXuchar)*((FXint*)ptr)); return 1; } // Obtain value from text field long FXCheckButton::onCmdGetIntValue(FXObject*,FXSelector,void* ptr){ *((FXint*)ptr)=getCheck(); return 1; } // Implement auto-hide or auto-gray modes long FXCheckButton::onUpdate(FXObject* sender,FXSelector sel,void* ptr){ if(!FXLabel::onUpdate(sender,sel,ptr)){ if(options&CHECKBUTTON_AUTOHIDE){if(shown()){hide();recalc();}} if(options&CHECKBUTTON_AUTOGRAY){disable();} } return 1; } // Gained focus long FXCheckButton::onFocusIn(FXObject* sender,FXSelector sel,void* ptr){ FXLabel::onFocusIn(sender,sel,ptr); update(border,border,width-(border<<1),height-(border<<1)); return 1; } // Lost focus long FXCheckButton::onFocusOut(FXObject* sender,FXSelector sel,void* ptr){ FXLabel::onFocusOut(sender,sel,ptr); update(border,border,width-(border<<1),height-(border<<1)); return 1; } // Entered button long FXCheckButton::onEnter(FXObject* sender,FXSelector sel,void* ptr){ FXLabel::onEnter(sender,sel,ptr); if(isEnabled() && (flags&FLAG_PRESSED)) setCheck(!oldcheck); return 1; } // Left button long FXCheckButton::onLeave(FXObject* sender,FXSelector sel,void* ptr){ FXLabel::onLeave(sender,sel,ptr); if(isEnabled() && (flags&FLAG_PRESSED)) setCheck(oldcheck); return 1; } // Pressed mouse button long FXCheckButton::onLeftBtnPress(FXObject*,FXSelector,void* ptr){ handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr); flags&=~FLAG_TIP; if(isEnabled() && !(flags&FLAG_PRESSED)){ grab(); if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONPRESS,message),ptr)) return 1; oldcheck=check; setCheck(!oldcheck); flags|=FLAG_PRESSED; flags&=~FLAG_UPDATE; return 1; } return 0; } // Released mouse button long FXCheckButton::onLeftBtnRelease(FXObject*,FXSelector,void* ptr){ if(isEnabled() && (flags&FLAG_PRESSED)){ ungrab(); flags|=FLAG_UPDATE; flags&=~FLAG_PRESSED; if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONRELEASE,message),ptr)) return 1; if(check!=oldcheck && target){ target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXuval)check); } return 1; } return 0; } // The widget lost the grab for some reason long FXCheckButton::onUngrabbed(FXObject* sender,FXSelector sel,void* ptr){ FXLabel::onUngrabbed(sender,sel,ptr); setCheck(oldcheck); flags&=~FLAG_PRESSED; flags|=FLAG_UPDATE; return 1; } // Key Press long FXCheckButton::onKeyPress(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; flags&=~FLAG_TIP; if(isEnabled()){ if(target && target->tryHandle(this,FXSEL(SEL_KEYPRESS,message),ptr)) return 1; if(!(flags&FLAG_PRESSED) && (event->code==KEY_space || event->code==KEY_KP_Space)){ oldcheck=check; setCheck(!oldcheck); flags|=FLAG_PRESSED; flags&=~FLAG_UPDATE; return 1; } } return 0; } // Key Release long FXCheckButton::onKeyRelease(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; if(isEnabled()){ if(target && target->tryHandle(this,FXSEL(SEL_KEYRELEASE,message),ptr)) return 1; if((flags&FLAG_PRESSED) && (event->code==KEY_space || event->code==KEY_KP_Space)){ flags|=FLAG_UPDATE; flags&=~FLAG_PRESSED; if(check!=oldcheck && target){ target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXuval)check); } return 1; } } return 0; } // Hot key combination pressed long FXCheckButton::onHotKeyPress(FXObject*,FXSelector,void* ptr){ handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr); flags&=~FLAG_TIP; if(isEnabled() && !(flags&FLAG_PRESSED)){ oldcheck=check; setCheck(!oldcheck); flags|=FLAG_PRESSED; flags&=~FLAG_UPDATE; } return 1; } // Hot key combination released long FXCheckButton::onHotKeyRelease(FXObject*,FXSelector,void*){ if(isEnabled() && (flags&FLAG_PRESSED)){ flags|=FLAG_UPDATE; flags&=~FLAG_PRESSED; if(check!=oldcheck && target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXuval)check); } return 1; } // Handle repaint long FXCheckButton::onPaint(FXObject*,FXSelector,void* ptr){ FXEvent *ev=(FXEvent*)ptr; FXint tw=0,th=0,tx,ty,ix,iy; FXDCWindow dc(this,ev); // Figure text size if(!label.empty()){ tw=labelWidth(label); th=labelHeight(label); } // Placement just_x(tx,ix,tw,13); just_y(ty,iy,th,13); // Widget background dc.setForeground(backColor); dc.fillRectangle(ev->rect.x,ev->rect.y,ev->rect.w,ev->rect.h); // Check background if(check==maybe || !isEnabled()) dc.setForeground(baseColor); else dc.setForeground(boxColor); dc.fillRectangle(ix+2,iy+2,9,9); // Check border if(options&CHECKBUTTON_PLUS){ dc.setForeground(textColor); dc.drawRectangle(ix+2,iy+2,8,8); } else{ dc.setForeground(shadowColor); dc.fillRectangle(ix,iy,12,1); dc.fillRectangle(ix,iy,1,12); dc.setForeground(borderColor); dc.fillRectangle(ix+1,iy+1,10,1); dc.fillRectangle(ix+1,iy+1,1,10); dc.setForeground(hiliteColor); dc.fillRectangle(ix,iy+12,13,1); dc.fillRectangle(ix+12,iy,1,13); dc.setForeground(baseColor); dc.fillRectangle(ix+1,iy+11,11,1); dc.fillRectangle(ix+11,iy+1,1,11); } // Check color if(check==maybe || !isEnabled()) dc.setForeground(shadowColor); else dc.setForeground(checkColor); // Show as + if(options&CHECKBUTTON_PLUS){ if(check!=true){ dc.fillRectangle(ix+6,iy+4,1,5); } dc.fillRectangle(ix+4,iy+6,5,1); } // Show as v else{ if(check!=false){ FXSegment seg[6]; #ifdef WIN32 seg[0].x1=3+ix; seg[0].y1=5+iy; seg[0].x2=5+ix; seg[0].y2=7+iy; seg[1].x1=3+ix; seg[1].y1=6+iy; seg[1].x2=5+ix; seg[1].y2=8+iy; seg[2].x1=3+ix; seg[2].y1=7+iy; seg[2].x2=5+ix; seg[2].y2=9+iy; seg[3].x1=5+ix; seg[3].y1=7+iy; seg[3].x2=10+ix; seg[3].y2=2+iy; seg[4].x1=5+ix; seg[4].y1=8+iy; seg[4].x2=10+ix; seg[4].y2=3+iy; seg[5].x1=5+ix; seg[5].y1=9+iy; seg[5].x2=10+ix; seg[5].y2=4+iy; #else seg[0].x1=3+ix; seg[0].y1=5+iy; seg[0].x2=5+ix; seg[0].y2=7+iy; seg[1].x1=3+ix; seg[1].y1=6+iy; seg[1].x2=5+ix; seg[1].y2=8+iy; seg[2].x1=3+ix; seg[2].y1=7+iy; seg[2].x2=5+ix; seg[2].y2=9+iy; seg[3].x1=5+ix; seg[3].y1=7+iy; seg[3].x2=9+ix; seg[3].y2=3+iy; seg[4].x1=5+ix; seg[4].y1=8+iy; seg[4].x2=9+ix; seg[4].y2=4+iy; seg[5].x1=5+ix; seg[5].y1=9+iy; seg[5].x2=9+ix; seg[5].y2=5+iy; #endif dc.drawLineSegments(seg,6); } } // Text if(!label.empty()){ dc.setFont(font); if(isEnabled()){ dc.setForeground(textColor); drawLabel(dc,label,hotoff,tx,ty,tw,th); if(hasFocus()){ dc.drawFocusRectangle(tx-1,ty-1,tw+2,th+2); } } else{ dc.setForeground(hiliteColor); drawLabel(dc,label,hotoff,tx+1,ty+1,tw,th); dc.setForeground(shadowColor); drawLabel(dc,label,hotoff,tx,ty,tw,th); } } // Frame drawFrame(dc,0,0,width,height); return 1; } // Set check color void FXCheckButton::setCheckColor(FXColor clr){ if(clr!=checkColor){ checkColor=clr; update(); } } // Set box color void FXCheckButton::setBoxColor(FXColor clr){ if(clr!=boxColor){ boxColor=clr; update(); } } // Change check button style void FXCheckButton::setCheckButtonStyle(FXuint style){ FXuint opts=(options&~CHECKBUTTON_MASK) | (style&CHECKBUTTON_MASK); if(options!=opts){ options=opts; update(); } } // Return current check button style FXuint FXCheckButton::getCheckButtonStyle() const { return (options&CHECKBUTTON_MASK); } // Save object to stream void FXCheckButton::save(FXStream& store) const { FXLabel::save(store); store << checkColor; store << boxColor; } // Load object from stream void FXCheckButton::load(FXStream& store){ FXLabel::load(store); store >> checkColor; store >> boxColor; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXChoiceBox.cpp000066400000000000000000000200751455751074500224150ustar00rootroot00000000000000/******************************************************************************** * * * C h o i c e B o x * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXObjectList.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXAccelTable.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXIcon.h" #include "FXSeparator.h" #include "FXLabel.h" #include "FXButton.h" #include "FXHorizontalFrame.h" #include "FXVerticalFrame.h" #include "FXScrollBar.h" #include "FXList.h" #include "FXChoiceBox.h" #include "icons.h" /* Notes: - Maybe allow setting initial value which selected. - Maybe have multiple choice capability. - Maybe have list of icons for each list item. */ // Padding for message box buttons #define HORZ_PAD 30 #define VERT_PAD 2 using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXChoiceBox) FXChoiceBoxMap[]={ FXMAPFUNC(SEL_COMMAND,FXChoiceBox::ID_CANCEL,FXChoiceBox::onCmdCancel), FXMAPFUNC(SEL_COMMAND,FXChoiceBox::ID_ACCEPT,FXChoiceBox::onCmdClicked), FXMAPFUNC(SEL_DOUBLECLICKED,FXChoiceBox::ID_CLICKED,FXChoiceBox::onCmdClicked), }; // Object implementation FXIMPLEMENT(FXChoiceBox,FXDialogBox,FXChoiceBoxMap,ARRAYNUMBER(FXChoiceBoxMap)) // Construct choice box with given caption, icon, message text, and with choices from array of strings FXChoiceBox::FXChoiceBox(FXWindow* own,const FXString& caption,const FXString& text,FXIcon* icn,const FXchar** choices,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXDialogBox(own,caption,opts|DECOR_TITLE|DECOR_BORDER,x,y,w,h,10,10,10,10, 10,10){ FXint n; initialize(text,icn); n=list->fillItems(choices); list->setNumVisible(FXMIN(n,5)); } // Construct choice box with given caption, icon, message text, and with choices from newline separated strings FXChoiceBox::FXChoiceBox(FXWindow* own,const FXString& caption,const FXString& text,FXIcon* icn,const FXString& choices,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXDialogBox(own,caption,opts|DECOR_TITLE|DECOR_BORDER,x,y,w,h,10,10,10,10, 10,10){ FXint n; initialize(text,icn); n=list->fillItems(choices); list->setNumVisible(FXMIN(n,5)); } // Construct free floating choice box with given caption, icon, message text, and with choices from array of strings FXChoiceBox::FXChoiceBox(FXApp* a,const FXString& caption,const FXString& text,FXIcon* icn,const FXchar** choices,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXDialogBox(a,caption,opts|DECOR_TITLE|DECOR_BORDER,x,y,w,h,10,10,10,10, 10,10){ FXint n; initialize(text,icn); n=list->fillItems(choices); list->setNumVisible(FXMIN(n,5)); } // Construct free floating choice box with given caption, icon, message text, and with choices from newline separated strings FXChoiceBox::FXChoiceBox(FXApp* a,const FXString& caption,const FXString& text,FXIcon* icn,const FXString& choices,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXDialogBox(a,caption,opts|DECOR_TITLE|DECOR_BORDER,x,y,w,h,10,10,10,10, 10,10){ FXint n; initialize(text,icn); n=list->fillItems(choices); list->setNumVisible(FXMIN(n,5)); } // Build contents void FXChoiceBox::initialize(const FXString& text,FXIcon* icn){ FXHorizontalFrame* buttons=new FXHorizontalFrame(this,LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH,0,0,0,0,0,0,0,0); new FXButton(buttons,tr("&OK"),nullptr,this,ID_ACCEPT,BUTTON_INITIAL|BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_CENTER_Y|LAYOUT_RIGHT,0,0,0,0,HORZ_PAD,HORZ_PAD,VERT_PAD,VERT_PAD); new FXButton(buttons,tr("&Cancel"),nullptr,this,ID_CANCEL,BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_CENTER_Y|LAYOUT_RIGHT,0,0,0,0,HORZ_PAD,HORZ_PAD,VERT_PAD,VERT_PAD); new FXHorizontalSeparator(this,SEPARATOR_GROOVE|LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X); FXHorizontalFrame* toppart=new FXHorizontalFrame(this,LAYOUT_SIDE_TOP|LAYOUT_FILL_X,0,0,0,0, 0,0,0,0, 10,10); new FXLabel(toppart,FXString::null,icn,ICON_BEFORE_TEXT|JUSTIFY_CENTER_X|JUSTIFY_CENTER_Y|LAYOUT_FILL_Y|LAYOUT_FILL_X); new FXLabel(toppart,text,nullptr,JUSTIFY_LEFT|ICON_BEFORE_TEXT|LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FILL_X); FXHorizontalFrame* midpart=new FXHorizontalFrame(this,FRAME_SUNKEN|FRAME_THICK|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0, 0,0,0,0, 10,10); list=new FXList(midpart,this,ID_CLICKED,LIST_BROWSESELECT|LAYOUT_FILL_Y|LAYOUT_FILL_X|HSCROLLING_OFF); } // Close dialog when double-clicked in list or hit accept long FXChoiceBox::onCmdClicked(FXObject*,FXSelector,void*){ getApp()->stopModal(this,list->getCurrentItem()); hide(); return 1; } // Close dialog with a cancel long FXChoiceBox::onCmdCancel(FXObject*,FXSelector,void*){ getApp()->stopModal(this,-1); hide(); return 1; } // We have to do this so as to force the initial text to be seleced FXuint FXChoiceBox::execute(FXuint placement){ create(); list->setFocus(); show(placement); return getApp()->runModalFor(this); } // Save object to stream void FXChoiceBox::save(FXStream& store) const { FXDialogBox::save(store); store << list; } // Load object from stream void FXChoiceBox::load(FXStream& store){ FXDialogBox::load(store); store >> list; } // Destroy choice box FXChoiceBox::~FXChoiceBox(){ list=(FXList*)-1L; } /*******************************************************************************/ // Show a modal choice dialog FXint FXChoiceBox::ask(FXWindow* owner,FXuint opts,const FXString& caption,const FXString& text,FXIcon* icon,const FXchar** choices){ FXChoiceBox box(owner,caption,text,icon,choices,opts); return box.execute(PLACEMENT_OWNER); } // Show a modal choice dialog FXint FXChoiceBox::ask(FXWindow* owner,FXuint opts,const FXString& caption,const FXString& text,FXIcon* icon,const FXString& choices){ FXChoiceBox box(owner,caption,text,icon,choices,opts); return box.execute(PLACEMENT_OWNER); } // Show a modal choice dialog, in free floating window FXint FXChoiceBox::ask(FXApp* app,FXuint opts,const FXString& caption,const FXString& text,FXIcon* icon,const FXchar** choices){ FXChoiceBox box(app,caption,text,icon,choices,opts); return box.execute(PLACEMENT_SCREEN); } // Show a modal choice dialog, in free floating window FXint FXChoiceBox::ask(FXApp* app,FXuint opts,const FXString& caption,const FXString& text,FXIcon* icon,const FXString& choices){ FXChoiceBox box(app,caption,text,icon,choices,opts); return box.execute(PLACEMENT_SCREEN); } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXColorBar.cpp000066400000000000000000000255611455751074500222620ustar00rootroot00000000000000/******************************************************************************** * * * C o l o r B a r W i d g e t * * * ********************************************************************************* * Copyright (C) 2001,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FXImage.h" #include "FXColorBar.h" /* Notes: */ #define BAR_WIDTH 30 #define BAR_MASK (COLORBAR_HORIZONTAL|COLORBAR_VERTICAL) using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXColorBar) FXColorBarMap[]={ FXMAPFUNC(SEL_PAINT,0,FXColorBar::onPaint), FXMAPFUNC(SEL_MOTION,0,FXColorBar::onMotion), FXMAPFUNC(SEL_LEFTBUTTONPRESS,0,FXColorBar::onLeftBtnPress), FXMAPFUNC(SEL_LEFTBUTTONRELEASE,0,FXColorBar::onLeftBtnRelease), FXMAPFUNC(SEL_QUERY_TIP,0,FXColorBar::onQueryTip), FXMAPFUNC(SEL_QUERY_HELP,0,FXColorBar::onQueryHelp), FXMAPFUNC(SEL_COMMAND,FXColorBar::ID_SETHELPSTRING,FXColorBar::onCmdSetHelp), FXMAPFUNC(SEL_COMMAND,FXColorBar::ID_GETHELPSTRING,FXColorBar::onCmdGetHelp), FXMAPFUNC(SEL_COMMAND,FXColorBar::ID_SETTIPSTRING,FXColorBar::onCmdSetTip), FXMAPFUNC(SEL_COMMAND,FXColorBar::ID_GETTIPSTRING,FXColorBar::onCmdGetTip), }; // Object implementation FXIMPLEMENT(FXColorBar,FXFrame,FXColorBarMap,ARRAYNUMBER(FXColorBarMap)) // Init FXColorBar::FXColorBar(){ flags|=FLAG_ENABLED; hsv[0]=0.0f; hsv[1]=0.0f; hsv[2]=1.0f; } // Make a color bar FXColorBar::FXColorBar(FXComposite* p,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb):FXFrame(p,opts,x,y,w,h,pl,pr,pt,pb){ flags|=FLAG_ENABLED; target=tgt; message=sel; bar=new FXImage(getApp(),nullptr,IMAGE_DITHER|IMAGE_KEEP|IMAGE_OWNED|IMAGE_SHMI|IMAGE_SHMP,1,1); hsv[0]=0.0f; hsv[1]=0.0f; hsv[2]=1.0f; } // Create window void FXColorBar::create(){ FXFrame::create(); updatebar(); bar->create(); } // Detach window void FXColorBar::detach(){ FXFrame::detach(); bar->detach(); } // Resize the bar void FXColorBar::layout(){ FXint ww,hh; ww=width-padleft-padright-(border<<1)-4; hh=height-padtop-padbottom-(border<<1)-4; if(ww<1) ww=1; if(hh<1) hh=1; if(bar->getWidth()!=ww || bar->getHeight()!=hh){ bar->resize(ww,hh); updatebar(); bar->render(); } flags&=~FLAG_DIRTY; } // Recompute the bar image void FXColorBar::updatebar(){ FXint x,y,w,h; FXColor clr; FXfloat r,g,b,d; w=bar->getWidth(); h=bar->getHeight(); if(options&COLORBAR_VERTICAL){ if(1setPixel(x,y,clr); } } } else{ if(1setPixel(x,y,clr); } } } } // Get default width FXint FXColorBar::getDefaultWidth(){ FXint w=(options&COLORBAR_VERTICAL)?BAR_WIDTH:1; return w+4+padleft+padright+(border<<1); } // Get default height FXint FXColorBar::getDefaultHeight(){ FXint h=(options&COLORBAR_VERTICAL)?1:BAR_WIDTH; return h+4+padtop+padbottom+(border<<1); } // Set help using a message long FXColorBar::onCmdSetHelp(FXObject*,FXSelector,void* ptr){ setHelpText(*((FXString*)ptr)); return 1; } // Get help using a message long FXColorBar::onCmdGetHelp(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getHelpText(); return 1; } // Set tip using a message long FXColorBar::onCmdSetTip(FXObject*,FXSelector,void* ptr){ setTipText(*((FXString*)ptr)); return 1; } // Get tip using a message long FXColorBar::onCmdGetTip(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getTipText(); return 1; } // We were asked about tip text long FXColorBar::onQueryTip(FXObject* sender,FXSelector sel,void* ptr){ if(FXFrame::onQueryTip(sender,sel,ptr)) return 1; if((flags&FLAG_TIP) && !tip.empty()){ sender->handle(this,FXSEL(SEL_COMMAND,ID_SETSTRINGVALUE),(void*)&tip); return 1; } return 0; } // We were asked about status text long FXColorBar::onQueryHelp(FXObject* sender,FXSelector sel,void* ptr){ if(FXFrame::onQueryHelp(sender,sel,ptr)) return 1; if((flags&FLAG_HELP) && !help.empty()){ sender->handle(this,FXSEL(SEL_COMMAND,ID_SETSTRINGVALUE),(void*)&help); return 1; } return 0; } // Handle repaint long FXColorBar::onPaint(FXObject*,FXSelector,void* ptr){ FXEvent *ev=(FXEvent*)ptr; FXDCWindow dc(this,ev); dc.setForeground(backColor); dc.fillRectangle(border,border,padleft,height-(border<<1)); dc.fillRectangle(width-padright-border,border,padright,height-(border<<1)); dc.fillRectangle(border+padleft,border,width-padleft-padright-(border<<1),padtop); dc.fillRectangle(border+padleft,height-padbottom-border,width-padleft-padright-(border<<1),padbottom); dc.drawImage(bar,padleft+border+2,padtop+border+2); drawDoubleSunkenRectangle(dc,padleft+border,padtop+border,width-padright-padleft-(border<<1),height-padbottom-padtop-(border<<1)); drawFrame(dc,0,0,width,height); if(options&COLORBAR_VERTICAL) drawDoubleRaisedRectangle(dc,border+padleft+2,border+padtop+2+(FXint)((1.0f-hsv[2])*(bar->getHeight()-4)),bar->getWidth(),4); else drawDoubleRaisedRectangle(dc,border+padleft+2+(FXint)(hsv[2]*(bar->getWidth()-4)),border+padtop+2,4,bar->getHeight()); return 1; } // Moving long FXColorBar::onMotion(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; FXint xx,yy,ww,hh,travel,p; FXfloat v=hsv[2]; if(flags&FLAG_PRESSED){ xx=border+padleft+2; yy=border+padtop+2; ww=bar->getWidth(); hh=bar->getHeight(); if(options&COLORBAR_VERTICAL){ travel=hh-4; p=yy+hh-event->win_y-2; } else{ travel=ww-4; p=event->win_x-xx-2; } if(p<0) p=0; if(p>travel) p=travel; if(0tryHandle(this,FXSEL(SEL_CHANGED,message),(void*)hsv); } flags|=FLAG_CHANGED; return 1; } return 0; } // Move spot to change hue, saturation long FXColorBar::onLeftBtnPress(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; FXint xx,yy,ww,hh,travel,p; FXfloat v=hsv[2]; flags&=~FLAG_TIP; if(isEnabled()){ grab(); if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONPRESS,message),ptr)) return 1; xx=border+padleft+2; yy=border+padtop+2; ww=bar->getWidth(); hh=bar->getHeight(); if(options&COLORBAR_VERTICAL){ travel=hh-4; p=yy+hh-event->win_y-2; } else{ travel=ww-4; p=event->win_x-xx-2; } if(p<0) p=0; if(p>travel) p=travel; if(0tryHandle(this,FXSEL(SEL_CHANGED,message),(void*)hsv); } flags|=FLAG_PRESSED; flags&=~FLAG_UPDATE; } return 1; } // End spot movement mode long FXColorBar::onLeftBtnRelease(FXObject*,FXSelector,void* ptr){ FXuint changed=(flags&FLAG_CHANGED); if(isEnabled()){ ungrab(); flags|=FLAG_UPDATE; flags&=~FLAG_PRESSED; flags&=~FLAG_CHANGED; if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONRELEASE,message),ptr)) return 1; if(changed && target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)hsv); return 1; } return 1; } // Change hue void FXColorBar::setHue(FXfloat h){ h=Math::fclamp(0.0f,h,360.0f); if(h!=hsv[0]){ hsv[0]=h; updatebar(); bar->render(); update(padleft+border+2,padtop+border+2,width-padleft-padright-(border<<1)-4,height-padtop-padbottom-(border<<1)-4); } } // Change saturation void FXColorBar::setSat(FXfloat s){ s=Math::fclamp(0.0f,s,1.0f); if(s!=hsv[1]){ hsv[1]=s; updatebar(); bar->render(); update(padleft+border+2,padtop+border+2,width-padleft-padright-(border<<1)-4,height-padtop-padbottom-(border<<1)-4); } } // Change saturation void FXColorBar::setVal(FXfloat v){ v=Math::fclamp(0.0f,v,1.0f); if(v!=hsv[2]){ hsv[2]=v; update(padleft+border+2,padtop+border+2,width-padleft-padright-(border<<1)-4,height-padtop-padbottom-(border<<1)-4); } } // Set color bar options void FXColorBar::setBarStyle(FXuint style){ FXuint opts=(options&~BAR_MASK) | (style&BAR_MASK); if(options!=opts){ options=opts; recalc(); update(); } } // Get color bar options FXuint FXColorBar::getBarStyle() const { return (options&BAR_MASK); } // Save data void FXColorBar::save(FXStream& store) const { FXFrame::save(store); store << bar; store << hsv[0]; store << hsv[1]; store << hsv[2]; store << tip; store << help; } // Load data void FXColorBar::load(FXStream& store){ FXFrame::load(store); store >> bar; store >> hsv[0]; store >> hsv[1]; store >> hsv[2]; store >> tip; store >> help; } // Destroy FXColorBar::~FXColorBar(){ delete bar; bar=(FXImage*)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXColorDialog.cpp000066400000000000000000000253011455751074500227450ustar00rootroot00000000000000/******************************************************************************** * * * C o l o r D i a l o g * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXFrame.h" #include "FXLabel.h" #include "FXButton.h" #include "FXComposite.h" #include "FXPacker.h" #include "FXShell.h" #include "FXTopWindow.h" #include "FXDialogBox.h" #include "FXColorSelector.h" #include "FXColorDialog.h" /* Notes: - Need shared instance of this dialog to pop up when double-clicking on a color well. */ using namespace FX; /*******************************************************************************/ namespace FX { // Color dialog registry section name const FXchar FXColorDialog::sectionName[]="Color Dialog"; // Map FXDEFMAP(FXColorDialog) FXColorDialogMap[]={ FXMAPFUNC(SEL_CHANGED,FXColorDialog::ID_COLORSELECTOR,FXColorDialog::onChgColor), FXMAPFUNC(SEL_COMMAND,FXColorDialog::ID_COLORSELECTOR,FXColorDialog::onCmdColor), FXMAPFUNC(SEL_COMMAND,FXColorDialog::ID_SETINTVALUE,FXColorDialog::onCmdSetIntValue), FXMAPFUNC(SEL_COMMAND,FXColorDialog::ID_GETINTVALUE,FXColorDialog::onCmdGetIntValue), }; // Object implementation FXIMPLEMENT(FXColorDialog,FXDialogBox,FXColorDialogMap,ARRAYNUMBER(FXColorDialogMap)) // Construct color dialog box FXColorDialog::FXColorDialog(FXWindow* own,const FXString& name,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXDialogBox(own,name,opts|DECOR_TITLE|DECOR_BORDER|DECOR_RESIZE|DECOR_CLOSE,x,y,w,h,0,0,0,0,4,4){ colorbox=new FXColorSelector(this,this,ID_COLORSELECTOR,LAYOUT_FILL_X|LAYOUT_FILL_Y); colorbox->acceptButton()->setTarget(this); colorbox->acceptButton()->setSelector(FXDialogBox::ID_ACCEPT); colorbox->cancelButton()->setTarget(this); colorbox->cancelButton()->setSelector(FXDialogBox::ID_CANCEL); } // Construct free-floating color dialog box FXColorDialog::FXColorDialog(FXApp* a,const FXString& name,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXDialogBox(a,name,opts|DECOR_TITLE|DECOR_BORDER|DECOR_RESIZE|DECOR_CLOSE,x,y,w,h,0,0,0,0,4,4){ colorbox=new FXColorSelector(this,this,ID_COLORSELECTOR,LAYOUT_FILL_X|LAYOUT_FILL_Y); colorbox->acceptButton()->setTarget(this); colorbox->acceptButton()->setSelector(FXDialogBox::ID_ACCEPT); colorbox->cancelButton()->setTarget(this); colorbox->cancelButton()->setSelector(FXDialogBox::ID_CANCEL); } // Create server-side resources void FXColorDialog::create(){ readRegistry(); FXDialogBox::create(); } // Destroy server-side resources void FXColorDialog::destroy(){ FXDialogBox::destroy(); writeRegistry(); } // Load settings from registry void FXColorDialog::readRegistry(){ setWidth(getApp()->reg().readIntEntry(sectionName,"width",getWidth())); setHeight(getApp()->reg().readIntEntry(sectionName,"height",getHeight())); setWellColor( 0,getApp()->reg().readColorEntry(sectionName,"WA",FXRGBA(255,255,255,255))); setWellColor( 1,getApp()->reg().readColorEntry(sectionName,"WB",FXRGBA(204,204,204,255))); setWellColor( 2,getApp()->reg().readColorEntry(sectionName,"WC",FXRGBA(153,153,153,255))); setWellColor( 3,getApp()->reg().readColorEntry(sectionName,"WD",FXRGBA(102,102,102,255))); setWellColor( 4,getApp()->reg().readColorEntry(sectionName,"WE",FXRGBA( 51, 51, 51,255))); setWellColor( 5,getApp()->reg().readColorEntry(sectionName,"WF",FXRGBA( 0, 0, 0,255))); setWellColor( 6,getApp()->reg().readColorEntry(sectionName,"WG",FXRGBA(255, 0, 0,255))); setWellColor( 7,getApp()->reg().readColorEntry(sectionName,"WH",FXRGBA( 0,255, 0,255))); setWellColor( 8,getApp()->reg().readColorEntry(sectionName,"WI",FXRGBA( 0, 0,255,255))); setWellColor( 9,getApp()->reg().readColorEntry(sectionName,"WJ",FXRGBA( 0,255,255,255))); setWellColor(10,getApp()->reg().readColorEntry(sectionName,"WK",FXRGBA(255,255, 0,255))); setWellColor(11,getApp()->reg().readColorEntry(sectionName,"WL",FXRGBA(255, 0,255,255))); setWellColor(12,getApp()->reg().readColorEntry(sectionName,"WM",FXRGBA(255,165, 0,255))); setWellColor(13,getApp()->reg().readColorEntry(sectionName,"WN",FXRGBA(153, 0, 0,255))); setWellColor(14,getApp()->reg().readColorEntry(sectionName,"WO",FXRGBA( 0,153, 0,255))); setWellColor(15,getApp()->reg().readColorEntry(sectionName,"WP",FXRGBA( 0, 0,153,255))); setWellColor(16,getApp()->reg().readColorEntry(sectionName,"WQ",FXRGBA( 0,153,153,255))); setWellColor(17,getApp()->reg().readColorEntry(sectionName,"WR",FXRGBA(153,153, 0,255))); setWellColor(18,getApp()->reg().readColorEntry(sectionName,"WS",FXRGBA(153, 0,153,255))); setWellColor(19,getApp()->reg().readColorEntry(sectionName,"WT",FXRGBA(255,175,175,255))); setWellColor(20,getApp()->reg().readColorEntry(sectionName,"WU",FXRGBA(175,255,175,255))); setWellColor(21,getApp()->reg().readColorEntry(sectionName,"WV",FXRGBA(175,175,255,255))); setWellColor(22,getApp()->reg().readColorEntry(sectionName,"WW",FXRGBA(175,255,255,255))); setWellColor(23,getApp()->reg().readColorEntry(sectionName,"WX",FXRGBA(255,255,175,255))); setActivePanel(getApp()->reg().readIntEntry(sectionName,"activecolorpane",COLORTAB_COLOR_RING)); } // Save settings to registry void FXColorDialog::writeRegistry(){ getApp()->reg().writeIntEntry(sectionName,"width",getWidth()); getApp()->reg().writeIntEntry(sectionName,"height",getHeight()); getApp()->reg().writeColorEntry(sectionName,"WA",getWellColor( 0)); getApp()->reg().writeColorEntry(sectionName,"WB",getWellColor( 1)); getApp()->reg().writeColorEntry(sectionName,"WC",getWellColor( 2)); getApp()->reg().writeColorEntry(sectionName,"WD",getWellColor( 3)); getApp()->reg().writeColorEntry(sectionName,"WE",getWellColor( 4)); getApp()->reg().writeColorEntry(sectionName,"WF",getWellColor( 5)); getApp()->reg().writeColorEntry(sectionName,"WG",getWellColor( 6)); getApp()->reg().writeColorEntry(sectionName,"WH",getWellColor( 7)); getApp()->reg().writeColorEntry(sectionName,"WI",getWellColor( 8)); getApp()->reg().writeColorEntry(sectionName,"WJ",getWellColor( 9)); getApp()->reg().writeColorEntry(sectionName,"WK",getWellColor(10)); getApp()->reg().writeColorEntry(sectionName,"WL",getWellColor(11)); getApp()->reg().writeColorEntry(sectionName,"WM",getWellColor(12)); getApp()->reg().writeColorEntry(sectionName,"WN",getWellColor(13)); getApp()->reg().writeColorEntry(sectionName,"WO",getWellColor(14)); getApp()->reg().writeColorEntry(sectionName,"WP",getWellColor(15)); getApp()->reg().writeColorEntry(sectionName,"WQ",getWellColor(16)); getApp()->reg().writeColorEntry(sectionName,"WR",getWellColor(17)); getApp()->reg().writeColorEntry(sectionName,"WS",getWellColor(18)); getApp()->reg().writeColorEntry(sectionName,"WT",getWellColor(19)); getApp()->reg().writeColorEntry(sectionName,"WU",getWellColor(20)); getApp()->reg().writeColorEntry(sectionName,"WV",getWellColor(21)); getApp()->reg().writeColorEntry(sectionName,"WW",getWellColor(22)); getApp()->reg().writeColorEntry(sectionName,"WX",getWellColor(23)); getApp()->reg().writeIntEntry(sectionName,"activecolorpane",getActivePanel()); } // Change RGBA color void FXColorDialog::setRGBA(FXColor clr){ colorbox->setRGBA(clr); } // Retrieve RGBA color FXColor FXColorDialog::getRGBA() const { return colorbox->getRGBA(); } // Forward ColorSelector color change to target [a color well] long FXColorDialog::onChgColor(FXObject*,FXSelector,void* ptr){ return target && target->tryHandle(this,FXSEL(SEL_CHANGED,message),ptr); } // Forward ColorSelector color command to target [a color well] long FXColorDialog::onCmdColor(FXObject*,FXSelector,void* ptr){ return target && target->tryHandle(this,FXSEL(SEL_COMMAND,message),ptr); } // Update color dialog from a message long FXColorDialog::onCmdSetIntValue(FXObject*,FXSelector,void* ptr){ setRGBA(*((FXColor*)ptr)); return 1; } // Obtain value from color dialog long FXColorDialog::onCmdGetIntValue(FXObject*,FXSelector,void* ptr){ *((FXColor*)ptr)=getRGBA(); return 1; } // Change active panel void FXColorDialog::setActivePanel(FXint pnl){ colorbox->setActivePanel(pnl); } // Return active panel FXint FXColorDialog::getActivePanel() const { return colorbox->getActivePanel(); } // Change well color void FXColorDialog::setWellColor(FXint w,FXColor clr){ colorbox->setWellColor(w,clr); } // Return well color FXColor FXColorDialog::getWellColor(FXint w) const { return colorbox->getWellColor(w); } // Change opaque only mode void FXColorDialog::setOpaqueOnly(FXbool forceopaque){ colorbox->setOpaqueOnly(forceopaque); } // Return true if only opaque colors allowed FXbool FXColorDialog::isOpaqueOnly() const { return colorbox->isOpaqueOnly(); } // Save data void FXColorDialog::save(FXStream& store) const { FXDialogBox::save(store); store << colorbox; } // Load data void FXColorDialog::load(FXStream& store){ FXDialogBox::load(store); store >> colorbox; } // Cleanup FXColorDialog::~FXColorDialog(){ destroy(); colorbox=(FXColorSelector*)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXColorList.cpp000066400000000000000000000154301455751074500224630ustar00rootroot00000000000000/******************************************************************************** * * * C o l o r L i s t W i d g e t * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXColors.h" #include "FXSize.h" #include "FXPoint.h" #include "FXObjectList.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FXFont.h" #include "FXIcon.h" #include "FXScrollBar.h" #include "FXColorList.h" /* Notes: */ #define ICON_SPACING 4 // Spacing between icon and label #define SIDE_SPACING 6 // Left or right spacing between items #define LINE_SPACING 4 // Line spacing between items #define SWATCH_WIDTH 24 // Swatch size #define SWATCH_HEIGHT 12 using namespace FX; /*******************************************************************************/ namespace FX { // Object implementation FXIMPLEMENT(FXColorItem,FXListItem,nullptr,0) // Draw item void FXColorItem::draw(const FXList* list,FXDC& dc,FXint xx,FXint yy,FXint ww,FXint hh) const { FXFont *font=list->getFont(); FXint th=0; if(!label.empty()) th=font->getFontHeight(); if(isSelected()) dc.setForeground(list->getSelBackColor()); else dc.setForeground(list->getBackColor()); dc.fillRectangle(xx,yy,ww,hh); if(hasFocus()){ dc.drawFocusRectangle(xx+1,yy+1,ww-2,hh-2); } xx+=SIDE_SPACING/2; dc.setForeground(color); dc.fillRectangle(xx,yy+(hh-SWATCH_HEIGHT)/2,SWATCH_WIDTH,SWATCH_HEIGHT); dc.setForeground(FXRGB(0,0,0)); dc.drawRectangle(xx,yy+(hh-SWATCH_HEIGHT)/2,SWATCH_WIDTH,SWATCH_HEIGHT); xx+=ICON_SPACING+SWATCH_WIDTH; if(!label.empty()){ dc.setFont(font); if(!isEnabled()) dc.setForeground(makeShadowColor(list->getBackColor())); else if(isSelected()) dc.setForeground(list->getSelTextColor()); else dc.setForeground(list->getTextColor()); dc.drawText(xx,yy+(hh-th)/2+font->getFontAscent(),label); } } // See if item got hit, and where: 0 is outside, 1 is icon, 2 is text FXint FXColorItem::hitItem(const FXList* list,FXint xx,FXint yy) const { FXint tw=0,th=0,ix,iy,tx,ty,h; FXFont *font=list->getFont(); if(!label.empty()){ tw=4+font->getTextWidth(label); th=4+font->getFontHeight(); } h=LINE_SPACING+FXMAX(th,SWATCH_HEIGHT); ix=SIDE_SPACING/2; tx=SIDE_SPACING/2+SWATCH_WIDTH+ICON_SPACING; iy=(h-SWATCH_HEIGHT)/2; ty=(h-th)/2; // In icon? if(ix<=xx && iy<=yy && xxgetFont(); FXint w=SWATCH_WIDTH; if(!label.empty()) w+=ICON_SPACING+font->getTextWidth(label); return SIDE_SPACING+w; } // Get height of item FXint FXColorItem::getHeight(const FXList* list) const { FXFont *font=list->getFont(); FXint h=0; if(!label.empty()) h=font->getFontHeight(); return LINE_SPACING+FXMAX(h,SWATCH_HEIGHT); } /*******************************************************************************/ // Object implementation FXIMPLEMENT(FXColorList,FXList,nullptr,0) // List FXColorList::FXColorList(FXComposite *p,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXList(p,tgt,sel,opts,x,y,w,h){ } // Create custom item FXListItem *FXColorList::createItem(const FXString& text,FXIcon*,void* ptr){ return new FXColorItem(text,FXRGB(0,0,0),ptr); } // Fill list by appending color items from array of strings and array of colors FXint FXColorList::fillItems(const FXchar *const *strings,FXColor *colors,void* ptr,FXbool notify){ FXint n=0; if(strings){ while(strings[n]){ appendItem(strings[n],colors[n],ptr,notify); n++; } } return n; } // Insert item at index with given text, color, and user-data pointer FXint FXColorList::insertItem(FXint index,const FXString& text,FXColor color,void* ptr,FXbool notify){ FXint pos=FXList::insertItem(index,text,nullptr,ptr,notify); setItemColor(pos,color); return pos; } // Append new item with given text, color, and user-data pointer FXint FXColorList::appendItem(const FXString& text,FXColor color,void* ptr,FXbool notify){ FXint pos=FXList::appendItem(text,nullptr,ptr,notify); setItemColor(pos,color); return pos; } // Prepend new item with given text, color, and user-data pointer FXint FXColorList::prependItem(const FXString& text,FXColor color,void* ptr,FXbool notify){ FXint pos=FXList::prependItem(text,nullptr,ptr,notify); setItemColor(pos,color); return pos; } // Change item color void FXColorList::setItemColor(FXint index,FXColor color){ if(index<0 || items.no()<=index){ fxerror("%s::setItemData: index out of range.\n",getClassName()); } ((FXColorItem*)items[index])->setColor(color); } // Return item color FXColor FXColorList::getItemColor(FXint index) const { if(index<0 || items.no()<=index){ fxerror("%s::getItemData: index out of range.\n",getClassName()); } return ((FXColorItem*)items[index])->getColor(); } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXColorRing.cpp000066400000000000000000000501051455751074500224450ustar00rootroot00000000000000/******************************************************************************** * * * C o l o r R i n g W i d g e t * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FXImage.h" #include "FXColorRing.h" /* Notes: - Ranges: Hue 0..360, saturation 0..1, value 0..1. - For insight into the workings of this thing a basic grasp of linear algebra would be very helpful. - The hue-ring part is pretty straightforward and needs no comment; the triangle part used for saturation and value needs some explanations: V=1 line S=1 line \ / C / \ Far S=1 (A) / \ Far V=1 (B) / CLR \ / \ / \ / BLK WHT \ --B-------------W----S=0 line point V=0 / \ / \ V=1 line Far S=0 (C) Observe that V=0 at the POINT B, and S is multi-valued at B [either 0 or 1]. Also observe that far outside the triangle, S=1 when to the left of BC, S=0 when below BW, and V=1 when right of BC. When far away, we project the point to the closest side of the triangle, and thus have to calculate only one of the two, either S (case B)or V (cases A and C). Thus we have: P = (C - W) * s + W where P is a point on line WC Q = (P - B) * v + B and Q is a point on the line BP Where v is computed as the distance from the line parallel to WC through B, normalized such that point W and C is at distance 1 the line. - We keep the inner triangle non-degenerate, i.e. it can not be 0-size. This guarantees that determinants are never zero. - We use delayed layout to recompute the dial image; this helps during vigoruous use of the hue-ring or resizing of the widget. - Also, we calculate the triangle corners during layout; this keeps manipulation of saturation and value very cheap [just move the inner ball]. - Dial can now be justified inside its box. */ #define RINGDIAMETER 60 // Default ring outer diameter #define RINGWIDTH 14 // Default ring width #define MINTRIANGLE 5 // Minimum triangle radius #define JUSTIFY_MASK (JUSTIFY_HZ_APART|JUSTIFY_VT_APART) using namespace FX; /*******************************************************************************/ namespace FX { // Special single-precision versions const FXfloat pi=3.1415926535897932384626433833f; const FXfloat dtor=0.0174532925199432957692369077f; const FXfloat rtod=57.295779513082320876798154814f; // Map FXDEFMAP(FXColorRing) FXColorRingMap[]={ FXMAPFUNC(SEL_PAINT,0,FXColorRing::onPaint), FXMAPFUNC(SEL_MOTION,0,FXColorRing::onMotion), FXMAPFUNC(SEL_MOUSEWHEEL,0,FXColorRing::onMouseWheel), FXMAPFUNC(SEL_LEFTBUTTONPRESS,0,FXColorRing::onLeftBtnPress), FXMAPFUNC(SEL_LEFTBUTTONRELEASE,0,FXColorRing::onLeftBtnRelease), FXMAPFUNC(SEL_QUERY_TIP,0,FXColorRing::onQueryTip), FXMAPFUNC(SEL_QUERY_HELP,0,FXColorRing::onQueryHelp), FXMAPFUNC(SEL_COMMAND,FXColorRing::ID_SETHELPSTRING,FXColorRing::onCmdSetHelp), FXMAPFUNC(SEL_COMMAND,FXColorRing::ID_GETHELPSTRING,FXColorRing::onCmdGetHelp), FXMAPFUNC(SEL_COMMAND,FXColorRing::ID_SETTIPSTRING,FXColorRing::onCmdSetTip), FXMAPFUNC(SEL_COMMAND,FXColorRing::ID_GETTIPSTRING,FXColorRing::onCmdGetTip), }; // Object implementation FXIMPLEMENT(FXColorRing,FXFrame,FXColorRingMap,ARRAYNUMBER(FXColorRingMap)) // Init FXColorRing::FXColorRing(){ flags|=FLAG_ENABLED; hsv[0]=0.0f; hsv[1]=0.0f; hsv[2]=1.0f; ringwidth=RINGWIDTH; ringouter=RINGDIAMETER/2; ringinner=RINGDIAMETER/2-RINGWIDTH; dialx=0; dialy=0; clrx=clry=0; blkx=blky=0; whtx=whty=0; satvalx=0; satvaly=0; huex=0; huey=0; mode=MOUSE_NONE; } // Make a color ring FXColorRing::FXColorRing(FXComposite* p,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb):FXFrame(p,opts,x,y,w,h,pl,pr,pt,pb){ flags|=FLAG_ENABLED; dial=new FXImage(getApp(),nullptr,IMAGE_DITHER|IMAGE_KEEP|IMAGE_OWNED|IMAGE_SHMI|IMAGE_SHMP,RINGDIAMETER,RINGDIAMETER); target=tgt; message=sel; hsv[0]=0.0f; hsv[1]=0.0f; hsv[2]=1.0f; ringwidth=RINGWIDTH; ringouter=RINGDIAMETER/2; ringinner=RINGDIAMETER/2-RINGWIDTH; dialx=0; dialy=0; clrx=clry=0; blkx=blky=0; whtx=whty=0; satvalx=0; satvaly=0; huex=0; huey=0; mode=MOUSE_NONE; } // Create window void FXColorRing::create(){ FXFrame::create(); updatering(); dial->create(); } // Detach window void FXColorRing::detach(){ FXFrame::detach(); dial->detach(); } // Get default width FXint FXColorRing::getDefaultWidth(){ return RINGDIAMETER+padleft+padright+(border<<1); } // Get default height FXint FXColorRing::getDefaultHeight(){ return RINGDIAMETER+padtop+padbottom+(border<<1); } // Resize the dial void FXColorRing::layout(){ FXint ww=width-padleft-padright-(border<<1); FXint hh=height-padtop-padbottom-(border<<1); FXint ss; // Enforce minimum triangle size ringinner=FXMIN(ww,hh)/2-ringwidth; if(ringinner<=MINTRIANGLE) ringinner=MINTRIANGLE; ringouter=ringinner+ringwidth; // Size is odd so center falls on whole pixel ss=ringouter+ringouter+1; // New dial location in widget if(options&JUSTIFY_LEFT) dialx=padleft+border; else if(options&JUSTIFY_RIGHT) dialx=width-padright-border-ss; else dialx=border+padleft+(ww-ss)/2; if(options&JUSTIFY_TOP) dialy=padtop+border; else if(options&JUSTIFY_BOTTOM) dialy=height-padbottom-border-ss; else dialy=border+padtop+(hh-ss)/2; // Do work if size changed or marked dirty if((dial->getWidth()!=ss) || (flags&FLAG_DIRTY)){ // Size has changed, resize the off-screen image if(dial->getWidth()!=ss) dial->resize(ss,ss); // Update ring image updatering(); // Rerender to server dial->render(); update(); } // Update hue ball position hueToXY(huex,huey,hsv[0]); // Update saturation and value ball position satValToXY(satvalx,satvaly,hsv[1],hsv[2]); flags&=~FLAG_DIRTY; } // Recompute the dial image void FXColorRing::updatering(){ FXfloat invdet,a,s,v,r,g,b; FXint o2,i2,r2,rx,ry,x,y; // Hue angle in radians a=(hsv[0]-180.0f)*dtor; // Calculate triangle points clrx=(FXint)(ringinner*Math::cos(a)+0.5f); clry=(FXint)(ringinner*Math::sin(a)+0.5f); blkx=(FXint)(ringinner*Math::cos(a+2.0f*pi/3.0f)+0.5f); blky=(FXint)(ringinner*Math::sin(a+2.0f*pi/3.0f)+0.5f); whtx=(FXint)(ringinner*Math::cos(a-2.0f*pi/3.0f)+0.5f); whty=(FXint)(ringinner*Math::sin(a-2.0f*pi/3.0f)+0.5f); // To test for ring o2=ringouter*ringouter; i2=ringinner*ringinner; // Determinant is OK because of MINTRIANGLE constraint invdet=1.0f/((whty-clry)*(whtx-blkx)+(clrx-whtx)*(whty-blky)); // Loop over pixels for(y=0; ygetHeight(); y++){ ry=y-ringouter; for(x=0; xgetWidth(); x++){ rx=x-ringouter; // Inside outer ring if((r2=(rx*rx+ry*ry))<=o2){ // Outside inner ring if(i2<=r2){ // Compute color fxhsv_to_rgb(r,g,b,Math::atan2((FXfloat)ry,(FXfloat)rx)*rtod+180.0f,1.0f,1.0f); dial->setPixel(x,y,FXRGB(255.0f*r,255.0f*g,255.0f*b)); continue; } // Inside triangle if(0<=(clry-blky)*(rx-clrx)-(clrx-blkx)*(ry-clry) && 0<=(whty-clry)*(rx-whtx)-(whtx-clrx)*(ry-whty) && 0<=(blky-whty)*(rx-blkx)-(blkx-whtx)*(ry-blky)){ // Compute saturation and value in triangle v=((whty-clry)*(rx-blkx)+(clrx-whtx)*(ry-blky)) * invdet; s=((whty-blky)*(rx-blkx)+(blkx-whtx)*(ry-blky)) * invdet; // Compute color fxhsv_to_rgb(r,g,b,hsv[0],s,v); dial->setPixel(x,y,FXRGB(255.0f*r,255.0f*g,255.0f*b)); continue; } } // Just set background dial->setPixel(x,y,backColor); } } } // Test if inside hue ring FXbool FXColorRing::inHueRing(FXint x,FXint y) const { FXint rx=x-dialx-ringouter; FXint ry=y-dialy-ringouter; return ringinner*ringinner<=rx*rx+ry*ry; } // Compute hue from position on ring x, y FXfloat FXColorRing::hueFromXY(FXint x,FXint y) const { return Math::atan2((FXfloat)(y-dialy-ringouter),(FXfloat)(x-dialx-ringouter))*rtod+180.0f; } // Compute position on ring from hue void FXColorRing::hueToXY(FXint& x,FXint& y,FXfloat hue) const { FXfloat a=(hue-180.0f)*dtor; FXfloat r=ringouter-ringwidth*0.5f; x=dialx+ringouter+(FXint)(r*Math::cos(a)+0.5f); y=dialy+ringouter+(FXint)(r*Math::sin(a)+0.5f); } // Test if inside saturation/value triangle FXbool FXColorRing::inTriangle(FXint x,FXint y) const { FXint rx=x-dialx-ringouter; FXint ry=y-dialy-ringouter; return 0<=(clry-blky)*(rx-clrx)-(clrx-blkx)*(ry-clry) && 0<=(whty-clry)*(rx-whtx)-(whtx-clrx)*(ry-whty) && 0<=(blky-whty)*(rx-blkx)-(blkx-whtx)*(ry-blky); } // Compute x,y location from saturation and value void FXColorRing::satValToXY(FXint& x,FXint& y,FXfloat s,FXfloat v) const { FXfloat px=whtx+(clrx-whtx)*s; FXfloat py=whty+(clry-whty)*s; x=dialx+ringouter+blkx+(FXint)((px-blkx)*v+0.5f); y=dialy+ringouter+blky+(FXint)((py-blky)*v+0.5f); } // Compute saturation and value given x, y in triangle and hue void FXColorRing::satValFromXY(FXfloat& s,FXfloat& v,FXint x,FXint y) const { FXint rx=x-dialx-ringouter; FXint ry=y-dialy-ringouter; FXfloat ss,vv; // Outside triangle on blk-clr side if((clry-blky)*(rx-clrx)-(clrx-blkx)*(ry-clry)<0){ ss=1.0f; vv=(FXfloat)((clrx-blkx)*(rx-blkx)+(clry-blky)*(ry-blky)) / (FXfloat)((clrx-blkx)*(clrx-blkx)+(clry-blky)*(clry-blky)); } // Outside triangle on wht-clr side else if((whty-clry)*(rx-whtx)-(whtx-clrx)*(ry-whty)<0){ vv=1.0f; ss=(FXfloat)((clrx-whtx)*(rx-whtx)+(clry-whty)*(ry-whty)) / (FXfloat)((clrx-whtx)*(clrx-whtx)+(clry-whty)*(clry-whty)); } // Outside triangle on blk-wht side else if((blky-whty)*(rx-blkx)-(blkx-whtx)*(ry-blky)<0){ ss=0.0f; vv=(FXfloat)((whtx-blkx)*(rx-blkx)+(whty-blky)*(ry-blky)) / (FXfloat)((whtx-blkx)*(whtx-blkx)+(whty-blky)*(whty-blky)); } // Inside the triangle; this is a bit nasty... else{ vv=(FXfloat)((whty-clry)*(rx-blkx)+(clrx-whtx)*(ry-blky)) / (FXfloat)((whty-clry)*(whtx-blkx)+(clrx-whtx)*(whty-blky)); // Take care of degenerate case at B if(vv<=0.0f){ vv=0.0f; ss=0.0f; } // Generic case else{ if(vv>=1.0f) vv=1.0f; // Don't divide by zero if(clry==whty){ ss=(FXfloat) (rx-blkx-vv*(whtx-blkx)) / (vv*(clrx-whtx)); } else{ ss=(FXfloat) (ry-blky-vv*(whty-blky)) / (vv*(clry-whty)); } } } // Clamp to range s=Math::fclamp(0.0f,ss,1.0f); v=Math::fclamp(0.0f,vv,1.0f); } // Set help using a message long FXColorRing::onCmdSetHelp(FXObject*,FXSelector,void* ptr){ setHelpText(*((FXString*)ptr)); return 1; } // Get help using a message long FXColorRing::onCmdGetHelp(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getHelpText(); return 1; } // Set tip using a message long FXColorRing::onCmdSetTip(FXObject*,FXSelector,void* ptr){ setTipText(*((FXString*)ptr)); return 1; } // Get tip using a message long FXColorRing::onCmdGetTip(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getTipText(); return 1; } // We were asked about tip text long FXColorRing::onQueryTip(FXObject* sender,FXSelector sel,void* ptr){ if(FXFrame::onQueryTip(sender,sel,ptr)) return 1; if((flags&FLAG_TIP) && !tip.empty()){ sender->handle(this,FXSEL(SEL_COMMAND,ID_SETSTRINGVALUE),(void*)&tip); return 1; } return 0; } // We were asked about status text long FXColorRing::onQueryHelp(FXObject* sender,FXSelector sel,void* ptr){ if(FXFrame::onQueryHelp(sender,sel,ptr)) return 1; if((flags&FLAG_HELP) && !help.empty()){ sender->handle(this,FXSEL(SEL_COMMAND,ID_SETSTRINGVALUE),(void*)&help); return 1; } return 0; } // Handle repaint long FXColorRing::onPaint(FXObject*,FXSelector,void* ptr){ FXEvent *event=(FXEvent*)ptr; FXDCWindow dc(this,event); // Fill around sides dc.setForeground(backColor); dc.fillRectangle(border,border,dialx-border,height-(border<<1)); dc.fillRectangle(dialx+dial->getWidth(),border,width-border-dialx-dial->getWidth(),height-(border<<1)); dc.fillRectangle(dialx,border,dial->getWidth(),dialy-border); dc.fillRectangle(dialx,dialy+dial->getHeight(),dial->getWidth(),height-border-dialy-dial->getHeight()); // Draw dial dc.drawImage(dial,dialx,dialy); dc.setForeground(borderColor); dc.drawArc(dialx+1,dialy,ringouter+ringouter,ringouter+ringouter,90*64,45*64); dc.drawArc(dialx,dialy+1,ringouter+ringouter,ringouter+ringouter,135*64,45*64); dc.setForeground(baseColor); dc.drawArc(dialx-1,dialy,ringouter+ringouter,ringouter+ringouter,270*64,45*64); dc.drawArc(dialx,dialy-1,ringouter+ringouter,ringouter+ringouter,315*64,45*64); dc.setForeground(shadowColor); dc.drawArc(dialx,dialy,ringouter+ringouter,ringouter+ringouter,45*64,180*64); dc.drawArc(dialx+ringwidth,dialy+ringwidth,ringinner+ringinner,ringinner+ringinner,225*64,180*64); dc.setForeground(hiliteColor); dc.drawArc(dialx,dialy,ringouter+ringouter,ringouter+ringouter,225*64,180*64); dc.drawArc(dialx+ringwidth,dialy+ringwidth,ringinner+ringinner,ringinner+ringinner,45*64,180*64); // Draw spots dc.setForeground(FXRGB(255,255,255)); dc.fillArc(satvalx-3,satvaly-3,7,7,0,360*64); dc.fillArc(huex-3,huey-3,7,7,0,360*64); dc.setForeground(FXRGB(0,0,0)); dc.fillArc(satvalx-2,satvaly-2,5,5,0,360*64); dc.fillArc(huex-2,huey-2,5,5,0,360*64); drawFrame(dc,0,0,width,height); return 1; } // Determine if special case applies FXbool FXColorRing::inCorner(FXint x,FXint y) const { FXint rx=x-dialx-ringouter; FXint ry=y-dialy-ringouter; return (ringouter*ringouter<=rx*rx+ry*ry) && (0.99999f<=hsv[1] && 0.99999f<=hsv[2]); } // Moving long FXColorRing::onMotion(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; FXfloat s,v; flags&=~FLAG_TIP; if(mode!=MOUSE_NONE){ if((mode==MOUSE_HUE) || inCorner(event->win_x,event->win_y)){ // Changing hue setHue(hueFromXY(event->win_x,event->win_y)); } else{ // Changing saturation and value satValFromXY(s,v,event->win_x,event->win_y); setHueSatVal(hsv[0],s,v); } flags|=FLAG_CHANGED; if(target) target->tryHandle(this,FXSEL(SEL_CHANGED,message),(void*)hsv); return 1; } return 0; } // Move spot to change hue, saturation long FXColorRing::onLeftBtnPress(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; FXfloat s,v; flags&=~FLAG_TIP; if(isEnabled()){ grab(); if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONPRESS,message),ptr)) return 1; if(inHueRing(event->win_x,event->win_y)){ setHue(hueFromXY(event->win_x,event->win_y)); mode=MOUSE_HUE; } else if(inTriangle(event->win_x,event->win_y)){ satValFromXY(s,v,event->win_x,event->win_y); setHueSatVal(hsv[0],s,v); mode=MOUSE_SATVAL; } flags|=FLAG_CHANGED; flags&=~FLAG_UPDATE; if(target) target->tryHandle(this,FXSEL(SEL_CHANGED,message),(void*)hsv); } return 1; } // End spot movement mode long FXColorRing::onLeftBtnRelease(FXObject*,FXSelector,void* ptr){ FXuint changed=(flags&FLAG_CHANGED); if(isEnabled()){ ungrab(); flags|=FLAG_UPDATE; flags&=~FLAG_CHANGED; mode=MOUSE_NONE; if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONRELEASE,message),ptr)) return 1; if(changed && target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)hsv); return 1; } return 1; } // Rotate hue by means of dial long FXColorRing::onMouseWheel(FXObject*,FXSelector,void* ptr){ FXfloat amount=((FXEvent*)ptr)->code/12.0f; if(isEnabled()){ if(((FXEvent*)ptr)->state&CONTROLMASK) amount/=10.0f; setHue(Math::fmod(hsv[0]+amount+360.0f,360.0f)); if(target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)hsv); return 1; } return 0; } // Change hue void FXColorRing::setHue(FXfloat h){ h=Math::fclamp(0.0f,h,360.0f); if(hsv[0]!=h){ hsv[0]=h; update(huex-4,huey-4,9,9); hueToXY(huex,huey,hsv[0]); update(huex-4,huey-4,9,9); recalc(); } } // Change saturation void FXColorRing::setSat(FXfloat s){ s=Math::fclamp(0.0f,s,1.0f); if(hsv[1]!=s){ hsv[1]=s; update(satvalx-4,satvaly-4,9,9); satValToXY(satvalx,satvaly,hsv[1],hsv[2]); update(satvalx-4,satvaly-4,9,9); } } // Change saturation void FXColorRing::setVal(FXfloat v){ v=Math::fclamp(0.0f,v,1.0f); if(hsv[2]!=v){ hsv[2]=v; update(satvalx-4,satvaly-4,9,9); satValToXY(satvalx,satvaly,hsv[1],hsv[2]); update(satvalx-4,satvaly-4,9,9); } } // Set hue, saturation, value void FXColorRing::setHueSatVal(FXfloat h,FXfloat s,FXfloat v){ // Clamp h=Math::fclamp(0.0f,h,360.0f); s=Math::fclamp(0.0f,s,1.0f); v=Math::fclamp(0.0f,v,1.0f); // Changed after clamping? if(hsv[0]!=h || hsv[1]!=s || hsv[2]!=v){ // Cheap case: just move the ball if(hsv[1]!=s || hsv[2]!=v){ hsv[1]=s; hsv[2]=v; update(satvalx-4,satvaly-4,9,9); satValToXY(satvalx,satvaly,hsv[1],hsv[2]); update(satvalx-4,satvaly-4,9,9); } // Expensive case: recalculate dial if(hsv[0]!=h){ hsv[0]=h; recalc(); } } } // Change width of hue ring void FXColorRing::setRingWidth(FXint rw){ if(rw<4) rw=4; if(ringwidth!=rw){ ringwidth=rw; recalc(); } } // Set text justify style void FXColorRing::setJustify(FXuint style){ FXuint opts=(options&~JUSTIFY_MASK) | (style&JUSTIFY_MASK); if(options!=opts){ options=opts; recalc(); } } // Get text justify style FXuint FXColorRing::getJustify() const { return (options&JUSTIFY_MASK); } // Save data void FXColorRing::save(FXStream& store) const { FXFrame::save(store); store << dial; store << hsv[0]; store << hsv[1]; store << hsv[2]; store << ringwidth; store << tip; store << help; } // Load data void FXColorRing::load(FXStream& store){ FXFrame::load(store); store >> dial; store >> hsv[0]; store >> hsv[1]; store >> hsv[2]; store >> ringwidth; store >> tip; store >> help; } // Destroy FXColorRing::~FXColorRing(){ delete dial; dial=(FXImage*)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXColorSelector.cpp000066400000000000000000001106751455751074500233370ustar00rootroot00000000000000/******************************************************************************** * * * C o l o r S e l e c t o r * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXColors.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXObject.h" #include "FXObjectList.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXAccelTable.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FXFont.h" #include "FXIcon.h" #include "FXGIFIcon.h" #include "FXWindow.h" #include "FXFrame.h" #include "FXSeparator.h" #include "FXLabel.h" #include "FXColorBar.h" #include "FXColorWell.h" #include "FXColorWheel.h" #include "FXColorRing.h" #include "FXColorList.h" #include "FXTextField.h" #include "FXButton.h" #include "FXPicker.h" #include "FXComposite.h" #include "FXPacker.h" #include "FXTabItem.h" #include "FXTabBook.h" #include "FXHorizontalFrame.h" #include "FXVerticalFrame.h" #include "FXMatrix.h" #include "FXShell.h" #include "FXScrollBar.h" #include "FXSlider.h" #include "FXList.h" #include "FXColorSelector.h" #include "icons.h" /* Notes: - Custom colors in the twentyfour wells are saved to registry for next time you run the program. - HSV Model: green yellow o-----o / \ / white \ cyan o o o red \ / \ / o-----o blue magenta - Perhaps this panel should send color change messages to active colorwell widget? - New default palette of colors; basic grey levels, primary colors, darker colors, and pastel colors. */ // Is color pure gray #define FXISGREY(rgba) (FXREDVAL(rgba)==FXGREENVAL(rgba) && FXREDVAL(rgba)==FXBLUEVAL(rgba)) using namespace FX; /*******************************************************************************/ namespace FX { /*******************************************************************************/ // Map FXDEFMAP(FXColorSelector) FXColorSelectorMap[]={ FXMAPFUNC(SEL_UPDATE,FXColorSelector::ID_ALPHA_TEXT,FXColorSelector::onUpdAlphaText), FXMAPFUNC(SEL_COMMAND,FXColorSelector::ID_ALPHA_TEXT,FXColorSelector::onCmdAlphaText), FXMAPFUNC(SEL_UPDATE,FXColorSelector::ID_ALPHA_LABEL,FXColorSelector::onUpdAlphaLabel), FXMAPFUNC(SEL_UPDATE,FXColorSelector::ID_ALPHA_SLIDER,FXColorSelector::onUpdAlphaSlider), FXMAPFUNC(SEL_CHANGED,FXColorSelector::ID_ALPHA_SLIDER,FXColorSelector::onCmdAlphaSlider), FXMAPFUNC(SEL_COMMAND,FXColorSelector::ID_ALPHA_SLIDER,FXColorSelector::onCmdAlphaSlider), FXMAPFUNCS(SEL_UPDATE,FXColorSelector::ID_RGB_RED_TEXT,FXColorSelector::ID_RGB_BLUE_TEXT,FXColorSelector::onUpdRGBText), FXMAPFUNCS(SEL_UPDATE,FXColorSelector::ID_HSV_HUE_TEXT,FXColorSelector::ID_HSV_VALUE_TEXT,FXColorSelector::onUpdHSVText), FXMAPFUNCS(SEL_UPDATE,FXColorSelector::ID_CMY_CYAN_TEXT,FXColorSelector::ID_CMY_YELLOW_TEXT,FXColorSelector::onUpdCMYText), FXMAPFUNCS(SEL_COMMAND,FXColorSelector::ID_RGB_RED_TEXT,FXColorSelector::ID_RGB_BLUE_TEXT,FXColorSelector::onCmdRGBText), FXMAPFUNCS(SEL_COMMAND,FXColorSelector::ID_HSV_HUE_TEXT,FXColorSelector::ID_HSV_VALUE_TEXT,FXColorSelector::onCmdHSVText), FXMAPFUNCS(SEL_COMMAND,FXColorSelector::ID_CMY_CYAN_TEXT,FXColorSelector::ID_CMY_YELLOW_TEXT,FXColorSelector::onCmdCMYText), FXMAPFUNCS(SEL_UPDATE,FXColorSelector::ID_RGB_RED_SLIDER,FXColorSelector::ID_RGB_BLUE_SLIDER,FXColorSelector::onUpdRGBSlider), FXMAPFUNCS(SEL_UPDATE,FXColorSelector::ID_HSV_HUE_SLIDER,FXColorSelector::ID_HSV_VALUE_SLIDER,FXColorSelector::onUpdHSVSlider), FXMAPFUNCS(SEL_UPDATE,FXColorSelector::ID_CMY_CYAN_SLIDER,FXColorSelector::ID_CMY_YELLOW_SLIDER,FXColorSelector::onUpdCMYSlider), FXMAPFUNCS(SEL_CHANGED,FXColorSelector::ID_RGB_RED_SLIDER,FXColorSelector::ID_RGB_BLUE_SLIDER,FXColorSelector::onCmdRGBSlider), FXMAPFUNCS(SEL_COMMAND,FXColorSelector::ID_RGB_RED_SLIDER,FXColorSelector::ID_RGB_BLUE_SLIDER,FXColorSelector::onCmdRGBSlider), FXMAPFUNCS(SEL_CHANGED,FXColorSelector::ID_HSV_HUE_SLIDER,FXColorSelector::ID_HSV_VALUE_SLIDER,FXColorSelector::onCmdHSVSlider), FXMAPFUNCS(SEL_COMMAND,FXColorSelector::ID_HSV_HUE_SLIDER,FXColorSelector::ID_HSV_VALUE_SLIDER,FXColorSelector::onCmdHSVSlider), FXMAPFUNCS(SEL_CHANGED,FXColorSelector::ID_CMY_CYAN_SLIDER,FXColorSelector::ID_CMY_YELLOW_SLIDER,FXColorSelector::onCmdCMYSlider), FXMAPFUNCS(SEL_COMMAND,FXColorSelector::ID_CMY_CYAN_SLIDER,FXColorSelector::ID_CMY_YELLOW_SLIDER,FXColorSelector::onCmdCMYSlider), FXMAPFUNC(SEL_COMMAND,FXColorSelector::ID_WELL_CHANGED,FXColorSelector::onCmdWell), FXMAPFUNC(SEL_CHANGED,FXColorSelector::ID_WELL_CHANGED,FXColorSelector::onChgWell), FXMAPFUNCS(SEL_COMMAND,FXColorSelector::ID_CUSTOM_FIRST,FXColorSelector::ID_CUSTOM_LAST,FXColorSelector::onCmdCustomWell), FXMAPFUNC(SEL_COMMAND,FXColorSelector::ID_COLOR_LIST,FXColorSelector::onCmdList), FXMAPFUNC(SEL_UPDATE,FXColorSelector::ID_DIAL_WHEEL,FXColorSelector::onUpdWheel), FXMAPFUNC(SEL_COMMAND,FXColorSelector::ID_DIAL_WHEEL,FXColorSelector::onCmdWheel), FXMAPFUNC(SEL_CHANGED,FXColorSelector::ID_DIAL_WHEEL,FXColorSelector::onCmdWheel), FXMAPFUNC(SEL_COMMAND,FXColorSelector::ID_COLORPICK,FXColorSelector::onCmdColorPick), FXMAPFUNC(SEL_COMMAND,FXColorSelector::ID_SETVALUE,FXColorSelector::onCmdSetValue), FXMAPFUNC(SEL_COMMAND,FXColorSelector::ID_SETINTVALUE,FXColorSelector::onCmdSetIntValue), FXMAPFUNC(SEL_COMMAND,FXColorSelector::ID_GETINTVALUE,FXColorSelector::onCmdGetIntValue), }; // Object implementation FXIMPLEMENT(FXColorSelector,FXPacker,FXColorSelectorMap,ARRAYNUMBER(FXColorSelectorMap)) /*******************************************************************************/ // Sort items based on color static FXint hueSort(const FXListItem* a,const FXListItem* b){ FXColor colora=((const FXColorItem*)a)->getColor(); FXColor colorb=((const FXColorItem*)b)->getColor(); FXfloat ca[3],cb[3]; fxrgb_to_hsl(ca[0],ca[1],ca[2],0.003921568627f*FXREDVAL(colora),0.003921568627f*FXGREENVAL(colora),0.003921568627f*FXBLUEVAL(colora)); fxrgb_to_hsl(cb[0],cb[1],cb[2],0.003921568627f*FXREDVAL(colorb),0.003921568627f*FXGREENVAL(colorb),0.003921568627f*FXBLUEVAL(colorb)); if(ca[2]!=cb[2]) return FXSGN(cb[2]-ca[2]); if(ca[1]!=cb[1]) return FXSGN(ca[1]-cb[1]); if(ca[0]!=cb[0]) return FXSGN(cb[0]-ca[0]); return 0; } // Separator item FXColorSelector::FXColorSelector(FXComposite *p,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXPacker(p,opts,x,y,w,h){ FXLabel *label; target=tgt; message=sel; // Buttons FXHorizontalFrame *buttons=new FXHorizontalFrame(this,LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH); accept=new FXButton(buttons,tr("&Accept"),nullptr,nullptr,0,BUTTON_INITIAL|BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT,0,0,0,0,20,20); cancel=new FXButton(buttons,tr("&Cancel"),nullptr,nullptr,0,BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT,0,0,0,0,20,20); // Separator new FXHorizontalSeparator(this,SEPARATOR_RIDGE|LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X); // Icons eyedropicon=new FXGIFIcon(getApp(),eyedrop); dialmodeicon=new FXGIFIcon(getApp(),dialmode); rgbmodeicon=new FXGIFIcon(getApp(),rgbmode); hsvmodeicon=new FXGIFIcon(getApp(),hsvmode); cmymodeicon=new FXGIFIcon(getApp(),cmymode); txtmodeicon=new FXGIFIcon(getApp(),listmode); // Wells with custom colors FXHorizontalFrame *colors=new FXHorizontalFrame(this,LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X, 0,0,0,0, 0,0,0,0, 0,0); colorwells[ 0]=new FXColorWell(colors,FXRGBA(255,255,255,255),this,ID_CUSTOM_FIRST+ 0,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[ 1]=new FXColorWell(colors,FXRGBA(204,204,204,255),this,ID_CUSTOM_FIRST+ 1,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[ 2]=new FXColorWell(colors,FXRGBA(153,153,153,255),this,ID_CUSTOM_FIRST+ 2,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[ 3]=new FXColorWell(colors,FXRGBA(102,102,102,255),this,ID_CUSTOM_FIRST+ 3,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[ 4]=new FXColorWell(colors,FXRGBA( 51, 51, 51,255),this,ID_CUSTOM_FIRST+ 4,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[ 5]=new FXColorWell(colors,FXRGBA( 0, 0, 0,255),this,ID_CUSTOM_FIRST+ 5,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[ 6]=new FXColorWell(colors,FXRGBA(255, 0, 0,255),this,ID_CUSTOM_FIRST+ 6,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[ 7]=new FXColorWell(colors,FXRGBA( 0,255, 0,255),this,ID_CUSTOM_FIRST+ 7,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[ 8]=new FXColorWell(colors,FXRGBA( 0, 0,255,255),this,ID_CUSTOM_FIRST+ 8,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[ 9]=new FXColorWell(colors,FXRGBA( 0,255,255,255),this,ID_CUSTOM_FIRST+ 9,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[10]=new FXColorWell(colors,FXRGBA(255,255, 0,255),this,ID_CUSTOM_FIRST+10,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[11]=new FXColorWell(colors,FXRGBA(255, 0,255,255),this,ID_CUSTOM_FIRST+11,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[12]=new FXColorWell(colors,FXRGBA(255,165, 0,255),this,ID_CUSTOM_FIRST+12,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[13]=new FXColorWell(colors,FXRGBA(153, 0, 0,255),this,ID_CUSTOM_FIRST+13,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[14]=new FXColorWell(colors,FXRGBA( 0,153, 0,255),this,ID_CUSTOM_FIRST+14,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[15]=new FXColorWell(colors,FXRGBA( 0, 0,153,255),this,ID_CUSTOM_FIRST+15,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[16]=new FXColorWell(colors,FXRGBA( 0,153,153,255),this,ID_CUSTOM_FIRST+16,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[17]=new FXColorWell(colors,FXRGBA(153,153, 0,255),this,ID_CUSTOM_FIRST+17,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[18]=new FXColorWell(colors,FXRGBA(153, 0,153,255),this,ID_CUSTOM_FIRST+18,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[19]=new FXColorWell(colors,FXRGBA(255,175,175,255),this,ID_CUSTOM_FIRST+19,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[20]=new FXColorWell(colors,FXRGBA(175,255,175,255),this,ID_CUSTOM_FIRST+20,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[21]=new FXColorWell(colors,FXRGBA(175,175,255,255),this,ID_CUSTOM_FIRST+21,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[22]=new FXColorWell(colors,FXRGBA(175,255,255,255),this,ID_CUSTOM_FIRST+22,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); colorwells[23]=new FXColorWell(colors,FXRGBA(255,255,175,255),this,ID_CUSTOM_FIRST+23,COLORWELL_SOURCEONLY|LAYOUT_CENTER_Y|LAYOUT_CENTER_X|FRAME_SUNKEN|FRAME_THICK, 0,0,0,0); // Main part FXHorizontalFrame *main=new FXHorizontalFrame(this,LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y); FXVerticalFrame *wellframe=new FXVerticalFrame(main,LAYOUT_FILL_Y,0,0,0,0, 0,0,10,0,0,2); // Color sucker new FXPicker(wellframe,tr("\tPick color"),eyedropicon,this,ID_COLORPICK,JUSTIFY_CENTER_X|JUSTIFY_CENTER_Y|FRAME_RAISED|FRAME_THICK|LAYOUT_CENTER_X|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT,0,0,56,32,0,0,0,0); // Main color well well=new FXColorWell(wellframe,FXRGBA(255,255,255,255),this,ID_WELL_CHANGED,COLORWELL_SOURCEONLY|LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FILL_Y|LAYOUT_FIX_WIDTH|FRAME_SUNKEN|FRAME_THICK, 0,0,64,0); // Tab book with switchable panels panels=new FXTabBook(main,nullptr,0,TABBOOK_TOPTABS|LAYOUT_FILL_Y|LAYOUT_FILL_X); // HSV Dial Mode new FXTabItem(panels,tr("\tHue, Saturation, Value"),dialmodeicon,TAB_TOP_NORMAL,0,0,0,0, 6,6,0,0); // Color wheel FXHorizontalFrame *dialblock=new FXHorizontalFrame(panels,FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_Y|LAYOUT_FILL_X|LAYOUT_TOP|LAYOUT_LEFT,0,0,0,0,15,15,5,5, 5,8); wheel=new FXColorRing(dialblock,this,ID_DIAL_WHEEL,LAYOUT_CENTER_Y|LAYOUT_FILL_Y|LAYOUT_FILL_X|JUSTIFY_LEFT|JUSTIFY_CENTER_Y,0,0,0,0,1,1,1,1); // RGB Mode new FXTabItem(panels,tr("\tRed, Green, Blue"),rgbmodeicon,TAB_TOP_NORMAL,0,0,0,0, 6,6,0,0); // RGB Sliders FXMatrix *rgbblock=new FXMatrix(panels,3,FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_Y|LAYOUT_FILL_X|LAYOUT_TOP|LAYOUT_LEFT|MATRIX_BY_COLUMNS,0,0,0,0,10,10,10,10, 5,8); // Red new FXLabel(rgbblock,tr("&Red:"),nullptr,LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|LAYOUT_RIGHT); rgbatext[0]=new FXTextField(rgbblock,5,this,FXColorSelector::ID_RGB_RED_TEXT,JUSTIFY_RIGHT|LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|FRAME_SUNKEN|FRAME_THICK,0,0,0,0, DEFAULT_PAD,DEFAULT_PAD,0,0); rgbaslider[0]=new FXSlider(rgbblock,this,FXColorSelector::ID_RGB_RED_SLIDER,LAYOUT_FILL_ROW|LAYOUT_FILL_COLUMN|LAYOUT_CENTER_Y|LAYOUT_FILL_X|LAYOUT_FIX_HEIGHT|SLIDER_HORIZONTAL|SLIDER_INSIDE_BAR,0,0,0,15); // Green slider new FXLabel(rgbblock,tr("&Green:"),nullptr,LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|LAYOUT_RIGHT); rgbatext[1]=new FXTextField(rgbblock,5,this,FXColorSelector::ID_RGB_GREEN_TEXT,JUSTIFY_RIGHT|LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|FRAME_SUNKEN|FRAME_THICK,0,0,0,0, DEFAULT_PAD,DEFAULT_PAD,0,0); rgbaslider[1]=new FXSlider(rgbblock,this,FXColorSelector::ID_RGB_GREEN_SLIDER,LAYOUT_FILL_ROW|LAYOUT_FILL_COLUMN|LAYOUT_CENTER_Y|LAYOUT_FILL_X|LAYOUT_FIX_HEIGHT|SLIDER_HORIZONTAL|SLIDER_INSIDE_BAR,0,0,0,15); // Blue slider new FXLabel(rgbblock,tr("&Blue:"),nullptr,LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|LAYOUT_RIGHT); rgbatext[2]=new FXTextField(rgbblock,5,this,FXColorSelector::ID_RGB_BLUE_TEXT,JUSTIFY_RIGHT|LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|FRAME_SUNKEN|FRAME_THICK,0,0,0,0, DEFAULT_PAD,DEFAULT_PAD,0,0); rgbaslider[2]=new FXSlider(rgbblock,this,FXColorSelector::ID_RGB_BLUE_SLIDER,LAYOUT_FILL_ROW|LAYOUT_FILL_COLUMN|LAYOUT_CENTER_Y|LAYOUT_FILL_X|LAYOUT_FIX_HEIGHT|SLIDER_HORIZONTAL|SLIDER_INSIDE_BAR,0,0,0,15); // Alpha slider label=new FXLabel(rgbblock,tr("&Alpha:"),nullptr,LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|LAYOUT_RIGHT); rgbatext[3]=new FXTextField(rgbblock,5,this,FXColorSelector::ID_ALPHA_TEXT,JUSTIFY_RIGHT|LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|FRAME_SUNKEN|FRAME_THICK,0,0,0,0, DEFAULT_PAD,DEFAULT_PAD,0,0); rgbaslider[3]=new FXSlider(rgbblock,this,FXColorSelector::ID_ALPHA_SLIDER,LAYOUT_FILL_ROW|LAYOUT_FILL_COLUMN|LAYOUT_CENTER_Y|LAYOUT_FILL_X|LAYOUT_FIX_HEIGHT|SLIDER_HORIZONTAL|SLIDER_INSIDE_BAR,0,0,0,15); label->setTarget(this); label->setSelector(ID_ALPHA_LABEL); // Set ranges and increment rgbaslider[0]->setRange(0,255); rgbaslider[1]->setRange(0,255); rgbaslider[2]->setRange(0,255); rgbaslider[3]->setRange(0,255); // HSV Mode new FXTabItem(panels,tr("\tHue, Saturation, Value"),hsvmodeicon,TAB_TOP_NORMAL,0,0,0,0, 6,6,0,0); // RGB Sliders FXMatrix *hsvblock=new FXMatrix(panels,3,FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_Y|LAYOUT_FILL_X|LAYOUT_TOP|LAYOUT_LEFT|MATRIX_BY_COLUMNS,0,0,0,0,10,10,10,10, 5,8); // Hue Slider new FXLabel(hsvblock,tr("Hue:"),nullptr,LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|LAYOUT_RIGHT); hsvatext[0]=new FXTextField(hsvblock,5,this,FXColorSelector::ID_HSV_HUE_TEXT,JUSTIFY_RIGHT|LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|FRAME_SUNKEN|FRAME_THICK,0,0,0,0, DEFAULT_PAD,DEFAULT_PAD,0,0); hsvaslider[0]=new FXSlider(hsvblock,this,FXColorSelector::ID_HSV_HUE_SLIDER,LAYOUT_FILL_ROW|LAYOUT_FILL_COLUMN|LAYOUT_CENTER_Y|LAYOUT_FILL_X|LAYOUT_FIX_HEIGHT|SLIDER_HORIZONTAL|SLIDER_INSIDE_BAR,0,0,0,15); // Saturation slider new FXLabel(hsvblock,tr("Saturation:"),nullptr,LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|LAYOUT_RIGHT); hsvatext[1]=new FXTextField(hsvblock,5,this,FXColorSelector::ID_HSV_SATURATION_TEXT,JUSTIFY_RIGHT|LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|FRAME_SUNKEN|FRAME_THICK,0,0,0,0, DEFAULT_PAD,DEFAULT_PAD,0,0); hsvaslider[1]=new FXSlider(hsvblock,this,FXColorSelector::ID_HSV_SATURATION_SLIDER,LAYOUT_FILL_ROW|LAYOUT_FILL_COLUMN|LAYOUT_CENTER_Y|LAYOUT_FILL_X|LAYOUT_FIX_HEIGHT|SLIDER_HORIZONTAL|SLIDER_INSIDE_BAR,0,0,0,15); // Value slider new FXLabel(hsvblock,tr("Value:"),nullptr,LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|LAYOUT_RIGHT); hsvatext[2]=new FXTextField(hsvblock,5,this,FXColorSelector::ID_HSV_VALUE_TEXT,JUSTIFY_RIGHT|LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|FRAME_SUNKEN|FRAME_THICK,0,0,0,0, DEFAULT_PAD,DEFAULT_PAD,0,0); hsvaslider[2]=new FXSlider(hsvblock,this,FXColorSelector::ID_HSV_VALUE_SLIDER,LAYOUT_FILL_ROW|LAYOUT_FILL_COLUMN|LAYOUT_CENTER_Y|LAYOUT_FILL_X|LAYOUT_FIX_HEIGHT|SLIDER_HORIZONTAL|SLIDER_INSIDE_BAR,0,0,0,15); // Alpha slider label=new FXLabel(hsvblock,tr("Alpha:"),nullptr,LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|LAYOUT_RIGHT); hsvatext[3]=new FXTextField(hsvblock,5,this,FXColorSelector::ID_ALPHA_TEXT,JUSTIFY_RIGHT|LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|FRAME_SUNKEN|FRAME_THICK,0,0,0,0, DEFAULT_PAD,DEFAULT_PAD,0,0); hsvaslider[3]=new FXSlider(hsvblock,this,FXColorSelector::ID_ALPHA_SLIDER,LAYOUT_FILL_ROW|LAYOUT_FILL_COLUMN|LAYOUT_CENTER_Y|LAYOUT_FILL_X|LAYOUT_FIX_HEIGHT|SLIDER_HORIZONTAL|SLIDER_INSIDE_BAR,0,0,0,15); label->setTarget(this); label->setSelector(ID_ALPHA_LABEL); // Set ranges hsvaslider[0]->setRange(0,360); hsvaslider[1]->setRange(0,1000); hsvaslider[2]->setRange(0,1000); hsvaslider[3]->setRange(0,255); // CMY Mode new FXTabItem(panels,tr("\tCyan, Magenta, Yellow"),cmymodeicon,TAB_TOP_NORMAL,0,0,0,0, 6,6,0,0); // RGB Sliders FXMatrix *cmyblock=new FXMatrix(panels,3,FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_Y|LAYOUT_FILL_X|LAYOUT_TOP|LAYOUT_LEFT|MATRIX_BY_COLUMNS,0,0,0,0,10,10,10,10, 5,8); // Cyan Slider new FXLabel(cmyblock,tr("Cyan:"),nullptr,LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|LAYOUT_RIGHT); cmytext[0]=new FXTextField(cmyblock,5,this,FXColorSelector::ID_CMY_CYAN_TEXT,JUSTIFY_RIGHT|LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|FRAME_SUNKEN|FRAME_THICK,0,0,0,0, DEFAULT_PAD,DEFAULT_PAD,0,0); cmyslider[0]=new FXSlider(cmyblock,this,FXColorSelector::ID_CMY_CYAN_SLIDER,LAYOUT_FILL_ROW|LAYOUT_FILL_COLUMN|LAYOUT_CENTER_Y|LAYOUT_FILL_X|LAYOUT_FIX_HEIGHT|SLIDER_HORIZONTAL|SLIDER_INSIDE_BAR,0,0,0,15); // Magenta slider new FXLabel(cmyblock,tr("Magenta:"),nullptr,LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|LAYOUT_RIGHT); cmytext[1]=new FXTextField(cmyblock,5,this,FXColorSelector::ID_CMY_MAGENTA_TEXT,JUSTIFY_RIGHT|LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|FRAME_SUNKEN|FRAME_THICK,0,0,0,0, DEFAULT_PAD,DEFAULT_PAD,0,0); cmyslider[1]=new FXSlider(cmyblock,this,FXColorSelector::ID_CMY_MAGENTA_SLIDER,LAYOUT_FILL_ROW|LAYOUT_FILL_COLUMN|LAYOUT_CENTER_Y|LAYOUT_FILL_X|LAYOUT_FIX_HEIGHT|SLIDER_HORIZONTAL|SLIDER_INSIDE_BAR,0,0,0,15); // Yellow slider new FXLabel(cmyblock,tr("Yellow:"),nullptr,LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|LAYOUT_RIGHT); cmytext[2]=new FXTextField(cmyblock,5,this,FXColorSelector::ID_CMY_YELLOW_TEXT,JUSTIFY_RIGHT|LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|FRAME_SUNKEN|FRAME_THICK,0,0,0,0, DEFAULT_PAD,DEFAULT_PAD,0,0); cmyslider[2]=new FXSlider(cmyblock,this,FXColorSelector::ID_CMY_YELLOW_SLIDER,LAYOUT_FILL_ROW|LAYOUT_FILL_COLUMN|LAYOUT_CENTER_Y|LAYOUT_FILL_X|LAYOUT_FIX_HEIGHT|SLIDER_HORIZONTAL|SLIDER_INSIDE_BAR,0,0,0,15); // Alpha slider label=new FXLabel(cmyblock,tr("Alpha:"),nullptr,LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|LAYOUT_RIGHT); cmytext[3]=new FXTextField(cmyblock,5,this,FXColorSelector::ID_ALPHA_TEXT,JUSTIFY_RIGHT|LAYOUT_FILL_ROW|LAYOUT_CENTER_Y|FRAME_SUNKEN|FRAME_THICK,0,0,0,0, DEFAULT_PAD,DEFAULT_PAD,0,0); cmyslider[3]=new FXSlider(cmyblock,this,FXColorSelector::ID_ALPHA_SLIDER,LAYOUT_FILL_ROW|LAYOUT_FILL_COLUMN|LAYOUT_CENTER_Y|LAYOUT_FILL_X|LAYOUT_FIX_HEIGHT|SLIDER_HORIZONTAL|SLIDER_INSIDE_BAR,0,0,0,15); label->setTarget(this); label->setSelector(ID_ALPHA_LABEL); // Set ranges cmyslider[0]->setRange(0,255); cmyslider[1]->setRange(0,255); cmyslider[2]->setRange(0,255); cmyslider[3]->setRange(0,255); // Named Color Mode new FXTabItem(panels,tr("\tBy Name"),txtmodeicon,TAB_TOP_NORMAL,0,0,0,0, 6,6,0,0); // Name list FXHorizontalFrame *outer=new FXHorizontalFrame(panels,FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_Y|LAYOUT_FILL_X); FXHorizontalFrame *frame=new FXHorizontalFrame(outer,LAYOUT_FILL_Y|LAYOUT_FILL_X|FRAME_SUNKEN|FRAME_THICK,0,0,0,0, 0,0,0,0); list=new FXColorList(frame,this,ID_COLOR_LIST,LAYOUT_FILL_Y|LAYOUT_FILL_X|LIST_BROWSESELECT); list->setNumVisible(8); list->setSortFunc(hueSort); // Add color names for(FXuint i=0; iappendItem(tr(colorName[i]),colorValue[i]); } list->sortItems(); // Init RGBA rgba[0]=0.0f; rgba[1]=0.0f; rgba[2]=0.0f; rgba[3]=1.0f; // Init HSVA hsva[0]=360.0f; hsva[1]=0.0f; hsva[2]=0.0f; hsva[3]=1.0f; // Reflect color in well updateWell(); // Initial focus on accept button accept->setFocus(); } /*******************************************************************************/ // Set color from message long FXColorSelector::onCmdSetValue(FXObject*,FXSelector,void* ptr){ setRGBA((FXColor)(FXuval)ptr); return 1; } // Update color selector from a message long FXColorSelector::onCmdSetIntValue(FXObject*,FXSelector,void* ptr){ setRGBA(*((FXColor*)ptr)); return 1; } // Obtain value from color selector long FXColorSelector::onCmdGetIntValue(FXObject*,FXSelector,void* ptr){ *((FXColor*)ptr)=getRGBA(); return 1; } /*******************************************************************************/ // ALPHA // Update well from Alpha slider long FXColorSelector::onCmdAlphaSlider(FXObject* sender,FXSelector sel,void*){ FXint value; sender->handle(this,FXSEL(SEL_COMMAND,ID_GETINTVALUE),(void*)&value); hsva[3]=rgba[3]=0.003921568627f*value; updateWell(); if(target) target->tryHandle(this,FXSEL(FXSELTYPE(sel),message),(void*)(FXuval)well->getRGBA()); return 1; } // Update well from Alpha text fields long FXColorSelector::onCmdAlphaText(FXObject* sender,FXSelector,void*){ FXdouble value; sender->handle(this,FXSEL(SEL_COMMAND,ID_GETREALVALUE),(void*)&value); hsva[3]=rgba[3]=0.003921568627f*(FXfloat)value; updateWell(); if(target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXuval)well->getRGBA()); return 1; } // Update Alpha text fields long FXColorSelector::onUpdAlphaText(FXObject* sender,FXSelector,void*){ FXString value; if(isOpaqueOnly()){ sender->handle(this,FXSEL(SEL_COMMAND,ID_HIDE),nullptr); } else{ value.fromDouble(255.0f*rgba[3],1,0); sender->handle(this,FXSEL(SEL_COMMAND,ID_SETSTRINGVALUE),(void*)&value); sender->handle(this,FXSEL(SEL_COMMAND,ID_SHOW),nullptr); } return 1; } // Update Alpha sliders long FXColorSelector::onUpdAlphaSlider(FXObject* sender,FXSelector,void*){ if(isOpaqueOnly()){ sender->handle(this,FXSEL(SEL_COMMAND,ID_HIDE),nullptr); } else{ FXint value=(FXint)(255.0f*rgba[3]); sender->handle(this,FXSEL(SEL_COMMAND,ID_SETINTVALUE),(void*)&value); sender->handle(this,FXSEL(SEL_COMMAND,ID_SHOW),nullptr); } return 1; } // Update Alpha Labels long FXColorSelector::onUpdAlphaLabel(FXObject* sender,FXSelector,void*){ sender->handle(this,isOpaqueOnly()?FXSEL(SEL_COMMAND,ID_HIDE):FXSEL(SEL_COMMAND,ID_SHOW),nullptr); return 1; } /*******************************************************************************/ // Wheel // Update well from wheel long FXColorSelector::onCmdWheel(FXObject*,FXSelector sel,void*){ hsva[0]=wheel->getHue(); hsva[1]=wheel->getSat(); hsva[2]=wheel->getVal(); fxhsv_to_rgb(rgba[0],rgba[1],rgba[2],hsva[0],hsva[1],hsva[2]); updateWell(); if(target) target->tryHandle(this,FXSEL(FXSELTYPE(sel),message),(void*)(FXuval)well->getRGBA()); return 1; } // Update wheel long FXColorSelector::onUpdWheel(FXObject*,FXSelector,void*){ wheel->setHue(hsva[0]); wheel->setSat(hsva[1]); wheel->setVal(hsva[2]); return 1; } /*******************************************************************************/ // RGB // Update well from RGB slider long FXColorSelector::onCmdRGBSlider(FXObject*,FXSelector sel,void*){ FXint which=FXSELID(sel)-ID_RGB_RED_SLIDER; rgba[which]=0.003921568627f*rgbaslider[which]->getValue(); fxrgb_to_hsv(hsva[0],hsva[1],hsva[2],rgba[0],rgba[1],rgba[2]); updateWell(); if(target) target->tryHandle(this,FXSEL(FXSELTYPE(sel),message),(void*)(FXuval)well->getRGBA()); return 1; } // Update well from RGB text fields long FXColorSelector::onCmdRGBText(FXObject*,FXSelector sel,void*){ FXint which=FXSELID(sel)-ID_RGB_RED_TEXT; rgba[which]=0.003921568627f*rgbatext[which]->getText().toFloat(); fxrgb_to_hsv(hsva[0],hsva[1],hsva[2],rgba[0],rgba[1],rgba[2]); updateWell(); if(target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXuval)well->getRGBA()); return 1; } // Update RGB text fields long FXColorSelector::onUpdRGBText(FXObject*,FXSelector sel,void*){ FXint which=FXSELID(sel)-ID_RGB_RED_TEXT; rgbatext[which]->setText(FXString::value(255.0f*rgba[which],1,0)); return 1; } // Update RGB sliders long FXColorSelector::onUpdRGBSlider(FXObject*,FXSelector sel,void*){ FXint which=FXSELID(sel)-ID_RGB_RED_SLIDER; rgbaslider[which]->setValue((FXint)(255.0f*rgba[which])); return 1; } /*******************************************************************************/ // HSV // Update well from HSV sliders long FXColorSelector::onCmdHSVSlider(FXObject*,FXSelector sel,void*){ const FXfloat factor[3]={1.0f,0.001f,0.001f}; FXint which=FXSELID(sel)-ID_HSV_HUE_SLIDER; hsva[which]=factor[which]*hsvaslider[which]->getValue(); fxhsv_to_rgb(rgba[0],rgba[1],rgba[2],hsva[0],hsva[1],hsva[2]); updateWell(); if(target) target->tryHandle(this,FXSEL(FXSELTYPE(sel),message),(void*)(FXuval)well->getRGBA()); return 1; } // Update well from HSV text fields long FXColorSelector::onCmdHSVText(FXObject*,FXSelector sel,void*){ const FXfloat factor[3]={1.0f,0.01f,0.01f}; FXint which=FXSELID(sel)-ID_HSV_HUE_TEXT; hsva[which]=factor[which]*hsvatext[which]->getText().toFloat(); fxhsv_to_rgb(rgba[0],rgba[1],rgba[2],hsva[0],hsva[1],hsva[2]); updateWell(); if(target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXuval)well->getRGBA()); return 1; } // Update HSV text fields long FXColorSelector::onUpdHSVText(FXObject*,FXSelector sel,void*){ const FXfloat factor[3]={1.0f,100.0f,100.0f}; FXint which=FXSELID(sel)-ID_HSV_HUE_TEXT; hsvatext[which]->setText(FXString::value(hsva[which]*factor[which],1,0)); return 1; } // Update HSV sliders long FXColorSelector::onUpdHSVSlider(FXObject*,FXSelector sel,void*){ const FXfloat factor[3]={1.0f,1000.0f,1000.0f}; FXint which=FXSELID(sel)-ID_HSV_HUE_SLIDER; hsvaslider[which]->setValue((FXint)(hsva[which]*factor[which])); return 1; } /*******************************************************************************/ // CMY long FXColorSelector::onCmdCMYSlider(FXObject*,FXSelector sel,void*){ FXint which=FXSELID(sel)-ID_CMY_CYAN_SLIDER; FXfloat val=0.003921568627f*cmyslider[which]->getValue(); rgba[which]=1.0f-val; fxrgb_to_hsv(hsva[0],hsva[1],hsva[2],rgba[0],rgba[1],rgba[2]); hsva[3]=rgba[3]; updateWell(); if(target) target->tryHandle(this,FXSEL(FXSELTYPE(sel),message),(void*)(FXuval)well->getRGBA()); return 1; } long FXColorSelector::onCmdCMYText(FXObject*,FXSelector sel,void*){ FXint which=FXSELID(sel)-ID_CMY_CYAN_TEXT; FXfloat val=0.003921568627f*cmytext[which]->getText().toFloat(); rgba[which]=1.0f-val; fxrgb_to_hsv(hsva[0],hsva[1],hsva[2],rgba[0],rgba[1],rgba[2]); hsva[3]=rgba[3]; updateWell(); if(target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXuval)well->getRGBA()); return 1; } long FXColorSelector::onUpdCMYText(FXObject*,FXSelector sel,void*){ FXint which=FXSELID(sel)-ID_CMY_CYAN_TEXT; FXfloat val=255.0f-255.0f*rgba[which]; cmytext[which]->setText(FXString::value(val,1,0)); return 1; } long FXColorSelector::onUpdCMYSlider(FXObject*,FXSelector sel,void*){ FXint which=FXSELID(sel)-ID_CMY_CYAN_SLIDER; FXint val=(FXint)(255.0f-255.0f*rgba[which]); cmyslider[which]->setValue(val); return 1; } /*******************************************************************************/ // Color picker; note, dc released prior to callback long FXColorSelector::onCmdColorPick(FXObject*,FXSelector,void* ptr){ FXColor color; { FXDCWindow dc(getRoot()); color=dc.readPixel(((FXPoint*)ptr)->x,((FXPoint*)ptr)->y); } setRGBA(color,true); return 1; } /*******************************************************************************/ // Dropped color in main well long FXColorSelector::onChgWell(FXObject*,FXSelector,void* ptr){ FXColor color=(FXColor)(FXuval)ptr; if(isOpaqueOnly()) color|=FXRGBA(0,0,0,255); rgba[0]=0.003921568627f*FXREDVAL(color); rgba[1]=0.003921568627f*FXGREENVAL(color); rgba[2]=0.003921568627f*FXBLUEVAL(color); rgba[3]=0.003921568627f*FXALPHAVAL(color); fxrgb_to_hsv(hsva[0],hsva[1],hsva[2],rgba[0],rgba[1],rgba[2]); hsva[3]=rgba[3]; return 1; } // Command from main well long FXColorSelector::onCmdWell(FXObject*,FXSelector,void*){ if(target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXuval)well->getRGBA()); return 1; } // Update main well void FXColorSelector::updateWell(){ well->setRGBA(FXRGBA((int)(rgba[0]*255.0f),(int)(rgba[1]*255.0f),(int)(rgba[2]*255.0f),(int)(rgba[3]*255.0f))); } /*******************************************************************************/ // Clicked on color in list long FXColorSelector::onCmdList(FXObject*,FXSelector,void* ptr){ setRGBA(list->getItemColor((FXint)(FXuval)ptr),true); return 1; } /*******************************************************************************/ // Custom well clicked long FXColorSelector::onCmdCustomWell(FXObject*,FXSelector,void* ptr){ setRGBA((FXColor)(FXuval)ptr,true); return 1; } /*******************************************************************************/ // Change RGBA color void FXColorSelector::setRGBA(FXColor color,FXbool notify){ if(isOpaqueOnly()) color|=FXRGBA(0,0,0,255); if(color!=well->getRGBA()){ rgba[0]=0.003921568627f*FXREDVAL(color); rgba[1]=0.003921568627f*FXGREENVAL(color); rgba[2]=0.003921568627f*FXBLUEVAL(color); rgba[3]=0.003921568627f*FXALPHAVAL(color); fxrgb_to_hsv(hsva[0],hsva[1],hsva[2],rgba[0],rgba[1],rgba[2]); hsva[3]=rgba[3]; well->setRGBA(color); if(target && notify) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXuval)color); } } // Retrieve RGBA color FXColor FXColorSelector::getRGBA() const { return well->getRGBA(); } // Change active panel void FXColorSelector::setActivePanel(FXint pnl){ panels->setCurrent(pnl); } // Return active panel FXint FXColorSelector::getActivePanel() const { return panels->getCurrent(); } // Change well color void FXColorSelector::setWellColor(FXint w,FXColor clr){ colorwells[w]->setRGBA(clr); } // Return well color FXColor FXColorSelector::getWellColor(FXint w) const { return colorwells[w]->getRGBA(); } // Change opaque only mode void FXColorSelector::setOpaqueOnly(FXbool opaque){ if(opaque){ well->setOpaqueOnly(true); setRGBA(well->getRGBA() | FXRGBA(0,0,0,255)); } else{ well->setOpaqueOnly(false); } } // Return true if only opaque colors allowed FXbool FXColorSelector::isOpaqueOnly() const { return well->isOpaqueOnly(); } /*******************************************************************************/ // Save data void FXColorSelector::save(FXStream& store) const { FXPacker::save(store); store << panels; store << well; store << list; store << accept; store << cancel; store << dialmodeicon; store << rgbmodeicon; store << hsvmodeicon; store << cmymodeicon; store << txtmodeicon; store << wheel; store << rgbaslider[0] << rgbaslider[1] << rgbaslider[2] << rgbaslider[3]; store << hsvaslider[0] << hsvaslider[1] << hsvaslider[2] << hsvaslider[3]; store << cmyslider[0] << cmyslider[1] << cmyslider[2] << cmyslider[3]; store << rgbatext[0] << rgbatext[1] << rgbatext[2] << rgbatext[3]; store << hsvatext[0] << hsvatext[1] << hsvatext[2] << hsvatext[3]; store << cmytext[0] << cmytext[1] << cmytext[2] << cmytext[3]; store << colorwells[0] << colorwells[1] << colorwells[2] << colorwells[3]; store << colorwells[4] << colorwells[5] << colorwells[6] << colorwells[7]; store << colorwells[8] << colorwells[9] << colorwells[10] << colorwells[11]; store << colorwells[12] << colorwells[13] << colorwells[14] << colorwells[15]; store << colorwells[16] << colorwells[17] << colorwells[18] << colorwells[19]; store << colorwells[20] << colorwells[21] << colorwells[22] << colorwells[23]; store.save(rgba,4); store.save(hsva,4); } // Load data void FXColorSelector::load(FXStream& store){ FXPacker::load(store); store >> panels; store >> well; store >> list; store >> accept; store >> cancel; store >> dialmodeicon; store >> rgbmodeicon; store >> hsvmodeicon; store >> cmymodeicon; store >> txtmodeicon; store >> wheel; store >> rgbaslider[0] >> rgbaslider[1] >> rgbaslider[2] >> rgbaslider[3]; store >> hsvaslider[0] >> hsvaslider[1] >> hsvaslider[2] >> hsvaslider[3]; store >> cmyslider[0] >> cmyslider[1] >> cmyslider[2] >> cmyslider[3]; store >> rgbatext[0] >> rgbatext[1] >> rgbatext[2] >> rgbatext[3]; store >> hsvatext[0] >> hsvatext[1] >> hsvatext[2] >> hsvatext[3]; store >> cmytext[0] >> cmytext[1] >> cmytext[2] >> cmytext[3]; store >> colorwells[0] >> colorwells[1] >> colorwells[2] >> colorwells[3]; store >> colorwells[4] >> colorwells[5] >> colorwells[6] >> colorwells[7]; store >> colorwells[8] >> colorwells[9] >> colorwells[10] >> colorwells[11]; store >> colorwells[12] >> colorwells[13] >> colorwells[14] >> colorwells[15]; store >> colorwells[16] >> colorwells[17] >> colorwells[18] >> colorwells[19]; store >> colorwells[20] >> colorwells[21] >> colorwells[22] >> colorwells[23]; store.load(rgba,4); store.load(hsva,4); } // Cleanup; icons must be explicitly deleted FXColorSelector::~FXColorSelector(){ delete eyedropicon; delete dialmodeicon; delete rgbmodeicon; delete hsvmodeicon; delete cmymodeicon; delete txtmodeicon; wheel=(FXColorRing*)-1L; eyedropicon=(FXIcon*)-1L; dialmodeicon=(FXIcon*)-1L; rgbmodeicon=(FXIcon*)-1L; hsvmodeicon=(FXIcon*)-1L; cmymodeicon=(FXIcon*)-1L; txtmodeicon=(FXIcon*)-1L; panels=(FXTabBook*)-1L; well=(FXColorWell*)-1L; accept=(FXButton*)-1L; cancel=(FXButton*)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXColorWell.cpp000066400000000000000000000457201455751074500224600ustar00rootroot00000000000000/******************************************************************************** * * * C o l o r W e l l C l a s s * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXElement.h" #include "FXStream.h" #include "FXString.h" #include "FXColors.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXObject.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FXLabel.h" #include "FXColors.h" #include "FXColorWell.h" #include "FXColorSelector.h" #include "FXColorDialog.h" /* Notes: - FXColorWell now observes border styles, but padding is outside of the well. - Focus rectangle now drawn inside the color swatch part of the well. - Possibly have no border or padding; so you can now tightly pack wells together, for example, inside FXMatrix. - Probably need to use this feature in FXColorSelector (large collection of custom colors in block under panel). - Also, FXColorWell has default size that can be changed; minimum is 3 pixels, 1 pixel for color, 2 for focus rectangle. - Single-click should send SEL_COMMAND to target. - Perhaps change of color should send SEL_CHANGED. - Do not start drag operation unless moving a little bit. - Drive from keyboard. - Yes, you can now drag a color into a text widget, or drag the name of a color into the well, as well as pasting a color into a text widget or vice versa! */ using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXColorWell) FXColorWellMap[]={ FXMAPFUNC(SEL_PAINT,0,FXColorWell::onPaint), FXMAPFUNC(SEL_MOTION,0,FXColorWell::onMotion), FXMAPFUNC(SEL_DRAGGED,0,FXColorWell::onDragged), FXMAPFUNC(SEL_DND_MOTION,0,FXColorWell::onDNDMotion), FXMAPFUNC(SEL_DND_ENTER,0,FXColorWell::onDNDEnter), FXMAPFUNC(SEL_DND_LEAVE,0,FXColorWell::onDNDLeave), FXMAPFUNC(SEL_DND_DROP,0,FXColorWell::onDNDDrop), FXMAPFUNC(SEL_DND_REQUEST,0,FXColorWell::onDNDRequest), FXMAPFUNC(SEL_FOCUSIN,0,FXColorWell::onFocusIn), FXMAPFUNC(SEL_FOCUSOUT,0,FXColorWell::onFocusOut), FXMAPFUNC(SEL_LEFTBUTTONPRESS,0,FXColorWell::onLeftBtnPress), FXMAPFUNC(SEL_LEFTBUTTONRELEASE,0,FXColorWell::onLeftBtnRelease), FXMAPFUNC(SEL_CLICKED,0,FXColorWell::onClicked), FXMAPFUNC(SEL_DOUBLECLICKED,0,FXColorWell::onDoubleClicked), FXMAPFUNC(SEL_KEYPRESS,0,FXColorWell::onKeyPress), FXMAPFUNC(SEL_KEYRELEASE,0,FXColorWell::onKeyRelease), FXMAPFUNC(SEL_UNGRABBED,0,FXColorWell::onUngrabbed), FXMAPFUNC(SEL_BEGINDRAG,0,FXColorWell::onBeginDrag), FXMAPFUNC(SEL_ENDDRAG,0,FXColorWell::onEndDrag), FXMAPFUNC(SEL_QUERY_TIP,0,FXColorWell::onQueryTip), FXMAPFUNC(SEL_QUERY_HELP,0,FXColorWell::onQueryHelp), FXMAPFUNC(SEL_COMMAND,FXColorWell::ID_SETVALUE,FXColorWell::onCmdSetValue), FXMAPFUNC(SEL_COMMAND,FXColorWell::ID_SETINTVALUE,FXColorWell::onCmdSetIntValue), FXMAPFUNC(SEL_COMMAND,FXColorWell::ID_GETINTVALUE,FXColorWell::onCmdGetIntValue), FXMAPFUNC(SEL_COMMAND,FXColorWell::ID_SETHELPSTRING,FXColorWell::onCmdSetHelp), FXMAPFUNC(SEL_COMMAND,FXColorWell::ID_GETHELPSTRING,FXColorWell::onCmdGetHelp), FXMAPFUNC(SEL_COMMAND,FXColorWell::ID_SETTIPSTRING,FXColorWell::onCmdSetTip), FXMAPFUNC(SEL_COMMAND,FXColorWell::ID_GETTIPSTRING,FXColorWell::onCmdGetTip), FXMAPFUNC(SEL_UPDATE,FXColorWell::ID_COLOR,FXColorWell::onUpdColor), FXMAPFUNC(SEL_CHANGED,FXColorWell::ID_COLOR,FXColorWell::onChgColor), FXMAPFUNC(SEL_COMMAND,FXColorWell::ID_COLOR,FXColorWell::onCmdColor), }; // Object implementation FXIMPLEMENT(FXColorWell,FXFrame,FXColorWellMap,ARRAYNUMBER(FXColorWellMap)) /*******************************************************************************/ // Init FXColorWell::FXColorWell(){ wellColor[0]=FXColors::White; wellColor[1]=FXColors::White; wellSize=12; rgba=FXColors::White; flags|=FLAG_ENABLED|FLAG_DROPTARGET; } // Make a color well FXColorWell::FXColorWell(FXComposite* p,FXColor clr,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb):FXFrame(p,opts,x,y,w,h,pl,pr,pt,pb){ flags|=FLAG_ENABLED|FLAG_DROPTARGET; wellColor[0]=blendOverWhite(clr); wellColor[1]=blendOverBlack(clr); wellSize=12; rgba=clr; target=tgt; message=sel; } // If window can have focus FXbool FXColorWell::canFocus() const { return true; } // Into focus chain void FXColorWell::setFocus(){ FXFrame::setFocus(); setDefault(true); } // Out of focus chain void FXColorWell::killFocus(){ FXFrame::killFocus(); setDefault(maybe); } // Get default size FXint FXColorWell::getDefaultWidth(){ return wellSize+padleft+padright+(border<<1); } FXint FXColorWell::getDefaultHeight(){ return wellSize+padtop+padbottom+(border<<1); } // Handle repaint long FXColorWell::onPaint(FXObject*,FXSelector,void* ptr){ FXDCWindow dc(this,(FXEvent*)ptr); FXPoint points[3]; dc.setForeground(backColor); dc.fillRectangle(0,0,width,padtop); dc.fillRectangle(0,padtop,padleft,height-padtop-padbottom); dc.fillRectangle(width-padright,padtop,padright,height-padtop-padbottom); dc.fillRectangle(0,height-padbottom,width,padbottom); drawFrame(dc,padleft,padtop,width-padright-padleft,height-padtop-padbottom); dc.setForeground(wellColor[0]); points[0].x=points[1].x=padleft+border; points[2].x=width-padright-border; points[0].y=points[2].y=padtop+border; points[1].y=height-padbottom-border; dc.fillPolygon(points,3); dc.setForeground(wellColor[1]); points[0].x=padleft+border; points[1].x=points[2].x=width-padright-border; points[0].y=points[1].y=height-padbottom-border; points[2].y=padtop+border; dc.fillPolygon(points,3); if(hasFocus()){ dc.drawFocusRectangle(padleft+border+1,padtop+border+1,width-padright-padleft-(border<<1)-2,height-padbottom-padtop-(border<<1)-2); } return 1; } // Gained focus long FXColorWell::onFocusIn(FXObject* sender,FXSelector sel,void* ptr){ FXFrame::onFocusIn(sender,sel,ptr); update(); return 1; } // Lost focus long FXColorWell::onFocusOut(FXObject* sender,FXSelector sel,void* ptr){ FXFrame::onFocusOut(sender,sel,ptr); update(); return 1; } // Dragging something over well; save old color and block GUI updates long FXColorWell::onDNDEnter(FXObject* sender,FXSelector sel,void* ptr){ if(FXFrame::onDNDEnter(sender,sel,ptr)) return 1; flags&=~FLAG_UPDATE; return 1; } // Dragged out of well, so restore old color and reenable GUI updates long FXColorWell::onDNDLeave(FXObject* sender,FXSelector sel,void* ptr){ if(FXFrame::onDNDLeave(sender,sel,ptr)) return 1; flags|=FLAG_UPDATE; return 1; } // Handle drag-and-drop motion long FXColorWell::onDNDMotion(FXObject* sender,FXSelector sel,void* ptr){ // Handle base class first if(FXFrame::onDNDMotion(sender,sel,ptr)) return 1; // No more messages while inside setDragRectangle(0,0,width,height,false); // Is it a color being dropped? if(offeredDNDType(FROM_DRAGNDROP,colorType)){ acceptDrop(DRAG_ACCEPT); return 1; } // Is it a name of a color being dropped? if(offeredDNDType(FROM_DRAGNDROP,textType)){ acceptDrop(DRAG_ACCEPT); return 1; } return 0; } // Handle drag-and-drop drop long FXColorWell::onDNDDrop(FXObject* sender,FXSelector sel,void* ptr){ FXuchar *pointer; FXuint length; FXColor color; // Enable updating flags|=FLAG_UPDATE; // Try handling it in base class first if(FXFrame::onDNDDrop(sender,sel,ptr)) return 1; // Try and obtain the color first if(getDNDData(FROM_DRAGNDROP,colorType,pointer,length)){ color=FXRGBA((((FXushort*)pointer)[0]+128)/257,(((FXushort*)pointer)[1]+128)/257,(((FXushort*)pointer)[2]+128)/257,(((FXushort*)pointer)[3]+128)/257); freeElms(pointer); setRGBA(color,true); return 1; } // Maybe its the name of a color if(getDNDData(FROM_DRAGNDROP,textType,pointer,length)){ resizeElms(pointer,length+1); pointer[length]='\0'; color=colorFromName((const FXchar*)pointer); freeElms(pointer); // Accept the drop only if it was a valid color name if(color!=FXRGBA(0,0,0,0)){ setRGBA(color,true); return 1; } } return 0; } // Service requested DND data long FXColorWell::onDNDRequest(FXObject* sender,FXSelector sel,void* ptr){ FXEvent *event=(FXEvent*)ptr; // Try handling it in base class first if(FXFrame::onDNDRequest(sender,sel,ptr)) return 1; // Requested as a color if(event->target==colorType){ FXushort *color; allocElms(color,4); color[0]=257*FXREDVAL(rgba); color[1]=257*FXGREENVAL(rgba); color[2]=257*FXBLUEVAL(rgba); color[3]=257*FXALPHAVAL(rgba); setDNDData(FROM_DRAGNDROP,colorType,(FXuchar*)color,sizeof(FXushort)*4); return 1; } // Requested as a color name if(event->target==textType){ FXchar *string; callocElms(string,50); nameFromColor(string,rgba); setDNDData(FROM_DRAGNDROP,textType,(FXuchar*)string,strlen(string)); return 1; } return 0; } // Start a drag operation long FXColorWell::onBeginDrag(FXObject* sender,FXSelector sel,void* ptr){ FXDragType types[2]={colorType,textType}; if(!FXFrame::onBeginDrag(sender,sel,ptr)){ beginDrag(types,ARRAYNUMBER(types)); setDragCursor(getApp()->getDefaultCursor(DEF_SWATCH_CURSOR)); } return 1; } // End drag operation long FXColorWell::onEndDrag(FXObject* sender,FXSelector sel,void* ptr){ if(!FXFrame::onEndDrag(sender,sel,ptr)){ endDrag(didAccept()==DRAG_COPY); setDragCursor(getApp()->getDefaultCursor(DEF_ARROW_CURSOR)); } return 1; } // Dragged stuff around long FXColorWell::onDragged(FXObject* sender,FXSelector sel,void* ptr){ if(!FXFrame::onDragged(sender,sel,ptr)){ handleDrag(((FXEvent*)ptr)->root_x,((FXEvent*)ptr)->root_y,DRAG_COPY); if(didAccept()==DRAG_COPY){ setDragCursor(getApp()->getDefaultCursor(DEF_SWATCH_CURSOR)); } else{ setDragCursor(getApp()->getDefaultCursor(DEF_DNDSTOP_CURSOR)); } } return 1; } // Moving long FXColorWell::onMotion(FXObject*,FXSelector,void* ptr){ if(flags&FLAG_DODRAG){ handle(this,FXSEL(SEL_DRAGGED,0),ptr); return 1; } if((flags&FLAG_TRYDRAG) && ((FXEvent*)ptr)->moved){ if(handle(this,FXSEL(SEL_BEGINDRAG,0),ptr)) flags|=FLAG_DODRAG; flags&=~FLAG_TRYDRAG; return 1; } return 0; } // Drag start long FXColorWell::onLeftBtnPress(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; flags&=~FLAG_TIP; handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr); if(isEnabled()){ grab(); if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONPRESS,message),ptr)) return 1; if(event->click_count==1){ flags&=~FLAG_UPDATE; flags|=FLAG_TRYDRAG; } } return 1; } // Drop long FXColorWell::onLeftBtnRelease(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; FXuint flgs=flags; if(isEnabled()){ ungrab(); flags|=FLAG_UPDATE; flags&=~(FLAG_TRYDRAG|FLAG_DODRAG); if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONRELEASE,message),ptr)) return 1; if(flgs&FLAG_DODRAG){handle(this,FXSEL(SEL_ENDDRAG,0),ptr);} if(event->click_count==1){ handle(this,FXSEL(SEL_CLICKED,0),(void*)(FXuval)rgba); if(!event->moved && target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXuval)rgba); } else if(event->click_count==2){ handle(this,FXSEL(SEL_DOUBLECLICKED,0),(void*)(FXuval)rgba); } return 1; } return 1; } // Key Press long FXColorWell::onKeyPress(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; flags&=~FLAG_TIP; if(isEnabled()){ if(target && target->tryHandle(this,FXSEL(SEL_KEYPRESS,message),ptr)) return 1; switch(event->code){ case KEY_space: case KEY_KP_Enter: case KEY_Return: flags&=~FLAG_UPDATE; return 1; } } return 0; } // Key Release long FXColorWell::onKeyRelease(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; if(isEnabled()){ flags|=FLAG_UPDATE; if(target && target->tryHandle(this,FXSEL(SEL_KEYRELEASE,message),ptr)) return 1; switch(event->code){ case KEY_space: handle(this,FXSEL(SEL_CLICKED,0),(void*)(FXuval)rgba); if(target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXuval)rgba); return 1; case KEY_KP_Enter: case KEY_Return: handle(this,FXSEL(SEL_DOUBLECLICKED,0),(void*)(FXuval)rgba); return 1; } } return 0; } // Clicked in the well long FXColorWell::onClicked(FXObject*,FXSelector,void*){ return target && target->tryHandle(this,FXSEL(SEL_CLICKED,message),(void*)(FXuval)rgba); } // Double clicked in well; normally pops the color dialog // except when COLORWELL_SOURCEONLY is passed in which case // editing by the dialog is not allowed (used for wells inside the // color dialog itself for example). // The well follows the editing via the dialog; when the dialog // is closed by cancelling it it will revert to the old color long FXColorWell::onDoubleClicked(FXObject*,FXSelector,void*){ if(target && target->tryHandle(this,FXSEL(SEL_DOUBLECLICKED,message),(void*)(FXuval)rgba)) return 1; if(isSourceOnly()) return 1; FXColorDialog colordialog(this,tr("Color Dialog")); FXColor oldcolor=getRGBA(); colordialog.setTarget(this); colordialog.setSelector(ID_COLOR); colordialog.setOpaqueOnly(isOpaqueOnly()); if(!colordialog.execute()){ setRGBA(oldcolor,true); } return 1; } // The widget lost the grab for some reason long FXColorWell::onUngrabbed(FXObject* sender,FXSelector sel,void* ptr){ FXFrame::onUngrabbed(sender,sel,ptr); flags&=~(FLAG_TRYDRAG|FLAG_DODRAG); flags|=FLAG_UPDATE; endDrag(false); return 1; } // Update another Color Well long FXColorWell::onUpdColor(FXObject* sender,FXSelector,void*){ sender->handle(this,FXSEL(SEL_COMMAND,ID_SETINTVALUE),(void*)&rgba); return 1; } // Change from another Color Well long FXColorWell::onChgColor(FXObject*,FXSelector,void* ptr){ flags&=~FLAG_UPDATE; setRGBA((FXColor)(FXuval)ptr); if(target) target->tryHandle(this,FXSEL(SEL_CHANGED,message),(void*)(FXuval)rgba); return 1; } // Command from another Color Well long FXColorWell::onCmdColor(FXObject*,FXSelector,void* ptr){ flags|=FLAG_UPDATE; setRGBA((FXColor)(FXuval)ptr); if(target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXuval)rgba); return 1; } // Set help using a message long FXColorWell::onCmdSetHelp(FXObject*,FXSelector,void* ptr){ setHelpText(*((FXString*)ptr)); return 1; } // Get help using a message long FXColorWell::onCmdGetHelp(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getHelpText(); return 1; } // Set tip using a message long FXColorWell::onCmdSetTip(FXObject*,FXSelector,void* ptr){ setTipText(*((FXString*)ptr)); return 1; } // Get tip using a message long FXColorWell::onCmdGetTip(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getTipText(); return 1; } // We were asked about tip text long FXColorWell::onQueryTip(FXObject* sender,FXSelector sel,void* ptr){ if(FXFrame::onQueryTip(sender,sel,ptr)) return 1; if((flags&FLAG_TIP) && !tip.empty()){ sender->handle(this,FXSEL(SEL_COMMAND,ID_SETSTRINGVALUE),(void*)&tip); return 1; } return 0; } // We were asked about status text long FXColorWell::onQueryHelp(FXObject* sender,FXSelector sel,void* ptr){ if(FXFrame::onQueryHelp(sender,sel,ptr)) return 1; if((flags&FLAG_HELP) && !help.empty()){ sender->handle(this,FXSEL(SEL_COMMAND,ID_SETSTRINGVALUE),(void*)&help); return 1; } return 0; } // Change RGBA color void FXColorWell::setRGBA(FXColor clr,FXbool notify){ if(isOpaqueOnly()) clr|=FXRGBA(0,0,0,255); if(clr!=rgba){ rgba=clr; wellColor[0]=blendOverWhite(rgba); wellColor[1]=blendOverBlack(rgba); update(); if(notify && target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXuval)rgba); } } // Set color long FXColorWell::onCmdSetValue(FXObject*,FXSelector,void* ptr){ setRGBA((FXColor)(FXuval)ptr); return 1; } // Update well from a message long FXColorWell::onCmdSetIntValue(FXObject*,FXSelector,void* ptr){ setRGBA(*((FXColor*)ptr)); return 1; } // Obtain value from well long FXColorWell::onCmdGetIntValue(FXObject*,FXSelector,void* ptr){ *((FXColor*)ptr)=getRGBA(); return 1; } // Change minimum well size void FXColorWell::setWellSise(FXint ws){ if(ws<3) ws=3; if(wellSize!=ws){ wellSize=ws; recalc(); } } // Return true if only opaque colors allowed FXbool FXColorWell::isOpaqueOnly() const { return (options&COLORWELL_OPAQUEONLY)!=0; } // Change opaque only mode void FXColorWell::setOpaqueOnly(FXbool opaque){ if(opaque){ options|=COLORWELL_OPAQUEONLY; setRGBA(rgba); } else{ options&=~COLORWELL_OPAQUEONLY; } } // Return true if only a source FXbool FXColorWell::isSourceOnly() const { return (options&COLORWELL_SOURCEONLY)!=0; } // Change source only mode void FXColorWell::setSourceOnly(FXbool srconly){ options^=((0-srconly)^options)&COLORWELL_SOURCEONLY; } // Save data void FXColorWell::save(FXStream& store) const { FXFrame::save(store); store << wellColor[0] << wellColor[1]; store << rgba; store << tip; store << help; } // Load data void FXColorWell::load(FXStream& store){ FXFrame::load(store); store >> wellColor[0] >> wellColor[1]; store >> rgba; store >> tip; store >> help; } // Destroy FXColorWell::~FXColorWell(){ } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXColorWheel.cpp000066400000000000000000000313431455751074500226150ustar00rootroot00000000000000/******************************************************************************** * * * C o l o r W h e e l W i d g e t * * * ********************************************************************************* * Copyright (C) 2001,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FXImage.h" #include "FXColorWheel.h" /* Notes: - We assume the dial is round. - Dial can now be justified inside its box. */ #define WHEELDIAMETER 60 // Default Wheel diameter #define JUSTIFY_MASK (JUSTIFY_HZ_APART|JUSTIFY_VT_APART) using namespace FX; /*******************************************************************************/ namespace FX { // Special single-precision versions const FXfloat pi=3.1415926535897932384626433833f; const FXfloat dtor=0.0174532925199432957692369077f; const FXfloat rtod=57.295779513082320876798154814f; // Map FXDEFMAP(FXColorWheel) FXColorWheelMap[]={ FXMAPFUNC(SEL_PAINT,0,FXColorWheel::onPaint), FXMAPFUNC(SEL_MOTION,0,FXColorWheel::onMotion), FXMAPFUNC(SEL_MOUSEWHEEL,0,FXColorWheel::onMouseWheel), FXMAPFUNC(SEL_LEFTBUTTONPRESS,0,FXColorWheel::onLeftBtnPress), FXMAPFUNC(SEL_LEFTBUTTONRELEASE,0,FXColorWheel::onLeftBtnRelease), FXMAPFUNC(SEL_QUERY_TIP,0,FXColorWheel::onQueryTip), FXMAPFUNC(SEL_QUERY_HELP,0,FXColorWheel::onQueryHelp), FXMAPFUNC(SEL_COMMAND,FXColorWheel::ID_SETHELPSTRING,FXColorWheel::onCmdSetHelp), FXMAPFUNC(SEL_COMMAND,FXColorWheel::ID_GETHELPSTRING,FXColorWheel::onCmdGetHelp), FXMAPFUNC(SEL_COMMAND,FXColorWheel::ID_SETTIPSTRING,FXColorWheel::onCmdSetTip), FXMAPFUNC(SEL_COMMAND,FXColorWheel::ID_GETTIPSTRING,FXColorWheel::onCmdGetTip), }; // Object implementation FXIMPLEMENT(FXColorWheel,FXFrame,FXColorWheelMap,ARRAYNUMBER(FXColorWheelMap)) // Make a color wheel FXColorWheel::FXColorWheel(){ flags|=FLAG_ENABLED; hsv[0]=0.0f; hsv[1]=0.0f; hsv[2]=1.0f; dialx=0; dialy=0; spotx=0; spoty=0; } // Make a color wheel FXColorWheel::FXColorWheel(FXComposite* p,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb):FXFrame(p,opts,x,y,w,h,pl,pr,pt,pb){ flags|=FLAG_ENABLED; target=tgt; message=sel; dial=new FXImage(getApp(),nullptr,IMAGE_DITHER|IMAGE_KEEP|IMAGE_OWNED|IMAGE_SHMI|IMAGE_SHMP,WHEELDIAMETER,WHEELDIAMETER); hsv[0]=0.0f; hsv[1]=0.0f; hsv[2]=1.0f; dialx=0; dialy=0; spotx=WHEELDIAMETER/2; spoty=WHEELDIAMETER/2; } // Create window void FXColorWheel::create(){ FXFrame::create(); updatedial(); dial->create(); } // Detach window void FXColorWheel::detach(){ FXFrame::detach(); dial->detach(); } // Get default width FXint FXColorWheel::getDefaultWidth(){ return WHEELDIAMETER+padleft+padright+(border<<1); } // Get default height FXint FXColorWheel::getDefaultHeight(){ return WHEELDIAMETER+padtop+padbottom+(border<<1); } // Resize the dial void FXColorWheel::layout(){ FXint ww=width-padleft-padright-(border<<1); FXint hh=height-padtop-padbottom-(border<<1); FXint ss=FXMAX(3,FXMIN(ww,hh)); // New dial location in widget if(options&JUSTIFY_LEFT) dialx=padleft+border; else if(options&JUSTIFY_RIGHT) dialx=width-padright-border-ss; else dialx=border+padleft+(ww-ss)/2; if(options&JUSTIFY_TOP) dialy=padtop+border; else if(options&JUSTIFY_BOTTOM) dialy=height-padbottom-border-ss; else dialy=border+padtop+(hh-ss)/2; // Do work if size changed or marked dirty if((dial->getWidth()!=ss) || (flags&FLAG_DIRTY)){ if(dial->getWidth()!=ss) dial->resize(ss,ss); updatedial(); dial->render(); } // Update spot position hstoxy(spotx,spoty,hsv[0],hsv[1]); flags&=~FLAG_DIRTY; } // Compute x,y location from hue and saturation FXbool FXColorWheel::hstoxy(FXint& x,FXint& y,FXfloat h,FXfloat s) const { FXfloat r=dial->getWidth()*0.5f; FXfloat a=(h-180.0f)*dtor; x=(FXint)(s*r*Math::cos(a)+r+0.5f); y=(FXint)(s*r*Math::sin(a)+r+0.5f); return true; } // Compute hue and saturation from x,y, return false if outside of dial FXbool FXColorWheel::xytohs(FXfloat& h,FXfloat& s,FXint x,FXint y) const { FXfloat r=dial->getWidth()*0.5f; FXfloat rx=x-r; FXfloat ry=y-r; FXfloat v=Math::sqrt(rx*rx+ry*ry); h=0.0f; s=0.0f; if(0.0fgetHeight(); y++){ for(FXint x=0; xgetWidth(); x++){ if(xytohs(h,s,x,y)){ fxhsv_to_rgb(r,g,b,h,s,hsv[2]); dial->setPixel(x,y,FXRGB(255.0f*r,255.0f*g,255.0f*b)); } else{ dial->setPixel(x,y,backColor); } } } } // Move the spot void FXColorWheel::movespot(FXint x,FXint y){ if(spotx!=x || spoty!=y){ update(dialx+spotx-4,dialy+spoty-4,9,9); xytohs(hsv[0],hsv[1],x,y); hstoxy(spotx,spoty,hsv[0],hsv[1]); update(dialx+spotx-4,dialy+spoty-4,9,9); } } // Set help using a message long FXColorWheel::onCmdSetHelp(FXObject*,FXSelector,void* ptr){ setHelpText(*((FXString*)ptr)); return 1; } // Get help using a message long FXColorWheel::onCmdGetHelp(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getHelpText(); return 1; } // Set tip using a message long FXColorWheel::onCmdSetTip(FXObject*,FXSelector,void* ptr){ setTipText(*((FXString*)ptr)); return 1; } // Get tip using a message long FXColorWheel::onCmdGetTip(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getTipText(); return 1; } // We were asked about tip text long FXColorWheel::onQueryTip(FXObject* sender,FXSelector sel,void* ptr){ if(FXFrame::onQueryTip(sender,sel,ptr)) return 1; if((flags&FLAG_TIP) && !tip.empty()){ sender->handle(this,FXSEL(SEL_COMMAND,ID_SETSTRINGVALUE),(void*)&tip); return 1; } return 0; } // We were asked about status text long FXColorWheel::onQueryHelp(FXObject* sender,FXSelector sel,void* ptr){ if(FXFrame::onQueryHelp(sender,sel,ptr)) return 1; if((flags&FLAG_HELP) && !help.empty()){ sender->handle(this,FXSEL(SEL_COMMAND,ID_SETSTRINGVALUE),(void*)&help); return 1; } return 0; } // Handle repaint long FXColorWheel::onPaint(FXObject*,FXSelector,void* ptr){ FXEvent *event=(FXEvent*)ptr; FXDCWindow dc(this,event); FXint d=dial->getWidth(); dc.setForeground(backColor); dc.fillRectangle(border,border,dialx-border,height-(border<<1)); dc.fillRectangle(dialx+dial->getWidth(),border,width-border-dialx-dial->getWidth(),height-(border<<1)); dc.fillRectangle(dialx,border,dial->getWidth(),dialy-border); dc.fillRectangle(dialx,dialy+dial->getHeight(),dial->getWidth(),height-border-dialy-dial->getHeight()); dc.drawImage(dial,dialx,dialy); dc.setForeground(borderColor); dc.drawArc(dialx+1,dialy,d,d,90*64,45*64); dc.drawArc(dialx,dialy+1,d,d,135*64,45*64); dc.setForeground(baseColor); dc.drawArc(dialx-1,dialy,d,d,270*64,45*64); dc.drawArc(dialx,dialy-1,d,d,315*64,45*64); dc.setForeground(shadowColor); dc.drawArc(dialx,dialy,d,d,45*64,180*64); dc.setForeground(hiliteColor); dc.drawArc(dialx,dialy,d,d,225*64,180*64); dc.setForeground(FXRGB(255,255,255)); dc.fillArc(dialx+spotx-3,dialy+spoty-3,7,7,0,360*64); dc.setForeground(FXRGB(0,0,0)); dc.fillArc(dialx+spotx-2,dialy+spoty-2,5,5,0,360*64); drawFrame(dc,0,0,width,height); return 1; } // Moving long FXColorWheel::onMotion(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; flags&=~FLAG_TIP; if(flags&FLAG_PRESSED){ movespot(event->win_x-dialx,event->win_y-dialy); flags|=FLAG_CHANGED; if(target) target->tryHandle(this,FXSEL(SEL_CHANGED,message),(void*)hsv); return 1; } return 0; } // Move spot to change hue, saturation long FXColorWheel::onLeftBtnPress(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; flags&=~FLAG_TIP; if(isEnabled()){ grab(); if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONPRESS,message),ptr)) return 1; movespot(event->win_x-dialx,event->win_y-dialy); flags|=FLAG_CHANGED; flags&=~FLAG_UPDATE; flags|=FLAG_PRESSED; if(target) target->tryHandle(this,FXSEL(SEL_CHANGED,message),(void*)hsv); } return 1; } // End spot movement mode long FXColorWheel::onLeftBtnRelease(FXObject*,FXSelector,void* ptr){ FXuint changed=(flags&FLAG_CHANGED); if(isEnabled()){ ungrab(); flags|=FLAG_UPDATE; flags&=~FLAG_PRESSED; flags&=~FLAG_CHANGED; if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONRELEASE,message),ptr)) return 1; if(changed && target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)hsv); return 1; } return 1; } // Rotate hue by means of dial long FXColorWheel::onMouseWheel(FXObject*,FXSelector,void* ptr){ FXfloat amount=((FXEvent*)ptr)->code/12.0f; if(isEnabled()){ if(((FXEvent*)ptr)->state&CONTROLMASK) amount*=0.1f; setHue(Math::fmod(hsv[0]+amount+360.0f,360.0f)); if(target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)hsv); return 1; } return 0; } // Change hue void FXColorWheel::setHue(FXfloat h){ h=Math::fclamp(0.0f,h,360.0f); if(h!=hsv[0]){ hsv[0]=h; update(dialx+spotx-4,dialy+spoty-4,9,9); hstoxy(spotx,spoty,hsv[0],hsv[1]); update(dialx+spotx-4,dialy+spoty-4,9,9); } } // Change saturation void FXColorWheel::setSat(FXfloat s){ s=Math::fclamp(0.0f,s,1.0f); if(s!=hsv[1]){ hsv[1]=s; update(dialx+spotx-4,dialy+spoty-4,9,9); hstoxy(spotx,spoty,hsv[0],hsv[1]); update(dialx+spotx-4,dialy+spoty-4,9,9); } } // Change saturation void FXColorWheel::setVal(FXfloat v){ v=Math::fclamp(0.0f,v,1.0f); if(v!=hsv[2]){ hsv[2]=v; recalc(); } } // Set hue, saturation, value void FXColorWheel::setHueSatVal(FXfloat h,FXfloat s,FXfloat v){ // Clamp h=Math::fclamp(0.0f,h,360.0f); s=Math::fclamp(0.0f,s,1.0f); v=Math::fclamp(0.0f,v,1.0f); // Changed after clamping? if(hsv[0]!=h || hsv[1]!=s || hsv[2]!=v){ // Cheap case: just move the ball if(hsv[0]!=h || hsv[1]!=s){ hsv[0]=h; hsv[1]=s; update(dialx+spotx-4,dialy+spoty-4,9,9); hstoxy(spotx,spoty,hsv[0],hsv[1]); update(dialx+spotx-4,dialy+spoty-4,9,9); } // Expensive case: recalculate dial if(hsv[2]!=v){ hsv[2]=v; recalc(); } } } // Set text justify style void FXColorWheel::setJustify(FXuint style){ FXuint opts=(options&~JUSTIFY_MASK) | (style&JUSTIFY_MASK); if(options!=opts){ options=opts; recalc(); } } // Get text justify style FXuint FXColorWheel::getJustify() const { return (options&JUSTIFY_MASK); } // Save data void FXColorWheel::save(FXStream& store) const { FXFrame::save(store); store << dial; store << hsv[0]; store << hsv[1]; store << hsv[2]; store << tip; store << help; } // Load data void FXColorWheel::load(FXStream& store){ FXFrame::load(store); store >> dial; store >> hsv[0]; store >> hsv[1]; store >> hsv[2]; store >> tip; store >> help; } // Destroy FXColorWheel::~FXColorWheel(){ delete dial; dial=(FXImage*)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXColors.cpp000066400000000000000000000771251455751074500220230ustar00rootroot00000000000000/******************************************************************************** * * * C o l o r N a m e F u n c t i o n s * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "fxascii.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXString.h" #include "FXColors.h" /* Notes: - Color constants inside FXColors namespace so as to avoid potential name clashes in application code. - Added color name to FXString and vice versa. Is more convenient. - API of nameFromColor() is not safe; would prefer to pass size parameter. - The old color named "None" was renamed to "Clear". X11 defines a preprocessor constant called None and namespaces can't protect against #defines [one more reason we like C++]. - At some point, we would like faster color -> name mapping [name -> color is OK, its a binary search]. */ #define MAXCOLORNAME 24 using namespace FX; /*******************************************************************************/ namespace FX { // Names of commonly used colors const FXchar *const colorName[683]={ "AliceBlue", "AntiqueWhite", "AntiqueWhite1", "AntiqueWhite2", "AntiqueWhite3", "AntiqueWhite4", "Aqua", "Aquamarine", "Aquamarine1", "Aquamarine2", "Aquamarine3", "Aquamarine4", "Azure", "Azure1", "Azure2", "Azure3", "Azure4", "Banana", "Beige", "Bisque", "Bisque1", "Bisque2", "Bisque3", "Bisque4", "Black", "BlanchedAlmond", "Blue", "Blue1", "Blue2", "Blue3", "Blue4", "BlueViolet", "Brick", "Brown", "Brown1", "Brown2", "Brown3", "Brown4", "Burlywood", "Burlywood1", "Burlywood2", "Burlywood3", "Burlywood4", "BurnedSienna", "BurnedUmber", "CadetBlue", "CadetBlue1", "CadetBlue2", "CadetBlue3", "CadetBlue4", "CadmiumOrange", "CadmiumRed", "CadmiumYellow", "Carrot", "Chartreuse", "Chartreuse1", "Chartreuse2", "Chartreuse3", "Chartreuse4", "Chocolate", "Chocolate1", "Chocolate2", "Chocolate3", "Chocolate4", "Cobalt", "CobaltGreen", "ColdGrey", "Coral", "Coral1", "Coral2", "Coral3", "Coral4", "CornflowerBlue", "Cornsilk", "Cornsilk1", "Cornsilk2", "Cornsilk3", "Cornsilk4", "Crimson", "Cyan", "Cyan1", "Cyan2", "Cyan3", "Cyan4", "DarkBlue", "DarkCyan", "DarkGoldenrod", "DarkGoldenrod1", "DarkGoldenrod2", "DarkGoldenrod3", "DarkGoldenrod4", "DarkGray", "DarkGreen", "DarkGrey", "DarkKhaki", "DarkMagenta", "DarkOliveGreen", "DarkOliveGreen1", "DarkOliveGreen2", "DarkOliveGreen3", "DarkOliveGreen4", "DarkOrange", "DarkOrange1", "DarkOrange2", "DarkOrange3", "DarkOrange4", "DarkOrchid", "DarkOrchid1", "DarkOrchid2", "DarkOrchid3", "DarkOrchid4", "DarkRed", "DarkSalmon", "DarkSeaGreen", "DarkSeaGreen1", "DarkSeaGreen2", "DarkSeaGreen3", "DarkSeaGreen4", "DarkSlateBlue", "DarkSlateGray", "DarkSlateGray1", "DarkSlateGray2", "DarkSlateGray3", "DarkSlateGray4", "DarkSlateGrey", "DarkTurquoise", "DarkViolet", "DeepPink", "DeepPink1", "DeepPink2", "DeepPink3", "DeepPink4", "DeepSkyBlue", "DeepSkyBlue1", "DeepSkyBlue2", "DeepSkyBlue3", "DeepSkyBlue4", "DimGray", "DimGrey", "DodgerBlue", "DodgerBlue1", "DodgerBlue2", "DodgerBlue3", "DodgerBlue4", "Eggshell", "EmeraldGreen", "Firebrick", "Firebrick1", "Firebrick2", "Firebrick3", "Firebrick4", "FloralWhite", "ForestGreen", "Fuchsia", "Gainsboro", "GhostWhite", "Gold", "Gold1", "Gold2", "Gold3", "Gold4", "Goldenrod", "Goldenrod1", "Goldenrod2", "Goldenrod3", "Goldenrod4", "Gray", "Gray0", "Gray1", "Gray10", "Gray100", "Gray11", "Gray12", "Gray13", "Gray14", "Gray15", "Gray16", "Gray17", "Gray18", "Gray19", "Gray2", "Gray20", "Gray21", "Gray22", "Gray23", "Gray24", "Gray25", "Gray26", "Gray27", "Gray28", "Gray29", "Gray3", "Gray30", "Gray31", "Gray32", "Gray33", "Gray34", "Gray35", "Gray36", "Gray37", "Gray38", "Gray39", "Gray4", "Gray40", "Gray41", "Gray42", "Gray43", "Gray44", "Gray45", "Gray46", "Gray47", "Gray48", "Gray49", "Gray5", "Gray50", "Gray51", "Gray52", "Gray53", "Gray54", "Gray55", "Gray56", "Gray57", "Gray58", "Gray59", "Gray6", "Gray60", "Gray61", "Gray62", "Gray63", "Gray64", "Gray65", "Gray66", "Gray67", "Gray68", "Gray69", "Gray7", "Gray70", "Gray71", "Gray72", "Gray73", "Gray74", "Gray75", "Gray76", "Gray77", "Gray78", "Gray79", "Gray8", "Gray80", "Gray81", "Gray82", "Gray83", "Gray84", "Gray85", "Gray86", "Gray87", "Gray88", "Gray89", "Gray9", "Gray90", "Gray91", "Gray92", "Gray93", "Gray94", "Gray95", "Gray96", "Gray97", "Gray98", "Gray99", "Green", "Green1", "Green2", "Green3", "Green4", "GreenYellow", "Grey", "Grey0", "Grey1", "Grey10", "Grey100", "Grey11", "Grey12", "Grey13", "Grey14", "Grey15", "Grey16", "Grey17", "Grey18", "Grey19", "Grey2", "Grey20", "Grey21", "Grey22", "Grey23", "Grey24", "Grey25", "Grey26", "Grey27", "Grey28", "Grey29", "Grey3", "Grey30", "Grey31", "Grey32", "Grey33", "Grey34", "Grey35", "Grey36", "Grey37", "Grey38", "Grey39", "Grey4", "Grey40", "Grey41", "Grey42", "Grey43", "Grey44", "Grey45", "Grey46", "Grey47", "Grey48", "Grey49", "Grey5", "Grey50", "Grey51", "Grey52", "Grey53", "Grey54", "Grey55", "Grey56", "Grey57", "Grey58", "Grey59", "Grey6", "Grey60", "Grey61", "Grey62", "Grey63", "Grey64", "Grey65", "Grey66", "Grey67", "Grey68", "Grey69", "Grey7", "Grey70", "Grey71", "Grey72", "Grey73", "Grey74", "Grey75", "Grey76", "Grey77", "Grey78", "Grey79", "Grey8", "Grey80", "Grey81", "Grey82", "Grey83", "Grey84", "Grey85", "Grey86", "Grey87", "Grey88", "Grey89", "Grey9", "Grey90", "Grey91", "Grey92", "Grey93", "Grey94", "Grey95", "Grey96", "Grey97", "Grey98", "Grey99", "Honeydew", "Honeydew1", "Honeydew2", "Honeydew3", "Honeydew4", "HotPink", "HotPink1", "HotPink2", "HotPink3", "HotPink4", "IndianRed", "IndianRed1", "IndianRed2", "IndianRed3", "IndianRed4", "Indigo", "Ivory", "Ivory1", "Ivory2", "Ivory3", "Ivory4", "Khaki", "Khaki1", "Khaki2", "Khaki3", "Khaki4", "Lavender", "LavenderBlush", "LavenderBlush1", "LavenderBlush2", "LavenderBlush3", "LavenderBlush4", "LawnGreen", "LemonChiffon", "LemonChiffon1", "LemonChiffon2", "LemonChiffon3", "LemonChiffon4", "LightBlue", "LightBlue1", "LightBlue2", "LightBlue3", "LightBlue4", "LightCoral", "LightCyan", "LightCyan1", "LightCyan2", "LightCyan3", "LightCyan4", "LightGoldenrod", "LightGoldenrod1", "LightGoldenrod2", "LightGoldenrod3", "LightGoldenrod4", "LightGoldenrodYellow", "LightGray", "LightGreen", "LightGrey", "LightPink", "LightPink1", "LightPink2", "LightPink3", "LightPink4", "LightSalmon", "LightSalmon1", "LightSalmon2", "LightSalmon3", "LightSalmon4", "LightSeaGreen", "LightSkyBlue", "LightSkyBlue1", "LightSkyBlue2", "LightSkyBlue3", "LightSkyBlue4", "LightSlateBlue", "LightSlateGray", "LightSlateGrey", "LightSteelBlue", "LightSteelBlue1", "LightSteelBlue2", "LightSteelBlue3", "LightSteelBlue4", "LightYellow", "LightYellow1", "LightYellow2", "LightYellow3", "LightYellow4", "Lime", "LimeGreen", "Linen", "Magenta", "Magenta1", "Magenta2", "Magenta3", "Magenta4", "Maroon", "Maroon1", "Maroon2", "Maroon3", "Maroon4", "MediumAquamarine", "MediumBlue", "MediumOrchid", "MediumOrchid1", "MediumOrchid2", "MediumOrchid3", "MediumOrchid4", "MediumPurple", "MediumPurple1", "MediumPurple2", "MediumPurple3", "MediumPurple4", "MediumSeaGreen", "MediumSlateBlue", "MediumSpringGreen", "MediumTurquoise", "MediumVioletRed", "MidnightBlue", "MintCream", "MistyRose", "MistyRose1", "MistyRose2", "MistyRose3", "MistyRose4", "Moccasin", "NavajoWhite", "NavajoWhite1", "NavajoWhite2", "NavajoWhite3", "NavajoWhite4", "Navy", "NavyBlue", "None", "OldLace", "Olive", "OliveDrab", "OliveDrab1", "OliveDrab2", "OliveDrab3", "OliveDrab4", "Orange", "Orange1", "Orange2", "Orange3", "Orange4", "OrangeRed", "OrangeRed1", "OrangeRed2", "OrangeRed3", "OrangeRed4", "Orchid", "Orchid1", "Orchid2", "Orchid3", "Orchid4", "PaleGoldenrod", "PaleGreen", "PaleGreen1", "PaleGreen2", "PaleGreen3", "PaleGreen4", "PaleTurquoise", "PaleTurquoise1", "PaleTurquoise2", "PaleTurquoise3", "PaleTurquoise4", "PaleVioletRed", "PaleVioletRed1", "PaleVioletRed2", "PaleVioletRed3", "PaleVioletRed4", "PapayaWhip", "PeachPuff", "PeachPuff1", "PeachPuff2", "PeachPuff3", "PeachPuff4", "Peru", "Pink", "Pink1", "Pink2", "Pink3", "Pink4", "Plum", "Plum1", "Plum2", "Plum3", "Plum4", "PowderBlue", "Purple", "Purple1", "Purple2", "Purple3", "Purple4", "Raspberry", "Red", "Red1", "Red2", "Red3", "Red4", "RosyBrown", "RosyBrown1", "RosyBrown2", "RosyBrown3", "RosyBrown4", "RoyalBlue", "RoyalBlue1", "RoyalBlue2", "RoyalBlue3", "RoyalBlue4", "SaddleBrown", "Salmon", "Salmon1", "Salmon2", "Salmon3", "Salmon4", "SandyBrown", "SeaGreen", "SeaGreen1", "SeaGreen2", "SeaGreen3", "SeaGreen4", "Seashell", "Seashell1", "Seashell2", "Seashell3", "Seashell4", "Sepia", "Sienna", "Sienna1", "Sienna2", "Sienna3", "Sienna4", "Silver", "SkyBlue", "SkyBlue1", "SkyBlue2", "SkyBlue3", "SkyBlue4", "SlateBlue", "SlateBlue1", "SlateBlue2", "SlateBlue3", "SlateBlue4", "SlateGray", "SlateGray1", "SlateGray2", "SlateGray3", "SlateGray4", "SlateGrey", "Snow", "Snow1", "Snow2", "Snow3", "Snow4", "SpringGreen", "SpringGreen1", "SpringGreen2", "SpringGreen3", "SpringGreen4", "SteelBlue", "SteelBlue1", "SteelBlue2", "SteelBlue3", "SteelBlue4", "Tan", "Tan1", "Tan2", "Tan3", "Tan4", "Teal", "Thistle", "Thistle1", "Thistle2", "Thistle3", "Thistle4", "Tomato", "Tomato1", "Tomato2", "Tomato3", "Tomato4", "Turquoise", "Turquoise1", "Turquoise2", "Turquoise3", "Turquoise4", "Ultramarine", "Violet", "VioletRed", "VioletRed1", "VioletRed2", "VioletRed3", "VioletRed4", "WarmGrey", "Wheat", "Wheat1", "Wheat2", "Wheat3", "Wheat4", "White", "WhiteSmoke", "Yellow", "Yellow1", "Yellow2", "Yellow3", "Yellow4", "YellowGreen", }; // Values of corresponding colors const FXColor colorValue[683]={ FXColors::AliceBlue, FXColors::AntiqueWhite, FXColors::AntiqueWhite1, FXColors::AntiqueWhite2, FXColors::AntiqueWhite3, FXColors::AntiqueWhite4, FXColors::Aqua, FXColors::Aquamarine, FXColors::Aquamarine1, FXColors::Aquamarine2, FXColors::Aquamarine3, FXColors::Aquamarine4, FXColors::Azure, FXColors::Azure1, FXColors::Azure2, FXColors::Azure3, FXColors::Azure4, FXColors::Banana, FXColors::Beige, FXColors::Bisque, FXColors::Bisque1, FXColors::Bisque2, FXColors::Bisque3, FXColors::Bisque4, FXColors::Black, FXColors::BlanchedAlmond, FXColors::Blue, FXColors::Blue1, FXColors::Blue2, FXColors::Blue3, FXColors::Blue4, FXColors::BlueViolet, FXColors::Brick, FXColors::Brown, FXColors::Brown1, FXColors::Brown2, FXColors::Brown3, FXColors::Brown4, FXColors::Burlywood, FXColors::Burlywood1, FXColors::Burlywood2, FXColors::Burlywood3, FXColors::Burlywood4, FXColors::BurnedSienna, FXColors::BurnedUmber, FXColors::CadetBlue, FXColors::CadetBlue1, FXColors::CadetBlue2, FXColors::CadetBlue3, FXColors::CadetBlue4, FXColors::CadmiumOrange, FXColors::CadmiumRed, FXColors::CadmiumYellow, FXColors::Carrot, FXColors::Chartreuse, FXColors::Chartreuse1, FXColors::Chartreuse2, FXColors::Chartreuse3, FXColors::Chartreuse4, FXColors::Chocolate, FXColors::Chocolate1, FXColors::Chocolate2, FXColors::Chocolate3, FXColors::Chocolate4, FXColors::Cobalt, FXColors::CobaltGreen, FXColors::ColdGray, FXColors::Coral, FXColors::Coral1, FXColors::Coral2, FXColors::Coral3, FXColors::Coral4, FXColors::CornflowerBlue, FXColors::Cornsilk, FXColors::Cornsilk1, FXColors::Cornsilk2, FXColors::Cornsilk3, FXColors::Cornsilk4, FXColors::Crimson, FXColors::Cyan, FXColors::Cyan1, FXColors::Cyan2, FXColors::Cyan3, FXColors::Cyan4, FXColors::DarkBlue, FXColors::DarkCyan, FXColors::DarkGoldenrod, FXColors::DarkGoldenrod1, FXColors::DarkGoldenrod2, FXColors::DarkGoldenrod3, FXColors::DarkGoldenrod4, FXColors::DarkGray, FXColors::DarkGreen, FXColors::DarkGray, FXColors::DarkKhaki, FXColors::DarkMagenta, FXColors::DarkOliveGreen, FXColors::DarkOliveGreen1, FXColors::DarkOliveGreen2, FXColors::DarkOliveGreen3, FXColors::DarkOliveGreen4, FXColors::DarkOrange, FXColors::DarkOrange1, FXColors::DarkOrange2, FXColors::DarkOrange3, FXColors::DarkOrange4, FXColors::DarkOrchid, FXColors::DarkOrchid1, FXColors::DarkOrchid2, FXColors::DarkOrchid3, FXColors::DarkOrchid4, FXColors::DarkRed, FXColors::DarkSalmon, FXColors::DarkSeaGreen, FXColors::DarkSeaGreen1, FXColors::DarkSeaGreen2, FXColors::DarkSeaGreen3, FXColors::DarkSeaGreen4, FXColors::DarkSlateBlue, FXColors::DarkSlateGray, FXColors::DarkSlateGray1, FXColors::DarkSlateGray2, FXColors::DarkSlateGray3, FXColors::DarkSlateGray4, FXColors::DarkSlateGray, FXColors::DarkTurquoise, FXColors::DarkViolet, FXColors::DeepPink, FXColors::DeepPink1, FXColors::DeepPink2, FXColors::DeepPink3, FXColors::DeepPink4, FXColors::DeepSkyBlue, FXColors::DeepSkyBlue1, FXColors::DeepSkyBlue2, FXColors::DeepSkyBlue3, FXColors::DeepSkyBlue4, FXColors::DimGray, FXColors::DimGray, FXColors::DodgerBlue, FXColors::DodgerBlue1, FXColors::DodgerBlue2, FXColors::DodgerBlue3, FXColors::DodgerBlue4, FXColors::Eggshell, FXColors::EmeraldGreen, FXColors::Firebrick, FXColors::Firebrick1, FXColors::Firebrick2, FXColors::Firebrick3, FXColors::Firebrick4, FXColors::FloralWhite, FXColors::ForestGreen, FXColors::Fuchsia, FXColors::Gainsboro, FXColors::GhostWhite, FXColors::Gold, FXColors::Gold1, FXColors::Gold2, FXColors::Gold3, FXColors::Gold4, FXColors::Goldenrod, FXColors::Goldenrod1, FXColors::Goldenrod2, FXColors::Goldenrod3, FXColors::Goldenrod4, FXColors::Gray, FXColors::Gray0, FXColors::Gray1, FXColors::Gray10, FXColors::Gray100, FXColors::Gray11, FXColors::Gray12, FXColors::Gray13, FXColors::Gray14, FXColors::Gray15, FXColors::Gray16, FXColors::Gray17, FXColors::Gray18, FXColors::Gray19, FXColors::Gray2, FXColors::Gray20, FXColors::Gray21, FXColors::Gray22, FXColors::Gray23, FXColors::Gray24, FXColors::Gray25, FXColors::Gray26, FXColors::Gray27, FXColors::Gray28, FXColors::Gray29, FXColors::Gray3, FXColors::Gray30, FXColors::Gray31, FXColors::Gray32, FXColors::Gray33, FXColors::Gray34, FXColors::Gray35, FXColors::Gray36, FXColors::Gray37, FXColors::Gray38, FXColors::Gray39, FXColors::Gray4, FXColors::Gray40, FXColors::Gray41, FXColors::Gray42, FXColors::Gray43, FXColors::Gray44, FXColors::Gray45, FXColors::Gray46, FXColors::Gray47, FXColors::Gray48, FXColors::Gray49, FXColors::Gray5, FXColors::Gray50, FXColors::Gray51, FXColors::Gray52, FXColors::Gray53, FXColors::Gray54, FXColors::Gray55, FXColors::Gray56, FXColors::Gray57, FXColors::Gray58, FXColors::Gray59, FXColors::Gray6, FXColors::Gray60, FXColors::Gray61, FXColors::Gray62, FXColors::Gray63, FXColors::Gray64, FXColors::Gray65, FXColors::Gray66, FXColors::Gray67, FXColors::Gray68, FXColors::Gray69, FXColors::Gray7, FXColors::Gray70, FXColors::Gray71, FXColors::Gray72, FXColors::Gray73, FXColors::Gray74, FXColors::Gray75, FXColors::Gray76, FXColors::Gray77, FXColors::Gray78, FXColors::Gray79, FXColors::Gray8, FXColors::Gray80, FXColors::Gray81, FXColors::Gray82, FXColors::Gray83, FXColors::Gray84, FXColors::Gray85, FXColors::Gray86, FXColors::Gray87, FXColors::Gray88, FXColors::Gray89, FXColors::Gray9, FXColors::Gray90, FXColors::Gray91, FXColors::Gray92, FXColors::Gray93, FXColors::Gray94, FXColors::Gray95, FXColors::Gray96, FXColors::Gray97, FXColors::Gray98, FXColors::Gray99, FXColors::Green, FXColors::Green1, FXColors::Green2, FXColors::Green3, FXColors::Green4, FXColors::GreenYellow, FXColors::Gray, FXColors::Gray0, FXColors::Gray1, FXColors::Gray10, FXColors::Gray100, FXColors::Gray11, FXColors::Gray12, FXColors::Gray13, FXColors::Gray14, FXColors::Gray15, FXColors::Gray16, FXColors::Gray17, FXColors::Gray18, FXColors::Gray19, FXColors::Gray2, FXColors::Gray20, FXColors::Gray21, FXColors::Gray22, FXColors::Gray23, FXColors::Gray24, FXColors::Gray25, FXColors::Gray26, FXColors::Gray27, FXColors::Gray28, FXColors::Gray29, FXColors::Gray3, FXColors::Gray30, FXColors::Gray31, FXColors::Gray32, FXColors::Gray33, FXColors::Gray34, FXColors::Gray35, FXColors::Gray36, FXColors::Gray37, FXColors::Gray38, FXColors::Gray39, FXColors::Gray4, FXColors::Gray40, FXColors::Gray41, FXColors::Gray42, FXColors::Gray43, FXColors::Gray44, FXColors::Gray45, FXColors::Gray46, FXColors::Gray47, FXColors::Gray48, FXColors::Gray49, FXColors::Gray5, FXColors::Gray50, FXColors::Gray51, FXColors::Gray52, FXColors::Gray53, FXColors::Gray54, FXColors::Gray55, FXColors::Gray56, FXColors::Gray57, FXColors::Gray58, FXColors::Gray59, FXColors::Gray6, FXColors::Gray60, FXColors::Gray61, FXColors::Gray62, FXColors::Gray63, FXColors::Gray64, FXColors::Gray65, FXColors::Gray66, FXColors::Gray67, FXColors::Gray68, FXColors::Gray69, FXColors::Gray7, FXColors::Gray70, FXColors::Gray71, FXColors::Gray72, FXColors::Gray73, FXColors::Gray74, FXColors::Gray75, FXColors::Gray76, FXColors::Gray77, FXColors::Gray78, FXColors::Gray79, FXColors::Gray8, FXColors::Gray80, FXColors::Gray81, FXColors::Gray82, FXColors::Gray83, FXColors::Gray84, FXColors::Gray85, FXColors::Gray86, FXColors::Gray87, FXColors::Gray88, FXColors::Gray89, FXColors::Gray9, FXColors::Gray90, FXColors::Gray91, FXColors::Gray92, FXColors::Gray93, FXColors::Gray94, FXColors::Gray95, FXColors::Gray96, FXColors::Gray97, FXColors::Gray98, FXColors::Gray99, FXColors::Honeydew, FXColors::Honeydew1, FXColors::Honeydew2, FXColors::Honeydew3, FXColors::Honeydew4, FXColors::HotPink, FXColors::HotPink1, FXColors::HotPink2, FXColors::HotPink3, FXColors::HotPink4, FXColors::IndianRed, FXColors::IndianRed1, FXColors::IndianRed2, FXColors::IndianRed3, FXColors::IndianRed4, FXColors::Indigo, FXColors::Ivory, FXColors::Ivory1, FXColors::Ivory2, FXColors::Ivory3, FXColors::Ivory4, FXColors::Khaki, FXColors::Khaki1, FXColors::Khaki2, FXColors::Khaki3, FXColors::Khaki4, FXColors::Lavender, FXColors::LavenderBlush, FXColors::LavenderBlush1, FXColors::LavenderBlush2, FXColors::LavenderBlush3, FXColors::LavenderBlush4, FXColors::LawnGreen, FXColors::LemonChiffon, FXColors::LemonChiffon1, FXColors::LemonChiffon2, FXColors::LemonChiffon3, FXColors::LemonChiffon4, FXColors::LightBlue, FXColors::LightBlue1, FXColors::LightBlue2, FXColors::LightBlue3, FXColors::LightBlue4, FXColors::LightCoral, FXColors::LightCyan, FXColors::LightCyan1, FXColors::LightCyan2, FXColors::LightCyan3, FXColors::LightCyan4, FXColors::LightGoldenrod, FXColors::LightGoldenrod1, FXColors::LightGoldenrod2, FXColors::LightGoldenrod3, FXColors::LightGoldenrod4, FXColors::LightGoldenrodYellow, FXColors::LightGray, FXColors::LightGreen, FXColors::LightGray, FXColors::LightPink, FXColors::LightPink1, FXColors::LightPink2, FXColors::LightPink3, FXColors::LightPink4, FXColors::LightSalmon, FXColors::LightSalmon1, FXColors::LightSalmon2, FXColors::LightSalmon3, FXColors::LightSalmon4, FXColors::LightSeaGreen, FXColors::LightSkyBlue, FXColors::LightSkyBlue1, FXColors::LightSkyBlue2, FXColors::LightSkyBlue3, FXColors::LightSkyBlue4, FXColors::LightSlateBlue, FXColors::LightSlateGray, FXColors::LightSlateGray, FXColors::LightSteelBlue, FXColors::LightSteelBlue1, FXColors::LightSteelBlue2, FXColors::LightSteelBlue3, FXColors::LightSteelBlue4, FXColors::LightYellow, FXColors::LightYellow1, FXColors::LightYellow2, FXColors::LightYellow3, FXColors::LightYellow4, FXColors::Lime, FXColors::LimeGreen, FXColors::Linen, FXColors::Magenta, FXColors::Magenta1, FXColors::Magenta2, FXColors::Magenta3, FXColors::Magenta4, FXColors::Maroon, FXColors::Maroon1, FXColors::Maroon2, FXColors::Maroon3, FXColors::Maroon4, FXColors::MediumAquamarine, FXColors::MediumBlue, FXColors::MediumOrchid, FXColors::MediumOrchid1, FXColors::MediumOrchid2, FXColors::MediumOrchid3, FXColors::MediumOrchid4, FXColors::MediumPurple, FXColors::MediumPurple1, FXColors::MediumPurple2, FXColors::MediumPurple3, FXColors::MediumPurple4, FXColors::MediumSeaGreen, FXColors::MediumSlateBlue, FXColors::MediumSpringGreen, FXColors::MediumTurquoise, FXColors::MediumVioletRed, FXColors::MidnightBlue, FXColors::MintCream, FXColors::MistyRose, FXColors::MistyRose1, FXColors::MistyRose2, FXColors::MistyRose3, FXColors::MistyRose4, FXColors::Moccasin, FXColors::NavajoWhite, FXColors::NavajoWhite1, FXColors::NavajoWhite2, FXColors::NavajoWhite3, FXColors::NavajoWhite4, FXColors::Navy, FXColors::NavyBlue, FXColors::Clear, FXColors::OldLace, FXColors::Olive, FXColors::OliveDrab, FXColors::OliveDrab1, FXColors::OliveDrab2, FXColors::OliveDrab3, FXColors::OliveDrab4, FXColors::Orange, FXColors::Orange1, FXColors::Orange2, FXColors::Orange3, FXColors::Orange4, FXColors::OrangeRed, FXColors::OrangeRed1, FXColors::OrangeRed2, FXColors::OrangeRed3, FXColors::OrangeRed4, FXColors::Orchid, FXColors::Orchid1, FXColors::Orchid2, FXColors::Orchid3, FXColors::Orchid4, FXColors::PaleGoldenrod, FXColors::PaleGreen, FXColors::PaleGreen1, FXColors::PaleGreen2, FXColors::PaleGreen3, FXColors::PaleGreen4, FXColors::PaleTurquoise, FXColors::PaleTurquoise1, FXColors::PaleTurquoise2, FXColors::PaleTurquoise3, FXColors::PaleTurquoise4, FXColors::PaleVioletRed, FXColors::PaleVioletRed1, FXColors::PaleVioletRed2, FXColors::PaleVioletRed3, FXColors::PaleVioletRed4, FXColors::PapayaWhip, FXColors::PeachPuff, FXColors::PeachPuff1, FXColors::PeachPuff2, FXColors::PeachPuff3, FXColors::PeachPuff4, FXColors::Peru, FXColors::Pink, FXColors::Pink1, FXColors::Pink2, FXColors::Pink3, FXColors::Pink4, FXColors::Plum, FXColors::Plum1, FXColors::Plum2, FXColors::Plum3, FXColors::Plum4, FXColors::PowderBlue, FXColors::Purple, FXColors::Purple1, FXColors::Purple2, FXColors::Purple3, FXColors::Purple4, FXColors::Raspberry, FXColors::Red, FXColors::Red1, FXColors::Red2, FXColors::Red3, FXColors::Red4, FXColors::RosyBrown, FXColors::RosyBrown1, FXColors::RosyBrown2, FXColors::RosyBrown3, FXColors::RosyBrown4, FXColors::RoyalBlue, FXColors::RoyalBlue1, FXColors::RoyalBlue2, FXColors::RoyalBlue3, FXColors::RoyalBlue4, FXColors::SaddleBrown, FXColors::Salmon, FXColors::Salmon1, FXColors::Salmon2, FXColors::Salmon3, FXColors::Salmon4, FXColors::SandyBrown, FXColors::SeaGreen, FXColors::SeaGreen1, FXColors::SeaGreen2, FXColors::SeaGreen3, FXColors::SeaGreen4, FXColors::Seashell, FXColors::Seashell1, FXColors::Seashell2, FXColors::Seashell3, FXColors::Seashell4, FXColors::Sepia, FXColors::Sienna, FXColors::Sienna1, FXColors::Sienna2, FXColors::Sienna3, FXColors::Sienna4, FXColors::Silver, FXColors::SkyBlue, FXColors::SkyBlue1, FXColors::SkyBlue2, FXColors::SkyBlue3, FXColors::SkyBlue4, FXColors::SlateBlue, FXColors::SlateBlue1, FXColors::SlateBlue2, FXColors::SlateBlue3, FXColors::SlateBlue4, FXColors::SlateGray, FXColors::SlateGray1, FXColors::SlateGray2, FXColors::SlateGray3, FXColors::SlateGray4, FXColors::SlateGray, FXColors::Snow, FXColors::Snow1, FXColors::Snow2, FXColors::Snow3, FXColors::Snow4, FXColors::SpringGreen, FXColors::SpringGreen1, FXColors::SpringGreen2, FXColors::SpringGreen3, FXColors::SpringGreen4, FXColors::SteelBlue, FXColors::SteelBlue1, FXColors::SteelBlue2, FXColors::SteelBlue3, FXColors::SteelBlue4, FXColors::Tan, FXColors::Tan1, FXColors::Tan2, FXColors::Tan3, FXColors::Tan4, FXColors::Teal, FXColors::Thistle, FXColors::Thistle1, FXColors::Thistle2, FXColors::Thistle3, FXColors::Thistle4, FXColors::Tomato, FXColors::Tomato1, FXColors::Tomato2, FXColors::Tomato3, FXColors::Tomato4, FXColors::Turquoise, FXColors::Turquoise1, FXColors::Turquoise2, FXColors::Turquoise3, FXColors::Turquoise4, FXColors::Ultramarine, FXColors::Violet, FXColors::VioletRed, FXColors::VioletRed1, FXColors::VioletRed2, FXColors::VioletRed3, FXColors::VioletRed4, FXColors::WarmGray, FXColors::Wheat, FXColors::Wheat1, FXColors::Wheat2, FXColors::Wheat3, FXColors::Wheat4, FXColors::White, FXColors::WhiteSmoke, FXColors::Yellow, FXColors::Yellow1, FXColors::Yellow2, FXColors::Yellow3, FXColors::Yellow4, FXColors::YellowGreen }; // Furnish our own version extern FXAPI FXint __sscanf(const FXchar* string,const FXchar* format,...); extern FXAPI FXint __snprintf(FXchar* string,FXint length,const FXchar* format,...); // Get RGB value from color name FXColor colorFromName(const FXchar* name){ FXchar temp[MAXCOLORNAME],*tail=temp,c; FXint l,h,m,eq,r,g,b,a; if(name){ while((c=*name++)!='\0' && tail<&temp[MAXCOLORNAME-1]){ // Squeeze out embedded spaces if(!Ascii::isSpace(c)) *tail++=c; } *tail='\0'; if(temp[0]=='#'){ switch(tail-temp-1){ case 3: __sscanf(temp+1,"%01x%01x%01x",&r,&g,&b); return FXRGB((r*17),(g*17),(b*17)); case 4: __sscanf(temp+1,"%01x%01x%01x%01x",&r,&g,&b,&a); return FXRGBA((r*17),(g*17),(b*17),(a*17)); case 6: __sscanf(temp+1,"%02x%02x%02x",&r,&g,&b); return FXRGB(r,g,b); case 8: __sscanf(temp+1,"%02x%02x%02x%02x",&r,&g,&b,&a); return FXRGBA(r,g,b,a); case 9: __sscanf(temp+1,"%03x%03x%03x",&r,&g,&b); return FXRGB((r/16),(g/16),(b/16)); case 12: __sscanf(temp+1,"%04x%04x%04x",&r,&g,&b); return FXRGB((r/257),(g/257),(b/257)); case 16: __sscanf(temp+1,"%04x%04x%04x%04x",&r,&g,&b,&a); return FXRGBA((r/257),(g/257),(b/257),(a/257)); } } else{ l=0; h=ARRAYNUMBER(colorName)-1; do{ m=(h+l)>>1; eq=FXString::comparecase(temp,colorName[m]); if(eq==0) return colorValue[m]; if(eq<0) h=m-1; else l=m+1; } while(h>=l); } } return FXRGBA(0,0,0,0); } // Get rgb value from color name FXColor colorFromName(const FXString& name){ return colorFromName(name.text()); } // Get color name from rgb value FXchar* nameFromColor(FXchar* name,FXColor color){ if(!name){ fxerror("FXColorName::nameFromColor: NULL name argument.\n"); } if(color && FXALPHAVAL(color)<255){ __snprintf(name,MAXCOLORNAME,"#%02x%02x%02x%02x",FXREDVAL(color),FXGREENVAL(color),FXBLUEVAL(color),FXALPHAVAL(color)); } else{ for(FXuint i=0; i>8)+128)>>8); gb+=((gs+(gs>>8)+128)>>8); bb+=((gs+(bs>>8)+128)>>8); return FXRGB(rb,gb,bb); } // Blend source color over black background color FXColor blendOverBlack(FXColor clr){ FXint as=FXALPHAVAL(clr); FXint rs=FXREDVAL(clr)*as; FXint gs=FXGREENVAL(clr)*as; FXint bs=FXBLUEVAL(clr)*as; FXint rd=((rs+(rs>>8)+128)>>8); FXint gd=((gs+(gs>>8)+128)>>8); FXint bd=((bs+(bs>>8)+128)>>8); return FXRGB(rd,gd,bd); } // Blend source color over white background color FXColor blendOverWhite(FXColor clr){ FXint as=FXALPHAVAL(clr); FXint rs=(FXREDVAL(clr)-255)*as; FXint gs=(FXGREENVAL(clr)-255)*as; FXint bs=(FXBLUEVAL(clr)-255)*as; FXint rd=255+((rs+(rs>>8)+128)>>8); FXint gd=255+((gs+(gs>>8)+128)>>8); FXint bd=255+((bs+(bs>>8)+128)>>8); return FXRGB(rd,gd,bd); } // Blend color src toward color dst by a given percentage FXColor makeBlendColor(FXColor src,FXColor dst,FXint percent){ FXuint r,g,b,tnecrep=100-percent; r=(FXREDVAL(dst)*percent+FXREDVAL(src)*tnecrep+50)/100; g=(FXGREENVAL(dst)*percent+FXGREENVAL(src)*tnecrep+50)/100; b=(FXBLUEVAL(dst)*percent+FXBLUEVAL(src)*tnecrep+50)/100; return FXRGB(r,g,b); } // Get highlight color FXColor makeHiliteColor(FXColor clr,FXint percent){ FXuint r,g,b,tnecrep=100-percent; r=(255*percent+FXREDVAL(clr)*tnecrep+50)/100; g=(255*percent+FXGREENVAL(clr)*tnecrep+50)/100; b=(255*percent+FXBLUEVAL(clr)*tnecrep+50)/100; return FXRGB(r,g,b); } // Get shadow color FXColor makeShadowColor(FXColor clr,FXint percent){ FXuint r,g,b,tnecrep=100-percent; r=(FXREDVAL(clr)*tnecrep+50)/100; g=(FXGREENVAL(clr)*tnecrep+50)/100; b=(FXBLUEVAL(clr)*tnecrep+50)/100; return FXRGB(r,g,b); } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXComboBox.cpp000066400000000000000000000503011455751074500222550ustar00rootroot00000000000000/******************************************************************************** * * * C o m b o B o x O b j e c t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXObjectList.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXWindow.h" #include "FXFrame.h" #include "FXLabel.h" #include "FXTextField.h" #include "FXButton.h" #include "FXMenuButton.h" #include "FXComposite.h" #include "FXPacker.h" #include "FXShell.h" #include "FXPopup.h" #include "FXScrollBar.h" #include "FXScrollArea.h" #include "FXList.h" #include "FXComboBox.h" /* Notes: - Handling typed text: a) Pass string to target only. b) Pass string to target & add to list [begin, after/before current, or end]. c) Pass string to target & replace current item's label. - FXComboBox is a text field which may be filled from an FXList. - FXComboBox is a text field which in turn may fill an FXList also. - In most other respects, it behaves like a FXTextField. - Need to catch up/down arrow keys. - Combobox turns OFF GUI Updating while being manipulated. - Need some way to size the FXList automatically to the number of items. - If you leave the list then getCurrentItem() returns the last item under cursor which is not the same item shown in FXComboBox. - FXComboBox::getItem() and FXComboBox::getItemText() are the same; this should probably change. - No reaction to up and down arrow while disabled. */ #define COMBOBOX_INS_MASK (COMBOBOX_REPLACE|COMBOBOX_INSERT_BEFORE|COMBOBOX_INSERT_AFTER|COMBOBOX_INSERT_FIRST|COMBOBOX_INSERT_LAST) #define COMBOBOX_MASK (COMBOBOX_STATIC|COMBOBOX_INS_MASK) using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXComboBox) FXComboBoxMap[]={ FXMAPFUNC(SEL_FOCUS_UP,0,FXComboBox::onFocusUp), FXMAPFUNC(SEL_FOCUS_DOWN,0,FXComboBox::onFocusDown), FXMAPFUNC(SEL_FOCUS_SELF,0,FXComboBox::onFocusSelf), FXMAPFUNC(SEL_UPDATE,FXComboBox::ID_TEXT,FXComboBox::onUpdFmText), FXMAPFUNC(SEL_CLICKED,FXComboBox::ID_LIST,FXComboBox::onListClicked), FXMAPFUNC(SEL_COMMAND,FXComboBox::ID_LIST,FXComboBox::onListCommand), FXMAPFUNC(SEL_LEFTBUTTONPRESS,FXComboBox::ID_TEXT,FXComboBox::onTextButton), FXMAPFUNC(SEL_MOUSEWHEEL,FXComboBox::ID_TEXT,FXComboBox::onMouseWheel), FXMAPFUNC(SEL_CHANGED,FXComboBox::ID_TEXT,FXComboBox::onTextChanged), FXMAPFUNC(SEL_COMMAND,FXComboBox::ID_TEXT,FXComboBox::onTextCommand), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_SETVALUE,FXComboBox::onFwdToText), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_SETINTVALUE,FXComboBox::onFwdToText), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_SETREALVALUE,FXComboBox::onFwdToText), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_SETSTRINGVALUE,FXComboBox::onFwdToText), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_GETINTVALUE,FXComboBox::onFwdToText), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_GETREALVALUE,FXComboBox::onFwdToText), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_GETSTRINGVALUE,FXComboBox::onFwdToText), }; // Object implementation FXIMPLEMENT(FXComboBox,FXPacker,FXComboBoxMap,ARRAYNUMBER(FXComboBoxMap)) // Combo box FXComboBox::FXComboBox(FXComposite *p,FXint cols,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb):FXPacker(p,opts,x,y,w,h,0,0,0,0,0,0){ flags|=FLAG_ENABLED; target=tgt; message=sel; field=new FXTextField(this,cols,this,FXComboBox::ID_TEXT,0,0,0,0,0,pl,pr,pt,pb); if(options&COMBOBOX_STATIC) field->setEditable(false); pane=new FXPopup(this,FRAME_LINE); list=new FXList(pane,this,FXComboBox::ID_LIST,LIST_BROWSESELECT|LIST_AUTOSELECT|LAYOUT_FILL_X|LAYOUT_FILL_Y|SCROLLERS_TRACK|HSCROLLER_NEVER); if(options&COMBOBOX_STATIC) list->setScrollStyle(SCROLLERS_TRACK|HSCROLLING_OFF); button=new FXMenuButton(this,FXString::null,nullptr,pane,FRAME_RAISED|FRAME_THICK|MENUBUTTON_DOWN|MENUBUTTON_ATTACH_RIGHT,0,0,0,0,0,0,0,0); button->setXOffset(border); button->setYOffset(border); flags&=~FLAG_UPDATE; // Never GUI update } // Create window void FXComboBox::create(){ FXPacker::create(); pane->create(); } // Detach window void FXComboBox::detach(){ FXPacker::detach(); pane->detach(); } // Destroy window void FXComboBox::destroy(){ pane->destroy(); FXPacker::destroy(); } // Enable the window void FXComboBox::enable(){ if(!isEnabled()){ FXPacker::enable(); field->enable(); button->enable(); } } // Disable the window void FXComboBox::disable(){ if(isEnabled()){ FXPacker::disable(); field->disable(); button->disable(); } } // Get default width FXint FXComboBox::getDefaultWidth(){ FXint ww=field->getDefaultWidth()+button->getDefaultWidth()+(border<<1); FXint pw=pane->getDefaultWidth(); return FXMAX(ww,pw); } // Get default height FXint FXComboBox::getDefaultHeight(){ FXint th=field->getDefaultHeight(); FXint bh=button->getDefaultHeight(); return FXMAX(th,bh)+(border<<1); } // Recalculate layout void FXComboBox::layout(){ FXint buttonWidth,textWidth,itemHeight; itemHeight=height-(border<<1); buttonWidth=button->getDefaultWidth(); textWidth=width-buttonWidth-(border<<1); field->position(border,border,textWidth,itemHeight); button->position(border+textWidth,border,buttonWidth,itemHeight); pane->resize(width,pane->getDefaultHeight()); flags&=~FLAG_DIRTY; } // Forward GUI update of text field to target; but only if pane is not popped long FXComboBox::onUpdFmText(FXObject*,FXSelector,void*){ return target && !isMenuShown() && target->tryHandle(this,FXSEL(SEL_UPDATE,message),nullptr); } // Command handled in the text field long FXComboBox::onFwdToText(FXObject* sender,FXSelector sel,void* ptr){ return field->handle(sender,sel,ptr); } // Clicked inside or outside an item in the list; unpost the pane long FXComboBox::onListClicked(FXObject*,FXSelector,void*){ return button->handle(this,FXSEL(SEL_COMMAND,ID_UNPOST),nullptr); } // Clicked on an item in the list; issue a callback long FXComboBox::onListCommand(FXObject*,FXSelector,void* ptr){ field->setText(list->getItemText((FXint)(FXival)ptr)); if(!(options&COMBOBOX_STATIC)) field->selectAll(); return target && target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)getText().text()); } // Pressed left button in text field long FXComboBox::onTextButton(FXObject*,FXSelector,void*){ if(options&COMBOBOX_STATIC){ button->showMenu(true); return 1; } return 0; } // Text has changed long FXComboBox::onTextChanged(FXObject*,FXSelector,void* ptr){ return target && target->tryHandle(this,FXSEL(SEL_CHANGED,message),ptr); } // Text has changed long FXComboBox::onTextCommand(FXObject*,FXSelector,void* ptr){ FXint index=list->getCurrentItem(); if(!(options&COMBOBOX_STATIC)){ switch(options&COMBOBOX_INS_MASK){ case COMBOBOX_REPLACE: if(0<=index) setItem(index,(FXchar*)ptr,getItemData(index)); break; case COMBOBOX_INSERT_BEFORE: if(0<=index) insertItem(index,(FXchar*)ptr); break; case COMBOBOX_INSERT_AFTER: if(0<=index) insertItem(index+1,(FXchar*)ptr); break; case COMBOBOX_INSERT_FIRST: insertItem(0,(FXchar*)ptr); break; case COMBOBOX_INSERT_LAST: appendItem((FXchar*)ptr); break; } } return target && target->tryHandle(this,FXSEL(SEL_COMMAND,message),ptr); } // Bounce focus to the text field long FXComboBox::onFocusSelf(FXObject* sender,FXSelector,void* ptr){ return field->handle(sender,FXSEL(SEL_FOCUS_SELF,0),ptr); } // Select upper item long FXComboBox::onFocusUp(FXObject*,FXSelector,void*){ if(isEnabled()){ FXint index=getCurrentItem(); if(index<0) index=getNumItems()-1; else if(0code<0){ if(index<0) index=0; else if(indexcode>0){ if(index<0) index=getNumItems()-1; else if(0isEditable(); } // Set widget is editable or not void FXComboBox::setEditable(FXbool edit){ field->setEditable(edit); } // Set text void FXComboBox::setText(const FXString& text,FXbool notify){ if(field->getText()!=text){ field->setText(text); if(notify && target){target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)getText().text());} } } // Obtain text FXString FXComboBox::getText() const { return field->getText(); } // Set number of text columns void FXComboBox::setNumColumns(FXint cols){ field->setNumColumns(cols); } // Get number of text columns FXint FXComboBox::getNumColumns() const { return field->getNumColumns(); } // Get number of items FXint FXComboBox::getNumItems() const { return list->getNumItems(); } // Get number of visible items FXint FXComboBox::getNumVisible() const { return list->getNumVisible(); } // Set number of visible items void FXComboBox::setNumVisible(FXint nvis){ list->setNumVisible(nvis); } // Is item current FXbool FXComboBox::isItemCurrent(FXint index) const { return list->isItemCurrent(index); } // Change current item void FXComboBox::setCurrentItem(FXint index,FXbool notify){ FXint current=list->getCurrentItem(); if(current!=index){ list->setCurrentItem(index); list->makeItemVisible(index); if(0<=index){ setText(list->getItemText(index),notify); } else{ setText(FXString::null,notify); } } } // Get current item FXint FXComboBox::getCurrentItem() const { return list->getCurrentItem(); } // Retrieve item FXString FXComboBox::getItem(FXint index) const { return list->getItem(index)->getText(); } // Replace text of item at index FXint FXComboBox::setItem(FXint index,const FXString& text,FXptr ptr,FXbool notify){ if(index<0 || list->getNumItems()<=index){ fxerror("%s::setItem: index out of range.\n",getClassName()); } list->setItem(index,text,nullptr,ptr); recalc(); if(isItemCurrent(index)){ setText(text,notify); } return index; } // Fill list by appending items from array of strings FXint FXComboBox::fillItems(const FXchar *const *strings,FXbool notify){ FXint numberofitems=list->getNumItems(); FXint n=list->fillItems(strings); recalc(); if(numberofitems<=list->getCurrentItem()){ setText(list->getItemText(list->getCurrentItem()),notify); } return n; } // Fill list by appending items from array of strings FXint FXComboBox::fillItems(const FXString* strings,FXbool notify){ FXint numberofitems=list->getNumItems(); FXint n=list->fillItems(strings); recalc(); if(numberofitems<=list->getCurrentItem()){ setText(list->getItemText(list->getCurrentItem()),notify); } return n; } // Fill list by appending items from newline separated strings FXint FXComboBox::fillItems(const FXString& strings,FXbool notify){ FXint numberofitems=list->getNumItems(); FXint n=list->fillItems(strings); recalc(); if(numberofitems<=list->getCurrentItem()){ setText(list->getItemText(list->getCurrentItem()),notify); } return n; } // Insert item at index FXint FXComboBox::insertItem(FXint index,const FXString& text,FXptr ptr,FXbool notify){ if(index<0 || list->getNumItems()insertItem(index,text,nullptr,ptr); recalc(); if(isItemCurrent(index)){ setText(text,notify); } return index; } // Append item FXint FXComboBox::appendItem(const FXString& text,FXptr ptr,FXbool notify){ FXint index=list->appendItem(text,nullptr,ptr); recalc(); if(isItemCurrent(index)){ setText(text,notify); } return index; } // Prepend item FXint FXComboBox::prependItem(const FXString& text,void* ptr,FXbool notify){ FXint index=list->prependItem(text,nullptr,ptr); recalc(); if(isItemCurrent(index)){ setText(text,notify); } return index; } // Move item from oldindex to newindex FXint FXComboBox::moveItem(FXint newindex,FXint oldindex,FXbool notify){ if(newindex<0 || list->getNumItems()<=newindex || oldindex<0 || list->getNumItems()<=oldindex){ fxerror("%s::moveItem: index out of range.\n",getClassName()); } FXint current=list->getCurrentItem(); list->moveItem(newindex,oldindex); recalc(); if(current!=list->getCurrentItem()){ current=list->getCurrentItem(); if(0<=current){ setText(list->getItemText(current),notify); } else{ setText(FXString::null,notify); } } return newindex; } // Remove given item void FXComboBox::removeItem(FXint index,FXbool notify){ FXint current=list->getCurrentItem(); list->removeItem(index); recalc(); if(index==current){ current=list->getCurrentItem(); if(0<=current){ setText(list->getItemText(current),notify); } else{ setText(FXString::null,notify); } } } // Remove all items void FXComboBox::clearItems(FXbool notify){ list->clearItems(); recalc(); setText(FXString::null,notify); } // Get item by name FXint FXComboBox::findItem(const FXString& string,FXint start,FXuint flgs) const { return list->findItem(string,start,flgs); } // Get item by data FXint FXComboBox::findItemByData(FXptr ptr,FXint start,FXuint flgs) const { return list->findItemByData(ptr,start,flgs); } // Set item text void FXComboBox::setItemText(FXint index,const FXString& txt){ list->setItemText(index,txt); recalc(); if(isItemCurrent(index)){ setText(txt); } } // Get item text FXString FXComboBox::getItemText(FXint index) const { return list->getItemText(index); } // Set item data void FXComboBox::setItemData(FXint index,FXptr ptr) const { list->setItemData(index,ptr); } // Get item data FXptr FXComboBox::getItemData(FXint index) const { return list->getItemData(index); } // Return true if item is enabled FXbool FXComboBox::isItemEnabled(FXint index) const { return list->isItemEnabled(index); } // Enable item FXbool FXComboBox::enableItem(FXint index){ return list->enableItem(index); } // Disable item FXbool FXComboBox::disableItem(FXint index){ return list->disableItem(index); } // Show menu void FXComboBox::showMenu(FXbool shw){ button->showMenu(shw); } // Is the pane shown FXbool FXComboBox::isMenuShown() const { return button->isMenuShown(); } // Set font void FXComboBox::setFont(FXFont* fnt){ if(!fnt){ fxerror("%s::setFont: NULL font specified.\n",getClassName()); } field->setFont(fnt); list->setFont(fnt); recalc(); } // Obtain font FXFont* FXComboBox::getFont() const { return field->getFont(); } // Change combobox style void FXComboBox::setComboStyle(FXuint mode){ FXuint opts=(options&~COMBOBOX_MASK)|(mode&COMBOBOX_MASK); if(opts!=options){ options=opts; if(options&COMBOBOX_STATIC){ field->setEditable(false); // Non-editable list->setScrollStyle(SCROLLERS_TRACK|HSCROLLING_OFF); // No scrolling } else{ field->setEditable(true); // Editable list->setScrollStyle(SCROLLERS_TRACK|HSCROLLER_NEVER); // Scrollable, but no scrollbar } recalc(); } } // Change popup pane shrinkwrap mode void FXComboBox::setShrinkWrap(FXbool flag){ pane->setShrinkWrap(flag); } // Return popup pane shrinkwrap mode FXbool FXComboBox::getShrinkWrap() const { return pane->getShrinkWrap(); } // Get combobox style FXuint FXComboBox::getComboStyle() const { return (options&COMBOBOX_MASK); } // Set text justify style void FXComboBox::setJustify(FXuint style){ field->setJustify(style); } // Get text justify style FXuint FXComboBox::getJustify() const { return field->getJustify(); } // Set window background color void FXComboBox::setBackColor(FXColor clr){ field->setBackColor(clr); list->setBackColor(clr); } // Get background color FXColor FXComboBox::getBackColor() const { return field->getBackColor(); } // Set text color void FXComboBox::setTextColor(FXColor clr){ field->setTextColor(clr); list->setTextColor(clr); } // Return text color FXColor FXComboBox::getTextColor() const { return field->getTextColor(); } // Set select background color void FXComboBox::setSelBackColor(FXColor clr){ field->setSelBackColor(clr); list->setSelBackColor(clr); } // Return selected background color FXColor FXComboBox::getSelBackColor() const { return field->getSelBackColor(); } // Set selected text color void FXComboBox::setSelTextColor(FXColor clr){ field->setSelTextColor(clr); list->setSelTextColor(clr); } // Return selected text color FXColor FXComboBox::getSelTextColor() const { return field->getSelTextColor(); } // Sort items using current sort function void FXComboBox::sortItems(){ list->sortItems(); } // Return sort function FXListSortFunc FXComboBox::getSortFunc() const { return list->getSortFunc(); } // Change sort function void FXComboBox::setSortFunc(FXListSortFunc func){ list->setSortFunc(func); } // Set help text void FXComboBox::setHelpText(const FXString& txt){ field->setHelpText(txt); } // Get help text const FXString& FXComboBox::getHelpText() const { return field->getHelpText(); } // Set tip text void FXComboBox::setTipText(const FXString& txt){ field->setTipText(txt); } // Get tip text const FXString& FXComboBox::getTipText() const { return field->getTipText(); } // Save object to stream void FXComboBox::save(FXStream& store) const { FXPacker::save(store); store << field; store << button; store << list; store << pane; } // Load object from stream void FXComboBox::load(FXStream& store){ FXPacker::load(store); store >> field; store >> button; store >> list; store >> pane; } // Delete it FXComboBox::~FXComboBox(){ delete pane; pane=(FXPopup*)-1L; field=(FXTextField*)-1L; button=(FXMenuButton*)-1L; list=(FXList*)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCompletion.cpp000066400000000000000000000075151455751074500226670ustar00rootroot00000000000000/******************************************************************************** * * * C o m p l e t i o n C o u n t e r * * * ********************************************************************************* * Copyright (C) 2014,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXAtomic.h" #include "FXSemaphore.h" #include "FXCompletion.h" /* Notes: - Completion allows a single thread to monitor a number of ongoing concurrent activities for completion. - When an activity is started, the counter is incremented. If this was the first activity, the monitoring semaphore will be decremented to zero. Starting subsequent activities will increment the count but leave the semaphore alone. - When an activity is finished, the counter is decremented; if this was the last activity, the semaphore will be incremented, causing the thread that called wait to unblock, and subsequently reset the semaphore for next time. - A semaphore is set to 1 when no activities are in progress; a call to wait() will immediately succeed in that case; the semaphore is automatically reset to 1 after examination by the calling thread. - Note that the first activity being started may have to wait until the calling thread from a previous activity completion check has returned from the wait() call. - Don't block in wait() or wait(nsec) if counter was zero already; no need to test semaphore in trywait(), since counter tells all. - A completion should NOT go out of scope until counter becomes zero again, since other activities are still outstanding. */ using namespace FX; namespace FX { /*******************************************************************************/ // Initialize completion counter FXCompletion::FXCompletion():semaphore(1),counter(0){ } // Increment counter void FXCompletion::increment(FXuint cnt){ if(atomicAdd(&counter,cnt)==0 && cnt){semaphore.wait();} } // Decrement counter void FXCompletion::decrement(FXuint cnt){ if(atomicAdd(&counter,0-cnt)==cnt && cnt){semaphore.post();} } // Wait till complete void FXCompletion::wait(){ if(counter){ semaphore.wait(); semaphore.post(); } } // Wait till complete or timeout; return false if timed out FXbool FXCompletion::wait(FXTime nsec){ if(counter){ if(!semaphore.wait(nsec)) return false; semaphore.post(); } return true; } // Delete completion counter FXCompletion::~FXCompletion(){ wait(); } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXComplexd.cpp000066400000000000000000000156371455751074500223350ustar00rootroot00000000000000/******************************************************************************** * * * D o u b l e - P r e c i s i o n C o m p l e x N u m b e r * * * ********************************************************************************* * Copyright (C) 2006,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXObject.h" #include "FXComplexd.h" /* Notes: - The cpow() function return complex power function value z = (x) + j(y) cpow(x,y) = cexp(y*clog(x)) - The cproj() function computes a projection of z onto the Riemann sphere: Argument projects to argument, except that all complex infinities (even those with one infinite part and one NaN part) project to positive infinity on the real axis. If argument has an infinite part, then cproj(argument) shall be equivalent to: INFINITY + I * copysign(0.0, cimag(argument)) z = (x) + j(y) cproj(z) = (2.0 * z) / (~z*z + 1.0) - The csin() function returns the complex sine value. z = (x) + j(y) csin(z) = cosh(y) * sin(x) + j * sinh(y) * cos(x) - The csinh() function returnes complex hyperbolic sine value z = (x) + j(y) csinh(z) = sinh(x) * cos(y) + j * cosh(x) * sin(y) - The sqrt() function returns the complex square root value, in the range of the right half-plane (including the imaginary axis) z = (x) + j(y) csqrt(z) = sqrt(0.5*(cabs(z)+x)) + j*(y/abs(y))*sqrt(0.5*(cabs(z)-x)) r = sqrt(0.5 * (abs(x) + cabs(z)) q = (0.5 * y) / r where(x >= 0) csqrt(z) = r + j*q where(x < 0 && y >= 0) csqrt(z) = q + j*r where(x < 0 && y < 0) csqrt(z) = -q + j*r -The ctan() function returns the complex tangent value. z = (x) + j(y) ctan(z) = (sin(2*x) + j*sinh(2*y)) / (cos(2*x) + cosh(2*y)) when (CCOS(z) = 0 + j0) ctan(z)= MAX_POS_DBLF + j0 else ctan (z) = CSIN(z) / CCOS(z) - The ctanh() function returnes complex hyperbolic tangent value z = (x) + j(y) ctanh(z) = (sinh(2*x) + j * sin(2*y)) / (cosh(2*x) + cos(2*y)) - The cacos() function returns the complex arc cosine value, in the range of a strip mathematically unbounded along the imaginary axis and in the interval [0,pi] along the real axis. z = (x) + j(y) cacos(z) = (PI/2, 0) - casin(z) (old version) cacos(z) = (+/-) j*cacosh(z) - The cacosh() function returns the complex arc hyperbolic cosine value, in the range of a half-strip of non-negative values along the real axis and in the interval [-i pi, +i pi] along the imaginary axis. z = (x) + j(y) cacosh(z) = clog(z+csqrt(~z*z-1.0)) - The carg() function returns the value of the argument in the interval [-pi, +pi]. z = (x) + j(y) carg(z) = atan2(y,x) - The casin() function returns the complex arc sine value, in the range of a strip mathematically unbounded along the imaginary axis and in the interval [-pi/2, +pi/2] along the real axis. z = (x) + j(y) casin(z) = -j*casinh(j*z) - The casinh() function returns the complex arc hyperbolic cosine value, in the range of a half-strip of non-negative values along the real axis and in the interval [-i pi, +i pi] along the imaginary axis. z = (x) + j(y) casinh(z) = clog(z+csqrt(~z*z+1)) - The catan() function returns the complex arc tangent value, in the range of a strip mathematically unbounded along the imaginary axis and in the interval [-pi/2, +pi/2] along the real axis. z = (x) + j(y) catan(z) = -j/2 * log( (j+z) / (j-z) ) catan(z) = 0.5 * atan(2*x,1-(x^2)-(y^2)) + j*0.25*(log((x^2)+(y+1)^2) - log((x^2)+(y-1)^2)) - The catanh() function returns the complex arc hyperbolic tangent value, in the range of a strip mathematically unbounded along the real axis and in the interval [-i pi/2, +i pi/2] along the imaginary axis. z = (x) + j(y) catanh(z) = 0.5 * clog((1+z)/(1-z)) catanh(z) = 0.25 * (log( (y^2)+(1+x)^2 ) - log( (y^2)+(1-x)^2 )) + j * 0.5 * atan(2*y,(1-(x^2)-(y^2)) - The ccos() function returns the complex cosine value. z =(x) + j(y) ccos(z) = ccosh(j*z) - The ccosh() function returnes complex hyperbolic cosine value z = (x) + j(y) ccosh(z) = cosh(x) * cos(y) + j * sinh(x) * sin(y) */ using namespace FX; /*******************************************************************************/ namespace FX { // Complex square root FXComplexd csqrt(const FXComplexd& c){ FXdouble mag=abs(c); FXdouble rr=Math::sqrt((mag+c.re)*0.5); FXdouble ii=Math::sqrt((mag-c.re)*0.5); return FXComplexd(rr,Math::copysign(ii,c.im)); } // Complex sine FXComplexd csin(const FXComplexd& c){ return FXComplexd(Math::sin(c.re)*Math::cosh(c.im),Math::cos(c.re)*Math::sinh(c.im)); } // Complex cosine FXComplexd ccos(const FXComplexd& c){ return FXComplexd(Math::cos(c.re)*Math::cosh(c.im),-Math::sin(c.re)*Math::sinh(c.im)); } // Complex tangent FXComplexd ctan(const FXComplexd& c){ FXComplexd ep=exp(FXComplexd(-c.im,c.re)); FXComplexd em=exp(FXComplexd(c.im,-c.re)); FXComplexd t=(em-ep)/(em+ep); return FXComplexd(-t.im,t.re); } // Complex hyperbolic sine FXComplexd csinh(const FXComplexd& c){ return FXComplexd(Math::cos(c.im)*Math::sinh(c.re),Math::sin(c.im)*Math::cosh(c.re)); } // Complex hyperbolic cosine FXComplexd ccosh(const FXComplexd& c){ return FXComplexd(Math::cos(c.im)*Math::cosh(c.re),Math::sin(c.im)*Math::sinh(c.re)); } // Complex hyperbolic tangent FXComplexd ctanh(const FXComplexd& c){ return csinh(c)/ccosh(c); } FXStream& operator<<(FXStream& store,const FXComplexd& c){ store << c.re << c.im; return store; } FXStream& operator>>(FXStream& store,FXComplexd& c){ store >> c.re >> c.im; return store; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXComplexf.cpp000066400000000000000000000063731455751074500223340ustar00rootroot00000000000000/******************************************************************************** * * * S i n g l e - P r e c i s i o n C o m p l e x N u m b e r * * * ********************************************************************************* * Copyright (C) 2006,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXObject.h" #include "FXComplexf.h" using namespace FX; /*******************************************************************************/ namespace FX { // Complex square root FXComplexf csqrt(const FXComplexf& c){ FXfloat mag=abs(c); FXfloat rr=Math::sqrt((mag+c.re)*0.5f); FXfloat ii=Math::sqrt((mag-c.re)*0.5f); return FXComplexf(rr,Math::copysign(ii,c.im)); } // Complex sine FXComplexf csin(const FXComplexf& c){ return FXComplexf(Math::sin(c.re)*Math::cosh(c.im),Math::cos(c.re)*Math::sinh(c.im)); } // Complex cosine FXComplexf ccos(const FXComplexf& c){ return FXComplexf(Math::cos(c.re)*Math::cosh(c.im),-Math::sin(c.re)*Math::sinh(c.im)); } // Complex tangent FXComplexf ctan(const FXComplexf& c){ FXComplexf em=exp(FXComplexf(c.im,-c.re)); FXComplexf ep=exp(FXComplexf(-c.im,c.re)); FXComplexf t=(em-ep)/(em+ep); return FXComplexf(-t.im,t.re); } // Complex hyperbolic sine FXComplexf csinh(const FXComplexf& c){ return FXComplexf(Math::cos(c.im)*Math::sinh(c.re),Math::sin(c.im)*Math::cosh(c.re)); } // Complex hyperbolic cosine FXComplexf ccosh(const FXComplexf& c){ return FXComplexf(Math::cos(c.im)*Math::cosh(c.re),Math::sin(c.im)*Math::sinh(c.re)); } // Complex hyperbolic tangent FXComplexf ctanh(const FXComplexf& c){ return csinh(c)/ccosh(c); } FXStream& operator<<(FXStream& store,const FXComplexf& c){ store << c.re << c.im; return store; } FXStream& operator>>(FXStream& store,FXComplexf& c){ store >> c.re >> c.im; return store; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXComposeContext.cpp000066400000000000000000000416271455751074500235320ustar00rootroot00000000000000/******************************************************************************** * * * C o m p o s e - C o n t e x t * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXFont.h" #include "FXComposeContext.h" #include "FXException.h" /* Notes: - In Asian languages, a text entry widget that's being edited may have an input method editor. During the composition process, the system needs to keep track of the state of the composition until it is committed as an input to the widget. This class represents that state. - Each text entry widget may have a compositon context, while it has the focus. - The composition context is deleted when the focus is moved to another widget away from the entry widget. */ #define DISPLAY(app) ((Display*)((app)->display)) using namespace FX; /*******************************************************************************/ namespace FX { // Object implementation FXIMPLEMENT(FXComposeContext,FXId,nullptr,0) #ifdef WIN32 ////////////////////////// MS-Windows /////////////////////////// // Deserialization FXComposeContext::FXComposeContext():window(nullptr),message(0){ FXTRACE((100,"FXComposeContext::FXComposeContext %p\n",this)); } // Create input context FXComposeContext::FXComposeContext(FXApp* a,FXWindow* win,FXSelector sel):FXId(a),window(win),message(sel){ FXTRACE((100,"FXComposeContext::FXComposeContext %p\n",this)); } // Realize the input context void FXComposeContext::create(){ if(!xid){ if(getApp()->isInitialized()){ FXTRACE((100,"%s::create %p\n",getClassName(),this)); xid=window->id(); } } } // Unrealize the input context void FXComposeContext::destroy(){ if(xid){ if(getApp()->isInitialized()){ FXTRACE((100,"%s::destroy %p\n",getClassName(),this)); /////// } } } // Set focus to it void FXComposeContext::focusIn(){ if(xid){ /////// } } // Kill focus to it void FXComposeContext::focusOut(){ if(xid){ /////// } } // Set the font void FXComposeContext::setFont(FXFont* font){ if(xid && font && font->id()){ HIMC himc=ImmGetContext((HWND)xid); LOGFONT lf; GetObject((HFONT)font->id(),sizeof(LOGFONT),&lf); ImmSetCompositionFont(himc,&lf); ImmReleaseContext((HWND)xid,himc); } } // Set the spot void FXComposeContext::setSpot(FXint x,FXint y){ if(xid){ HIMC himc=ImmGetContext((HWND)xid); COMPOSITIONFORM cf; cf.dwStyle=CFS_POINT; FXint tox,toy; window->translateCoordinatesTo(tox,toy,window->getShell(),x,y); cf.ptCurrentPos.x=tox; cf.ptCurrentPos.y=toy; ImmSetCompositionWindow(himc,&cf); ImmReleaseContext((HWND)xid,himc); } } // Set the area void FXComposeContext::setArea(FXint x,FXint y,FXint w,FXint h){ if(xid){ /////// } } // Translate key event FXString FXComposeContext::translateEvent(FXRawEvent& event){ FXString result; if(xid){ HIMC himc=ImmGetContext(event.hwnd); LONG mlen=0; FXnchar* mstr; if(event.lParam&GCS_RESULTSTR){ mlen=ImmGetCompositionString(himc,GCS_RESULTSTR,nullptr,0); mstr=new FXnchar [mlen]; ImmGetCompositionString(himc,GCS_RESULTSTR,mstr,mlen); } else{ mlen=ImmGetCompositionString(himc,GCS_COMPSTR,nullptr,0); mstr=new FXnchar [mlen+1]; ImmGetCompositionString(himc,GCS_COMPSTR,mstr,mlen); } mstr[mlen/sizeof(FXnchar)]=0; ImmReleaseContext(event.hwnd,himc); int utf8len=WideCharToMultiByte(CP_UTF8,0,mstr,-1,nullptr,0,nullptr,nullptr); FXchar* utf8str=new FXchar [utf8len]; WideCharToMultiByte(CP_UTF8,0,mstr,-1,utf8str,utf8len,nullptr,nullptr); result.assign(utf8str,utf8len); delete [] mstr; delete [] utf8str; } return result; } // Delete input context FXComposeContext::~FXComposeContext(){ FXTRACE((100,"FXComposeContext::~FXComposeContext %p\n",this)); } #else ////////////////////////////// X-Windows /////////////////////////////// // Deserialization FXComposeContext::FXComposeContext():window(nullptr),message(0),fontset(0){ FXTRACE((100,"FXComposeContext::FXComposeContext %p\n",this)); } // Create input context FXComposeContext::FXComposeContext(FXApp* a,FXWindow* win,FXSelector sel):FXId(a),window(win),message(sel),fontset(0){ FXTRACE((100,"FXComposeContext::FXComposeContext %p\n",this)); } /* // Determine list of input styles XIMStyles *ximstyles=nullptr; XGetIMValues((XIM)xim,XNQueryInputStyle,&ximstyles,nullptr); if(ximstyles){ FXuint s; // Try preferred input style for(s=0; scount_styles; s++){ if(ximstyles->supported_styles[s]==inputstyle) goto match; } // Try root input style inputstyle=XIMPreeditNothing|XIMStatusNothing; for(s=0; scount_styles; s++){ if(ximstyles->supported_styles[s]==inputstyle) goto match; } // Try none style inputstyle=XIMPreeditNone|XIMStatusNone; for(s=0; scount_styles; s++){ if(ximstyles->supported_styles[s]==inputstyle) goto match; } // No style at all inputstyle=0; // Free list match:XFree(ximstyles); */ /* FXbool isIMRunning(Display *display){ const FXchar *p=XSetLocaleModifiers(nullptr); if(p){ FXTRACE((100,"XSetLocaleModifiers=%s\n",p)); FXString server("@server="); server.append(p+4); // skip "@im=" FXint pos=server.find('@',1); if(0isInitialized()){ FXTRACE((100,"%s::create %p\n",getClassName(),this)); #ifndef NO_XIM XIMCallback statusStartStruct; XIMCallback statusDoneStruct; XIMCallback statusDrawStruct; XIMCallback editStartStruct; XIMCallback editDoneStruct; XIMCallback editDrawStruct; XIMCallback editCaretStruct; XVaNestedList editAttr; XVaNestedList statusAttr; XIMStyles *ximstyles=nullptr; XRectangle rect; XPoint spot; FXuint style,s; // Check if input methods are available if(!getApp()->hasInputMethod()){ fxerror("FXComposeContext: no input methods\n"); } // We must have a window if(!window || !window->id()){ fxerror("FXComposeContext: illegal window parameter\n"); } // Get input style if(FXString::comparecase(getApp()->inputstyle,"onthespot")==0) style=XIMPreeditCallbacks|XIMStatusNothing; else if(FXString::comparecase(getApp()->inputstyle,"overthespot")==0) style=XIMPreeditPosition|XIMStatusNothing; else if(FXString::comparecase(getApp()->inputstyle,"offthespot")==0) style=XIMPreeditArea|XIMStatusArea; else if(FXString::comparecase(getApp()->inputstyle,"root")==0) style=XIMPreeditNothing|XIMStatusNothing; else style=XIMPreeditNone|XIMStatusNone; // Determine list of input styles XGetIMValues((XIM)getApp()->xim,XNQueryInputStyle,&ximstyles,nullptr); if(ximstyles){ // Try preferred input style for(s=0; scount_styles; s++){ if(ximstyles->supported_styles[s]==style) goto m; } // Try root input style style=XIMPreeditNothing|XIMStatusNothing; for(s=0; scount_styles; s++){ if(ximstyles->supported_styles[s]==style) goto m; } // Try none style style=XIMPreeditNone|XIMStatusNone; for(s=0; scount_styles; s++){ if(ximstyles->supported_styles[s]==style) goto m; } // Pick first if(ximstyles->count_styles){ style=ximstyles->supported_styles[0]; } // Free list m: XFree(ximstyles); } // On the spot method if(style&XIMPreeditCallbacks){ editStartStruct.client_data=(XPointer)this; editStartStruct.callback=(XIMProc)editStartCallback; editDoneStruct.client_data=(XPointer)this; editDoneStruct.callback=(XIMProc)editDoneCallback; editDrawStruct.client_data=(XPointer)this; editDrawStruct.callback=(XIMProc)editDrawCallback; editCaretStruct.client_data=(XPointer)this; editCaretStruct.callback=(XIMProc)editCaretCallback; editAttr=XVaCreateNestedList(0,XNPreeditStartCallback,&editStartStruct,XNPreeditDrawCallback,&editDrawStruct,XNPreeditDoneCallback,&editDoneStruct,XNPreeditCaretCallback,&editCaretStruct,nullptr); // Have status callbacks if(style&XIMStatusCallbacks){ FXTRACE((100,"On the Spot/Status\n")); statusStartStruct.client_data=(XPointer)this; statusStartStruct.callback=(XIMProc)statusStartCallback; statusDoneStruct.client_data=(XPointer)this; statusDoneStruct.callback=(XIMProc)statusDoneCallback; statusDrawStruct.client_data=(XPointer)this; statusDrawStruct.callback=(XIMProc)statusDrawCallback; statusAttr=XVaCreateNestedList(0,XNStatusStartCallback,&statusStartStruct,XNStatusDoneCallback,&statusDoneStruct,XNStatusDrawCallback,&statusDrawStruct,nullptr); xid=(FXID)XCreateIC((XIM)getApp()->xim,XNInputStyle,XIMPreeditCallbacks|XIMStatusCallbacks,XNClientWindow,window->id(),XNPreeditAttributes,editAttr,XNStatusAttributes,statusAttr,nullptr); XFree(statusAttr); } // No status callbacks else{ FXTRACE((100,"On the Spot\n")); xid=(FXID)XCreateIC((XIM)getApp()->xim,XNInputStyle,XIMPreeditCallbacks|XIMStatusNothing,XNClientWindow,window->id(),XNPreeditAttributes,editAttr,nullptr); } XFree(editAttr); } // Off the spot method else if(style&XIMPreeditArea){ FXTRACE((100,"Off the Spot\n")); rect.x=0; rect.y=0; rect.width=window->getWidth(); rect.height=window->getHeight(); editAttr=XVaCreateNestedList(0,XNArea,&rect,nullptr); xid=(FXID)XCreateIC((XIM)getApp()->xim,XNInputStyle,XIMPreeditArea|XIMStatusArea,XNClientWindow,window->id(),XNPreeditAttributes,editAttr,nullptr); XFree(editAttr); } // Over the spot method else if(style&XIMPreeditPosition){ FXTRACE((100,"Over the Spot\n")); spot.x=1; spot.y=1; int missing_charcount; char** missing_charsetlist; char* def_string; fontset=XCreateFontSet(DISPLAY(getApp()),"10x20,10x20",&missing_charsetlist,&missing_charcount,&def_string); editAttr=XVaCreateNestedList(0,XNSpotLocation,&spot,XNFontSet,fontset,nullptr); xid=(FXID)XCreateIC((XIM)getApp()->xim,XNInputStyle,XIMPreeditPosition|XIMStatusNothing,XNClientWindow,window->id(),XNPreeditAttributes,editAttr,nullptr); XFreeStringList(missing_charsetlist); XFree(editAttr); } // Root method else{ FXTRACE((100,"Root\n")); xid=(FXID)XCreateIC((XIM)getApp()->xim,XNInputStyle,XIMPreeditNothing|XIMStatusNothing,XNClientWindow,window->id(),nullptr); } // Reset context if(xid){ //long filterevents=0; //XGetICValues((XIC)xid,XNFilterEvents,&filterevents,nullptr); //XSelectInput((Display*)getApp()->getDisplay(),window->id(),BASIC_EVENT_MASK|ENABLED_EVENT_MASK|filterevents); XmbResetIC((XIC)xid); } #endif } } } // Unrealize the input context void FXComposeContext::destroy(){ if(xid){ if(getApp()->isInitialized()){ FXTRACE((100,"%s::destroy %p\n",getClassName(),this)); #ifndef NO_XIM XDestroyIC((XIC)xid); #endif } } } // Set focus to it void FXComposeContext::focusIn(){ #ifndef NO_XIM if(xid){ XSetICFocus((XIC)xid); } #endif } // Kill focus to it void FXComposeContext::focusOut(){ #ifndef NO_XIM if(xid){ XUnsetICFocus((XIC)xid); } #endif } // Set the font void FXComposeContext::setFont(FXFont* font){ if(xid && font && font->id()){ #ifndef NO_XIM /// #endif } } // Set the spot void FXComposeContext::setSpot(FXint x,FXint y){ #ifndef NO_XIM if(xid){ XVaNestedList editAttr; XPoint spot; spot.x=x; spot.y=y; editAttr=XVaCreateNestedList(0,XNSpotLocation,&spot,nullptr); XSetICValues((XIC)xid,XNPreeditAttributes,editAttr,nullptr); XFree(editAttr); } #endif } // Set the area void FXComposeContext::setArea(FXint x,FXint y,FXint w,FXint h){ #ifndef NO_XIM if(xid){ XVaNestedList editAttr; XRectangle rect; rect.x=x; rect.y=y; rect.width=w; rect.height=h; editAttr=XVaCreateNestedList(0,XNArea,&rect,nullptr); XSetICValues((XIC)xid,XNPreeditAttributes,editAttr,nullptr); XFree(editAttr); } #endif } // Translate key event FXString FXComposeContext::translateEvent(FXRawEvent& event){ FXString result; #ifndef NO_XIM if(xid){ char* buffer=new char [513]; KeySym sym; Status s; int n; n=XmbLookupString((XIC)xid,&event.xkey,buffer,512,&sym,&s); if(s==XBufferOverflow){ delete [] buffer; buffer=new char [n+1]; n=XmbLookupString((XIC)xid,&event.xkey,buffer,n,&sym,&s); } if(s!=XLookupChars && s!=XLookupBoth) n=0; // FIXME decode buffer based on XLocaleOfIM(XIMOfIC((XIC)xid)) buffer[n]=0; FXTRACE((100,"XLocaleOfIM=%s\n",XLocaleOfIM(XIMOfIC((XIC)xid)))); result.assign(buffer,n); delete [] buffer; } #endif return result; } int FXComposeContext::editStartCallback(void*,FXComposeContext* cc,void*){ FXTRACE((100,"editStartCallback\n")); return -1; // No length limit } void FXComposeContext::editDoneCallback(void*,FXComposeContext* cc,void*){ FXTRACE((100,"editDoneCallback\n")); } void FXComposeContext::editDrawCallback(void*,FXComposeContext* cc,void* ptr){ #ifndef NO_XIM XIMPreeditDrawCallbackStruct *drawstruct=(XIMPreeditDrawCallbackStruct*)ptr; XIMText *ximtext=drawstruct->text; FXTRACE((100,"editDrawCallback caret=%d first=%d len=%d\n",drawstruct->caret,drawstruct->chg_first,drawstruct->chg_length)); #endif } void FXComposeContext::editCaretCallback(void*,FXComposeContext* cc,void* ptr){ #ifndef NO_XIM XIMPreeditCaretCallbackStruct *caretstruct=(XIMPreeditCaretCallbackStruct*)ptr; FXTRACE((100,"editCaretCallback position=%d direction=%d style=%d\n",caretstruct->position,caretstruct->direction,caretstruct->style)); #endif } void FXComposeContext::statusStartCallback(void*,FXComposeContext* cc,void*){ FXTRACE((100,"statusStartCallback\n")); } void FXComposeContext::statusDoneCallback(void*,FXComposeContext* cc,void*){ FXTRACE((100,"statusDoneCallback\n")); } void FXComposeContext::statusDrawCallback(void*,FXComposeContext* cc,void* ptr){ #ifndef NO_XIM XIMStatusDrawCallbackStruct* drawstruct=(XIMStatusDrawCallbackStruct*)ptr; FXTRACE((100,"statusDrawCallback\n")); #endif } // Delete input context FXComposeContext::~FXComposeContext(){ FXTRACE((100,"FXComposeContext::~FXComposeContext %p\n",this)); destroy(); window=(FXWindow*)-1L; if(fontset) XFreeFontSet(DISPLAY(getApp()),(XFontSet)fontset); fontset=(XFontSet)-1L; } #endif ///////////////////////////////////////////////////////////////////////// } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXComposite.cpp000066400000000000000000000213001455751074500225040ustar00rootroot00000000000000/******************************************************************************** * * * C o m p o s i t e W i n d o w O b j e c t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXAccelTable.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXComposite.h" /* Notes: - Rather a slim class. - Focus should be assigned to a window via SEL_FOCUSELF message. Composite widgets won't have focus so SEL_FOCUSELF should return 0 and do nothing. - Maybe add flag to exempt a widget from maxChildWidth() and/or maxChildHeight() so that things like separators can stay small when everything else gets as big as the biggest child. */ using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXComposite) FXCompositeMap[]={ FXMAPFUNC(SEL_KEYPRESS,0,FXComposite::onKeyPress), FXMAPFUNC(SEL_KEYRELEASE,0,FXComposite::onKeyRelease), FXMAPFUNC(SEL_FOCUS_NEXT,0,FXComposite::onFocusNext), FXMAPFUNC(SEL_FOCUS_PREV,0,FXComposite::onFocusPrev), FXMAPFUNC(SEL_FOCUS_UP,0,FXComposite::onFocusPrev), FXMAPFUNC(SEL_FOCUS_DOWN,0,FXComposite::onFocusNext), FXMAPFUNC(SEL_FOCUS_LEFT,0,FXComposite::onFocusPrev), FXMAPFUNC(SEL_FOCUS_RIGHT,0,FXComposite::onFocusNext), FXMAPFUNC(SEL_COMMAND,FXComposite::ID_UPDATE,FXComposite::onCmdUpdate), }; // Object implementation FXIMPLEMENT(FXComposite,FXWindow,FXCompositeMap,ARRAYNUMBER(FXCompositeMap)) // Only used for Root Window FXComposite::FXComposite(FXApp* a,FXVisual *vis):FXWindow(a,vis){ } // Only used for Shell Window FXComposite::FXComposite(FXApp* a,FXWindow* own,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXWindow(a,own,opts,x,y,w,h){ } // Create empty composite window FXComposite::FXComposite(FXComposite* p,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXWindow(p,opts,x,y,w,h){ } // Is widget a composite FXbool FXComposite::isComposite() const { return true; } // Create window void FXComposite::create(){ FXWindow::create(); for(FXWindow *c=getFirst(); c; c=c->getNext()) c->create(); } // Detach window void FXComposite::detach(){ for(FXWindow *c=getFirst(); c; c=c->getNext()) c->detach(); FXWindow::detach(); } // Destroy window void FXComposite::destroy(){ for(FXWindow *c=getFirst(); c; c=c->getNext()) c->destroy(); FXWindow::destroy(); } // Get width FXint FXComposite::getDefaultWidth(){ FXint w=0,t; for(FXWindow *child=getFirst(); child; child=child->getNext()){ if(child->shown()){ t=child->getX()+child->getWidth(); if(wgetNext()){ if(child->shown()){ t=child->getY()+child->getHeight(); if(hgetNext()){ if(child->shown()){ hints=child->getLayoutHints(); if(hints&LAYOUT_FIX_WIDTH) t=child->getWidth(); else t=child->getDefaultWidth(); if(mgetNext()){ if(child->shown()){ hints=child->getLayoutHints(); if(hints&LAYOUT_FIX_HEIGHT) t=child->getHeight(); else t=child->getDefaultHeight(); if(mgetNext()){ if(child->shown()){ child->position(child->getX(),child->getY(),child->getWidth(),child->getHeight()); } } flags&=~FLAG_DIRTY; } // Update all subwindows long FXComposite::onCmdUpdate(FXObject* sender,FXSelector,void* ptr){ update(); for(FXWindow *child=getFirst(); child; child=child->getNext()){ if(child->shown()) child->handle(sender,FXSEL(SEL_COMMAND,ID_UPDATE),ptr); } return 1; } // Focus moved to next long FXComposite::onFocusNext(FXObject*,FXSelector sel,void* ptr){ FXWindow *child; if(getFocus()) child=getFocus()->getNext(); else child=getFirst(); while(child){ if(child->shown()){ if(child->handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr)) return 1; if(child->handle(this,sel,ptr)) return 1; } child=child->getNext(); } return 0; } // Focus moved to previous long FXComposite::onFocusPrev(FXObject*,FXSelector sel,void* ptr){ FXWindow *child; if(getFocus()) child=getFocus()->getPrev(); else child=getLast(); while(child){ if(child->shown()){ if(child->handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr)) return 1; if(child->handle(this,sel,ptr)) return 1; } child=child->getPrev(); } return 0; } // Keyboard press long FXComposite::onKeyPress(FXObject* sender,FXSelector sel,void* ptr){ FXEvent* event=(FXEvent*)ptr; FXTRACE((200,"%p->%s::onKeyPress keysym=0x%04x state=%04x\n",this,getClassName(),((FXEvent*)ptr)->code,((FXEvent*)ptr)->state)); // Bounce to focus widget if(getFocus() && getFocus()->handle(sender,sel,ptr)) return 1; // Try target first if(isEnabled() && target && target->tryHandle(this,FXSEL(SEL_KEYPRESS,message),ptr)) return 1; // Check the accelerators if(getAccelTable() && getAccelTable()->handle(this,sel,ptr)) return 1; // Otherwise, perform the default keyboard processing switch(MKUINT(event->code,event->state&(SHIFTMASK|CONTROLMASK|ALTMASK|METAMASK))){ case KEY_Tab: case KEY_Next: return handle(this,FXSEL(SEL_FOCUS_NEXT,0),ptr); case KEY_Prior: case KEY_ISO_Left_Tab: case MKUINT(KEY_ISO_Left_Tab,SHIFTMASK): case MKUINT(KEY_Tab,SHIFTMASK): return handle(this,FXSEL(SEL_FOCUS_PREV,0),ptr); case KEY_Up: case KEY_KP_Up: return handle(this,FXSEL(SEL_FOCUS_UP,0),ptr); case KEY_Down: case KEY_KP_Down: return handle(this,FXSEL(SEL_FOCUS_DOWN,0),ptr); case KEY_Left: case KEY_KP_Left: return handle(this,FXSEL(SEL_FOCUS_LEFT,0),ptr); case KEY_Right: case KEY_KP_Right: return handle(this,FXSEL(SEL_FOCUS_RIGHT,0),ptr); } return 0; } // Keyboard release long FXComposite::onKeyRelease(FXObject* sender,FXSelector sel,void* ptr){ FXTRACE((200,"%p->%s::onKeyRelease keysym=0x%04x state=%04x\n",this,getClassName(),((FXEvent*)ptr)->code,((FXEvent*)ptr)->state)); // Bounce to focus widget if(getFocus() && getFocus()->handle(sender,sel,ptr)) return 1; // Try target first if(isEnabled() && target && target->tryHandle(this,FXSEL(SEL_KEYRELEASE,message),ptr)) return 1; // Check the accelerators if(getAccelTable() && getAccelTable()->handle(this,sel,ptr)) return 1; return 0; } // Dispose of all the children FXComposite::~FXComposite(){ while(getFirst()){ delete getFirst(); } } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCondition.cpp000066400000000000000000000165711455751074500225060ustar00rootroot00000000000000/******************************************************************************** * * * C o n d i t i o n C l a s s * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXMutex.h" #include "FXCondition.h" /* Notes: - Condition variable. */ using namespace FX; /*******************************************************************************/ namespace FX { // Initialize condition FXCondition::FXCondition(){ #if defined(WIN32) && (_WIN32_WINNT >= 0x0600) // Vista or newer // If this fails on your machine, determine what value // of sizeof(pthread_cond_t) is supposed to be on your // machine and mail it to: jeroen@fox-toolkit.net!! FXASSERT_STATIC(sizeof(data)>=sizeof(CONDITION_VARIABLE)); InitializeConditionVariable((CONDITION_VARIABLE*)data); #elif defined(WIN32) // If this fails on your machine, determine what value // of sizeof(pthread_cond_t) is supposed to be on your // machine and mail it to: jeroen@fox-toolkit.net!! //FXTRACE((150,"sizeof(CRITICAL_SECTION)+sizeof(HANDLE)+sizeof(HANDLE)+sizeof(FXuval)=%d\n",sizeof(CRITICAL_SECTION)+sizeof(HANDLE)+sizeof(HANDLE)+sizeof(FXuval))); FXASSERT_STATIC(sizeof(data)>=sizeof(CRITICAL_SECTION)+sizeof(HANDLE)+sizeof(HANDLE)+sizeof(FXuval)); data[0]=(FXuval)CreateEvent(nullptr,0,0,nullptr); // Wakes one, autoreset data[1]=(FXuval)CreateEvent(nullptr,1,0,nullptr); // Wakes all, manual reset data[2]=0; // Blocked count InitializeCriticalSection((CRITICAL_SECTION*)&data[3]); // Critical section #else // If this fails on your machine, determine what value // of sizeof(pthread_cond_t) is supposed to be on your // machine and mail it to: jeroen@fox-toolkit.net!! //FXTRACE((150,"sizeof(pthread_cond_t)=%d\n",sizeof(pthread_cond_t))); FXASSERT_STATIC(sizeof(data)>=sizeof(pthread_cond_t)); pthread_cond_init((pthread_cond_t*)data,nullptr); #endif } // Wake up one single waiting thread void FXCondition::signal(){ #if defined(WIN32) && (_WIN32_WINNT >= 0x0600) // Vista or newer WakeConditionVariable((CONDITION_VARIABLE*)data); #elif defined(WIN32) EnterCriticalSection((CRITICAL_SECTION*)&data[3]); int blocked=(data[2]>0); LeaveCriticalSection((CRITICAL_SECTION*)&data[3]); if(blocked) SetEvent((HANDLE)data[0]); #else pthread_cond_signal((pthread_cond_t*)data); #endif } // Wake up all waiting threads void FXCondition::broadcast(){ #if defined(WIN32) && (_WIN32_WINNT >= 0x0600) // Vista or newer WakeAllConditionVariable((CONDITION_VARIABLE*)data); #elif defined(WIN32) EnterCriticalSection((CRITICAL_SECTION*)&data[3]); int blocked=(data[2]>0); LeaveCriticalSection((CRITICAL_SECTION*)&data[3]); if(blocked) SetEvent((HANDLE)data[1]); #else pthread_cond_broadcast((pthread_cond_t*)data); #endif } // Wait FXbool FXCondition::wait(FXMutex& mtx){ #if defined(WIN32) && (_WIN32_WINNT >= 0x0600) // Vista or newer return SleepConditionVariableCS((CONDITION_VARIABLE*)data,(CRITICAL_SECTION*)mtx.data,INFINITE)!=0; #elif defined(WIN32) EnterCriticalSection((CRITICAL_SECTION*)&data[3]); data[2]++; LeaveCriticalSection((CRITICAL_SECTION*)&data[3]); mtx.unlock(); DWORD result=WaitForMultipleObjects(2,(HANDLE*)data,0,INFINITE); EnterCriticalSection((CRITICAL_SECTION*)&data[3]); data[2]--; int last_waiter=(result==WAIT_OBJECT_0+1)&&(data[2]==0); // Unblocked by broadcast & no other blocked threads LeaveCriticalSection((CRITICAL_SECTION*)&data[3]); if(last_waiter) ResetEvent((HANDLE)data[1]); // Reset signal mtx.lock(); return (WAIT_OBJECT_0+0==result)||(result==WAIT_OBJECT_0+1); #else return pthread_cond_wait((pthread_cond_t*)data,(pthread_mutex_t*)mtx.data)==0; #endif } // Wait using single global mutex FXbool FXCondition::wait(FXMutex& mtx,FXTime nsec){ #if defined(WIN32) && (_WIN32_WINNT >= 0x0600) // Vista or newer if(0= 199309L) struct timespec ts; clock_gettime(CLOCK_REALTIME,&ts); ts.tv_sec=ts.tv_sec+(ts.tv_nsec+nsec)/1000000000; ts.tv_nsec=(ts.tv_nsec+nsec)%1000000000; return pthread_cond_timedwait((pthread_cond_t*)data,(pthread_mutex_t*)mtx.data,&ts)==0; #else struct timespec ts; struct timeval tv; gettimeofday(&tv,nullptr); tv.tv_usec*=1000; ts.tv_sec=tv.tv_sec+(tv.tv_usec+nsec)/1000000000; ts.tv_nsec=(tv.tv_usec+nsec)%1000000000; return pthread_cond_timedwait((pthread_cond_t*)data,(pthread_mutex_t*)mtx.data,&ts)==0; #endif } return pthread_cond_wait((pthread_cond_t*)data,(pthread_mutex_t*)mtx.data)==0; } return false; #endif } // Delete condition FXCondition::~FXCondition(){ #if defined(WIN32) && (_WIN32_WINNT >= 0x0600) // Vista or newer // NOP // #elif defined(WIN32) CloseHandle((HANDLE)data[0]); CloseHandle((HANDLE)data[1]); DeleteCriticalSection((CRITICAL_SECTION*)&data[3]); #else pthread_cond_destroy((pthread_cond_t*)data); #endif } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXConsole.cpp000066400000000000000000000302111455751074500221450ustar00rootroot00000000000000/******************************************************************************** * * * C o n s o l e W i d g e t * * * ********************************************************************************* * Copyright (C) 2006,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXElement.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXAccelTable.h" #include "FXFont.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FXScrollBar.h" #include "FXScrollArea.h" #include "FXConsole.h" /* To do: */ using namespace FX; /*******************************************************************************/ namespace FX { FXDEFMAP(FXConsole) FXConsoleMap[]={ FXMAPFUNC(SEL_PAINT,0,FXConsole::onPaint), FXMAPFUNC(SEL_COMMAND,FXConsole::ID_XXX,FXConsole::onXXX), }; // Object implementation FXIMPLEMENT(FXConsole,FXScrollArea,FXConsoleMap,ARRAYNUMBER(FXConsoleMap)) // Deserialization FXConsole::FXConsole(){ flags|=FLAG_ENABLED|FLAG_DROPTARGET; font=nullptr; margintop=0; marginbottom=0; marginleft=0; marginright=0; historylines=0; visiblelines=0; topline=0; vrows=0; vcols=0; textColor=0; selbackColor=0; seltextColor=0; cursorColor=0; } // Construct and init FXConsole::FXConsole(FXComposite *p,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb):FXScrollArea(p,opts,x,y,w,h){ flags|=FLAG_ENABLED|FLAG_DROPTARGET; defaultCursor=getApp()->getDefaultCursor(DEF_TEXT_CURSOR); dragCursor=getApp()->getDefaultCursor(DEF_TEXT_CURSOR); font=getApp()->getNormalFont(); textColor=getApp()->getForeColor(); selbackColor=getApp()->getSelbackColor(); seltextColor=getApp()->getSelforeColor(); cursorColor=getApp()->getForeColor(); target=tgt; message=sel; margintop=pt; marginbottom=pb; marginleft=pl; marginright=pr; historylines=100; visiblelines=1; topline=0; vrows=0; vcols=0; contents.no(historylines); style.no(historylines); for(int i=0; icreate(); recalc(); } // Detach window void FXConsole::detach(){ FXScrollArea::detach(); font->detach(); } // If window can have focus FXbool FXConsole::canFocus() const { return true; } // Get default width FXint FXConsole::getDefaultWidth(){ return 0getTextWidth("8",1) : FXScrollArea::getDefaultWidth(); } // Get default height FXint FXConsole::getDefaultHeight(){ return 0getFontHeight() : FXScrollArea::getDefaultHeight(); } // Move content void FXConsole::moveContents(FXint x,FXint y){ FXint dx=x-pos_x; FXint dy=y-pos_y; pos_x=x; pos_y=y; scroll(marginleft,margintop,getVisibleWidth()-marginleft-marginright,getVisibleHeight()-margintop-marginbottom,dx,dy); } // Determine minimum content width of scroll area FXint FXConsole::getContentWidth(){ return marginleft+marginright+1; // FIXME } // Determine minimum content height of scroll area FXint FXConsole::getContentHeight(){ return margintop+marginbottom+font->getFontHeight()*contents.no(); } // Recalculate layout void FXConsole::layout(){ FXint hh=font->getFontHeight(); FXint totallines; // Number of visible lines has changed visiblelines=(height-margintop-marginbottom+hh-1)/hh; if(visiblelines<1) visiblelines=1; // Total lines to buffer totallines=FXMAX(visiblelines,historylines); if(contents.no()!=totallines){ contents.no(totallines); // FIXME keep text insofar as possible! if(style.no()){ style.no(totallines); } } FXTRACE((100,"visiblelines=%d historylines=%d totallines=%d hh=%d space=%d\n",visiblelines,historylines,totallines,hh,height-margintop-marginbottom)); // Scrollbars adjusted placeScrollBars(width,height); // No more dirty flags&=~FLAG_DIRTY; } // Character width FXint FXConsole::charWidth(FXwchar ch,FXint col) const { if(ch<' '){ if(ch!='\t'){ return font->getCharWidth('#'); } return font->getCharWidth(' ')*(8-col%8); } return font->getCharWidth(ch); } // Determine style FXuint FXConsole::styleOf(FXint line,FXint index,FXint p,FXint c) const { FXuint s=0; FXchar ch; // Selected part of text // if(selstartpos<=p && p=contents[index].length()) return s; // Special style for control characters ch=contents[index][p]; // Get value from style buffer if(style.no()) s|=style[index][p]; // Tabs are just fill if(ch == '\t') return s; // Spaces are just fill if(ch == ' ') return s; // Newlines are just fill if(ch == '\n') return s; // Get special style for control codes if((FXuchar)ch < ' ') return s|STYLE_CONTROL|STYLE_TEXT; return s|STYLE_TEXT; } // Draw fragment of text in given style void FXConsole::drawTextFragment(FXDCWindow& dc,FXint x,FXint y,FXint,FXint,const FXchar *text,FXint n,FXuint sty) const { FXColor color=FXRGB(255,255,255); dc.setForeground(color); y+=font->getFontAscent(); dc.drawText(x,y,text,n); } // Draw text line with correct style void FXConsole::drawTextLine(FXDCWindow& dc,FXint line,FXint left,FXint right) const { FXint index=(topline+line)%contents.no(); FXint edge=pos_x+marginleft; FXint h=font->getFontHeight(); FXint y=pos_y+margintop+line*h; FXint x=0; FXint w=0; FXuint curstyle; FXuint newstyle; FXint cw,sp,ep,sc,ec; // Scan ahead till until we hit the end or the left edge for(sp=sc=0; sp=left) break; x+=cw; } // First style to display curstyle=styleOf(line,index,sp,sc); // Draw until we hit the end or the right edge for(ep=sp,ec=sc; ep=right) break; w+=cw; } // Draw unfinished fragment // fillBufferRect(dc,edge+x,y,w,h,curstyle); if(curstyle&STYLE_TEXT) drawTextFragment(dc,edge+x,y,w,h,&contents[index][sp],ep-sp,curstyle); x+=w; // Fill any left-overs outside of text if(x+edgegetFontHeight(); FXint yy=pos_y+margintop; FXint tl=(y-yy)/hh; FXint bl=(y+h-yy)/hh; FXint ln; if(tl<0) tl=0; if(bl>=contents.no()) bl=contents.no()-1; FXTRACE((100,"tl=%d bl=%d\n",tl,bl)); for(ln=tl; ln<=bl; ln++){ drawTextLine(dc,ln,x,x+w); } } // Draw the text long FXConsole::onPaint(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; FXDCWindow dc(this,event); dc.setFont(font); dc.setForeground(FXRGB(255,0,0)); dc.fillRectangle(event->rect.x,event->rect.y,event->rect.w,event->rect.h); // Viewport FXint vw=getVisibleWidth(); FXint vh=getVisibleHeight(); // Paint top margin if(event->rect.y<=margintop){ dc.setForeground(backColor); dc.fillRectangle(0,0,vw,margintop); } // Paint bottom margin if(event->rect.y+event->rect.h>=vh-marginbottom){ dc.setForeground(backColor); dc.fillRectangle(0,vh-marginbottom,vw,marginbottom); } // Paint left margin if(event->rect.xrect.x+event->rect.w>=vw-marginright){ dc.setForeground(backColor); dc.fillRectangle(vw-marginright,margintop,marginright,vh-margintop-marginbottom); } // Paint text dc.setClipRectangle(marginleft,margintop,vw-marginright-marginleft,vh-margintop-marginbottom); drawContents(dc,event->rect.x,event->rect.y,event->rect.w,event->rect.h); return 1; } // Draw the text long FXConsole::onXXX(FXObject*,FXSelector,void*){ return 1; } // Change top margin void FXConsole::setMarginTop(FXint mt){ if(margintop!=mt){ margintop=mt; recalc(); update(); } } // Change bottom margin void FXConsole::setMarginBottom(FXint mb){ if(marginbottom!=mb){ marginbottom=mb; recalc(); update(); } } // Change left margin void FXConsole::setMarginLeft(FXint ml){ if(marginleft!=ml){ marginleft=ml; recalc(); update(); } } // Change right margin void FXConsole::setMarginRight(FXint mr){ if(marginright!=mr){ marginright=mr; recalc(); update(); } } // Change history lines void FXConsole::setHistoryLines(FXint hl){ if(hl<1) hl=1; if(historylines!=hl){ historylines=hl; recalc(); update(); } } // Change number of visible rows void FXConsole::setVisibleRows(FXint rows){ if(rows<0) rows=0; if(vrows!=rows){ vrows=rows; recalc(); } } // Change number of visible columns void FXConsole::setVisibleColumns(FXint cols){ if(cols<0) cols=0; if(vcols!=cols){ vcols=cols; recalc(); } } // Change the font void FXConsole::setFont(FXFont* fnt){ if(!fnt){ fxerror("%s::setFont: NULL font specified.\n",getClassName()); } if(font!=fnt){ font=fnt; recalc(); update(); } } // Save object to stream void FXConsole::save(FXStream& store) const { FXScrollArea::save(store); store << margintop; store << marginbottom; store << marginleft; store << marginright; store << font; store << textColor; store << selbackColor; store << seltextColor; store << cursorColor; store << help; store << tip; } // Load object from stream void FXConsole::load(FXStream& store){ FXScrollArea::load(store); store >> margintop; store >> marginbottom; store >> marginleft; store >> marginright; store >> font; store >> textColor; store >> selbackColor; store >> seltextColor; store >> cursorColor; store >> help; store >> tip; } // Clean up FXConsole::~FXConsole(){ font=(FXFont*)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXCursor.cpp000066400000000000000000000335401455751074500220300ustar00rootroot00000000000000/******************************************************************************** * * * C u r s o r - O b j e c t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXElement.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXColors.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXVisual.h" #include "FXCursor.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXException.h" /* Notes: - Cursor size should be less than or equal to 32x32; limitation in Windows! - Need standard glyph for "invisible" cursor. - Keep hotx and hoty INSIDE the cursor glyph!! - Thanks Niall Douglas for the changes for alpha-blended cursors. */ #define TOPIC_CONSTRUCT 1000 #define TOPIC_CREATION 1001 #define DISPLAY(app) ((Display*)((app)->display)) #define DARKCOLOR(r,g,b) (((r)+(g)+(b))<382) #define CURSOR_STOCK 255 #define CURSOR_MASK (CURSOR_KEEP) using namespace FX; /*******************************************************************************/ namespace FX { extern FXbool fxloadXBM(FXColor*& data,const FXuchar *pixels,const FXuchar *mask,FXint width,FXint height); // Object implementation FXIMPLEMENT(FXCursor,FXId,nullptr,0) // Deserialization FXCursor::FXCursor(){ data=nullptr; width=0; height=0; hotx=0; hoty=0; options=CURSOR_ARROW; } // Make stock cursor FXCursor::FXCursor(FXApp* a,FXStockCursor curid):FXId(a){ FXTRACE((TOPIC_CONSTRUCT,"FXCursor::FXCursor %p\n",this)); data=nullptr; width=0; height=0; hotx=0; hoty=0; options=curid; } // Make cursor from source and mask FXCursor::FXCursor(FXApp* a,const FXuchar* src,const FXuchar* msk,FXint w,FXint h,FXint hx,FXint hy):FXId(a){ FXTRACE((TOPIC_CONSTRUCT,"FXCursor::FXCursor %p\n",this)); fxloadXBM(data,src,msk,w,h); width=w; height=h; hotx=FXCLAMP(0,hx,width-1); hoty=FXCLAMP(0,hy,height-1); options=CURSOR_OWNED; } // Make cursor from FXColor pixels FXCursor::FXCursor(FXApp* a,const FXColor *pix,FXint w,FXint h,FXint hx,FXint hy):FXId(a){ FXTRACE((TOPIC_CONSTRUCT,"FXCursor::FXCursor %p\n",this)); data=const_cast(pix); width=w; height=h; hotx=FXCLAMP(0,hx,width-1); hoty=FXCLAMP(0,hy,height-1); options=0; } // Return true if color cursor FXbool FXCursor::isColor() const { if(data){ for(FXint i=width*height-1; 0<=i; i--){ if(data[i]!=FXColors::Black && data[i]!=FXColors::White && FXALPHAVAL(data[i])!=0) return true; } } return false; } // Create cursor void FXCursor::create(){ if(!xid){ if(getApp()->isInitialized()){ FXTRACE((TOPIC_CREATION,"%s::create %p\n",getClassName(),this)); #if defined(WIN32) // WIN32 // Mapping to standard WIN32 cursors const LPCTSTR stock[]={IDC_ARROW,IDC_ARROW,IDC_ARROW,IDC_IBEAM,IDC_WAIT,IDC_CROSS,IDC_SIZENS,IDC_SIZEWE,IDC_SIZEALL}; FXASSERT_STATIC(sizeof(FXID)>=sizeof(HCURSOR)); // Building stock cursor if(options&CURSOR_STOCK){ FXTRACE((TOPIC_CREATION,"%s::create: stock cursor\n",getClassName())); xid=LoadCursor(nullptr,stock[options&CURSOR_STOCK]); } // Building custom cursor else{ // Should have data if(!data){ fxerror("%s::create: cursor needs pixel data.\n",getClassName()); } // Let's hope it's the correct size! if(width>32 || height>32){ fxerror("%s::create: cursor exceeds maximum size of 32x32 pixels\n",getClassName()); } // We have support for color cursors (WindowXP and up) and its a color cursor OSVERSIONINFO osvi={sizeof(OSVERSIONINFO)}; if(isColor() && GetVersionEx((OSVERSIONINFO*)&osvi) && (osvi.dwPlatformId==VER_PLATFORM_WIN32_NT) && (osvi.dwMajorVersion==5) && (osvi.dwMinorVersion>=0 || osvi.dwMajorVersion>5)){ const BITMAPV4HEADER bi={sizeof(BITMAPV4HEADER),32,-32,1,32,BI_BITFIELDS,0,0,0,0,0,0x00FF0000,0x0000FF00,0x000000FF,0xFF000000,0,{{0,0,0},{0,0,0},{0,0,0}},0,0,0}; FXTRACE((TOPIC_CREATION,"%s::create: custom color %dx%d cursor\n",getClassName(),width,height)); // Make a DIB void *imgdata=0; HDC hdc=GetDC(nullptr); HBITMAP himage=CreateDIBSection(hdc,(BITMAPINFO*)&bi,DIB_RGB_COLORS,&imgdata,nullptr,0); ReleaseDC(nullptr,hdc); if(!himage){ throw FXImageException("unable to create cursor"); } // Fill in data FXColor *imgptr=(FXColor*)imgdata; FXColor *srcimgptr=data; memset(imgdata,0,32*32*sizeof(FXColor)); for(FXint j=0; j=128){ tmpand[dstoffset+(i>>3)]&=~(128>>(i&7)); if(!DARKCOLOR(((FXuchar*)(data+srcoffset+i))[2],((FXuchar*)(data+srcoffset+i))[1],((FXuchar*)(data+srcoffset+i))[0])){ tmpxor[dstoffset+(i>>3)]|=(128>>(i&7)); } } } srcoffset+=width; dstoffset+=4; } xid=CreateCursor((HINSTANCE)(getApp()->display),hotx,hoty,32,32,tmpand,tmpxor); } } #else // X11 // Mapping to standard X11 cursors const FXuint stock[]={XC_left_ptr,XC_left_ptr,XC_right_ptr,XC_xterm,XC_watch,XC_crosshair,XC_sb_h_double_arrow,XC_sb_v_double_arrow,XC_fleur}; FXASSERT_STATIC(sizeof(FXID)>=sizeof(Cursor)); // Building stock cursor if(options&CURSOR_STOCK){ FXTRACE((TOPIC_CREATION,"%s::create: stock cursor\n",getClassName())); xid=XCreateFontCursor(DISPLAY(getApp()),stock[options&CURSOR_STOCK]); } // Building custom cursor else{ // Should have data if(!data){ fxerror("%s::create: cursor needs pixel data.\n",getClassName()); } // Let's hope it's the correct size! if(width>32 || height>32){ fxerror("%s::create: cursor exceeds maximum size of 32x32 pixels\n",getClassName()); } // We have support for color cursors and its a color cursor #ifdef HAVE_XCURSOR_H if(isColor() && XcursorSupportsARGB(DISPLAY(getApp()))){ FXTRACE((TOPIC_CREATION,"%s::create: custom color %dx%d cursor\n",getClassName(),width,height)); XcursorImage *image=XcursorImageCreate(width,height); image->xhot=hotx; image->yhot=hoty; for(FXint s=0; spixels)[s][0]=((FXuchar(*)[4])data)[s][3]; // A ((FXuchar(*)[4])image->pixels)[s][1]=((FXuchar(*)[4])data)[s][2]; // R ((FXuchar(*)[4])image->pixels)[s][2]=((FXuchar(*)[4])data)[s][1]; // G ((FXuchar(*)[4])image->pixels)[s][3]=((FXuchar(*)[4])data)[s][0]; // B #else image->pixels[s]=data[s]; #endif } xid=XcursorImageLoadCursor(DISPLAY(getApp()),image); XcursorImageDestroy(image); } // No support for color cursor or simple black/white cursor else{ #endif FXuchar shapebits[128]; FXuchar maskbits[128]; XColor color[2]; FXint dstbytes=(width+7)/8; FXint srcoffset=0; FXint dstoffset=0; FXTRACE((TOPIC_CREATION,"%s::create: custom b/w %dx%d cursor\n",getClassName(),width,height)); color[0].pixel=BlackPixel(DISPLAY(getApp()),DefaultScreen(DISPLAY(getApp()))); color[1].pixel=WhitePixel(DISPLAY(getApp()),DefaultScreen(DISPLAY(getApp()))); color[0].flags=DoRed|DoGreen|DoBlue; color[1].flags=DoRed|DoGreen|DoBlue; XQueryColors(DISPLAY(getApp()),DefaultColormap(DISPLAY(getApp()),DefaultScreen(DISPLAY(getApp()))),color,2); memset(shapebits,0,sizeof(shapebits)); memset(maskbits,0,sizeof(maskbits)); for(FXint j=0; j=128){ maskbits[dstoffset+(i>>3)]|=(1<<(i&7)); if(DARKCOLOR(((FXuchar*)(data+srcoffset+i))[2],((FXuchar*)(data+srcoffset+i))[1],((FXuchar*)(data+srcoffset+i))[0])) shapebits[dstoffset+(i>>3)]|=(1<<(i&7)); } } srcoffset+=width; dstoffset+=dstbytes; } Pixmap srcpix=XCreateBitmapFromData(DISPLAY(getApp()),XDefaultRootWindow(DISPLAY(getApp())),(char*)shapebits,width,height); if(!srcpix){ throw FXImageException("unable to create cursor"); } Pixmap mskpix=XCreateBitmapFromData(DISPLAY(getApp()),XDefaultRootWindow(DISPLAY(getApp())),(char*)maskbits,width,height); if(!mskpix){ throw FXImageException("unable to create cursor"); } xid=XCreatePixmapCursor(DISPLAY(getApp()),srcpix,mskpix,&color[0],&color[1],hotx,hoty); XFreePixmap(DISPLAY(getApp()),srcpix); XFreePixmap(DISPLAY(getApp()),mskpix); #ifdef HAVE_XCURSOR_H } #endif } #endif // Were we successful? if(!xid){ throw FXImageException("unable to create cursor"); } // Release pixel buffer if(!(options&CURSOR_KEEP)) release(); } } } // Detach cursor void FXCursor::detach(){ if(xid){ FXTRACE((TOPIC_CREATION,"%s::detach %p\n",getClassName(),this)); xid=0; } } // Release pixels buffer if it was owned void FXCursor::release(){ if(options&CURSOR_OWNED){ options&=~CURSOR_OWNED; freeElms(data); } data=nullptr; } // Destroy cursor void FXCursor::destroy(){ if(xid){ if(getApp()->isInitialized()){ FXTRACE((TOPIC_CREATION,"%s::destroy %p\n",getClassName(),this)); #if defined(WIN32) DestroyCursor((HCURSOR)xid); #else XFreeCursor(DISPLAY(getApp()),xid); #endif } xid=0; } } // Change options void FXCursor::setOptions(FXuint opts){ options=(options&~CURSOR_MASK) | (opts&CURSOR_MASK); } // Set pixel data ownership flag void FXCursor::setOwned(FXbool owned){ options^=((0-owned)^options)&CURSOR_OWNED; } // Get pixel ownership flag FXbool FXCursor::isOwned() const { return (options&CURSOR_OWNED)!=0; } // Save pixel data only FXbool FXCursor::savePixels(FXStream& store) const { FXuint size=width*height; store.save(data,size); return true; } // Load pixel data only FXbool FXCursor::loadPixels(FXStream& store){ FXuint size=width*height; if(options&CURSOR_OWNED){freeElms(data);} if(!allocElms(data,size)) return false; store.load(data,size); options|=CURSOR_OWNED; return true; } // Save cursor to stream void FXCursor::save(FXStream& store) const { FXuchar haspixels=(data!=nullptr); FXId::save(store); store << width << height << hotx << hoty; store << options; store << haspixels; if(haspixels) savePixels(store); } // Load cursor from stream void FXCursor::load(FXStream& store){ FXuchar haspixels; FXId::load(store); store >> width >> height >> hotx >> hoty; store >> options; store >> haspixels; if(haspixels) loadPixels(store); } // Clean up FXCursor::~FXCursor(){ FXTRACE((TOPIC_CONSTRUCT,"FXCursor::~FXCursor %p\n",this)); destroy(); if(options&CURSOR_OWNED){freeElms(data);} data=(FXColor *)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDC.cpp000066400000000000000000000264771455751074500210540ustar00rootroot00000000000000/******************************************************************************** * * * D e v i c e C o n t e x t B a s e C l a s s * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXVisual.h" #include "FXRegion.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXDC.h" /* Notes: - Major Contributions for Windows NT by Lyle Johnson. - This is not an abstract base class; rather, its a NULL-implementation, i.e. drawing commands to FXDC will go to into the bit bucket. - All functions in the DC are virtuals. - A DC is associated with a certain drawing surface, using: FXDC::begin(FXDrawable* drawable) and disassociated with: FXDC::end() - While associated with a certain surface, no other association may be made until after the association is broken. - One possible exception to the above rule COULD be made: repeated locks on the same surface might be OK; the surface should only be unlocked when an equal number of unlocks takes place [[[]][]]. - One DC object is created for all windows of the same depth and other attributes. - We like the OpenGL model of write-only, i.e. we [typically] don't read back any info from the DC. [Except stuff like device characteristics]. - We envision the following flavors of DC's: 1) A NULL context, in which all output goes to /dev/null 2) A Window context, in which output goes to a on- or off-screen window or pixmap. 3) A printer context, in which output is rendered e.g. as PostScript. - Implementations of DC's for specific target devices may cache various things such as patterns, stipples, colors, etc, so as to optimize performance. - Since DC's may be shared between windows, you should leave the DC in the same state as you found it before releasing it. - You acquire a DC by asking the drawable surface on which you want to draw for a DC. You receive a subclass of FXDC, and have no knowledge of device specific details, except as revealed by the basic FXDC API's. - After you're through with drawing, you should release the DC. - Motto: Nobody knows about any other DC that FXDC!!! The other ones are implementations, not directly accessible by any but a few select FOX implementation files. - In FOX, a FXDC is NOT a wrapper class:- we do NOT assume the O.S. provides its own DC abstraction:- hence all those virtuals. This also means it is possible to make your own, simply by subclassing FXDC! */ using namespace FX; /*******************************************************************************/ namespace FX { // Initialize nicely FXDC::FXDC(FXApp* a):app(a){ ctx=nullptr; font=nullptr; pattern=STIPPLE_NONE; stipple=nullptr; tile=nullptr; mask=nullptr; clip.x=0; clip.y=0; clip.w=32767; clip.h=32767; fg=0; bg=1; width=1; // SANDER FIX cap=CAP_BUTT; join=JOIN_MITER; style=LINE_SOLID; fill=FILL_SOLID; rule=RULE_EVEN_ODD; rop=BLT_SRC; fillElms(dashpat,4,32); dashpat[0]=4; dashpat[1]=4; dashlen=2; dashoff=0; tx=0; ty=0; cx=0; cy=0; } // Read back pixel FXColor FXDC::readPixel(FXint,FXint){ return FXRGBA(0,0,0,0); } // Draw a point in the current pen color void FXDC::drawPoint(FXint,FXint){ } // Draw points in the current pen color. // Each point's position is relative to the drawable's origin (as usual). void FXDC::drawPoints(const FXPoint*,FXuint){ } // Draw points in the current pen color. The first point's position is // relative to the drawable's origin, but each subsequent point's position // is relative to the previous point's position; each FXPoint defines // the relative coordinates. Think LOGO. void FXDC::drawPointsRel(const FXPoint*,FXuint){ } // Draw a line void FXDC::drawLine(FXint,FXint,FXint,FXint){ } // Draw multiple lines. All points are drawn connected. // Each point is specified relative to Drawable's origin. void FXDC::drawLines(const FXPoint*,FXuint){ } // Draw multiple lines. All points are drawn connected. // First point's coordinate is relative to drawable's origin, but // subsequent points' coordinates are relative to previous point. void FXDC::drawLinesRel(const FXPoint*,FXuint){ } // Draw unconnected line segments void FXDC::drawLineSegments(const FXSegment*,FXuint){ } // Draw unfilled rectangle void FXDC::drawRectangle(FXint,FXint,FXint,FXint){ } // Draw unfilled rectangles void FXDC::drawRectangles(const FXRectangle*,FXuint){ } // Draw unfilled rounded rectangle void FXDC::drawRoundRectangle(FXint,FXint,FXint,FXint,FXint,FXint){ } // Draw arc void FXDC::drawArc(FXint,FXint,FXint,FXint,FXint,FXint){ } // Draw arcs void FXDC::drawArcs(const FXArc*,FXuint){ } // Draw ellipse void FXDC::drawEllipse(FXint,FXint,FXint,FXint){ } // Filled rectangle void FXDC::fillRectangle(FXint,FXint,FXint,FXint){ } // Filled rectangles void FXDC::fillRectangles(const FXRectangle*,FXuint){ } // Filled rounded rectangle void FXDC::fillRoundRectangle(FXint,FXint,FXint,FXint,FXint,FXint){ } // Fill chord void FXDC::fillChord(FXint,FXint,FXint,FXint,FXint,FXint){ } // Fill chords void FXDC::fillChords(const FXArc*,FXuint){ } // Fill arc void FXDC::fillArc(FXint,FXint,FXint,FXint,FXint,FXint){ } // Fill arcs void FXDC::fillArcs(const FXArc*,FXuint){ } // Fill ellipse void FXDC::fillEllipse(FXint,FXint,FXint,FXint){ } // Filled simple polygon void FXDC::fillPolygon(const FXPoint*,FXuint){ } // Fill concave polygon void FXDC::fillConcavePolygon(const FXPoint*,FXuint){ } // Fill complex (self-intersecting) polygon void FXDC::fillComplexPolygon(const FXPoint*,FXuint){ } // Filled simple polygon with relative points void FXDC::fillPolygonRel(const FXPoint*,FXuint){ } // Fill concave polygon void FXDC::fillConcavePolygonRel(const FXPoint*,FXuint){ } // Fill complex (self-intersecting) polygon void FXDC::fillComplexPolygonRel(const FXPoint*,FXuint){ } // Fill vertical gradient rectangle void FXDC::fillVerticalGradient(FXint,FXint,FXint,FXint,FXColor,FXColor){ } // Fill horizontal gradient rectangle void FXDC::fillHorizontalGradient(FXint,FXint,FXint,FXint,FXColor,FXColor){ } // Draw string with base line starting at x, y void FXDC::drawText(FXint,FXint,const FXchar*,FXuint){ } // Draw string with base line starting at x, y void FXDC::drawText(FXint,FXint,const FXString&){ } // Draw text starting at x, y over filled background void FXDC::drawImageText(FXint,FXint,const FXchar*,FXuint){ } // Draw text starting at x, y over filled background void FXDC::drawImageText(FXint,FXint,const FXString&){ } // Draw area from source void FXDC::drawArea(const FXDrawable*,FXint,FXint,FXint,FXint,FXint,FXint){ } // Draw area stretched area from source void FXDC::drawArea(const FXDrawable*,FXint,FXint,FXint,FXint,FXint,FXint,FXint,FXint){ } // Draw image void FXDC::drawImage(const FXImage*,FXint,FXint){ } // Draw bitmap void FXDC::drawBitmap(const FXBitmap*,FXint,FXint){ } // Draw icon void FXDC::drawIcon(const FXIcon*,FXint,FXint){ } // Draw icon shaded void FXDC::drawIconShaded(const FXIcon*,FXint,FXint){ } // Draw icon sunken void FXDC::drawIconSunken(const FXIcon*,FXint,FXint){ } // Draw hashed box void FXDC::drawHashBox(FXint,FXint,FXint,FXint,FXint){ } // Draw focus rectangle void FXDC::drawFocusRectangle(FXint,FXint,FXint,FXint){ } // Set foreground drawing color (brush) void FXDC::setForeground(FXColor clr){ fg=clr; } // Set background drawing color (brush) void FXDC::setBackground(FXColor clr){ bg=clr; } // Set dash pattern void FXDC::setDashes(FXuint dashoffset,const FXuchar *dashpattern,FXuint dashlength){ FXuint len=0; if(dashlen<1 || dashlength>32){ fxerror("FXDC::setDashes: bad dashlength parameter.\n"); } for(FXuint i=0; i * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXAccelTable.h" #include "FXFont.h" #include "FXCursor.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXImage.h" #include "FXBitmap.h" #include "FXIcon.h" #include "FXWindow.h" #include "FXFrame.h" #include "FXComposite.h" #include "FXRootWindow.h" #include "FXShell.h" #include "FXRegion.h" #include "FXDCPrint.h" /* Notes: - Contributed by celer@ipro.lug.usf.edu. - Coordinate system starts in upper left corner, same as screen [which is different from the way PostScript normally does things]. - Implement the many missing functions. - Make it EPS compatible. - Allow user to override PostScript Functions. - Usage: psdc.beginPrint(paper desc); psdc.beginPage(pageno) .... drawing commands .... psdc.endPage(); psdc.endPrint(); - Perhaps feed into FXStream instead of FILE* this might be cool to drag and drop [E]PS into apps... - Do we still need the enum's in FXMediaSize if mediasize indexes into the registry database's paper size list? */ using namespace FX; /*******************************************************************************/ namespace FX { // Construct FXDCPrint::FXDCPrint(FXApp* a):FXDC(a){ font=getApp()->getNormalFont(); psout=nullptr; // FIXME use ctx for this mediawidth=0.0; mediaheight=0.0; mediabb.xmin=0.0; mediabb.xmax=0.0; mediabb.ymin=0.0; mediabb.ymax=0.0; docbb.xmin=0.0; docbb.xmax=0.0; docbb.ymin=0.0; docbb.ymax=0.0; pagebb.xmin=0.0; pagebb.xmax=0.0; pagebb.ymin=0.0; pagebb.ymax=0.0; pagecount=0; nchars=0; } // Destruct FXDCPrint::~FXDCPrint(){ } // Output hex number void FXDCPrint::outhex(FXuint hex){ if(!psout){ fxerror("FXDCPrint: no output device has been selected.\n"); } fprintf((FILE*)psout,"%02x",hex); if(++nchars>35){fputc('\n',(FILE*)psout);nchars=0;} } // Output formatted stuff void FXDCPrint::outf(const char* format,...){ va_list arguments; if(!psout){ fxerror("FXDCPrint: no output device has been selected.\n"); } va_start(arguments,format); vfprintf((FILE*)psout,format,arguments); va_end(arguments); } // Extends bounding box with point x,y void FXDCPrint::bbox(FXdouble x,FXdouble y){ if(x(mediawidth-mediabb.xmax); //mymax=static_cast(mediawidth-mediabb.xmin); mymin=mediabb.xmin; mymax=mediabb.xmax; mxrange=mxmax-mxmin; myrange=mymax-mymin; //xo=xi; //yo=mediawidth-yi; } else{ mxmin=mediabb.xmin; mxmax=mediabb.xmax; mymin=mediabb.ymin; mymax=mediabb.ymax; mxrange=mxmax-mxmin; myrange=mymax-mymin; } if(pyrange/pxrange<=myrange/mxrange){ // short/wide xo=mxmin+((xi-pxmin)/pxrange)*mxrange; yo=mymin+0.5*(myrange-pyrange*(mxrange/pxrange))+(pyrange-yi)*(mxrange/pxrange); } else{ // tall/thin xo=mxmin+0.5*(mxrange-pxrange*(myrange/pyrange))+xi*(myrange/pyrange); yo=mymin+((pyrange-yi)/pyrange)*myrange; } } // Generate print job prolog FXbool FXDCPrint::beginPrint(FXPrinter& job){ int numpages; Yr=792; //480 // This is essentially the height of the page(used so that the upper left hand corner is the origin) Xr=0; // Print to file if(job.flags&PRINT_DEST_FILE){ psout=fopen(job.name.text(),"w"); if(!psout) return false; } // Print to printer else{ char buffer[1000]; const FXchar* printercmd=getApp()->reg().readStringEntry("PRINTER","command","lpr -P%s -#%d"); sprintf(buffer,printercmd,job.name.text(),job.numcopies); #ifdef WIN32 #ifndef _WINDOWS #ifdef __CYGWIN__ psout=popen(buffer,"w"); #else psout=_popen(buffer,"w"); // _popen() available for console apps only! #endif #else psout=0; #endif #else psout=popen(buffer,"w"); #endif if(!psout) return false; } // Copy flags flags=job.flags; // This determines transformations mediawidth=job.mediawidth; mediaheight=job.mediaheight; // Set media bb; this determines transformation mediabb.xmin=job.leftmargin; mediabb.xmax=job.mediawidth-job.rightmargin; mediabb.ymin=job.bottommargin; mediabb.ymax=job.mediaheight-job.topmargin; // Initialize page and document bb from media bb pagebb=mediabb; docbb=mediabb; // Begin header outf("%%!PS-Adobe-3.0\n"); outf("%%%%Title: Print Job\n"); outf("%%%%Creator: FOX GUI Toolkit Application\n"); // Bounding box if(flags&PRINT_NOBOUNDS){ docbb.xmin= 1000000.0; docbb.xmax=-1000000.0; docbb.ymin= 1000000.0; docbb.ymax=-1000000.0; outf("%%%%BoundingBox: (atend)\n"); } else{ docbb.xmin=job.leftmargin; docbb.xmax=job.mediawidth-job.rightmargin; docbb.ymin=job.bottommargin; docbb.ymax=job.mediaheight-job.topmargin; outf("%%%%BoundingBox: %d %d %d %d\n",(int)docbb.xmin,(int)docbb.ymin,(int)docbb.xmax,(int)docbb.ymax); } setContentRange((int)docbb.xmin, (int)docbb.ymin, (int)docbb.xmax, (int)docbb.ymax); // Calculate number of pages numpages=0; if(flags&PRINT_PAGES_ODD){ numpages=1+(job.topage-job.frompage)/2; } else if(flags&PRINT_PAGES_EVEN){ numpages=1+(job.topage-job.frompage)/2; } else if(flags&PRINT_PAGES_RANGE){ numpages=1+job.topage-job.frompage; } // How many pages are coming if(numpages==0){ outf("%%%%Pages: (atend)\n"); } else{ outf("%%%%Pages: %d\n",numpages); } outf("%%%%DocumentFonts:\n"); outf("%%%%EndComments\n"); // Procedure definitions outf("%%%%BeginProlog\n\n\n"); // Various definitions outf("%% h w x y drawRect\n"); outf("/drawRect {\n\tnewpath moveto dup 0 rlineto exch dup 0 exch\n\trlineto exch neg 0 rlineto neg 0 exch rlineto\n\tclosepath stroke\n} def\n"); outf("%% h w x y fillRect\n"); outf("/fillRect {\n\tnewpath moveto dup 0 rlineto exch dup 0 exch\n\trlineto exch neg 0 rlineto neg 0 exch rlineto\n\tclosepath fill stroke\n} def\n"); outf("%% x y a b drawLine\n"); outf("/drawLine {\n\tnewpath moveto lineto stroke\n} def\n"); outf("%% x y ..... npoints drawLines\n"); outf("/drawLines {\n\t3 1 roll newpath moveto {lineto} repeat stroke\n} def\n"); outf("%% x y a b ..... nsegments drawSegmt\n"); outf("/drawSegmt {\n\tnewpath {\n\t\tmoveto lineto\n\t} repeat stroke\n} def\n"); outf("%% x y drawPoint\n"); outf("/drawPoint {\n\ttranslate 1 1 scale 8 8 1 [ 8 0 0 8 0 0 ] {<0000>} image\n} def\n"); outf("%% centerx centery startAngle endAngle radiusX radiusY drawArc\n"); outf("/drawArc {\n\tgsave dup 3 1 roll div dup 1 scale 6 -1 roll\n\texch div 5 1 roll 3 -2 roll arc stroke grestore\n} def\n"); outf("%% (string) x y height drawText\n"); outf("/drawText {\n\tgsave findfont exch scalefont setfont moveto\n\tshow grestore\n} def\n"); // Image operator outf("/bwproc\n"); outf(" { rgbproc\n"); outf(" dup length 3 idiv string 0 3 0\n"); outf(" 5 -1 roll\n"); outf(" { add 2 1 roll 1 sub dup 0 eq\n"); outf(" { pop 3 idiv 3 -1 roll dup 4 -1 roll dup\n"); outf(" 3 1 roll 5 -1 roll put 1 add 3 0 }\n"); outf(" { 2 1 roll } ifelse\n"); outf(" } forall\n"); outf(" pop pop pop\n"); outf("} def\n"); outf("systemdict /colorimage known not\n"); outf(" { /colorimage\n"); outf(" { pop pop /rgbproc exch def\n"); outf(" { bwproc } image\n"); outf(" } def\n"); outf("} if\n"); // For 3D outf("%% Color - r g b C\n"); outf("/C { setrgbcolor } bind def\n"); outf("%% Point - x y r g b P\n"); outf("/P { C newpath 0.5 0.0 360.0 arc closepath fill } bind def\n"); outf("%% Flat Shaded Line - x2 y2 x1 y1 r g b L\n"); outf("/L { C newpath moveto lineto stroke } bind def\n"); outf("%% Smooth-shaded line - x2 y2 r2 g2 b2 x1 y1 r1 g1 b1 SL\n"); outf("/SL {\n"); outf(" /b1 exch def\n"); outf(" /g1 exch def\n"); outf(" /r1 exch def\n"); outf(" /y1 exch def\n"); outf(" /x1 exch def\n"); outf(" /b2 exch def\n"); outf(" /g2 exch def\n"); outf(" /r2 exch def\n"); outf(" /y2 exch def\n"); outf(" /x2 exch def\n"); outf("\n"); outf(" b2 b1 sub abs 0.01 gt\n"); outf(" g2 g1 sub abs 0.005 gt\n"); outf(" r2 r1 sub abs 0.008 gt\n"); outf(" or or {\n"); outf(" /bm b1 b2 add 0.5 mul def\n"); outf(" /gm g1 g2 add 0.5 mul def\n"); outf(" /rm r1 r2 add 0.5 mul def\n"); outf(" /ym y1 y2 add 0.5 mul def\n"); outf(" /xm x1 x2 add 0.5 mul def\n"); outf("\n"); outf(" x1 y1 r1 g1 b1 xm ym rm gm bm SL\n"); outf(" xm ym rm gm bm x2 y2 r2 g2 b2 SL\n"); outf(" } {\n"); outf(" x1 y1 x2 y2 r1 g1 b1 L\n"); outf(" } ifelse\n"); outf("} bind def\n"); outf("%% Flat-shaded triangle - x3 y3 x2 y2 x1 y1 r g b T\n"); outf("/T { C newpath moveto lineto lineto closepath fill } bind def\n"); outf("%% Smooth-shaded triangle - x3 y3 r3 g3 b3 x2 y2 r2 g2 b2 x1 y1 r1 g1 b1 ST\n"); outf("/ST {\n"); outf(" /b1 exch def\n"); outf(" /g1 exch def\n"); outf(" /r1 exch def\n"); outf(" /y1 exch def\n"); outf(" /x1 exch def\n"); outf(" /b2 exch def\n"); outf(" /g2 exch def\n"); outf(" /r2 exch def\n"); outf(" /y2 exch def\n"); outf(" /x2 exch def\n"); outf(" /b3 exch def\n"); outf(" /g3 exch def\n"); outf(" /r3 exch def\n"); outf(" /y3 exch def\n"); outf(" /x3 exch def\n"); outf("\n"); outf(" b2 b1 sub abs 0.05 gt\n"); outf(" g2 g1 sub abs 0.017 gt\n"); outf(" r2 r1 sub abs 0.032 gt\n"); outf(" b3 b1 sub abs 0.05 gt\n"); outf(" g3 g1 sub abs 0.017 gt\n"); outf(" r3 r1 sub abs 0.032 gt\n"); outf(" b2 b3 sub abs 0.05 gt\n"); outf(" g2 g3 sub abs 0.017 gt\n"); outf(" r2 r3 sub abs 0.032 gt\n"); outf(" or or or or or or or or {\n"); outf(" /b12 b1 b2 add 0.5 mul def\n"); outf(" /g12 g1 g2 add 0.5 mul def\n"); outf(" /r12 r1 r2 add 0.5 mul def\n"); outf(" /y12 y1 y2 add 0.5 mul def\n"); outf(" /x12 x1 x2 add 0.5 mul def\n"); outf("\n"); outf(" /b13 b1 b3 add 0.5 mul def\n"); outf(" /g13 g1 g3 add 0.5 mul def\n"); outf(" /r13 r1 r3 add 0.5 mul def\n"); outf(" /y13 y1 y3 add 0.5 mul def\n"); outf(" /x13 x1 x3 add 0.5 mul def\n"); outf("\n"); outf(" /b32 b3 b2 add 0.5 mul def\n"); outf(" /g32 g3 g2 add 0.5 mul def\n"); outf(" /r32 r3 r2 add 0.5 mul def\n"); outf(" /y32 y3 y2 add 0.5 mul def\n"); outf(" /x32 x3 x2 add 0.5 mul def\n"); outf("\n"); outf(" x1 y1 r1 g1 b1 x12 y12 r12 g12 b12 x13 y13 r13 g13 b13\n"); outf(" x2 y2 r2 g2 b2 x12 y12 r12 g12 b12 x32 y32 r32 g32 b32\n"); outf(" x3 y3 r3 g3 b3 x32 y32 r32 g32 b32 x13 y13 r13 g13 b13\n"); outf(" x32 y32 r32 g32 b32 x12 y12 r12 g12 b12 x13 y13 r13 g13 b13\n"); outf(" ST ST ST ST\n"); outf(" } {\n"); outf(" x1 y1 x2 y2 x3 y3 r1 g1 b1 T\n"); outf(" } ifelse\n"); outf("} bind def\n"); // End of prologue outf("%%%%EndProlog\n"); // Document setup outf("%%%%BeginSetup\n"); outf("/#copies %d def\n",job.numcopies); outf("%%%%EndSetup\n"); // Keep track of #pages pagecount=0; return true; } // Generate print job epilog FXbool FXDCPrint::endPrint(){ outf("%%%%Trailer\n"); // We now know the bounding box if(flags&PRINT_NOBOUNDS){ if(docbb.xmingetFontDesc(fontdesc); outf("gsave /%s findfont\n",font->getName().text()); outf("%d scalefont\n",font->getSize()/10); outf("setfont\n"); outf("newpath\n%g %g moveto\n(",xx,yy); for(FXuint i=0; i(pxmax-pxmin); //FXfloat pyrange=static_cast(pymax-pymin); //FXfloat mxmin,mxmax,mymin,mymax,mxrange,myrange; /* if(flags&PRINT_LANDSCAPE){ mxmin=static_cast(mediabb.ymin); mxmax=static_cast(mediabb.ymax); //mymin=static_cast(mediawidth-mediabb.xmax); //mymax=static_cast(mediawidth-mediabb.xmin); mymin=static_cast(mediabb.xmin); mymax=static_cast(mediabb.xmax); mxrange=mxmax-mxmin; myrange=mymax-mymin; } else{ mxmin=static_cast(mediabb.xmin); mxmax=static_cast(mediabb.xmax); mymin=static_cast(mediabb.ymin); mymax=static_cast(mediabb.ymax); mxrange=mxmax-mxmin; myrange=mymax-mymin; } */ FXdouble fsize=0.1*font->getSize(); // Hack... // Account for dpi and scale up or down with graph... // Perhaps override screen resolution via registry // FXint screenres=getApp()->reg().readUnsignedEntry("SETTINGS","screenres",100); // Validate /* if(screenres<50) screenres=50; if(screenres>200) screenres=200; if(pyrange/pxrange<=myrange/mxrange){ // short/wide fsize *= (mxrange/pxrange)*(screenres/72.f); } else{// tall/thin fsize *= (myrange/pyrange)*(screenres/72.f); } */ FXString fname=font->getName(); if(fname=="times"){ fname="Times"; } else if(fname=="helvetica"){ fname="Helvetica"; } else if(fname=="courier"){ fname="Courier"; } else{ fname="Courier"; } if(font->getWeight()==FXFont::Bold){ if(font->getSlant()==FXFont::Italic){ fname+="-BoldItalic"; } else if(font->getSlant()==FXFont::Oblique){ fname+="-BoldOblique"; } else { fname+="-Bold"; } } else{ if(font->getSlant()==FXFont::Italic){ fname+="-Italic"; } else if(font->getSlant()==FXFont::Oblique){ fname+="-Oblique"; } } if(fname=="Times"){ fname+="-Roman"; } outf("(%s) %lg %lg %ld /%s drawText\n",string,xx,yy,(int)fsize,fname.text()); } // Draw string with base line starting at x, y void FXDCPrint::drawText(FXint x,FXint y,const FXString& string){ drawText(x,y,string.text(),string.length()); } // Draw string with base line starting at x, y over filled background void FXDCPrint::drawImageText(FXint,FXint,const FXchar*,FXuint){ } // Draw string with base line starting at x, y over filled background void FXDCPrint::drawImageText(FXint x,FXint y,const FXString& string){ drawImageText(x,y,string.text(),string.length()); } // Draw area from source void FXDCPrint::drawArea(const FXDrawable*,FXint,FXint,FXint,FXint,FXint,FXint){ } // Draw area stretched area from source void FXDCPrint::drawArea(const FXDrawable*,FXint,FXint,FXint,FXint,FXint,FXint,FXint,FXint){ } // Draw image // Contibuted by dwalz@cs.uni-magdeburg.de void FXDCPrint::drawImage(const FXImage *img,FXint dx,FXint dy){ FXuint opts=img->getOptions(); if(opts&IMAGE_OWNED){ FXint ww = img->getWidth(); FXint hh = img->getHeight(); FXuchar *buffer = (FXuchar*)img->getData(); outf("gsave\n"); outf("/picstr %d string def\n",ww*3); outf("%d %d translate\n",dx,hh-dy); outf("%d %d scale\n",ww,-hh); outf("%d %d %d\n",ww,hh,8); outf("[%d 0 0 -%d 0 %d]\n",ww,hh,hh); outf("{currentfile picstr readhexstring pop}\n"); outf("false %d\n",3); outf("colorimage\n"); int end=ww*hh*4; for(int i=0; i FXint FXSetup::DoNTPrint(FXPrinter& printInfo){ PDEVMODE pDevMode = nullptr; LONG lDevModeSize; HANDLE hDevMode = nullptr; HDC pDC = nullptr; DOCINFO docInfo; FXString msg = FXString("License setup wizard was unable to print,\nto printer:")+FXString(printInfo.name); FXint xOrigin; FXint yOrigin; FXint xSize; FXint ySize; lDevModeSize = DocumentProperties(nullptr,nullptr,printInfo.name,nullptr,nullptr,0); if(lDevModeSize > 0){ hDevMode = GlobalAlloc(GHND,lDevModeSize); pDevMode = (PDEVMODE)GlobalLock(hDevMode); DocumentProperties(nullptr,nullptr,printInfo.name,pDevMode,nullptr,DM_OUT_BUFFER); } pDC = CreateDC("WINSPOOL",printInfo.name,nullptr,pDevMode); if(pDC){ xOrigin = GetDeviceCaps(pDC,PHYSICALOFFSETX); yOrigin = GetDeviceCaps(pDC,PHYSICALOFFSETY); xSize = GetDeviceCaps(pDC,HORZRES); ySize = GetDeviceCaps(pDC,VERTRES); docInfo.cbSize = sizeof(DOCINFO); docInfo.lpszDocName = printInfo.name; docInfo.lpszOutput = nullptr; docInfo.lpszDatatype = nullptr; docInfo.fwType = 0; if(StartDoc(pDC,&docInfo)){ if(StartPage(pDC)){ FXint yPos = yOrigin+200; FXint x1Pos = xOrigin+50; FXint x2Pos = xOrigin+600; FXint n; TextOut(pDC,x1Pos,yPos,"Customer Information:",strlen("Customer Information:")); yPos = yPos+50; for(n=0; n < sizeof(machineInfo)/sizeof(char*);n++){ TextOut(pDC,x1Pos,yPos,machineInfo[n],strlen(machineInfo[n])); TextOut(pDC,x2Pos,yPos,lockID[n].text(),lockID[n].length()); yPos = yPos+50; } yPos = yPos+50; for(n=0; n < sizeof(CustomerInfo)/sizeof(char*);n++){ TextOut(pDC,x1Pos,yPos,CustomerInfo[n],strlen(CustomerInfo[n])); TextOut(pDC,x2Pos,yPos,fieldTexts[n].text(),fieldTexts[n].length()); yPos = yPos+50; } if(EndPage(pDC)){ if(EndDoc(pDC)){ GlobalFree((PDEVMODE)pDevMode); GlobalFree((HANDLE)hDevMode); DeleteDC(pDC); return 1; } } } else{ GlobalFree((PDEVMODE)pDevMode); GlobalFree((HANDLE)hDevMode); DeleteDC(pDC); FXMessageBox::error(this,MBOX_OK,"Print Error",msg.text()); return 0; } } else{ GlobalFree((PDEVMODE)pDevMode); GlobalFree((HANDLE)hDevMode); FXMessageBox::error(this,MBOX_OK,"Print Error",msg.text()); return 0; } } else{ GlobalFree((PDEVMODE)pDevMode); GlobalFree((HANDLE)hDevMode); FXMessageBox::error(this,MBOX_OK,"Print Error",msg.text()); return 0; } return 1; } */ } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDCWindow.cpp000066400000000000000000003072651455751074500222410ustar00rootroot00000000000000/******************************************************************************** * * * D e v i c e C o n t e x t F o r W i n d o w s a n d I m a g e s * * * ********************************************************************************* * Copyright (C) 1999,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxchar.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXObject.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXAccelTable.h" #include "FXVisual.h" #include "FXFont.h" #include "FXCursor.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXDrawable.h" #include "FXImage.h" #include "FXBitmap.h" #include "FXIcon.h" #include "FXWindow.h" #include "FXFrame.h" #include "FXComposite.h" #include "FXRootWindow.h" #include "FXShell.h" #include "FXRegion.h" #include "FXDCWindow.h" /* Notes: - Associate a DC with a surface before you begin using it: long SomeWidget::onPaint(FXObject*,FXSelector,void* ptr){ FXDCWindow dc(this,ptr); dc.drawLine(...); ... jadajadajada ... return 1; } The association is automatically broken when you go out of scope; the destructor of the FXDCWindow does this for you. - Optimizations: only perform style/attribute changes just before an actual drawing command takes place:- X-Windows apparently already does this; MS-Windows also? - We assume the following initial state: BLIT Function: BLT_SRC Foreground: black (0) Background: white (1) Line Width: 0 (meaning thinnest/fastest, no guaranteed pixelation) Cap Style: CAP_BUTT Join Style: JOIN_MITER Line Style: LINE_SOLID Fill Style: FILL_SOLID Fill Rule: RULE_EVEN_ODD Font: None Other Paremeters: To Be Determined - Under X-Windows, end() will restore the GC to the state above; flags keeps track of which changes have been made to minimize the necessary updating. - Under X, graphics_exposures should be OFF:- at least some SGI IRIX machines have broken implementations of graphics_exposures. - Try suggestions from "Kevin Radke" below: Sorry about the huge delay with this code. Work has been horribly busy and I wasn't able to dig up the CD with the original code. However, if I remember correctly (and this code snippet I found was from that test), I changed from using cosmetic pens to use geometric pens and specifying a line join style of PS_JOIN_BEVEL. I.E. LOGBRUSH logBrush; logBrush.lbStyle = BS_SOLID; logBrush.lbColor = RGB(red, green, blue); logBrush.lbHatch = HS_CROSS; // Not used // NYI Only solid lines are valid on Windows 95. style is ignored return ExtCreatePen (PS_GEOMETRIC | PS_JOIN_BEVEL | style, width, &logBrush, 0, NULL); this returns an HPEN. I remember this being significantly slower than cosmetic pens (under NT4) and at the time that I scrapped the code, and dealt with the drawing differences between X and Win32 at a higher level. This won't work on Win95/Win98 (without using paths), and after a closer look at the docs here it makes more sense to specify PS_ENDCAP_SQUARE to draw the last pixel instead of the line join style. I remember experimenting with both, so the code I found may have been in intermediate (unworking) version. In any case, it isn't too hard to experiment to see which has the required behavior. I've unfortunately been away from FOX work for a few months or I'd try it myself. - Device caps for DirectX: http://www.molybdenium.de/devicecaps/e_index.html */ using namespace FX; namespace FX { /******************************************************************************** * MS-Windows * ********************************************************************************/ #if defined(WIN32) // This one is not defined in the Cygwin header files #ifndef PS_JOIN_MASK #define PS_JOIN_MASK 0x0000F000 #endif // Construct for expose event painting FXDCWindow::FXDCWindow(FXDrawable* draw,FXEvent* event):FXDC(draw->getApp()),surface(nullptr),rect(0,0,0,0),devfg(0),devbg(0),oldpalette(nullptr),oldbrush(nullptr),oldpen(nullptr),needsNewBrush(false),needsNewPen(false),needsPath(false),needsClipReset(false){ begin(draw); rect.x=clip.x=event->rect.x; rect.y=clip.y=event->rect.y; rect.w=clip.w=event->rect.w; rect.h=clip.h=event->rect.h; HRGN hrgn=CreateRectRgn(clip.x,clip.y,clip.x+clip.w,clip.y+clip.h); SelectClipRgn((HDC)ctx,hrgn); DeleteObject(hrgn); } // Construct for normal painting FXDCWindow::FXDCWindow(FXDrawable* draw):FXDC(draw->getApp()),surface(nullptr),rect(0,0,0,0),devfg(0),devbg(0),oldpalette(nullptr),oldbrush(nullptr),oldpen(nullptr),needsNewBrush(false),needsNewPen(false),needsPath(false),needsClipReset(false){ begin(draw); } // Destruct FXDCWindow::~FXDCWindow(){ end(); } // Begin locks in a drawable surface void FXDCWindow::begin(FXDrawable *draw){ if(!draw){ fxerror("FXDCWindow::begin: NULL drawable.\n"); } if(!draw->id()){ fxerror("FXDCWindow::begin: drawable not created yet.\n"); } surface=draw; // Careful:- surface->id() can be HWND or HBITMAP depending on drawable ctx=draw->GetDC(); rect.x=clip.x=0; rect.y=clip.y=0; rect.w=clip.w=draw->getWidth(); rect.h=clip.h=draw->getHeight(); // Select and realize palette, if necessary if(surface->visual->colormap){ oldpalette=::SelectPalette((HDC)ctx,(HPALETTE)surface->visual->colormap,false); ::RealizePalette((HDC)ctx); } devfg=~0; devbg=0; // Create our default pen (black, solid, one pixel wide) LOGBRUSH lb; lb.lbStyle=BS_SOLID; lb.lbColor=PALETTERGB(0,0,0); lb.lbHatch=0; oldpen=::SelectObject((HDC)ctx,ExtCreatePen(PS_GEOMETRIC|PS_SOLID|PS_ENDCAP_FLAT|PS_JOIN_MITER,1,&lb,0,nullptr)); // Create our default brush (solid white, for fills) lb.lbStyle=BS_SOLID; lb.lbColor=PALETTERGB(255,255,255); lb.lbHatch=0; oldbrush=::SelectObject((HDC)ctx,CreateBrushIndirect(&lb)); // Text alignment ::SetTextAlign((HDC)ctx,TA_BASELINE|TA_LEFT); // Polygon fill mode ::SetPolyFillMode((HDC)ctx,ALTERNATE); // Reset flags needsNewBrush=false; needsNewPen=false; needsPath=false; needsClipReset=false; } // End unlocks the drawable surface void FXDCWindow::end(){ if(ctx){ ::DeleteObject(::SelectObject((HDC)ctx,oldpen)); ::DeleteObject(::SelectObject((HDC)ctx,oldbrush)); if(surface->visual->colormap){ SelectPalette((HDC)ctx,(HPALETTE)oldpalette,false); } surface->ReleaseDC((HDC)ctx); if(needsClipReset){ DWORD dwFlags=GetWindowLong((HWND)surface->id(),GWL_STYLE); SetWindowLong((HWND)surface->id(),GWL_STYLE,dwFlags|WS_CLIPCHILDREN); } ctx=nullptr; } surface=nullptr; } // Read back pixel FXColor FXDCWindow::readPixel(FXint x,FXint y){ FXColor color=FXRGBA(0,0,0,0); if(!surface){ fxerror("FXDCWindow::readPixel: DC not connected to drawable.\n"); } if(0<=x && 0<=y && xgetWidth() && ygetHeight()){ COLORREF clr=GetPixel((HDC)ctx,x,y); color=FXRGB(GetRValue(clr),GetGValue(clr),GetBValue(clr)); } return color; } // Draw pixel in current foreground color void FXDCWindow::drawPoint(FXint x,FXint y){ if(!surface){ fxerror("FXDCWindow::drawPoint: DC not connected to drawable.\n"); } ::SetPixel((HDC)ctx,x,y,devfg); } // Draw points void FXDCWindow::drawPoints(const FXPoint* points,FXuint npoints){ if(!surface){ fxerror("FXDCWindow::drawPoints: DC not connected to drawable.\n"); } for(FXuint i=0; iw) ew=w>>1; if(eh+eh>h) eh=h>>1; ::RoundRect((HDC)ctx,x,y,x+w+1,y+h+1,ew,eh); ::SelectObject((HDC)ctx,hbrush); } // Draw arc; angles in degrees*64, ang2 relative to ang1 // If angle is negative flip the start and end; also, if ang2 is zero, // don't draw anything at all (patch: Sander Jansen ). void FXDCWindow::drawArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2){ FXbool reversed=(ang2<0); if(!surface){ fxerror("FXDCWindow::drawArc: DC not connected to drawable.\n"); } if(ang2==0) return; if(needsNewPen) updatePen(); ang2+=ang1; w+=1; h+=1; int xStart=int(x+0.5*w+w*Math::cos(ang1*PI/(180.0*64.0))); int yStart=int(y+0.5*h-h*Math::sin(ang1*PI/(180.0*64.0))); int xEnd=int(x+0.5*w+w*Math::cos(ang2*PI/(180.0*64.0))); int yEnd=int(y+0.5*h-h*Math::sin(ang2*PI/(180.0*64.0))); if(needsPath){ ::BeginPath((HDC)ctx); } if(reversed) ::Arc((HDC)ctx,x,y,x+w,y+h,xEnd,yEnd,xStart,yStart); else ::Arc((HDC)ctx,x,y,x+w,y+h,xStart,yStart,xEnd,yEnd); if(needsPath){ ::EndPath((HDC)ctx); ::StrokePath((HDC)ctx); } } // Draw arcs void FXDCWindow::drawArcs(const FXArc* arcs,FXuint narcs){ if(!surface){ fxerror("FXDCWindow::drawArcs: DC not connected to drawable.\n"); } for(FXuint i=0; i>1),y+(h>>1),x+(w>>1),y+(h>>1)); if(needsPath){ ::EndPath((HDC)ctx); ::StrokePath((HDC)ctx); } } // Fill using currently selected ROP code void FXDCWindow::fillRectangle(FXint x,FXint y,FXint w,FXint h){ if(!surface){ fxerror("FXDCWindow::fillRectangle: DC not connected to drawable.\n"); } if(needsNewBrush) updateBrush(); HPEN hpen=(HPEN)::SelectObject((HDC)ctx,GetStockObject(NULL_PEN)); ::Rectangle((HDC)ctx,x,y,x+w+1,y+h+1); ::SelectObject((HDC)ctx,hpen); } // Fill using currently selected ROP code void FXDCWindow::fillRectangles(const FXRectangle* rectangles,FXuint nrectangles){ if(!surface){ fxerror("FXDCWindow::fillRectangles: DC not connected to drawable.\n"); } if(needsNewBrush) updateBrush(); HPEN hpen=(HPEN)::SelectObject((HDC)ctx,GetStockObject(NULL_PEN)); for(FXuint i=0; iw) ew=w>>1; if(eh+eh>h) eh=h>>1; ::RoundRect((HDC)ctx,x,y,x+w+1,y+h+1,ew,eh); ::SelectObject((HDC)ctx,hpen); } // Fill chord void FXDCWindow::fillChord(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2){ FXbool reversed=(ang2<0); if(!surface){ fxerror("FXDCWindow::fillChord: DC not connected to drawable.\n"); } if(ang2==0) return; if(needsNewBrush) updateBrush(); ang2+=ang1; w+=1; h+=1; int xStart=int(x+0.5*w+w*Math::cos(ang1*PI/(180.0*64.0))); int yStart=int(y+0.5*h-h*Math::sin(ang1*PI/(180.0*64.0))); int xEnd=int(x+0.5*w+w*Math::cos(ang2*PI/(180.0*64.0))); int yEnd=int(y+0.5*h-h*Math::sin(ang2*PI/(180.0*64.0))); HPEN hpen=(HPEN)::SelectObject((HDC)ctx,GetStockObject(NULL_PEN)); if(reversed) ::Chord((HDC)ctx,x,y,x+w,y+h,xEnd,yEnd,xStart,yStart); else ::Chord((HDC)ctx,x,y,x+w,y+h,xStart,yStart,xEnd,yEnd); ::SelectObject((HDC)ctx,hpen); } // Fill chords void FXDCWindow::fillChords(const FXArc* chords,FXuint nchords){ if(!surface){ fxerror("FXDCWindow::fillChords: DC not connected to drawable.\n"); } for(FXuint i=0; i). void FXDCWindow::fillArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2){ FXbool reversed=(ang2<0); if(!surface){ fxerror("FXDCWindow::fillArc: DC not connected to drawable.\n"); } if(ang2==0) return; if(needsNewBrush) updateBrush(); ang2+=ang1; w+=1; h+=1; int xStart=int(x+0.5*w+w*Math::cos(ang1*PI/(180.0*64.0))); int yStart=int(y+0.5*h-h*Math::sin(ang1*PI/(180.0*64.0))); int xEnd=int(x+0.5*w+w*Math::cos(ang2*PI/(180.0*64.0))); int yEnd=int(y+0.5*h-h*Math::sin(ang2*PI/(180.0*64.0))); HPEN hpen=(HPEN)::SelectObject((HDC)ctx,GetStockObject(NULL_PEN)); if(reversed) ::Pie((HDC)ctx,x,y,x+w,y+h,xEnd,yEnd,xStart,yStart); else ::Pie((HDC)ctx,x,y,x+w,y+h,xStart,yStart,xEnd,yEnd); ::SelectObject((HDC)ctx,hpen); } //Ellipse((HDC)ctx,x,y,x+w,y+h); // Fill arcs void FXDCWindow::fillArcs(const FXArc* arcs,FXuint narcs){ if(!surface){ fxerror("FXDCWindow::fillArcs: DC not connected to drawable.\n"); } for(FXuint i=0; i>1),y+(h>>1),x+(w>>1),y+(h>>1)); ::SelectObject((HDC)ctx,hpen); } // Filled simple polygon void FXDCWindow::fillPolygon(const FXPoint* points,FXuint npoints){ POINT pts[1360]; // Worst case limit according to MSDN if(!surface){ fxerror("FXDCWindow::fillPolygon: DC not connected to drawable.\n"); } if(npoints>=1360){ fxerror("FXDCWindow::fillPolygon: too many points.\n"); } if(needsNewBrush) updateBrush(); HPEN hpen=(HPEN)::SelectObject((HDC)ctx,GetStockObject(NULL_PEN)); for(FXuint i=0; i=1360){ fxerror("FXDCWindow::fillConcavePolygon: too many points.\n"); } if(needsNewBrush) updateBrush(); HPEN hpen=(HPEN)::SelectObject((HDC)ctx,GetStockObject(NULL_PEN)); for(FXuint i=0; i=1360){ fxerror("FXDCWindow::fillComplexPolygon: too many points.\n"); } if(needsNewBrush) updateBrush(); HPEN hpen=(HPEN)::SelectObject((HDC)ctx,GetStockObject(NULL_PEN)); for(FXuint i=0; i=1360){ fxerror("FXDCWindow::fillPolygonRel: too many points.\n"); } if(needsNewBrush) updateBrush(); HPEN hpen=(HPEN)::SelectObject((HDC)ctx,GetStockObject(NULL_PEN)); for(FXuint i=0; i=1360){ fxerror("FXDCWindow::fillConcavePolygonRel: too many points.\n"); } if(needsNewBrush) updateBrush(); HPEN hpen=(HPEN)::SelectObject((HDC)ctx,GetStockObject(NULL_PEN)); for(FXuint i=0; i=1360){ fxerror("FXDCWindow::fillComplexPolygonRel: too many points.\n"); } if(needsNewBrush) updateBrush(); HPEN hpen=(HPEN)::SelectObject((HDC)ctx,GetStockObject(NULL_PEN)); for(FXuint i=0; i= 1300) TRIVERTEX v[2]; GRADIENT_RECT r; r.UpperLeft=0; r.LowerRight=1; v[0].x=x; v[0].y=y; v[0].Red=FXREDVAL(top)<<8; v[0].Green=FXGREENVAL(top)<<8; v[0].Blue=FXBLUEVAL(top)<<8; v[0].Alpha=0xFF00; v[1].x=x+w; v[1].y=y+h; v[1].Red=FXREDVAL(bottom)<<8; v[1].Green=FXGREENVAL(bottom)<<8; v[1].Blue=FXBLUEVAL(bottom)<<8; v[1].Alpha=0xFF00; ::GradientFill((HDC)ctx,v,2,&r,1,GRADIENT_FILL_RECT_V); #endif } // Fill horizontal gradient rectangle void FXDCWindow::fillHorizontalGradient(FXint x,FXint y,FXint w,FXint h,FXColor left,FXColor right){ #if defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__CYGWIN__) || (_MSC_VER >= 1300) TRIVERTEX v[2]; GRADIENT_RECT r; r.UpperLeft=0; r.LowerRight=1; v[0].x=x; v[0].y=y; v[0].Red=FXREDVAL(left)<<8; v[0].Green=FXGREENVAL(left)<<8; v[0].Blue=FXBLUEVAL(left)<<8; v[0].Alpha=0xFF00; v[1].x=x+w; v[1].y=y+h; v[1].Red=FXREDVAL(right)<<8; v[1].Green=FXGREENVAL(right)<<8; v[1].Blue=FXBLUEVAL(right)<<8; v[1].Alpha=0xFF00; ::GradientFill((HDC)ctx,v,2,&r,1,GRADIENT_FILL_RECT_H); #endif } // Set text font void FXDCWindow::setFont(FXFont *fnt){ if(!surface){ fxerror("FXDCWindow::setFont: DC not connected to drawable.\n"); } if(!fnt || !fnt->id()){ fxerror("FXDCWindow::setFont: illegal or NULL font specified.\n"); } ::SelectObject((HDC)ctx,fnt->id()); font=fnt; } // Draw string with base line starting at x, y void FXDCWindow::drawText(FXint x,FXint y,const FXchar* string,FXuint length){ if(!surface){ fxerror("FXDCWindow::drawText: DC not connected to drawable.\n"); } if(!font){ fxerror("FXDCWindow::drawText: no font selected.\n"); } FXnchar sbuffer[4096]; FXint count=utf2ncs(sbuffer,string,ARRAYNUMBER(sbuffer),length); FXint bkmode=::SetBkMode((HDC)ctx,TRANSPARENT); ::TextOutW((HDC)ctx,x,y,sbuffer,count); ::SetBkMode((HDC)ctx,bkmode); } // Draw text starting at x, y over filled background void FXDCWindow::drawImageText(FXint x,FXint y,const FXchar* string,FXuint length){ if(!surface){ fxerror("FXDCWindow::drawImageText: DC not connected to drawable.\n"); } if(!font){ fxerror("FXDCWindow::drawImageText: no font selected.\n"); } FXnchar sbuffer[4096]; FXint count=utf2ncs(sbuffer,string,ARRAYNUMBER(sbuffer),length); FXint bkmode=::SetBkMode((HDC)ctx,OPAQUE); ::TextOutW((HDC)ctx,x,y,sbuffer,count); // RECT r; // r.left=clip.x; r.top=clip.y; r.right=clip.x+clip.w; r.bottom=clip.y+clip.h; // ExtTextOutW((HDC)ctx,x,y,ETO_OPAQUE|ETO_CLIPPED,&r,sbuffer,count,nullptr); ::SetBkMode((HDC)ctx,bkmode); } // Draw string with base line starting at x, y void FXDCWindow::drawText(FXint x,FXint y,const FXString& string){ drawText(x,y,string.text(),string.length()); } // Draw text starting at x, y over filled background void FXDCWindow::drawImageText(FXint x,FXint y,const FXString& string){ drawImageText(x,y,string.text(),string.length()); } // Draw area from source // Some of these ROP codes do not have names; the full list can be found in the MSDN docs // at Platform SDK/Reference/Appendixes/Win32 Appendixes/Raster Operation Codes/Ternary Raster Operations void FXDCWindow::drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy){ if(!surface){ fxerror("FXDCWindow::drawArea: DC not connected to drawable.\n"); } if(!source || !source->id()){ fxerror("FXDCWindow::drawArea: illegal source specified.\n"); } HDC shdc=(HDC)source->GetDC(); switch(rop){ case BLT_CLR: // D := 0 ::BitBlt((HDC)ctx,dx,dy,sw,sh,shdc,sx,sy,BLACKNESS); break; case BLT_SRC_AND_DST: // D := S & D ::BitBlt((HDC)ctx,dx,dy,sw,sh,shdc,sx,sy,SRCAND); break; case BLT_SRC_AND_NOT_DST: // D := S & ~D ::BitBlt((HDC)ctx,dx,dy,sw,sh,shdc,sx,sy,SRCERASE); break; case BLT_SRC: // D := S ::BitBlt((HDC)ctx,dx,dy,sw,sh,shdc,sx,sy,SRCCOPY); break; case BLT_NOT_SRC_AND_DST: // D := ~S & D ::BitBlt((HDC)ctx,dx,dy,sw,sh,shdc,sx,sy,0x220326); break; case BLT_DST: // D := D break; case BLT_SRC_XOR_DST: // D := S ^ D ::BitBlt((HDC)ctx,dx,dy,sw,sh,shdc,sx,sy,SRCINVERT); break; case BLT_SRC_OR_DST: // D := S | D ::BitBlt((HDC)ctx,dx,dy,sw,sh,shdc,sx,sy,SRCPAINT); break; case BLT_NOT_SRC_AND_NOT_DST: // D := ~S & ~D == D := ~(S | D) ::BitBlt((HDC)ctx,dx,dy,sw,sh,shdc,sx,sy,NOTSRCERASE); break; case BLT_NOT_SRC_XOR_DST: // D := ~S ^ D ::BitBlt((HDC)ctx,dx,dy,sw,sh,shdc,sx,sy,0x990066); // Not sure about this one break; case BLT_NOT_DST: // D := ~D ::BitBlt((HDC)ctx,dx,dy,sw,sh,shdc,sx,sy,DSTINVERT); break; case BLT_SRC_OR_NOT_DST: // D := S | ~D ::BitBlt((HDC)ctx,dx,dy,sw,sh,shdc,sx,sy,0xDD0228); break; case BLT_NOT_SRC: // D := ~S ::BitBlt((HDC)ctx,dx,dy,sw,sh,shdc,sx,sy,NOTSRCCOPY); break; case BLT_NOT_SRC_OR_DST: // D := ~S | D ::BitBlt((HDC)ctx,dx,dy,sw,sh,shdc,sx,sy,MERGEPAINT); break; case BLT_NOT_SRC_OR_NOT_DST: // D := ~S | ~D == ~(S & D) ::BitBlt((HDC)ctx,dx,dy,sw,sh,shdc,sx,sy,0x7700E6); break; case BLT_SET: // D := 1 ::BitBlt((HDC)ctx,dx,dy,sw,sh,shdc,sx,sy,WHITENESS); break; } source->ReleaseDC(shdc); } // Draw area stretched area from source void FXDCWindow::drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy,FXint dw,FXint dh){ if(!surface){ fxerror("FXDCWindow::drawArea: DC not connected to drawable.\n"); } if(!source || !source->id()){ fxerror("FXDCWindow::drawArea: illegal source specified.\n"); } HDC shdc=(HDC)source->GetDC(); switch(rop){ case BLT_CLR: // D := 0 ::StretchBlt((HDC)ctx,dx,dy,dw,dh,shdc,sx,sy,sw,sh,BLACKNESS); break; case BLT_SRC_AND_DST: // D := S & D ::StretchBlt((HDC)ctx,dx,dy,dw,dh,shdc,sx,sy,sw,sh,SRCAND); break; case BLT_SRC_AND_NOT_DST: // D := S & ~D ::StretchBlt((HDC)ctx,dx,dy,dw,dh,shdc,sx,sy,sw,sh,SRCERASE); break; case BLT_SRC: // D := S ::StretchBlt((HDC)ctx,dx,dy,dw,dh,shdc,sx,sy,sw,sh,SRCCOPY); break; case BLT_NOT_SRC_AND_DST: // D := ~S & D ::StretchBlt((HDC)ctx,dx,dy,dw,dh,shdc,sx,sy,sw,sh,0x220326); break; case BLT_DST: // D := D break; case BLT_SRC_XOR_DST: // D := S ^ D ::StretchBlt((HDC)ctx,dx,dy,dw,dh,shdc,sx,sy,sw,sh,SRCINVERT); break; case BLT_SRC_OR_DST: // D := S | D ::StretchBlt((HDC)ctx,dx,dy,dw,dh,shdc,sx,sy,sw,sh,SRCPAINT); break; case BLT_NOT_SRC_AND_NOT_DST: // D := ~S & ~D == D := ~(S | D) ::StretchBlt((HDC)ctx,dx,dy,dw,dh,shdc,sx,sy,sw,sh,NOTSRCERASE); break; case BLT_NOT_SRC_XOR_DST: // D := ~S ^ D ::StretchBlt((HDC)ctx,dx,dy,dw,dh,shdc,sx,sy,sw,sh,0x990066); // Not sure about this one break; case BLT_NOT_DST: // D := ~D ::StretchBlt((HDC)ctx,dx,dy,dw,dh,shdc,sx,sy,sw,sh,DSTINVERT); break; case BLT_SRC_OR_NOT_DST: // D := S | ~D ::StretchBlt((HDC)ctx,dx,dy,dw,dh,shdc,sx,sy,sw,sh,0xDD0228); break; case BLT_NOT_SRC: // D := ~S ::StretchBlt((HDC)ctx,dx,dy,dw,dh,shdc,sx,sy,sw,sh,NOTSRCCOPY); break; case BLT_NOT_SRC_OR_DST: // D := ~S | D ::StretchBlt((HDC)ctx,dx,dy,dw,dh,shdc,sx,sy,sw,sh,MERGEPAINT); break; case BLT_NOT_SRC_OR_NOT_DST: // D := ~S | ~D == ~(S & D) ::StretchBlt((HDC)ctx,dx,dy,dw,dh,shdc,sx,sy,sw,sh,0x7700E6); break; case BLT_SET: // D := 1 ::StretchBlt((HDC)ctx,dx,dy,dw,dh,shdc,sx,sy,sw,sh,WHITENESS); break; } source->ReleaseDC(shdc); } // Draw image void FXDCWindow::drawImage(const FXImage* image,FXint dx,FXint dy){ if(!surface){ fxerror("FXDCWindow::drawImage: DC not connected to drawable.\n"); } if(!image || !image->id()){ fxerror("FXDCWindow::drawImage: illegal image specified.\n"); } HDC dcMem=(HDC)image->GetDC(); switch(rop){ case BLT_CLR: // D := 0 ::BitBlt((HDC)ctx,dx,dy,image->width,image->height,dcMem,0,0,BLACKNESS); break; case BLT_SRC_AND_DST: // D := S & D ::BitBlt((HDC)ctx,dx,dy,image->width,image->height,dcMem,0,0,SRCAND); break; case BLT_SRC_AND_NOT_DST: // D := S & ~D ::BitBlt((HDC)ctx,dx,dy,image->width,image->height,dcMem,0,0,SRCERASE); break; case BLT_SRC: // D := S ::BitBlt((HDC)ctx,dx,dy,image->width,image->height,dcMem,0,0,SRCCOPY); break; case BLT_NOT_SRC_AND_DST: // D := ~S & D ::BitBlt((HDC)ctx,dx,dy,image->width,image->height,dcMem,0,0,0x220326); break; case BLT_DST: // D := D break; case BLT_SRC_XOR_DST: // D := S ^ D ::BitBlt((HDC)ctx,dx,dy,image->width,image->height,dcMem,0,0,SRCINVERT); break; case BLT_SRC_OR_DST: // D := S | D ::BitBlt((HDC)ctx,dx,dy,image->width,image->height,dcMem,0,0,SRCPAINT); break; case BLT_NOT_SRC_AND_NOT_DST: // D := ~S & ~D == D := ~(S | D) ::BitBlt((HDC)ctx,dx,dy,image->width,image->height,dcMem,0,0,NOTSRCERASE); break; case BLT_NOT_SRC_XOR_DST: // D := ~S ^ D ::BitBlt((HDC)ctx,dx,dy,image->width,image->height,dcMem,0,0,0x990066); // Not sure about this one break; case BLT_NOT_DST: // D := ~D ::BitBlt((HDC)ctx,dx,dy,image->width,image->height,dcMem,0,0,DSTINVERT); break; case BLT_SRC_OR_NOT_DST: // D := S | ~D ::BitBlt((HDC)ctx,dx,dy,image->width,image->height,dcMem,0,0,0xDD0228); break; case BLT_NOT_SRC: // D := ~S ::BitBlt((HDC)ctx,dx,dy,image->width,image->height,dcMem,0,0,NOTSRCCOPY); break; case BLT_NOT_SRC_OR_DST: // D := ~S | D ::BitBlt((HDC)ctx,dx,dy,image->width,image->height,dcMem,0,0,MERGEPAINT); break; case BLT_NOT_SRC_OR_NOT_DST: // D := ~S | ~D == ~(S & D) ::BitBlt((HDC)ctx,dx,dy,image->width,image->height,dcMem,0,0,0x7700E6); break; case BLT_SET: // D := 1 ::BitBlt((HDC)ctx,dx,dy,image->width,image->height,dcMem,0,0,WHITENESS); break; /* BLENDFUNCTION bf; bf.BlendOp=AC_SRC_OVER; // For RGBA image bf.BlendFlags=0; bf.SourceConstantAlpha=0xff; bf.AlphaFormat=AC_SRC_ALPHA; AlphaBlend((HDC)ctx,dx,dy,image->width,image->height,dcMem,0,0,image->width,image->height,bf); */ } image->ReleaseDC(dcMem); } // Draw bitmap void FXDCWindow::drawBitmap(const FXBitmap* bitmap,FXint dx,FXint dy) { if(!surface) fxerror("FXDCWindow::drawBitmap: DC not connected to drawable.\n"); if(!bitmap || !bitmap->id()) fxerror("FXDCWindow::drawBitmap: illegal bitmap specified.\n"); HDC dcMem=(HDC)bitmap->GetDC(); switch(rop){ case BLT_CLR: // D := 0 ::BitBlt((HDC)ctx,dx,dy,bitmap->width,bitmap->height,dcMem,0,0,BLACKNESS); break; case BLT_SRC_AND_DST: // D := S & D ::BitBlt((HDC)ctx,dx,dy,bitmap->width,bitmap->height,dcMem,0,0,SRCAND); break; case BLT_SRC_AND_NOT_DST: // D := S & ~D ::BitBlt((HDC)ctx,dx,dy,bitmap->width,bitmap->height,dcMem,0,0,SRCERASE); break; case BLT_SRC: // D := S ::BitBlt((HDC)ctx,dx,dy,bitmap->width,bitmap->height,dcMem,0,0,SRCCOPY); break; case BLT_NOT_SRC_AND_DST: // D := ~S & D ::BitBlt((HDC)ctx,dx,dy,bitmap->width,bitmap->height,dcMem,0,0,0x220326); break; case BLT_DST: // D := D break; case BLT_SRC_XOR_DST: // D := S ^ D ::BitBlt((HDC)ctx,dx,dy,bitmap->width,bitmap->height,dcMem,0,0,SRCINVERT); break; case BLT_SRC_OR_DST: // D := S | D ::BitBlt((HDC)ctx,dx,dy,bitmap->width,bitmap->height,dcMem,0,0,SRCPAINT); break; case BLT_NOT_SRC_AND_NOT_DST: // D := ~S & ~D == D := ~(S | D) ::BitBlt((HDC)ctx,dx,dy,bitmap->width,bitmap->height,dcMem,0,0,NOTSRCERASE); break; case BLT_NOT_SRC_XOR_DST: // D := ~S ^ D ::BitBlt((HDC)ctx,dx,dy,bitmap->width,bitmap->height,dcMem,0,0,0x990066); // Not sure about this one break; case BLT_NOT_DST: // D := ~D ::BitBlt((HDC)ctx,dx,dy,bitmap->width,bitmap->height,dcMem,0,0,DSTINVERT); break; case BLT_SRC_OR_NOT_DST: // D := S | ~D ::BitBlt((HDC)ctx,dx,dy,bitmap->width,bitmap->height,dcMem,0,0,0xDD0228); break; case BLT_NOT_SRC: // D := ~S ::BitBlt((HDC)ctx,dx,dy,bitmap->width,bitmap->height,dcMem,0,0,NOTSRCCOPY); break; case BLT_NOT_SRC_OR_DST: // D := ~S | D ::BitBlt((HDC)ctx,dx,dy,bitmap->width,bitmap->height,dcMem,0,0,MERGEPAINT); break; case BLT_NOT_SRC_OR_NOT_DST: // D := ~S | ~D == ~(S & D) ::BitBlt((HDC)ctx,dx,dy,bitmap->width,bitmap->height,dcMem,0,0,0x7700E6); break; case BLT_SET: // D := 1 ::BitBlt((HDC)ctx,dx,dy,bitmap->width,bitmap->height,dcMem,0,0,WHITENESS); break; } bitmap->ReleaseDC(dcMem); } // Draw icon void FXDCWindow::drawIcon(const FXIcon* icon,FXint dx,FXint dy){ if(!surface){ fxerror("FXDCWindow::drawIcon: DC not connected to drawable.\n"); } if(!icon || !icon->id() || !icon->shape){ fxerror("FXDCWindow::drawIcon: illegal icon specified.\n"); } HDC hdcsrc=(HDC)icon->GetDC(); if(icon->getOptions()&IMAGE_OPAQUE){ ::BitBlt((HDC)ctx,dx,dy,icon->getWidth(),icon->getHeight(),hdcsrc,0,0,SRCCOPY); } else{ HDC hdcmsk=::CreateCompatibleDC((HDC)ctx); HBITMAP holdbmp=(HBITMAP)::SelectObject(hdcmsk,(HBITMAP)icon->shape); COLORREF coldback=::SetBkColor((HDC)ctx,RGB(255,255,255)); COLORREF coldtext=::SetTextColor((HDC)ctx,RGB(0,0,0)); ::BitBlt((HDC)ctx,dx,dy,icon->getWidth(),icon->getHeight(),hdcmsk,0,0,SRCAND); ::BitBlt((HDC)ctx,dx,dy,icon->getWidth(),icon->getHeight(),hdcsrc,0,0,SRCPAINT); ::SelectObject(hdcmsk,holdbmp); ::DeleteDC(hdcmsk); ::SetBkColor((HDC)ctx,coldback); ::SetTextColor((HDC)ctx,coldtext); } icon->ReleaseDC(hdcsrc); } // This may be done faster, I suspect; but I'm tired of looking at this now; // at least it's correct as it stands.. void FXDCWindow::drawIconShaded(const FXIcon* icon,FXint dx,FXint dy){ if(!surface){ fxerror("FXDCWindow::drawIconShaded: DC not connected to drawable.\n"); } if(!icon || !icon->id() || !icon->shape){ fxerror("FXDCWindow::drawIconShaded: illegal icon specified.\n"); } FXColor selbackColor=getApp()->getSelbackColor(); HDC hdcsrc=(HDC)icon->GetDC(); HDC hdcmsk=::CreateCompatibleDC((HDC)ctx); // Set shape mask HBITMAP holdbmp=(HBITMAP)::SelectObject(hdcmsk,(HBITMAP)icon->shape); // Set colors COLORREF coldback=::SetBkColor((HDC)ctx,RGB(255,255,255)); COLORREF coldtext=::SetTextColor((HDC)ctx,RGB(0,0,0)); // Paint icon ::BitBlt((HDC)ctx,dx,dy,icon->getWidth(),icon->getHeight(),hdcmsk,0,0,SRCAND); ::BitBlt((HDC)ctx,dx,dy,icon->getWidth(),icon->getHeight(),hdcsrc,0,0,SRCPAINT); // Select brush HBRUSH hbrush=::CreatePatternBrush((HBITMAP)getApp()->stipples[STIPPLE_GRAY]); HBRUSH holdbrush=(HBRUSH)::SelectObject((HDC)ctx,hbrush); ::SetBrushOrgEx((HDC)ctx,dx,dy,nullptr); // Make black where pattern is 0 and shape is 0 [DPSoa] ::BitBlt((HDC)ctx,dx,dy,icon->getWidth(),icon->getHeight(),hdcmsk,0,0,0x00A803A9); // Set colors ::SetTextColor((HDC)ctx,RGB(FXREDVAL(selbackColor),FXGREENVAL(selbackColor),FXBLUEVAL(selbackColor))); ::SetBkColor((HDC)ctx,RGB(0,0,0)); // Make selbackcolor where pattern is 0 and shape is 0 [DPSoo] ::BitBlt((HDC)ctx,dx,dy,icon->getWidth(),icon->getHeight(),hdcmsk,0,0,0x00FE02A9); // Resetore ctx ::SelectObject(hdcmsk,holdbmp); ::DeleteDC(hdcmsk); ::SelectObject((HDC)ctx,holdbrush); ::DeleteObject(hbrush); ::SetBkColor((HDC)ctx,coldback); ::SetTextColor((HDC)ctx,coldtext); ::SetBrushOrgEx((HDC)ctx,tx,ty,nullptr); icon->ReleaseDC(hdcsrc); } // Draw a sunken or etched-in icon. void FXDCWindow::drawIconSunken(const FXIcon* icon,FXint dx,FXint dy){ if(!surface){ fxerror("FXDCWindow::drawIconSunken: DC not connected to drawable.\n"); } if(!icon || !icon->id() || !icon->shape){ fxerror("FXDCWindow::drawIconSunken: illegal icon specified.\n"); } FXColor shadowColor=getApp()->getShadowColor(); FXColor hiliteColor=getApp()->getHiliteColor(); HDC hdcsrc=(HDC)icon->GetDC(); HDC hdcmono=::CreateCompatibleDC((HDC)ctx); // Set etch mask HBITMAP holdbmp=(HBITMAP)::SelectObject(hdcmono,(HBITMAP)icon->etch); // Set colors COLORREF coldback=::SetBkColor((HDC)ctx,RGB(255,255,255)); COLORREF coldtext=::SetTextColor((HDC)ctx,RGB(0,0,0)); // While brush colors apply to the pattern HBRUSH hbrhilite=::CreateSolidBrush(RGB(FXREDVAL(hiliteColor),FXGREENVAL(hiliteColor),FXBLUEVAL(hiliteColor))); HBRUSH holdbrush=(HBRUSH)::SelectObject((HDC)ctx,hbrhilite); // BitBlt the black bits in the monochrome bitmap into highlight colors // in the destination DC (offset a bit). This BitBlt(), and the next one, // use an unnamed raster op (0xB8074a) whose effect is D := ((D ^ P) & S) ^ P. // Or at least I think it is ;) The code = PSDPxax, so that's correct JVZ ::BitBlt((HDC)ctx,dx+1,dy+1,icon->getWidth(),icon->getHeight(),hdcmono,0,0,0xB8074A); HBRUSH hbrshadow=::CreateSolidBrush(RGB(FXREDVAL(shadowColor),FXGREENVAL(shadowColor),FXBLUEVAL(shadowColor))); ::SelectObject((HDC)ctx,hbrshadow); // Now BitBlt the black bits in the monochrome bitmap into the // shadow color on the destination DC. ::BitBlt((HDC)ctx,dx,dy,icon->getWidth(),icon->getHeight(),hdcmono,0,0,0xB8074A); // Resetore ctx ::SelectObject(hdcmono,holdbmp); ::DeleteDC(hdcmono); ::SelectObject((HDC)ctx,holdbrush); ::DeleteObject(hbrhilite); ::DeleteObject(hbrshadow); ::SetBkColor((HDC)ctx,coldback); ::SetTextColor((HDC)ctx,coldtext); icon->ReleaseDC(hdcsrc); } // Draw hash box void FXDCWindow::drawHashBox(FXint x,FXint y,FXint w,FXint h,FXint b){ if(!surface){ fxerror("FXDCWindow::drawHashBox: DC not connected to drawable.\n"); } HBRUSH hbrush=::CreatePatternBrush((HBITMAP)getApp()->stipples[STIPPLE_GRAY]); HBRUSH holdbrush=(HBRUSH)::SelectObject((HDC)ctx,hbrush); COLORREF coldback=::SetBkColor((HDC)ctx,RGB(255,255,255)); COLORREF coldtext=::SetTextColor((HDC)ctx,RGB(0,0,0)); ::PatBlt((HDC)ctx,x,y,w-b,b,PATINVERT); ::PatBlt((HDC)ctx,x+w-b,y,b,h-b,PATINVERT); ::PatBlt((HDC)ctx,x+b,y+h-b,w-b,b,PATINVERT); ::PatBlt((HDC)ctx,x,y+b,b,h-b,PATINVERT); ::SelectObject((HDC)ctx,holdbrush); ::DeleteObject(hbrush); ::SetBkColor((HDC)ctx,coldback); ::SetTextColor((HDC)ctx,coldtext); } // Draw focus rectangle void FXDCWindow::drawFocusRectangle(FXint x,FXint y,FXint w,FXint h){ if(!surface){ fxerror("FXDCWindow::drawFocusRectangle: DC not connected to drawable.\n"); } HBRUSH hbrush=::CreatePatternBrush((HBITMAP)getApp()->stipples[STIPPLE_GRAY]); HBRUSH holdbrush=(HBRUSH)::SelectObject((HDC)ctx,hbrush); COLORREF coldback=::SetBkColor((HDC)ctx,RGB(255,255,255)); COLORREF coldtext=::SetTextColor((HDC)ctx,RGB(0,0,0)); ::SetBrushOrgEx((HDC)ctx,x,y,nullptr); ::PatBlt((HDC)ctx,x,y,w-1,1,PATINVERT); ::PatBlt((HDC)ctx,x+w-1,y,1,h-1,PATINVERT); ::PatBlt((HDC)ctx,x+1,y+h-1,w-1,1,PATINVERT); ::PatBlt((HDC)ctx,x,y+1,1,h-1,PATINVERT); ::SelectObject((HDC)ctx,holdbrush); ::DeleteObject(hbrush); ::SetBkColor((HDC)ctx,coldback); ::SetTextColor((HDC)ctx,coldtext); ::SetBrushOrgEx((HDC)ctx,tx,ty,nullptr); } static DWORD FXStipplePattern2Hatch(FXStipplePattern pat){ switch(pat){ case STIPPLE_HORZ: return HS_HORIZONTAL; case STIPPLE_VERT: return HS_VERTICAL; case STIPPLE_CROSS: return HS_CROSS; case STIPPLE_DIAG: return HS_BDIAGONAL; case STIPPLE_REVDIAG: return HS_FDIAGONAL; case STIPPLE_CROSSDIAG: return HS_DIAGCROSS; default: return HS_CROSS; } } void FXDCWindow::updatePen(){ DWORD dashes[32]; DWORD penstyle,i; LOGBRUSH lb; // Setup brush of this pen switch(fill){ case FILL_SOLID: lb.lbStyle=BS_SOLID; lb.lbColor=devfg; lb.lbHatch=0; break; case FILL_TILED: lb.lbStyle=BS_SOLID; lb.lbColor=devfg; lb.lbHatch=0; break; case FILL_STIPPLED: if(stipple){ lb.lbStyle=BS_PATTERN; lb.lbColor=devfg; lb.lbHatch=(FXuval)stipple->id(); // This should be a HBITMAP } else if(pattern>=STIPPLE_0 && pattern<=STIPPLE_16){ lb.lbStyle=BS_PATTERN; lb.lbColor=devfg; lb.lbHatch=(FXuval)getApp()->stipples[pattern]; } else{ lb.lbStyle=BS_HATCHED; lb.lbColor=devfg; lb.lbHatch=FXStipplePattern2Hatch(pattern); } break; case FILL_OPAQUESTIPPLED: if(stipple){ lb.lbStyle=BS_PATTERN; lb.lbColor=devfg; lb.lbHatch=(FXuval)stipple->id(); // This should be a HBITMAP } else if(pattern>=STIPPLE_0 && pattern<=STIPPLE_16){ lb.lbStyle=BS_PATTERN; lb.lbColor=devfg; lb.lbHatch=(FXuval)getApp()->stipples[pattern]; } else{ lb.lbStyle=BS_HATCHED; lb.lbColor=devfg; lb.lbHatch=FXStipplePattern2Hatch(pattern); } break; } penstyle=0; // Cap style if(cap==CAP_ROUND) penstyle|=PS_JOIN_ROUND; else if(cap==CAP_PROJECTING) penstyle|=PS_ENDCAP_SQUARE; else penstyle|=PS_ENDCAP_FLAT; // Join style if(join==JOIN_MITER) penstyle|=PS_JOIN_MITER; else if(join==JOIN_ROUND) penstyle|=PS_JOIN_ROUND; else penstyle|=PS_JOIN_BEVEL; // Kind of pen //if(width<=1 && fill==FILL_SOLID) // penstyle|=PS_COSMETIC; //else penstyle|=PS_GEOMETRIC; // Line style if(style==LINE_SOLID){ penstyle|=PS_SOLID; ::DeleteObject(::SelectObject((HDC)ctx,::ExtCreatePen(penstyle,width,&lb,0,nullptr))); } else if(dashoff==0 && dashlen==2 && dashpat[0]==1 && dashpat[1]==1){ penstyle|=PS_DOT; ::DeleteObject(::SelectObject((HDC)ctx,::ExtCreatePen(penstyle,width,&lb,0,nullptr))); } else if(dashoff==0 && dashlen==2 && dashpat[0]==3 && dashpat[1]==1){ penstyle|=PS_DASH; ::DeleteObject(::SelectObject((HDC)ctx,::ExtCreatePen(penstyle,width,&lb,0,nullptr))); } else if(dashoff==0 && dashlen==4 && dashpat[0]==3 && dashpat[1]==1 && dashpat[2]==1 && dashpat[3]==1){ penstyle|=PS_DASHDOT; ::DeleteObject(::SelectObject((HDC)ctx,::ExtCreatePen(penstyle,width,&lb,0,nullptr))); } else if(dashoff==0 && dashlen==6 && dashpat[0]==3 && dashpat[1]==1 && dashpat[2]==1 && dashpat[3]==1 && dashpat[4]==1 && dashpat[5]==1){ penstyle|=PS_DASHDOTDOT; ::DeleteObject(::SelectObject((HDC)ctx,::ExtCreatePen(penstyle,width,&lb,0,nullptr))); } else{ penstyle|=PS_USERSTYLE; for(i=0; i1); needsNewPen=false; } void FXDCWindow::updateBrush(){ LOGBRUSH lb; switch(fill){ case FILL_SOLID: lb.lbStyle=BS_SOLID; lb.lbColor=devfg; lb.lbHatch=0; ::DeleteObject(::SelectObject((HDC)ctx,::CreateBrushIndirect(&lb))); break; case FILL_TILED: if(tile){ ::DeleteObject(::SelectObject((HDC)ctx,::CreatePatternBrush((HBITMAP)tile->id()))); } else{ lb.lbStyle=BS_SOLID; lb.lbColor=devfg; lb.lbHatch=0; ::DeleteObject(::SelectObject((HDC)ctx,::CreateBrushIndirect(&lb))); } break; case FILL_STIPPLED: if(stipple){ lb.lbStyle=BS_PATTERN; lb.lbColor=devfg; lb.lbHatch=(FXuval)stipple->id(); // This should be a HBITMAP } else if(pattern>=STIPPLE_0 && pattern<=STIPPLE_16){ lb.lbStyle=BS_PATTERN; lb.lbColor=devfg; lb.lbHatch=(FXuval)getApp()->stipples[pattern]; } else{ lb.lbStyle=BS_HATCHED; lb.lbColor=devfg; lb.lbHatch=FXStipplePattern2Hatch(pattern); } ::DeleteObject(::SelectObject((HDC)ctx,::CreateBrushIndirect(&lb))); break; case FILL_OPAQUESTIPPLED: if(stipple){ lb.lbStyle=BS_PATTERN; lb.lbColor=devfg; lb.lbHatch=(FXuval)stipple->id(); // This should be a HBITMAP } else if(pattern>=STIPPLE_0 && pattern<=STIPPLE_16){ lb.lbStyle=BS_PATTERN; lb.lbColor=devfg; lb.lbHatch=(FXuval)getApp()->stipples[pattern]; } else{ lb.lbStyle=BS_HATCHED; lb.lbColor=devfg; lb.lbHatch=FXStipplePattern2Hatch(pattern); } ::DeleteObject(::SelectObject((HDC)ctx,::CreateBrushIndirect(&lb))); break; } if(fill==FILL_STIPPLED){ ::SetBkMode((HDC)ctx,TRANSPARENT); // Alas, only works for BS_HATCHED... } else{ ::SetBkMode((HDC)ctx,OPAQUE); } if(fill!=FILL_SOLID){ ::SetBrushOrgEx((HDC)ctx,tx,ty,nullptr); } needsNewBrush=false; } // Set foreground color void FXDCWindow::setForeground(FXColor clr){ if(!surface){ fxerror("FXDCWindow::setForeground: DC not connected to drawable.\n"); } devfg=surface->visual->getPixel(clr); needsNewPen=true; needsNewBrush=true; ::SetTextColor((HDC)ctx,devfg); fg=clr; } // Set background color void FXDCWindow::setBackground(FXColor clr){ if(!surface){ fxerror("FXDCWindow::setBackground: DC not connected to drawable.\n"); } devbg=surface->visual->getPixel(clr); ::SetBkColor((HDC)ctx,devbg); bg=clr; } // Set dash pattern (for the LINE_ONOFF_DASH line style) void FXDCWindow::setDashes(FXuint dashoffset,const FXuchar *dashpattern,FXuint dashlength){ FXuint len=0; if(!surface){ fxerror("FXDCWindow::setDashes: DC not connected to drawable.\n"); } if(dashlen<1 || dashlength>32){ fxerror("FXDCWindow::setDashes: bad dashlength parameter.\n"); } for(FXuint i=0; iid()){ fxerror("FXDCWindow::setTile: illegal image specified.\n"); } tile=image; tx=dx; ty=dy; } // Set stipple pattern void FXDCWindow::setStipple(FXBitmap* bitmap,FXint dx,FXint dy){ if(!surface){ fxerror("FXDCWindow::setStipple: DC not connected to drawable.\n"); } if(!bitmap || !bitmap->id()){ fxerror("FXDCWindow::setStipple: illegal image specified.\n"); } stipple=bitmap; pattern=STIPPLE_NONE; needsNewBrush=true; needsNewPen=true; tx=dx; ty=dy; } void FXDCWindow::setStipple(FXStipplePattern pat,FXint dx,FXint dy){ if(!surface){ fxerror("FXDCWindow::setStipple: DC not connected to drawable.\n"); } stipple=nullptr; pattern=pat; needsNewBrush=true; needsNewPen=true; tx=dx; ty=dy; } // Patch from "Dimitris Servis" // The new clip rectangle should be the intersect of the region // boundary rectangle and the paint rectangle. // Another patch from Ivan Markov to delete // the region which must be disposed off explicitly. void FXDCWindow::setClipRegion(const FXRegion& region){ if(!surface){ fxerror("FXDCWindow::setClipRegion: DC not connected to drawable.\n"); } FXRectangle rectangle=region.bounds(); clip.x=FXMAX(rectangle.x,rect.x); clip.y=FXMAX(rectangle.y,rect.y); clip.w=FXMIN(rectangle.x+rectangle.w,rect.x+rect.w)-clip.x; clip.h=FXMIN(rectangle.y+rectangle.h,rect.y+rect.h)-clip.y; if(clip.w<=0) clip.w=0; if(clip.h<=0) clip.h=0; HRGN hrgn=::CreateRectRgn(clip.x,clip.y,clip.x+clip.w,clip.y+clip.h); ::CombineRgn(hrgn,hrgn,(HRGN)region.region,RGN_AND); ::SelectClipRgn((HDC)ctx,hrgn); ::DeleteObject(hrgn); } // Set clip rectangle void FXDCWindow::setClipRectangle(FXint x,FXint y,FXint w,FXint h){ if(!surface){ fxerror("FXDCWindow::setClipRectangle: DC not connected to drawable.\n"); } clip.x=FXMAX(x,rect.x); clip.y=FXMAX(y,rect.y); clip.w=FXMIN(x+w,rect.x+rect.w)-clip.x; clip.h=FXMIN(y+h,rect.y+rect.h)-clip.y; if(clip.w<=0) clip.w=0; if(clip.h<=0) clip.h=0; HRGN hrgn=::CreateRectRgn(clip.x,clip.y,clip.x+clip.w,clip.y+clip.h); ::SelectClipRgn((HDC)ctx,hrgn); ::DeleteObject(hrgn); } // Set clip rectangle void FXDCWindow::setClipRectangle(const FXRectangle& rectangle){ if(!surface){ fxerror("FXDCWindow::setClipRectangle: DC not connected to drawable.\n"); } clip.x=FXMAX(rectangle.x,rect.x); clip.y=FXMAX(rectangle.y,rect.y); clip.w=FXMIN(rectangle.x+rectangle.w,rect.x+rect.w)-clip.x; clip.h=FXMIN(rectangle.y+rectangle.h,rect.y+rect.h)-clip.y; if(clip.w<=0) clip.w=0; if(clip.h<=0) clip.h=0; HRGN hrgn=::CreateRectRgn(clip.x,clip.y,clip.x+clip.w,clip.y+clip.h); ::SelectClipRgn((HDC)ctx,hrgn); ::DeleteObject(hrgn); } // Clear clip rectangle void FXDCWindow::clearClipRectangle(){ if(!surface){ fxerror("FXDCWindow::clearClipRectangle: DC not connected to drawable.\n"); } clip=rect; HRGN hrgn=::CreateRectRgn(clip.x,clip.y,clip.x+clip.w,clip.y+clip.h); ::SelectClipRgn((HDC)ctx,hrgn); ::DeleteObject(hrgn); } // Set clip mask void FXDCWindow::setClipMask(FXBitmap* bitmap,FXint dx,FXint dy){ if(!surface){ fxerror("FXDCWindow::setClipMask: DC not connected to drawable.\n"); } if(!bitmap || !bitmap->id()){ fxerror("FXDCWindow::setClipMask: illegal mask specified.\n"); } FXASSERT(false); mask=bitmap; cx=dx; cy=dy; } // Clear clip mask void FXDCWindow::clearClipMask(){ if(!surface){ fxerror("FXDCWindow::clearClipMask: DC not connected to drawable.\n"); } FXASSERT(false); mask=nullptr; cx=0; cy=0; } // Window will clip against child windows void FXDCWindow::clipChildren(FXbool yes){ if(!surface){ fxerror("FXDCWindow::clipChildren: window has not yet been created.\n"); } DWORD dwFlags=::GetWindowLong((HWND)surface->id(),GWL_STYLE); HPEN hPen; HBRUSH hBrush; HFONT hFont; COLORREF textcolor; COLORREF backcolor; FXint fillmode; if(yes){ if(!(dwFlags&WS_CLIPCHILDREN)){ if((HWND)surface->id()!=GetDesktopWindow()){ hPen=(HPEN)SelectObject((HDC)ctx,::GetStockObject(NULL_PEN)); hBrush=(HBRUSH)::SelectObject((HDC)ctx,::GetStockObject(NULL_BRUSH)); hFont=(HFONT)::SelectObject((HDC)ctx,::GetStockObject(SYSTEM_FONT)); textcolor=::GetTextColor((HDC)ctx); backcolor=::GetBkColor((HDC)ctx); fillmode=::GetPolyFillMode((HDC)ctx); ::ReleaseDC((HWND)surface->id(),(HDC)ctx); ::SetWindowLong((HWND)surface->id(),GWL_STYLE,dwFlags|WS_CLIPCHILDREN); ctx=::GetDC((HWND)surface->id()); ::SelectObject((HDC)ctx,hFont); ::SelectObject((HDC)ctx,hPen); ::SelectObject((HDC)ctx,hBrush); if(surface->visual->colormap){ ::SelectPalette((HDC)ctx,(HPALETTE)surface->visual->colormap,false); ::RealizePalette((HDC)ctx); } ::SetTextAlign((HDC)ctx,TA_BASELINE|TA_LEFT); ::SetTextColor((HDC)ctx,textcolor); ::SetBkColor((HDC)ctx,backcolor); ::SetPolyFillMode((HDC)ctx,fillmode); needsClipReset=false; } } } else{ if(dwFlags&WS_CLIPCHILDREN){ if((HWND)surface->id()!=GetDesktopWindow()){ hPen=(HPEN)::SelectObject((HDC)ctx,::GetStockObject(NULL_PEN)); hBrush=(HBRUSH)::SelectObject((HDC)ctx,::GetStockObject(NULL_BRUSH)); hFont=(HFONT)::SelectObject((HDC)ctx,::GetStockObject(SYSTEM_FONT)); textcolor=::GetTextColor((HDC)ctx); backcolor=::GetBkColor((HDC)ctx); fillmode=::GetPolyFillMode((HDC)ctx); ::ReleaseDC((HWND)surface->id(),(HDC)ctx); ::SetWindowLong((HWND)surface->id(),GWL_STYLE,dwFlags&~WS_CLIPCHILDREN); ctx=::GetDC((HWND)surface->id()); ::SelectObject((HDC)ctx,hFont); ::SelectObject((HDC)ctx,hPen); ::SelectObject((HDC)ctx,hBrush); if(surface->visual->colormap){ ::SelectPalette((HDC)ctx,(HPALETTE)surface->visual->colormap,false); ::RealizePalette((HDC)ctx); } ::SetTextAlign((HDC)ctx,TA_BASELINE|TA_LEFT); ::SetTextColor((HDC)ctx,textcolor); ::SetBkColor((HDC)ctx,backcolor); ::SetPolyFillMode((HDC)ctx,fillmode); needsClipReset=true; } } } } /******************************************************************************** * X-Windows * ********************************************************************************/ #else // Construct for expose event painting FXDCWindow::FXDCWindow(FXDrawable* draw,FXEvent* event):FXDC(draw->getApp()),surface(nullptr),rect(0,0,0,0),devfg(0),devbg(0){ #ifdef HAVE_XFT_H xftDraw=nullptr; #endif begin(draw); rect.x=clip.x=event->rect.x; rect.y=clip.y=event->rect.y; rect.w=clip.w=event->rect.w; rect.h=clip.h=event->rect.h; XSetClipRectangles((Display*)getApp()->getDisplay(),(GC)ctx,0,0,(XRectangle*)(void*)&clip,1,Unsorted); #ifdef HAVE_XFT_H XftDrawSetClipRectangles((XftDraw*)xftDraw,0,0,(XRectangle*)(void*)&clip,1); #endif flags|=GCClipMask; } // Construct for normal painting FXDCWindow::FXDCWindow(FXDrawable* draw):FXDC(draw->getApp()),surface(nullptr),rect(0,0,0,0),devfg(0),devbg(0){ #ifdef HAVE_XFT_H xftDraw=nullptr; #endif begin(draw); } // Destruct FXDCWindow::~FXDCWindow(){ end(); } // Begin locks in a drawable surface void FXDCWindow::begin(FXDrawable *draw){ if(!draw){ fxerror("FXDCWindow::begin: NULL drawable.\n"); } if(!draw->id()){ fxerror("FXDCWindow::begin: drawable not created yet.\n"); } surface=draw; rect.x=clip.x=0; rect.y=clip.y=0; rect.w=clip.w=draw->getWidth(); rect.h=clip.h=draw->getHeight(); devfg=~0; devbg=0; ctx=surface->visual->gc; flags=0; #ifdef HAVE_XFT_H xftDraw=(void*)XftDrawCreate((Display*)getApp()->getDisplay(),(Drawable)surface->id(),(Visual*)surface->visual->visual,(Colormap)surface->visual->colormap); #endif } // End unlock the drawable surface; restore it void FXDCWindow::end(){ if(flags){ XGCValues gcv; if(flags&GCFunction) gcv.function=BLT_SRC; if(flags&GCForeground) gcv.foreground=BlackPixel((Display*)getApp()->getDisplay(),DefaultScreen((Display*)getApp()->getDisplay())); if(flags&GCBackground) gcv.background=WhitePixel((Display*)getApp()->getDisplay(),DefaultScreen((Display*)getApp()->getDisplay())); if(flags&GCLineWidth) gcv.line_width=0; if(flags&GCCapStyle) gcv.cap_style=CAP_BUTT; if(flags&GCJoinStyle) gcv.join_style=JOIN_MITER; if(flags&GCLineStyle) gcv.line_style=LINE_SOLID; if(flags&GCFillStyle) gcv.fill_style=FILL_SOLID; if(flags&GCStipple) gcv.stipple=getApp()->stipples[STIPPLE_WHITE]; // Needed for IRIX6.4 bug workaround! if(flags&GCFillRule) gcv.fill_rule=RULE_EVEN_ODD; #ifndef HAVE_XFT_H if(flags&GCFont) gcv.font=getApp()->getNormalFont()->id(); #endif if(flags&GCClipMask) gcv.clip_mask=None; if(flags&GCClipXOrigin) gcv.clip_x_origin=0; if(flags&GCClipYOrigin) gcv.clip_y_origin=0; if(flags&GCDashOffset) gcv.dash_offset=0; if(flags&GCDashList) gcv.dashes=4; if(flags&GCTileStipXOrigin) gcv.ts_x_origin=0; if(flags&GCTileStipYOrigin) gcv.ts_y_origin=0; if(flags&GCGraphicsExposures) gcv.graphics_exposures=True; if(flags&GCSubwindowMode) gcv.subwindow_mode=ClipByChildren; XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,flags,&gcv); flags=0; } surface=nullptr; #ifdef HAVE_XFT_H if(xftDraw){ XftDrawDestroy((XftDraw*)xftDraw); xftDraw=nullptr; } #endif } // Read back pixel FXColor FXDCWindow::readPixel(FXint x,FXint y){ FXColor color=FXRGBA(0,0,0,0); if(!surface){ fxerror("FXDCWindow::readPixel: DC not connected to drawable.\n"); } if(0<=x && 0<=y && xgetWidth() && ygetHeight()){ XImage* xim=XGetImage((Display*)getApp()->getDisplay(),surface->id(),x,y,1,1,AllPlanes,ZPixmap); if(xim && xim->data){ color=surface->visual->getColor(XGetPixel(xim,0,0)); XDestroyImage(xim); } } return color; } // Draw point void FXDCWindow::drawPoint(FXint x,FXint y){ if(!surface){ fxerror("FXDCWindow::drawPoint: DC not connected to drawable.\n"); } XDrawPoint((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,x,y); } // Draw points void FXDCWindow::drawPoints(const FXPoint* points,FXuint npoints){ if(!surface){ fxerror("FXDCWindow::drawPoints: DC not connected to drawable.\n"); } XDrawPoints((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,const_cast((const XPoint*)points),npoints,CoordModeOrigin); } // Draw points relative void FXDCWindow::drawPointsRel(const FXPoint* points,FXuint npoints){ if(!surface){ fxerror("FXDCWindow::drawPointsRel: DC not connected to drawable.\n"); } XDrawPoints((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,const_cast((const XPoint*)points),npoints,CoordModePrevious); } // Draw line void FXDCWindow::drawLine(FXint x1,FXint y1,FXint x2,FXint y2){ if(!surface){ fxerror("FXDCWindow::drawLine: DC not connected to drawable.\n"); } XDrawLine((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,x1,y1,x2,y2); } // Draw lines void FXDCWindow::drawLines(const FXPoint* points,FXuint npoints){ if(!surface){ fxerror("FXDCWindow::drawLines: DC not connected to drawable.\n"); } XDrawLines((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,const_cast((const XPoint*)points),npoints,CoordModeOrigin); } // Draw lines relative void FXDCWindow::drawLinesRel(const FXPoint* points,FXuint npoints){ if(!surface){ fxerror("FXDCWindow::drawLinesRel: DC not connected to drawable.\n"); } XDrawLines((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,const_cast((const XPoint*)points),npoints,CoordModePrevious); } // Draw line segments void FXDCWindow::drawLineSegments(const FXSegment* segments,FXuint nsegments){ if(!surface){ fxerror("FXDCWindow::drawLineSegments: DC not connected to drawable.\n"); } XDrawSegments((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,const_cast((const XSegment*)segments),nsegments); } // Draw rectangle void FXDCWindow::drawRectangle(FXint x,FXint y,FXint w,FXint h){ if(!surface){ fxerror("FXDCWindow::drawRectangle: DC not connected to drawable.\n"); } XDrawRectangle((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,x,y,w,h); } // Draw rectangles void FXDCWindow::drawRectangles(const FXRectangle* rectangles,FXuint nrectangles){ if(!surface){ fxerror("FXDCWindow::drawRectangles: DC not connected to drawable.\n"); } XDrawRectangles((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,const_cast((const XRectangle*)rectangles),nrectangles); } // Draw round rectangle void FXDCWindow::drawRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh){ XArc arcs[4]; XSegment segs[4]; XGCValues gcv; if(!surface){ fxerror("FXDCWindow::drawRoundRectangle: DC not connected to drawable.\n"); } if(ew+ew>w) ew=w>>1; if(eh+eh>h) eh=h>>1; arcs[0].x=arcs[2].x=x; arcs[0].y=arcs[1].y=y; arcs[1].x=arcs[3].x=x+w-(ew<<1); arcs[2].y=arcs[3].y=y+h-(eh<<1); arcs[0].width=arcs[1].width=arcs[2].width=arcs[3].width=ew<<1; arcs[0].height=arcs[1].height=arcs[2].height=arcs[3].height=eh<<1; arcs[0].angle1=5760; arcs[0].angle2=5760; arcs[1].angle1=0; arcs[1].angle2=5760; arcs[2].angle1=11520; arcs[2].angle2=5760; arcs[3].angle1=17280; arcs[3].angle2=5760; segs[0].x1=segs[1].x1=x+ew; segs[0].x2=segs[1].x2=x+w-ew; segs[0].y1=segs[0].y2=y; segs[1].y1=segs[1].y2=y+h; segs[2].x1=segs[2].x2=x; segs[3].x1=segs[3].x2=x+w; segs[2].y1=segs[3].y1=y+eh; segs[2].y2=segs[3].y2=y+h-eh; gcv.cap_style=CapButt; XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCCapStyle,&gcv); XDrawArcs((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,arcs,4); XDrawSegments((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,segs,4); gcv.cap_style=cap; XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCCapStyle,&gcv); } // Draw arc void FXDCWindow::drawArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2){ if(!surface){ fxerror("FXDCWindow::drawArc: DC not connected to drawable.\n"); } XDrawArc((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,x,y,w,h,ang1,ang2); } // Draw arcs void FXDCWindow::drawArcs(const FXArc* arcs,FXuint narcs){ if(!surface){ fxerror("FXDCWindow::drawArcs: DC not connected to drawable.\n"); } XDrawArcs((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,const_cast((const XArc*)arcs),narcs); } // Draw ellipse void FXDCWindow::drawEllipse(FXint x,FXint y,FXint w,FXint h){ if(!surface){ fxerror("FXDCWindow::drawEllipse: DC not connected to drawable.\n"); } XDrawArc((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,x,y,w,h,0,23040); } // Fill rectangle void FXDCWindow::fillRectangle(FXint x,FXint y,FXint w,FXint h){ if(!surface){ fxerror("FXDCWindow::fillRectangle: DC not connected to drawable.\n"); } XFillRectangle((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,x,y,w,h); } // Fill rectangles void FXDCWindow::fillRectangles(const FXRectangle* rectangles,FXuint nrectangles){ if(!surface){ fxerror("FXDCWindow::fillRectangles: DC not connected to drawable.\n"); } XFillRectangles((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,const_cast((const XRectangle*)rectangles),nrectangles); } // Fill rounded rectangle void FXDCWindow::fillRoundRectangle(FXint x,FXint y,FXint w,FXint h,FXint ew,FXint eh){ XArc arcs[4]; XRectangle recs[3]; if(!surface){ fxerror("FXDCWindow::fillRoundRectangle: DC not connected to drawable.\n"); } if(ew+ew>w) ew=w>>1; if(eh+eh>h) eh=h>>1; arcs[0].x=arcs[2].x=x; arcs[0].y=arcs[1].y=y; arcs[1].x=arcs[3].x=x+w-(ew<<1); arcs[2].y=arcs[3].y=y+h-(eh<<1); arcs[0].width=arcs[1].width=arcs[2].width=arcs[3].width=ew<<1; arcs[0].height=arcs[1].height=arcs[2].height=arcs[3].height=eh<<1; arcs[0].angle1=5760; arcs[0].angle2=5760; arcs[1].angle1=0; arcs[1].angle2=5760; arcs[2].angle1=11520; arcs[2].angle2=5760; arcs[3].angle1=17280; arcs[3].angle2=5760; recs[0].x=recs[2].x=x+ew; recs[0].width=recs[2].width=w-(ew<<1); recs[0].height=recs[2].height=eh; recs[0].y=y; recs[2].y=y+h-eh; recs[1].x=x; recs[1].y=y+eh; recs[1].width=w; recs[1].height=h-(eh<<1); XFillArcs((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,arcs,4); XFillRectangles((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,recs,3); } // Fill chord void FXDCWindow::fillChord(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2){ if(!surface){ fxerror("FXDCWindow::fillChord: DC not connected to drawable.\n"); } XSetArcMode((Display*)getApp()->getDisplay(),(GC)ctx,ArcChord); XFillArc((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,x,y,w,h,ang1,ang2); XSetArcMode((Display*)getApp()->getDisplay(),(GC)ctx,ArcPieSlice); } // Fill chords void FXDCWindow::fillChords(const FXArc* chords,FXuint nchords){ if(!surface){ fxerror("FXDCWindow::fillChords: DC not connected to drawable.\n"); } XSetArcMode((Display*)getApp()->getDisplay(),(GC)ctx,ArcChord); XFillArcs((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,const_cast((const XArc*)chords),nchords); XSetArcMode((Display*)getApp()->getDisplay(),(GC)ctx,ArcPieSlice); } // Fill arc void FXDCWindow::fillArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2){ if(!surface){ fxerror("FXDCWindow::fillArc: DC not connected to drawable.\n"); } XFillArc((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,x,y,w,h,ang1,ang2); } // Fill arcs void FXDCWindow::fillArcs(const FXArc* arcs,FXuint narcs){ if(!surface){ fxerror("FXDCWindow::fillArcs: DC not connected to drawable.\n"); } XFillArcs((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,const_cast((const XArc*)arcs),narcs); } // Fill ellipse void FXDCWindow::fillEllipse(FXint x,FXint y,FXint w,FXint h){ if(!surface){ fxerror("FXDCWindow::fillEllipse: DC not connected to drawable.\n"); } XFillArc((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,x,y,w,h,0,23040); } // Fill polygon void FXDCWindow::fillPolygon(const FXPoint* points,FXuint npoints){ if(!surface){ fxerror("FXDCWindow::fillArcs: DC not connected to drawable.\n"); } XFillPolygon((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,const_cast((const XPoint*)points),npoints,Convex,CoordModeOrigin); } // Fill concave polygon void FXDCWindow::fillConcavePolygon(const FXPoint* points,FXuint npoints){ if(!surface){ fxerror("FXDCWindow::fillConcavePolygon: DC not connected to drawable.\n"); } XFillPolygon((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,const_cast((const XPoint*)points),npoints,Nonconvex,CoordModeOrigin); } // Fill complex polygon void FXDCWindow::fillComplexPolygon(const FXPoint* points,FXuint npoints){ if(!surface){ fxerror("FXDCWindow::fillComplexPolygon: DC not connected to drawable.\n"); } XFillPolygon((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,const_cast((const XPoint*)points),npoints,Complex,CoordModeOrigin); } // Fill polygon relative void FXDCWindow::fillPolygonRel(const FXPoint* points,FXuint npoints){ if(!surface){ fxerror("FXDCWindow::fillPolygonRel: DC not connected to drawable.\n"); } XFillPolygon((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,const_cast((const XPoint*)points),npoints,Convex,CoordModePrevious); } // Fill concave polygon relative void FXDCWindow::fillConcavePolygonRel(const FXPoint* points,FXuint npoints){ if(!surface){ fxerror("FXDCWindow::fillConcavePolygonRel: DC not connected to drawable.\n"); } XFillPolygon((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,const_cast((const XPoint*)points),npoints,Nonconvex,CoordModePrevious); } // Fill complex polygon relative void FXDCWindow::fillComplexPolygonRel(const FXPoint* points,FXuint npoints){ if(!surface){ fxerror("FXDCWindow::fillComplexPolygonRel: DC not connected to drawable.\n"); } XFillPolygon((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,const_cast((const XPoint*)points),npoints,Complex,CoordModePrevious); } // Fill vertical gradient rectangle void FXDCWindow::fillVerticalGradient(FXint x,FXint y,FXint w,FXint h,FXColor top,FXColor bottom){ FXint rr,gg,bb,dr,dg,db,r1,g1,b1,r2,g2,b2,yl,yh,yy,dy,n,t; if(!surface){ fxerror("FXDCWindow::fillVerticalGradient: DC not connected to drawable.\n"); } if(0n) n=t; if((t=FXABS(db))>n) n=t; n++; if(n>h) n=h; if(n>128) n=128; rr=(r1<<16)+32767; gg=(g1<<16)+32767; bb=(b1<<16)+32767; yy=32767; dr=(dr<<16)/n; dg=(dg<<16)/n; db=(db<<16)/n; dy=(h<<16)/n; do{ yl=yy>>16; yy+=dy; yh=yy>>16; setForeground(FXRGB(rr>>16,gg>>16,bb>>16)); fillRectangle(x,y+yl,w,yh-yl); rr+=dr; gg+=dg; bb+=db; } while(yhgetDisplay(),&grad,stops,colors,2); XRenderComposite((Display*)getApp()->getDisplay(),PictOpSrc,picture,0,surface->xrenderpicture,0,0,0,0,x,y,w,h); XRenderFreePicture((Display*)getApp()->getDisplay(),picture); #endif } // Fill horizontal gradient rectangle void FXDCWindow::fillHorizontalGradient(FXint x,FXint y,FXint w,FXint h,FXColor left,FXColor right){ FXint rr,gg,bb,dr,dg,db,r1,g1,b1,r2,g2,b2,xl,xh,xx,dx,n,t; if(!surface){ fxerror("FXDCWindow::fillHorizontalGradient: DC not connected to drawable.\n"); } if(0n) n=t; if((t=FXABS(db))>n) n=t; n++; if(n>w) n=w; if(n>128) n=128; rr=(r1<<16)+32767; gg=(g1<<16)+32767; bb=(b1<<16)+32767; xx=32767; dr=(dr<<16)/n; dg=(dg<<16)/n; db=(db<<16)/n; dx=(w<<16)/n; do{ xl=xx>>16; xx+=dx; xh=xx>>16; setForeground(FXRGB(rr>>16,gg>>16,bb>>16)); fillRectangle(x+xl,y,xh-xl,h); rr+=dr; gg+=dg; bb+=db; } while(xhgetDisplay(),&grad,stops,colors,2); XRenderComposite((Display*)getApp()->getDisplay(),PictOpSrc,picture,0,surface->xrenderpicture,0,0,0,0,x,y,w,h); XRenderFreePicture((Display*)getApp()->getDisplay(),picture); #endif } // Set text font void FXDCWindow::setFont(FXFont *fnt){ if(!surface){ fxerror("FXDCWindow::setFont: DC not connected to drawable.\n"); } if(!fnt || !fnt->id()){ fxerror("FXDCWindow::setFont: illegal or NULL font specified.\n"); } #ifndef HAVE_XFT_H XSetFont((Display*)getApp()->getDisplay(),(GC)ctx,fnt->id()); flags|=GCFont; #endif font=fnt; } /* We eventually want subclassable fonts. FXDCWindow knows about surface, but does not know about font type. Thus, drawText() here should vector to new API's in FXFont. New API gets FXDC* (or FXDC&) so that it can obtain colors, &c. Thus, all knowledge of font-technology is kept inside FXFont. Knowledge of FXDCWindow surface is kept inside FXDCWindow. But FXDC may have some responsibility for layout of characters. Of course, certain font types can only draw on certain DC types... void FXDCWindow::drawText(FXint x,FXint y,const FXchar* string,FXuint length){ if(!surface){ fxerror("FXDCWindow::drawText: DC not connected to drawable.\n"); } if(!font){ fxerror("FXDCWindow::drawText: no font selected.\n"); } font->drawText(this,x,y,string,length); } */ #define FS ((XFontStruct*)(font->font)) static FXint utf2db(XChar2b *dst,const FXchar *src,FXint n){ FXint len,p; FXwchar w; for(p=len=0; p>8); dst[len].byte2=(w&255); } return len; } // Draw string with base line starting at x, y void FXDCWindow::drawText(FXint x,FXint y,const FXchar* string,FXuint length){ if(!surface){ fxerror("FXDCWindow::drawText: DC not connected to drawable.\n"); } if(!font){ fxerror("FXDCWindow::drawText: no font selected.\n"); } #ifdef HAVE_XFT_H XftColor color; color.pixel=devfg; color.color.red=FXREDVAL(fg)*257; color.color.green=FXGREENVAL(fg)*257; color.color.blue=FXBLUEVAL(fg)*257; color.color.alpha=FXALPHAVAL(fg)*257; XftDrawStringUtf8((XftDraw*)xftDraw,&color,(XftFont*)font->font,x,y,(const FcChar8*)string,length); #else FXint count,escapement,defwidth,ww,size,i; FXdouble ang,ux,uy; FXuchar r,c; XChar2b sbuffer[4096]; count=utf2db(sbuffer,string,FXMIN(length,4096)); if(font->getAngle()){ ang=font->getAngle()*0.00027270769562411399179; defwidth=FS->min_bounds.width; ux=Math::cos(ang); uy=Math::sin(ang); if(FS->per_char){ r=FS->default_char>>8; c=FS->default_char&255; size=(FS->max_char_or_byte2-FS->min_char_or_byte2+1); if(FS->min_char_or_byte2<=c && c<=FS->max_char_or_byte2 && FS->min_byte1<=r && r<=FS->max_byte1){ defwidth=FS->per_char[(r-FS->min_byte1)*size+(c-FS->min_char_or_byte2)].width; } for(i=escapement=0; igetDisplay(),surface->id(),(GC)ctx,(FXint)(x+escapement*ux),(FXint)(y-escapement*uy),&sbuffer[i],1); r=sbuffer[i].byte1; c=sbuffer[i].byte2; escapement+=defwidth; if(FS->min_char_or_byte2<=c && c<=FS->max_char_or_byte2 && FS->min_byte1<=r && r<=FS->max_byte1){ if((ww=FS->per_char[(r-FS->min_byte1)*size+(c-FS->min_char_or_byte2)].width)!=0) escapement+=ww-defwidth; } } } else{ for(i=escapement=0; igetDisplay(),surface->id(),(GC)ctx,(FXint)(x+escapement*ux),(FXint)(y-escapement*uy),&sbuffer[i],1); escapement+=defwidth; } } } else{ XDrawString16((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,x,y,sbuffer,count); } #endif } // Draw text starting at x, y over filled background void FXDCWindow::drawImageText(FXint x,FXint y,const FXchar* string,FXuint length){ if(!surface){ fxerror("FXDCWindow::drawImageText: DC not connected to drawable.\n"); } if(!font){ fxerror("FXDCWindow::drawImageText: no font selected.\n"); } #ifdef HAVE_XFT_H XGlyphInfo extents; XftColor fgcolor,bgcolor; fgcolor.pixel=devfg; fgcolor.color.red=FXREDVAL(fg)*257; fgcolor.color.green=FXGREENVAL(fg)*257; fgcolor.color.blue=FXBLUEVAL(fg)*257; fgcolor.color.alpha=FXALPHAVAL(fg)*257; bgcolor.pixel=devbg; bgcolor.color.red=FXREDVAL(bg)*257; bgcolor.color.green=FXGREENVAL(bg)*257; bgcolor.color.blue=FXBLUEVAL(bg)*257; bgcolor.color.alpha=FXALPHAVAL(bg)*257; // Area to blank XftTextExtents8((Display*)getApp()->getDisplay(),(XftFont*)font->font,(const FcChar8*)string,length,&extents); // Erase around text [FIXME wrong location] XftDrawRect((XftDraw*)xftDraw,&bgcolor,x,y-font->getFontAscent(),extents.width,extents.height); //XftDrawRect((XftDraw*)xftDraw,&bgcolor,x+cache->xoff,y-xftfs->ascent,cache->x2off-cache->xoff,xftfs->ascent+xftfs->descent); //XftDrawRect((XftDraw*)xftDraw,&bgcolor,x+cache->xoff,y-((XftFont*)font->font)->ascent,cache->x2off-cache->xoff,((XftFont*)font->font)->ascent+((XftFont*)font->font)->descent); XftDrawStringUtf8((XftDraw*)xftDraw,&fgcolor,(XftFont*)font->font,x,y,(const FcChar8*)string,length); #else FXint count,escapement,defwidth,ww,size,i; FXdouble ang,ux,uy; FXuchar r,c; XChar2b sbuffer[4096]; count=utf2db(sbuffer,string,FXMIN(length,4096)); if(font->getAngle()){ ang=font->getAngle()*0.00027270769562411399179; defwidth=FS->min_bounds.width; ux=Math::cos(ang); uy=Math::sin(ang); if(FS->per_char){ r=FS->default_char>>8; c=FS->default_char&255; size=(FS->max_char_or_byte2-FS->min_char_or_byte2+1); if(FS->min_char_or_byte2<=c && c<=FS->max_char_or_byte2 && FS->min_byte1<=r && r<=FS->max_byte1){ defwidth=FS->per_char[(r-FS->min_byte1)*size+(c-FS->min_char_or_byte2)].width; } for(i=escapement=0; igetDisplay(),surface->id(),(GC)ctx,(FXint)(x+escapement*ux),(FXint)(y-escapement*uy),&sbuffer[i],1); r=sbuffer[i].byte1; c=sbuffer[i].byte2; escapement+=defwidth; if(FS->min_char_or_byte2<=c && c<=FS->max_char_or_byte2 && FS->min_byte1<=r && r<=FS->max_byte1){ if((ww=FS->per_char[(r-FS->min_byte1)*size+(c-FS->min_char_or_byte2)].width)!=0) escapement+=ww-defwidth; } } } else{ for(i=escapement=0; igetDisplay(),surface->id(),(GC)ctx,(FXint)(x+escapement*ux),(FXint)(y-escapement*uy),&sbuffer[i],1); escapement+=defwidth; } } } else{ XDrawImageString16((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,x,y,sbuffer,count); } #endif } #undef FS // Draw string with base line starting at x, y void FXDCWindow::drawText(FXint x,FXint y,const FXString& string){ drawText(x,y,string.text(),string.length()); } // Draw text starting at x, y over filled background void FXDCWindow::drawImageText(FXint x,FXint y,const FXString& string){ drawImageText(x,y,string.text(),string.length()); } // Draw area void FXDCWindow::drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy){ if(!surface){ fxerror("FXDCWindow::drawArea: DC not connected to drawable.\n"); } if(!source || !source->id()){ fxerror("FXDCWindow::drawArea: illegal source specified.\n"); } XCopyArea((Display*)getApp()->getDisplay(),source->id(),surface->id(),(GC)ctx,sx,sy,sw,sh,dx,dy); } // Draw area stretched area from source; FIXME this works but it's like molasses! void FXDCWindow::drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy,FXint dw,FXint dh){ FXint i,j,x,y,xs,ys; if(!surface){ fxerror("FXDCWindow::drawArea: DC not connected to drawable.\n"); } if(!source || !source->id()){ fxerror("FXDCWindow::drawArea: illegal source specified.\n"); } xs=(sw<<16)/dw; ys=(sh<<16)/dh; i=0; y=ys>>1; do{ j=0; x=xs>>1; do{ XCopyArea((Display*)getApp()->getDisplay(),source->id(),surface->id(),(GC)ctx,sx+(x>>16),sy+(y>>16),1,1,dx+j,dy+i); x+=xs; } while(++jid()){ fxerror("FXDCWindow::drawImage: illegal image specified.\n"); } XCopyArea((Display*)getApp()->getDisplay(),image->id(),surface->id(),(GC)ctx,0,0,image->width,image->height,dx,dy); } // Draw bitmap void FXDCWindow::drawBitmap(const FXBitmap* bitmap,FXint dx,FXint dy) { if(!surface) fxerror("FXDCWindow::drawBitmap: DC not connected to drawable.\n"); if(!bitmap || !bitmap->id()) fxerror("FXDCWindow::drawBitmap: illegal bitmap specified.\n"); XCopyPlane((Display*)getApp()->getDisplay(),bitmap->id(),surface->id(),(GC)ctx,0,0,bitmap->width,bitmap->height,dx,dy,1); } // Draw a vanilla icon void FXDCWindow::drawIcon(const FXIcon* icon,FXint dx,FXint dy){ if(!surface){ fxerror("FXDCWindow::drawIcon: DC not connected to drawable.\n"); } if(!icon || !icon->id() || !icon->shape){ fxerror("FXDCWindow::drawIcon: illegal icon specified.\n"); } FXRectangle d=clip*FXRectangle(dx,dy,icon->width,icon->height); if(d.w>0 && d.h>0){ if(icon->getOptions()&IMAGE_OPAQUE){ XCopyArea((Display*)getApp()->getDisplay(),icon->id(),surface->id(),(GC)ctx,d.x-dx,d.y-dy,d.w,d.h,d.x,d.y); } else{ XGCValues gcv; gcv.clip_mask=icon->shape; gcv.clip_x_origin=dx; gcv.clip_y_origin=dy; XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCClipMask|GCClipXOrigin|GCClipYOrigin,&gcv); XCopyArea((Display*)getApp()->getDisplay(),icon->id(),surface->id(),(GC)ctx,d.x-dx,d.y-dy,d.w,d.h,d.x,d.y); XSetClipRectangles((Display*)getApp()->getDisplay(),(GC)ctx,0,0,(XRectangle*)(void*)&clip,1,Unsorted); // Restore old clip rectangle flags|=GCClipMask; } } } // Draw a shaded icon, like when it is selected void FXDCWindow::drawIconShaded(const FXIcon* icon,FXint dx,FXint dy){ if(!surface){ fxerror("FXDCWindow::drawIconShaded: DC not connected to drawable.\n"); } if(!icon || !icon->id() || !icon->shape){ fxerror("FXDCWindow::drawIconShaded: illegal icon specified.\n"); } FXRectangle d=clip*FXRectangle(dx,dy,icon->width,icon->height); if(d.w>0 && d.h>0){ XGCValues gcv; gcv.clip_mask=icon->shape; gcv.clip_x_origin=dx; gcv.clip_y_origin=dy; XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCClipMask|GCClipXOrigin|GCClipYOrigin,&gcv); XCopyArea((Display*)getApp()->getDisplay(),icon->id(),surface->id(),(GC)ctx,d.x-dx,d.y-dy,d.w,d.h,d.x,d.y); gcv.function=BLT_SRC; gcv.stipple=getApp()->stipples[STIPPLE_GRAY]; gcv.fill_style=FILL_STIPPLED; gcv.ts_x_origin=dx; gcv.ts_y_origin=dy; gcv.foreground=surface->visual->getPixel(getApp()->getSelbackColor()); XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCForeground|GCFunction|GCTileStipXOrigin|GCTileStipYOrigin|GCStipple|GCFillStyle,&gcv); XFillRectangle((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,d.x,d.y,d.w,d.h); gcv.function=rop; gcv.fill_style=fill; gcv.ts_x_origin=tx; gcv.ts_y_origin=ty; XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCTileStipXOrigin|GCTileStipYOrigin|GCFunction|GCFillStyle,&gcv); // Restore old raster op function and fill style XSetClipRectangles((Display*)getApp()->getDisplay(),(GC)ctx,0,0,(XRectangle*)(void*)&clip,1,Unsorted); // Restore old clip rectangle flags|=GCClipMask; } } // This draws a sunken icon void FXDCWindow::drawIconSunken(const FXIcon* icon,FXint dx,FXint dy){ if(!surface){ fxerror("FXDCWindow::drawIconSunken: DC not connected to drawable.\n"); } if(!icon || !icon->id() || !icon->etch){ fxerror("FXDCWindow::drawIconSunken: illegal icon specified.\n"); } XGCValues gcv; FXColor base=getApp()->getBaseColor(); FXColor clr=FXRGB((85*FXREDVAL(base))/100,(85*FXGREENVAL(base))/100,(85*FXBLUEVAL(base))/100); // Erase to black gcv.background=0; gcv.foreground=0xffffffff; gcv.function=BLT_NOT_SRC_AND_DST; XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCForeground|GCBackground|GCFunction,&gcv); XCopyPlane((Display*)getApp()->getDisplay(),icon->etch,surface->id(),(GC)ctx,0,0,icon->width,icon->height,dx+1,dy+1,1); // Paint highlight part gcv.function=BLT_SRC_OR_DST; gcv.foreground=surface->visual->getPixel(getApp()->getHiliteColor()); XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCForeground|GCFunction,&gcv); XCopyPlane((Display*)getApp()->getDisplay(),icon->etch,surface->id(),(GC)ctx,0,0,icon->width,icon->height,dx+1,dy+1,1); // Erase to black gcv.foreground=0xffffffff; gcv.function=BLT_NOT_SRC_AND_DST; XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCForeground|GCFunction,&gcv); XCopyPlane((Display*)getApp()->getDisplay(),icon->etch,surface->id(),(GC)ctx,0,0,icon->width,icon->height,dx,dy,1); // Paint shadow part gcv.function=BLT_SRC_OR_DST; gcv.foreground=surface->visual->getPixel(clr); XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCForeground|GCFunction,&gcv); XCopyPlane((Display*)getApp()->getDisplay(),icon->etch,surface->id(),(GC)ctx,0,0,icon->width,icon->height,dx,dy,1); // Restore stuff gcv.foreground=devfg; gcv.background=devbg; gcv.function=rop; XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCForeground|GCBackground|GCFunction,&gcv); } // Draw hash box void FXDCWindow::drawHashBox(FXint x,FXint y,FXint w,FXint h,FXint b){ XGCValues gcv; if(!surface){ fxerror("FXDCWindow::drawHashBox: DC not connected to drawable.\n"); } gcv.stipple=getApp()->stipples[STIPPLE_GRAY]; gcv.fill_style=FILL_STIPPLED; XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCStipple|GCFillStyle,&gcv); XFillRectangle((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,x,y,w-b,b); XFillRectangle((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,x+w-b,y,b,h-b); XFillRectangle((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,x+b,y+h-b,w-b,b); XFillRectangle((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,x,y+b,b,h-b); gcv.stipple=getApp()->stipples[STIPPLE_WHITE]; // Needed for IRIX6.4 bug workaround! gcv.fill_style=fill; XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCStipple|GCFillStyle,&gcv); } // Draw focus rectangle void FXDCWindow::drawFocusRectangle(FXint x,FXint y,FXint w,FXint h){ XGCValues gcv; if(!surface){ fxerror("FXDCWindow::drawFocusRectangle: DC not connected to drawable.\n"); } gcv.stipple=getApp()->stipples[STIPPLE_GRAY]; gcv.fill_style=FILL_STIPPLED; gcv.background=0; gcv.foreground=0xffffffff; // Maybe should use FILL_OPAQUESTIPPLED and current fg/bg color and BLT_SRC gcv.function=BLT_SRC_XOR_DST; // This would be more flexible gcv.ts_x_origin=x; gcv.ts_y_origin=y; XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCTileStipXOrigin|GCTileStipYOrigin|GCForeground|GCBackground|GCFunction|GCStipple|GCFillStyle,&gcv); XFillRectangle((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,x,y,w-1,1); XFillRectangle((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,x+w-1,y,1,h-1); XFillRectangle((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,x+1,y+h-1,w-1,1); XFillRectangle((Display*)getApp()->getDisplay(),surface->id(),(GC)ctx,x,y+1,1,h-1); gcv.stipple=getApp()->stipples[STIPPLE_WHITE]; // Needed for IRIX6.4 bug workaround! gcv.fill_style=fill; gcv.background=devbg; gcv.foreground=devfg; gcv.function=rop; gcv.ts_x_origin=tx; gcv.ts_y_origin=ty; XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCTileStipXOrigin|GCTileStipYOrigin|GCForeground|GCBackground|GCFunction|GCStipple|GCFillStyle,&gcv); } // Set foreground color void FXDCWindow::setForeground(FXColor clr){ if(!surface){ fxerror("FXDCWindow::setForeground: DC not connected to drawable.\n"); } devfg=surface->visual->getPixel(clr); XSetForeground((Display*)getApp()->getDisplay(),(GC)ctx,devfg); flags|=GCForeground; fg=clr; } // Set background color void FXDCWindow::setBackground(FXColor clr){ if(!surface){ fxerror("FXDCWindow::setBackground: DC not connected to drawable.\n"); } devbg=surface->visual->getPixel(clr); XSetBackground((Display*)getApp()->getDisplay(),(GC)ctx,devbg); flags|=GCBackground; bg=clr; } // Set dashes void FXDCWindow::setDashes(FXuint dashoffset,const FXuchar *dashpattern,FXuint dashlength){ FXuint len=0; if(!surface){ fxerror("FXDCWindow::setDashes: DC not connected to drawable.\n"); } if(dashlength>32){ fxerror("FXDCWindow::setDashes: bad dashlength parameter.\n"); } for(FXuint i=0; igetDisplay(),(GC)ctx,dashoff,(char*)dashpat,dashlen); flags|=(GCDashList|GCDashOffset); } // Set line width void FXDCWindow::setLineWidth(FXuint linewidth){ XGCValues gcv; if(!surface){ fxerror("FXDCWindow::setLineWidth: DC not connected to drawable.\n"); } gcv.line_width=linewidth; XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCLineWidth,&gcv); flags|=GCLineWidth; width=linewidth; } // Set line cap style void FXDCWindow::setLineCap(FXCapStyle capstyle){ XGCValues gcv; if(!surface){ fxerror("FXDCWindow::setLineCap: DC not connected to drawable.\n"); } gcv.cap_style=capstyle; XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCCapStyle,&gcv); flags|=GCCapStyle; cap=capstyle; } // Set line join style void FXDCWindow::setLineJoin(FXJoinStyle joinstyle){ XGCValues gcv; if(!surface){ fxerror("FXDCWindow::setLineJoin: DC not connected to drawable.\n"); } gcv.join_style=joinstyle; XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCJoinStyle,&gcv); flags|=GCJoinStyle; join=joinstyle; } // Set line style void FXDCWindow::setLineStyle(FXLineStyle linestyle){ XGCValues gcv; if(!surface){ fxerror("FXDCWindow::setLineStyle: DC not connected to drawable.\n"); } gcv.line_style=linestyle; XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCLineStyle,&gcv); flags|=GCLineStyle; style=linestyle; } // Set fill style void FXDCWindow::setFillStyle(FXFillStyle fillstyle){ if(!surface){ fxerror("FXDCWindow::setFillStyle: DC not connected to drawable.\n"); } XSetFillStyle((Display*)getApp()->getDisplay(),(GC)ctx,fillstyle); flags|=GCFillStyle; fill=fillstyle; } // Set polygon fill rule void FXDCWindow::setFillRule(FXFillRule fillrule){ if(!surface){ fxerror("FXDCWindow::setFillRule: DC not connected to drawable.\n"); } XSetFillRule((Display*)getApp()->getDisplay(),(GC)ctx,fillrule); flags|=GCFillRule; rule=fillrule; } // Set raster function void FXDCWindow::setFunction(FXFunction func){ if(!surface){ fxerror("FXDCWindow::setFunction: DC not connected to drawable.\n"); } XSetFunction((Display*)getApp()->getDisplay(),(GC)ctx,func); flags|=GCFunction; rop=func; } // Set tile pattern void FXDCWindow::setTile(FXImage* image,FXint dx,FXint dy){ XGCValues gcv; if(!surface){ fxerror("FXDCWindow::setTile: DC not connected to drawable.\n"); } if(!image || !image->id()){ fxerror("FXDCWindow::setTile: illegal image specified.\n"); } gcv.tile=image->id(); gcv.ts_x_origin=dx; gcv.ts_y_origin=dy; XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCTileStipXOrigin|GCTileStipYOrigin|GCTile,&gcv); if(dx) flags|=GCTileStipXOrigin; if(dy) flags|=GCTileStipYOrigin; tile=image; tx=dx; ty=dy; } // Set stipple bitmap void FXDCWindow::setStipple(FXBitmap* bitmap,FXint dx,FXint dy){ XGCValues gcv; if(!surface){ fxerror("FXDCWindow::setStipple: DC not connected to drawable.\n"); } if(!bitmap || !bitmap->id()){ fxerror("FXDCWindow::setStipple: illegal image specified.\n"); } gcv.stipple=bitmap->id(); gcv.ts_x_origin=dx; gcv.ts_y_origin=dy; XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCTileStipXOrigin|GCTileStipYOrigin|GCStipple,&gcv); if(dx) flags|=GCTileStipXOrigin; if(dy) flags|=GCTileStipYOrigin; flags|=GCStipple; stipple=bitmap; pattern=STIPPLE_NONE; tx=dx; ty=dy; } // Set stipple pattern void FXDCWindow::setStipple(FXStipplePattern pat,FXint dx,FXint dy){ XGCValues gcv; if(!surface){ fxerror("FXDCWindow::setStipple: DC not connected to drawable.\n"); } if(pat>STIPPLE_CROSSDIAG) pat=STIPPLE_CROSSDIAG; FXASSERT(getApp()->stipples[pat]); gcv.stipple=getApp()->stipples[pat]; gcv.ts_x_origin=dx; gcv.ts_y_origin=dy; XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCTileStipXOrigin|GCTileStipYOrigin|GCStipple,&gcv); if(dx) flags|=GCTileStipXOrigin; if(dy) flags|=GCTileStipYOrigin; stipple=nullptr; pattern=pat; flags|=GCStipple; tx=dx; ty=dy; } // Set clip region void FXDCWindow::setClipRegion(const FXRegion& region){ if(!surface){ fxerror("FXDCWindow::setClipRegion: DC not connected to drawable.\n"); } XSetRegion((Display*)getApp()->getDisplay(),(GC)ctx,(Region)region.region);///// Should intersect region and rect?? #ifdef HAVE_XFT_H XftDrawSetClip((XftDraw*)xftDraw,(Region)region.region); #endif flags|=GCClipMask; } // Set clip rectangle void FXDCWindow::setClipRectangle(FXint x,FXint y,FXint w,FXint h){ if(!surface){ fxerror("FXDCWindow::setClipRectangle: DC not connected to drawable.\n"); } clip.x=FXMAX(x,rect.x); clip.y=FXMAX(y,rect.y); clip.w=FXMIN(x+w,rect.x+rect.w)-clip.x; clip.h=FXMIN(y+h,rect.y+rect.h)-clip.y; if(clip.w<=0) clip.w=0; if(clip.h<=0) clip.h=0; XSetClipRectangles((Display*)getApp()->getDisplay(),(GC)ctx,0,0,(XRectangle*)(void*)&clip,1,Unsorted); #ifdef HAVE_XFT_H XftDrawSetClipRectangles((XftDraw*)xftDraw,0,0,(XRectangle*)(void*)&clip,1); #endif flags|=GCClipMask; } // Set clip rectangle void FXDCWindow::setClipRectangle(const FXRectangle& rectangle){ if(!surface){ fxerror("FXDCWindow::setClipRectangle: DC not connected to drawable.\n"); } clip.x=FXMAX(rectangle.x,rect.x); clip.y=FXMAX(rectangle.y,rect.y); clip.w=FXMIN(rectangle.x+rectangle.w,rect.x+rect.w)-clip.x; clip.h=FXMIN(rectangle.y+rectangle.h,rect.y+rect.h)-clip.y; if(clip.w<=0) clip.w=0; if(clip.h<=0) clip.h=0; XSetClipRectangles((Display*)getApp()->getDisplay(),(GC)ctx,0,0,(XRectangle*)(void*)&clip,1,Unsorted); #ifdef HAVE_XFT_H XftDrawSetClipRectangles((XftDraw*)xftDraw,0,0,(XRectangle*)(void*)&clip,1); #endif flags|=GCClipMask; } // Clear clip rectangle void FXDCWindow::clearClipRectangle(){ if(!surface){ fxerror("FXDCWindow::clearClipRectangle: DC not connected to drawable.\n"); } clip=rect; XSetClipRectangles((Display*)getApp()->getDisplay(),(GC)ctx,0,0,(XRectangle*)(void*)&clip,1,Unsorted); #ifdef HAVE_XFT_H XftDrawSetClipRectangles((XftDraw*)xftDraw,0,0,(XRectangle*)(void*)&clip,1); #endif flags|=GCClipMask; } // Set clip mask void FXDCWindow::setClipMask(FXBitmap* bitmap,FXint dx,FXint dy){ XGCValues gcv; if(!surface){ fxerror("FXDCWindow::setClipMask: DC not connected to drawable.\n"); } if(!bitmap || !bitmap->id()){ fxerror("FXDCWindow::setClipMask: illegal mask specified.\n"); } gcv.clip_mask=bitmap->id(); gcv.clip_x_origin=dx; gcv.clip_y_origin=dy; XChangeGC((Display*)getApp()->getDisplay(),(GC)ctx,GCClipMask|GCClipXOrigin|GCClipYOrigin,&gcv); if(dx) flags|=GCClipXOrigin; if(dy) flags|=GCClipYOrigin; flags|=GCClipMask; mask=bitmap; cx=dx; cy=dy; } // Clear clip mask void FXDCWindow::clearClipMask(){ if(!surface){ fxerror("FXDCWindow::clearClipMask: DC not connected to drawable.\n"); } clip=rect; XSetClipRectangles((Display*)getApp()->getDisplay(),(GC)ctx,0,0,(XRectangle*)(void*)&clip,1,Unsorted); flags|=GCClipMask; mask=nullptr; cx=0; cy=0; } // Set clip child windows void FXDCWindow::clipChildren(FXbool yes){ if(!surface){ fxerror("FXDCWindow::clipChildren: window has not yet been created.\n"); } if(yes){ XSetSubwindowMode((Display*)getApp()->getDisplay(),(GC)ctx,ClipByChildren); #ifdef HAVE_XFT_H XftDrawSetSubwindowMode((XftDraw*)xftDraw,ClipByChildren); #endif flags&=~GCSubwindowMode; } else{ XSetSubwindowMode((Display*)getApp()->getDisplay(),(GC)ctx,IncludeInferiors); #ifdef HAVE_XFT_H XftDrawSetSubwindowMode((XftDraw*)xftDraw,IncludeInferiors); #endif flags|=GCSubwindowMode; } } #endif } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDDSIcon.cpp000066400000000000000000000066521455751074500220020ustar00rootroot00000000000000/******************************************************************************** * * * D D S I c o n O b j e c t * * * ********************************************************************************* * Copyright (C) 2008,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXMemoryStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXObject.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXImage.h" #include "FXIcon.h" #include "FXDDSIcon.h" /* Notes: - Support for displaying texture images; note, FOX decompresses these back to RGB; for direct use, the non-decompressed image data should be handed directly to OpenGL. */ using namespace FX; /*******************************************************************************/ namespace FX { // Suggested file extension const FXchar FXDDSIcon::fileExt[]="dds"; // Suggested mime type const FXchar FXDDSIcon::mimeType[]="image/x-dds"; // Object implementation FXIMPLEMENT(FXDDSIcon,FXIcon,nullptr,0) // Initialize nicely FXDDSIcon::FXDDSIcon(FXApp* a,const FXuchar *pix,FXColor clr,FXuint opts,FXint w,FXint h):FXIcon(a,nullptr,clr,opts,w,h){ if(pix){ FXMemoryStream ms(FXStreamLoad,const_cast(pix)); loadPixels(ms); } } // Save object to stream FXbool FXDDSIcon::savePixels(FXStream& store) const { if(fxsaveDDS(store,data,width,height,1)){ return true; } return false; } // Load object from stream FXbool FXDDSIcon::loadPixels(FXStream& store){ FXColor *pixels; FXint w,h,d; if(fxloadDDS(store,pixels,w,h,d)){ setData(pixels,IMAGE_OWNED,w,h); if(options&IMAGE_ALPHAGUESS) setTransparentColor(guesstransp()); if(options&IMAGE_THRESGUESS) setThresholdValue(guessthresh()); return true; } return false; } // Clean up FXDDSIcon::~FXDDSIcon(){ } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDDSImage.cpp000066400000000000000000000063521455751074500221310ustar00rootroot00000000000000/******************************************************************************** * * * D D S I c o n O b j e c t * * * ********************************************************************************* * Copyright (C) 2008,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXMemoryStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXImage.h" #include "FXDDSImage.h" /* Notes: - Support for displaying texture images; note, FOX decompresses these back to RGB; for direct use, the non-decompressed image data should be handed directly to OpenGL. */ using namespace FX; /*******************************************************************************/ namespace FX { // Suggested file extension const FXchar FXDDSImage::fileExt[]="dds"; // Suggested mime type const FXchar FXDDSImage::mimeType[]="image/x-dds"; // Object implementation FXIMPLEMENT(FXDDSImage,FXImage,nullptr,0) // Initialize FXDDSImage::FXDDSImage(FXApp* a,const FXuchar *pix,FXuint opts,FXint w,FXint h):FXImage(a,nullptr,opts,w,h){ if(pix){ FXMemoryStream ms(FXStreamLoad,const_cast(pix)); loadPixels(ms); } } // Save pixel data only FXbool FXDDSImage::savePixels(FXStream& store) const { if(fxsaveDDS(store,data,width,height,1)){ return true; } return false; } // Load pixel data only FXbool FXDDSImage::loadPixels(FXStream& store){ FXColor *pixels; FXint w,h,d; if(fxloadDDS(store,pixels,w,h,d)){ setData(pixels,IMAGE_OWNED,w,h); return true; } return false; } // Clean up FXDDSImage::~FXDDSImage(){ } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDLL.cpp000066400000000000000000000226161455751074500211700ustar00rootroot00000000000000/******************************************************************************** * * * D y n a m i c L i n k L i b r a r y S u p p o r t * * * ********************************************************************************* * Copyright (C) 2002,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXString.h" #include "FXDLL.h" /* Notes: - Make sure it works on other unices. - Get main executable handle like: GetOwnModuleHandle(); or dlopen(nullptr,RTLD_NOW|RTLD_GLOBAL); - Nice thing for tracing: Dl_info dli; dladdr(__builtin_return_address(0), &dli); fprintf(stderr, "debug trace [%d]: %s called by %p [ %s(%p) %s(%p) ].\n",getpid(), __func__,__builtin_return_address(0),strrchr(dli.dli_fname, '/') ?strrchr(dli.dli_fname, '/')+1 : dli.dli_fname,dli.dli_fbase, dli.dli_sname, dli.dli_saddr); dladdr(__builtin_return_address(1), &dli); fprintf(stderr, "debug trace [%d]: %*s called by %p [ %s(%p) %s(%p) ].\n",getpid(), strlen(__func__), "...",__builtin_return_address(1),strrchr(dli.dli_fname, '/') ?strrchr(dli.dli_fname, '/')+1 : dli.dli_fname,dli.dli_fbase, dli.dli_sname, dli.dli_saddr); - Some machines have dlinfo(); you can get directory from where DLL comes: char directory[1024]; if(dlinfo(hnd,RTLD_DI_ORIGIN,directory)!=-1){ return directory; } - Another way: HMODULE hModule; if(GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,addr,&hModule)!=0){ return hModule; } */ using namespace FX; /*******************************************************************************/ namespace FX { // Return the name of the library module FXString FXDLL::name() const { if(hnd){ #if defined(WIN32) // WIN32 char buffer[1024]; if(GetModuleFileNameA((HINSTANCE)hnd,buffer,sizeof(buffer))){ return FXString(buffer); } #elif defined(HAVE_SHL_LOAD) // HP-UX struct shl_descriptor desc; if(shl_gethandle_r((shl_t)hnd,&desc)!=-1){ return FXString(desc.filename); } #elif defined(__minix) // MINIX //// NOT SUPPORTED //// #else // POSIX Dl_info info; void *ptr=dlsym(hnd,"_init"); // FIXME any better way? if(ptr && dladdr(ptr,&info)){ return FXString(info.dli_fname); } #endif } return FXString::null; } // Load the library module from the given name FXbool FXDLL::load(const FXString& nm){ if(!hnd && !nm.empty()){ #if defined(WIN32) // WIN32 // Order of loading with LoadLibrary (or LoadLibraryEx with no // LOAD_WITH_ALTERED_SEARCH_PATH flag): // // 1. Directory from which the application was loaded. // 2. Current directory. // 3. System directory, as determined by GetSystemDirectory(). // 4. 16-bit system directory. // 5. Windows directory, as determined by GetWindowsDirectory(). // 6. Directories in the $PATH. // // With flag LOAD_WITH_ALTERED_SEARCH_PATH: // // 1. Directory specified by the filename path. // 2. Current directory. // 3. System directory. // 4. 16-bit system directory. // 5. Windows directory. // 6. Directories in the $PATH. // // We switched to the latter so sub-modules needed by a DLL are // plucked from the same place as name (thanks to Rafael de // Pelegrini Soares" ). hnd=LoadLibraryExA(nm.text(),nullptr,LOAD_WITH_ALTERED_SEARCH_PATH); #elif defined(HAVE_SHL_LOAD) // HP-UX hnd=shl_load(nm.text(),BIND_IMMEDIATE|BIND_NONFATAL|DYNAMIC_PATH,0L); #elif defined(__minix) // MINIX //// NOT SUPPORTED //// #else // POSIX hnd=dlopen(nm.text(),RTLD_NOW|RTLD_GLOBAL); #endif } return hnd!=nullptr; } // Unload the library module void FXDLL::unload(){ if(hnd){ #if defined(WIN32) // WIN32 FreeLibrary((HMODULE)hnd); #elif defined(HAVE_SHL_LOAD) // HP-UX shl_unload((shl_t)hnd); #elif defined(__minix) // MINIX //// NOT SUPPORTED //// #else // POSIX dlclose(hnd); #endif hnd=nullptr; } } // Return the address of the symbol in this library module void* FXDLL::address(const FXchar* sym) const { if(hnd && sym && sym[0]){ #if defined(WIN32) // WIN32 return (void*)GetProcAddress((HMODULE)hnd,sym); #elif defined(HAVE_SHL_LOAD) // HP-UX void* ptr=nullptr; if(shl_findsym((shl_t*)&hnd,sym,TYPE_UNDEFINED,&ptr)==0) return ptr; #elif defined(__minix) // MINIX //// NOT SUPPORTED //// #else // POSIX return dlsym(hnd,sym); #endif } return nullptr; } // Return the address of the symbol in this library module void* FXDLL::address(const FXString& sym) const { return address(sym.text()); } // Return the symbol name of the given address FXString FXDLL::symbol(void *addr){ #if defined(WIN32) // WIN32 // FIXME // #elif defined(HAVE_SHL_LOAD) // HP-UX // FIXME // #elif defined(__minix) // MINIX //// NOT SUPPORTED //// #else // POSIX Dl_info info; if(dladdr(addr,&info)){ return FXString(info.dli_sname); } #endif return FXString::null; } // Return the name of the library module containing the address FXString FXDLL::name(void *addr){ #if defined(WIN32) // WIN32 MEMORY_BASIC_INFORMATION mbi; if(VirtualQuery((const void*)addr,&mbi,sizeof(mbi))){ char buffer[1024]; if(GetModuleFileNameA((HINSTANCE)mbi.AllocationBase,buffer,sizeof(buffer))){ return FXString(buffer); } // FXnchar buffer[1024]; // if(GetModuleFileNameW((HINSTANCE)mbi.AllocationBase,buffer,sizeof(buffer))){ // return FXString(buffer); // } } #elif defined(HAVE_SHL_LOAD) // HP-UX // FIXME // #elif defined(__minix) // MINIX //// NOT SUPPORTED //// #else // POSIX Dl_info info; if(dladdr(addr,&info)){ return FXString(info.dli_fname); } #endif return FXString::null; } // Find DLL containing symbol FXDLL FXDLL::dll(void* addr){ #if defined(WIN32) // WIN32 MEMORY_BASIC_INFORMATION mbi; if(VirtualQuery((const void*)addr,&mbi,sizeof(mbi))){ //FXTRACE((1,"BaseAddress = %p\n",mbi.BaseAddress)); //FXTRACE((1,"AllocationBase = %p\n",mbi.AllocationBase)); //FXTRACE((1,"AllocationProtect = 0x%x\n",mbi.AllocationProtect)); //FXTRACE((1,"RegionSize = %d\n",mbi.RegionSize)); //FXTRACE((1,"State = 0x%x\n",mbi.State)); //FXTRACE((1,"Protect = 0x%x\n",mbi.Protect)); //FXTRACE((1,"Type = 0x%x\n",mbi.Type)); return FXDLL(mbi.AllocationBase); } #elif defined(HAVE_SHL_LOAD) // HP-UX // FIXME // #elif defined(__minix) // MINIX //// NOT SUPPORTED //// #else // POSIX Dl_info info; if(dladdr(addr,&info)){ //FXTRACE((1,"dli_fname = %s\n",info.dli_fname)); //FXTRACE((1,"dli_fbase = %p\n",info.dli_fbase)); //FXTRACE((1,"dli_sname = %s\n",info.dli_sname)); //FXTRACE((1,"dli_saddr = %p\n",info.dli_saddr)); return FXDLL(dlopen(info.dli_fname,RTLD_NOLOAD|RTLD_NOW|RTLD_GLOBAL)); } #endif return FXDLL(nullptr); } // Find DLL of ourselves FXDLL FXDLL::dll(){ return dll((void*)FXDLL::error); } // Return error message if error occurred loading the library module FXString FXDLL::error(){ #if defined(WIN32) // WIN32 DWORD dw=GetLastError(); FXchar buffer[512]; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,nullptr,dw,MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),(LPTSTR)buffer,sizeof(buffer),nullptr); return FXString(buffer); #elif defined(HAVE_SHL_LOAD) // HP-UX return FXString::null; #elif defined(__minix) // MINIX //// NOT SUPPORTED //// #else // POSIX return FXString(dlerror()); #endif } /*******************************************************************************/ // Initialize by loading given library name FXAUTODLL::FXAUTODLL(const FXString& nm){ load(nm); } // Unload library if we have one FXAUTODLL::~FXAUTODLL(){ unload(); } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDataTarget.cpp000066400000000000000000000247551455751074500226030ustar00rootroot00000000000000/******************************************************************************** * * * D a t a T a r g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXDataTarget.h" /* Notes: - DataTarget connects GUI to basic values such as flags (FXbool), integral or real numbers, and strings (FXString). - Values in the application program may get updated from the GUI, and vice-versa GUI gets updated when the program has changed a value as well. - Would be nice to set value from message ID also... - When the sender of onCmdValue does not understand the ID_GETXXXXVALUE message, the data target keeps the same value as before. - Catch SEL_CHANGED when we have expunged this from FXTextField. - DT_VOID, i.e. unconnected FXDataTarget maybe it should grey out corresponding widgets. - Need to add ID_GETLONGVALUE/ID_SETLONGVALUE message handlers some day. - onCmdValue, onUpdValue, onCmdOption, and onUpdOption now return 0 if the type variable is not one of the known types. This allows more easy subclassing of FXDataTarget to add custom data types. - When the type is DT_VOID, a change message does not change any data but simply passes along the message to data target's target; an update message will be a no-op, but return 1 so that the sending message will remain sensitized if auto- gray is on. */ using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXDataTarget) FXDataTargetMap[]={ FXMAPFUNC(SEL_COMMAND,FXDataTarget::ID_VALUE,FXDataTarget::onCmdValue), FXMAPFUNC(SEL_CHANGED,FXDataTarget::ID_VALUE,FXDataTarget::onCmdValue), FXMAPFUNC(SEL_UPDATE,FXDataTarget::ID_VALUE,FXDataTarget::onUpdValue), FXMAPFUNCS(SEL_COMMAND,FXDataTarget::ID_OPTION-10001,FXDataTarget::ID_OPTION+10000,FXDataTarget::onCmdOption), FXMAPFUNCS(SEL_UPDATE,FXDataTarget::ID_OPTION-10001,FXDataTarget::ID_OPTION+10000,FXDataTarget::onUpdOption), }; // Object implementation FXIMPLEMENT(FXDataTarget,FXObject,FXDataTargetMap,ARRAYNUMBER(FXDataTargetMap)) // Value changed from widget long FXDataTarget::onCmdValue(FXObject* sender,FXSelector sel,void*){ FXdouble d; FXint i; switch(type){ case DT_VOID: break; case DT_BOOL: i=*((FXbool*)data); sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_GETINTVALUE),(void*)&i); *((FXbool*)data)=(i!=0); break; case DT_CHAR: i=*((FXchar*)data); sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_GETINTVALUE),(void*)&i); *((FXchar*)data)=i; break; case DT_UCHAR: i=*((FXuchar*)data); sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_GETINTVALUE),(void*)&i); *((FXuchar*)data)=i; break; case DT_SHORT: i=*((FXshort*)data); sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_GETINTVALUE),(void*)&i); *((FXshort*)data)=i; break; case DT_USHORT: i=*((FXushort*)data); sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_GETINTVALUE),(void*)&i); *((FXushort*)data)=i; break; case DT_INT: case DT_UINT: sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_GETINTVALUE),data); break; case DT_LONG: case DT_ULONG: sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_GETLONGVALUE),data); break; case DT_FLOAT: d=*((FXfloat*)data); sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_GETREALVALUE),(void*)&d); *((FXfloat*)data)=(FXfloat)d; break; case DT_DOUBLE: sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_GETREALVALUE),data); break; case DT_STRING: sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_GETSTRINGVALUE),data); break; default: return 0; } if(target){ target->handle(this,FXSEL(FXSELTYPE(sel),message),data); } return 1; } // Widget changed from value long FXDataTarget::onUpdValue(FXObject* sender,FXSelector,void*){ FXdouble d; FXint i; switch(type){ case DT_VOID: break; case DT_BOOL: i=*((FXbool*)data); sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_SETINTVALUE),(void*)&i); break; case DT_CHAR: i=*((FXchar*)data); sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_SETINTVALUE),(void*)&i); break; case DT_UCHAR: i=*((FXuchar*)data); sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_SETINTVALUE),(void*)&i); break; case DT_SHORT: i=*((FXshort*)data); sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_SETINTVALUE),(void*)&i); break; case DT_USHORT: i=*((FXushort*)data); sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_SETINTVALUE),(void*)&i); break; case DT_INT: case DT_UINT: sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_SETINTVALUE),data); break; case DT_LONG: case DT_ULONG: sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_SETLONGVALUE),data); break; case DT_FLOAT: d=*((FXfloat*)data); sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_SETREALVALUE),(void*)&d); break; case DT_DOUBLE: sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_SETREALVALUE),data); break; case DT_STRING: sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_SETSTRINGVALUE),data); break; default: return 0; } return 1; } // Value set from message id long FXDataTarget::onCmdOption(FXObject*,FXSelector sel,void*){ FXint num=((FXint)FXSELID(sel))-ID_OPTION; switch(type){ case DT_VOID: break; case DT_BOOL: *((FXbool*)data)=(num!=0); break; case DT_CHAR: *((FXchar*)data)=num; break; case DT_UCHAR: *((FXuchar*)data)=num; break; case DT_SHORT: *((FXshort*)data)=num; break; case DT_USHORT: *((FXushort*)data)=num; break; case DT_INT: *((FXint*)data)=num; break; case DT_UINT: *((FXuint*)data)=num; break; case DT_LONG: *((FXlong*)data)=num; break; case DT_ULONG: *((FXulong*)data)=num; break; case DT_FLOAT: *((FXfloat*)data)=(FXfloat)num; break; case DT_DOUBLE: *((FXdouble*)data)=num; break; default: return 0; } if(target){ target->handle(this,FXSEL(FXSELTYPE(sel),message),data); } return 1; } // Check widget whose message id matches long FXDataTarget::onUpdOption(FXObject* sender,FXSelector sel,void*){ FXint num=((FXint)FXSELID(sel))-ID_OPTION; FXint i=0; switch(type){ case DT_VOID: break; case DT_BOOL: i=*((FXbool*)data); sender->handle(this,(num==i)?FXSEL(SEL_COMMAND,FXWindow::ID_CHECK):FXSEL(SEL_COMMAND,FXWindow::ID_UNCHECK),nullptr); break; case DT_CHAR: i=*((FXchar*)data); sender->handle(this,(num==i)?FXSEL(SEL_COMMAND,FXWindow::ID_CHECK):FXSEL(SEL_COMMAND,FXWindow::ID_UNCHECK),nullptr); break; case DT_UCHAR: i=*((FXuchar*)data); sender->handle(this,(num==i)?FXSEL(SEL_COMMAND,FXWindow::ID_CHECK):FXSEL(SEL_COMMAND,FXWindow::ID_UNCHECK),nullptr); break; case DT_SHORT: i=*((FXshort*)data); sender->handle(this,(num==i)?FXSEL(SEL_COMMAND,FXWindow::ID_CHECK):FXSEL(SEL_COMMAND,FXWindow::ID_UNCHECK),nullptr); break; case DT_USHORT: i=*((FXushort*)data); sender->handle(this,(num==i)?FXSEL(SEL_COMMAND,FXWindow::ID_CHECK):FXSEL(SEL_COMMAND,FXWindow::ID_UNCHECK),nullptr); break; case DT_INT: i=*((FXint*)data); sender->handle(this,(num==i)?FXSEL(SEL_COMMAND,FXWindow::ID_CHECK):FXSEL(SEL_COMMAND,FXWindow::ID_UNCHECK),nullptr); break; case DT_UINT: i=*((FXuint*)data); sender->handle(this,(num==i)?FXSEL(SEL_COMMAND,FXWindow::ID_CHECK):FXSEL(SEL_COMMAND,FXWindow::ID_UNCHECK),nullptr); break; case DT_LONG: i=(FXint) *((FXlong*)data); sender->handle(this,(num==i)?FXSEL(SEL_COMMAND,FXWindow::ID_CHECK):FXSEL(SEL_COMMAND,FXWindow::ID_UNCHECK),nullptr); break; case DT_ULONG: i=(FXint) *((FXulong*)data); sender->handle(this,(num==i)?FXSEL(SEL_COMMAND,FXWindow::ID_CHECK):FXSEL(SEL_COMMAND,FXWindow::ID_UNCHECK),nullptr); break; case DT_FLOAT: i=(FXint) *((FXfloat*)data); sender->handle(this,(num==i)?FXSEL(SEL_COMMAND,FXWindow::ID_CHECK):FXSEL(SEL_COMMAND,FXWindow::ID_UNCHECK),nullptr); break; case DT_DOUBLE: i=(FXint) *((FXdouble*)data); sender->handle(this,(num==i)?FXSEL(SEL_COMMAND,FXWindow::ID_CHECK):FXSEL(SEL_COMMAND,FXWindow::ID_UNCHECK),nullptr); break; default: return 0; } return 1; } // Destroy FXDataTarget::~FXDataTarget(){ target=(FXObject*)-1L; data=(void*)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDate.cpp000066400000000000000000000211451455751074500214260ustar00rootroot00000000000000/******************************************************************************** * * * D a t e C l a s s * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXDate.h" /* Notes: - Henry F. Fliegel and Thomas C. Van Flandern, "A Machine Algorithm for Processing Calendar Dates". CACM, Vol. 11, No. 10, October 1968, pp 657. - Major clean up and simplification was done! - Added week number calculations! - Start of the JD count is 0 at 12 NOON 1 JAN -4712 (4713 BC). - Reminder, MJD = JD - 2400000.5. */ using namespace FX; /*******************************************************************************/ namespace FX { // Many nanoseconds in a second static const FXTime seconds=1000000000L; // Julian day number of GPS week zero (Jan 6, 1980) static const FXuint GPS_EPOCH_JDAY=2444245; // Julian day number of UNIX epoch (Jan 1, 1970) static const FXuint UNIX_EPOCH_JDAY=2440588; // Julian day number of J2000 (Jan 1, 2000) static const FXuint J2000_EPOCH_JDAY=2451545; // UNIX time to GPS time offset in nanoseconds static const FXTime UNIX_TO_GPS=315964800L*seconds; // Short month names const FXchar FXDate::shortMonthName[12][4]={ "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" }; // Long month names const FXchar FXDate::longMonthName[12][10]={ "January","February","March","April","May","June","July","August","September","October","November","December" }; // Short week day name const FXchar FXDate::shortWeekDay[7][4]={ "Sun","Mon","Tue","Wed","Thu","Fri","Sat" }; // Long week day name const FXchar FXDate::longWeekDay[7][10]={ "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday" }; // Number of days in nomimal month static const FXuchar monthDays[13]={ 0,31,28,31,30,31,30,31,31,30,31,30,31 }; /*******************************************************************************/ // Initialize with year and day of year FXDate::FXDate(FXint yr,FXint dy){ setDate(yr,dy); } // Initialize with year, month, and day of month FXDate::FXDate(FXint yr,FXint mo,FXint dy){ setDate(yr,mo,dy); } // Set date to year and day of year void FXDate::setDate(FXint yr,FXint dy){ if(dy<1 || dy>366){ fxerror("FXDate::setDate: bad argument.\n"); } julian=(1461*(yr+4799))/4-(3*((yr+4899)/100))/4+dy-31739; } // Get year and day of year from date void FXDate::getDate(FXint& yr,FXint& dy) const { FXint l,n,i,j; l=julian+68569; n=(4*l)/146097; l=l-(146097*n+3)/4; i=(4000*(l+1))/1461001; l=l-(1461*i)/4+31; j=(80*l)/2447; l=j/11; yr=100*(n-49)+i+l; dy=julian-(1461*(yr+4799))/4+(3*((yr+4899)/100))/4+31739; } // Set date to year, month, and day of month void FXDate::setDate(FXint yr,FXint mo,FXint dy){ if(mo<1 || mo>12 || dy<1 || dy>31){ fxerror("FXDate::setDate: bad argument.\n"); } julian=(1461*(yr+4800+(mo-14)/12))/4+(367*(mo-2-12*((mo-14)/12)))/12-(3*((yr+4900+(mo-14)/12)/100))/4+dy-32075; } // Get year, month, and day of month from date void FXDate::getDate(FXint& yr,FXint& mo,FXint& dy) const { FXint l,n,i,j; l=julian+68569; n=(4*l)/146097; l=l-(146097*n+3)/4; i=(4000*(l+1))/1461001; l=l-(1461*i)/4+31; j=(80*l)/2447; dy=l-(2447*j)/80; l=j/11; mo=j+2-(12*l); yr=100*(n-49)+i+l; } // Set date from nanoseconds since 1/1/1970 // Technically, Julian Day starts at noon; however we truncate // incoming time to 00:00:00. void FXDate::setTime(FXTime ns){ const FXTime days=86400L*seconds; julian=UNIX_EPOCH_JDAY+(FXuint)(((0<=ns)?ns:ns-days+1)/days); } // Get nanoseconds since 1/1/1970 from date // Return time in nanoseconds at start of the day FXTime FXDate::getTime() const { const FXTime days=86400L*seconds; return ((FXTime)julian-(FXTime)UNIX_EPOCH_JDAY)*days; } // is value a leap year? FXbool FXDate::leapYear(FXint yr){ return ((yr%4==0) && (yr%100!=0)) || (yr%400==0); } // Return number of days in a given year FXint FXDate::daysInYear(FXint yr){ return leapYear(yr) ? 366 : 365; } // Return number of days in the month in given year, month FXint FXDate::daysInMonth(FXint yr,FXint mo){ return (mo==2 && leapYear(yr)) ? 29 : monthDays[mo]; } // Return day of the month FXint FXDate::day() const { FXint yr,mo,dy; getDate(yr,mo,dy); return dy; } // Return month FXint FXDate::month() const { FXint yr,mo,dy; getDate(yr,mo,dy); return mo; } // Return year FXint FXDate::year() const { FXint yr,mo,dy; getDate(yr,mo,dy); return yr; } // Return day of the week FXint FXDate::dayOfWeek() const { return (julian+1)%7; // Sunday is day 0 of week } // Return true if leap year FXbool FXDate::leapYear() const { return leapYear(year()); } // Return number of days in this year FXint FXDate::daysInYear() const { return daysInYear(year()); } // Return days in this month FXint FXDate::daysInMonth() const { FXint yr,mo,dy; getDate(yr,mo,dy); return daysInMonth(yr,mo); } // Return day of year FXint FXDate::dayOfYear() const { FXDate s(year(),1); return julian-s.julian+1; } // Return ISO8601 week number of this date FXint FXDate::weekOfYear() const { FXint d4=(((julian+31741-julian%7)%146097)%36524)%1461; FXint L=d4/1460; FXint d1=(d4-L)%365+L; return 1+d1/7; } // Add d days to this date FXDate& FXDate::addDays(FXint d){ julian+=d; return *this; } // Add m months to this date; day of month is adjusted for leap-years FXDate& FXDate::addMonths(FXint m){ FXint yr,mo,dy,mx; getDate(yr,mo,dy); if(0<=m){ yr=yr+(mo-1+m)/12; mo=1+(mo-1+m)%12; } else{ yr=yr+(mo-12+m)/12; mo=1+(mo+2147483627+m)%12; } mx=daysInMonth(yr,mo); if(dy>mx) dy=mx; setDate(yr,mo,dy); return *this; } // Add y years to this date; day of month is adjusted for leap-years FXDate& FXDate::addYears(FXint y){ FXint yr,mo,dy; getDate(yr,mo,dy); yr+=y; if(dy>28 && mo==2 && !leapYear(yr)) dy=28; setDate(yr,mo,dy); return *this; } // Return current local date FXDate FXDate::localDate(){ #if defined(WIN32) SYSTEMTIME t; GetLocalTime(&t); return FXDate(t.wYear,t.wMonth,t.wDay); #elif defined(HAVE_LOCALTIME_R) struct tm result,*t; time_t ltime; time(<ime); t=localtime_r(<ime,&result); return FXDate(t->tm_year+1900,t->tm_mon+1,t->tm_mday); #else struct tm *t; time_t ltime; time(<ime); t=localtime(<ime); return FXDate(t->tm_year+1900,t->tm_mon+1,t->tm_mday); #endif } // Return current universal (UTC) date FXDate FXDate::universalDate(){ #if defined(WIN32) SYSTEMTIME t; GetSystemTime(&t); return FXDate(t.wYear,t.wMonth,t.wDay); #elif defined(HAVE_GMTIME_R) struct tm result,*t; time_t ltime; time(<ime); t=gmtime_r(<ime,&result); return FXDate(t->tm_year+1900,t->tm_mon+1,t->tm_mday); #else struct tm *t; time_t ltime; time(<ime); t=gmtime(<ime); return FXDate(t->tm_year+1900,t->tm_mon+1,t->tm_mday); #endif } // save to store FXStream& operator<<(FXStream& store,const FXDate& d){ store << d.julian; return store; } // load from store FXStream& operator>>(FXStream& store,FXDate& d){ store >> d.julian; return store; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDebugTarget.cpp000066400000000000000000000117021455751074500227440ustar00rootroot00000000000000/******************************************************************************** * * * D e b u g - T a r g e t O b j e c t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXAccelTable.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXDebugTarget.h" /* Notes: - The point of this object is simply to accept all messages, and print out where they came from, which type they were, etc. - So purely for debugging purposes. */ using namespace FX; /*******************************************************************************/ namespace FX { // Table of message type names const char *const FXDebugTarget::messageTypeName[]={ "SEL_NONE", "SEL_KEYPRESS", "SEL_KEYRELEASE", "SEL_LEFTBUTTONPRESS", "SEL_LEFTBUTTONRELEASE", "SEL_MIDDLEBUTTONPRESS", "SEL_MIDDLEBUTTONRELEASE", "SEL_RIGHTBUTTONPRESS", "SEL_RIGHTBUTTONRELEASE", "SEL_MOTION", "SEL_ENTER", "SEL_LEAVE", "SEL_FOCUSIN", "SEL_FOCUSOUT", "SEL_KEYMAP", "SEL_UNGRABBED", "SEL_PAINT", "SEL_CREATE", "SEL_DESTROY", "SEL_UNMAP", "SEL_MAP", "SEL_CONFIGURE", "SEL_SELECTION_LOST", "SEL_SELECTION_GAINED", "SEL_SELECTION_REQUEST", "SEL_RAISED", "SEL_LOWERED", "SEL_CLOSE", "SEL_DELETE", "SEL_MINIMIZE", "SEL_RESTORE", "SEL_MAXIMIZE", "SEL_UPDATE", "SEL_COMMAND", "SEL_CLICKED", "SEL_DOUBLECLICKED", "SEL_TRIPLECLICKED", "SEL_MOUSEWHEEL", "SEL_CHANGED", "SEL_VERIFY", "SEL_DESELECTED", "SEL_SELECTED", "SEL_INSERTED", "SEL_REPLACED", "SEL_DELETED", "SEL_OPENED", "SEL_CLOSED", "SEL_EXPANDED", "SEL_COLLAPSED", "SEL_BEGINDRAG", "SEL_ENDDRAG", "SEL_DRAGGED", "SEL_LASSOED", "SEL_TIMEOUT", "SEL_SIGNAL", "SEL_CLIPBOARD_LOST", "SEL_CLIPBOARD_GAINED", "SEL_CLIPBOARD_REQUEST", "SEL_CHORE", "SEL_FOCUS_SELF", "SEL_FOCUS_RIGHT", "SEL_FOCUS_LEFT", "SEL_FOCUS_DOWN", "SEL_FOCUS_UP", "SEL_FOCUS_NEXT", "SEL_FOCUS_PREV", "SEL_DND_ENTER", "SEL_DND_LEAVE", "SEL_DND_DROP", "SEL_DND_MOTION", "SEL_DND_REQUEST", "SEL_IO_READ", "SEL_IO_WRITE", "SEL_IO_EXCEPT", "SEL_PICKED", "SEL_QUERY_TIP", "SEL_QUERY_HELP", "SEL_DOCKED", "SEL_FLOATED", "SEL_SPACEBALLMOTION", "SEL_SPACEBALLBUTTONPRESS", "SEL_SPACEBALLBUTTONRELEASE", "SEL_SESSION_NOTIFY", "SEL_SESSION_CLOSED", "SEL_COPYDATA", "SEL_IME_START", "SEL_IME_END" }; // Map FXDEFMAP(FXDebugTarget) FXDebugTargetMap[]={ FXMAPTYPES(SEL_KEYPRESS,SEL_LAST,FXDebugTarget::onMessage), }; // Object implementation FXIMPLEMENT(FXDebugTarget,FXObject,FXDebugTargetMap,ARRAYNUMBER(FXDebugTargetMap)) // Init FXDebugTarget::FXDebugTarget(){ lastsender=nullptr; lastsel=0; count=0; } // Got one long FXDebugTarget::onMessage(FXObject* sender,FXSelector sel,void* ptr){ FXuint type=FXSELTYPE(sel); FXuint msid=FXSELID(sel); FXASSERT(ARRAYNUMBER(messageTypeName)==SEL_LAST); if(sender!=lastsender || sel!=lastsel){ fxmessage("\nTYPE:%-23s ID:%-5d SENDER: %-15s PTR: %8p #%-4d",typegetClassName():"NULL",ptr,1); lastsender=sender; lastsel=sel; count=1; } else{ count++; fxmessage("\b\b\b\b%-4d",count); } return 0; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDelegator.cpp000066400000000000000000000046231455751074500224610ustar00rootroot00000000000000/******************************************************************************** * * * D e l e g a t o r T a r g e t * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXDelegator.h" /* Notes: - A delegator forwards messages to another target. - A delegator does not itself understand any message; it is mainly used to provide a single point at which the actual object receiving the messages from the controls can be switched around to another. */ using namespace FX; /*******************************************************************************/ namespace FX { // Object implementation FXIMPLEMENT(FXDelegator,FXObject,nullptr,0) // Delegate message to another target long FXDelegator::onDefault(FXObject* sender,FXSelector sel,void* ptr){ return delegate && delegate->handle(sender,sel,ptr); } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDial.cpp000066400000000000000000000527731455751074500214350ustar00rootroot00000000000000/******************************************************************************** * * * D i a l W i d g e t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FXDial.h" /* Notes: - Contributed by: Guoqing Tian. - Position decoupled from angle. - Add some API's. - Properly handle cyclic/non cyclic stuff. - Callbacks should report position in the void* ptr. - Keep notchangle>=0, as % of negative numbers is implementation defined. - Not yet happy with keyboard/wheel mode valuator. - Visual cue for focus:- please no ugly border! - Maybe add some delta-mode whereby we report changes? */ #define DIALWIDTH 12 #define DIALDIAMETER 40 #define NUMSIDECOLORS 16 #define DIAL_MASK (DIAL_HORIZONTAL|DIAL_CYCLIC|DIAL_HAS_NOTCH) using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXDial) FXDialMap[]={ FXMAPFUNC(SEL_PAINT,0,FXDial::onPaint), FXMAPFUNC(SEL_MOTION,0,FXDial::onMotion), FXMAPFUNC(SEL_MOUSEWHEEL,0,FXDial::onMouseWheel), FXMAPFUNC(SEL_LEFTBUTTONPRESS,0,FXDial::onLeftBtnPress), FXMAPFUNC(SEL_LEFTBUTTONRELEASE,0,FXDial::onLeftBtnRelease), FXMAPFUNC(SEL_KEYPRESS,0,FXDial::onKeyPress), FXMAPFUNC(SEL_KEYRELEASE,0,FXDial::onKeyRelease), FXMAPFUNC(SEL_UNGRABBED,0,FXDial::onUngrabbed), FXMAPFUNC(SEL_QUERY_TIP,0,FXDial::onQueryTip), FXMAPFUNC(SEL_QUERY_HELP,0,FXDial::onQueryHelp), FXMAPFUNC(SEL_COMMAND,FXDial::ID_SETVALUE,FXDial::onCmdSetValue), FXMAPFUNC(SEL_COMMAND,FXDial::ID_SETINTVALUE,FXDial::onCmdSetIntValue), FXMAPFUNC(SEL_COMMAND,FXDial::ID_GETINTVALUE,FXDial::onCmdGetIntValue), FXMAPFUNC(SEL_COMMAND,FXDial::ID_SETLONGVALUE,FXDial::onCmdSetLongValue), FXMAPFUNC(SEL_COMMAND,FXDial::ID_GETLONGVALUE,FXDial::onCmdGetLongValue), FXMAPFUNC(SEL_COMMAND,FXDial::ID_SETREALVALUE,FXDial::onCmdSetRealValue), FXMAPFUNC(SEL_COMMAND,FXDial::ID_GETREALVALUE,FXDial::onCmdGetRealValue), FXMAPFUNC(SEL_COMMAND,FXDial::ID_SETINTRANGE,FXDial::onCmdSetIntRange), FXMAPFUNC(SEL_COMMAND,FXDial::ID_GETINTRANGE,FXDial::onCmdGetIntRange), FXMAPFUNC(SEL_COMMAND,FXDial::ID_SETREALRANGE,FXDial::onCmdSetRealRange), FXMAPFUNC(SEL_COMMAND,FXDial::ID_GETREALRANGE,FXDial::onCmdGetRealRange), FXMAPFUNC(SEL_COMMAND,FXDial::ID_SETHELPSTRING,FXDial::onCmdSetHelp), FXMAPFUNC(SEL_COMMAND,FXDial::ID_GETHELPSTRING,FXDial::onCmdGetHelp), FXMAPFUNC(SEL_COMMAND,FXDial::ID_SETTIPSTRING,FXDial::onCmdSetTip), FXMAPFUNC(SEL_COMMAND,FXDial::ID_GETTIPSTRING,FXDial::onCmdGetTip), }; // Object implementation FXIMPLEMENT(FXDial,FXFrame,FXDialMap,ARRAYNUMBER(FXDialMap)) FXDial::FXDial(){ flags|=FLAG_ENABLED; notchAngle=0; notchSpacing=0; notchOffset=0; notchColor=0; dragPoint=0; dragPos=0; range[0]=0; range[1]=0; incr=0; pos=0; } // Make a window FXDial::FXDial(FXComposite* p,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb):FXFrame(p,opts,x,y,w,h,pl,pr,pt,pb){ flags|=FLAG_ENABLED; target=tgt; message=sel; notchAngle=0; notchSpacing=90; notchOffset=0; notchColor=FXRGB(255,128,0); dragPoint=0; dragPos=0; range[0]=0; range[1]=359; incr=360; pos=0; } // Get minimum width FXint FXDial::getDefaultWidth(){ FXint w=(options&DIAL_HORIZONTAL)?DIALDIAMETER:DIALWIDTH; return w+padleft+padright+(border<<1); } // Get minimum height FXint FXDial::getDefaultHeight(){ FXint h=(options&DIAL_HORIZONTAL)?DIALWIDTH:DIALDIAMETER; return h+padtop+padbottom+(border<<1); } // Returns true because a dial can receive focus FXbool FXDial::canFocus() const { return true; } // Set help using a message long FXDial::onCmdSetHelp(FXObject*,FXSelector,void* ptr){ setHelpText(*((FXString*)ptr)); return 1; } // Get help using a message long FXDial::onCmdGetHelp(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getHelpText(); return 1; } // Set tip using a message long FXDial::onCmdSetTip(FXObject*,FXSelector,void* ptr){ setTipText(*((FXString*)ptr)); return 1; } // Get tip using a message long FXDial::onCmdGetTip(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getTipText(); return 1; } // We were asked about tip text long FXDial::onQueryTip(FXObject* sender,FXSelector sel,void* ptr){ if(FXFrame::onQueryTip(sender,sel,ptr)) return 1; if((flags&FLAG_TIP) && !tip.empty()){ sender->handle(this,FXSEL(SEL_COMMAND,ID_SETSTRINGVALUE),(void*)&tip); return 1; } return 0; } // We were asked about status text long FXDial::onQueryHelp(FXObject* sender,FXSelector sel,void* ptr){ if(FXFrame::onQueryHelp(sender,sel,ptr)) return 1; if((flags&FLAG_HELP) && !help.empty()){ sender->handle(this,FXSEL(SEL_COMMAND,ID_SETSTRINGVALUE),(void*)&help); return 1; } return 0; } // Update value from a message long FXDial::onCmdSetValue(FXObject*,FXSelector,void* ptr){ setValue((FXint)(FXival)ptr); return 1; } // Update value from a message long FXDial::onCmdSetIntValue(FXObject*,FXSelector,void* ptr){ setValue(*((FXint*)ptr)); return 1; } // Obtain value from text field long FXDial::onCmdGetIntValue(FXObject*,FXSelector,void* ptr){ *((FXint*)ptr)=getValue(); return 1; } // Update value from a message long FXDial::onCmdSetLongValue(FXObject*,FXSelector,void* ptr){ setValue((FXint)*((FXlong*)ptr)); return 1; } // Obtain value with a message long FXDial::onCmdGetLongValue(FXObject*,FXSelector,void* ptr){ *((FXlong*)ptr)=(FXlong)getValue(); return 1; } // Update value from a message long FXDial::onCmdSetRealValue(FXObject*,FXSelector,void* ptr){ setValue((FXint)*((FXdouble*)ptr)); return 1; } // Obtain value from text field long FXDial::onCmdGetRealValue(FXObject*,FXSelector,void* ptr){ *((FXdouble*)ptr) = (FXdouble)getValue(); return 1; } // Update range from a message long FXDial::onCmdSetIntRange(FXObject*,FXSelector,void* ptr){ setRange(((FXint*)ptr)[0],((FXint*)ptr)[1]); return 1; } // Get range with a message long FXDial::onCmdGetIntRange(FXObject*,FXSelector,void* ptr){ getRange(((FXint*)ptr)[0],((FXint*)ptr)[1]); return 1; } // Update range from a message long FXDial::onCmdSetRealRange(FXObject*,FXSelector,void* ptr){ setRange((FXint) ((FXdouble*)ptr)[0],(FXint) ((FXdouble*)ptr)[1]); return 1; } // Get range with a message long FXDial::onCmdGetRealRange(FXObject*,FXSelector,void* ptr){ ((FXdouble*)ptr)[0]=(FXdouble)range[0]; ((FXdouble*)ptr)[1]=(FXdouble)range[1]; return 1; } // Pressed LEFT button long FXDial::onLeftBtnPress(FXObject*,FXSelector,void* ptr){ FXEvent *event=(FXEvent*)ptr; flags&=~FLAG_TIP; handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr); if(isEnabled()){ grab(); if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONPRESS,message),ptr)) return 1; if(options&DIAL_HORIZONTAL) dragPoint=event->win_x; else dragPoint=event->win_y; dragPos=pos; flags|=FLAG_PRESSED; flags&=~FLAG_UPDATE; return 1; } return 0; } // Released LEFT button long FXDial::onLeftBtnRelease(FXObject*,FXSelector,void* ptr){ FXuint changed=(flags&FLAG_CHANGED); if(isEnabled()){ ungrab(); flags|=FLAG_UPDATE; flags&=~FLAG_PRESSED; flags&=~FLAG_CHANGED; if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONRELEASE,message),ptr)) return 1; if(changed && target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXival)pos); return 1; } return 0; } // The widget lost the grab for some reason long FXDial::onUngrabbed(FXObject* sender,FXSelector sel,void* ptr){ FXFrame::onUngrabbed(sender,sel,ptr); flags&=~FLAG_PRESSED; flags&=~FLAG_CHANGED; flags|=FLAG_UPDATE; return 1; } // Moving long FXDial::onMotion(FXObject*,FXSelector,void* ptr){ FXEvent *event=(FXEvent*)ptr; FXint travel,size,delta,newpos,tmp; if(flags&FLAG_PRESSED){ if(options&DIAL_HORIZONTAL){ size=width-(border<<1); travel=event->win_x-dragPoint; } else{ size=height-(border<<1); travel=dragPoint-event->win_y; } if(size<100) size=100; if(travel){ delta=(incr*travel)/(2*size); if(options&DIAL_CYCLIC){ tmp=dragPos+delta-range[0]; while(tmp<0) tmp+=(range[1]-range[0]+1); newpos=range[0]+tmp%(range[1]-range[0]+1); } else{ if(dragPos+deltarange[1]) newpos=range[1]; else newpos=dragPos+delta; } if(pos!=newpos){ pos=newpos; FXASSERT(range[0]<=pos && pos<=range[1]); notchAngle=(notchOffset+(3600*(pos-range[0]))/incr)%3600; update(border+padleft+1,border+padtop+1,width-(border<<1)-padleft-padright-2,height-(border<<1)-padtop-padbottom-2); flags|=FLAG_CHANGED; if(target) target->tryHandle(this,FXSEL(SEL_CHANGED,message),(void*)(FXival)pos); return 1; } } } return 0; } // Mouse wheel (Thanks to "Lyle Johnson" ) long FXDial::onMouseWheel(FXObject*,FXSelector,void* ptr){ FXEvent *event=(FXEvent*)ptr; FXint delta,newpos,tmp,mod; // Determine the change in dial units; this probably still needs // tweaking. The formula below adjusts the dial position by 1/36 // of a revolution for each "hop" of the mousewheel. delta=(event->code*incr)/4320; // Determine new dial position if(options&DIAL_CYCLIC){ mod=range[1]-range[0]+1; tmp=pos+delta-range[0]; while(tmp<0) tmp+=mod; newpos=range[0]+tmp%mod; // FIXME small problem if range[1]-range[0]+1 is UINT_MAX } else{ if(pos+deltarange[1]) newpos=range[1]; else newpos=pos+delta; } if(pos!=newpos){ pos=newpos; FXASSERT(range[0]<=pos && pos<=range[1]); notchAngle=(notchOffset+(3600*(pos-range[0]))/incr)%3600; update(border+padleft+1,border+padtop+1,width-(border<<1)-padleft-padright-2,height-(border<<1)-padtop-padbottom-2); if(target) target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXival)pos); } return 1; } // Keyboard press long FXDial::onKeyPress(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; if(isEnabled()){ if(target && target->tryHandle(this,FXSEL(SEL_KEYPRESS,message),ptr)) return 1; switch(event->code){ case KEY_Left: case KEY_KP_Left: if(options&DIAL_HORIZONTAL) goto dec; break; case KEY_Right: case KEY_KP_Right: if(options&DIAL_HORIZONTAL) goto inc; break; case KEY_Up: case KEY_KP_Up: if(!(options&DIAL_HORIZONTAL)) goto inc; break; case KEY_Down: case KEY_KP_Down: if(!(options&DIAL_HORIZONTAL)) goto dec; break; case KEY_plus: case KEY_KP_Add: inc: setValue(pos+1,true); return 1; case KEY_minus: case KEY_KP_Subtract: dec: setValue(pos-1,true); return 1; } } return 0; } // Keyboard release long FXDial::onKeyRelease(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; if(isEnabled()){ if(target && target->tryHandle(this,FXSEL(SEL_KEYRELEASE,message),ptr)) return 1; switch(event->code){ case KEY_Left: case KEY_KP_Left: case KEY_Right: case KEY_KP_Right: if(options&DIAL_HORIZONTAL) return 1; break; case KEY_Up: case KEY_KP_Up: case KEY_Down: case KEY_KP_Down: if(!(options&DIAL_HORIZONTAL)) return 1; break; case KEY_plus: case KEY_KP_Add: case KEY_KP_Subtract: case KEY_minus: return 1; } } return 0; } // Handle repaint long FXDial::onPaint(FXObject*,FXSelector,void* ptr){ const FXdouble fac=0.5*PI/((FXdouble)(NUMSIDECOLORS-1)); FXEvent *event=(FXEvent*)ptr; FXint i,size,u,d,lu,ld,t,r,fm,to,off,ang; FXuint rmax,gmax,bmax,red,green,blue; FXint lt,rt,tp,bm; FXdouble mid,tmp; FXDCWindow dc(this,event); // Paint background dc.setForeground(backColor); dc.fillRectangle(0,0,width,height); off=(notchAngle+3600)%notchSpacing; fm=off/notchSpacing; to=(off+1800-notchSpacing+1)/notchSpacing; // Rectangle of dial lt=border+padleft+1; rt=width-border-padright-2; tp=border+padtop+1; bm=height-border-padbottom-2; // Colors for sides rmax=(126*FXREDVAL(backColor))/100; gmax=(126*FXGREENVAL(backColor))/100; bmax=(126*FXBLUEVAL(backColor))/100; rmax=FXMIN(rmax,255); gmax=FXMIN(gmax,255); bmax=FXMIN(bmax,255); // Horizontal dial if(options&DIAL_HORIZONTAL){ size=rt-lt; r=size/2-1; mid=0.5*(lt+rt); for(i=fm; i<=to; i++){ ang=i*notchSpacing+off; t=(FXint)(mid-r*Math::cos(0.1*DTOR*ang)); if((options&DIAL_HAS_NOTCH) && (ang+3600)%3600==notchAngle){ dc.setForeground(hiliteColor); dc.drawLine(t-1,tp,t-1,bm); dc.setForeground(notchColor); dc.drawLine(t,tp,t,bm); dc.drawLine(t+1,tp,t+1,bm); dc.setForeground(borderColor); dc.drawLine(t+2,tp,t+2,bm); } else{ if(ang<200){ dc.setForeground(shadowColor); dc.drawLine(t,tp,t,bm); dc.setForeground(borderColor); dc.drawLine(t+1,tp,t+1,bm); } else if(ang<300){ dc.setForeground(borderColor); dc.drawLine(t,tp,t,bm); } else if(ang<600){ dc.setForeground(hiliteColor); dc.drawLine(t,tp,t,bm); dc.setForeground(borderColor); dc.drawLine(t+1,tp,t+1,bm); } else if(ang<1200){ dc.setForeground(hiliteColor); dc.drawLine(t-1,tp,t-1,bm); dc.drawLine(t,tp,t,bm); dc.setForeground(borderColor); dc.drawLine(t+1,tp,t+1,bm); } else if(ang<1500){ dc.setForeground(hiliteColor); dc.drawLine(t,tp,t,bm); dc.setForeground(borderColor); dc.drawLine(t+1,tp,t+1,bm); } else if(ang<1600){ dc.setForeground(borderColor); dc.drawLine(t,tp,t,bm); } else{ dc.setForeground(shadowColor); dc.drawLine(t,tp,t,bm); dc.setForeground(borderColor); dc.drawLine(t-1,tp,t-1,bm); } } } dc.drawLine(lt,tp,lt,bm); dc.drawLine(rt,tp,rt,bm); lu=lt; ld=rt; for(i=0; ihi){ fxerror("%s::setRange: trying to set negative range.\n",getClassName()); } if(range[0]!=lo || range[1]!=hi){ range[0]=lo; range[1]=hi; setValue(pos,notify); } } // Set dial value void FXDial::setValue(FXint p,FXbool notify){ FXint n; if(prange[1]) p=range[1]; n=(notchOffset+(3600*(p-range[0]))/incr)%3600; if(n!=notchAngle){ notchAngle=n; update(); } if(p!=pos){ pos=p; if(notify && target){target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)(FXival)pos);} } } // Change increment, i.e. the amount of pos change per revolution void FXDial::setRevolutionIncrement(FXint i){ incr=FXMAX(1,i); notchAngle=(notchOffset+(3600*(pos-range[0]))/incr)%3600; update(); } // Change notch spacing void FXDial::setNotchSpacing(FXint spacing){ if(spacing<1) spacing=1; if(spacing>3600) spacing=3600; while(3600%spacing) spacing--; // Should be a divisor of 3600 if(notchSpacing!=spacing){ notchSpacing=spacing; update(); } } // Change notch offset void FXDial::setNotchOffset(FXint offset){ if(offset>3600) offset=3600; if(offset<-3600) offset=-3600; offset=(offset+3600)%3600; if(offset!=notchOffset){ notchOffset=offset; notchAngle=(notchOffset+(3600*(pos-range[0]))/incr)%3600; update(); } } // Get dial options FXuint FXDial::getDialStyle() const { return (options&DIAL_MASK); } // Set dial options void FXDial::setDialStyle(FXuint style){ FXuint opts=(options&~DIAL_MASK) | (style&DIAL_MASK); if(options!=opts){ options=opts; recalc(); } } // Save object to stream void FXDial::save(FXStream& store) const { FXFrame::save(store); store << notchAngle; store << notchSpacing; store << notchOffset; store << notchColor; store << range[0]; store << range[1]; store << incr; store << pos; store << help; store << tip; } // Load object from stream void FXDial::load(FXStream& store){ FXFrame::load(store); store >> notchAngle; store >> notchSpacing; store >> notchOffset; store >> notchColor; store >> range[0]; store >> range[1]; store >> incr; store >> pos; store >> help; store >> tip; } // Change the Center Notch color void FXDial::setNotchColor(FXColor clr){ if(clr!=notchColor){ notchColor=clr; update(); } } // Change help text void FXDial::setHelpText(const FXString& text){ help=text; } // Change tip text void FXDial::setTipText(const FXString& text){ tip=text; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDialogBox.cpp000066400000000000000000000110231455751074500224130ustar00rootroot00000000000000/******************************************************************************** * * * D i a l o g B o x O b j e c t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "fxkeys.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXAccelTable.h" #include "FXWindow.h" #include "FXApp.h" #include "FXDialogBox.h" /* To do: - Iconified/normal. - Unmap when main window unmapped. - Transient For stuff. - Place so that cursor over dialog. - Hitting ESC will cancel out of the dialog. - Hitting RETURN will localate the default button, and then send it a RETURN; Note that the default button is initially assigned, but whichever button has the focus will be the default button; default-ness moves between buttons. */ using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXDialogBox) FXDialogBoxMap[]={ FXMAPFUNC(SEL_CLOSE,0,FXDialogBox::onCmdCancel), FXMAPFUNC(SEL_COMMAND,FXDialogBox::ID_ACCEPT,FXDialogBox::onCmdAccept), FXMAPFUNC(SEL_CHORE,FXDialogBox::ID_CANCEL,FXDialogBox::onCmdCancel), FXMAPFUNC(SEL_TIMEOUT,FXDialogBox::ID_CANCEL,FXDialogBox::onCmdCancel), FXMAPFUNC(SEL_COMMAND,FXDialogBox::ID_CANCEL,FXDialogBox::onCmdCancel), }; // Object implementation FXIMPLEMENT(FXDialogBox,FXTopWindow,FXDialogBoxMap,ARRAYNUMBER(FXDialogBoxMap)) // Contruct free floating dialog FXDialogBox::FXDialogBox(FXApp* a,const FXString& name,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb,FXint hs,FXint vs):FXTopWindow(a,name,nullptr,nullptr,opts,x,y,w,h,pl,pr,pt,pb,hs,vs){ getAccelTable()->addAccel(MKUINT(KEY_Escape,0),this,FXSEL(SEL_COMMAND,ID_CANCEL)); } // Contruct dialog which will stay on top of owner FXDialogBox::FXDialogBox(FXWindow* own,const FXString& name,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb,FXint hs,FXint vs):FXTopWindow(own,name,nullptr,nullptr,opts,x,y,w,h,pl,pr,pt,pb,hs,vs){ getAccelTable()->addAccel(MKUINT(KEY_Escape,0),this,FXSEL(SEL_COMMAND,ID_CANCEL)); } // Close dialog with an accept long FXDialogBox::onCmdAccept(FXObject*,FXSelector,void*){ getApp()->stopModal(this,true); hide(); return 1; } // Close dialog with a cancel long FXDialogBox::onCmdCancel(FXObject*,FXSelector,void*){ getApp()->stopModal(this,false); hide(); return 1; } // Execute dialog box modally; after creating the dialog and // showing it on the screen, we call getApp()->refresh() to // incur a GUI update pass over all the widgets; without an // explicit call, the GUI update would only be scheduled after // the message handler invoking this function would return. FXuint FXDialogBox::execute(FXuint placement){ create(); show(placement); getApp()->refresh(); return getApp()->runModalFor(this); } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDictionary.cpp000066400000000000000000000223401455751074500226540ustar00rootroot00000000000000/******************************************************************************** * * * D i c t i o n a r y C l a s s * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXElement.h" #include "FXException.h" #include "FXString.h" #include "FXDictionary.h" /* Notes: - We store the hash key, so that 99.999% of the time we can compare hash numbers; only when hash numbers match do we need to compare keys. With a pretty decent hash function, the number of calls to strcmp() should be roughly the same as the number of successful lookups. - When entry is removed, its key and data are cleared, but its hash value remains the same; in other words, voided slots have empty key but non-zero hash value, and free slots have empty key AND zero hash value. - Invariants: 1 Always at least one table entry marked as "free" i.e. key==empty and hash==0. 2 Table grows when number of free slots becomes less than or equal to 1+N/4. 3 Table shrinks when used number of slots becomes less than or equal to N/4. - Minimum table size is 1 (one free slot). Thus, for a table to have one element its size must be at least 2. - Empty table is represented by magic EMPTY table value. This is compile-time constant data and will never change. - NULL keys or empty-string keys are not allowed. - Similar to FXVariantMap; reimplemented to support plain void* as payload. */ #define EMPTY (const_cast((const Entry*)(__dictionary__empty__+3))) #define BSHIFT 5 using namespace FX; /*******************************************************************************/ namespace FX { // Empty dictionary table value extern const FXint __string__empty__[]; extern const FXival __dictionary__empty__[]; const FXival __dictionary__empty__[6]={1,0,1,(FXival)(__string__empty__+1),0,0}; // Adjust the size of the table FXbool FXDictionary::no(FXival n){ FXival m=no(); if(__likely(m!=n)){ Entry* elbat; void* p; // Release old table if(10); // At least one free slot if(elbat.no(n)){ if(1>=BSHIFT; } elbat.table[x].key.adopt(table[i].key); // Steal the string buffers elbat.table[x].data=table[i].data; elbat.table[x].hash=(FXuint)h; // And copy the hash value } } elbat.free(n-used()); // All non-empty slots now free elbat.used(used()); // Used slots not changed } adopt(elbat); return true; } return false; } // Construct empty dictionary FXDictionary::FXDictionary():table(EMPTY){ FXASSERT(sizeof(FXDictionary)==sizeof(void*)); FXASSERT(sizeof(Entry)<=sizeof(FXival)*3); } // Construct from another dictionary FXDictionary::FXDictionary(const FXDictionary& other):table(EMPTY){ FXASSERT(sizeof(FXDictionary)==sizeof(void*)); FXASSERT(sizeof(Entry)<=sizeof(FXival)*3); if(1>=BSHIFT; } } return -1; } // Return reference to slot assocated with given key void*& FXDictionary::at(const FXchar* ky){ FXuval p,b,h,x; if(__unlikely(!ky || !*ky)){ throw FXRangeException("FXDictionary::at: null or empty key\n"); } p=b=h=FXString::hash(ky); FXASSERT(h); while(table[x=p&(no()-1)].hash){ if(table[x].hash==h && table[x].key==ky) goto x; // Return existing slot p=(p<<2)+p+b+1; b>>=BSHIFT; } if(__unlikely(free()<=1+(no()>>2)) && __unlikely(!resize(no()<<1))){ throw FXMemoryException("FXDictionary::at: out of memory\n"); } p=b=h; while(table[x=p&(no()-1)].hash){ if(table[x].key.empty()) goto y; // Return voided slot p=(p<<2)+p+b+1; b>>=BSHIFT; } free(free()-1); // Put into empty slot y:used(used()+1); table[x].key=ky; table[x].hash=(FXuint)h; x:return table[x].data; } // Return constant reference to slot assocated with given key void *const& FXDictionary::at(const FXchar* ky) const { if(__unlikely(!ky || !*ky)){ throw FXRangeException("FXDictionary::at: null or empty key\n"); } if(__likely(!empty())){ FXuval p,b,x,h; p=b=h=FXString::hash(ky); FXASSERT(h); while(table[x=p&(no()-1)].hash){ if(table[x].hash==h && table[x].key==ky) return table[x].data; p=(p<<2)+p+b+1; b>>=BSHIFT; } } return EMPTY[0].data; } // Remove association with given key; return old value, if any void* FXDictionary::remove(const FXchar* ky){ void* old=nullptr; if(__unlikely(!ky || !*ky)){ throw FXRangeException("FXDictionary::remove: null or empty key\n"); } if(__likely(!empty())){ FXuval p,b,h,x; p=b=h=FXString::hash(ky); FXASSERT(h); while(table[x=p&(no()-1)].hash!=h || table[x].key!=ky){ if(!table[x].hash) goto x; p=(p<<2)+p+b+1; b>>=BSHIFT; } table[x].key.clear(); // Void the slot (not empty!) old=table[x].data; table[x].data=nullptr; used(used()-1); if(__unlikely(used()<=(no()>>2))) resize(no()>>1); } x:return old; } // Erase data at pos in the table; return old value, if any void* FXDictionary::erase(FXival pos){ if(__unlikely(pos<0 || no()<=pos)){ throw FXRangeException("FXDictionary::erase: argument out of range\n"); } if(!table[pos].key.empty()){ void* old=table[pos].data; table[pos].key.clear(); // Void the slot (not empty!) table[pos].data=nullptr; used(used()-1); if(__unlikely(used()<=(no()>>2))) resize(no()>>1); return old; } return nullptr; } // Clear entire table FXbool FXDictionary::clear(){ return no(1); } // Destroy table FXDictionary::~FXDictionary(){ clear(); } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDir.cpp000066400000000000000000000531021455751074500212650ustar00rootroot00000000000000/******************************************************************************** * * * D i r e c t o r y E n u m e r a t o r * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxchar.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXString.h" #include "FXIO.h" #include "FXStat.h" #include "FXFile.h" #include "FXPath.h" #include "FXDir.h" /* Notes: - This class implements a way to list the files in a directory. - We just want to wrap directory iteration, nothing fancy. - Maybe add positioning for seek and tell type functions. */ using namespace FX; /*******************************************************************************/ namespace FX { #ifdef WIN32 struct SPACE { HANDLE handle; FXuint first; WIN32_FIND_DATA result; }; #else struct SPACE { DIR* handle; struct dirent* dp; }; #endif // Construct directory enumerator FXDir::FXDir(){ // If this fails on your machine, determine what sizeof(SPACE) is // on your machine and mail it to: jeroen@fox-toolkit.net! //FXTRACE((150,"sizeof(SPACE)=%ld\n",sizeof(SPACE))); FXASSERT(sizeof(SPACE)<=sizeof(space)); #ifdef WIN32 alias_cast(space)->handle=INVALID_HANDLE_VALUE; #else alias_cast(space)->handle=nullptr; #endif } // Construct directory enumerator FXDir::FXDir(const FXString& path){ // If this fails on your machine, determine what sizeof(SPACE) is // on your machine and mail it to: jeroen@fox-toolkit.net! //FXTRACE((150,"sizeof(SPACE)=%ld\n",sizeof(SPACE))); FXASSERT(sizeof(SPACE)<=sizeof(space)); #ifdef WIN32 alias_cast(space)->handle=INVALID_HANDLE_VALUE; #else alias_cast(space)->handle=nullptr; #endif open(path); } // Open directory to path, return true if ok. FXbool FXDir::open(const FXString& path){ if(!path.empty()){ #ifdef WIN32 #ifdef UNICODE FXnchar buffer[MAXPATHLEN+2]; utf2ncs(buffer,path.text(),MAXPATHLEN); wcsncat(buffer,TEXT("\\*"),MAXPATHLEN+2); #else FXchar buffer[MAXPATHLEN+2]; fxstrlcpy(buffer,path.text(),MAXPATHLEN); fxstrlcat(buffer,"\\*",MAXPATHLEN+2); #endif alias_cast(space)->handle=FindFirstFile(buffer,&alias_cast(space)->result); if(alias_cast(space)->handle!=INVALID_HANDLE_VALUE){ alias_cast(space)->first=true; return true; } #else alias_cast(space)->handle=opendir(path.text()); if(alias_cast(space)->handle!=nullptr){ return true; } #endif } return false; } // Returns true if the directory is open FXbool FXDir::isOpen() const { #ifdef WIN32 return (alias_cast(space)->handle!=INVALID_HANDLE_VALUE); #else return alias_cast(space)->handle!=nullptr; #endif } // Go to next directory entry and return its name FXbool FXDir::next(FXString& name){ if(isOpen()){ #if defined(WIN32) if(alias_cast(space)->first || FindNextFile(alias_cast(space)->handle,&alias_cast(space)->result)){ alias_cast(space)->first=false; name.assign(alias_cast(space)->result.cFileName); return true; } #else if((alias_cast(space)->dp=readdir(alias_cast(space)->handle))!=nullptr){ name.assign(alias_cast(space)->dp->d_name); return true; } #endif } name.clear(); return false; } // Close directory void FXDir::close(){ if(isOpen()){ #ifdef WIN32 FindClose(alias_cast(space)->handle); alias_cast(space)->handle=INVALID_HANDLE_VALUE; #else closedir(alias_cast(space)->handle); alias_cast(space)->handle=nullptr; #endif } } // Create new directory FXbool FXDir::create(const FXString& path,FXuint perm){ if(!path.empty()){ #ifdef WIN32 #ifdef UNICODE FXnchar buffer[MAXPATHLEN]; utf2ncs(buffer,path.text(),MAXPATHLEN); return CreateDirectoryW(buffer,nullptr)!=0; #else return CreateDirectoryA(path.text(),nullptr)!=0; #endif #else return ::mkdir(path.text(),perm)==0; #endif } return false; } // Remove directory FXbool FXDir::remove(const FXString& path){ if(!path.empty()){ #ifdef WIN32 #ifdef UNICODE FXnchar buffer[MAXPATHLEN]; utf2ncs(buffer,path.text(),MAXPATHLEN); return RemoveDirectoryW(buffer)!=0; #else return RemoveDirectoryA(path.text())!=0; #endif #else return ::rmdir(path.text())==0; #endif } return false; } // List all the files in directory FXint FXDir::listFiles(FXString*& filelist,const FXString& path,const FXString& pattern,FXuint flags){ FXDir dir(path); // Initialize to empty filelist=nullptr; // Get directory stream pointer if(dir.isOpen()){ FXuint mode=(flags&CaseFold)?(FXPath::PathName|FXPath::NoEscape|FXPath::CaseFold):(FXPath::PathName|FXPath::NoEscape); FXString *newlist; FXint size=0; FXint count=0; FXString pathname; FXString name; FXStat data; // Loop over directory entries while(dir.next(name)){ // Build full pathname pathname=path; if(!ISPATHSEP(pathname.tail())) pathname+=PATHSEPSTRING; pathname+=name; // Get info on file if(!FXStat::statFile(pathname,data)) continue; #ifdef WIN32 // Filter out files; a bit tricky... if(!data.isDirectory() && ((flags&NoFiles) || (data.isHidden() && !(flags&HiddenFiles)) || (!(flags&AllFiles) && !FXPath::match(name,pattern,mode)))) continue; // Filter out directories; even more tricky! if(data.isDirectory() && ((flags&NoDirs) || (data.isHidden() && !(flags&HiddenDirs)) || ((name[0]=='.' && (name[1]==0 || (name[1]=='.' && name[2]==0))) && (flags&NoParent)) || (!(flags&AllDirs) && !FXPath::match(name,pattern,mode)))) continue; #else // Filter out files; a bit tricky... if(!data.isDirectory() && ((flags&NoFiles) || (name[0]=='.' && !(flags&HiddenFiles)) || (!(flags&AllFiles) && !FXPath::match(name,pattern,mode)))) continue; // Filter out directories; even more tricky! if(data.isDirectory() && ((flags&NoDirs) || (name[0]=='.' && !(flags&HiddenDirs)) || ((name[0]=='.' && (name[1]==0 || (name[1]=='.' && name[2]==0))) && (flags&NoParent)) || (!(flags&AllDirs) && !FXPath::match(name,pattern,mode)))) continue; #endif // Grow list if(count+1>=size){ size=size?(size<<1):256; newlist=new FXString [size]; for(FXint i=0; i>=1,letter[0]++){ if(mask&1) list[count++]=letter; } filelist[count++]=PATHSEPSTRING PATHSEPSTRING; // UNC for file shares return count; } */ /* // A UNC name was given of the form "\\" or "\\server" if(ISPATHSEP(path[0]) && ISPATHSEP(path[1]) && path.find(PATHSEP,2)<0){ NETRESOURCE host; // Fill in host.dwScope=RESOURCE_GLOBALNET; host.dwType=RESOURCETYPE_DISK; host.dwDisplayType=RESOURCEDISPLAYTYPE_GENERIC; host.dwUsage=RESOURCEUSAGE_CONTAINER; host.lpLocalName=nullptr; host.lpRemoteName=(char*)path.text(); host.lpComment=nullptr; host.lpProvider=nullptr; // Open network enumeration if(WNetOpenEnum((path[2]?RESOURCE_GLOBALNET:RESOURCE_CONTEXT),RESOURCETYPE_DISK,0,(path[2]?&host:nullptr),&hEnum)==NO_ERROR){ NETRESOURCE resource[16384/sizeof(NETRESOURCE)]; FXTRACE((1,"Enumerating=%s\n",path.text())); while(1){ nCount=-1; // Read as many as will fit nSize=sizeof(resource); if(WNetEnumResource(hEnum,&nCount,resource,&nSize)!=NO_ERROR) break; for(i=0; i=size){ size=size?(size<<1):256; newlist=new FXString[size]; for(j=0; j=size){ size=size?(size<<1):256; newlist=new FXString[size]; for(int f=0; f& netResourceList,DWORD openEnumScope){ // Comments are mine, unless indicated otherwise. - Danil Hrchner // // Passing the value RESOURCE_GLOBALNET for openEnumScope will make this // function search recursively through the network shares for disk resources. // Passing the value RESOURCE_CONTEXT will make this function list the servers // in the network neighbourhood. DWORD retVal; HANDLE handle; // WNetEnumResource() reports containers as being disk resources if // WNetOpenEnum() is called with RESOURCETYPE_DISK. This does not happen if // it's called with RESOURCETYPE_ANY. // BTW RESOURCETYPE_DISK does not guarantee that only disk resources are // reported (I also get a printer container in the list). if((retVal=WNetOpenEnum(openEnumScope,RESOURCETYPE_DISK,0,netResource,&handle))!=NO_ERROR){ // we get here also if access was denied to enumerate the container FXTRACE((1,"ERROR: WNetOpenEnum() (%d)\n", retVal)); return; } NETRESOURCE *netResources; DWORD netResourcesSize=16*1024; // 16 kB is a good size, according to MSDN if ((netResources=(NETRESOURCE *)malloc(netResourcesSize))==nullptr){ FXTRACE((1,"ERROR: Not enough memory for NETRESOURCE structures\n")); WNetCloseEnum(handle); return; } do{ DWORD nEntries=(DWORD)-1; retVal=WNetEnumResource(handle,&nEntries,netResources,&netResourcesSize); // netResourcesSize is not modified if the buffer is large enough if(retVal==ERROR_MORE_DATA){ // MSDN info is not correct; ERROR_MORE_DATA means the buffer was too // small for a _single_ entry // netResourcesSize (now) contains required size if((netResources=(NETRESOURCE *)realloc(netResources,netResourcesSize))==nullptr){ FXTRACE((1,"ERROR: Reallocation for NETRESOURCE structures failed\n")); WNetCloseEnum(handle); return; } nEntries=(DWORD)-1; retVal=WNetEnumResource(handle,&nEntries,netResources,&netResourcesSize); } if(retVal!=NO_ERROR && retVal!=ERROR_NO_MORE_ITEMS){ char *str; switch (retVal){ case ERROR_MORE_DATA: str="more data"; break; // shouldn't happen case ERROR_INVALID_HANDLE: str="invalid handle"; break; case ERROR_NO_NETWORK: str="no network"; break; case ERROR_EXTENDED_ERROR: str="extended error"; break; default: str="unknown"; } FXTRACE((1,"ERROR: Network enum error: %s (%d)\n",str,retVal)); free(netResources); WNetCloseEnum(handle); return; } for(DWORD n=0; n < nEntries; n++){ FXbool isContainer=false; // if RESOURCE_CONTEXT was passed to WNetOpenEnum(), dwScope will be // RESOURCE_GLOBALNET if(netResources[n].dwScope==RESOURCE_GLOBALNET && (netResources[n].dwUsage&RESOURCEUSAGE_CONTAINER)){ isContainer=true; // If RESOURCE_CONTEXT was passed to WNetOpenEnum(), the first entry is // a "self reference". For example, starting from the network root one // can find a container entry with lpComment "Entire Network" // (lpRemoteName and lpLocalName are nullptr for me). This container // contains an entry with the same properties. In order to avoid getting // into an infinite loop, we must handle this case. // However, trying to enumerate normal containers while RESOURCE_CONTEXT // was used causes WNetOpenEnum() to return ERROR_INVALID_PARAMETER. if(netResources[n].lpRemoteName){ netResourceList.append(new FXStringObject(((FXString)netResources[n].lpRemoteName)+PATHSEP)); if(openEnumScope!=RESOURCE_CONTEXT){ fxenumWNetContainerResource(&netResources[n],netResourceList,openEnumScope); } } } // Using the variable isContainer is necessary if WNetOpenEnum() is // called with RESOURCETYPE_DISK. See above. if(netResources[n].dwType==RESOURCETYPE_DISK && !isContainer){ netResourceList.append(new FXStringObject(((FXString)netResources[n].lpRemoteName)+PATHSEP)); } } } while(retVal!=ERROR_NO_MORE_ITEMS); free(netResources); WNetCloseEnum(handle); // it makes no sense to check for NO_ERROR } // Folding case if(flags&LIST_CASEFOLD) matchmode|=FILEMATCH_CASEFOLD; if(FXFile::isShareServer(path)){ pathname=path; // pathname must not have an ending back slash or else // fxenumWNetContainerResource() (WNetOpenEnum()) will fail if(ISPATHSEP(pathname[pathname.length()-1])) pathname.trunc(pathname.length()-1); NETRESOURCE netResource; memset(&netResource,0,sizeof(NETRESOURCE)); netResource.lpRemoteName=(char *)pathname.text(); FXObjectListOf netResourceList; // a share server can only provide shares, which are similar to directories if(!(flags&LIST_NO_DIRS)) fxenumWNetContainerResource(&netResource,netResourceList,RESOURCE_GLOBALNET); for(int n=0; n < netResourceList.no(); n++){ // Get name name=*netResourceList[n]; if(ISPATHSEP(name[name.length()-1])) name.trunc(name.length()-1); name=FXFile::name(name); // Filter out directories if(!(flags&LIST_ALL_DIRS) && !match(pattern,name,matchmode)) continue; // Grow list if(count+1>=size){ size=size?(size<<1):256; newlist=new FXString[size]; for(int f=0; f=size){ size=size?(size<<1):256; newlist=new FXString[size]; for(int f=0; f * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxascii.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXPath.h" #include "FXIO.h" #include "FXStat.h" #include "FXFile.h" #include "FXDir.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXAccelTable.h" #include "FXObjectList.h" #include "FXFont.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXImage.h" #include "FXIcon.h" #include "FXGIFIcon.h" #include "FXBMPIcon.h" #include "FXFrame.h" #include "FXLabel.h" #include "FXTextField.h" #include "FXButton.h" #include "FXMenuButton.h" #include "FXComposite.h" #include "FXPacker.h" #include "FXShell.h" #include "FXPopup.h" #include "FXScrollBar.h" #include "FXScrollArea.h" #include "FXTreeList.h" #include "FXTreeListBox.h" #include "FXDirBox.h" #include "FXDictionary.h" #include "FXDictionaryOf.h" #include "FXIconCache.h" #include "FXFileAssociations.h" #include "icons.h" /* Notes: - When setting path, it adds all directories from the top down to the lowest directory. - When switching from one path to the next, keep as much of the old path as possible; remove and create minimum number of items. - Thus, if path is same as old path, there's no change in the items. - Share icons with other widgets; upgrade icons to some nicer ones. - Should some of these icons move to FXFileAssociations? - Need to support ":" directory list separator so we can path not just a single path but a list of paths. */ using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXDirBox) FXDirBoxMap[]={ FXMAPFUNC(SEL_CHANGED,FXDirBox::ID_TREE,FXDirBox::onTreeChanged), FXMAPFUNC(SEL_COMMAND,FXDirBox::ID_TREE,FXDirBox::onTreeCommand), FXMAPFUNC(SEL_COMMAND,FXDirBox::ID_SETVALUE,FXDirBox::onCmdSetValue), FXMAPFUNC(SEL_COMMAND,FXDirBox::ID_SETSTRINGVALUE,FXDirBox::onCmdSetStringValue), FXMAPFUNC(SEL_COMMAND,FXDirBox::ID_GETSTRINGVALUE,FXDirBox::onCmdGetStringValue), }; // Implementation FXIMPLEMENT(FXDirBox,FXTreeListBox,FXDirBoxMap,ARRAYNUMBER(FXDirBoxMap)) // Directory box FXDirBox::FXDirBox(FXComposite *p,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb):FXTreeListBox(p,tgt,sel,opts,x,y,w,h, pl,pr,pt,pb){ associations=nullptr; if(!(options&DIRBOX_NO_OWN_ASSOC)) associations=new FXFileAssociations(getApp()); foldericon=new FXGIFIcon(getApp(),minifolder); cdromicon=new FXGIFIcon(getApp(),minicdrom); harddiskicon=new FXGIFIcon(getApp(),miniharddisk); netdriveicon=new FXGIFIcon(getApp(),mininetdrive); floppyicon=new FXGIFIcon(getApp(),minifloppy); nethoodicon=new FXGIFIcon(getApp(),mininethood); zipdiskicon=new FXGIFIcon(getApp(),minizipdrive); setDirectory(PATHSEPSTRING); } // Create void FXDirBox::create(){ FXTreeListBox::create(); foldericon->create(); cdromicon->create(); harddiskicon->create(); netdriveicon->create(); floppyicon->create(); nethoodicon->create(); zipdiskicon->create(); } // Detach disconnects the icons void FXDirBox::detach(){ foldericon->detach(); cdromicon->detach(); harddiskicon->detach(); netdriveicon->detach(); floppyicon->detach(); nethoodicon->detach(); zipdiskicon->detach(); FXTreeListBox::detach(); } // Destroy zaps the icons void FXDirBox::destroy(){ foldericon->destroy(); cdromicon->destroy(); harddiskicon->destroy(); netdriveicon->destroy(); floppyicon->destroy(); nethoodicon->destroy(); zipdiskicon->destroy(); FXTreeListBox::destroy(); } // Set the current item's text from the message long FXDirBox::onCmdSetValue(FXObject*,FXSelector,void* ptr){ setDirectory((char*)ptr); return 1; } // Change value long FXDirBox::onCmdSetStringValue(FXObject*,FXSelector,void* ptr){ setDirectory(*((FXString*)ptr)); return 1; } // Obtain value long FXDirBox::onCmdGetStringValue(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getDirectory(); return 1; } // Return item path FXString FXDirBox::getItemPathname(FXTreeItem *item) const { FXString path; if(item){ while(1){ path.prepend(item->getText()); item=item->getParent(); if(!item) break; if(item->getParent()) path.prepend(PATHSEP); } } return path; } // Find child of item matching name static FXTreeItem* findItemChild(FXTreeItem* item,const FXString& name){ while(item){ #ifdef WIN32 if(FXString::comparecase(name,item->getText())==0) return item; #else if(FXString::compare(name,item->getText())==0) return item; #endif item=item->getNext(); } return nullptr; } #ifdef WIN32 // Windows flavor // Return the item from the absolute pathname FXTreeItem* FXDirBox::getPathnameItem(const FXString& path){ FXTreeItem *item=nullptr; if(!path.empty()){ FXint beg=0; FXint end=0; // Parse root directory if(ISPATHSEP(path[end])){ end++; if(ISPATHSEP(path[end])) end++; } else if(Ascii::isLetter(path[end]) && path[end+1]==':'){ end+=2; if(ISPATHSEP(path[end])) end++; } // Absolute path? if(begfindDirBinding(drives[i]); if(assoc && assoc->miniicon) icon=assoc->miniicon; } child=appendItem(nullptr,drives[i],icon,icon); if(id()) child->create(); } // Delete drive list delete [] drives; // Perhaps something else? if((item=findItemChild(getFirstItem(),name))==nullptr){ icon=foldericon; if(associations){ assoc=associations->findDirBinding(path.left(end)); if(assoc && assoc->miniicon) icon=assoc->miniicon; } item=appendItem(nullptr,name,icon,icon); if(id()) item->create(); } } // Now the subdirectories while(endgetFirst(),name))==nullptr){ // Remove the old ones removeItems(item->getFirst(),item->getLast()); // Update icon icon=foldericon; if(associations){ assoc=associations->findDirBinding(path.left(end)); if(assoc && assoc->miniicon) icon=assoc->miniicon; } child=appendItem(item,name,icon,icon); if(id()) child->create(); } // Skip over path separators while(ISPATHSEP(path[end])) end++; // Next level down item=child; } } } return item; } #if 0 // Return the item from the absolute pathname FXTreeItem* FXDirBox::getPathnameItem(const FXString& path){ FXFileAssoc *fileassoc; FXTreeItem *item,*it; FXIcon *icon; FXint beg=0; FXint end=0; FXchar drivename[10]; // FXchar volumename[256]; // FXchar filesystem[100]; // FXchar fullname[266]; // DWORD MaximumComponentLength; // DWORD FileSystemFlags; FXuint drivemask; // Remove old items first clearItems(); // Parse past root if(ISPATHSEP(path[0])){ end++; if(ISPATHSEP(path[1])) end++; } else if(Ascii::isLetter(path[0]) && path[1]==':'){ end+=2; if(ISPATHSEP(path[2])) end++; } // Absolute path? if(begfindDirBinding(drivename); if(fileassoc && fileassoc->miniicon) icon=fileassoc->miniicon; } // Create item if(id()) icon->create(); // Add another root item it=appendItem(nullptr,drivename,icon,icon); // Rest of path under this root if(FXString::comparecase(path,drivename,end)==0) item=it; } drivemask>>=1; } /* // Network neighborhood icon=nethoodicon; // Maybe override from associations if(associations){ fileassoc=associations->findDirBinding("\\\\"); if(fileassoc && fileassoc->miniicon) icon=fileassoc->miniicon; } // Create item if(id()) icon->create(); // Add netword neighborhood item it=appendItem(nullptr,"\\\\",icon,icon); // Rest of path under this root maybe if(FXString::comparecase(path,"\\\\",end)==0) item=it; */ // Got root? if(item){ // Add the rest while(endfindDirBinding(path.left(end)); if(fileassoc && fileassoc->miniicon) icon=fileassoc->miniicon; } // Create item if(id()) icon->create(); // Add next item under last item=appendItem(item,path.mid(beg,end-beg),icon,icon); // Skip over path separator if(endfindDirBinding(path.left(end)); if(assoc && assoc->miniicon) icon=assoc->miniicon; } // Create item item=appendItem(nullptr,name,icon,icon); if(id()) item->create(); } // Now the subdirectories while(endgetFirst(),name))==nullptr){ // Remove the old ones removeItems(item->getFirst(),item->getLast()); // Update icon icon=foldericon; if(associations){ assoc=associations->findDirBinding(path.left(end)); if(assoc && assoc->miniicon) icon=assoc->miniicon; } // Add new child=appendItem(item,name,icon,icon); if(id()) child->create(); } // Skip over path separators while(ISPATHSEP(path[end])) end++; // Next level down item=child; } } } return item; } #endif // Forward clicked message from list to target long FXDirBox::onTreeCommand(FXObject*,FXSelector,void* ptr){ FXString string=getItemPathname((FXTreeItem*)ptr); field->setText(tree->getItemText((FXTreeItem*)ptr)); field->setIcon(tree->getItemClosedIcon((FXTreeItem*)ptr)); removeItem(((FXTreeItem*)ptr)->getFirst()); return target && target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)string.text()); } // Forward changed message from list to target long FXDirBox::onTreeChanged(FXObject*,FXSelector,void* ptr){ FXString string=getItemPathname((FXTreeItem*)ptr); if(target) target->tryHandle(this,FXSEL(SEL_CHANGED,message),(void*)string.text()); return 1; } // Set directory void FXDirBox::setDirectory(const FXString& pathname,FXbool notify){ FXTRACE((100,"FXDirBox::setDirectory(%s,%d)\n",pathname.text(),notify)); setCurrentItem(getPathnameItem(FXPath::absolute(pathname)),notify); } // Return current directory FXString FXDirBox::getDirectory() const { return getItemPathname(getCurrentItem()); } // Change file associations; delete the old one unless it was shared void FXDirBox::setAssociations(FXFileAssociations* assocs,FXbool owned,FXbool notify){ FXuint opts=options; options^=((owned-1)^options)&DIRBOX_NO_OWN_ASSOC; if(associations!=assocs){ FXString path=getDirectory(); if(!(opts&DIRBOX_NO_OWN_ASSOC)) delete associations; associations=assocs; clearItems(notify); setDirectory(path,notify); } } // Save object to stream void FXDirBox::save(FXStream& store) const { FXTreeListBox::save(store); store << associations; store << foldericon; store << cdromicon; store << harddiskicon; store << netdriveicon; store << floppyicon; store << nethoodicon; store << zipdiskicon; } // Load object from stream void FXDirBox::load(FXStream& store){ FXTreeListBox::load(store); store >> associations; store >> foldericon; store >> cdromicon; store >> harddiskicon; store >> netdriveicon; store >> floppyicon; store >> nethoodicon; store >> zipdiskicon; } // Delete it FXDirBox::~FXDirBox(){ clearItems(); if(!(options&DIRBOX_NO_OWN_ASSOC)) delete associations; delete foldericon; delete cdromicon; delete harddiskicon; delete netdriveicon; delete floppyicon; delete nethoodicon; delete zipdiskicon; associations=(FXFileAssociations*)-1L; foldericon=(FXIcon*)-1L; cdromicon=(FXIcon*)-1L; harddiskicon=(FXIcon*)-1L; netdriveicon=(FXIcon*)-1L; floppyicon=(FXIcon*)-1L; nethoodicon=(FXIcon*)-1L; zipdiskicon=(FXIcon*)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDirDialog.cpp000066400000000000000000000144271455751074500224140ustar00rootroot00000000000000/******************************************************************************** * * * D i r e c t o r y S e l e c t i o n D i a l o g * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXPath.h" #include "FXIO.h" #include "FXStat.h" #include "FXFile.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXFont.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXRecentFiles.h" #include "FXFrame.h" #include "FXLabel.h" #include "FXButton.h" #include "FXComposite.h" #include "FXTreeList.h" #include "FXDirList.h" #include "FXPacker.h" #include "FXShell.h" #include "FXTopWindow.h" #include "FXDialogBox.h" #include "FXDirSelector.h" #include "FXDirDialog.h" /* Notes: - Wraps the FXDirSelector directory selection mega widget. */ using namespace FX; /*******************************************************************************/ namespace FX { // File dialog registry section name const FXchar FXDirDialog::sectionName[]="Directory Dialog"; // Object implementation FXIMPLEMENT(FXDirDialog,FXDialogBox,nullptr,0) // Construct directory dialog box FXDirDialog::FXDirDialog(FXWindow* own,const FXString& name,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXDialogBox(own,name,opts|DECOR_TITLE|DECOR_BORDER|DECOR_RESIZE|DECOR_CLOSE,x,y,w,h,4,4,4,4,4,4){ initdialog(); } // Construct directory dialog box FXDirDialog::FXDirDialog(FXApp* a,const FXString& name,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXDialogBox(a,name,opts|DECOR_TITLE|DECOR_BORDER|DECOR_RESIZE|DECOR_CLOSE,x,y,w,h,4,4,4,4,4,4){ initdialog(); } // Initialize dialog and load settings void FXDirDialog::initdialog(){ dirbox=new FXDirSelector(this,nullptr,0,LAYOUT_FILL_X|LAYOUT_FILL_Y); dirbox->acceptButton()->setTarget(this); dirbox->acceptButton()->setSelector(FXDialogBox::ID_ACCEPT); dirbox->cancelButton()->setTarget(this); dirbox->cancelButton()->setSelector(FXDialogBox::ID_CANCEL); setWidth(getApp()->reg().readIntEntry(sectionName,"width",getWidth())); setHeight(getApp()->reg().readIntEntry(sectionName,"height",getHeight())); } // Hide window and save settings void FXDirDialog::hide(){ FXDialogBox::hide(); getApp()->reg().writeIntEntry(sectionName,"width",getWidth()); getApp()->reg().writeIntEntry(sectionName,"height",getHeight()); } // Set directory void FXDirDialog::setDirectory(const FXString& path){ dirbox->setDirectory(path); } // Get directory FXString FXDirDialog::getDirectory() const { return dirbox->getDirectory(); } // Change wildcard matching pattern void FXDirDialog::setPattern(const FXString& ptrn){ dirbox->setPattern(ptrn); } // Return wildcard pattern FXString FXDirDialog::getPattern() const { return dirbox->getPattern(); } // Return true if showing files as well as directories FXbool FXDirDialog::showFiles() const { return dirbox->showFiles(); } // Show or hide normal files void FXDirDialog::showFiles(FXbool showing){ dirbox->showFiles(showing); } // Return true if showing hidden files FXbool FXDirDialog::showHiddenFiles() const { return dirbox->showHiddenFiles(); } // Show or hide hidden files void FXDirDialog::showHiddenFiles(FXbool showing){ dirbox->showHiddenFiles(showing); } // Change wildcard matching mode void FXDirDialog::setMatchMode(FXuint mode){ dirbox->setMatchMode(mode); } // Return wildcard matching mode FXuint FXDirDialog::getMatchMode() const { return dirbox->getMatchMode(); } // Change Directory List style void FXDirDialog::setDirBoxStyle(FXuint style){ dirbox->setDirBoxStyle(style); } // Return Directory List style FXuint FXDirDialog::getDirBoxStyle() const { return dirbox->getDirBoxStyle(); } // Change file associations void FXDirDialog::setAssociations(FXFileAssociations* assoc,FXbool owned){ dirbox->setAssociations(assoc,owned); } // Return file associations FXFileAssociations* FXDirDialog::getAssociations() const { return dirbox->getAssociations(); } // Save data void FXDirDialog::save(FXStream& store) const { FXDialogBox::save(store); store << dirbox; } // Load data void FXDirDialog::load(FXStream& store){ FXDialogBox::load(store); store >> dirbox; } // Cleanup FXDirDialog::~FXDirDialog(){ dirbox=(FXDirSelector*)-1L; } // Open existing directory name FXString FXDirDialog::getOpenDirectory(FXWindow* owner,const FXString& caption,const FXString& path){ FXDirDialog dirdialog(owner,caption); FXString dirname; dirdialog.setDirectory(path); if(dirdialog.execute()){ dirname=dirdialog.getDirectory(); if(FXStat::isDirectory(dirname)) return dirname; } return FXString::null; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDirList.cpp000066400000000000000000001333451455751074500221310ustar00rootroot00000000000000/******************************************************************************** * * * D i r e c t o r y L i s t O b j e c t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxascii.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXPath.h" #include "FXIO.h" #include "FXStat.h" #include "FXFile.h" #include "FXDir.h" #include "FXURL.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXFont.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXIcon.h" #include "FXBMPIcon.h" #include "FXGIFIcon.h" #include "FXScrollBar.h" #include "FXDirList.h" #include "FXMenuPane.h" #include "FXMenuCaption.h" #include "FXMenuCommand.h" #include "FXMenuCascade.h" #include "FXMenuRadio.h" #include "FXMenuCheck.h" #include "FXMenuSeparator.h" #include "FXDictionary.h" #include "FXDictionaryOf.h" #include "FXIconCache.h" #include "FXFileAssociations.h" #include "FXMessageBox.h" #ifdef WIN32 #include #endif #include "icons.h" /* Notes: - One can never create items in constructor:- createItem() may be overloaded! - Instead of FXTreeItems, callbacks should pass pointer to directory? - Clipboard of a filenames. - Should do drag and drop and such. - Clipboard, DND, etc. support. - We should NOT assume the root's name is just '/'. It could be C:\ etc. - Try read icons from /.dir.gif and /.opendir.gif! - Special icon for root. - We should generate SEL_INSERTED, SEL_DELETED, SEL_CHANGED messages as the FXDirList updates itself from the file system. - Under MS-Windows, always pass MatchNoEscape setting match mode! - Every once in a while, even if checking doesn't reveal a change, refresh the entire list anyway! - New implementation of expandTree() was needed; only rescan children of newly expanded item if it was a directory and didn't have any children yet. Before we were rescanning the children when expanding with force=true; this was potentially bad if children already existed, e.g. when called from makeItemVisible(). - When rescanning, recurse into all existing children, regardless of whether expanded or not. - For collapseTree(), right now we save some ram and remove children when changing from expanded to collapsed; other options are however possible. */ #define REFRESHINTERVAL 1000000000 // Interval between refreshes #define REFRESHFREQUENCY 30 // File systems not supporting mod-time, refresh every nth time using namespace FX; /*******************************************************************************/ namespace FX { // Object implementation FXIMPLEMENT(FXDirItem,FXTreeItem,nullptr,0) // Map FXDEFMAP(FXDirList) FXDirListMap[]={ FXMAPFUNC(SEL_DND_ENTER,0,FXDirList::onDNDEnter), FXMAPFUNC(SEL_DND_LEAVE,0,FXDirList::onDNDLeave), FXMAPFUNC(SEL_DND_DROP,0,FXDirList::onDNDDrop), FXMAPFUNC(SEL_DND_MOTION,0,FXDirList::onDNDMotion), FXMAPFUNC(SEL_DND_REQUEST,0,FXDirList::onDNDRequest), FXMAPFUNC(SEL_BEGINDRAG,0,FXDirList::onBeginDrag), FXMAPFUNC(SEL_DRAGGED,0,FXDirList::onDragged), FXMAPFUNC(SEL_ENDDRAG,0,FXDirList::onEndDrag), FXMAPFUNC(SEL_TIMEOUT,FXDirList::ID_REFRESHTIMER,FXDirList::onRefreshTimer), FXMAPFUNC(SEL_UPDATE,FXDirList::ID_SHOW_HIDDEN,FXDirList::onUpdShowHidden), FXMAPFUNC(SEL_UPDATE,FXDirList::ID_HIDE_HIDDEN,FXDirList::onUpdHideHidden), FXMAPFUNC(SEL_UPDATE,FXDirList::ID_TOGGLE_HIDDEN,FXDirList::onUpdToggleHidden), FXMAPFUNC(SEL_UPDATE,FXDirList::ID_SHOW_FILES,FXDirList::onUpdShowFiles), FXMAPFUNC(SEL_UPDATE,FXDirList::ID_HIDE_FILES,FXDirList::onUpdHideFiles), FXMAPFUNC(SEL_UPDATE,FXDirList::ID_TOGGLE_FILES,FXDirList::onUpdToggleFiles), FXMAPFUNC(SEL_UPDATE,FXDirList::ID_SET_PATTERN,FXDirList::onUpdSetPattern), FXMAPFUNC(SEL_UPDATE,FXDirList::ID_SORT_REVERSE,FXDirList::onUpdSortReverse), FXMAPFUNC(SEL_UPDATE,FXDirList::ID_SORT_CASE,FXDirList::onUpdSortCase), FXMAPFUNC(SEL_UPDATE,FXDirList::ID_DELETE_SEL,FXDirList::onUpdHaveSel), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_SETVALUE,FXDirList::onCmdSetValue), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_SETSTRINGVALUE,FXDirList::onCmdSetStringValue), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_GETSTRINGVALUE,FXDirList::onCmdGetStringValue), FXMAPFUNC(SEL_COMMAND,FXDirList::ID_SHOW_HIDDEN,FXDirList::onCmdShowHidden), FXMAPFUNC(SEL_COMMAND,FXDirList::ID_HIDE_HIDDEN,FXDirList::onCmdHideHidden), FXMAPFUNC(SEL_COMMAND,FXDirList::ID_TOGGLE_HIDDEN,FXDirList::onCmdToggleHidden), FXMAPFUNC(SEL_COMMAND,FXDirList::ID_SHOW_FILES,FXDirList::onCmdShowFiles), FXMAPFUNC(SEL_COMMAND,FXDirList::ID_HIDE_FILES,FXDirList::onCmdHideFiles), FXMAPFUNC(SEL_COMMAND,FXDirList::ID_TOGGLE_FILES,FXDirList::onCmdToggleFiles), FXMAPFUNC(SEL_COMMAND,FXDirList::ID_SET_PATTERN,FXDirList::onCmdSetPattern), FXMAPFUNC(SEL_COMMAND,FXDirList::ID_SORT_REVERSE,FXDirList::onCmdSortReverse), FXMAPFUNC(SEL_COMMAND,FXDirList::ID_SORT_CASE,FXDirList::onCmdSortCase), FXMAPFUNC(SEL_COMMAND,FXDirList::ID_REFRESH,FXDirList::onCmdRefresh), FXMAPFUNC(SEL_COMMAND,FXDirList::ID_DELETE_SEL,FXDirList::onCmdDeleteSel), FXMAPFUNC(SEL_CHORE,FXDirList::ID_DROPASK,FXDirList::onCmdDropAsk), FXMAPFUNC(SEL_CHORE,FXDirList::ID_DROPCOPY,FXDirList::onCmdDropCopy), FXMAPFUNC(SEL_COMMAND,FXDirList::ID_DROPCOPY,FXDirList::onCmdDropCopy), FXMAPFUNC(SEL_CHORE,FXDirList::ID_DROPMOVE,FXDirList::onCmdDropMove), FXMAPFUNC(SEL_COMMAND,FXDirList::ID_DROPMOVE,FXDirList::onCmdDropMove), FXMAPFUNC(SEL_CHORE,FXDirList::ID_DROPLINK,FXDirList::onCmdDropLink), FXMAPFUNC(SEL_COMMAND,FXDirList::ID_DROPLINK,FXDirList::onCmdDropLink), }; // Object implementation FXIMPLEMENT(FXDirList,FXTreeList,FXDirListMap,ARRAYNUMBER(FXDirListMap)) // For serialization FXDirList::FXDirList(){ dropEnable(); associations=nullptr; list=nullptr; opendiricon=nullptr; closeddiricon=nullptr; documenticon=nullptr; applicationicon=nullptr; cdromicon=nullptr; harddiskicon=nullptr; networkicon=nullptr; floppyicon=nullptr; zipdiskicon=nullptr; #ifdef WIN32 matchmode=FXPath::PathName|FXPath::NoEscape|FXPath::CaseFold; #else matchmode=FXPath::PathName|FXPath::NoEscape; #endif setSortFunc(ascendingCase); dropaction=DRAG_MOVE; draggable=true; counter=0; } // Directory List Widget FXDirList::FXDirList(FXComposite *p,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXTreeList(p,tgt,sel,opts,x,y,w,h),pattern("*"){ dropEnable(); associations=nullptr; list=nullptr; if(!(options&DIRLIST_NO_OWN_ASSOC)) associations=new FXFileAssociations(getApp()); opendiricon=new FXGIFIcon(getApp(),minifolderopen); closeddiricon=new FXGIFIcon(getApp(),minifolder); documenticon=new FXGIFIcon(getApp(),minidoc); applicationicon=new FXGIFIcon(getApp(),miniapp); cdromicon=new FXGIFIcon(getApp(),minicdrom); harddiskicon=new FXGIFIcon(getApp(),miniharddisk); networkicon=new FXGIFIcon(getApp(),mininetdrive); floppyicon=new FXGIFIcon(getApp(),minifloppy); zipdiskicon=new FXGIFIcon(getApp(),minizipdrive); #ifdef WIN32 matchmode=FXPath::PathName|FXPath::NoEscape|FXPath::CaseFold; #else matchmode=FXPath::PathName|FXPath::NoEscape; #endif setSortFunc(ascendingCase); dropaction=DRAG_MOVE; draggable=true; counter=0; } // Create X window void FXDirList::create(){ FXTreeList::create(); getApp()->addTimeout(this,ID_REFRESHTIMER,REFRESHINTERVAL); opendiricon->create(); closeddiricon->create(); documenticon->create(); applicationicon->create(); cdromicon->create(); harddiskicon->create(); networkicon->create(); floppyicon->create(); zipdiskicon->create(); listItems(false,true); // FIXME } // Detach disconnects the icons void FXDirList::detach(){ FXTreeList::detach(); getApp()->removeTimeout(this,ID_REFRESHTIMER); opendiricon->detach(); closeddiricon->detach(); documenticon->detach(); applicationicon->detach(); cdromicon->detach(); harddiskicon->detach(); networkicon->detach(); floppyicon->detach(); zipdiskicon->detach(); } // Destroy zaps the icons void FXDirList::destroy(){ FXTreeList::destroy(); getApp()->removeTimeout(this,ID_REFRESHTIMER); opendiricon->destroy(); closeddiricon->destroy(); documenticon->destroy(); applicationicon->destroy(); cdromicon->destroy(); harddiskicon->destroy(); networkicon->destroy(); floppyicon->destroy(); zipdiskicon->destroy(); } // Create item FXTreeItem* FXDirList::createItem(const FXString& text,FXIcon* oi,FXIcon* ci,void* ptr){ return new FXDirItem(text,oi,ci,ptr); } /*******************************************************************************/ // Sort ascending order, keeping directories first FXint FXDirList::ascending(const FXTreeItem* pa,const FXTreeItem* pb){ FXint diff=static_cast(pb)->isDirectory() - static_cast(pa)->isDirectory(); return diff ? diff : FXString::comparenatural(pa->label,pb->label); } // Sort descending order, keeping directories first FXint FXDirList::descending(const FXTreeItem* pa,const FXTreeItem* pb){ FXint diff=static_cast(pb)->isDirectory() - static_cast(pa)->isDirectory(); return diff ? diff : FXString::comparenatural(pb->label,pa->label); } // Sort ascending order, case insensitive, keeping directories first FXint FXDirList::ascendingCase(const FXTreeItem* pa,const FXTreeItem* pb){ FXint diff=static_cast(pb)->isDirectory() - static_cast(pa)->isDirectory(); return diff ? diff : FXString::comparenaturalcase(pa->label,pb->label); } // Sort descending order, case insensitive, keeping directories first FXint FXDirList::descendingCase(const FXTreeItem* pa,const FXTreeItem* pb){ FXint diff=static_cast(pb)->isDirectory() - static_cast(pa)->isDirectory(); return diff ? diff : FXString::comparenaturalcase(pb->label,pa->label); } /*******************************************************************************/ // Select files matching wildcard pattern FXbool FXDirList::selectMatching(const FXString& ptrn,FXuint mode,FXbool notify){ FXTreeItem *item=getFirstItem(); FXbool changes=false; while(item){ if(FXPath::match(getItemText(item),ptrn,mode)){ changes|=selectItem(item,notify); } if(item->getFirst()){ item=item->getFirst(); } else{ while(!item->getNext() && item->getParent()) item=item->getParent(); item=item->getNext(); } } return changes; } // Return uri-list of selected files FXString FXDirList::getSelectedFiles() const { FXTreeItem *item=getFirstItem(); FXString result; while(item){ if(isItemSelected(item)){ result.append(FXURL::fileToURL(getItemPathname(item))); result.append("\r\n"); } if(item->getFirst()){ item=item->getFirst(); } else{ while(!item->getNext() && item->getParent()) item=item->getParent(); item=item->getNext(); } } return result; } // Update if we have selection long FXDirList::onUpdHaveSel(FXObject* sender,FXSelector,void*){ FXTreeItem *item=getFirstItem(); while(item){ if(isItemSelected(item)){ sender->handle(this,FXSEL(SEL_COMMAND,ID_ENABLE),nullptr); return 1; } if(item->getFirst()){ item=item->getFirst(); } else{ while(!item->getNext() && item->getParent()) item=item->getParent(); item=item->getNext(); } } sender->handle(this,FXSEL(SEL_COMMAND,ID_DISABLE),nullptr); return 1; } /*******************************************************************************/ // Delete selection long FXDirList::onCmdDeleteSel(FXObject*,FXSelector,void*){ // FIXME FXString delfiles=getSelectedFiles(); //// return 1; } /*******************************************************************************/ // Copy files to drop directory long FXDirList::onCmdDropCopy(FXObject*,FXSelector,void*){ FXString filedst,filesrc; FXint beg,end; FXuint answer; for(beg=0; begroot_x,((FXEvent*)ptr)->root_y); getApp()->runModalWhileShown(&dropmenu); dropdirectory=FXString::null; dropfiles=FXString::null; dropaction=DRAG_REJECT; return 1; } /*******************************************************************************/ // Handle drag-and-drop enter long FXDirList::onDNDEnter(FXObject* sender,FXSelector sel,void* ptr){ FXTreeList::onDNDEnter(sender,sel,ptr); return 1; } // Handle drag-and-drop leave long FXDirList::onDNDLeave(FXObject* sender,FXSelector sel,void* ptr){ FXTreeList::onDNDLeave(sender,sel,ptr); stopAutoScroll(); dropdirectory.clear(); dropaction=DRAG_REJECT; return 1; } // Handle drag-and-drop motion long FXDirList::onDNDMotion(FXObject* sender,FXSelector sel,void* ptr){ FXEvent *event=(FXEvent*)ptr; FXTreeItem *item; // Start autoscrolling if(startAutoScroll(event,false)) return 1; // Give base class a shot if(FXTreeList::onDNDMotion(sender,sel,ptr)) return 1; // Dropping list of filenames if(offeredDNDType(FROM_DRAGNDROP,urilistType)){ // Locate drop place item=getItemAt(event->win_x,event->win_y); // We can drop in a directory if(item && isItemDirectory(item)){ // Get drop directory dropdirectory=getItemPathname(item); // What is being done (move,copy,link) dropaction=inquireDNDAction(); // See if this is writable if(FXStat::isAccessible(dropdirectory,FXIO::ReadOnly|FXIO::WriteOnly)){ acceptDrop(DRAG_ACCEPT); } } return 1; } return 0; } // Handle drag-and-drop drop long FXDirList::onDNDDrop(FXObject* sender,FXSelector sel,void* ptr){ // Stop scrolling stopAutoScroll(); // Perhaps target wants to deal with it if(FXTreeList::onDNDDrop(sender,sel,ptr)) return 1; // Get uri-list of files being dropped if(getDNDData(FROM_DRAGNDROP,urilistType,dropfiles)){ if(!dropfiles.empty()){ switch(dropaction){ case DRAG_COPY: getApp()->addChore(this,ID_DROPCOPY,ptr); break; case DRAG_MOVE: getApp()->addChore(this,ID_DROPMOVE,ptr); break; case DRAG_LINK: getApp()->addChore(this,ID_DROPLINK,ptr); break; default: getApp()->addChore(this,ID_DROPASK,ptr); break; } return 1; } } return 0; } // Somebody wants our dragged data long FXDirList::onDNDRequest(FXObject* sender,FXSelector sel,void* ptr){ // Perhaps the target wants to supply its own data if(FXTreeList::onDNDRequest(sender,sel,ptr)) return 1; // Return list of filenames as a uri-list if(((FXEvent*)ptr)->target==urilistType){ setDNDData(FROM_DRAGNDROP,urilistType,dragfiles); return 1; } // Delete selected files if(((FXEvent*)ptr)->target==deleteType){ FXTRACE((100,"Delete files not yet implemented\n")); return 1; } return 0; } // Start a drag operation long FXDirList::onBeginDrag(FXObject* sender,FXSelector sel,void* ptr){ if(!FXTreeList::onBeginDrag(sender,sel,ptr)){ beginDrag(&urilistType,1); dragfiles=getSelectedFiles(); } return 1; } // Dragged stuff around long FXDirList::onDragged(FXObject* sender,FXSelector sel,void* ptr){ FXEvent* event=(FXEvent*)ptr; if(!FXTreeList::onDragged(sender,sel,ptr)){ FXDragAction action=DRAG_ASK; if(event->state&CONTROLMASK) action=DRAG_COPY; if(event->state&SHIFTMASK) action=DRAG_MOVE; if(event->state&ALTMASK) action=DRAG_LINK; handleDrag(event->root_x,event->root_y,action); action=didAccept(); switch(action){ case DRAG_COPY: setDragCursor(getApp()->getDefaultCursor(DEF_DNDCOPY_CURSOR)); break; case DRAG_MOVE: setDragCursor(getApp()->getDefaultCursor(DEF_DNDMOVE_CURSOR)); break; case DRAG_LINK: setDragCursor(getApp()->getDefaultCursor(DEF_DNDLINK_CURSOR)); break; case DRAG_ASK: setDragCursor(getApp()->getDefaultCursor(DEF_DNDASK_CURSOR)); break; default: setDragCursor(getApp()->getDefaultCursor(DEF_DNDSTOP_CURSOR)); break; } } return 1; } // End drag operation long FXDirList::onEndDrag(FXObject* sender,FXSelector sel,void* ptr){ if(!FXTreeList::onEndDrag(sender,sel,ptr)){ endDrag((didAccept()!=DRAG_REJECT)); setDragCursor(getDefaultCursor()); dragfiles=FXString::null; } return 1; } /*******************************************************************************/ // Open up the path down to the given string long FXDirList::onCmdSetValue(FXObject*,FXSelector,void* ptr){ setCurrentFile((const FXchar*)ptr); return 1; } // Open up the path down to the given string long FXDirList::onCmdSetStringValue(FXObject*,FXSelector,void* ptr){ setCurrentFile(*((FXString*)ptr)); return 1; } // Obtain value of the current item long FXDirList::onCmdGetStringValue(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getCurrentFile(); return 1; } // Toggle hidden files long FXDirList::onCmdToggleHidden(FXObject*,FXSelector,void*){ showHiddenFiles(!showHiddenFiles()); return 1; } // Update toggle hidden files widget long FXDirList::onUpdToggleHidden(FXObject* sender,FXSelector,void*){ sender->handle(this,showHiddenFiles()?FXSEL(SEL_COMMAND,ID_CHECK):FXSEL(SEL_COMMAND,ID_UNCHECK),nullptr); return 1; } // Show hidden files long FXDirList::onCmdShowHidden(FXObject*,FXSelector,void*){ showHiddenFiles(true); return 1; } // Update show hidden files widget long FXDirList::onUpdShowHidden(FXObject* sender,FXSelector,void*){ sender->handle(this,showHiddenFiles()?FXSEL(SEL_COMMAND,ID_CHECK):FXSEL(SEL_COMMAND,ID_UNCHECK),nullptr); return 1; } // Hide hidden files long FXDirList::onCmdHideHidden(FXObject*,FXSelector,void*){ showHiddenFiles(false); return 1; } // Update hide hidden files widget long FXDirList::onUpdHideHidden(FXObject* sender,FXSelector,void*){ sender->handle(this,showHiddenFiles()?FXSEL(SEL_COMMAND,ID_UNCHECK):FXSEL(SEL_COMMAND,ID_CHECK),nullptr); return 1; } // Toggle files display long FXDirList::onCmdToggleFiles(FXObject*,FXSelector,void*){ showFiles(!showFiles()); return 1; } // Update toggle files widget long FXDirList::onUpdToggleFiles(FXObject* sender,FXSelector,void*){ sender->handle(this,showFiles()?FXSEL(SEL_COMMAND,ID_CHECK):FXSEL(SEL_COMMAND,ID_UNCHECK),nullptr); return 1; } // Show files long FXDirList::onCmdShowFiles(FXObject*,FXSelector,void*){ showFiles(true); return 1; } // Update show files widget long FXDirList::onUpdShowFiles(FXObject* sender,FXSelector,void*){ sender->handle(this,showFiles()?FXSEL(SEL_COMMAND,ID_CHECK):FXSEL(SEL_COMMAND,ID_UNCHECK),nullptr); return 1; } // Hide files long FXDirList::onCmdHideFiles(FXObject*,FXSelector,void*){ showFiles(false); return 1; } // Update hide files widget long FXDirList::onUpdHideFiles(FXObject* sender,FXSelector,void*){ sender->handle(this,showFiles()?FXSEL(SEL_COMMAND,ID_UNCHECK):FXSEL(SEL_COMMAND,ID_CHECK),nullptr); return 1; } // Change pattern long FXDirList::onCmdSetPattern(FXObject*,FXSelector,void* ptr){ setPattern((const char*)ptr); return 1; } // Update pattern long FXDirList::onUpdSetPattern(FXObject* sender,FXSelector,void*){ sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_SETVALUE),(void*)pattern.text()); return 1; } // Reverse sort order long FXDirList::onCmdSortReverse(FXObject*,FXSelector,void*){ if(getSortFunc()==ascending) setSortFunc(descending); else if(getSortFunc()==descending) setSortFunc(ascending); else if(getSortFunc()==ascendingCase) setSortFunc(descendingCase); else if(getSortFunc()==descendingCase) setSortFunc(ascendingCase); sortItems(); return 1; } // Update sender long FXDirList::onUpdSortReverse(FXObject* sender,FXSelector,void* ptr){ sender->handle(this,(getSortFunc()==descending || getSortFunc()==descendingCase) ? FXSEL(SEL_COMMAND,ID_CHECK) : FXSEL(SEL_COMMAND,ID_UNCHECK),ptr); return 1; } // Toggle case sensitivity long FXDirList::onCmdSortCase(FXObject*,FXSelector,void*){ if(getSortFunc()==ascending) setSortFunc(ascendingCase); else if(getSortFunc()==descending) setSortFunc(descendingCase); else if(getSortFunc()==ascendingCase) setSortFunc(ascending); else if(getSortFunc()==descendingCase) setSortFunc(descending); sortItems(); return 1; } // Check if case sensitive long FXDirList::onUpdSortCase(FXObject* sender,FXSelector,void* ptr){ sender->handle(this,(getSortFunc()==ascendingCase || getSortFunc()==descendingCase) ? FXSEL(SEL_COMMAND,ID_CHECK) : FXSEL(SEL_COMMAND,ID_UNCHECK),ptr); return 1; } /*******************************************************************************/ // Refresh; don't update if user is interacting with the list long FXDirList::onRefreshTimer(FXObject*,FXSelector,void*){ if(flags&FLAG_UPDATE){ listItems(false,true); // FIXME // listItems((counter==0),true); counter=(counter+1)%REFRESHFREQUENCY; } getApp()->addTimeout(this,ID_REFRESHTIMER,REFRESHINTERVAL); return 0; } // Force an immediate update of the list long FXDirList::onCmdRefresh(FXObject*,FXSelector,void*){ listItems(true,true); return 1; } // List items void FXDirList::listItems(FXbool force,FXbool notify){ FXDirItem *item; // Do root first time if(!getFirstItem() || force){ listRootItems(force,notify); } // Check all items item=(FXDirItem*)getFirstItem(); while(item){ // Is directory already populated? if(item->isDirectory() && item->getFirst()){ // Do the refresh if needed // FIXME if listChildItems() returns false, the item // may have gone away; remove it in that case... listChildItems(item,force,notify); // Go deeper if(item->getFirst()){ item=(FXDirItem*)item->getFirst(); continue; } } // Go up while(!item->getNext() && item->getParent()){ item=(FXDirItem*)item->getParent(); } // Go to next item=(FXDirItem*)item->getNext(); } } // FIXME // Interpret force flag properly. // Issue callbacks properly. // Windows:- can we finally list shares? #ifdef WIN32 // Windows flavor // List root directories void FXDirList::listRootItems(FXbool force,FXbool notify){ FXDirItem *oldlist=list; FXDirItem *newlist=nullptr; FXDirItem **po=&oldlist; FXDirItem **pn=&newlist; FXDirItem *item; FXDirItem *link; FXString name; FXuint mask; // Loop over drive letters for(mask=GetLogicalDrives(),name="A:\\"; mask; mask>>=1,name[0]++){ // Skip unavailable drives if(!(mask&1)) continue; // Find it, and take it out from the old list if found for(FXDirItem** pp=po; (item=*pp)!=nullptr; pp=&item->link){ if(FXString::comparecase(item->label,name)==0){ *pp=item->link; item->link=nullptr; goto fnd; } } // Not found; prepend before list item=(FXDirItem*)appendItem(nullptr,name,opendiricon,closeddiricon,nullptr,notify); // Next gets hung after this one fnd:*pn=item; pn=&item->link; // Update item information item->setHasItems(true); item->assoc=nullptr; item->size=0L; item->date=0; item->mode=FXIO::Directory; // Assume no associations switch(GetDriveTypeA(name.text())){ case DRIVE_REMOVABLE: if(name[0]=='A' || name[0]=='B'){ item->setOpenIcon(floppyicon); item->setClosedIcon(floppyicon); } else{ item->setOpenIcon(zipdiskicon); item->setClosedIcon(zipdiskicon); } break; case DRIVE_REMOTE: item->setOpenIcon(networkicon); item->setClosedIcon(networkicon); break; case DRIVE_CDROM: item->setOpenIcon(cdromicon); item->setClosedIcon(cdromicon); break; case DRIVE_RAMDISK: item->setOpenIcon(opendiricon); item->setClosedIcon(closeddiricon); break; case DRIVE_FIXED: item->setOpenIcon(harddiskicon); item->setClosedIcon(harddiskicon); break; case DRIVE_UNKNOWN: case DRIVE_NO_ROOT_DIR: default: item->setOpenIcon(opendiricon); item->setClosedIcon(closeddiricon); break; } // If association is found, use it if(associations) item->assoc=associations->findDirBinding(name); if(item->assoc){ if(item->assoc->miniicon) item->setClosedIcon(item->assoc->miniicon); if(item->assoc->miniiconopen) item->setOpenIcon(item->assoc->miniiconopen); } // Create item if(id()) item->create(); } // Wipe items remaining in list:- they have disappeared!! for(item=oldlist; item; item=link){ link=item->link; removeItem(item,notify); } // Remember new list list=newlist; // Update sort order sortRootItems(); } #else // UNIX flavor // List root directories void FXDirList::listRootItems(FXbool force,FXbool notify){ FXDirItem *item=(FXDirItem*)firstitem; // First time, make root node if(!item) item=list=(FXDirItem*)appendItem(nullptr,PATHSEPSTRING,harddiskicon,harddiskicon,nullptr,notify); // Update item information item->setHasItems(true); item->setOpenIcon(harddiskicon); item->setClosedIcon(harddiskicon); item->assoc=nullptr; item->size=0L; item->date=0; item->mode=FXIO::Directory; // If association is found, use it if(associations) item->assoc=associations->findDirBinding(PATHSEPSTRING); if(item->assoc){ if(item->assoc->miniicon) item->setClosedIcon(item->assoc->miniicon); if(item->assoc->miniiconopen) item->setOpenIcon(item->assoc->miniiconopen); } // Create item if(id()) item->create(); // Need to layout recalc(); } #endif /*******************************************************************************/ // List child items FXbool FXDirList::listChildItems(FXDirItem *par,FXbool force,FXbool notify){ FXString directory=getItemPathname(par); FXStat info; // See if directory still there if(FXStat::statFile(directory,info)){ // Last modified time of parent directory FXTime date=info.modified(); // Regenerate list if update forced or modified time changed if(force || date!=par->getDate()){ FXDirItem *oldlist=par->list; FXDirItem *newlist=nullptr; FXDirItem **po=&oldlist; FXDirItem **pn=&newlist; FXDirItem *olditem=nullptr; FXDirItem *newitem=nullptr; FXDirItem *link; FXString pathname; FXString name; FXuint mode; FXDir dir; // Managed to open directory if(dir.open(directory)){ // Process directory entries while(dir.next(name)){ // Never show "." and ".." in the directory list widget, and // optionally suppress hidden files or directories if(name[0]=='.'){ if(name[1]=='\0') continue; if(name[1]=='.' && name[2]=='\0') continue; if(!(options&DIRLIST_SHOWHIDDEN)) continue; } // Build full pathname of entry pathname=directory; if(!ISPATHSEP(pathname.tail())) pathname+=PATHSEPSTRING; pathname+=name; #ifdef WIN32 // Get file/link info if(!FXStat::statFile(pathname,info)) continue; mode=info.mode(); // Suppress hidden files or directories if((mode&FXIO::Hidden) && !(options&DIRLIST_SHOWHIDDEN)) continue; #else // Get file/link info if(!FXStat::statLink(pathname,info)) continue; mode=info.mode(); // If its a link, get file mode from target if(info.isLink()){ mode=FXStat::mode(pathname) | FXIO::SymLink; } #endif // Skip item if it is a file and we want only directories, or if it fails to match wildcard pattern if(!(mode&FXIO::Directory) && !((options&DIRLIST_SHOWFILES) && FXPath::match(name,pattern,matchmode))) continue; // Find it, and take it out from the old list if found for(FXDirItem** pp=po; (olditem=*pp)!=nullptr; pp=&olditem->link){ if(FXString::compare(olditem->label,name)==0){ *pp=olditem->link; olditem->link=nullptr; break; } } // Use a new item if forced, if there was no old item, or if the item information was changed if(force || !olditem || olditem->getDate()!=info.modified() || olditem->getSize()!=info.size() || olditem->getMode()!=mode){ // Make new item newitem=(FXDirItem*)createItem(name,nullptr,nullptr,nullptr); // Update item information newitem->setDraggable(draggable); newitem->setSize(info.size()); newitem->setDate(info.modified()); newitem->setMode(mode); newitem->setAssoc(nullptr); // Determine icons and type if(newitem->isDirectory()){ newitem->setHasItems(true); newitem->setOpenIcon(opendiricon); newitem->setClosedIcon(closeddiricon); if(associations) newitem->setAssoc(associations->findDirBinding(pathname)); } else if(newitem->isExecutable()){ newitem->setHasItems(false); newitem->setOpenIcon(applicationicon); newitem->setClosedIcon(applicationicon); if(associations) newitem->setAssoc(associations->findExecBinding(pathname)); } else{ newitem->setHasItems(false); newitem->setOpenIcon(documenticon); newitem->setClosedIcon(documenticon); if(associations) newitem->setAssoc(associations->findFileBinding(pathname)); } // If association is found, use it if(newitem->getAssoc()){ if(newitem->getAssoc()->miniicon) newitem->setClosedIcon(newitem->getAssoc()->miniicon); if(newitem->getAssoc()->miniiconopen) newitem->setOpenIcon(newitem->getAssoc()->miniiconopen); } // Create item if(id()) newitem->create(); // Replace existing item or add new one if(olditem){ newitem->list=olditem->list; // Old items list of children setItem(olditem,newitem,notify); } else{ appendItem(par,newitem,notify); } *pn=newitem; pn=&newitem->link; // Hang newitem in list } // No change else{ *pn=olditem; pn=&olditem->link; // Hang olditem in list } } dir.close(); } // Wipe items remaining in list:- they have disappeared!! for(olditem=oldlist; olditem; olditem=link){ link=olditem->link; removeItem(olditem,notify); } // Remember new list par->list=newlist; // Update sort order sortChildItems(par); // Now we know for sure whether we really have subitems or not par->setHasItems(!!par->first); // Update timestamp par->date=date; } return true; } return false; } /*******************************************************************************/ // Find child of item matching name static FXTreeItem* findChildItem(FXTreeItem* item,const FXString& name){ while(item){ #ifdef WIN32 if(FXString::comparecase(name,item->getText())==0) return item; #else if(FXString::compare(name,item->getText())==0) return item; #endif item=item->getNext(); } return nullptr; } // Return the item from the absolute pathname FXTreeItem* FXDirList::expandPath(const FXString& path,FXbool notify){ FXTreeItem *item=nullptr; if(!path.empty()){ FXTreeItem *it; FXString name; FXint beg=0; FXint end=0; #ifdef WIN32 if(ISPATHSEP(path[0])){ end++; if(ISPATHSEP(path[1])) end++; } else if(Ascii::isLetter(path[0]) && path[1]==':'){ end+=2; if(ISPATHSEP(path[2])) end++; } #else if(ISPATHSEP(path[0])) end++; #endif if(begfirst,name))==nullptr){ // Relist child items listChildItems((FXDirItem*)item,true,notify); // If we still don't find it, return closest existing item if((it=findChildItem(item->first,name))==nullptr) break; } // Skip over path separators while(ISPATHSEP(path[end])) end++; // Go deeper item=it; } } } } return item; } // Set current file; return true if success FXbool FXDirList::setCurrentFile(const FXString& pathname,FXbool notify){ FXTRACE((100,"%s::setCurrentFile(%s)\n",getClassName(),pathname.text())); FXTreeItem* item; if((item=expandPath(FXPath::absolute(pathname),notify))!=nullptr){ setAnchorItem(item); setCurrentItem(item,notify); makeItemVisible(item); return true; } return false; } // Get current (dir/file) name path FXString FXDirList::getCurrentFile() const { return getItemPathname(currentitem); } // Set current directory; return true if success FXbool FXDirList::setDirectory(const FXString& pathname,FXbool notify){ FXTRACE((100,"%s::setDirectory(%s)\n",getClassName(),pathname.text())); FXTreeItem* item; if((item=expandPath(FXPath::absolute(pathname),notify))!=nullptr){ expandTree(item,notify); setAnchorItem(item); setCurrentItem(item,notify); makeItemVisible(item); return true; } return false; } // Return directory part of path to current item FXString FXDirList::getDirectory() const { if(currentitem){ if(((const FXDirItem*)currentitem)->isDirectory()){ return getItemPathname(currentitem); } return getItemPathname(currentitem->parent); } return FXString::null; } /*******************************************************************************/ // Return absolute pathname of item FXString FXDirList::getItemPathname(const FXTreeItem* item) const { FXString path; if(item){ while(1){ path.prepend(item->getText()); item=item->parent; if(!item) break; if(item->parent) path.prepend(PATHSEP); } } return path; } // Return the (closest) item from the absolute pathname FXTreeItem* FXDirList::getPathnameItem(const FXString& path) const { FXTreeItem* item=nullptr; if(!path.empty()){ FXTreeItem* it; FXint beg=0; FXint end=0; #ifdef WIN32 if(ISPATHSEP(path[0])){ end++; if(ISPATHSEP(path[1])) end++; } else if(Ascii::isLetter(path[0]) && path[1]==':'){ end+=2; if(ISPATHSEP(path[2])) end++; } #else if(ISPATHSEP(path[0])) end++; #endif if(begfirst,path.mid(beg,end-beg)))==nullptr) break; // Skip over path separators while(ISPATHSEP(path[end])) end++; // Go deeper item=it; } } } } return item; } // Is file FXbool FXDirList::isItemFile(const FXTreeItem* item) const { return item && ((const FXDirItem*)item)->isFile(); } // Is directory FXbool FXDirList::isItemDirectory(const FXTreeItem* item) const { return item && ((const FXDirItem*)item)->isDirectory(); } // Is executable FXbool FXDirList::isItemExecutable(const FXTreeItem* item) const { return item && ((const FXDirItem*)item)->isExecutable(); } // Return true if this is a symbolic link item FXbool FXDirList::isItemSymlink(const FXTreeItem* item) const { return item && ((const FXDirItem*)item)->isSymlink(); } // Return file association of item FXFileAssoc* FXDirList::getItemAssoc(const FXTreeItem* item) const { return item ? ((const FXDirItem*)item)->getAssoc() : nullptr; } // Return the file size for this item FXlong FXDirList::getItemSize(const FXTreeItem* item) const { return item ? ((const FXDirItem*)item)->getSize() : 0; } // Return the date for this item, in nanoseconds FXTime FXDirList::getItemDate(const FXTreeItem* item) const { return item ? ((const FXDirItem*)item)->getDate() : 0; } // Return the mode bits for this item FXuint FXDirList::getItemMode(const FXTreeItem* item) const { return item ? ((const FXDirItem*)item)->getMode() : 0; } /*******************************************************************************/ // Expand tree FXbool FXDirList::expandTree(FXTreeItem* tree,FXbool notify){ FXDirItem* item=(FXDirItem*)tree; if(FXTreeList::expandTree(item,notify)){ if(item->isDirectory() && !item->getFirst()){ listChildItems(item,true,notify); } return true; } return false; } // Collapse tree FXbool FXDirList::collapseTree(FXTreeItem* tree,FXbool notify){ FXDirItem* item=(FXDirItem*)tree; if(FXTreeList::collapseTree(item,notify)){ if(item->isDirectory() && item->getFirst()){ removeItems(item->getFirst(),item->getLast(),notify); item->list=nullptr; } return true; } return false; } // Set the pattern to filter void FXDirList::setPattern(const FXString& ptrn,FXbool notify){ if(!ptrn.empty() && pattern!=ptrn){ pattern=ptrn; listItems(true,notify); } } // Change file match mode void FXDirList::setMatchMode(FXuint mode,FXbool notify){ if(matchmode!=mode){ matchmode=mode; listItems(true,notify); } } // Get list style FXbool FXDirList::showFiles() const { return (options&DIRLIST_SHOWFILES)!=0; } // Change list style void FXDirList::showFiles(FXbool flag,FXbool notify){ FXuint opts=(((0-flag)^options)&DIRLIST_SHOWFILES)^options; if(options!=opts){ options=opts; listItems(true,notify); } } // Return true if showing hidden files FXbool FXDirList::showHiddenFiles() const { return (options&DIRLIST_SHOWHIDDEN)!=0; } // Change show hidden files mode void FXDirList::showHiddenFiles(FXbool flag,FXbool notify){ FXuint opts=(((0-flag)^options)&DIRLIST_SHOWHIDDEN)^options; if(opts!=options){ options=opts; listItems(true,notify); } } // Change file associations; delete the old one unless it was shared void FXDirList::setAssociations(FXFileAssociations* assocs,FXbool owned,FXbool notify){ FXuint opts=options; options^=((owned-1)^options)&DIRLIST_NO_OWN_ASSOC; if(associations!=assocs){ if(!(opts&DIRLIST_NO_OWN_ASSOC)) delete associations; associations=assocs; listItems(true,notify); } } // Set draggable files void FXDirList::setDraggableFiles(FXbool flag,FXbool notify){ if(draggable!=flag){ draggable=flag; listItems(true,notify); } } // Save data void FXDirList::save(FXStream& store) const { FXTreeList::save(store); store << associations; store << opendiricon; store << closeddiricon; store << documenticon; store << applicationicon; store << cdromicon; store << harddiskicon; store << networkicon; store << floppyicon; store << zipdiskicon; store << pattern; store << matchmode; store << draggable; } // Load data void FXDirList::load(FXStream& store){ FXTreeList::load(store); store >> associations; store >> opendiricon; store >> closeddiricon; store >> documenticon; store >> applicationicon; store >> cdromicon; store >> harddiskicon; store >> networkicon; store >> floppyicon; store >> zipdiskicon; store >> pattern; store >> matchmode; store >> draggable; } // Cleanup FXDirList::~FXDirList(){ clearItems(); getApp()->removeChore(this); getApp()->removeTimeout(this,ID_REFRESHTIMER); if(!(options&DIRLIST_NO_OWN_ASSOC)) delete associations; delete opendiricon; delete closeddiricon; delete documenticon; delete applicationicon; delete cdromicon; delete harddiskicon; delete networkicon; delete floppyicon; delete zipdiskicon; associations=(FXFileAssociations*)-1L; list=(FXDirItem*)-1L; opendiricon=(FXGIFIcon*)-1L; closeddiricon=(FXGIFIcon*)-1L; documenticon=(FXGIFIcon*)-1L; applicationicon=(FXGIFIcon*)-1L; cdromicon=(FXIcon*)-1L; harddiskicon=(FXIcon*)-1L; networkicon=(FXIcon*)-1L; floppyicon=(FXIcon*)-1L; zipdiskicon=(FXIcon*)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDirSelector.cpp000066400000000000000000000463661455751074500230040ustar00rootroot00000000000000/******************************************************************************** * * * D i r e c t o r y S e l e c t i o n W i d g e t * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXSystem.h" #include "FXPath.h" #include "FXIO.h" #include "FXStat.h" #include "FXFile.h" #include "FXDir.h" #include "FXObjectList.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXAccelTable.h" #include "FXRecentFiles.h" #include "FXFont.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXGIFIcon.h" #include "FXBMPIcon.h" #include "FXFrame.h" #include "FXLabel.h" #include "FXButton.h" #include "FXMenuButton.h" #include "FXComposite.h" #include "FXPacker.h" #include "FXShell.h" #include "FXPopup.h" #include "FXMenuPane.h" #include "FXScrollBar.h" #include "FXTextField.h" #include "FXScrollArea.h" #include "FXTreeList.h" #include "FXTreeListBox.h" #include "FXVerticalFrame.h" #include "FXHorizontalFrame.h" #include "FXDirList.h" #include "FXList.h" #include "FXListBox.h" #include "FXDirSelector.h" #include "FXMenuCaption.h" #include "FXMenuCommand.h" #include "FXMenuCascade.h" #include "FXMenuRadio.h" #include "FXMenuCheck.h" #include "FXMenuSeparator.h" #include "FXTopWindow.h" #include "FXDialogBox.h" #include "FXInputDialog.h" #include "FXSeparator.h" #include "FXMessageBox.h" #include "icons.h" /* Notes: - Need a button to quickly hop to home directory. - Need a button to hop to current working directory. - Keep list of recently visited places. - Need button to hide/show hidden directories. */ #define DIRSTYLEMASK (TREELIST_SHOWS_LINES|TREELIST_SHOWS_BOXES|TREELIST_ROOT_BOXES) using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXDirSelector) FXDirSelectorMap[]={ FXMAPFUNC(SEL_COMMAND,FXDirSelector::ID_DIRNAME,FXDirSelector::onCmdName), FXMAPFUNC(SEL_OPENED,FXDirSelector::ID_DIRLIST,FXDirSelector::onCmdOpened), FXMAPFUNC(SEL_RIGHTBUTTONRELEASE,FXDirSelector::ID_DIRLIST,FXDirSelector::onPopupMenu), FXMAPFUNC(SEL_COMMAND,FXDirSelector::ID_HOME,FXDirSelector::onCmdHome), FXMAPFUNC(SEL_COMMAND,FXDirSelector::ID_WORK,FXDirSelector::onCmdWork), FXMAPFUNC(SEL_COMMAND,FXDirSelector::ID_DIRECTORY_UP,FXDirSelector::onCmdDirectoryUp), FXMAPFUNC(SEL_COMMAND,FXDirSelector::ID_VISIT,FXDirSelector::onCmdVisit), FXMAPFUNC(SEL_COMMAND,FXDirSelector::ID_BOOKMARK,FXDirSelector::onCmdBookmark), FXMAPFUNC(SEL_COMMAND,FXDirSelector::ID_UNBOOKMARK,FXDirSelector::onCmdUnBookmark), FXMAPFUNC(SEL_COMMAND,FXDirSelector::ID_NEW,FXDirSelector::onCmdNew), FXMAPFUNC(SEL_UPDATE,FXDirSelector::ID_NEW,FXDirSelector::onUpdNew), FXMAPFUNC(SEL_UPDATE,FXDirSelector::ID_REMOVE,FXDirSelector::onUpdSelected), FXMAPFUNC(SEL_COMMAND,FXDirSelector::ID_REMOVE,FXDirSelector::onCmdRemove), FXMAPFUNC(SEL_UPDATE,FXDirSelector::ID_MOVE,FXDirSelector::onUpdSelected), FXMAPFUNC(SEL_COMMAND,FXDirSelector::ID_MOVE,FXDirSelector::onCmdMove), FXMAPFUNC(SEL_UPDATE,FXDirSelector::ID_COPY,FXDirSelector::onUpdSelected), FXMAPFUNC(SEL_COMMAND,FXDirSelector::ID_COPY,FXDirSelector::onCmdCopy), FXMAPFUNC(SEL_UPDATE,FXDirSelector::ID_LINK,FXDirSelector::onUpdSelected), FXMAPFUNC(SEL_COMMAND,FXDirSelector::ID_LINK,FXDirSelector::onCmdLink), }; // Implementation FXIMPLEMENT(FXDirSelector,FXPacker,FXDirSelectorMap,ARRAYNUMBER(FXDirSelectorMap)) // Make directory selector widget FXDirSelector::FXDirSelector(FXComposite *p,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXPacker(p,opts,x,y,w,h,DEFAULT_SPACING,DEFAULT_SPACING,DEFAULT_SPACING,DEFAULT_SPACING,8,8),mrufiles(p->getApp(),"Visited Directories"){ FXString currentdirectory=FXSystem::getCurrentDirectory(); FXAccelTable *table=getShell()->getAccelTable(); target=tgt; message=sel; FXHorizontalFrame *buttons=new FXHorizontalFrame(this,LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH,0,0,0,0,0,0,0,0); accept=new FXButton(buttons,tr("&OK"),nullptr,nullptr,0,BUTTON_INITIAL|BUTTON_DEFAULT|LAYOUT_RIGHT|FRAME_RAISED|FRAME_THICK,0,0,0,0,20,20); cancel=new FXButton(buttons,tr("&Cancel"),nullptr,nullptr,0,BUTTON_DEFAULT|LAYOUT_RIGHT|FRAME_RAISED|FRAME_THICK,0,0,0,0,20,20); FXHorizontalFrame *field=new FXHorizontalFrame(this,LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X,0,0,0,0,0,0,0,0); new FXLabel(field,tr("&Directory:"),nullptr,JUSTIFY_LEFT|LAYOUT_CENTER_Y); dirname=new FXTextField(field,25,this,ID_DIRNAME,LAYOUT_FILL_X|LAYOUT_CENTER_Y|FRAME_SUNKEN|FRAME_THICK); FXVerticalFrame *frame=new FXVerticalFrame(this,LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK,0,0,0,0, 0,0,0,0, 0,0); new FXLabel(frame,tr("&Name"),nullptr,JUSTIFY_LEFT|JUSTIFY_CENTER_Y|LAYOUT_TOP|FRAME_RAISED|FRAME_THICK|LAYOUT_FILL_X); dirbox=new FXDirList(frame,this,ID_DIRLIST,LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|TREELIST_SHOWS_LINES|TREELIST_SHOWS_BOXES|TREELIST_BROWSESELECT); updiricon=new FXGIFIcon(getApp(),dirup_gif); homeicon=new FXGIFIcon(getApp(),gotohome); workicon=new FXGIFIcon(getApp(),gotowork); bookmarkicon=new FXGIFIcon(getApp(),bookmrk_gif); bookaddicon=new FXGIFIcon(getApp(),bookset_gif); bookdelicon=new FXGIFIcon(getApp(),bookdel_gif); bookclricon=new FXGIFIcon(getApp(),bookclr_gif); sortingicon=new FXBMPIcon(getApp(),sorting,0,IMAGE_ALPHAGUESS); newicon=new FXGIFIcon(getApp(),foldernew); deleteicon=new FXGIFIcon(getApp(),filedelete); moveicon=new FXGIFIcon(getApp(),filemove); copyicon=new FXGIFIcon(getApp(),filecopy); linkicon=new FXGIFIcon(getApp(),filelink); mrufiles.setTarget(this); mrufiles.setSelector(ID_VISIT); if(table){ table->addAccel(MKUINT(KEY_BackSpace,0),this,FXSEL(SEL_COMMAND,FXDirSelector::ID_DIRECTORY_UP)); table->addAccel(MKUINT(KEY_Delete,0),this,FXSEL(SEL_COMMAND,FXDirSelector::ID_REMOVE)); table->addAccel(MKUINT(KEY_h,CONTROLMASK),this,FXSEL(SEL_COMMAND,FXDirSelector::ID_HOME)); table->addAccel(MKUINT(KEY_w,CONTROLMASK),this,FXSEL(SEL_COMMAND,FXDirSelector::ID_WORK)); table->addAccel(MKUINT(KEY_n,CONTROLMASK),this,FXSEL(SEL_COMMAND,FXDirSelector::ID_NEW)); } dirbox->setDirectory(currentdirectory); dirname->setText(currentdirectory); dirbox->setFocus(); } // Set directory void FXDirSelector::setDirectory(const FXString& path){ dirname->setText(path); dirbox->setDirectory(path); } // Return directory FXString FXDirSelector::getDirectory() const { return dirname->getText(); } // Change wildcard matching pattern void FXDirSelector::setPattern(const FXString& ptrn){ dirbox->setPattern(ptrn); } // Return wildcard pattern FXString FXDirSelector::getPattern() const { return dirbox->getPattern(); } // Return true if showing files as well as directories FXbool FXDirSelector::showFiles() const { return dirbox->showFiles(); } // Show or hide normal files void FXDirSelector::showFiles(FXbool showing){ dirbox->showFiles(showing); } // Return true if showing hidden files FXbool FXDirSelector::showHiddenFiles() const { return dirbox->showHiddenFiles(); } // Show or hide hidden files void FXDirSelector::showHiddenFiles(FXbool showing){ dirbox->showHiddenFiles(showing); } // Change wildcard matching mode void FXDirSelector::setMatchMode(FXuint mode){ dirbox->setMatchMode(mode); } // Return wildcard matching mode FXuint FXDirSelector::getMatchMode() const { return dirbox->getMatchMode(); } // Change directory list style void FXDirSelector::setDirBoxStyle(FXuint style){ dirbox->setListStyle((dirbox->getListStyle()&~DIRSTYLEMASK) | (style&DIRSTYLEMASK)); } // Return directory list style FXuint FXDirSelector::getDirBoxStyle() const { return dirbox->getListStyle()&DIRSTYLEMASK; } // Typed in new directory name, open path in the tree long FXDirSelector::onCmdName(FXObject*,FXSelector,void*){ dirbox->setDirectory(dirname->getText()); return 1; } // Opened an item, making it the current one long FXDirSelector::onCmdOpened(FXObject*,FXSelector,void* ptr){ const FXTreeItem* item=(const FXTreeItem*)ptr; dirname->setText(dirbox->getItemPathname(item)); return 1; } // Back to home directory long FXDirSelector::onCmdHome(FXObject*,FXSelector,void*){ setDirectory(FXSystem::getHomeDirectory()); return 1; } // Back to current working directory long FXDirSelector::onCmdWork(FXObject*,FXSelector,void*){ setDirectory(FXSystem::getCurrentDirectory()); return 1; } // User clicked up directory button long FXDirSelector::onCmdDirectoryUp(FXObject*,FXSelector,void*){ setDirectory(FXPath::upLevel(getDirectory())); return 1; } // Move to recent directory long FXDirSelector::onCmdVisit(FXObject*,FXSelector,void* ptr){ FXString path((const FXchar*)ptr); if(FXStat::exists(path)){ setDirectory(path); return 1; } mrufiles.removeFile(path); getApp()->beep(); return 1; } // Bookmark this directory long FXDirSelector::onCmdBookmark(FXObject*,FXSelector,void*){ mrufiles.appendFile(dirbox->getDirectory()); return 1; } // Unbookmark this directory long FXDirSelector::onCmdUnBookmark(FXObject*,FXSelector,void*){ mrufiles.removeFile(dirbox->getDirectory()); return 1; } // Create new directory long FXDirSelector::onCmdNew(FXObject*,FXSelector,void*){ FXBMPIcon newfoldericon(getApp(),newfolder,0,IMAGE_ALPHAGUESS); FXString dir(getDirectory()); FXString name(tr("folder")); if(FXInputDialog::getString(name,this,tr("Create New Directory"),"Create new directory in: "+dir,&newfoldericon)){ FXString folder=FXPath::absolute(dir,name); if(FXStat::exists(folder)){ FXMessageBox::error(this,MBOX_OK,tr("Already Exists"),"File or directory %s already exists.\n",folder.text()); return 1; } if(!FXDir::create(folder)){ FXMessageBox::error(this,MBOX_OK,tr("Cannot Create"),"Cannot create directory %s.\n",folder.text()); return 1; } setDirectory(folder); } return 1; } // Update create new directory long FXDirSelector::onUpdNew(FXObject* sender,FXSelector,void*){ sender->handle(this,FXStat::isAccessible(getDirectory(),FXIO::Writing)?FXSEL(SEL_COMMAND,ID_ENABLE):FXSEL(SEL_COMMAND,ID_DISABLE),nullptr); return 1; } // Copy file or directory long FXDirSelector::onCmdCopy(FXObject*,FXSelector,void*){ FXString oldname=dirbox->getCurrentFile(); FXString newname=FXPath::directory(oldname)+PATHSEPSTRING "CopyOf"+FXPath::name(oldname); FXInputDialog inputdialog(this,tr("Copy File"),"Copy file from location:\n\n"+oldname+"\n\nto location:",nullptr,INPUTDIALOG_STRING,0,0,0,0); inputdialog.setText(newname); inputdialog.setNumColumns(60); if(inputdialog.execute()){ newname=inputdialog.getText(); if(!FXFile::copyFiles(oldname,newname,false)){ FXMessageBox::error(this,MBOX_OK,tr("Error Copying File"),"Unable to copy file:\n\n%s to: %s.",oldname.text(),newname.text()); } } return 1; } // Move file or directory long FXDirSelector::onCmdMove(FXObject*,FXSelector,void*){ FXString oldname=dirbox->getCurrentFile(); FXString newname=oldname; FXInputDialog inputdialog(this,tr("Move File"),"Move file from location:\n\n"+oldname+"\n\nto location:",nullptr,INPUTDIALOG_STRING,0,0,0,0); inputdialog.setText(newname); inputdialog.setNumColumns(60); if(inputdialog.execute()){ newname=inputdialog.getText(); if(!FXFile::moveFiles(oldname,newname,false)){ FXMessageBox::error(this,MBOX_OK,tr("Error Moving File"),"Unable to move file:\n\n%s to: %s.",oldname.text(),newname.text()); } } return 1; } // Link file or directory long FXDirSelector::onCmdLink(FXObject*,FXSelector,void*){ FXString oldname=dirbox->getCurrentFile(); FXString newname=FXPath::directory(oldname)+PATHSEPSTRING "LinkTo"+FXPath::name(oldname); FXInputDialog inputdialog(this,tr("Link File"),"Link file from location:\n\n"+oldname+"\n\nto location:",nullptr,INPUTDIALOG_STRING,0,0,0,0); inputdialog.setText(newname); inputdialog.setNumColumns(60); if(inputdialog.execute()){ newname=inputdialog.getText(); if(!FXFile::symlink(oldname,newname)){ FXMessageBox::error(this,MBOX_YES_NO,tr("Error Linking File"),"Unable to link file:\n\n%s to: %s.",oldname.text(),newname.text()); } } return 1; } // Remove file or directory long FXDirSelector::onCmdRemove(FXObject*,FXSelector,void*){ FXString fullname=dirbox->getCurrentFile(); if(MBOX_CLICKED_YES==FXMessageBox::warning(this,MBOX_YES_NO,tr("Deleting file"),"Are you sure you want to delete the file:\n\n%s",fullname.text())){ if(!FXFile::removeFiles(fullname,true)){ FXMessageBox::error(this,MBOX_YES_NO,tr("Error Deleting File"),"Unable to delete file:\n\n%s.",fullname.text()); } } return 1; } // Sensitize when files are selected long FXDirSelector::onUpdSelected(FXObject* sender,FXSelector,void*){ sender->handle(this,dirbox->getCurrentItem()?FXSEL(SEL_COMMAND,ID_ENABLE):FXSEL(SEL_COMMAND,ID_DISABLE),nullptr); return 1; } // Popup menu for item in file list long FXDirSelector::onPopupMenu(FXObject*,FXSelector,void* ptr){ FXEvent *event=(FXEvent*)ptr; if(event->moved) return 1; FXMenuPane filemenu(this); new FXMenuCommand(&filemenu,tr("Up one level"),updiricon,this,ID_DIRECTORY_UP); new FXMenuCommand(&filemenu,tr("Home directory"),homeicon,this,ID_HOME); new FXMenuCommand(&filemenu,tr("Work directory"),workicon,this,ID_WORK); new FXMenuSeparator(&filemenu); FXMenuPane sortmenu(this); new FXMenuCascade(&filemenu,tr("Sorting"),sortingicon,&sortmenu); new FXMenuCheck(&sortmenu,tr("Reverse"),dirbox,FXDirList::ID_SORT_REVERSE); new FXMenuCheck(&sortmenu,tr("Ignore case"),dirbox,FXDirList::ID_SORT_CASE); new FXMenuCheck(&sortmenu,tr("Hidden files"),dirbox,FXDirList::ID_TOGGLE_HIDDEN); FXMenuPane bookmenu(this); new FXMenuCascade(&filemenu,tr("Bookmarks"),bookmarkicon,&bookmenu); new FXMenuCommand(&bookmenu,tr("Set bookmark"),bookaddicon,this,ID_BOOKMARK); new FXMenuCommand(&bookmenu,tr("&Unset bookmark"),bookdelicon,this,ID_UNBOOKMARK); new FXMenuCommand(&bookmenu,tr("Clear bookmarks"),bookclricon,&mrufiles,FXRecentFiles::ID_CLEAR); FXMenuSeparator* sep1=new FXMenuSeparator(&bookmenu); sep1->setTarget(&mrufiles); sep1->setSelector(FXRecentFiles::ID_ANYFILES); new FXMenuCommand(&bookmenu,FXString::null,nullptr,&mrufiles,FXRecentFiles::ID_FILE_1); new FXMenuCommand(&bookmenu,FXString::null,nullptr,&mrufiles,FXRecentFiles::ID_FILE_2); new FXMenuCommand(&bookmenu,FXString::null,nullptr,&mrufiles,FXRecentFiles::ID_FILE_3); new FXMenuCommand(&bookmenu,FXString::null,nullptr,&mrufiles,FXRecentFiles::ID_FILE_4); new FXMenuCommand(&bookmenu,FXString::null,nullptr,&mrufiles,FXRecentFiles::ID_FILE_5); new FXMenuCommand(&bookmenu,FXString::null,nullptr,&mrufiles,FXRecentFiles::ID_FILE_6); new FXMenuCommand(&bookmenu,FXString::null,nullptr,&mrufiles,FXRecentFiles::ID_FILE_7); new FXMenuCommand(&bookmenu,FXString::null,nullptr,&mrufiles,FXRecentFiles::ID_FILE_8); new FXMenuCommand(&bookmenu,FXString::null,nullptr,&mrufiles,FXRecentFiles::ID_FILE_9); new FXMenuCommand(&bookmenu,FXString::null,nullptr,&mrufiles,FXRecentFiles::ID_FILE_10); new FXMenuSeparator(&filemenu); new FXMenuCommand(&filemenu,tr("New directory..."),newicon,this,ID_NEW); new FXMenuCommand(&filemenu,tr("Copy..."),copyicon,this,ID_COPY); new FXMenuCommand(&filemenu,tr("Move..."),moveicon,this,ID_MOVE); new FXMenuCommand(&filemenu,tr("Link..."),linkicon,this,ID_LINK); new FXMenuCommand(&filemenu,tr("Delete..."),deleteicon,this,ID_REMOVE); filemenu.create(); filemenu.popup(nullptr,event->root_x,event->root_y); getApp()->runModalWhileShown(&filemenu); return 1; } // Change file associations void FXDirSelector::setAssociations(FXFileAssociations* assoc,FXbool owned){ dirbox->setAssociations(assoc,owned); } // Return file associations FXFileAssociations* FXDirSelector::getAssociations() const { return dirbox->getAssociations(); } // Save data void FXDirSelector::save(FXStream& store) const { FXPacker::save(store); store << dirbox; store << dirname; store << accept; store << cancel; store << updiricon; store << homeicon; store << workicon; store << bookmarkicon; store << bookaddicon; store << bookdelicon; store << bookclricon; store << sortingicon; store << newicon; store << deleteicon; store << moveicon; store << copyicon; store << linkicon; } // Load data void FXDirSelector::load(FXStream& store){ FXPacker::load(store); store >> dirbox; store >> dirname; store >> accept; store >> cancel; store >> updiricon; store >> homeicon; store >> workicon; store >> bookmarkicon; store >> bookaddicon; store >> bookdelicon; store >> bookclricon; store >> sortingicon; store >> newicon; store >> deleteicon; store >> moveicon; store >> copyicon; store >> linkicon; } // Clean up FXDirSelector::~FXDirSelector(){ FXAccelTable *table=getShell()->getAccelTable(); if(table){ table->removeAccel(MKUINT(KEY_BackSpace,0)); table->removeAccel(MKUINT(KEY_h,CONTROLMASK)); table->removeAccel(MKUINT(KEY_w,CONTROLMASK)); } delete updiricon; delete homeicon; delete workicon; delete bookmarkicon; delete bookaddicon; delete bookdelicon; delete bookclricon; delete sortingicon; delete newicon; delete deleteicon; delete moveicon; delete copyicon; delete linkicon; dirbox=(FXDirList*)-1L; dirname=(FXTextField*)-1L; accept=(FXButton*)-1L; cancel=(FXButton*)-1L; updiricon=(FXIcon*)-1L; homeicon=(FXIcon*)-1L; workicon=(FXIcon*)-1L; bookmarkicon=(FXIcon*)-1L; bookaddicon=(FXIcon*)-1L; bookdelicon=(FXIcon*)-1L; bookclricon=(FXIcon*)-1L; sortingicon=(FXIcon*)-1L; newicon=(FXIcon*)-1L; deleteicon=(FXIcon*)-1L; moveicon=(FXIcon*)-1L; copyicon=(FXIcon*)-1L; linkicon=(FXIcon*)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDirVisitor.cpp000066400000000000000000000162561455751074500226560ustar00rootroot00000000000000/******************************************************************************** * * * D i r e c t o r y V i s i t o r * * * ********************************************************************************* * Copyright (C) 2008,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXString.h" #include "FXIO.h" #include "FXStat.h" #include "FXFile.h" #include "FXPath.h" #include "FXDir.h" #include "FXDirVisitor.h" /* Notes: - There are three return codes to influence processing: 0 : Skip item, move to next 1 : Continue with processing. 2 : Bail on the whole thing. - Automatically skip directories already being visited to avoid circular symlinks from causing infinite recursion. - Also skip directories with insufficient permissions. - Recursion limiter feature added; allows one to stop below a certain level. */ using namespace FX; /*******************************************************************************/ namespace FX { // Keep track of visited directories, avoiding infinite recursion struct FXDirVisitor::Seen { FXStat stat; // File status Seen** current; // Current one Seen* last; // Link last visited directory // Save old value of current, point it here Seen(Seen** cur):current(cur),last(*cur){ *current=this; } // Restore old value of current ~Seen(){ *current=last; } }; // Return info on current file const FXStat& FXDirVisitor::info() const { return current->stat; } // Recursively traverse starting from path FXuint FXDirVisitor::traverse(const FXString& path,FXint depth){ if(0last){ if(node.stat.index()==s->stat.index() && node.stat.volume()==s->stat.volume()) return 0; } // Conditionally enter subdirectories if((code=enter(path))==1){ FXDir directory(path); FXString name; // Traverse items in directory while(directory.next(name)){ // Non-navigational directory item if(!(name[0]=='.' && (name[1]=='\0' || (name[1]=='.' && name[2]=='\0')))){ // Traverse sub-item, decreasing recursion depth by one if(traverse(path+(ISPATHSEP(path.tail())?"":PATHSEPSTRING)+name,depth-1)==2){ // Leave directory leave(path); // Return bail code return 2; } } } // Leave directory return leave(path); } return code; } // Regular file return visit(path); } } return 0; } // Enter directory FXuint FXDirVisitor::enter(const FXString&){ return 1; } // Handle file FXuint FXDirVisitor::visit(const FXString&){ return 1; } // Leave directory FXuint FXDirVisitor::leave(const FXString&){ return 1; } // Destructor FXDirVisitor::~FXDirVisitor(){ } /*******************************************************************************/ // Recursively traverse starting from path FXuint FXGlobVisitor::traverse(const FXString& path,const FXString& wild,FXuint opts,FXint depth){ wildcard=wild; options=opts; return FXDirVisitor::traverse(path,depth); } // Enter directory FXuint FXGlobVisitor::enter(const FXString& path){ FXuint mode=(options&FXDir::CaseFold)?(FXPath::NoEscape|FXPath::CaseFold):(FXPath::NoEscape); #ifdef WIN32 return !(options&FXDir::NoDirs) && ((options&FXDir::HiddenDirs) || !FXStat::isHidden(path)) && ((options&FXDir::AllDirs) || FXPath::match(path,wildcard,mode)); #else return !(options&FXDir::NoDirs) && ((options&FXDir::HiddenDirs) || !FXPath::isHidden(path)) && ((options&FXDir::AllDirs) || FXPath::match(path,wildcard,mode)); #endif } // Handle file FXuint FXGlobVisitor::visit(const FXString& path){ FXuint mode=(options&FXDir::CaseFold)?(FXPath::NoEscape|FXPath::CaseFold):(FXPath::NoEscape); #ifdef WIN32 return !(options&FXDir::NoFiles) && ((options&FXDir::HiddenFiles) || !FXStat::isHidden(path)) && ((options&FXDir::AllFiles) || FXPath::match(path,wildcard,mode)); #else return !(options&FXDir::NoFiles) && ((options&FXDir::HiddenFiles) || !FXPath::isHidden(path)) && ((options&FXDir::AllFiles) || FXPath::match(path,wildcard,mode)); #endif } // Leave directory FXuint FXGlobVisitor::leave(const FXString&){ return 1; } // Destructor FXGlobVisitor::~FXGlobVisitor(){ } /*******************************************************************************/ // Create new glob counting visitor FXGlobCountVisitor::FXGlobCountVisitor():countFolders(0),countFiles(0),countBytes(0),maxDepth(0),depth(0){ } // Start traversal of path FXuint FXGlobCountVisitor::traverse(const FXString& path,const FXString& wild,FXuint opts,FXint limit){ countFolders=countFiles=countBytes=maxDepth=depth=0; return FXGlobVisitor::traverse(path,wild,opts,limit); } // Enter directory FXuint FXGlobCountVisitor::enter(const FXString& path){ if(FXGlobVisitor::enter(path)){ countFolders++; depth++; return 1; } return 0; } // He mister tally man, tally me banana... FXuint FXGlobCountVisitor::visit(const FXString& path){ if(FXGlobVisitor::visit(path)){ countBytes+=info().size(); countFiles++; return 1; } return 0; } // Leave directory FXuint FXGlobCountVisitor::leave(const FXString& path){ if(FXGlobVisitor::leave(path)){ maxDepth=FXMAX(maxDepth,depth); depth--; return 1; } return 0; } // Destructor FXGlobCountVisitor::~FXGlobCountVisitor(){ } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDirWatch.cpp000066400000000000000000000352541455751074500222640ustar00rootroot00000000000000/******************************************************************************** * * * W a t c h D i r e c t o r i e s f o r C h a n g e s * * * ********************************************************************************* * Copyright (C) 2006,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxchar.h" #include "fxmath.h" #include "FXException.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXEvent.h" #include "FXStringDictionary.h" #include "FXDictionary.h" #include "FXReverseDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXPath.h" #include "FXWindow.h" #include "FXApp.h" #include "FXIO.h" #include "FXStat.h" #include "FXDirWatch.h" /* Notes: - Make this more elegant. - See also inotify(7) and fanotify(7). - Perhaps only create & add handle to FXApp when first watch is created, and remove it when last watch is removed. - For inotify_event, the following may be of some importance: "The name field is only present when an event is returned for a file inside a watched directory; it identifies the file pathname relative to the watched directory. This pathname is null-terminated, and may include further null bytes to align subsequent reads to a suitable address boundary." - In other words, if watching a file then there is no name string in the inotify_event!! - We need a fallback version that uses timers. */ // Maximum message size #define MAXMESSAGE 8192 // Bad handle value #ifdef WIN32 #define BadHandle INVALID_HANDLE_VALUE #else #define BadHandle -1 #endif // Test #undef HAVE_INOTIFY_INIT1 using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXDirWatch) FXDirWatchMap[]={ FXMAPFUNC(SEL_IO_READ,FXDirWatch::ID_CHANGE,FXDirWatch::onMessage), FXMAPFUNC(SEL_TIMEOUT,FXDirWatch::ID_CHANGE,FXDirWatch::onMessage) }; // Object implementation FXIMPLEMENT(FXDirWatch,FXObject,FXDirWatchMap,ARRAYNUMBER(FXDirWatchMap)); // Add handler to application FXDirWatch::FXDirWatch(FXApp* a,FXObject* tgt,FXSelector sel):app(a),hnd(BadHandle),timestamp(0),target(tgt),message(sel){ FXTRACE((1,"FXDirWatch::FXDirWatch(%p,%p,%d)\n",a,tgt,sel)); } // Remove handler from application FXDirWatch::~FXDirWatch(){ FXTRACE((1,"FXDirWatch::~FXDirWatch\n")); clearAll(); app=(FXApp*)-1L; target=(FXObject*)-1L; } #if defined(WIN32) ///////////////////////////////////////////////////////////// // Event filter flags const FXuint FILTER=FILE_NOTIFY_CHANGE_FILE_NAME|FILE_NOTIFY_CHANGE_DIR_NAME|FILE_NOTIFY_CHANGE_ATTRIBUTES|FILE_NOTIFY_CHANGE_SIZE|FILE_NOTIFY_CHANGE_LAST_WRITE; // FIXME important note: watches contents of directory, not a file. // FIXME also, does not watch directory itself. // FIXME thus, to watch directory /path/dir, you may need to watch /path AND /path/dir, // FIXME or watch /path with recursive option.... // Add path to watch; return true if added FXbool FXDirWatch::addWatch(const FXString& path){ FXTRACE((1,"FXDirWatch::addWatch(%s)\n",path.text())); if(!pathToHandle.has(path)){ #if defined(UNICODE) FXnchar unifile[MAXPATHLEN]; utf2ncs(unifile,path.text(),MAXPATHLEN); FXuint attrs=::GetFileAttributesW(unifile); if((attrs!=INVALID_FILE_ATTRIBUTES) && (attrs&FILE_ATTRIBUTE_DIRECTORY)){ HANDLE h=::FindFirstChangeNotificationW(unifile,false,FILTER); #else FXuint attrs=::GetFileAttributesA(path.text()); if((attrs!=INVALID_FILE_ATTRIBUTES) && (attrs&FILE_ATTRIBUTE_DIRECTORY)){ HANDLE h=::FindFirstChangeNotificationA(path.text(),false,FILTER); #endif if(h!=BadHandle){ app->addInput(this,ID_CHANGE,h,INPUT_READ,(FXptr)h); pathToHandle[path]=(FXptr)h; handleToPath[(FXptr)h]=path; FXTRACE((1,"%s -> %d\n",path.text(),h)); return true; } } } return false; } // Remove path to watch; return true if removed FXbool FXDirWatch::remWatch(const FXString& path){ FXTRACE((1,"FXDirWatch::remWatch(%s)\n",path.text())); if(pathToHandle.has(path)){ HANDLE h=(HANDLE)pathToHandle[path]; pathToHandle.remove(path); handleToPath.remove((FXptr)h); app->removeInput(h,INPUT_READ); if(FindCloseChangeNotification(h)!=0){ FXTRACE((1,"%s -> %d\n",path.text(),h)); return true; } } return false; } // Clear all watches FXbool FXDirWatch::clearAll(){ FXTRACE((1,"FXDirWatch::clearAll\n")); if(pathToHandle.used()!=0){ for(FXint i=0; iremoveInput(h,INPUT_READ); FindCloseChangeNotification(h); } } pathToHandle.clear(); handleToPath.clear(); return true; } return false; } // Fire signal message to target long FXDirWatch::onMessage(FXObject*,FXSelector,void* ptr){ FXTRACE((1,"FXDirWatch::onMessage()\n")); FXString pathname; HANDLE h=(HANDLE)ptr; FindNextChangeNotification(h); pathname=handleToPath[(FXptr)h]; FXTRACE((2,"pathname=\"%s\"\n",pathname.text())); #if 0 BOOL ReadDirectoryChangesW( HANDLE hDirectory, LPVOID lpBuffer, DWORD nBufferLength, BOOL bWatchSubtree, DWORD dwNotifyFilter, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped, LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine ); struct FILE_NOTIFY_INFORMATION { DWORD NextEntryOffset; DWORD Action; DWORD FileNameLength; WCHAR FileName[1]; }; USES_CONVERSION; HANDLE hDir = CreateFile("c:\\Folder", // pointer to the file name FILE_LIST_DIRECTORY, // access (read-write) mode FILE_SHARE_READ|FILE_SHARE_DELETE, // share mode NULL, // security descriptor OPEN_EXISTING, // how to create FILE_FLAG_BACKUP_SEMANTICS, // file attributes NULL // file with attributes to copy ); FILE_NOTIFY_INFORMATION Buffer[1024]; DWORD BytesReturned; while( ReadDirectoryChangesW(hDir, // handle to directory &Buffer, // read results buffer sizeof(Buffer), // length of buffer TRUE, // monitoring option FILE_NOTIFY_CHANGE_SECURITY|FILE_NOTIFY_CHANGE_CREATION|FILE_NOTIFY_CHANGE_LAST_ACCESS|FILE_NOTIFY_CHANGE_LAST_WRITE|FILE_NOTIFY_CHANGE_SIZE|FILE_NOTIFY_CHANGE_ATTRIBUTES|FILE_NOTIFY_CHANGE_DIR_NAME|FILE_NOTIFY_CHANGE_FILE_NAME, // filter conditions &BytesReturned, // bytes returned NULL, // overlapped buffer NULL)){ // completion routine ... } ::CloseHandle(hDir); #endif return 1; } #elif defined(HAVE_INOTIFY_INIT1) ////////////////////////////////////////////// // Event filter flags const FXuint FILTER_DIRS=IN_ATTRIB|IN_DELETE_SELF|IN_MOVE|IN_CREATE|IN_DELETE; const FXuint FILTER_FILE=IN_ATTRIB|IN_DELETE_SELF|IN_MOVE|IN_MODIFY|IN_MOVE_SELF; // Add path to watch; return true if added FXbool FXDirWatch::addWatch(const FXString& path){ FXTRACE((1,"FXDirWatch::addWatch(%s)\n",path.text())); if(!pathToHandle.has(path)){ FXStat stat; if(FXStat::statFile(path,stat)){ if(pathToHandle.used()==0){ hnd=::inotify_init1(IN_CLOEXEC); //hnd=::inotify_init1(IN_CLOEXEC|O_NONBLOCK); if(hnd!=BadHandle){ getApp()->addInput(this,ID_CHANGE,hnd,INPUT_READ); } } if(hnd!=BadHandle){ FXuint mask=stat.isDirectory()?FILTER_DIRS:FILTER_FILE; FXInputHandle h=::inotify_add_watch(hnd,path.text(),mask); if(h!=BadHandle){ pathToHandle[path]=(FXptr)(FXival)h; handleToPath[(FXptr)(FXival)h]=path; FXTRACE((1,"FXDirWatch::addWatch(%s) -> %d\n",path.text(),h)); return true; } } } } return false; } // Remove path to watch; return true if removed FXbool FXDirWatch::remWatch(const FXString& path){ FXTRACE((1,"FXDirWatch::remWatch(%s)\n",path.text())); if(pathToHandle.has(path)){ if(hnd!=BadHandle){ FXInputHandle h=(FXival)pathToHandle[path]; pathToHandle.remove(path); handleToPath.remove((FXptr)(FXival)h); if(::inotify_rm_watch(hnd,h)!=BadHandle){ FXTRACE((1,"FXDirWatch::remWatch(%s) -> %d\n",path.text(),h)); if(pathToHandle.used()==0){ app->removeInput(hnd,INPUT_READ); ::close(hnd); hnd=BadHandle; } return true; } } } return false; } // Clear all watches FXbool FXDirWatch::clearAll(){ FXTRACE((1,"FXDirWatch::clearAll\n")); if(pathToHandle.used()!=0){ for(FXint i=0; iremoveInput(hnd,INPUT_READ); ::close(hnd); hnd=BadHandle; return true; } return false; } // Fire signal message to target long FXDirWatch::onMessage(FXObject*,FXSelector,void*){ FXTRACE((1,"FXDirWatch::onMessage()\n")); FXival expect=0; if(0<=::ioctl(hnd,FIONREAD,&expect) && 0wd],ne->name); FXTRACE((2,"wd=%d mask=%x cookie=%u len=%u name=\"%s\" pathname=\"%s\"\n",ne->wd,ne->mask,ne->cookie,ne->len,ne->name,pathname.text())); if(ne->mask&IN_ACCESS) FXTRACE((2,"IN_ACCESS ")); if(ne->mask&IN_ATTRIB) FXTRACE((2,"IN_ATTRIB ")); if(ne->mask&IN_CLOSE_NOWRITE) FXTRACE((2,"IN_CLOSE_NOWRITE ")); if(ne->mask&IN_CLOSE_WRITE) FXTRACE((2,"IN_CLOSE_WRITE ")); if(ne->mask&IN_CREATE) FXTRACE((2,"IN_CREATE ")); if(ne->mask&IN_DELETE) FXTRACE((2,"IN_DELETE ")); if(ne->mask&IN_DELETE_SELF) FXTRACE((2,"IN_DELETE_SELF ")); if(ne->mask&IN_IGNORED) FXTRACE((2,"IN_IGNORED ")); if(ne->mask&IN_ISDIR) FXTRACE((2,"IN_ISDIR ")); if(ne->mask&IN_MODIFY) FXTRACE((2,"IN_MODIFY ")); if(ne->mask&IN_MOVE_SELF) FXTRACE((2,"IN_MOVE_SELF ")); if(ne->mask&IN_MOVED_FROM) FXTRACE((2,"IN_MOVED_FROM ")); if(ne->mask&IN_MOVED_TO) FXTRACE((2,"IN_MOVED_TO ")); if(ne->mask&IN_OPEN) FXTRACE((2,"IN_OPEN ")); if(ne->mask&IN_Q_OVERFLOW) FXTRACE((2,"IN_Q_OVERFLOW ")); if(ne->mask&IN_UNMOUNT) FXTRACE((2,"IN_UNMOUNT ")); FXTRACE((2,"\n")); if(ne->mask&(IN_MOVED_TO|IN_CREATE)){ FXTRACE((1,"SEL_INSERTED \"%s\"\n",pathname.text())); } else if(ne->mask&(IN_DELETE|IN_MOVED_FROM)){ FXTRACE((1,"SEL_DELETED \"%s\"\n",pathname.text())); } else if(ne->mask&(IN_ATTRIB)){ FXTRACE((1,"SEL_CHANGED \"%s\"\n",pathname.text())); } pne+=sizeof(inotify_event)+ne->len; } } freeElms(ptr); } } return 1; } #else ////////////////////////////////////////////////////////////////////////// // Interval between refreshes const FXTime REFRESHINTERVAL=1000000000; // Add path to watch; return true if added FXbool FXDirWatch::addWatch(const FXString& path){ FXTRACE((1,"FXDirWatch::addWatch(%s)\n",path.text())); if(!pathToHandle.has(path)){ FXStat stat; if(FXStat::statFile(path,stat)){ if(pathToHandle.used()==0){ getApp()->addTimeout(this,ID_CHANGE,REFRESHINTERVAL); } pathToHandle[path]=(FXptr)(stat.isFile()?1L:2L); return true; } } return false; } // Remove path to watch; return true if removed FXbool FXDirWatch::remWatch(const FXString& path){ FXTRACE((1,"FXDirWatch::remWatch(%s)\n",path.text())); if(pathToHandle.has(path)){ pathToHandle.remove(path); if(pathToHandle.used()==0){ getApp()->removeTimeout(this,ID_CHANGE); } return true; } return false; } // Clear all watches FXbool FXDirWatch::clearAll(){ FXTRACE((1,"FXDirWatch::clearAll()\n")); if(pathToHandle.used()!=0){ pathToHandle.clear(); getApp()->removeTimeout(this,ID_CHANGE); return true; } return false; } // Fire signal message to target long FXDirWatch::onMessage(FXObject*,FXSelector,void*){ FXTRACE((1,"FXDirWatch::onMessage()\n")); if(pathToHandle.used()!=0){ FXTime newstamp=0; for(FXint i=0; iaddTimeout(this,ID_CHANGE,REFRESHINTERVAL); } return 1; } #endif ///////////////////////////////////////////////////////////////////////// } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDispatcher.cpp000066400000000000000000000253601455751074500226420ustar00rootroot00000000000000/******************************************************************************** * * * C a l l b a c k D i s p a t c h e r * * * ********************************************************************************* * Copyright (C) 2006,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXAtomic.h" #include "FXElement.h" #include "FXHash.h" #include "FXCallback.h" #include "FXAutoThreadStorageKey.h" #include "FXThread.h" #include "FXException.h" #include "FXReactor.h" #include "FXDispatcher.h" /* Notes: - FXDispatcher extends FXReactor by implementing convenient callbacks for handles, signals, timers, and idle processing performed by FXReactor. - The callbacks may connect to member functions of classes, but also global functions. - Special handles [e.g. wakeup pipe or display connection], may be added by addHandle(hnd,mode) instead of addHandle(cb,hnd,mode,ptr). In this case, no hash entry will be added, which means when these types of handles are dispatched via overrides of dispatchHandle(), they must be filtered out prior to being processed by this implementation of dispatchHandle(); otherwise, a core dump may result. - Likewise, addSignal(sig,async) may be used in lieu of addSignal(cb,sig,ptr,async) to establis special ways of handling select signals. The addSignal(sig,async) will not establish a handler callback, and thus when such a signal is raised, it must be filtered via overrides of dispatchSignal prior to being processed by this implementation of dispatchSignal(); otherwise, a core dump may result. - Sample usage: disp->addInterval(TimeoutCallback::create(target),dt,ptr); FIXME maybe this is better: disp->addInterval(FXObject* tgt,FXSelector sel,FXTime ns=1000000000,FXptr ptr=nullptr); OK, if message map only contains function-pointers [method_call() template-generated function call addresses], then we can look up this method-call: long (*caller)(FXObject*,FXSelector,void*); caller=metaClass.search(sel); We can store caller into callback struct! Then: caller(target,this,FXSEL(SEL_TIMEOUT,message),userdata); */ using namespace FX; /*******************************************************************************/ namespace FX { // Handle callback struct FXDispatcher::Handle { HandleCallback cb; // Callback void *ptr; // User data }; // Signal callback struct FXDispatcher::Signal { SignalCallback cb; // Callback void *ptr; // User data }; // Timer callback struct FXDispatcher::Timer { TimeoutCallback cb; // Callback FXTime due; // When timer is due (ns) Timer *next; // Next timeout in list void *ptr; // User data }; // Idle callback struct FXDispatcher::Idle { IdleCallback cb; // Callback Idle *next; // Next chore in list void *ptr; // User data }; /*******************************************************************************/ // Construct dispatcher object FXDispatcher::FXDispatcher():signals(nullptr),timers(nullptr),idles(nullptr),timerrecs(nullptr),idlerecs(nullptr){ } // Initialize dispatcher FXbool FXDispatcher::init(){ if(FXReactor::init()){ callocElms(signals,64); timers=nullptr; idles=nullptr; timerrecs=nullptr; idlerecs=nullptr; return true; } return false; } /*******************************************************************************/ // Add signal to signal-set observed by the dispatcher FXbool FXDispatcher::addSignal(SignalCallback cb,FXint sig,void* ptr,FXbool async){ if(FXReactor::addSignal(sig,async)){ signals[sig]=new Signal; signals[sig]->cb=cb; // Set callback signals[sig]->ptr=ptr; // Set pointer return true; } return false; } // Add signal to signal-set observed by the dispatcher FXbool FXDispatcher::addSignal(FXint sig,FXbool async){ return FXReactor::addSignal(sig,async); } // Remove signal from signal-set observed by the dispatcher FXbool FXDispatcher::remSignal(FXint sig){ if(FXReactor::remSignal(sig)){ delete signals[sig]; signals[sig]=nullptr; return true; } return false; } // Dispatch when a signal was fired FXbool FXDispatcher::dispatchSignal(FXint sig){ if(hasSignal(sig)){ return signals[sig] && signals[sig]->cb(this,sig,signals[sig]->ptr); } return false; } /*******************************************************************************/ // Add timeout callback cb at time due (ns since Epoch). void* FXDispatcher::addTimeout(TimeoutCallback cb,FXTime due,void* ptr){ void* res=nullptr; if(isInitialized()){ Timer **tt=&timers,*t,*x; while((x=*tt)!=nullptr){ if(x->cb==cb){ *tt=x->next; res=x->ptr; t=x; goto a; } tt=&x->next; } if(timerrecs){ t=timerrecs; timerrecs=t->next; } else{ t=new Timer; } a: t->cb=cb; t->due=due; t->next=nullptr; t->ptr=ptr; tt=&timers; while((x=*tt) && x->due<=t->due){ tt=&x->next; } t->next=*tt; *tt=t; } return res; } // Add timeout callback cb after time interval (ns). void* FXDispatcher::addInterval(TimeoutCallback cb,FXTime interval,void* ptr){ return addTimeout(cb,FXThread::time()+interval,ptr); } // Remove timeout callback cb. void* FXDispatcher::remTimeout(TimeoutCallback cb){ void* res=nullptr; if(isInitialized()){ Timer **tt=&timers,*t; while((t=*tt)!=nullptr){ if(t->cb==cb){ *tt=t->next; res=t->ptr; t->next=timerrecs; timerrecs=t; continue; } tt=&t->next; } } return res; } // Return the remaining time, in nanoseconds FXTime FXDispatcher::getTimeout(TimeoutCallback cb) const { for(Timer *t=timers; t; t=t->next){ if(t->cb==cb) return t->due; } return forever; } // Return timeout when something needs to happen FXTime FXDispatcher::nextTimeout(){ return timers ? timers->due : forever; } // Return true if timeout callback cb been set. FXbool FXDispatcher::hasTimeout(TimeoutCallback cb) const { for(Timer *t=timers; t; t=t->next){ if(t->cb==cb) return true; } return false; } // Dispatch when timeout expires FXbool FXDispatcher::dispatchTimeout(FXTime due){ Timer *t=timers; if(t && t->due<=due){ timers=t->next; t->next=timerrecs; timerrecs=t; return t->cb(this,t->due,t->ptr); } return false; } /*******************************************************************************/ // Add idle callback be executed when dispatch about to block. void* FXDispatcher::addIdle(IdleCallback cb,void* ptr){ void* res=nullptr; if(isInitialized()){ Idle **cc=&idles,*c,*x; while((x=*cc)!=nullptr){ // Search list for cb if(x->cb==cb){ *cc=x->next; res=x->ptr; c=x; goto a; } cc=&x->next; } if(idlerecs){ // Recycled chore c=idlerecs; idlerecs=c->next; } else{ // Fresh chore c=new Idle; } a: c->cb=cb; c->ptr=ptr; c->next=nullptr; while((x=*cc)!=nullptr){ // Continue to end of list cc=&x->next; } *cc=c; } return res; } // Remove idle callback cb. void* FXDispatcher::remIdle(IdleCallback cb){ void *res=nullptr; if(isInitialized()){ Idle **cc=&idles,*c; while((c=*cc)!=nullptr){ if(c->cb==cb){ *cc=c->next; res=c->ptr; c->next=idlerecs; idlerecs=c; continue; } cc=&c->next; } } return res; } // Return true if idle callback cb been set. FXbool FXDispatcher::hasIdle(IdleCallback cb) const { for(Idle *c=idles; c; c=c->next){ if(c->cb==cb) return true; } return false; } // Dispatch one idle callback. FXbool FXDispatcher::dispatchIdle(){ Idle *c=idles; if(c){ idles=c->next; c->next=idlerecs; idlerecs=c; return c->cb(this,c->ptr); } return false; } /*******************************************************************************/ // Add callback cb with new handle hnd to watch-list FXbool FXDispatcher::addHandle(HandleCallback cb,FXInputHandle hnd,FXuint mode,void* ptr){ if(FXReactor::addHandle(hnd,mode)){ Handle *handle=new Handle(); handle->cb=cb; handle->ptr=ptr; handles.insert(reinterpret_cast(hnd),handle); return true; } return false; } // Add new handle hnd to watch-list FXbool FXDispatcher::addHandle(FXInputHandle hnd,FXuint mode){ return FXReactor::addHandle(hnd,mode); } // Remove handle hnd from list FXbool FXDispatcher::remHandle(FXInputHandle hnd){ if(FXReactor::remHandle(hnd)){ Handle *handle=static_cast(handles.remove(reinterpret_cast(hnd))); delete handle; return true; } return false; } // Return true if handle has been set. FXbool FXDispatcher::hasHandle(FXInputHandle hnd) const { if(isInitialized()){ return 0<=handles.find(reinterpret_cast(hnd)); } return false; } // Dispatch when when handle hnd is signaled with mode FXbool FXDispatcher::dispatchHandle(FXInputHandle hnd,FXuint mode,FXuint){ Handle *handle=static_cast(handles[reinterpret_cast(hnd)]); return handle && handle->cb(this,hnd,mode,handle->ptr); } /*******************************************************************************/ // Exit dispatcher FXbool FXDispatcher::exit(){ if(FXReactor::exit()){ Idle *c; Timer *t; FXival i; for(i=0; i(handles.data(i)); } while((t=timers)!=nullptr){ timers=t->next; delete t; } while((t=timerrecs)!=nullptr){ timerrecs=t->next; delete t; } while((c=idles)!=nullptr){ idles=c->next; delete c; } while((c=idlerecs)!=nullptr){ idlerecs=c->next; delete c; } for(i=0; i<64; ++i){ delete signals[i]; } freeElms(signals); handles.clear(); timers=nullptr; idles=nullptr; timerrecs=nullptr; idlerecs=nullptr; return true; } return false; } // Destroy dispatcher object FXDispatcher::~FXDispatcher(){ exit(); } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDisplay.cpp000066400000000000000000000036721455751074500221630ustar00rootroot00000000000000/******************************************************************************** * * * D i s p l a y C l a s s * * * ********************************************************************************* * Copyright (C) 2019,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "FXDisplay.h" /* Notes: */ using namespace FX; namespace FX { /*******************************************************************************/ // Construct display FXDisplay::FXDisplay():display(nullptr){ } // Destroy display FXDisplay::~FXDisplay(){ } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDockBar.cpp000066400000000000000000000640331455751074500220610ustar00rootroot00000000000000/******************************************************************************** * * * D o c k S i t e W i d g e t * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXAccelTable.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FXGIFIcon.h" #include "FXFrame.h" #include "FXComposite.h" #include "FXPacker.h" #include "FXPopup.h" #include "FXMenuPane.h" #include "FXMenuCaption.h" #include "FXMenuCommand.h" #include "FXMenuCascade.h" #include "FXMenuSeparator.h" #include "FXMenuRadio.h" #include "FXMenuCheck.h" #include "FXShell.h" #include "FXSeparator.h" #include "FXTopWindow.h" #include "FXDockBar.h" #include "FXDockSite.h" #include "FXToolBarGrip.h" #include "FXToolBarShell.h" #include "icons.h" /* Notes: Jeroen's Theory of Docking Because if I don't write this down, no one will *ever* figure this out! We assume here we're docking a horizontally oriented bar inside a horizontally oriented dock. Vertical orientation works, of course, completely analoguous. Docking a floating bar. When dragging a floating bar, we call findDockNear() to determine which dock site this bar could dock into. This dock site is a sibling of the current widget remembered in the drydock variable. The routine findDockNear() invokes insideDock() to determine if a docking could take place or not. Not all dock sites are available for docking. Some dock bars have a preferred orientation and can not be docked everywhere. To this end, the dock bar maintains a member variable allowed which contains the set of sides that the bar is allowed to dock at. When findDockNear() returns a non-NULL value, a potential dock site has been found; a timer is set to dock at this site if the cursor hovers near its current position:- we don't dock immediately, since the user may be just moving the bar across a potential dock site on his way to another place on the screen. When the dragging ends, or when the timer expires, the bar is docked at the dock site. Subsequent dragging will simply move the bar inside the dock site, and just rearrange the dock site. Floating a docked bar. When moving a docked bar, dragging it simply rearranges the order of the bars inside the dock, until such time that the bar is substantially moved away from the dock site, as determined by insideDock(). Then the dock bar is reparented under the toolbar shell and subsequent movement will simply move the floaring bar. The function insideDock() determines if a proposed position is to be considered docked or non-docked. This is determined differently, based on whether the bar is currently docked or not: 1 If the bar is docked, we consider the proposed bar position undocked when the upper edge is FUDGE pixels above the dock site, or when the lower edge is FUDGE pixels below the dock site. 2 Alternatively, if the bar is floating, we consider the bar position docked when the upper or lower edge of the bar is within PROXIMITY inside the dock site. 3 In addition to 1 and 2, we also require that the horizontal alignment of the dock bar and dock site are within a certain TOLERANCE. This is determined differently depending on whether the bar is wider than the site or not: a If the bar is wider, we want the dock site within -TOLERANCE to bar width + TOLERANCE relative to the bar. b If the dock site is wider, we want the bar to be within -TOLERANCE to docksite width + TOLERANCE relative to the site. c A minor wrinkle is that if the bar is stretched (LAYOUT_FILL_X), we don't use the current width of the bar in the above calculations, but the default width instead; this is because a subsequent undocking, which would shrink-wrap around the dock bar, leaves a smaller widget and this may then immediately redock again. 4 If the above tests indicate that the bar is docked, insideDock() returns true. When undocking a bar, the arrangement inside the dock site needs to stay the same for the remaining bars [if any]. Thus, we call undockToolBar() to inform the dock site that one of its bars will be removed. Depending on its own internal layout algorithm, the dock site will then be able to adjust the options of the remaining bars so that they stay in place. When docking a bar, we need to figure out where the new bar goes. To that end, dockToolBar() informs the dock site to determine where the new bar goes and adjust the layout options of the other dock bars accordingly. If the dock bar is moved, the dock site is informed by moveToolBar() which lets the dock site then rearrange the layouts according to the new bar position. */ #define HANDLESIZE 6 // Resize handle length #define FUDGE 30 // Vertical distance beyond which bar pulls out #define PROXIMITY 10 // Vertical proximity below which bar is sucked int dock #define TOLERANCE 30 // Horizontal alignment tolerance beyond which bar pulls out #define DOCKINGSNAPDELAY 300000000 // Delay before dock bar snaps to dock site // Docking side #define LAYOUT_SIDE_MASK (LAYOUT_SIDE_LEFT|LAYOUT_SIDE_RIGHT|LAYOUT_SIDE_TOP|LAYOUT_SIDE_BOTTOM) using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXDockBar) FXDockBarMap[]={ // FXMAPFUNC(SEL_MOTION,0,FXDockBar::onMotion), // FXMAPFUNC(SEL_ENTER,0,FXDockBar::onEnter), // FXMAPFUNC(SEL_LEAVE,0,FXDockBar::onLeave), FXMAPFUNC(SEL_FOCUS_PREV,0,FXDockBar::onFocusLeft), FXMAPFUNC(SEL_FOCUS_NEXT,0,FXDockBar::onFocusRight), // FXMAPFUNC(SEL_LEFTBUTTONPRESS,0,FXDockBar::onLeftBtnPress), // FXMAPFUNC(SEL_LEFTBUTTONRELEASE,0,FXDockBar::onLeftBtnRelease), FXMAPFUNC(SEL_UPDATE,FXDockBar::ID_DOCK_FLOAT,FXDockBar::onUpdUndock), FXMAPFUNC(SEL_UPDATE,FXDockBar::ID_DOCK_TOP,FXDockBar::onUpdDockTop), FXMAPFUNC(SEL_UPDATE,FXDockBar::ID_DOCK_BOTTOM,FXDockBar::onUpdDockBottom), FXMAPFUNC(SEL_UPDATE,FXDockBar::ID_DOCK_LEFT,FXDockBar::onUpdDockLeft), FXMAPFUNC(SEL_UPDATE,FXDockBar::ID_DOCK_RIGHT,FXDockBar::onUpdDockRight), FXMAPFUNC(SEL_UPDATE,FXDockBar::ID_DOCK_FLIP,FXDockBar::onUpdDockFlip), FXMAPFUNC(SEL_COMMAND,FXDockBar::ID_DOCK_FLOAT,FXDockBar::onCmdUndock), FXMAPFUNC(SEL_COMMAND,FXDockBar::ID_DOCK_TOP,FXDockBar::onCmdDockTop), FXMAPFUNC(SEL_COMMAND,FXDockBar::ID_DOCK_BOTTOM,FXDockBar::onCmdDockBottom), FXMAPFUNC(SEL_COMMAND,FXDockBar::ID_DOCK_LEFT,FXDockBar::onCmdDockLeft), FXMAPFUNC(SEL_COMMAND,FXDockBar::ID_DOCK_RIGHT,FXDockBar::onCmdDockRight), FXMAPFUNC(SEL_BEGINDRAG,FXDockBar::ID_TOOLBARGRIP,FXDockBar::onBeginDragGrip), FXMAPFUNC(SEL_ENDDRAG,FXDockBar::ID_TOOLBARGRIP,FXDockBar::onEndDragGrip), FXMAPFUNC(SEL_DRAGGED,FXDockBar::ID_TOOLBARGRIP,FXDockBar::onDraggedGrip), FXMAPFUNC(SEL_TIMEOUT,FXDockBar::ID_TIMER,FXDockBar::onDockTimer), FXMAPFUNC(SEL_RIGHTBUTTONRELEASE,FXDockBar::ID_TOOLBARGRIP,FXDockBar::onPopupMenu), }; // Object implementation FXIMPLEMENT(FXDockBar,FXPacker,FXDockBarMap,ARRAYNUMBER(FXDockBarMap)) /* // Cursor shape based on mode const FXDefaultCursor FXDockBar::cursorType[16]={ DEF_ARROW_CURSOR, DEF_DRAGH_CURSOR, // DRAG_TOP DEF_DRAGH_CURSOR, // DRAG_BOTTOM DEF_ARROW_CURSOR, DEF_DRAGV_CURSOR, // DRAG_LEFT DEF_DRAGTL_CURSOR, // DRAG_LEFT DRAG_TOP DEF_DRAGTR_CURSOR, // DRAG_LEFT DRAG_BOTTOM DEF_ARROW_CURSOR, DEF_DRAGV_CURSOR, // DRAG_RIGHT DEF_DRAGTR_CURSOR, // DRAG_RIGHT DRAG_TOP DEF_DRAGTL_CURSOR, // DRAG_RIGHT DRAG_BOTTOM DEF_ARROW_CURSOR, DEF_ARROW_CURSOR, DEF_ARROW_CURSOR, DEF_ARROW_CURSOR, DEF_ARROW_CURSOR, }; */ // Deserialization FXDockBar::FXDockBar():drydock(nullptr),wetdock(nullptr){ flags|=FLAG_ENABLED; gripx=0; gripy=0; allowed=ALLOW_EVERYWHERE; // mode=DRAG_NONE; } // Make a dockable and, possibly, floatable toolbar FXDockBar::FXDockBar(FXComposite* p,FXComposite* q,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb,FXint hs,FXint vs):FXPacker(p,opts,x,y,w,h,pl,pr,pt,pb,hs,vs),drydock(p),wetdock(q){ flags|=FLAG_ENABLED; gripx=0; gripy=0; allowed=ALLOW_EVERYWHERE; // mode=DRAG_NONE; } // Make a non-floatable toolbar FXDockBar::FXDockBar(FXComposite* p,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb,FXint hs,FXint vs):FXPacker(p,opts,x,y,w,h,pl,pr,pt,pb,hs,vs),drydock(nullptr),wetdock(nullptr){ flags|=FLAG_ENABLED; gripx=0; gripy=0; allowed=ALLOW_EVERYWHERE; // mode=DRAG_NONE; } // Return true if toolbar is docked FXbool FXDockBar::isDocked() const { return (getParent()!=wetdock); } // Set parent when docked, if it was docked it will remain docked void FXDockBar::setDryDock(FXComposite* dry){ if(dry && dry->id() && getParent()==drydock){ reparent(dry,nullptr); } drydock=dry; } // Set parent when floating void FXDockBar::setWetDock(FXComposite* wet){ if(wet && wet->id() && getParent()==wetdock){ reparent(wet,nullptr); } wetdock=wet; } // Dock the bar before other window void FXDockBar::dock(FXDockSite* docksite,FXWindow* other,FXbool notify){ if(docksite && getParent()!=docksite){ setDryDock(docksite); reparent(docksite,other); if(wetdock) wetdock->hide(); docksite->dockToolBar(this,other); if(notify && target){target->tryHandle(this,FXSEL(SEL_DOCKED,message),docksite);} } } // Dock the bar near position in dock site void FXDockBar::dock(FXDockSite* docksite,FXint localx,FXint localy,FXbool notify){ if(docksite && getParent()!=docksite){ setDryDock(docksite); reparent(docksite,nullptr); if(wetdock) wetdock->hide(); docksite->dockToolBar(this,localx,localy); if(notify && target){target->tryHandle(this,FXSEL(SEL_DOCKED,message),docksite);} } } // Undock the bar void FXDockBar::undock(FXint rootx,FXint rooty,FXbool notify){ FXDockSite* docksite=dynamic_cast(getParent()); if(wetdock && isDocked()){ if(docksite) docksite->undockToolBar(this); reparent(wetdock); wetdock->position(rootx,rooty,wetdock->getDefaultWidth(),wetdock->getDefaultHeight()); wetdock->show(); if(notify && target){target->tryHandle(this,FXSEL(SEL_FLOATED,message),docksite);} } } // Return true if layout side is allowable FXbool FXDockBar::isAllowable(FXuint hints) const { if(hints&LAYOUT_SIDE_LEFT){ if(hints&LAYOUT_SIDE_BOTTOM){ // Right if(allowed&ALLOW_RIGHT) return true; } else{ // Left if(allowed&ALLOW_LEFT) return true; } } else{ if(hints&LAYOUT_SIDE_BOTTOM){ // Bottom if(allowed&ALLOW_BOTTOM) return true; } else{ // Top if(allowed&ALLOW_TOP) return true; } } return false; } // Search siblings of drydock for first dock opportunity FXDockSite* FXDockBar::findDockAtSide(FXuint side){ FXDockSite* docksite; FXWindow *child; if(drydock){ child=drydock->getParent()->getFirst(); while(child){ docksite=dynamic_cast(child); if(docksite && docksite->shown() && side==(docksite->getLayoutHints()&LAYOUT_SIDE_MASK)){ if(isAllowable(docksite->getLayoutHints())) return docksite; } child=child->getNext(); } } return nullptr; } // Test if bar is inside docksite FXbool FXDockBar::insideDock(FXDockSite* docksite,FXint barx,FXint bary){ if(docksite){ // Bar size FXint barw=getWidth(); FXint barh=getHeight(); // Vertically oriented dock if(docksite->getLayoutHints()&LAYOUT_SIDE_LEFT){ // If docked, undock when left or right edge pulls out beyond FUDGE pixels from dock; when floating, dock when left or right edge moves within PROXIMITY of dock if(((getParent()==docksite) && (docksite->getX()-FUDGE<=barx && barx+barwgetX()+docksite->getWidth()+FUDGE)) || ((getParent()!=docksite) && ((docksite->getX()-PROXIMITY<=barx && barxgetX()+docksite->getWidth()+PROXIMITY) || (docksite->getX()-PROXIMITY<=barx+barw && barx+barw<=docksite->getX()+docksite->getWidth()+PROXIMITY)))){ // If filled, fudge the height if(getLayoutHints()&LAYOUT_FILL_Y) barh=getDefaultHeight(); // Test if either bar or dock "sticks out" too much to dock if(barh>docksite->getHeight()){ if(bary-TOLERANCE<=docksite->getY() && docksite->getY()+docksite->getHeight()<=bary+barh+TOLERANCE) return true; } else{ if(docksite->getY()-TOLERANCE<=bary && bary+barh<=docksite->getY()+docksite->getHeight()+TOLERANCE) return true; } } } // Horizontally oriented dock else{ // If docked, undock when upper or lower edge pulls out beyond FUDGE pixels from dock; when floating, dock when upper or lower edge moves within PROXIMITY of dock if(((getParent()==docksite) && (docksite->getY()-FUDGE<=bary && bary+barh<=docksite->getY()+docksite->getHeight()+FUDGE)) || ((getParent()!=docksite) && ((docksite->getY()-PROXIMITY<=bary && bary<=docksite->getY()+docksite->getHeight()+PROXIMITY) || (docksite->getY()-PROXIMITY<=bary+barh && bary+barh<=docksite->getY()+docksite->getHeight()+PROXIMITY)))){ // If filled, fudge the width if(getLayoutHints()&LAYOUT_FILL_X) barw=getDefaultWidth(); // Test if either bar or dock "sticks out" too much to dock if(barw>docksite->getWidth()){ if(barx-TOLERANCE<=docksite->getX() && docksite->getX()+docksite->getWidth()<=barx+barw+TOLERANCE) return true; } else{ if(docksite->getX()-TOLERANCE<=barx && barx+barw<=docksite->getX()+docksite->getWidth()+TOLERANCE) return true; } } } } return false; } // Search siblings of drydock for dock opportunity near given coordinates FXDockSite* FXDockBar::findDockNear(FXint rootx,FXint rooty){ FXDockSite *docksite; FXWindow *child; FXint barx,bary; if(drydock){ // Translate without pain; assumes position of the top window is correct for(child=drydock->getParent(),barx=rootx,bary=rooty; child!=getRoot(); child=child->getParent()){ barx-=child->getX(); bary-=child->getY(); } // Localize dock site child=drydock->getParent()->getFirst(); while(child){ docksite=dynamic_cast(child); if(docksite && docksite->shown() && insideDock(docksite,barx,bary)){ if(isAllowable(docksite->getLayoutHints())) return docksite; } child=child->getNext(); } } return nullptr; } // Undock long FXDockBar::onCmdUndock(FXObject*,FXSelector,void*){ FXint rootx,rooty; translateCoordinatesTo(rootx,rooty,getRoot(),8,8); undock(rootx,rooty,true); return 1; } // Check if undocked long FXDockBar::onUpdUndock(FXObject* sender,FXSelector,void*){ sender->handle(this,(wetdock && wetdock!=getParent())?FXSEL(SEL_COMMAND,ID_ENABLE):FXSEL(SEL_COMMAND,ID_DISABLE),nullptr); return 1; } // Redock on top long FXDockBar::onCmdDockTop(FXObject*,FXSelector,void*){ dock(findDockAtSide(LAYOUT_SIDE_TOP),nullptr,true); return 1; } // Check if docked at top long FXDockBar::onUpdDockTop(FXObject* sender,FXSelector,void*){ FXDockSite* docksite=findDockAtSide(LAYOUT_SIDE_TOP); sender->handle(this,(docksite && docksite!=getParent())?FXSEL(SEL_COMMAND,ID_ENABLE):FXSEL(SEL_COMMAND,ID_DISABLE),nullptr); return 1; } // Redock on bottom long FXDockBar::onCmdDockBottom(FXObject*,FXSelector,void*){ dock(findDockAtSide(LAYOUT_SIDE_BOTTOM),nullptr,true); return 1; } // Check if docked at bottom long FXDockBar::onUpdDockBottom(FXObject* sender,FXSelector,void*){ FXDockSite* docksite=findDockAtSide(LAYOUT_SIDE_BOTTOM); sender->handle(this,(docksite && docksite!=getParent())?FXSEL(SEL_COMMAND,ID_ENABLE):FXSEL(SEL_COMMAND,ID_DISABLE),nullptr); return 1; } // Redock on left long FXDockBar::onCmdDockLeft(FXObject*,FXSelector,void*){ dock(findDockAtSide(LAYOUT_SIDE_LEFT),nullptr,true); return 1; } // Check if docked at left long FXDockBar::onUpdDockLeft(FXObject* sender,FXSelector,void*){ FXDockSite* docksite=findDockAtSide(LAYOUT_SIDE_LEFT); sender->handle(this,(docksite && docksite!=getParent())?FXSEL(SEL_COMMAND,ID_ENABLE):FXSEL(SEL_COMMAND,ID_DISABLE),nullptr); return 1; } // Redock on right long FXDockBar::onCmdDockRight(FXObject*,FXSelector,void*){ dock(findDockAtSide(LAYOUT_SIDE_RIGHT),nullptr,true); return 1; } // Check if docked at right long FXDockBar::onUpdDockRight(FXObject* sender,FXSelector,void*){ FXDockSite* docksite=findDockAtSide(LAYOUT_SIDE_RIGHT); sender->handle(this,(docksite && docksite!=getParent())?FXSEL(SEL_COMMAND,ID_ENABLE):FXSEL(SEL_COMMAND,ID_DISABLE),nullptr); return 1; } // Check for flip long FXDockBar::onUpdDockFlip(FXObject* sender,FXSelector,void*){ sender->handle(this,FXSEL(SEL_COMMAND,ID_DISABLE),nullptr); return 1; } // Right clicked on bar long FXDockBar::onPopupMenu(FXObject*,FXSelector,void* ptr){ FXEvent* event=static_cast(ptr); if(event->moved) return 1; FXMenuPane dockmenu(this); FXGIFIcon dockflipicon(getApp(),dockflip); FXGIFIcon docktopicon(getApp(),docktop,FXRGB(255,255,255),IMAGE_ALPHACOLOR); FXGIFIcon dockbottomicon(getApp(),dockbottom,FXRGB(255,255,255),IMAGE_ALPHACOLOR); FXGIFIcon docklefticon(getApp(),dockleft,FXRGB(255,255,255),IMAGE_ALPHACOLOR); FXGIFIcon dockrighticon(getApp(),dockright,FXRGB(255,255,255),IMAGE_ALPHACOLOR); FXGIFIcon dockfreeicon(getApp(),dockfree,FXRGB(255,255,255),IMAGE_ALPHACOLOR); new FXMenuCaption(&dockmenu,tr("Docking")); new FXMenuSeparator(&dockmenu); new FXMenuCommand(&dockmenu,tr("Top"),&docktopicon,this,ID_DOCK_TOP); new FXMenuCommand(&dockmenu,tr("Bottom"),&dockbottomicon,this,ID_DOCK_BOTTOM); new FXMenuCommand(&dockmenu,tr("Left"),&docklefticon,this,ID_DOCK_LEFT); new FXMenuCommand(&dockmenu,tr("Right"),&dockrighticon,this,ID_DOCK_RIGHT); new FXMenuCommand(&dockmenu,tr("Float"),&dockfreeicon,this,ID_DOCK_FLOAT); new FXMenuCommand(&dockmenu,tr("Flip"),&dockflipicon,this,ID_DOCK_FLIP); dockmenu.create(); dockmenu.popup(nullptr,event->root_x,event->root_y); getApp()->runModalWhileShown(&dockmenu); return 1; } // Tool bar grip drag started; the grip widget can be at any level under this dock bar long FXDockBar::onBeginDragGrip(FXObject* sender,FXSelector,void* ptr){ FXWindow *grip=static_cast(sender); FXEvent* event=static_cast(ptr); if(dynamic_cast(drydock)){ for(gripx=event->click_x,gripy=event->click_y; grip && grip!=this; grip=grip->getParent()){ gripx+=grip->getX(); gripy+=grip->getY(); } raise(); return 1; } return 0; } // Tool bar grip drag ended long FXDockBar::onEndDragGrip(FXObject*,FXSelector,void* ptr){ FXToolBarShell *toolbarshell=dynamic_cast(getParent()); FXEvent* event=static_cast(ptr); FXDockSite *toolbardock; FXint rootx,rooty,localx,localy; getApp()->removeTimeout(this,ID_TIMER); if(toolbarshell){ if(!(event->state&CONTROLMASK)){ rootx=event->root_x-gripx; rooty=event->root_y-gripy; toolbardock=findDockNear(rootx,rooty); if(toolbardock){ translateCoordinatesTo(localx,localy,toolbardock,0,0); dock(toolbardock,localx,localy,true); } } } return 1; } // Hovered near dock site:- dock it! long FXDockBar::onDockTimer(FXObject*,FXSelector,void* ptr){ FXDockSite *toolbardock=static_cast(ptr); FXint localx,localy; translateCoordinatesTo(localx,localy,toolbardock,0,0); dock(toolbardock,localx,localy,true); return 1; } // Tool bar grip dragged long FXDockBar::onDraggedGrip(FXObject*,FXSelector,void* ptr){ FXToolBarShell *toolbarshell=dynamic_cast(getParent()); FXDockSite *toolbardock=dynamic_cast(getParent()); FXEvent* event=static_cast(ptr); FXint rootx,rooty,dockx,docky; // Root position rootx=event->root_x-gripx; rooty=event->root_y-gripy; // Stop dock timer getApp()->removeTimeout(this,ID_TIMER); // We are docked if(toolbardock){ // Get mouse position relative to dock site toolbardock->translateCoordinatesFrom(dockx,docky,getRoot(),rootx,rooty); // Move the bar around in dock site toolbardock->moveToolBar(this,dockx,docky); // Test if we pulled too far to stay inside if(!insideDock(toolbardock,dockx+toolbardock->getX(),docky+toolbardock->getY())){ undock(rootx,rooty,true); } } // We are floating else if(toolbarshell){ // We're near a dock, if we hover around we'll dock there if(!(event->state&CONTROLMASK)){ toolbardock=findDockNear(rootx,rooty); if(toolbardock) getApp()->addTimeout(this,ID_TIMER,DOCKINGSNAPDELAY,toolbardock); } // Move around freely wetdock->move(rootx,rooty); } return 1; } /* // Find out where window was grabbed FXuchar FXDockBar::where(FXint x,FXint y) const { FXuchar code=DRAG_NONE; if((0<=x && xcode!=CROSSINGGRAB){ setDefaultCursor(getApp()->getDefaultCursor(cursorType[where(((FXEvent*)ptr)->win_x,((FXEvent*)ptr)->win_y)])); } return 1; } // Restore cursor if we left the window normally long FXDockBar::onLeave(FXObject* sender,FXSelector sel,void* ptr){ FXPacker::onLeave(sender,sel,ptr); if(((FXEvent*)ptr)->code!=CROSSINGUNGRAB){ setDefaultCursor(getApp()->getDefaultCursor(DEF_ARROW_CURSOR)); } return 1; } // Pressed LEFT button long FXDockBar::onLeftBtnPress(FXObject*,FXSelector,void* ptr){ FXEvent *event=(FXEvent*)ptr; flags&=~FLAG_TIP; handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr); if(isEnabled()){ grab(); if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONPRESS,message),ptr)) return 1; mode=where(event->win_x,event->win_y); if(mode!=DRAG_NONE){ if(mode&DRAG_TOP) gripy=event->win_y; else if(mode&DRAG_BOTTOM) gripy=event->win_y-height; if(mode&DRAG_LEFT) gripx=event->win_x; else if(mode&DRAG_RIGHT) gripx=event->win_x-width; setDragCursor(getApp()->getDefaultCursor(cursorType[mode])); } return 1; } return 0; } // Released LEFT button long FXDockBar::onLeftBtnRelease(FXObject*,FXSelector,void* ptr){ if(isEnabled()){ ungrab(); setDragCursor(getApp()->getDefaultCursor(DEF_ARROW_CURSOR)); if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONRELEASE,message),ptr)) return 1; if(mode!=DRAG_NONE){ mode=DRAG_NONE; recalc(); } return 1; } return 0; } // Moved the mouse long FXDockBar::onMotion(FXObject*,FXSelector,void* ptr){ FXEvent *event=(FXEvent*)ptr; if(mode!=DRAG_NONE){ FXDockSite *toolbardock=dynamic_cast(getParent()); FXint mousex,mousey; FXint x,y,w,h; // Translate to dock site's frame toolbardock->translateCoordinatesFrom(mousex,mousey,getRoot(),event->root_x-gripx,event->root_y-gripy); x=xpos; y=ypos; w=width; h=height; // Vertical if(mode&DRAG_TOP){ y=mousey; h=ypos+height-mousey; } else if(mode&DRAG_BOTTOM){ h=mousey-ypos; } // Horizontal if(mode&DRAG_LEFT){ x=mousex; w=xpos+width-mousex; } else if(mode&DRAG_RIGHT){ w=mousex-xpos; } // Resize and move toolbardock->resizeToolBar(this,x,y,w,h); recalc(); return 1; } // Change cursor based on location setDefaultCursor(getApp()->getDefaultCursor(cursorType[where(event->win_x,event->win_y)])); return 0; } */ // Save data void FXDockBar::save(FXStream& store) const { FXPacker::save(store); store << drydock; store << wetdock; store << allowed; } // Load data void FXDockBar::load(FXStream& store){ FXPacker::load(store); store >> drydock; store >> wetdock; store >> allowed; } // Destroy FXDockBar::~FXDockBar(){ getApp()->removeTimeout(this,ID_TIMER); drydock=(FXComposite*)-1L; wetdock=(FXComposite*)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDockHandler.cpp000066400000000000000000000231631455751074500227310ustar00rootroot00000000000000/******************************************************************************** * * * D o c k H a n d l e r W i d g e t * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXDockHandler.h" /* Notes: - On MS-Windows, this works just fine, without fanfare. - On X11, some quaintness in the X-Server causes havoc if reparent() is called on a window while it was grabbed. - Not to be deterred, we implement here the following workaround: 1) We create a temporary dummy window, just 1x1 pixels in size, in the upper left corner of the screen [yes, that was not a dead pixel after all!]. 2) We add this to the hash table, so now events from the "true" window as well those from the dummy window are dispatched to the toolbar grip. 3) We temporarily replace the xid of the true window with the dummy one, then invoke grab() to grab the mouse, then restore the original xid. 4) Now you can wave your mouse around and dock or undock toolbars. 5) When we're done, we replace the xid again with the dummy window, call ungrab(), then restore the original xid again. 6) Then, delete the dummy window. - The only downside of this method is that the win_x and win_y member data in FXEvent is unreliable; fortunately, the standard toolbar docking algorithms do not use these members. - Of course, we'd rather not have to do all this; so don't hesitate to inform us if you have a better way! */ using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXDockHandler) FXDockHandlerMap[]={ FXMAPFUNC(SEL_MOTION,0,FXDockHandler::onMotion), FXMAPFUNC(SEL_LEFTBUTTONPRESS,0,FXDockHandler::onLeftBtnPress), FXMAPFUNC(SEL_LEFTBUTTONRELEASE,0,FXDockHandler::onLeftBtnRelease), FXMAPFUNC(SEL_KEYPRESS,0,FXDockHandler::onKeyPress), FXMAPFUNC(SEL_KEYRELEASE,0,FXDockHandler::onKeyRelease), FXMAPFUNC(SEL_QUERY_TIP,0,FXDockHandler::onQueryTip), FXMAPFUNC(SEL_QUERY_HELP,0,FXDockHandler::onQueryHelp), FXMAPFUNC(SEL_COMMAND,FXDockHandler::ID_SETHELPSTRING,FXDockHandler::onCmdSetHelp), FXMAPFUNC(SEL_COMMAND,FXDockHandler::ID_GETHELPSTRING,FXDockHandler::onCmdGetHelp), FXMAPFUNC(SEL_COMMAND,FXDockHandler::ID_SETTIPSTRING,FXDockHandler::onCmdSetTip), FXMAPFUNC(SEL_COMMAND,FXDockHandler::ID_GETTIPSTRING,FXDockHandler::onCmdGetTip), }; // Object implementation FXIMPLEMENT_ABSTRACT(FXDockHandler,FXFrame,FXDockHandlerMap,ARRAYNUMBER(FXDockHandlerMap)) // Deserialization FXDockHandler::FXDockHandler(){ flags|=FLAG_ENABLED|FLAG_SHOWN; xxx=0; } // Construct and init FXDockHandler::FXDockHandler(FXComposite* p,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb):FXFrame(p,opts,x,y,w,h,pl,pr,pt,pb){ flags|=FLAG_SHOWN|FLAG_ENABLED; dragCursor=getApp()->getDefaultCursor(DEF_MOVE_CURSOR); target=tgt; message=sel; xxx=0; } // Can have focus FXbool FXDockHandler::canFocus() const { return true; } // Moved long FXDockHandler::onMotion(FXObject*,FXSelector,void* ptr){ if(flags&FLAG_DODRAG){ handle(this,FXSEL(SEL_DRAGGED,0),ptr); return 1; } if((flags&FLAG_TRYDRAG) && ((FXEvent*)ptr)->moved){ if(handle(this,FXSEL(SEL_BEGINDRAG,0),ptr)) flags|=FLAG_DODRAG; flags&=~FLAG_TRYDRAG; return 1; } return 0; } // Pressed LEFT button long FXDockHandler::onLeftBtnPress(FXObject*,FXSelector,void* ptr){ flags&=~FLAG_TIP; handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr); if(isEnabled()){ flags=(flags&~(FLAG_UPDATE|FLAG_DODRAG))|FLAG_TRYDRAG; #ifdef WIN32 grab(); #else Display *display=(Display*)getApp()->getDisplay(); const unsigned long mask=CWBackPixmap|CWWinGravity|CWBitGravity|CWBorderPixel|CWOverrideRedirect|CWSaveUnder|CWEventMask|CWDontPropagate|CWColormap|CWCursor; XSetWindowAttributes wattr; FXID tempxid=xid; wattr.background_pixmap=None; wattr.background_pixel=0; wattr.border_pixmap=None; wattr.border_pixel=0; wattr.bit_gravity=ForgetGravity; wattr.win_gravity=NorthWestGravity; wattr.backing_store=NotUseful; wattr.backing_planes=0; wattr.backing_pixel=0; wattr.save_under=false; wattr.event_mask=ButtonPressMask|ButtonReleaseMask|PointerMotionMask|KeyPressMask|KeyReleaseMask|FocusChangeMask|StructureNotifyMask|ExposureMask|PropertyChangeMask|EnterWindowMask|LeaveWindowMask; wattr.do_not_propagate_mask=KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask|ButtonMotionMask; wattr.override_redirect=true; wattr.colormap=DefaultColormap(display,DefaultScreen(display)); wattr.cursor=None; xxx=XCreateWindow(display,RootWindow(display,DefaultScreen(display)),0,0,1,1,0,DefaultDepth(display,DefaultScreen(display)),InputOutput,DefaultVisual(display,DefaultScreen(display)),mask,&wattr); getApp()->hash.insert((void*)xxx,this); XMapWindow(display,xxx); xid=xxx; grab(); xid=tempxid; #endif update(); } return 1; } // Released LEFT button long FXDockHandler::onLeftBtnRelease(FXObject*,FXSelector,void* ptr){ if(isEnabled()){ FXuint flg=flags; flags=(flags&~(FLAG_TRYDRAG|FLAG_DODRAG))|FLAG_UPDATE; if(flg&(FLAG_DODRAG|FLAG_TRYDRAG)){ #ifdef WIN32 ungrab(); #else Display *display=(Display*)getApp()->getDisplay(); FXID tempxid=xid; xid=xxx; ungrab(); xid=tempxid; getApp()->hash.remove((void*)xxx); XDestroyWindow(display,xxx); xxx=0; #endif } if(flg&FLAG_DODRAG){handle(this,FXSEL(SEL_ENDDRAG,0),ptr);} update(); } return 1; } // Key Press long FXDockHandler::onKeyPress(FXObject*,FXSelector,void* ptr){ FXEvent* event=static_cast(ptr); if(isEnabled()){ if(target && target->tryHandle(this,FXSEL(SEL_KEYPRESS,message),ptr)) return 1; if(event->code==KEY_Control_L || event->code==KEY_Control_R){ if(flags&FLAG_DODRAG){handle(this,FXSEL(SEL_DRAGGED,0),ptr);} return 1; } } return 0; } // Key Release long FXDockHandler::onKeyRelease(FXObject*,FXSelector,void* ptr){ FXEvent* event=static_cast(ptr); if(isEnabled()){ if(target && target->tryHandle(this,FXSEL(SEL_KEYRELEASE,message),ptr)) return 1; if(event->code==KEY_Control_L || event->code==KEY_Control_R){ if(flags&FLAG_DODRAG){handle(this,FXSEL(SEL_DRAGGED,0),ptr);} return 1; } } return 0; } // We were asked about tip text long FXDockHandler::onQueryTip(FXObject* sender,FXSelector sel,void* ptr){ if(FXFrame::onQueryTip(sender,sel,ptr)) return 1; if((flags&FLAG_TIP) && !tip.empty()){ sender->handle(this,FXSEL(SEL_COMMAND,ID_SETSTRINGVALUE),(void*)&tip); return 1; } return 0; } // We were asked about status text long FXDockHandler::onQueryHelp(FXObject* sender,FXSelector sel,void* ptr){ if(FXFrame::onQueryHelp(sender,sel,ptr)) return 1; if((flags&FLAG_HELP) && !help.empty()){ sender->handle(this,FXSEL(SEL_COMMAND,ID_SETSTRINGVALUE),(void*)&help); return 1; } return 0; } // Set tip using a message long FXDockHandler::onCmdSetTip(FXObject*,FXSelector,void* ptr){ setTipText(*((FXString*)ptr)); return 1; } // Get tip using a message long FXDockHandler::onCmdGetTip(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getTipText(); return 1; } // Set help using a message long FXDockHandler::onCmdSetHelp(FXObject*,FXSelector,void* ptr){ setHelpText(*((FXString*)ptr)); return 1; } // Get help using a message long FXDockHandler::onCmdGetHelp(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getHelpText(); return 1; } // Save data void FXDockHandler::save(FXStream& store) const { FXFrame::save(store); store << tip; store << help; } // Load data void FXDockHandler::load(FXStream& store){ FXFrame::load(store); store >> tip; store >> help; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDockSite.cpp000066400000000000000000001247161455751074500222660ustar00rootroot00000000000000/******************************************************************************** * * * D o c k S i t e W i d g e t * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXPacker.h" #include "FXDockBar.h" #include "FXDockSite.h" /* Notes: - Use "Box-Car" algorithm when sliding horizontally (vertically). - Vertical arrangement is very tricky; we don't insert in between galleys when dragging since its not so easy to use; but this remains a possibility for future expansion. - We can STILL do wrapping of individual toolbars inside the toolbar dock; normally we compute the width the standard way, but if this does not fit the available space and its the first widget on the galley, we can call getHeightForWidth() and thereby wrap the item in on the galley. Thus we have both wrapping of the toobars as well as wrapping inside the toolbar. - FIXME we should look at LAYOUT_DOCK_NEXT before shown() because if you hide a bar, we want to keep stuff in the same place. - Another nice addition would be to constrain docking from adding extra galleys, except when unavoidable. */ #define FUDGE 20 // Amount to move down/up before jumping into next galley using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXDockSite) FXDockSiteMap[]={ // FXMAPFUNC(SEL_MOTION,0,FXDockSite::onMotion), // FXMAPFUNC(SEL_ENTER,0,FXDockSite::onEnter), // FXMAPFUNC(SEL_LEAVE,0,FXDockSite::onLeave), // FXMAPFUNC(SEL_LEFTBUTTONPRESS,0,FXDockSite::onLeftBtnPress), // FXMAPFUNC(SEL_LEFTBUTTONRELEASE,0,FXDockSite::onLeftBtnRelease), FXMAPFUNC(SEL_FOCUS_PREV,0,FXDockSite::onFocusLeft), FXMAPFUNC(SEL_FOCUS_NEXT,0,FXDockSite::onFocusRight), }; // Object implementation FXIMPLEMENT(FXDockSite,FXPacker,FXDockSiteMap,ARRAYNUMBER(FXDockSiteMap)) /* // Cursor shape based on mode const FXDefaultCursor FXDockSite::cursorType[16]={ DEF_ARROW_CURSOR, DEF_DRAGH_CURSOR, // DRAG_TOP DEF_DRAGH_CURSOR, // DRAG_BOTTOM DEF_ARROW_CURSOR, DEF_DRAGV_CURSOR, // DRAG_LEFT DEF_DRAGTL_CURSOR, // DRAG_LEFT DRAG_TOP DEF_DRAGTR_CURSOR, // DRAG_LEFT DRAG_BOTTOM DEF_ARROW_CURSOR, DEF_DRAGV_CURSOR, // DRAG_RIGHT DEF_DRAGTR_CURSOR, // DRAG_RIGHT DRAG_TOP DEF_DRAGTL_CURSOR, // DRAG_RIGHT DRAG_BOTTOM DEF_ARROW_CURSOR, DEF_ARROW_CURSOR, DEF_ARROW_CURSOR, DEF_ARROW_CURSOR, DEF_ARROW_CURSOR, }; */ // Make a dock site FXDockSite::FXDockSite(FXComposite* p,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb,FXint hs,FXint vs):FXPacker(p,opts,x,y,w,h,pl,pr,pt,pb,hs,vs){ // mode=DRAG_NONE; } // Change wrap option void FXDockSite::wrapGalleys(FXbool wrap){ if(wrap && wrapGalleys()){ options&=~DOCKSITE_NO_WRAP; recalc(); } else if(!wrap && !wrapGalleys()){ options|=DOCKSITE_NO_WRAP; recalc(); } } // Get wrap option FXbool FXDockSite::wrapGalleys() const { return (options&DOCKSITE_NO_WRAP)==0; } // Compute minimum width based on child layout hints FXint FXDockSite::getDefaultWidth(){ FXint total=0,galw=0,w; FXWindow *child; FXuint hints; // Vertically oriented if(options&LAYOUT_SIDE_LEFT){ for(child=getFirst(); child; child=child->getNext()){ if(child->shown()){ hints=child->getLayoutHints(); w=(hints&LAYOUT_FIX_WIDTH)?child->getWidth():child->getDefaultWidth(); if(hints&LAYOUT_DOCK_NEXT){ if(total) total+=hspacing; total+=galw; galw=w; } else{ if(w>galw) galw=w; } } } total+=galw; } // Horizontally oriented else{ for(child=getFirst(); child; child=child->getNext()){ if(child->shown()){ hints=child->getLayoutHints(); w=(hints&LAYOUT_FIX_WIDTH)?child->getWidth():child->getDefaultWidth(); if(hints&LAYOUT_DOCK_NEXT){ if(galw>total) total=galw; galw=w; } else{ if(galw) galw+=hspacing; galw+=w; } } } if(galw>total) total=galw; } return padleft+padright+total+(border<<1); } // Compute minimum height based on child layout hints FXint FXDockSite::getDefaultHeight(){ FXint total=0,galh=0,h; FXWindow *child; FXuint hints; // Vertically oriented if(options&LAYOUT_SIDE_LEFT){ for(child=getFirst(); child; child=child->getNext()){ if(child->shown()){ hints=child->getLayoutHints(); h=(hints&LAYOUT_FIX_HEIGHT)?child->getHeight():child->getDefaultHeight(); if(hints&LAYOUT_DOCK_NEXT){ if(galh>total) total=galh; galh=h; } else{ if(galh) galh+=vspacing; galh+=h; } } } if(galh>total) total=galh; } // Horizontally oriented else{ for(child=getFirst(); child; child=child->getNext()){ if(child->shown()){ hints=child->getLayoutHints(); h=(hints&LAYOUT_FIX_HEIGHT)?child->getHeight():child->getDefaultHeight(); if(hints&LAYOUT_DOCK_NEXT){ if(total) total+=vspacing; total+=galh; galh=h; } else{ if(h>galh) galh=h; } } } total+=galh; } return padtop+padbottom+total+(border<<1); } // Return width for given height (vertical orientation) FXint FXDockSite::getWidthForHeight(FXint givenheight){ FXint total=0,galh=0,galw=0,w,h; FXWindow *child; FXuint hints; givenheight-=padtop+padbottom+border+border; for(child=getFirst(); child; child=child->getNext()){ if(child->shown()){ hints=child->getLayoutHints(); w=(hints&LAYOUT_FIX_WIDTH)?child->getWidth():child->getDefaultWidth(); h=(hints&LAYOUT_FIX_HEIGHT)?child->getHeight():child->getDefaultHeight(); if((hints&LAYOUT_DOCK_NEXT) || (!(options&DOCKSITE_NO_WRAP) && galh+h>givenheight)){ if(total) total+=hspacing; total+=galw; galw=w; galh=h+vspacing; } else{ galh+=h+vspacing; if(w>galw) galw=w; } } } total+=galw; return padleft+padright+total+(border<<1); } // Return height for given width (horizontal orientation) FXint FXDockSite::getHeightForWidth(FXint givenwidth){ FXint total=0,galh=0,galw=0,w,h; FXWindow *child; FXuint hints; givenwidth-=padleft+padright+border+border; for(child=getFirst(); child; child=child->getNext()){ if(child->shown()){ hints=child->getLayoutHints(); w=(hints&LAYOUT_FIX_WIDTH)?child->getWidth():child->getDefaultWidth(); h=(hints&LAYOUT_FIX_HEIGHT)?child->getHeight():child->getDefaultHeight(); if((hints&LAYOUT_DOCK_NEXT) || (!(options&DOCKSITE_NO_WRAP) && galw+w>givenwidth)){ if(total) total+=vspacing; total+=galh; galw=w+hspacing; galh=h; } else{ galw+=w+hspacing; if(h>galh) galh=h; } } } total+=galh; return padtop+padbottom+total+(border<<1); } // Find begin and end of galley containing bar on horizontal dock site void FXDockSite::galleyOfHorzBar(FXWindow *bar,FXWindow*& begin,FXWindow*& end) const { FXint space=width-padleft-padright-border-border,ss=0,w; FXWindow *child; for(child=bar; child->getPrev(); child=child->getPrev()){ if(child->shown() && (child->getLayoutHints()&LAYOUT_DOCK_NEXT)) break; } for(begin=child; child!=bar; child=child->getNext()){ if(!child->shown()) continue; w=(child->getLayoutHints()&LAYOUT_FIX_WIDTH) ? child->getWidth() : child->getDefaultWidth(); if(!(options&DOCKSITE_NO_WRAP) && ss+w>space){ begin=child; ss=w+hspacing; } else{ ss+=w+hspacing; } } for(end=child; child; end=child,child=child->getNext()){ if(!child->shown()) continue; w=(child->getLayoutHints()&LAYOUT_FIX_WIDTH) ? child->getWidth() : child->getDefaultWidth(); if(ss && ((child->getLayoutHints()&LAYOUT_DOCK_NEXT) || (!(options&DOCKSITE_NO_WRAP) && ss+w>space))) break; ss+=w+hspacing; } } // Find begin and end of galley containing bar on vertical dock site void FXDockSite::galleyOfVertBar(FXWindow *bar,FXWindow*& begin,FXWindow*& end) const { FXint space=height-padtop-padbottom-border-border,ss=0,h; FXWindow *child; for(child=bar; child->getPrev(); child=child->getPrev()){ if(child->shown() && (child->getLayoutHints()&LAYOUT_DOCK_NEXT)) break; } for(begin=child; child!=bar; child=child->getNext()){ if(child->shown()){ h=(child->getLayoutHints()&LAYOUT_FIX_HEIGHT) ? child->getHeight() : child->getDefaultHeight(); if(!(options&DOCKSITE_NO_WRAP) && ss+h>space){ begin=child; ss=h+vspacing; } else{ ss+=h+vspacing; } } } for(end=child; child; end=child,child=child->getNext()){ if(child->shown()){ h=(child->getLayoutHints()&LAYOUT_FIX_HEIGHT) ? child->getHeight() : child->getDefaultHeight(); if(ss && ((child->getLayoutHints()&LAYOUT_DOCK_NEXT) || (!(options&DOCKSITE_NO_WRAP) && ss+h>space))) break; ss+=h+vspacing; } } } // Determine vertical galley size FXint FXDockSite::galleyWidth(FXWindow *begin,FXWindow*& end,FXint space,FXint& require,FXint& expand) const { FXint galley,any,w,h; FXWindow *child; FXuint hints; require=expand=galley=any=0; for(child=end=begin; child; end=child,child=child->getNext()){ if(child->shown()){ // Get size hints=child->getLayoutHints(); w=(hints&LAYOUT_FIX_WIDTH)?child->getWidth():child->getDefaultWidth(); h=(hints&LAYOUT_FIX_HEIGHT)?child->getHeight():child->getDefaultHeight(); // Break for new galley? if(any && ((hints&LAYOUT_DOCK_NEXT) || ((require+h>space) && wrapGalleys()))) break; // Expanding widgets if(hints&LAYOUT_FILL_Y) expand+=h; // Figure galley size require+=h+vspacing; if(w>galley) galley=w; any=1; } } require-=vspacing; return galley; } // Determine horizontal galley size FXint FXDockSite::galleyHeight(FXWindow *begin,FXWindow*& end,FXint space,FXint& require,FXint& expand) const { FXint galley,any,w,h; FXWindow *child; FXuint hints; require=expand=galley=any=0; for(child=end=begin; child; end=child,child=child->getNext()){ if(child->shown()){ // Get size hints=child->getLayoutHints(); w=(hints&LAYOUT_FIX_WIDTH)?child->getWidth():child->getDefaultWidth(); h=(hints&LAYOUT_FIX_HEIGHT)?child->getHeight():child->getDefaultHeight(); // Break for new galley? if(any && ((hints&LAYOUT_DOCK_NEXT) || ((require+w>space) && wrapGalleys()))) break; // Expanding widgets if(hints&LAYOUT_FILL_X) expand+=w; // Figure galley size require+=w+hspacing; if(h>galley) galley=h; any=1; } } require-=hspacing; return galley; } // Recalculate layout void FXDockSite::layout(){ FXint expand,remain,require,left,right,top,bottom,galx,galy,galw,galh,e,t,x,y,w,h; FXWindow *begin,*end,*child; FXuint hints; // Vertically oriented if(options&LAYOUT_SIDE_LEFT){ // Galley height left=border+padleft; right=width-padright-border; // Loop over galleys for(begin=getFirst(); begin; begin=end->getNext()){ // Space available top=border+padtop; bottom=height-padbottom-border; // Galley width galw=galleyWidth(begin,end,bottom-top,require,expand); // Remaining space remain=bottom-top-require; if(expand) require=bottom-top; // Start next galley galx=left; left=left+galw+hspacing; // Placement of widgets on galley for(child=begin,e=0; child; child=child->getNext()){ if(child->shown()){ // Get size hints=child->getLayoutHints(); w=(hints&LAYOUT_FIX_WIDTH)?child->getWidth():child->getDefaultWidth(); h=(hints&LAYOUT_FIX_HEIGHT)?child->getHeight():child->getDefaultHeight(); // X-filled if(hints&LAYOUT_FILL_X) w=galw; // Y-filled if(hints&LAYOUT_FILL_Y){ t=h*remain; e+=t%expand; h+=t/expand+e/expand; e%=expand; } require-=h; // Determine child x-position x=child->getX(); if(xgalx+galw) x=galx+galw-w; // Determine child y-position y=child->getY(); if(y+h>bottom-require) y=bottom-require-h; if(yposition(x,y,w,h); } if(child==end) break; } } } // Horizontally oriented else{ // Galley height top=border+padtop; bottom=height-padbottom-border; // Loop over galleys for(begin=getFirst(); begin; begin=end->getNext()){ // Space available left=border+padleft; right=width-padright-border; // Galley height galh=galleyHeight(begin,end,right-left,require,expand); // Remaining space remain=right-left-require; if(expand) require=right-left; // Start next galley galy=top; top=top+galh+vspacing; // Placement of widgets on galley for(child=begin,e=0; child; child=child->getNext()){ if(child->shown()){ // Get size hints=child->getLayoutHints(); w=(hints&LAYOUT_FIX_WIDTH)?child->getWidth():child->getDefaultWidth(); h=(hints&LAYOUT_FIX_HEIGHT)?child->getHeight():child->getDefaultHeight(); // Y-filled if(hints&LAYOUT_FILL_Y) h=galh; // X-filled if(hints&LAYOUT_FILL_X){ t=w*remain; e+=t%expand; w+=t/expand+e/expand; e%=expand; } require-=w; // Determine child y-position y=child->getY(); if(ygaly+galh) y=galy+galh-h; // Determine child x-position x=child->getX(); if(x+w>right-require) x=right-require-w; if(xposition(x,y,w,h); } if(child==end) break; } } } flags&=~FLAG_DIRTY; } /*******************************************************************************/ // Move bar vertically in galley [begin..end] void FXDockSite::moveVerBar(FXWindow*& begin,FXWindow*& end,FXWindow* bar,FXint barx,FXint bary,FXint barw,FXint barh,FXbool hop){ FXWindow *child; FXint pos,by; by=bary; // Pushing up if(barygetY()){ // Figure minimum position for(child=begin,pos=border+padtop; child && child!=bar; child=child->getNext()){ if(child->shown()){ pos+=child->getHeight()+vspacing; } } // Can't move higher if(barygetHeight()){bary=pos;}else{barh=bary+barh-pos;bary=pos;} } // Bars in front of this one? if(bar!=begin){ child=bar; pos=bary; // Move bars in box-car fashion do{ child=child->getPrev(); if(!child->shown()) continue; pos=pos-vspacing-child->getHeight(); if(child->getY()<=pos) break; child->move(child->getX(),pos); } while(child!=begin); // Hop bar over child=bar->getPrev(); if(hop && bygetY()){ // Hopping over first on galley:- transfer flag over to new first if((child==begin) && (child->getLayoutHints()&LAYOUT_DOCK_NEXT)){ child->setLayoutHints(child->getLayoutHints()&~LAYOUT_DOCK_NEXT); bar->setLayoutHints(bar->getLayoutHints()|LAYOUT_DOCK_NEXT); } // And rearrange order of children bary=child->getY(); child->move(child->getY(),bary+barh+vspacing); bar->reparent(this,child); // Update galley if(child==begin) begin=bar; if(bar==end) end=child; } } } // Pushing down if(bary+barh>bar->getY()+bar->getHeight()){ // Figure maximum position for(child=end,pos=height-padbottom-border; child && child!=bar; child=child->getPrev()){ if(child->shown()){ pos-=child->getHeight()+vspacing; } } // Can't move lower if(bary+barh>pos){ if(barh==bar->getHeight()){bary=pos-barh;}else{barh=pos-bary;} } // Bars after this one? if(bar!=end){ child=bar; pos=bary+barh+vspacing; // Move bars in box-car fashion do{ child=child->getNext(); if(!child->shown()) continue; if(child->getY()>=pos) break; child->move(child->getX(),pos); pos=pos+vspacing+child->getHeight(); } while(child!=end); // Hop bar over child=bar->getNext(); if(hop && by+barh>child->getY()+child->getHeight()){ // First on galley hopped over to the right:- transfer flag to new first if((bar==begin) && (bar->getLayoutHints()&LAYOUT_DOCK_NEXT)){ bar->setLayoutHints(bar->getLayoutHints()&~LAYOUT_DOCK_NEXT); child->setLayoutHints(child->getLayoutHints()|LAYOUT_DOCK_NEXT); } // And rearrange order of children bary=child->getY()+child->getHeight()-barh; child->move(child->getX(),bary-child->getHeight()-vspacing); bar->reparent(this,child->getNext()); // Update galley if(child==end) end=bar; if(bar==begin) begin=child; } } } // Move it bar->position(barx,bary,barw,barh); } // Move bar horizontally in galley [begin..end] void FXDockSite::moveHorBar(FXWindow*& begin,FXWindow*& end,FXWindow* bar,FXint barx,FXint bary,FXint barw,FXint barh,FXbool hop){ FXWindow *child; FXint pos,bx; bx=barx; // Pushing left if(barxgetX()){ // Figure minimum position for(child=begin,pos=border+padleft; child && child!=bar; child=child->getNext()){ if(child->shown()){ pos+=child->getWidth()+hspacing; } } // Can't move leftward if(barxgetWidth()){barx=pos;}else{barw=barx+barw-pos;barx=pos;} } // Bars in front of this one? if(bar!=begin){ child=bar; pos=barx; // Move bars in box-car fashion do{ child=child->getPrev(); if(!child->shown()) continue; pos=pos-hspacing-child->getWidth(); if(child->getX()<=pos) break; child->move(pos,child->getY()); } while(child!=begin); // Hop bar over child=bar->getPrev(); if(hop && bxgetX()){ // Hopping over first on galley:- transfer flag over to new first if((child==begin) && (child->getLayoutHints()&LAYOUT_DOCK_NEXT)){ child->setLayoutHints(child->getLayoutHints()&~LAYOUT_DOCK_NEXT); bar->setLayoutHints(bar->getLayoutHints()|LAYOUT_DOCK_NEXT); } // And rearrange order of children barx=child->getX(); child->move(barx+barw+hspacing,child->getY()); bar->reparent(this,child); // Update galley if(child==begin) begin=bar; if(bar==end) end=child; } } } // Pushing right if(barx+barw>bar->getX()+bar->getWidth()){ // Figure maximum position for(child=end,pos=width-padright-border; child && child!=bar; child=child->getPrev()){ if(child->shown()){ pos-=child->getWidth()+hspacing; } } // Can't move rightward if(barx+barw>pos){ if(barw==bar->getWidth()){barx=pos-barw;}else{barw=pos-barx;} } // Bars after this one? if(bar!=end){ child=bar; pos=barx+barw+hspacing; // Move bars in box-car fashion do{ child=child->getNext(); if(!child->shown()) continue; if(child->getX()>=pos) break; child->move(pos,child->getY()); pos=pos+hspacing+child->getWidth(); } while(child!=end); // Hop bar over child=bar->getNext(); if(hop && bx+barw>child->getX()+child->getWidth()){ // First on galley hopped over to the right:- transfer flag to new first if((bar==begin) && (bar->getLayoutHints()&LAYOUT_DOCK_NEXT)){ bar->setLayoutHints(bar->getLayoutHints()&~LAYOUT_DOCK_NEXT); child->setLayoutHints(child->getLayoutHints()|LAYOUT_DOCK_NEXT); } // And rearrange order of children barx=child->getX()+child->getWidth()-barw; child->move(barx-child->getWidth()-hspacing,child->getY()); bar->reparent(this,child->getNext()); // Update galley if(child==end) end=bar; if(bar==begin) begin=child; } } } // Move it bar->position(barx,bary,barw,barh); } /*******************************************************************************/ // FIXME can not move left edge if docked on right and widget NOT galley-wide yet // Position toolbar void FXDockSite::resizeToolBar(FXDockBar* bar,FXint barx,FXint bary,FXint barw,FXint barh){ if(bar && bar->getParent()==this){ FXint top,bottom,left,right,expand,require,w,h,mbw,mbh,t; FXWindow *begin,*end,*c; //FXTRACE((100,"barx=%d bary=%d barw=%d barh=%d\n",barx,bary,barw,barh)); // Interior top=border+padtop; bottom=height-padbottom-border; left=border+padleft; right=width-padright-border; // Vertically oriented if(options&LAYOUT_SIDE_LEFT){ // Minimum bar width mbw=bar->getPadLeft()+bar->getPadRight()+bar->getBorderWidth()+bar->getBorderWidth(); // Determine galley sizes for(begin=end=getFirst(); begin; begin=end->getNext()){ w=galleyWidth(begin,end,bottom-top,require,expand); // Found galley of the bar if(before(begin,bar) && before(bar,end)){ // Dragging the right if(barx+barw!=bar->getX()+bar->getWidth()){ if(barw=left+w){ // Can not drag rightward barw=left+w-barx; } else{ // Only drag leftward if another widget holds the galley up for(c=begin,t=-1; c; c=c->getNext()){ if(c!=bar && c->shown() && (t=(c->getLayoutHints()&LAYOUT_FIX_WIDTH) ? c->getWidth() : c->getDefaultWidth())==w) break; if(c==end) break; } if(tgetX()){ if(barwgetNext()){ if(c!=bar && c->shown() && (t=(c->getLayoutHints()&LAYOUT_FIX_WIDTH) ? c->getWidth() : c->getDefaultWidth())==w) break; if(c==end) break; } if(tgetPadTop()+bar->getPadBottom()+bar->getBorderWidth()+bar->getBorderWidth(); // Determine galley sizes for(begin=end=getFirst(); begin; begin=end->getNext()){ h=galleyHeight(begin,end,right-left,require,expand); // Found galley of the bar if(before(begin,bar) && before(bar,end)){ // Same bar, move horizontally if(barytop+h) bary=top+h-barh; // Move bar horizontally; this may change the galley start and end! moveHorBar(begin,end,bar,barx,bary,barw,barh,false); break; } top+=h+vspacing; } } } } /*******************************************************************************/ // Move dock bar, changing its options to suit position void FXDockSite::moveToolBar(FXDockBar* bar,FXint barx,FXint bary){ FXint left,right,top,bottom,galx,galy,galw,galh,dockx,docky,barw,barh,expand,require,w,h; FXWindow *begin,*end,*cur,*curend,*nxt,*nxtend,*prv,*prvend; // We insist this bar hangs under this dock site if(bar && bar->getParent()==this){ // Proposed location dockx=barx; docky=bary; // Bar size barw=bar->getWidth(); barh=bar->getHeight(); // Interior top=border+padtop; bottom=height-padbottom-border; left=border+padleft; right=width-padright-border; // Vertically oriented if(options&LAYOUT_SIDE_LEFT){ // Determine galley sizes galx=left; galw=0; for(begin=getFirst(),cur=prv=nxt=curend=prvend=nxtend=nullptr; begin; begin=end->getNext()){ w=galleyWidth(begin,end,bottom-top,require,expand); if(!after(end,bar)){ if(left<=barx && barxgalx+galw) dockx=galx+galw-barw; // Move bar vertically; this may change the galley start and end! moveVerBar(cur,curend,bar,dockx,docky,barw,barh,true); // Moving bar right, unless we're about to pull it out of the dock if(barx+barw>=galx+galw+FUDGE && (!bar->getWetDock() || barx+barwgetNext()->setLayoutHints(cur->getNext()->getLayoutHints()|LAYOUT_DOCK_NEXT); nxt->setLayoutHints(nxt->getLayoutHints()|LAYOUT_DOCK_NEXT); bar->setLayoutHints(bar->getLayoutHints()&~LAYOUT_DOCK_NEXT); bar->reparent(this,nxtend->getNext()); } else{ // Hang below last if(cur==bar && bar!=curend) cur->getNext()->setLayoutHints(cur->getNext()->getLayoutHints()|LAYOUT_DOCK_NEXT); else cur->setLayoutHints(cur->getLayoutHints()|LAYOUT_DOCK_NEXT); bar->setLayoutHints(bar->getLayoutHints()|LAYOUT_DOCK_NEXT); bar->reparent(this,nullptr); } } // Moving bar left, unless we're about to pull it out of the dock else if(barxgetWetDock() || barx>padleft+border)){ if(prv){ // Hang at end of previous galley if(cur==bar && bar!=curend) cur->getNext()->setLayoutHints(cur->getNext()->getLayoutHints()|LAYOUT_DOCK_NEXT); prv->setLayoutHints(prv->getLayoutHints()|LAYOUT_DOCK_NEXT); bar->setLayoutHints(bar->getLayoutHints()&~LAYOUT_DOCK_NEXT); bar->reparent(this,prvend->getNext()); } else{ // Hand above first if(cur==bar && bar!=curend) cur->getNext()->setLayoutHints(cur->getNext()->getLayoutHints()|LAYOUT_DOCK_NEXT); else cur->setLayoutHints(cur->getLayoutHints()|LAYOUT_DOCK_NEXT); bar->setLayoutHints(bar->getLayoutHints()|LAYOUT_DOCK_NEXT); bar->reparent(this,getFirst()); } } #if 0 // Determine galley sizes galx=left; galw=0; for(begin=getFirst(),cur=prv=nxt=curend=prvend=nxtend=nullptr; begin; begin=end->getNext()){ w=galleyWidth(begin,end,bottom-top,require,expand); if(!after(end,bar)){ if(left<=barx && barxgalx+galw) dockx=galx+galw-barw; // Move bar vertically; this may change the galley start and end! moveVerBar(cur,curend,bar,dockx,docky,barw,barh,true); // Moving bar right, unless we're about to pull it out of the dock if(barx+barw>=galx+galw+FUDGE && (!bar->getWetDock() || barx+barwgetNext()->setLayoutHints(cur->getNext()->getLayoutHints()|LAYOUT_DOCK_NEXT); nxt->setLayoutHints(nxt->getLayoutHints()|LAYOUT_DOCK_NEXT); bar->setLayoutHints(bar->getLayoutHints()&~LAYOUT_DOCK_NEXT); bar->reparent(this,nxtend->getNext()); } else{ // Hang below last if(cur==bar && bar!=curend) cur->getNext()->setLayoutHints(cur->getNext()->getLayoutHints()|LAYOUT_DOCK_NEXT); else cur->setLayoutHints(cur->getLayoutHints()|LAYOUT_DOCK_NEXT); bar->setLayoutHints(bar->getLayoutHints()|LAYOUT_DOCK_NEXT); bar->reparent(this,nullptr); } } // Moving bar left, unless we're about to pull it out of the dock else if(barxgetWetDock() || barx>padleft+border)){ if(prv){ // Hang at end of previous galley if(cur==bar && bar!=curend) cur->getNext()->setLayoutHints(cur->getNext()->getLayoutHints()|LAYOUT_DOCK_NEXT); prv->setLayoutHints(prv->getLayoutHints()|LAYOUT_DOCK_NEXT); bar->setLayoutHints(bar->getLayoutHints()&~LAYOUT_DOCK_NEXT); bar->reparent(this,prvend->getNext()); } else{ // Hand above first if(cur==bar && bar!=curend) cur->getNext()->setLayoutHints(cur->getNext()->getLayoutHints()|LAYOUT_DOCK_NEXT); else cur->setLayoutHints(cur->getLayoutHints()|LAYOUT_DOCK_NEXT); bar->setLayoutHints(bar->getLayoutHints()|LAYOUT_DOCK_NEXT); bar->reparent(this,getFirst()); } } #endif } // Horizontally oriented else{ // Determine galley sizes galy=top; galh=0; for(begin=getFirst(),cur=prv=nxt=curend=prvend=nxtend=nullptr; begin; begin=end->getNext()){ h=galleyHeight(begin,end,right-left,require,expand); if(!after(end,bar)){ if(top<=bary && barygaly+galh) docky=galy+galh-barh; // Move bar horizontally; this may change the galley start and end! moveHorBar(cur,curend,bar,dockx,docky,barw,barh,true); // Moving bar down, unless we're about to pull it out of the dock if(bary+barh>=galy+galh+FUDGE && (!bar->getWetDock() || bary+barhgetNext()->setLayoutHints(cur->getNext()->getLayoutHints()|LAYOUT_DOCK_NEXT); nxt->setLayoutHints(nxt->getLayoutHints()|LAYOUT_DOCK_NEXT); bar->setLayoutHints(bar->getLayoutHints()&~LAYOUT_DOCK_NEXT); bar->reparent(this,nxtend->getNext()); } else{ // Hang below last if(cur==bar && bar!=curend) cur->getNext()->setLayoutHints(cur->getNext()->getLayoutHints()|LAYOUT_DOCK_NEXT); else cur->setLayoutHints(cur->getLayoutHints()|LAYOUT_DOCK_NEXT); bar->setLayoutHints(bar->getLayoutHints()|LAYOUT_DOCK_NEXT); bar->reparent(this,nullptr); } } // Moving bar up, unless we're about to pull it out of the dock else if(barygetWetDock() || bary>border+padtop)){ if(prv){ // Hang at end of previous galley if(cur==bar && bar!=curend) cur->getNext()->setLayoutHints(cur->getNext()->getLayoutHints()|LAYOUT_DOCK_NEXT); prv->setLayoutHints(prv->getLayoutHints()|LAYOUT_DOCK_NEXT); bar->setLayoutHints(bar->getLayoutHints()&~LAYOUT_DOCK_NEXT); bar->reparent(this,prvend->getNext()); } else{ // Hand above first if(cur==bar && bar!=curend) cur->getNext()->setLayoutHints(cur->getNext()->getLayoutHints()|LAYOUT_DOCK_NEXT); else cur->setLayoutHints(cur->getLayoutHints()|LAYOUT_DOCK_NEXT); bar->setLayoutHints(bar->getLayoutHints()|LAYOUT_DOCK_NEXT); bar->reparent(this,getFirst()); } } } } } // Fix layouts for undocking given bar void FXDockSite::undockToolBar(FXDockBar* bar){ FXWindow *begin,*end; // We insist this bar hangs under this dock site if(bar && bar->getParent()==this){ // Vertically oriented if(options&LAYOUT_SIDE_LEFT){ // Get galley of bar galleyOfVertBar(bar,begin,end); // Adjust layout options if(begin==bar && bar!=end) begin->getNext()->setLayoutHints(begin->getNext()->getLayoutHints()|LAYOUT_DOCK_NEXT); else begin->setLayoutHints(begin->getLayoutHints()|LAYOUT_DOCK_NEXT); } // Horizontally oriented else{ // Get galley of bar galleyOfHorzBar(bar,begin,end); // Adjust layout options if(begin==bar && bar!=end) begin->getNext()->setLayoutHints(begin->getNext()->getLayoutHints()|LAYOUT_DOCK_NEXT); else begin->setLayoutHints(begin->getLayoutHints()|LAYOUT_DOCK_NEXT); } // Fix bar's layout hints too bar->setLayoutHints(bar->getLayoutHints()&~LAYOUT_DOCK_NEXT); } } // Fix layouts for docking given bar at given position void FXDockSite::dockToolBar(FXDockBar* bar,FXWindow* other){ // We insist this bar hangs under this dock site if(bar && bar->getParent()==this){ // New galley for bar bar->setLayoutHints(bar->getLayoutHints()|LAYOUT_DOCK_NEXT); if(other) other->setLayoutHints(bar->getNext()->getLayoutHints()|LAYOUT_DOCK_NEXT); } } // Fix layouts for docking given bar at given position void FXDockSite::dockToolBar(FXDockBar* bar,FXint barx,FXint bary){ FXint left,right,top,bottom,barw,barh,expand,require,cx,cy,w,h; FXWindow *begin,*end,*child; // We insist this bar hangs under this dock site if(bar && bar->getParent()==this){ // Interior top=border+padtop; left=border+padleft; bottom=height-padbottom-border; right=width-padright-border; // Bar size barw=bar->getWidth(); barh=bar->getHeight(); // Vertically oriented if(options&LAYOUT_SIDE_LEFT){ cx=barx+barw/2; // Tentatively bar->reparent(this,getFirst()); bar->setLayoutHints(bar->getLayoutHints()|LAYOUT_DOCK_NEXT); if(bar->getNext()){ // Start galley on next bar->getNext()->setLayoutHints(bar->getNext()->getLayoutHints()|LAYOUT_DOCK_NEXT); // Right of the left edge if(left<=cx){ // Determine galley for(begin=bar->getNext(); begin; begin=end->getNext()){ w=galleyWidth(begin,end,bottom-top,require,expand); if(left<=cx && cxgetNext() && (!child->shown() || bary>=child->getY()); child=child->getNext()){} // At the front if((child==begin) && (child->getLayoutHints()&LAYOUT_DOCK_NEXT)){ child->setLayoutHints(child->getLayoutHints()&~LAYOUT_DOCK_NEXT); } else{ bar->setLayoutHints(bar->getLayoutHints()&~LAYOUT_DOCK_NEXT); } // hang in front bar->reparent(this,child); goto ver; } left+=w+hspacing; } // Link at the bottom bar->reparent(this,nullptr); } } // Move horizontally ver: bar->move(FXCLAMP(left,barx,right),bary); } // Horizontally oriented else{ cy=bary+barh/2; // Tentatively bar->reparent(this,getFirst()); bar->setLayoutHints(bar->getLayoutHints()|LAYOUT_DOCK_NEXT); if(bar->getNext()){ // Start galley on next bar->getNext()->setLayoutHints(bar->getNext()->getLayoutHints()|LAYOUT_DOCK_NEXT); // Below top edge if(top<=cy){ // Determine galley for(begin=bar->getNext(); begin; begin=end->getNext()){ h=galleyHeight(begin,end,right-left,require,expand); if(top<=cy && cygetNext() && (!child->shown() || barx>=child->getX()); child=child->getNext()){} // At the front if((child==begin) && (child->getLayoutHints()&LAYOUT_DOCK_NEXT)){ child->setLayoutHints(child->getLayoutHints()&~LAYOUT_DOCK_NEXT); } else{ bar->setLayoutHints(bar->getLayoutHints()&~LAYOUT_DOCK_NEXT); } // hang in front bar->reparent(this,child); goto hor; } top+=h+vspacing; } // Link at the bottom bar->reparent(this,nullptr); } } // Move horizontally hor: bar->move(barx,FXCLAMP(top,bary,bottom)); } } } /* // Find out where window was grabbed FXuchar FXDockSite::where(FXint x,FXint y) const { FXuchar code=DRAG_NONE; if((0<=x && xcode!=CROSSINGGRAB){ setDefaultCursor(getApp()->getDefaultCursor(cursorType[where(((FXEvent*)ptr)->win_x,((FXEvent*)ptr)->win_y)])); } return 1; } // Restore cursor if we left the window normally long FXDockSite::onLeave(FXObject* sender,FXSelector sel,void* ptr){ FXPacker::onLeave(sender,sel,ptr); if(((FXEvent*)ptr)->code!=CROSSINGUNGRAB){ setDefaultCursor(getApp()->getDefaultCursor(DEF_ARROW_CURSOR)); } return 1; } // Pressed LEFT button long FXDockSite::onLeftBtnPress(FXObject*,FXSelector,void* ptr){ FXEvent *event=(FXEvent*)ptr; flags&=~FLAG_TIP; handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr); if(isEnabled()){ grab(); if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONPRESS,message),ptr)) return 1; mode=where(event->win_x,event->win_y); if(mode!=DRAG_NONE){ if(mode&DRAG_TOP) gripy=event->win_y; else if(mode&DRAG_BOTTOM) gripy=event->win_y-height; if(mode&DRAG_LEFT) gripx=event->win_x; else if(mode&DRAG_RIGHT) gripx=event->win_x-width; setDragCursor(getApp()->getDefaultCursor(cursorType[mode])); } return 1; } return 0; } // Released LEFT button long FXDockSite::onLeftBtnRelease(FXObject*,FXSelector,void* ptr){ if(isEnabled()){ ungrab(); setDragCursor(getApp()->getDefaultCursor(DEF_ARROW_CURSOR)); if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONRELEASE,message),ptr)) return 1; if(mode!=DRAG_NONE){ mode=DRAG_NONE; recalc(); } return 1; } return 0; } // Moved the mouse long FXDockSite::onMotion(FXObject*,FXSelector,void* ptr){ FXEvent *event=(FXEvent*)ptr; if(mode!=DRAG_NONE){ FXDockSite *toolbardock=dynamic_cast(getParent()); FXint mousex,mousey; FXint x,y,w,h; // Translate to dock site's frame toolbardock->translateCoordinatesFrom(mousex,mousey,getRoot(),event->root_x-gripx,event->root_y-gripy); x=xpos; y=ypos; w=width; h=height; // Vertical if(mode&DRAG_TOP){ y=mousey; h=ypos+height-mousey; } else if(mode&DRAG_BOTTOM){ h=mousey-ypos; } // Horizontal if(mode&DRAG_LEFT){ x=mousex; w=xpos+width-mousex; } else if(mode&DRAG_RIGHT){ w=mousex-xpos; } // Resize and move toolbardock->resizeToolBar(this,x,y,w,h); recalc(); return 1; } // Change cursor based on location setDefaultCursor(getApp()->getDefaultCursor(cursorType[where(event->win_x,event->win_y)])); return 0; } */ } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDockTitle.cpp000066400000000000000000000143421455751074500224340ustar00rootroot00000000000000/******************************************************************************** * * * D o c k T i t l e W i d g e t * * * ********************************************************************************* * Copyright (C) 2005,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXFont.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FXDockTitle.h" /* Notes: */ #define JUSTIFY_MASK (JUSTIFY_HZ_APART|JUSTIFY_VT_APART) using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXDockTitle) FXDockTitleMap[]={ FXMAPFUNC(SEL_PAINT,0,FXDockTitle::onPaint), FXMAPFUNC(SEL_COMMAND,FXDockTitle::ID_SETVALUE,FXDockTitle::onCmdSetValue), FXMAPFUNC(SEL_COMMAND,FXDockTitle::ID_SETSTRINGVALUE,FXDockTitle::onCmdSetStringValue), FXMAPFUNC(SEL_COMMAND,FXDockTitle::ID_GETSTRINGVALUE,FXDockTitle::onCmdGetStringValue), }; // Object implementation FXIMPLEMENT(FXDockTitle,FXDockHandler,FXDockTitleMap,ARRAYNUMBER(FXDockTitleMap)) // Deserialization FXDockTitle::FXDockTitle(){ font=(FXFont*)-1L; captionColor=0; } // Construct and init FXDockTitle::FXDockTitle(FXComposite* p,const FXString& text,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb):FXDockHandler(p,tgt,sel,opts,x,y,w,h,pl,pr,pt,pb),caption(text){ font=getApp()->getNormalFont(); captionColor=getApp()->getSelforeColor(); backColor=getApp()->getSelbackColor(); } // Create window void FXDockTitle::create(){ FXFrame::create(); font->create(); } // Detach window void FXDockTitle::detach(){ FXFrame::detach(); font->detach(); } // Get default width FXint FXDockTitle::getDefaultWidth(){ FXint w=0; if(!caption.empty()) w=font->getTextWidth(caption.text(),caption.length()); return padleft+padright+(border<<1)+w; } // Get default height FXint FXDockTitle::getDefaultHeight(){ FXint h=0; if(!caption.empty()) h=font->getFontHeight(); return padtop+padbottom+(border<<1)+h; } // Handle repaint long FXDockTitle::onPaint(FXObject*,FXSelector,void* ptr){ FXEvent* event=static_cast(ptr); FXDCWindow dc(this,event); FXint tw,th,tx,ty; dc.setForeground(backColor); dc.fillRectangle(border,border,width-(border<<1),height-(border<<1)); if(!caption.empty()){ dc.setFont(font); tw=font->getTextWidth(caption.text(),caption.length()); th=font->getFontHeight(); if(options&JUSTIFY_LEFT) tx=padleft+border; else if(options&JUSTIFY_RIGHT) tx=width-padright-border-tw; else tx=border+padleft+(width-padleft-padright-(border<<1)-tw)/2; if(options&JUSTIFY_TOP) ty=border+padtop; else if(options&JUSTIFY_BOTTOM) ty=height-padbottom-border-th; else ty=border+padtop+(height-padbottom-padtop-(border<<1)-th)/2; dc.setForeground(captionColor); dc.drawText(tx,ty+font->getFontAscent(),caption); } drawFrame(dc,0,0,width,height); return 1; } // Update value from a message long FXDockTitle::onCmdSetValue(FXObject*,FXSelector,void* ptr){ setCaption((const FXchar*)ptr); return 1; } // Update value from a message long FXDockTitle::onCmdSetStringValue(FXObject*,FXSelector,void* ptr){ setCaption(*((FXString*)ptr)); return 1; } // Obtain value from text field long FXDockTitle::onCmdGetStringValue(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getCaption(); return 1; } // Change caption void FXDockTitle::setCaption(const FXString& text){ if(caption!=text){ caption=text; recalc(); update(); } } // Change the font void FXDockTitle::setFont(FXFont *fnt){ if(!fnt){ fxerror("%s::setFont: NULL font specified.\n",getClassName()); } if(font!=fnt){ font=fnt; recalc(); update(); } } // Set caption color void FXDockTitle::setCaptionColor(FXColor clr){ if(clr!=captionColor){ captionColor=clr; update(); } } // Set text justify style void FXDockTitle::setJustify(FXuint style){ FXuint opts=(options&~JUSTIFY_MASK) | (style&JUSTIFY_MASK); if(options!=opts){ options=opts; update(); } } // Get text justify style FXuint FXDockTitle::getJustify() const { return (options&JUSTIFY_MASK); } // Save data void FXDockTitle::save(FXStream& store) const { FXDockHandler::save(store); store << caption; store << font; store << captionColor; } // Load data void FXDockTitle::load(FXStream& store){ FXDockHandler::load(store); store >> caption; store >> font; store >> captionColor; } // Destroy FXDockTitle::~FXDockTitle(){ font=(FXFont*)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDocument.cpp000066400000000000000000000173171455751074500223350ustar00rootroot00000000000000/******************************************************************************** * * * D o c u m e n t O b j e c t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXPath.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXAccelTable.h" #include "FXObjectList.h" #include "FXCursor.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXFrame.h" #include "FXRootWindow.h" #include "FXShell.h" #include "FXDocument.h" /* Notes: - How to use: 1) You construct a FXDocument class, e.g. when your app loads a file. 2) FXDocument constructs one or more FXMDIChild widgets, and makes itself the target of the each of them so that it will be notified when the FXMDIChild minimizes, maximizes, or gets closed etc. 3) MenuCommands, Buttons and what have you which need to send messages to FXDocument will do so through delegation via FXMDIClient, and FXMDIChild. Thus, the only places pointing to a specific FXDocument are FXMDIChild windows, and their sub-widgets (such as for example the FXGLViewer). 4) When the user interacts with one of the FXMDIChild's controls, data in the FXDocument is changed. If any other FXMDIChild windows are used this same data, they may need to be updated. FXDocument can do this through message ``broadcast'' from the FXMDIClient to its list FXMDIChild windows: mdiclient->forallWindows(sender,sel,ptr) sends a message to ALL FXMDIChild windows under mdiclient. Also: mdiclient->forallDocWindows(document,sender,sel,ptr) sends a message to all FXMDIChild windows whose target is document. A new message, understood by ALL FXWindows, has been added if you want to simply force a repaint; so in order to just repaint everything: long MyDocument::onCmdChangedSomething(FXObject* sender, FXSelector sel,void* ptr){ forallWindows(sender,FXSEL(SEL_COMMAND,ID_UPDATE),ptr); return 1; } 5) Thus, - There is only ONE place that keeps track of all the FXMDIChild windows pertaining to a certain document. Your application may want to cycle through the FXMDIChild list itself; this can be done by: mdichild = mdiclient->getMDIChildFirst(); mdichild = mdichild->getMDINext(); and so on. The FXMDIChild windows are linked into a doubly-linked list. - After a change, FXMDIChild window contents may be updated by a simple message broadcast to all FXMDIChild windows; in many cases, the original FXMDIChild with which the user interacted should be skipped. This can be accomplished by simply passing the same sender which sent the change to the FXDocument back to the broadcast message, so if a message is received by the FXMDIChild it could simply test if it itself was the originator. - Applications which don't ``buy into'' this whole multi-document business but still want to have multiple viewer windows won't have to bother with FXDocuments at all! Just create FXMDIChild widgets and make them send the messages to the right place... 6) FXMainWindow and FXMDIChild can ask their target to supply the title to be displayed in the titlebar; this is done through GUI Updating. 7) New FXMDIChildren should be created by FXDocument; when an FXMDIChild is closed, the FXDocument should be asked first; if its the last window, FXDocument should prompt to save the data if modified. After data has been saved, the FXDocument returns 1 in the SEL_CLOSE handler which causes the FXMDIChild to delete itself. 8) A message ID_CLOSE_DOCUMENT to FXDocument (via FXMDIClient and FXMDIChild) checks if document needs to be saved; once saved, the document can delete all child windows. It could do this via: mdiclient->forallDocWindows(this,this,FXSEL(SEL_COMMAND,FXWindow::ID_DELETE),NULL); forAllfirst sends a SEL_CLOSEALL to each document; if this returns 1, FXMDIClient proceeds to send ID_MDI_CLOSE to each FXMDIChild belonging to the same document. Each FXMDIChild will then ask the FXDocument whether its OK to close this FXMDIChild; since the FXDocument was already saved in response to the SEL_CLOSEALL, the FXDocument is no longer dirty and the answer will be OK to close for all of them [except perhaps in unusual circumstances]. */ using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXDocument) FXDocumentMap[]={ FXMAPFUNC(SEL_UPDATE,FXDocument::ID_TITLE,FXDocument::onUpdTitle), FXMAPFUNC(SEL_UPDATE,FXDocument::ID_FILENAME,FXDocument::onUpdFilename), }; // Object implementation FXIMPLEMENT(FXDocument,FXObject,FXDocumentMap,ARRAYNUMBER(FXDocumentMap)) // Construct FXDocument::FXDocument(){ modified=false; } // Change title void FXDocument::setTitle(const FXString& name){ title=name; } // Set file name, and the title also void FXDocument::setFilename(const FXString& path){ filename=FXPath::absolute(path); title=FXPath::stem(filename); } // Update document title long FXDocument::onUpdTitle(FXObject* sender,FXSelector,void*){ FXString string=title; if(modified) string+="*"; sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_SETSTRINGVALUE),(void*)&string); return 1; } // Update document filename long FXDocument::onUpdFilename(FXObject* sender,FXSelector,void*){ FXString string=filename; if(modified) string+="*"; sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_SETSTRINGVALUE),(void*)&string); return 1; } // Save object to stream void FXDocument::save(FXStream& store) const { FXObject::save(store); } // Load object from stream void FXDocument::load(FXStream& store){ FXObject::load(store); } // Destruct FXDocument::~FXDocument(){ } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDragCorner.cpp000066400000000000000000000166521455751074500226060ustar00rootroot00000000000000/******************************************************************************** * * * D r a g C o r n e r W i d g e t * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXDCWindow.h" #include "FXApp.h" #include "FXDragCorner.h" #define CORNERSIZE 17 #define DISPLAY(app) ((Display*)((app)->getDisplay())) /* Notes: - Need to grab server while dragging? - Need to use extended window manager hints so that minimum/maximum size and so on are properly observed. */ using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXDragCorner) FXDragCornerMap[]={ FXMAPFUNC(SEL_PAINT,0,FXDragCorner::onPaint), FXMAPFUNC(SEL_LEFTBUTTONPRESS,0,FXDragCorner::onLeftBtnPress), FXMAPFUNC(SEL_LEFTBUTTONRELEASE,0,FXDragCorner::onLeftBtnRelease), FXMAPFUNC(SEL_MOTION,0,FXDragCorner::onMotion), }; // Object implementation FXIMPLEMENT(FXDragCorner,FXWindow,FXDragCornerMap,ARRAYNUMBER(FXDragCornerMap)) // Deserialization FXDragCorner::FXDragCorner(){ flags|=FLAG_ENABLED|FLAG_SHOWN; hiliteColor=0; shadowColor=0; oldw=0; oldh=0; xoff=0; yoff=0; ewmh=false; } // Construct and init FXDragCorner::FXDragCorner(FXComposite* p):FXWindow(p,LAYOUT_RIGHT|LAYOUT_BOTTOM){ flags|=FLAG_ENABLED|FLAG_SHOWN; defaultCursor=getApp()->getDefaultCursor(DEF_DRAGBR_CURSOR); dragCursor=getApp()->getDefaultCursor(DEF_DRAGBR_CURSOR); backColor=getApp()->getBaseColor(); hiliteColor=getApp()->getHiliteColor(); shadowColor=getApp()->getShadowColor(); oldw=0; oldh=0; xoff=0; yoff=0; ewmh=false; } // Get default width FXint FXDragCorner::getDefaultWidth(){ return CORNERSIZE; } // Get default height FXint FXDragCorner::getDefaultHeight(){ return CORNERSIZE; } // Create drag corner void FXDragCorner::create(){ FXWindow::create(); #ifndef WIN32 unsigned long n,i; Atom type; unsigned char *prop; int format; if(Success==XGetWindowProperty(DISPLAY(getApp()),XDefaultRootWindow(DISPLAY(getApp())),getApp()->wmNetSupported,0,2048,False,XA_ATOM,&type,&format,&n,&i,&prop)){ for(i=0; iwmNetMoveResize){ ewmh=true; break; } } XFree(prop); } #endif } // Slightly different from Frame border long FXDragCorner::onPaint(FXObject*,FXSelector,void* ptr){ FXEvent *ev=(FXEvent*)ptr; FXDCWindow dc(this,ev); dc.setForeground(backColor); dc.fillRectangle(ev->rect.x,ev->rect.y,ev->rect.w,ev->rect.h); dc.setForeground(shadowColor); dc.drawLine(width-2,height-1,width,height-3); dc.drawLine(width-8,height-1,width,height-9); dc.drawLine(width-14,height-1,width,height-15); dc.setForeground(hiliteColor); dc.drawLine(width-5,height-1,width,height-6); dc.drawLine(width-11,height-1,width,height-12); dc.drawLine(width-17,height-1,width,height-18); return 1; } // Pressed LEFT button long FXDragCorner::onLeftBtnPress(FXObject*,FXSelector,void* ptr){ FXEvent *event=(FXEvent*)ptr; #ifndef WIN32 if(ewmh){ XClientMessageEvent ev; ev.type=ClientMessage; ev.display=DISPLAY(getApp()); ev.window=getShell()->id(); ev.message_type=getApp()->wmNetMoveResize; ev.format=32; ev.data.l[0]=event->root_x; ev.data.l[1]=event->root_y; ev.data.l[2]=4; // Bottom right ev.data.l[3]=LEFTBUTTON; ev.data.l[4]=0; XSendEvent(DISPLAY(getApp()),XDefaultRootWindow(DISPLAY(getApp())),False,(SubstructureRedirectMask|SubstructureNotifyMask),(XEvent*)&ev); ungrab(); return 1; } #endif FXDCWindow dc(getRoot()); FXint xx,yy,wx,wy; grab(); xoff=width-event->win_x; yoff=height-event->win_y; translateCoordinatesTo(wx,wy,getShell(),event->win_x,event->win_y); oldw=wx+xoff; oldh=wy+yoff; dc.clipChildren(false); dc.setFunction(BLT_SRC_XOR_DST); dc.setForeground(FXRGB(255,255,255)); getShell()->translateCoordinatesTo(xx,yy,getRoot(),0,0); dc.drawRectangle(xx,yy,oldw,oldh); flags|=FLAG_PRESSED; return 1; } // Released LEFT button long FXDragCorner::onLeftBtnRelease(FXObject*,FXSelector,void* ptr){ FXEvent *event=(FXEvent*)ptr; if(flags&FLAG_PRESSED){ FXDCWindow dc(getRoot()); FXint xx,yy,wx,wy; ungrab(); getShell()->translateCoordinatesTo(xx,yy,getRoot(),0,0); translateCoordinatesTo(wx,wy,getShell(),event->win_x,event->win_y); dc.clipChildren(false); dc.setFunction(BLT_SRC_XOR_DST); dc.setForeground(FXRGB(255,255,255)); dc.drawRectangle(xx,yy,oldw,oldh); getShell()->resize(wx+xoff,wy+yoff); flags&=~FLAG_PRESSED; } return 1; } // Moved long FXDragCorner::onMotion(FXObject*,FXSelector,void* ptr){ FXEvent *event=(FXEvent*)ptr; if(flags&FLAG_PRESSED){ FXDCWindow dc(getRoot()); FXint xx,yy,wx,wy; getShell()->translateCoordinatesTo(xx,yy,getRoot(),0,0); translateCoordinatesTo(wx,wy,getShell(),event->win_x,event->win_y); dc.clipChildren(false); dc.setFunction(BLT_SRC_XOR_DST); dc.setForeground(FXRGB(255,255,255)); dc.drawRectangle(xx,yy,oldw,oldh); oldw=wx+xoff; oldh=wy+yoff; dc.drawRectangle(xx,yy,oldw,oldh); return 1; } return 0; } // Set highlight color void FXDragCorner::setHiliteColor(FXColor clr){ if(hiliteColor!=clr){ hiliteColor=clr; update(); } } // Set shadow color void FXDragCorner::setShadowColor(FXColor clr){ if(shadowColor!=clr){ shadowColor=clr; update(); } } // Save data void FXDragCorner::save(FXStream& store) const { FXWindow::save(store); store << hiliteColor; store << shadowColor; } // Load data void FXDragCorner::load(FXStream& store){ FXWindow::load(store); store >> hiliteColor; store >> shadowColor; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDrawable.cpp000066400000000000000000000065121455751074500222730ustar00rootroot00000000000000/******************************************************************************** * * * D r a w a b l e A r e a * * * ********************************************************************************* * Copyright (C) 1997,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXVisual.h" #include "FXEvent.h" #include "FXDrawable.h" #include "FXWindow.h" #include "FXApp.h" /* Notes: - Abstract drawable surface which may be used as drawing target in FXDCWindow; it may also be used as source in drawing operations. */ using namespace FX; /*******************************************************************************/ namespace FX { // Object implementation FXIMPLEMENT_ABSTRACT(FXDrawable,FXId,nullptr,0) // For deserialization FXDrawable::FXDrawable():visual(nullptr),width(0),height(0){ } // Initialize nicely FXDrawable::FXDrawable(FXApp* a,FXint w,FXint h):FXId(a),visual(nullptr),width(FXMAX(w,0)),height(FXMAX(h,0)){ } // Change visual void FXDrawable::setVisual(FXVisual* vis){ if(!vis){ fxerror("%s::setVisual: NULL visual\n",getClassName()); } if(xid){ fxerror("%s::setVisual: visual should be set before calling create()\n",getClassName()); } visual=vis; } // Resize drawable to the specified width and height void FXDrawable::resize(FXint w,FXint h){ width=FXMAX(w,0); height=FXMAX(h,0); } // Save data void FXDrawable::save(FXStream& store) const { FXId::save(store); store << visual; store << width; store << height; } // Load data void FXDrawable::load(FXStream& store){ FXId::load(store); store >> visual; store >> width; store >> height; } // Clean up FXDrawable::~FXDrawable(){ visual=(FXVisual*)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXDriveBox.cpp000066400000000000000000000233431455751074500222750ustar00rootroot00000000000000/******************************************************************************** * * * D r i v e B o x O b j e c t * * * ********************************************************************************* * Copyright (C) 1999,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXAccelTable.h" #include "FXObjectList.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXPath.h" #include "FXSystem.h" #include "FXDrawable.h" #include "FXImage.h" #include "FXIcon.h" #include "FXGIFIcon.h" #include "FXBMPIcon.h" #include "FXFont.h" #include "FXWindow.h" #include "FXComposite.h" #include "FXShell.h" #include "FXTopWindow.h" #include "FXDialogBox.h" #include "FXMessageBox.h" #include "FXFrame.h" #include "FXLabel.h" #include "FXTextField.h" #include "FXButton.h" #include "FXMenuButton.h" #include "FXComposite.h" #include "FXPacker.h" #include "FXShell.h" #include "FXPopup.h" #include "FXScrollBar.h" #include "FXScrollArea.h" #include "FXList.h" #include "FXListBox.h" #include "FXDriveBox.h" #include "FXDictionary.h" #include "FXDictionaryOf.h" #include "FXIconCache.h" #include "FXFileAssociations.h" #include "icons.h" /* Notes: - When setting path, it adds all directories from the top down to the lowest directory. - It also adds common places in the file system. - Add API's to set current path [from root down to whereever] - Add code to read path of selected item - Add some better icons */ using namespace FX; /*******************************************************************************/ namespace FX { // Map FXDEFMAP(FXDriveBox) FXDriveBoxMap[]={ FXMAPFUNC(SEL_CHANGED,FXDriveBox::ID_LIST,FXDriveBox::onListChanged), FXMAPFUNC(SEL_CLICKED,FXDriveBox::ID_LIST,FXDriveBox::onListClicked), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_SETVALUE,FXDriveBox::onCmdSetValue), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_SETSTRINGVALUE,FXDriveBox::onCmdSetStringValue), FXMAPFUNC(SEL_COMMAND,FXWindow::ID_GETSTRINGVALUE,FXDriveBox::onCmdGetStringValue), }; // Implementation FXIMPLEMENT(FXDriveBox,FXListBox,FXDriveBoxMap,ARRAYNUMBER(FXDriveBoxMap)) // Directory box FXDriveBox::FXDriveBox(FXComposite *p,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb):FXListBox(p,tgt,sel,opts,x,y,w,h, pl,pr,pt,pb){ associations=nullptr; if(!(options&DRIVEBOX_NO_OWN_ASSOC)) associations=new FXFileAssociations(getApp()); foldericon=new FXGIFIcon(getApp(),minifolder); cdromicon=new FXGIFIcon(getApp(),minicdrom); harddiskicon=new FXGIFIcon(getApp(),miniharddisk); netdriveicon=new FXGIFIcon(getApp(),mininetdrive); floppyicon=new FXGIFIcon(getApp(),minifloppy); nethoodicon=new FXGIFIcon(getApp(),mininethood); zipdiskicon=new FXGIFIcon(getApp(),minizipdrive); setDrive(FXSystem::getCurrentDrive()); } // Create void FXDriveBox::create(){ FXListBox::create(); foldericon->create(); cdromicon->create(); harddiskicon->create(); netdriveicon->create(); floppyicon->create(); nethoodicon->create(); zipdiskicon->create(); } // Detach disconnects the icons void FXDriveBox::detach(){ FXListBox::detach(); foldericon->detach(); cdromicon->detach(); harddiskicon->detach(); netdriveicon->detach(); floppyicon->detach(); nethoodicon->detach(); zipdiskicon->detach(); } // Destroy zaps the icons void FXDriveBox::destroy(){ FXListBox::destroy(); foldericon->destroy(); cdromicon->destroy(); harddiskicon->destroy(); netdriveicon->destroy(); floppyicon->destroy(); nethoodicon->destroy(); zipdiskicon->destroy(); } // Set the current item's text from the message long FXDriveBox::onCmdSetValue(FXObject*,FXSelector,void* ptr){ setDrive((char*)ptr); return 1; } // Change value long FXDriveBox::onCmdSetStringValue(FXObject*,FXSelector,void* ptr){ setDrive(*((FXString*)ptr)); return 1; } // Obtain value long FXDriveBox::onCmdGetStringValue(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getDrive(); return 1; } #ifdef WIN32 // Windows flavor // Fill list with names of available drives void FXDriveBox::listDrives(){ FXFileAssoc *fileassoc; FXIcon *icon; FXchar drivename[10]; FXuint drivemask; // Remove old drives clearItems(); // Add all drives drivemask=GetLogicalDrives(); drivename[1]=':'; drivename[2]=PATHSEP; drivename[3]='\0'; // Loop over drive letters for(drivename[0]='A'; drivename[0]<='Z'; drivename[0]++){ if(drivemask&1){ // Default icon based on hardware type switch(GetDriveTypeA(drivename)){ case DRIVE_REMOVABLE: icon=(drivename[0]<='B') ? floppyicon : zipdiskicon; break; case DRIVE_FIXED: icon=harddiskicon; break; case DRIVE_REMOTE: icon=netdriveicon; break; case DRIVE_CDROM: icon=cdromicon; break; case DRIVE_RAMDISK: icon=harddiskicon; break; case DRIVE_UNKNOWN: icon=foldericon; break; case DRIVE_NO_ROOT_DIR: icon=foldericon; break; default: icon=foldericon; break; } // Maybe override from associations if(associations){ fileassoc=associations->findDirBinding(drivename); if(fileassoc && fileassoc->miniicon) icon=fileassoc->miniicon; } // Create item if(id()) icon->create(); // Add another item appendItem(drivename,icon); } drivemask>>=1; } } #else // UNIX flavor // Fill list with names of available drives void FXDriveBox::listDrives(){ FXFileAssoc *fileassoc; FXIcon *icon; // Remove old items first clearItems(); // Determine associations, icons and type icon=foldericon; if(associations){ fileassoc=associations->findDirBinding("/"); if(fileassoc && fileassoc->miniicon) icon=fileassoc->miniicon; } // Create icon if(id()) icon->create(); // Add item appendItem("/",icon); } #endif // Forward clicked message from list to target long FXDriveBox::onListClicked(FXObject*,FXSelector,void* ptr){ button->handle(this,FXSEL(SEL_COMMAND,ID_UNPOST),nullptr); // Unpost the list if(0<=((FXint)(FXival)ptr)){ field->setText(getItemText((FXint)(FXival)ptr)); field->setIcon(getItemIcon((FXint)(FXival)ptr)); if(target){target->tryHandle(this,FXSEL(SEL_COMMAND,message),(void*)getItemText((FXint)(FXival)ptr).text());} } return 1; } // List has changed long FXDriveBox::onListChanged(FXObject*,FXSelector,void* ptr){ return target && target->tryHandle(this,FXSEL(SEL_CHANGED,message),(void*)getItemText((FXint)(FXival)ptr).text()); } // Set directory FXbool FXDriveBox::setDrive(const FXString& drive){ listDrives(); setCurrentItem(findItem(FXPath::drive(FXPath::absolute(drive)))); return true; } // Return current drive FXString FXDriveBox::getDrive() const { return getItemText(getCurrentItem()); } // Change associations table; force regeneration of the items // in the tree list so all the new bindings take effect void FXDriveBox::setAssociations(FXFileAssociations* assocs){ if(associations!=assocs){ associations=assocs; listDrives(); } } // Save object to stream void FXDriveBox::save(FXStream& store) const { FXListBox::save(store); store << associations; store << foldericon; store << cdromicon; store << harddiskicon; store << netdriveicon; store << floppyicon; store << nethoodicon; store << zipdiskicon; } // Load object from stream void FXDriveBox::load(FXStream& store){ FXListBox::load(store); store >> associations; store >> foldericon; store >> cdromicon; store >> harddiskicon; store >> netdriveicon; store >> floppyicon; store >> nethoodicon; store >> zipdiskicon; } // Delete it FXDriveBox::~FXDriveBox(){ clearItems(); if(!(options&DRIVEBOX_NO_OWN_ASSOC)) delete associations; delete foldericon; delete cdromicon; delete harddiskicon; delete netdriveicon; delete floppyicon; delete nethoodicon; delete zipdiskicon; associations=(FXFileAssociations*)-1L; foldericon=(FXIcon*)-1L; cdromicon=(FXIcon*)-1L; harddiskicon=(FXIcon*)-1L; netdriveicon=(FXIcon*)-1L; floppyicon=(FXIcon*)-1L; nethoodicon=(FXIcon*)-1L; zipdiskicon=(FXIcon*)-1L; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXEXEIcon.cpp000066400000000000000000000062451455751074500220070ustar00rootroot00000000000000/******************************************************************************** * * * E X E I c o n O b j e c t * * * ********************************************************************************* * Copyright (C) 2014,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXMemoryStream.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXEXEIcon.h" /* Notes: */ using namespace FX; /*******************************************************************************/ namespace FX { // Suggested file extension const FXchar FXEXEIcon::fileExt[]="exe"; // Suggested mime type const FXchar FXEXEIcon::mimeType[]="application/octet-stream"; // Object implementation FXIMPLEMENT(FXEXEIcon,FXIcon,nullptr,0) // Initialize nicely FXEXEIcon::FXEXEIcon(FXApp* a,const FXuchar *pix,FXColor clr,FXuint opts,FXint w,FXint h,FXint ri,FXint rt):FXIcon(a,nullptr,clr,opts,w,h),rtype(rt),rid(ri){ if(pix){ FXMemoryStream ms(FXStreamLoad,const_cast(pix)); loadPixels(ms); } } // Can not save pixels FXbool FXEXEIcon::savePixels(FXStream&) const { return false; } // Load object from stream FXbool FXEXEIcon::loadPixels(FXStream& store){ FXColor *pixels; FXint w,h; if(fxloadEXE(store,pixels,w,h,rtype,rid)){ setData(pixels,IMAGE_OWNED,w,h); if(options&IMAGE_ALPHAGUESS) setTransparentColor(guesstransp()); if(options&IMAGE_THRESGUESS) setThresholdValue(guessthresh()); return true; } return false; } // Clean up FXEXEIcon::~FXEXEIcon(){ } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXEXEImage.cpp000066400000000000000000000060201455751074500221300ustar00rootroot00000000000000/******************************************************************************** * * * E X E I m a g e O b j e c t * * * ********************************************************************************* * Copyright (C) 2014,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXMemoryStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXEXEImage.h" /* Notes: */ using namespace FX; /*******************************************************************************/ namespace FX { // Suggested file extension const FXchar FXEXEImage::fileExt[]="exe"; // Suggested mime type const FXchar FXEXEImage::mimeType[]="application/octet-stream"; // Object implementation FXIMPLEMENT(FXEXEImage,FXImage,nullptr,0) // Initialize FXEXEImage::FXEXEImage(FXApp* a,const FXuchar *pix,FXuint opts,FXint w,FXint h,FXint ri,FXint rt):FXImage(a,nullptr,opts,w,h),rtype(rt),rid(ri){ if(pix){ FXMemoryStream ms(FXStreamLoad,const_cast(pix)); loadPixels(ms); } } // Can not save pixels FXbool FXEXEImage::savePixels(FXStream&) const { return false; } // Load pixel data only FXbool FXEXEImage::loadPixels(FXStream& store){ FXColor *pixels; FXint w,h; if(fxloadEXE(store,pixels,w,h,rtype,rid)){ setData(pixels,IMAGE_OWNED,w,h); return true; } return false; } // Clean up FXEXEImage::~FXEXEImage(){ } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXEventDispatcher.cpp000066400000000000000000000520531455751074500236430ustar00rootroot00000000000000/******************************************************************************** * * * E v e n t D i s p a t c h e r * * * ********************************************************************************* * Copyright (C) 2019,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXAtomic.h" #include "FXElement.h" #include "FXHash.h" #include "FXCallback.h" #include "FXAutoThreadStorageKey.h" #include "FXThread.h" #include "FXException.h" #include "FXReactor.h" #include "FXReactorCore.h" #include "FXDispatcher.h" #include "FXEventDispatcher.h" /* Notes: - FXEventDispatcher processes I/O handles, timers, signals, and idle activities just like FXDispatcher, but also processes messages/events from the display connection. - FXRawEvents from display connection are passed to dispatchEvent(). - FXEventDispatcher::dispatch() must re-implement FXReactor::dispatch() because display connection is special in some sense [having to do with message queue management]. - FIXME link to chain of FXEventLoop items from this class, and add the modal loops here. - These may be useful additions: HANDLE CreateWaitableTimerEx(LPSECURITY_ATTRIBUTES lpTimerAttributes,LPCWSTR lpTimerName, DWORD dwFlags,DWORD dwDesiredAccess); BOOL SetWaitableTimer(HANDLE hTimer,const LARGE_INTEGER *lpDueTime, LONG lPeriod,PTIMERAPCROUTINE pfnCompletionRoutine,LPVOID lpArgToCompletionRoutine,BOOL fResume); BOOL SetWaitableTimerEx(HANDLE hTimer,const LARGE_INTEGER *lpDueTime, LONG lPeriod,PTIMERAPCROUTINE pfnCompletionRoutine,LPVOID lpArgToCompletionRoutine, PREASON_CONTEXT WakeContext,ULONG TolerableDelay); BOOL CancelWaitableTimer(HANDLE hTimer); DWORD WaitForSingleObject(HANDLE hHandle,DWORD dwMilliseconds); int timerfd_create(int clockid, int flags); int timerfd_settime(int fd,int flags, const struct itimerspec* new_value, struct itimerspec* old_value); int timerfd_gettime(int fd,struct itimerspec* curr_value); */ using namespace FX; /*******************************************************************************/ namespace FX { // Units of time in nanoseconds const FXTime seconds=1000000000; const FXTime milliseconds=1000000; const FXTime microseconds=1000; // Construct event dispatcher object FXEventDispatcher::FXEventDispatcher():display(nullptr){ } // Initialize dispatcher FXbool FXEventDispatcher::init(FXptr dpy){ if(FXDispatcher::init()){ if(dpy){ #if !defined(WIN32) addHandle(ConnectionNumber((Display*)dpy),InputRead); #endif display=dpy; return true; } } return false; } // Initialize dispatcher FXbool FXEventDispatcher::init(){ if(FXDispatcher::init()){ display=nullptr; return true; } return false; } #if defined(WIN32) ////////////////////////////////////////////////////////////// // Dispatch driver FXbool FXEventDispatcher::dispatch(FXTime blocking,FXuint flags){ if(internals){ FXTime now,due,delay,interval; FXuint sig,nxt,mode,ms; FXInputHandle hnd; FXRawEvent event; // Loop till we got something while(1){ // Check for timeout delay=forever; if(flags&DispatchTimers){ due=nextTimeout(); if(duesignotified[sig],0)){ do{ nxt=(nxt+63)&63; }while(!internals->signotified[nxt] && nxt!=sig); sigreceived=nxt; if(dispatchSignal(sig)) return true; // Signal activity continue; } } // Peek for messages. This marks the message queue as unsignalled, so that // MsgWaitForMultipleObjects() would block even if there are unhandled messages. // The fix is to call MsgWaitForMultipleObjects() only AFTER having ascertained // that there are NO unhandled messages queued up. if(flags&DispatchEvents){ if(PeekMessage(&event,nullptr,0,0,PM_REMOVE)){ if(dispatchEvent(event)) return true; // Event activity continue; } } // Check active handles if(0<=current && currenthandles[current]; // Shuffle raised handle up in the list mode=internals->modes[current]; // To give all handles equal play time nxt=(current+1)%numhandles; swap(internals->handles[current],internals->handles[nxt]); swap(internals->modes[current],internals->modes[nxt]); current=-1; if(dispatchHandle(hnd,mode,flags)) return true; // IO activity continue; } // Select active handles or events; don't block if(flags&DispatchEvents){ current=MsgWaitForMultipleObjectsEx(numhandles,internals->handles,0,QS_ALLINPUT,MWMO_ALERTABLE); } else{ current=WaitForMultipleObjectsEx(numhandles,internals->handles,false,0,true); } // No handles were active if(current==WAIT_TIMEOUT){ // Idle callback if we're about to block if(flags&DispatchIdle){ if(dispatchIdle()) return true; // Idle activity } // We're not blocking if(blocking<=0) return false; // One more call to PeekMessage() here because the preceding idle processing // may have caused some more messages to be posted to the message queue. // A call to MsgWaitForMultipleObjects() when there are messages already in // the queue would block until the next message comes in. if(flags&DispatchEvents){ if(PeekMessage(&event,nullptr,0,0,PM_REMOVE)){ if(dispatchEvent(event)) return true; // Event activity continue; } } // Indefinite wait ms=INFINITE; // If not blocking indefinitely, don't exceed maxwait time interval. interval=Math::imin(delay,blocking); if(intervalhandles,ms,QS_ALLINPUT,MWMO_ALERTABLE); } else{ current=WaitForMultipleObjectsEx(numhandles,internals->handles,false,ms,true); } // Return if there was no timeout within maximum block time if(current==WAIT_TIMEOUT){ if(blocking=WAIT_ABANDONED_0){ throw FXFatalException("FXReactor::dispatch: error waiting on handles."); } } } return false; } #elif defined(HAVE_EPOLL_CREATE1) /////////////////////////////////////////////// // Dispatch driver FXbool FXEventDispatcher::dispatch(FXTime blocking,FXuint flags){ if(internals){ FXTime now,due,delay,interval; FXuint sig,nxt,ms,mode,ticks; FXInputHandle hnd; FXRawEvent event,ev; // Loop till we got something while(1){ // Check for timeout delay=forever; if(flags&DispatchTimers){ due=nextTimeout(); if(duesignotified[sig],0)){ do{ nxt=(nxt+63)&63; }while(!internals->signotified[nxt] && nxt!=sig); sigreceived=nxt; if(dispatchSignal(sig)) return true; // Signal activity continue; } } // Handle events if(flags&DispatchEvents){ if(XEventsQueued((Display*)display,QueuedAfterFlush)){ XNextEvent((Display*)display,&event); #if 0 #if 0 // Event was filtered by input method; get next one if(xim && XFilterEvent(&event,None)){ continue; } if(xim && getFocusWindow() && XFilterEvent(&event,(Window)getFocusWindow()->id())){ // FIXME continue; } #endif // Passing in focuswindow to XFilterEvent just didn't work on Gnome3 with either scim or ibus if(xim && getFocusWindow() && XFilterEvent(&event,None)){ // [Patch from Roland Baudin] FIXME but also need to deal with keyboard grabs return false; } #endif // Compress motion events if(event.xany.type==MotionNotify){ while(XPending((Display*)display)){ XPeekEvent((Display*)display,&ev); if((ev.xany.type!=MotionNotify) || (event.xmotion.window!=ev.xmotion.window) || (event.xmotion.state!=ev.xmotion.state)) break; XNextEvent((Display*)display,&event); } } // Compress wheel events else if((event.xany.type==ButtonPress) && (event.xbutton.button==Button4 || event.xbutton.button==Button5)){ ticks=1; while(XPending((Display*)display)){ XPeekEvent((Display*)display,&ev); if((ev.xany.type!=ButtonPress && ev.xany.type!=ButtonRelease) || (event.xany.window!=ev.xany.window) || (event.xbutton.button!=ev.xbutton.button)) break; ticks+=(ev.xany.type==ButtonPress); XNextEvent((Display*)display,&event); } event.xbutton.subwindow=(Window)ticks; // Stick it here for later } // Compress configure events else if(event.xany.type==ConfigureNotify){ while(XCheckTypedWindowEvent((Display*)display,event.xconfigure.window,ConfigureNotify,&ev)){ event.xconfigure.width=ev.xconfigure.width; event.xconfigure.height=ev.xconfigure.height; if(ev.xconfigure.send_event){ event.xconfigure.x=ev.xconfigure.x; event.xconfigure.y=ev.xconfigure.y; } } } // Event activity if(dispatchEvent(event)) return true; // Event activity continue; } } // Check active handles if(0events[current].data.fd; if(internals->events[current].events&EPOLLIN){ mode|=InputRead; } if(internals->events[current].events&EPOLLOUT){ mode|=InputWrite; } if(internals->events[current].events&EPOLLERR){ mode|=InputExcept; } // Display connection became active if(ConnectionNumber((Display*)display)==hnd) continue; // Regular handle became active if(dispatchHandle(hnd,mode,flags)) return true; // IO activity continue; } // Select active handles and check signals; don't block numwatched=epoll_pwait(internals->handle,internals->events,ARRAYNUMBER(internals->events),0,nullptr); // No active handles yet; need to wait if(numwatched==0){ // Idle callback if we're about to block if(flags&DispatchIdle){ if(dispatchIdle()) return true; // Idle activity } // We're not blocking if(blocking<=0) return false; // Indefinite wait ms=-1; // If not blocking indefinitely, don't exceed maxwait time interval. interval=Math::imin(delay,blocking); if(intervalhandle,internals->events,ARRAYNUMBER(internals->events),ms,nullptr); // Return if there was no timeout within maximum block time if(numwatched==0){ if(blocking= 200112L) struct timespec delta; #else struct timeval delta; #endif // Loop till we got something while(1){ // Check for timeout delay=forever; if(flags&DispatchTimers){ due=nextTimeout(); if(duesignotified[sig],0)){ do{ nxt=(nxt+63)&63; }while(!internals->signotified[nxt] && nxt!=sig); sigreceived=nxt; if(dispatchSignal(sig)) return true; // Signal activity continue; } } // Handle events if(flags&DispatchEvents){ if(XEventsQueued((Display*)display,QueuedAfterFlush)){ XNextEvent((Display*)display,&event); #if 0 #if 0 // Event was filtered by input method; get next one if(xim && XFilterEvent(&event,None)){ continue; } if(xim && getFocusWindow() && XFilterEvent(&event,(Window)getFocusWindow()->id())){ // FIXME continue; } #endif // Passing in focuswindow to XFilterEvent just didn't work on Gnome3 with either scim or ibus if(xim && getFocusWindow() && XFilterEvent(&event,None)){ // [Patch from Roland Baudin] FIXME but also need to deal with keyboard grabs return false; } #endif // Compress motion events if(event.xany.type==MotionNotify){ while(XPending((Display*)display)){ XPeekEvent((Display*)display,&ev); if((ev.xany.type!=MotionNotify) || (event.xmotion.window!=ev.xmotion.window) || (event.xmotion.state!=ev.xmotion.state)) break; XNextEvent((Display*)display,&event); } } // Compress wheel events else if((event.xany.type==ButtonPress) && (event.xbutton.button==Button4 || event.xbutton.button==Button5)){ ticks=1; while(XPending((Display*)display)){ XPeekEvent((Display*)display,&ev); if((ev.xany.type!=ButtonPress && ev.xany.type!=ButtonRelease) || (event.xany.window!=ev.xany.window) || (event.xbutton.button!=ev.xbutton.button)) break; ticks+=(ev.xany.type==ButtonPress); XNextEvent((Display*)display,&event); } event.xbutton.subwindow=(Window)ticks; // Stick it here for later } // Compress configure events else if(event.xany.type==ConfigureNotify){ while(XCheckTypedWindowEvent((Display*)display,event.xconfigure.window,ConfigureNotify,&ev)){ event.xconfigure.width=ev.xconfigure.width; event.xconfigure.height=ev.xconfigure.height; if(ev.xconfigure.send_event){ event.xconfigure.x=ev.xconfigure.x; event.xconfigure.y=ev.xconfigure.y; } } } // Event activity if(dispatchEvent(event)) return true; // Event activity continue; } } // Check active handles if(0watched[0])){ FD_CLR(current,&internals->watched[0]); numraised--; mode|=InputRead; } if(FD_ISSET(current,&internals->watched[1])){ FD_CLR(current,&internals->watched[1]); numraised--; mode|=InputWrite; } if(FD_ISSET(current,&internals->watched[2])){ FD_CLR(current,&internals->watched[2]); numraised--; mode|=InputExcept; } } while(mode==0); // Display connection became active if(ConnectionNumber((Display*)display)==current) continue; // IO handle became active if(dispatchHandle(current,mode,flags)) return true; // IO activity continue; } // Prepare handles to check internals->watched[0]=internals->handles[0]; internals->watched[1]=internals->handles[1]; internals->watched[2]=internals->handles[2]; // Select active handles and check signals; don't block #if (_POSIX_C_SOURCE >= 200112L) numraised=pselect(numhandles,&internals->watched[0],&internals->watched[1],&internals->watched[2],nullptr,nullptr); #else numraised=select(numhandles,&internals->watched[0],&internals->watched[1],&internals->watched[2],nullptr); #endif // No handles were active if(numraised==0){ // Idle callback if we're about to block if(flags&DispatchIdle){ if(dispatchIdle()) return true; // Idle activity } // We're not blocking if(blocking<=0) return false; // Prepare handles to check internals->watched[0]=internals->handles[0]; internals->watched[1]=internals->handles[1]; internals->watched[2]=internals->handles[2]; // Nanoseconds to wait interval=Math::imin(delay,blocking); if(interval= 200112L) delta.tv_sec=interval/seconds; delta.tv_nsec=(interval-seconds*delta.tv_sec); numraised=pselect(numhandles,&internals->watched[0],&internals->watched[1],&internals->watched[2],&delta,nullptr); #else delta.tv_sec=interval/seconds; delta.tv_usec=(interval-seconds*delta.tv_sec)/microseconds; numraised=select(numhandles,&internals->watched[0],&internals->watched[1],&internals->watched[2],&delta); #endif // Return if there was no timeout within maximum block time if(numraised==0){ if(blocking * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXAtomic.h" #include "FXElement.h" #include "FXHash.h" #include "FXCallback.h" #include "FXReactor.h" #include "FXReactorCore.h" #include "FXDispatcher.h" #include "FXEventDispatcher.h" #include "FXEventLoop.h" /* Notes: - Manage nested event loops. - Exceptions will unroll through event loops. - The member variable invocation holds the address of the variable containing the innermost model loop currently running; so we can locate all model loops through invocation. */ using namespace FX; /*******************************************************************************/ namespace FX { // Enter modal loop FXEventLoop::FXEventLoop(FXEventLoop** inv,FXWindow* win,FXuint mode):dispatcher(nullptr),invocation(inv),upper(*inv),window(win),modality(mode),code(0),done(false){ *invocation=this; } // Return window of current modal loop FXWindow* FXEventLoop::getModalWindow() const { if(invocation){ return (*invocation)->window; } return nullptr; } // Test if the window is involved in a modal invocation FXbool FXEventLoop::isModal(FXWindow *win) const { if(invocation){ FXEventLoop* eventloop=*invocation; while(eventloop){ if(eventloop->window==win && eventloop->modality){ return true; } eventloop=eventloop->upper; } } return false; } // Break out of all event loops, closing all nested loops also void FXEventLoop::stop(FXint value){ if(invocation){ FXEventLoop* eventloop=*invocation; while(eventloop){ eventloop->done=true; eventloop->code=0; if(eventloop->upper==nullptr){ eventloop->code=value; break; } eventloop=eventloop->upper; } } } // Break out of modal loop matching window, and all deeper ones void FXEventLoop::stopModal(FXWindow* win,FXint value){ if(isModal(win)){ FXEventLoop* eventloop=*invocation; while(eventloop){ eventloop->done=true; eventloop->code=0; if(eventloop->window==win && eventloop->modality){ eventloop->code=value; break; } eventloop=eventloop->upper; } } } // Break out of innermost modal loop, and all deeper non-modal ones void FXEventLoop::stopModal(FXint value){ if(invocation){ FXEventLoop* eventloop=*invocation; while(eventloop){ eventloop->done=true; eventloop->code=0; if(eventloop->modality){ eventloop->code=value; break; } eventloop=eventloop->upper; } } } // Exit modal loop FXEventLoop::~FXEventLoop(){ *invocation=upper; } #if 0 // Perform a single event dispatch FXbool FXEventLoop::runOneEvent(FXTime blocking,FXuint flags){ return dispatcher && dispatcher->dispatch(blocking,flags); } // Run application FXint FXEventLoop::run(){ FXEventLoop inv(&invocation); while(!inv.done){ runOneEvent(); } return inv.code; } // Run till some flag becomes non-zero FXint FXEventLoop::runUntil(FXuint& condition){ FXEventLoop inv(&invocation); while(!inv.done && condition==0){ runOneEvent(); } return condition; } // Run event loop while events are available FXint FXEventLoop::runWhileEvents(FXTime blocking){ FXEventLoop inv(&invocation,); while(!inv.done && runOneEvent(blocking)) blocking=1000; return !inv.done; } // Run event loop while events are available FXint FXEventLoop::runModalWhileEvents(FXWindow* window,FXTime blocking){ FXEventLoop inv(&invocation,window,MODAL_FOR_WINDOW); while(!inv.done && runOneEvent(blocking)) blocking=1000; return !inv.done; } // Run modal event loop, blocking events to all windows, until stopModal is called. FXint FXEventLoop::runModal(){ FXEventLoop inv(&invocation); while(!inv.done){ runOneEvent(); } return inv.code; } // Run modal for window FXint FXEventLoop::runModalFor(FXWindow* window){ FXEventLoop inv(&invocation,window,MODAL_FOR_WINDOW); while(!inv.done){ runOneEvent(); } return inv.code; } // Run modal while window is shown, or until stopModal is called FXint FXEventLoop::runModalWhileShown(FXWindow* window){ FXEventLoop inv(&invocation,window,MODAL_FOR_WINDOW); while(!inv.done && window->shown()){ runOneEvent(); } return inv.code; } // Run popup menu FXint FXEventLoop::runPopup(FXWindow* window){ FXEventLoop inv(&invocation,window,MODAL_FOR_POPUP); while(!inv.done && window->shown()){ runOneEvent(); } return inv.code; } #endif } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXException.cpp000066400000000000000000000052451455751074500225120ustar00rootroot00000000000000/******************************************************************************** * * * E x c e p t i o n T y p e s * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "fxver.h" #include "fxdefs.h" #include "FXException.h" using namespace FX; namespace FX { // Generic unspecified exception const FXchar FXException::exceptionName[]="unknown"; // Fatal error occured const FXchar FXFatalException::exceptionName[]="fatal"; // Error occured const FXchar FXErrorException::exceptionName[]="error"; // Index out of range const FXchar FXRangeException::exceptionName[]="out of range"; // Invalid pointer argument const FXchar FXPointerException::exceptionName[]="invalid pointer"; // Some resource exhausted const FXchar FXResourceException::exceptionName[]="resource exhausted"; // Out of memory const FXchar FXMemoryException::exceptionName[]="out of memory"; // Window exception const FXchar FXWindowException::exceptionName[]="window exception"; // Image, cursor, bitmap exception const FXchar FXImageException::exceptionName[]="image exception"; // Font exception const FXchar FXFontException::exceptionName[]="font exception"; // Thread exception const FXchar FXThreadException::exceptionName[]="thread exception"; } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXExpression.cpp000066400000000000000000000767251455751074500227260ustar00rootroot00000000000000/******************************************************************************** * * * E x p r e s s i o n E v a l u a t o r * * * ********************************************************************************* * Copyright (C) 1998,2023 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxascii.h" #include "fxunicode.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXElement.h" #include "FXString.h" #include "FXExpression.h" /* Notes: - Old as night, but recently rediscovered ;-). - Better treatment of identifiers needed [user-supplied names]. - Maintain stack-depth during compile phase for possible limit check. - The new return code ErrMore means not all the input for the expression was consumed; It could treated it as ErrOK. However, we should add a way to find out where the parse stopped. */ #define TOPIC_CONSTRUCT 1000 #define TOPIC_DETAIL 1001 //#define TOPIC_EXPDUMP 1015 // Debugging expression code #define MAXSTACKDEPTH 128 // Access to argument #if defined(__i386__) || defined(__x86_64__) // No alignment limits on shorts #define SETARG(p,val) (*((FXshort*)(p))=(val)) #define GETARG(p) (*((const FXshort*)(p))) #elif (FOX_BIGENDIAN == 1) // Big-endian machines #define SETARG(p,val) (*((p)+0)=(val)>>8,*((p)+1)=(val)) #define GETARG(p) ((FXshort)((*((p)+0)<<8)+(*((p)+1)))) #else // Little-endian machines #define SETARG(p,val) (*((p)+0)=(val),*((p)+1)=(val)>>8) #define GETARG(p) ((FXshort)((*((p)+0))+(*((p)+1)<<8))) #endif using namespace FX; /*******************************************************************************/ namespace FX { // Furnish our own versions extern FXAPI FXlong __strtoll(const FXchar *beg,const FXchar** end=nullptr,FXint base=0,FXbool* ok=nullptr); extern FXAPI FXdouble __strtod(const FXchar *beg,const FXchar** end=nullptr,FXbool* ok=nullptr); namespace { // Tokens enum { TK_EOF = 0U, TK_INT = 1U, TK_INT_HEX = 2U, TK_INT_BIN = 3U, TK_INT_OCT = 4U, TK_REAL = 5U, TK_PLUS = 6U, TK_MINUS = 7U, TK_TIMES = 8U, TK_DIVIDE = 9U, TK_MODULO = 10U, TK_POWER = 11U, TK_LPAR = 12U, TK_RPAR = 13U, TK_LESS = 14U, TK_GREATER = 15U, TK_LESSEQ = 16U, TK_GREATEREQ = 17U, TK_EQUAL = 18U, TK_NOTEQUAL = 19U, TK_AND = 20U, TK_OR = 21U, TK_XOR = 22U, TK_NOT = 23U, TK_SHIFTLEFT = 24U, TK_SHIFTRIGHT = 25U, TK_COMMA = 26U, TK_QUEST = 27U, TK_COLON = 28U, TK_ERROR = 29U, TK_PI = 2585U, TK_EULER = 69U, TK_RTOD = 3005613U, TK_DTOR = 2389741U, TK_ABS = 108848U, TK_ACOS = 3592862U, TK_ACOSH = 118564406U, TK_ASIN = 3610325U, TK_ASINH = 119140637U, TK_ATAN = 3615258U, TK_ATANH = 119303474U, TK_CBRT = 3520359U, TK_CEIL = 3523203U, TK_COS = 107103U, TK_COSH = 3534423U, TK_CUB = 107284U, TK_ERF = 113713U, TK_ERFC = 3752498U, TK_EXP = 114029U, TK_EXP2 = 3763007U, TK_EXP10 = 124179084U, TK_FLOOR = 122360152U, TK_INVERF = 4219871328U, TK_INVERFC = 1816800259U, TK_ISFIN = 128618299U, TK_ISINF = 128611099U, TK_ISNAN = 128609851U, TK_LOG = 114052U, TK_LOG2 = 3763766U, TK_LOG10 = 124204261U, TK_NEAR = 3985784U, TK_SIN = 124308U, TK_SINH = 4102268U, TK_SQR = 123536U, TK_SQRT = 4076772U, TK_ROUND = 136616002U, TK_TRUNC = 133596670U, TK_TAN = 123227U, TK_TANH = 4066515U, TK_WRAP = 4221012U, TK_WRAP4 = 139293408U, TK_MAX = 121748U, TK_MIN = 121482U, TK_POW = 119176U, TK_ATAN2 = 119303528U, }; // Opcodes enum { OP_END, OP_BRA, OP_BRT, OP_BRF, OP_NUM, OP_VAR, OP_NOT, OP_NEG, OP_MUL, OP_DIV, OP_MOD, OP_ADD, OP_SUB, OP_AND, OP_OR, OP_XOR, OP_SHL, OP_SHR, OP_LT, OP_GT, OP_LE, OP_GE, OP_EQ, OP_NE, OP_ABS, OP_ACOS, OP_ACOSH, OP_ASIN, OP_ASINH, OP_ATAN, OP_ATANH, OP_CEIL, OP_COS, OP_COSH, OP_ERF, OP_ERFC, OP_EXP, OP_EXP2, OP_EXP10, OP_FLOOR, OP_INVERF, OP_INVERFC, OP_ISFIN, OP_ISINF, OP_ISNAN, OP_LOG, OP_LOG2, OP_LOG10, OP_NEAR, OP_SIN, OP_SINH, OP_SQR, OP_CUB, OP_SQRT, OP_CBRT, OP_ROUND, OP_TRUNC, OP_TAN, OP_TANH, OP_WRAP, OP_WRAP4, OP_MAX, OP_MIN, OP_POW, OP_ATAN2, OP_LAST }; // Compile class class FXCompile { const FXchar *head; // Start of token const FXchar *tail; // End of token + 1 const FXchar *vars; // Variables FXuchar *code; // Program code FXuchar *pc; // Program counter FXuint token; // Token public: // Create compile engine FXCompile(FXuchar *prog,const FXchar* ex,const FXchar* vs); // Return size of generated code FXival size() const { return pc-code; } // Get token void gettok(); // Parsing FXExpression::Error compile(); FXExpression::Error expression(); FXExpression::Error altex(); FXExpression::Error compex(); FXExpression::Error shiftexp(); FXExpression::Error bitexp(); FXExpression::Error addexp(); FXExpression::Error mulexp(); FXExpression::Error powexp(); FXExpression::Error primary(); FXExpression::Error element(); // Variable lookup FXint lookup(const FXchar* sym,FXival len) const; // Code generation FXuchar* opcode(FXuchar op); FXuchar* offset(FXival n); FXuchar* number(FXdouble num); // Backpatch void fix(FXuchar *ptr,FXival val); }; /*******************************************************************************/ // Construct compile engine FXCompile::FXCompile(FXuchar *prog,const FXchar* ex,const FXchar* vs):head(ex),tail(ex),vars(vs),code(prog),pc(prog),token(TK_EOF){ } // Compile expression FXExpression::Error FXCompile::compile(){ FXExpression::Error err; FXuchar* at=pc; gettok(); pc+=2; FXASSERT_STATIC(OP_LAST<=256); // Empty expression if(token==TK_EOF) return FXExpression::ErrEmpty; // Parse expression err=expression(); // Error occurred if(err!=FXExpression::ErrOK) return err; // Return from evaluator opcode(OP_END); FXTRACE((TOPIC_DETAIL,"SIZE=%ld\n",pc-code)); // Code is too long if(code+32767': token=TK_GREATER; tail++; if(*tail=='='){ token=TK_GREATEREQ; tail++; } else if(*tail=='>'){ token=TK_SHIFTRIGHT; tail++; } return; case '|': token=TK_OR; tail++; return; case '&': token=TK_AND; tail++; return; case '^': token=TK_XOR; tail++; return; case '~': token=TK_NOT; tail++; return; case '-': token=TK_MINUS; tail++; return; case '+': token=TK_PLUS; tail++; return; case '*': token=TK_TIMES; tail++; if(*tail=='*'){ token=TK_POWER; tail++; } return; case '/': token=TK_DIVIDE; tail++; return; case '%': token=TK_MODULO; tail++; return; case '!': token=TK_ERROR; tail++; if(*tail=='='){ token=TK_NOTEQUAL; tail++; } return; case '(': token=TK_LPAR; tail++; return; case ')': token=TK_RPAR; tail++; return; case ',': token=TK_COMMA; tail++; return; case '?': token=TK_QUEST; tail++; return; case ':': token=TK_COLON; tail++; return; case '.': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': token=TK_INT; if(c=='0'){ tail++; if(*tail=='x' || *tail=='X'){ tail++; if(!Ascii::isHexDigit(*tail)){ token=TK_ERROR; return; } tail++; while(Ascii::isHexDigit(*tail)) tail++; token=TK_INT_HEX; return; } if(*tail=='b' || *tail=='B'){ tail++; if(*tail!='0' && *tail!='1'){ token=TK_ERROR; return; } tail++; while(*tail=='0' || *tail=='1') tail++; token=TK_INT_BIN; return; } if('0'<=*tail && *tail<='7'){ tail++; while('0'<=*tail && *tail<='7') tail++; if('7'<=*tail && *tail<='9'){ token=TK_ERROR; return; } token=TK_INT_OCT; return; } } while(Ascii::isDigit(*tail)) tail++; if(*tail=='.'){ token=TK_REAL; tail++; while(Ascii::isDigit(*tail)) tail++; } if(*tail=='e' || *tail=='E'){ token=TK_REAL; tail++; if(*tail=='-' || *tail=='+') tail++; if(!Ascii::isDigit(*tail)){ token=TK_ERROR; return; } tail++; while(Ascii::isDigit(*tail)) tail++; } return; case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': token=(FXuchar)*tail++; while(Ascii::isWord(*tail)){ token=((token<<5)+token) ^ (FXuchar)*tail++; } //FXTRACE((1,"token=%u\n",token)); return; default: token=TK_ERROR; return; } } token=TK_EOF; } // Emit opcode FXuchar* FXCompile::opcode(FXuchar op){ FXuchar* result=pc; if(code){ pc[0]=op; } pc++; return result; } // Emit offset FXuchar* FXCompile::offset(FXival n){ FXuchar* result=pc; if(code){ SETARG(pc,n); } pc+=2; return result; } // Emit double FXuchar* FXCompile::number(FXdouble n){ FXuchar* result=pc; if(code){ #if defined(__i386__) || defined(__x86_64__) || defined(WIN32) || defined(__minix) ((FXdouble*)pc)[0]=n; #else pc[0]=((const FXuchar*)&n)[0]; pc[1]=((const FXuchar*)&n)[1]; pc[2]=((const FXuchar*)&n)[2]; pc[3]=((const FXuchar*)&n)[3]; pc[4]=((const FXuchar*)&n)[4]; pc[5]=((const FXuchar*)&n)[5]; pc[6]=((const FXuchar*)&n)[6]; pc[7]=((const FXuchar*)&n)[7]; #endif } pc+=8; return result; } // Fix value void FXCompile::fix(FXuchar *ptr,FXival val){ if(code && ptr){ SETARG(ptr,val); } } } /*******************************************************************************/ // Default expression (returns 0) #if (FOX_BIGENDIAN == 1) const FXuchar FXExpression::initial[]={0,14,OP_NUM,0,0,0,0,0,0,0,0,OP_END}; #endif #if (FOX_BIGENDIAN == 0) const FXuchar FXExpression::initial[]={14,0,OP_NUM,0,0,0,0,0,0,0,0,OP_END}; #endif // Empty expression #define EMPTY (const_cast(FXExpression::initial)) // Error messages const FXchar *const FXExpression::errors[]={ "OK", "Empty expression", "Extra characters at end", "Out of memory", "Unmatched parenthesis", "Illegal token", "Expected comma", "Unknown identifier", "Expected colon", "Expression too long", }; // Construct empty expression object FXExpression::FXExpression():code(EMPTY){ FXTRACE((TOPIC_CONSTRUCT,"FXExpression::FXExpression()\n")); } // Copy regex object FXExpression::FXExpression(const FXExpression& orig):code(EMPTY){ FXTRACE((TOPIC_CONSTRUCT,"FXExpression::FXExpression(FXExpression)\n")); if(orig.code!=initial){ dupElms(code,orig.code,GETARG(orig.code)); } } // Compile expression from pattern; fail if error FXExpression::FXExpression(const FXchar* expression,const FXchar* variables,FXExpression::Error* error):code(EMPTY){ FXTRACE((TOPIC_CONSTRUCT,"FXExpression::FXExpression(%s,%s,%p)\n",expression,variables,error)); FXExpression::Error err=parse(expression,variables); if(error){ *error=err; } } // Compile expression from pattern; fail if error FXExpression::FXExpression(const FXString& expression,const FXString& variables,FXExpression::Error* error):code(EMPTY){ FXTRACE((TOPIC_CONSTRUCT,"FXExpression::FXExpression(%s,%s,%p)\n",expression.text(),variables.text(),error)); FXExpression::Error err=parse(expression.text(),variables.text()); if(error){ *error=err; } } // Assignment FXExpression& FXExpression::operator=(const FXExpression& orig){ if(code!=orig.code){ if(code!=initial) freeElms(code); code=EMPTY; if(orig.code!=initial){ dupElms(code,orig.code,GETARG(orig.code)); } } return *this; } /*******************************************************************************/ #ifdef TOPIC_EXPDUMP #include "fxexprdbg.h" #endif // Parse expression, return error code if syntax error is found FXExpression::Error FXExpression::parse(const FXchar* expression,const FXchar* variables){ FXExpression::Error err=FXExpression::ErrEmpty; FXTRACE((TOPIC_DETAIL,"Expression::parse(%s,%p)\n",expression,variables)); // Free old code, if any clear(); // If not empty, parse expression if(expression){ // Create compile engine FXCompile cs(nullptr,expression,variables); // Parse to check syntax and determine size if((err=cs.compile())==ErrOK){ FXuchar *prog; // Allocate new code if(allocElms(prog,cs.size())){ // Create compile engine FXCompile gs(prog,expression,variables); // Now generate code for expression if((err=gs.compile())==ErrOK){ // Size still checking out? FXASSERT(gs.size()==cs.size()); // Install new program code=prog; #ifdef TOPIC_EXPDUMP if(getTraceTopic(TOPIC_EXPDUMP)){ dump(code); } #endif // Report success return ErrOK; } freeElms(prog); } } } return err; } // Parse expression, return error code if syntax error is found FXExpression::Error FXExpression::parse(const FXString& expression,const FXString& variables){ return parse(expression.text(),variables.text()); } // Evaluate expression FXdouble FXExpression::evaluate(const FXdouble *args) const { FXdouble stack[MAXSTACKDEPTH]; const FXuchar *pc=code+2; FXdouble *sp=stack; stack[0]=0.0; while(1){ switch(*pc++){ case OP_END: return *sp; case OP_BRA: pc+=GETARG(pc); break; case OP_BRF: pc+=*sp-- ? 2 : GETARG(pc); break; case OP_BRT: pc+=*sp-- ? GETARG(pc) : 2; break; #if defined(__i386__) || defined(__x86_64__) || defined(WIN32) || defined(__minix) case OP_NUM: *++sp=*((const FXdouble*)pc); pc+=8; break; #else case OP_NUM: ++sp; ((FXuchar*)sp)[0]=*pc++; ((FXuchar*)sp)[1]=*pc++; ((FXuchar*)sp)[2]=*pc++; ((FXuchar*)sp)[3]=*pc++; ((FXuchar*)sp)[4]=*pc++; ((FXuchar*)sp)[5]=*pc++; ((FXuchar*)sp)[6]=*pc++; ((FXuchar*)sp)[7]=*pc++; break; #endif case OP_VAR: *++sp=args[*pc++]; break; case OP_NOT: *sp=(FXdouble)(~((FXlong)*sp)); break; case OP_NEG: *sp=-*sp; break; case OP_ABS: *sp=Math::fabs(*sp); break; case OP_SIN: *sp=Math::sin(*sp); break; case OP_COS: *sp=Math::cos(*sp); break; case OP_TAN: *sp=Math::tan(*sp); break; case OP_ASIN: *sp=Math::asin(*sp); break; case OP_ACOS: *sp=Math::acos(*sp); break; case OP_ATAN: *sp=Math::atan(*sp); break; case OP_SINH: *sp=Math::sinh(*sp); break; case OP_COSH: *sp=Math::cosh(*sp); break; case OP_TANH: *sp=Math::tanh(*sp); break; case OP_ASINH: *sp=Math::asinh(*sp); break; case OP_ACOSH: *sp=Math::acosh(*sp); break; case OP_ATANH: *sp=Math::atanh(*sp); break; case OP_SQR: *sp=Math::sqr(*sp); break; case OP_CUB: *sp=Math::cub(*sp); break; case OP_SQRT: *sp=Math::sqrt(*sp); break; case OP_CBRT: *sp=Math::cbrt(*sp); break; case OP_CEIL: *sp=Math::ceil(*sp); break; case OP_FLOOR: *sp=Math::floor(*sp); break; case OP_NEAR: *sp=Math::nearbyint(*sp); break; case OP_ROUND: *sp=Math::round(*sp); break; case OP_TRUNC: *sp=Math::trunc(*sp); break; case OP_ERF: *sp=Math::erf(*sp); break; case OP_ERFC: *sp=Math::erfc(*sp); break; case OP_INVERF: *sp=Math::inverf(*sp); break; case OP_INVERFC: *sp=Math::inverfc(*sp); break; case OP_EXP: *sp=Math::exp(*sp); break; case OP_EXP2: *sp=Math::exp2(*sp); break; case OP_EXP10: *sp=Math::exp10(*sp); break; case OP_LOG: *sp=Math::log(*sp); break; case OP_LOG2: *sp=Math::log2(*sp); break; case OP_LOG10: *sp=Math::log10(*sp); break; case OP_ISFIN: *sp=(FXdouble)Math::fpFinite(*sp); break; case OP_ISINF: *sp=(FXdouble)Math::fpInfinite(*sp); break; case OP_ISNAN: *sp=(FXdouble)Math::fpNan(*sp); break; case OP_WRAP: *sp=Math::wrap(*sp); break; case OP_WRAP4: *sp=Math::wrap4(*sp); break; case OP_MUL: *(sp-1)=*(sp-1) * *sp; --sp; break; case OP_DIV: *(sp-1)=*(sp-1) / *sp; --sp; break; case OP_MOD: *(sp-1)=Math::fmod(*(sp-1),*sp); --sp; break; case OP_ADD: *(sp-1)=*(sp-1) + *sp; --sp; break; case OP_SUB: *(sp-1)=*(sp-1) - *sp; --sp; break; case OP_AND: *(sp-1)=(FXdouble)(((FXlong)*(sp-1)) & ((FXlong)*sp)); --sp; break; case OP_OR: *(sp-1)=(FXdouble)(((FXlong)*(sp-1)) | ((FXlong)*sp)); --sp; break; case OP_XOR: *(sp-1)=(FXdouble)(((FXlong)*(sp-1)) ^ ((FXlong)*sp)); --sp; break; case OP_SHL: *(sp-1)=(FXdouble)(((FXlong)*(sp-1)) << ((FXlong)*sp)); --sp; break; case OP_SHR: *(sp-1)=(FXdouble)(((FXlong)*(sp-1)) >> ((FXlong)*sp)); --sp; break; case OP_LT: *(sp-1)=(FXdouble)(*(sp-1) < *sp); --sp; break; case OP_GT: *(sp-1)=(FXdouble)(*(sp-1) > *sp); --sp; break; case OP_LE: *(sp-1)=(FXdouble)(*(sp-1) <= *sp); --sp; break; case OP_GE: *(sp-1)=(FXdouble)(*(sp-1) >= *sp); --sp; break; case OP_EQ: *(sp-1)=(FXdouble)(*(sp-1) == *sp); --sp; break; case OP_NE: *(sp-1)=(FXdouble)(*(sp-1) != *sp); --sp; break; case OP_POW: *(sp-1)=Math::pow(*(sp-1),*sp); --sp; break; case OP_MAX: *(sp-1)=Math::fmax(*(sp-1),*sp); --sp; break; case OP_MIN: *(sp-1)=Math::fmin(*(sp-1),*sp); --sp; break; case OP_ATAN2: *(sp-1)=Math::atan2(*(sp-1),*sp); --sp; break; } } return 0.0; } // Save FXStream& operator<<(FXStream& store,const FXExpression& s){ FXshort size=GETARG(s.code); store << size; store.save(s.code+2,size-2); return store; } // Load FXStream& operator>>(FXStream& store,FXExpression& s){ FXshort size; store >> size; allocElms(s.code,size); store.load(s.code+2,size-2); SETARG(s.code,size); return store; } // Clear the expression void FXExpression::clear(){ if(code!=EMPTY){ freeElms(code); code=EMPTY; } } // Clean up FXExpression::~FXExpression(){ FXTRACE((TOPIC_CONSTRUCT,"FXExpression::~FXExpression()\n")); clear(); } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXExtentd.cpp000066400000000000000000000133511455751074500221640ustar00rootroot00000000000000/******************************************************************************** * * * D o u b l e - P r e c i s i o n E x t e n t C l a s s * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXVec2d.h" #include "FXExtentd.h" /* Notes: */ using namespace FX; /************************** E x t e n t C l a s s *************************/ namespace FX { // Longest side FXdouble FXExtentd::longest() const { FXdouble x=upper.x-lower.x; FXdouble y=upper.y-lower.y; return Math::fmax(x,y); } // Shortest side FXdouble FXExtentd::shortest() const { FXdouble x=upper.x-lower.x; FXdouble y=upper.y-lower.y; return Math::fmin(x,y); } // Length of diagonal FXdouble FXExtentd::diameter() const { FXdouble x=upper.x-lower.x; FXdouble y=upper.y-lower.y; return Math::sqrt(x*x+y*y); } // Get radius of box FXdouble FXExtentd::radius() const { return diameter()*0.5; } // Get diagonal of box FXVec2d FXExtentd::diagonal() const { return upper-lower; } // Get center of box FXVec2d FXExtentd::center() const { return 0.5*(upper+lower); } // Test if empty FXbool FXExtentd::empty() const { return upper.xn) n=ni; if(fiupper.x)) return false; } if(__likely(dir.y!=0.0)){ if(0.0n) n=ni; if(fif) return false; } else{ if((pos.yupper.y)) return false; } hit[0]=n; hit[1]=f; return true; } // Test if overlap FXbool overlap(const FXExtentd& a,const FXExtentd& b){ return a.upper.x>=b.lower.x && a.lower.x<=b.upper.x && a.upper.y>=b.lower.y && a.lower.y<=b.upper.y; } // Union of two boxes FXExtentd unite(const FXExtentd& a,const FXExtentd& b){ return FXExtentd(lo(a.lower,b.lower),hi(a.upper,b.upper)); } // Intersection of two boxes FXExtentd intersect(const FXExtentd& a,const FXExtentd& b){ return FXExtentd(hi(a.lower,b.lower),lo(a.upper,b.upper)); } // Saving FXStream& operator<<(FXStream& store,const FXExtentd& ext){ store << ext.lower.x << ext.upper.x; store << ext.lower.y << ext.upper.y; return store; } // Loading FXStream& operator>>(FXStream& store,FXExtentd& ext){ store >> ext.lower.x >> ext.upper.x; store >> ext.lower.y >> ext.upper.y; return store; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXExtentf.cpp000066400000000000000000000133421455751074500221660ustar00rootroot00000000000000/******************************************************************************** * * * S i n g l e - P r e c i s i o n E x t e n t C l a s s * * * ********************************************************************************* * Copyright (C) 2004,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXVec2f.h" #include "FXExtentf.h" /* Notes: */ using namespace FX; /************************** E x t e n t C l a s s *************************/ namespace FX { // Longest side FXfloat FXExtentf::longest() const { FXfloat x=upper.x-lower.x; FXfloat y=upper.y-lower.y; return Math::fmax(x,y); } // Shortest side FXfloat FXExtentf::shortest() const { FXfloat x=upper.x-lower.x; FXfloat y=upper.y-lower.y; return Math::fmin(x,y); } // Length of diagonal FXfloat FXExtentf::diameter() const { FXfloat x=upper.x-lower.x; FXfloat y=upper.y-lower.y; return Math::sqrt(x*x+y*y); } // Get radius of box FXfloat FXExtentf::radius() const { return diameter()*0.5f; } // Get diagonal of box FXVec2f FXExtentf::diagonal() const { return upper-lower; } // Get center of box FXVec2f FXExtentf::center() const { return 0.5f*(upper+lower); } // Test if empty FXbool FXExtentf::empty() const { return upper.xn) n=ni; if(fiupper.x)) return false; } if(__likely(dir.y!=0.0f)){ if(0.0fn) n=ni; if(fif) return false; } else{ if((pos.yupper.y)) return false; } hit[0]=n; hit[1]=f; return true; } // Test if overlap FXbool overlap(const FXExtentf& a,const FXExtentf& b){ return a.upper.x>=b.lower.x && a.lower.x<=b.upper.x && a.upper.y>=b.lower.y && a.lower.y<=b.upper.y; } // Union of two boxes FXExtentf unite(const FXExtentf& a,const FXExtentf& b){ return FXExtentf(lo(a.lower,b.lower),hi(a.upper,b.upper)); } // Intersection of two boxes FXExtentf intersect(const FXExtentf& a,const FXExtentf& b){ return FXExtentf(hi(a.lower,b.lower),lo(a.upper,b.upper)); } // Saving FXStream& operator<<(FXStream& store,const FXExtentf& ext){ store << ext.lower.x << ext.upper.x; store << ext.lower.y << ext.upper.y; return store; } // Loading FXStream& operator>>(FXStream& store,FXExtentf& ext){ store >> ext.lower.x >> ext.upper.x; store >> ext.lower.y >> ext.upper.y; return store; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXFile.cpp000066400000000000000000000421761455751074500214370ustar00rootroot00000000000000/******************************************************************************** * * * F i l e C l a s s * * * ********************************************************************************* * Copyright (C) 2000,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxchar.h" #include "fxmath.h" #include "fxascii.h" #include "FXArray.h" #include "FXHash.h" #include "FXStream.h" #include "FXString.h" #include "FXIO.h" #include "FXIODevice.h" #include "FXStat.h" #include "FXFile.h" #include "FXPipe.h" #include "FXDir.h" /* Notes: - Implemented many functions in terms of FXFile and FXDir so we won't have to worry about unicode stuff. */ // Bad handle value #ifdef WIN32 #define BadHandle INVALID_HANDLE_VALUE #else #define BadHandle -1 #endif using namespace FX; /*******************************************************************************/ namespace FX { // Construct file and attach existing handle h FXFile::FXFile(FXInputHandle h){ attach(h); } // Construct and open a file FXFile::FXFile(const FXString& filename,FXuint m,FXuint perm){ open(filename,m,perm); } #if defined(WIN32) // Open file FXbool FXFile::open(const FXString& filename,FXuint m,FXuint perm){ if(device==BadHandle){ // Basic access mode DWORD access=0; switch(m&(FXIO::ReadOnly|FXIO::WriteOnly)){ case FXIO::ReadOnly: access=GENERIC_READ; break; case FXIO::WriteOnly: access=GENERIC_WRITE; break; case FXIO::ReadWrite: access=GENERIC_READ|GENERIC_WRITE; break; } // Creation and truncation mode DWORD creation=OPEN_EXISTING; switch(m&(FXIO::Create|FXIO::Truncate|FXIO::Exclusive)){ case FXIO::Create: creation=OPEN_ALWAYS; break; case FXIO::Exclusive: creation=CREATE_NEW; break; case FXIO::Truncate: creation=TRUNCATE_EXISTING; break; case FXIO::Create|FXIO::Truncate: creation=CREATE_ALWAYS; break; case FXIO::Create|FXIO::Exclusive: creation=CREATE_NEW; break; case FXIO::Create|FXIO::Truncate|FXIO::Exclusive: creation=CREATE_NEW; break; } // Attributes (hidden, read-only) DWORD attributes=FILE_ATTRIBUTE_NORMAL; if(!(perm&FXIO::AllWrite)){ attributes=(attributes&~FILE_ATTRIBUTE_NORMAL)|FILE_ATTRIBUTE_READONLY; } if(perm&FXIO::Hidden){ attributes=(attributes&~FILE_ATTRIBUTE_NORMAL)|FILE_ATTRIBUTE_HIDDEN; } // Inheritable SECURITY_ATTRIBUTES security; security.nLength=sizeof(SECURITY_ATTRIBUTES); security.bInheritHandle=((m&FXIO::Inheritable)==0); security.lpSecurityDescriptor=nullptr; // Do it #if defined(UNICODE) FXnchar unifile[MAXPATHLEN]; utf2ncs(unifile,filename.text(),MAXPATHLEN); device=::CreateFileW(unifile,access,FILE_SHARE_READ|FILE_SHARE_WRITE,&security,creation,attributes,nullptr); #else device=::CreateFileA(filename.text(),access,FILE_SHARE_READ|FILE_SHARE_WRITE,&security,creation,attributes,nullptr); #endif return (device!=BadHandle); } return false; } #else // Open file FXbool FXFile::open(const FXString& filename,FXuint m,FXuint perm){ if(device==BadHandle){ // Basic access mode FXint flags=0; switch(m&(FXIO::ReadOnly|FXIO::WriteOnly)){ case FXIO::ReadOnly: flags=O_RDONLY; break; case FXIO::WriteOnly: flags=O_WRONLY; break; case FXIO::ReadWrite: flags=O_RDWR; break; } // Truncate it if(m&FXIO::Truncate){ flags|=O_TRUNC; } // Change access time #if defined(O_NOATIME) if(m&FXIO::NoAccessTime){ flags|=O_NOATIME; } #endif // Inheritable #if defined(O_CLOEXEC) if(!(m&FXIO::Inheritable)){ flags|=O_CLOEXEC; } #endif // Appending and truncation if(m&FXIO::Append){ flags|=O_APPEND; } // Non-blocking mode if(m&FXIO::NonBlocking){ flags|=O_NONBLOCK; } // Creation mode if(m&FXIO::Create){ flags|=O_CREAT; if(m&FXIO::Exclusive){ flags|=O_EXCL; } } // Permission bits FXint bits=perm&0777; if(perm&FXIO::SetUser){ bits|=S_ISUID; } if(perm&FXIO::SetGroup){ bits|=S_ISGID; } if(perm&FXIO::Sticky){ bits|=S_ISVTX; } // Do it device=::open(filename.text(),flags,bits); return (device!=BadHandle); } return false; } #endif // Return true if serial access only FXbool FXFile::isSerial() const { return false; } // Get position FXlong FXFile::position() const { if(device!=BadHandle){ #if defined(WIN32) LARGE_INTEGER off,pos; off.QuadPart=pos.QuadPart=0; if(SetFilePointerEx(device,off,&pos,FILE_CURRENT)!=0){ return pos.QuadPart; } #else FXlong pos; if((pos=::lseek(device,0,SEEK_CUR))>=0){ return pos; } #endif } return FXIO::Error; } // Move to position FXlong FXFile::position(FXlong offset,FXuint from){ if(device!=BadHandle){ #if defined(WIN32) LARGE_INTEGER off,pos; off.QuadPart=pos.QuadPart=offset; if(SetFilePointerEx(device,off,&pos,from)!=0){ return pos.QuadPart; } #else FXlong pos; if(0<=(pos=::lseek(device,offset,from))){ return pos; } #endif } return FXIO::Error; } // Truncate file FXlong FXFile::truncate(FXlong sz){ if(device!=BadHandle){ #if defined(WIN32) LARGE_INTEGER off,pos; off.QuadPart=pos.QuadPart=sz; if(SetFilePointerEx(device,off,&pos,FILE_BEGIN)!=0){ if(::SetEndOfFile(device)!=0){ return sz; } } #else FXlong pos; if(::ftruncate(device,sz)==0){ if(0<=(pos=::lseek(device,sz,SEEK_SET))){ return pos; } } #endif } return FXIO::Error; } // Flush to disk FXbool FXFile::flush(){ if(device!=BadHandle){ #if defined(WIN32) return ::FlushFileBuffers(device)!=0; #elif defined(_BSD_SOURCE) || defined(_XOPEN_SOURCE) || (_POSIX_C_SOURCE >= 200112L) return ::fsync(device)==0; #endif } return false; } // Test if we're at the end; -1 if error FXint FXFile::eof(){ if(device!=BadHandle){ return !(position() * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXFile.h" #include "FXFileStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXDictionary.h" #include "FXDictionaryOf.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXIcon.h" #include "FXIconCache.h" #include "FXFileAssociations.h" /* Notes: - FXFileAssociations needs additional fields, e.g. a print command. - The associate member function should be virtual so we can overload it. - FXFileAssociations is solely responsible for determining mime-type, and duplicate code in FXDirList and FXFileList is eliminated. - We will use two different techniques: - For directories, we will match "/usr/people/jeroen", then try "/people/jeroen", and finally, try "/jeroen" to determine directory bindings (Note we pass a "/" in front so we won't match a file binding when looking for directories. This means we can in many cases keep the same icon bindings even if some directory tree of a project is moved around in the file system. - For files, we will try to match the whole name, then try the extensions. - We will try to match "defaultdirbinding" to determine directory type, and "defaultfilebinding" for a file, and "defaultexecbinding", for an executable to allow bindings to be set for broad categories. - We should look into using the mime-database and content-based file type detection [I'm not a big fan of this, but it may sometimes be necessary]. - Refer to RFC 2045, 2046, 2047, 2048, and 2077. The Internet media type registry is at: ftp://ftp.iana.org/in-notes/iana/assignments/media-types/ - We should at least organize things so that enough info is passed in so we can read a fragment of the content and do it (so that means the full pathname, and perhaps some flags). - The registry format has been extended; it now is: command string ';' extension string ';' bigicon [ ':' bigiconopen ] ';' miniicon [ ':' miniiconopen ] ';' mimetype [ ';' flags ... ] - An empty binding like: ext="" Can be used to override a global binding with an empty one, i.e. it is as if no binding exists; you will get the default or fallback in this case. - Obtaining icons for files, folders, executable, etc. under Windows: 1) Get icon sizes: w = GetSystemMetrics(SM_CXSMICON); h = GetSystemMetrics(SM_CYSMICON); 2) Default icons for folder: // Get key RegOpenKeyEx(HKEY_CLASSES_ROOT,"folder\\DefaultIcon",0,KEY_READ,&key); // To get data RegQueryValueEx(key,subKey,0,0,(LPBYTE)buf,&bufsz); // Obtain HICON extract it result=ExtractIconEx(filename,iconindex,arrayofbigicons,arrayofsmallicons,nicons); 3) Default icon(s) for file: // Extract from shell32.dll ExtractIconEx("shell32.dll",0,NULL,&smallicon,1); 4) Default exe icon(s): // Extract from shell32.dll ExtractIconExA("shell32.dll",2,NULL,&smallicon,1); 5) Other executables: // Extract from executable: ExtractIconEx("absolutepathofexe",indexoflast,NULL,&smallicon,1); 6) Documents: // Key on ".bmp" (extension with . in front) RegOpenKeyEx(HKEY_CLASSES_ROOT,".bmp",0,KEY_READ,&key); // Obtain value using: RegQueryValueEx(key,subKey,0,0,(LPBYTE)buf,&bufsz); // Key on file type and look for default icon: RegOpenKeyEx(HKEY_CLASSES_ROOT,"PaintPicture\\DefaultIcon",0,KEY_READ,&keyoficon); // Obtain value using: RegQueryValueEx(key,subKey,0,0,(LPBYTE)buf,&bufsz); // String contains program pathname, and icon index. Use: ExtractIconEx("absolutepathofprogram",index,NULL,&smallicon,1); */ #define TOPIC_CONSTRUCT 1000 #define COMMANDLEN 256 #define EXTENSIONLEN 128 #define MIMETYPELEN 64 #define ICONNAMELEN 256 using namespace FX; /*******************************************************************************/ namespace FX { // Object implementation FXIMPLEMENT(FXFileAssociations,FXObject,nullptr,0) // These registry keys are used for default bindings. const FXchar FXFileAssociations::defaultExecBinding[]="defaultexecbinding"; const FXchar FXFileAssociations::defaultDirBinding[]="defaultdirbinding"; const FXchar FXFileAssociations::defaultFileBinding[]="defaultfilebinding"; // Construct for serialization FXFileAssociations::FXFileAssociations():cache(nullptr),settings(nullptr){ } // Construct an file-extension association table FXFileAssociations::FXFileAssociations(FXApp* app):cache(app),settings(&app->reg()){ FXTRACE((TOPIC_CONSTRUCT,"FXFileAssociations::FXFileAssociations\n")); cache.setIconPath(settings->readStringEntry("SETTINGS","iconpath",FXIconCache::defaultIconPath)); } // Construct an file-extension association table, and alternative settings database FXFileAssociations::FXFileAssociations(FXApp* app,FXSettings* sdb):cache(app),settings(sdb){ FXTRACE((TOPIC_CONSTRUCT,"FXFileAssociations::FXFileAssociations\n")); cache.setIconPath(settings->readStringEntry("SETTINGS","iconpath",FXIconCache::defaultIconPath)); } // Parse binding and populate association from it FXFileAssoc* FXFileAssociations::parse(const FXString& assoc){ FXTRACE((200,"FXFileAssociations::parse(\"%s\")\n",assoc.text())); if(!assoc.empty()){ FXFileAssoc* result=new FXFileAssoc; if(result){ FXString mininameopen; FXString bignameopen; FXString mininame; FXString bigname; FXString string; FXuint flags=0; // Parse command result->command=assoc.section(';',0); // Parse description result->extension=assoc.section(';',1); // Big icon closed and open string=assoc.section(';',2); bigname=string.section(':',0); bignameopen=string.section(':',1); // Small icon closed and open string=assoc.section(';',3); mininame=string.section(':',0); mininameopen=string.section(':',1); // Initialize icons result->bigicon=nullptr; result->miniicon=nullptr; result->bigiconopen=nullptr; result->miniiconopen=nullptr; // Insert icons into icon dictionary if(!bigname.empty()){ result->bigicon=result->bigiconopen=cache.insert(bigname); } if(!mininame.empty()){ result->miniicon=result->miniiconopen=cache.insert(mininame); } // Add open icons also; we will fall back on the regular icons in needed if(!bignameopen.empty()){ result->bigiconopen=cache.insert(bignameopen); } if(!mininameopen.empty()){ result->miniiconopen=cache.insert(mininameopen); } // Parse mime type result->mimetype=assoc.section(';',4); // Drag type will be set later result->dragtype=0; // Parse flags string=assoc.section(';',5); if(string.contains("c")) flags|=1; if(string.contains("t")) flags|=2; result->flags=flags; FXTRACE((300,"FXFileAssociations::parse: command=\"%s\" extension=\"%s\" mimetype=\"%s\" big=\"%s\" bigopen=\"%s\" mini=\"%s\" miniopen=\"%s\" flags=%d\n",result->command.text(),result->extension.text(),result->mimetype.text(),bigname.text(),bignameopen.text(),mininame.text(),mininameopen.text(),flags)); // Return it return result; } } return nullptr; } // Fetch file association FXFileAssoc* FXFileAssociations::fetch(const FXString& ext){ FXTRACE((200,"FXFileAssociations::fetch(\"%s\")\n",ext.text())); FXFileAssoc* result=bindings[ext]; if(!result){ result=parse(getSettings()->readStringEntry("FILETYPES",ext,nullptr)); if(result){ bindings[ext]=result; } } return result; } // Find file association from registry FXFileAssoc* FXFileAssociations::findFileBinding(const FXString& pathname){ FXTRACE((200,"FXFileAssociations::findFileBinding(\"%s\")\n",pathname.text())); const FXchar* filename=pathname.text(); FXFileAssoc* record; for(const FXchar* p=filename; *p; ++p){ if(ISPATHSEP(*p)) filename=p+1; } while(*filename!='\0'){ if((record=fetch(filename))!=nullptr) return record; filename=strchr(filename,'.'); if(!filename) break; filename++; } return fetch(defaultFileBinding); } // Find directory association from registry FXFileAssoc* FXFileAssociations::findDirBinding(const FXString& pathname){ FXTRACE((200,"FXFileAssociations::findDirBinding(\"%s\")\n",pathname.text())); const FXchar* path=pathname.text(); FXFileAssoc* record; while(*path){ if((record=fetch(path))!=nullptr) return record; while(ISPATHSEP(*path)) path++; // Skip path seperators while(*path && !ISPATHSEP(*path)) path++; // Skip directory name } return fetch(defaultDirBinding); } // Find executable association from registry FXFileAssoc* FXFileAssociations::findExecBinding(const FXString& pathname){ FXTRACE((200,"FXFileAssociations::findExecBinding(\"%s\")\n",pathname.text())); return fetch(defaultExecBinding); } // Delete all icons void FXFileAssociations::clear(){ for(FXival i=0; i * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXPath.h" #include "FXIO.h" #include "FXStat.h" #include "FXFile.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXRecentFiles.h" #include "FXFrame.h" #include "FXLabel.h" #include "FXButton.h" #include "FXComposite.h" #include "FXPacker.h" #include "FXShell.h" #include "FXTopWindow.h" #include "FXDialogBox.h" #include "FXFileSelector.h" #include "FXFileDialog.h" /* Notes: - Wraps the FXFileSelector file selection mega widget. */ using namespace FX; /*******************************************************************************/ namespace FX { // File dialog registry section name const FXchar FXFileDialog::sectionName[]="File Dialog"; // Object implementation FXIMPLEMENT(FXFileDialog,FXDialogBox,nullptr,0) // Construct file fialog box FXFileDialog::FXFileDialog(FXWindow* own,const FXString& name,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXDialogBox(own,name,opts|DECOR_TITLE|DECOR_BORDER|DECOR_RESIZE|DECOR_CLOSE,x,y,w,h,4,4,4,4,4,4){ filebox=new FXFileSelector(this,nullptr,0,LAYOUT_FILL_X|LAYOUT_FILL_Y); filebox->acceptButton()->setTarget(this); filebox->acceptButton()->setSelector(FXDialogBox::ID_ACCEPT); filebox->cancelButton()->setTarget(this); filebox->cancelButton()->setSelector(FXDialogBox::ID_CANCEL); } // Construct free-floating file dialog box FXFileDialog::FXFileDialog(FXApp* a,const FXString& name,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXDialogBox(a,name,opts|DECOR_TITLE|DECOR_BORDER|DECOR_RESIZE|DECOR_CLOSE,x,y,w,h,4,4,4,4,4,4){ filebox=new FXFileSelector(this,nullptr,0,LAYOUT_FILL_X|LAYOUT_FILL_Y); filebox->acceptButton()->setTarget(this); filebox->acceptButton()->setSelector(FXDialogBox::ID_ACCEPT); filebox->cancelButton()->setTarget(this); filebox->cancelButton()->setSelector(FXDialogBox::ID_CANCEL); } // Create server-side resources void FXFileDialog::create(){ readRegistry(); FXDialogBox::create(); } // Destroy server-side resources void FXFileDialog::destroy(){ FXDialogBox::destroy(); writeRegistry(); } // Load settings from registry void FXFileDialog::readRegistry(){ setWidth(getApp()->reg().readIntEntry(sectionName,"width",getWidth())); setHeight(getApp()->reg().readIntEntry(sectionName,"height",getHeight())); setFileBoxStyle(getApp()->reg().readUIntEntry(sectionName,"style",getFileBoxStyle())); showHiddenFiles(getApp()->reg().readBoolEntry(sectionName,"showhidden",showHiddenFiles())); } // Save settings to registry void FXFileDialog::writeRegistry(){ getApp()->reg().writeIntEntry(sectionName,"width",getWidth()); getApp()->reg().writeIntEntry(sectionName,"height",getHeight()); getApp()->reg().writeUIntEntry(sectionName,"style",getFileBoxStyle()); getApp()->reg().writeBoolEntry(sectionName,"showhidden",showHiddenFiles()); } // Set file name void FXFileDialog::setFilename(const FXString& path){ filebox->setFilename(path); } // Get filename, if any FXString FXFileDialog::getFilename() const { return filebox->getFilename(); } // Return empty-string terminated list of selected file names, FXString* FXFileDialog::getFilenames() const { return filebox->getFilenames(); } // Set directory void FXFileDialog::setDirectory(const FXString& path){ filebox->setDirectory(path); } // Get directory FXString FXFileDialog::getDirectory() const { return filebox->getDirectory(); } // Set pattern void FXFileDialog::setPattern(const FXString& ptrn){ filebox->setPattern(ptrn); } // Get pattern FXString FXFileDialog::getPattern() const { return filebox->getPattern(); } // Change patterns, each pattern separated by newline void FXFileDialog::setPatternList(const FXString& patterns){ filebox->setPatternList(patterns); } // Return list of patterns FXString FXFileDialog::getPatternList() const { return filebox->getPatternList(); } // Set current file pattern from the list void FXFileDialog::setCurrentPattern(FXint patno){ filebox->setCurrentPattern(patno); } // Return current pattern FXint FXFileDialog::getCurrentPattern() const { return filebox->getCurrentPattern(); } // Change pattern text for pattern number void FXFileDialog::setPatternText(FXint patno,const FXString& text){ filebox->setPatternText(patno,text); } // Get pattern text for given pattern number FXString FXFileDialog::getPatternText(FXint patno) const { return filebox->getPatternText(patno); } // Return number of patterns FXint FXFileDialog::getNumPatterns() const { return filebox->getNumPatterns(); } // Allow pattern entry void FXFileDialog::allowPatternEntry(FXbool flag){ filebox->allowPatternEntry(flag); } // Return true if pattern entry is allowed FXbool FXFileDialog::allowPatternEntry() const { return filebox->allowPatternEntry(); } // Change space for item void FXFileDialog::setItemSpace(FXint s){ filebox->setItemSpace(s); } // Get space for item FXint FXFileDialog::getItemSpace() const { return filebox->getItemSpace(); } // Change File List style void FXFileDialog::setFileBoxStyle(FXuint style){ filebox->setFileBoxStyle(style); } // Return File List style FXuint FXFileDialog::getFileBoxStyle() const { return filebox->getFileBoxStyle(); } // Change file selection mode void FXFileDialog::setSelectMode(FXuint mode){ filebox->setSelectMode(mode); } // Return file selection mode FXuint FXFileDialog::getSelectMode() const { return filebox->getSelectMode(); } // Change wildcard matching mode void FXFileDialog::setMatchMode(FXuint mode){ filebox->setMatchMode(mode); } // Return wildcard matching mode FXuint FXFileDialog::getMatchMode() const { return filebox->getMatchMode(); } // Return true if showing hidden files FXbool FXFileDialog::showHiddenFiles() const { return filebox->showHiddenFiles(); } // Show or hide hidden files void FXFileDialog::showHiddenFiles(FXbool flag){ filebox->showHiddenFiles(flag); } // Return true if image preview on FXbool FXFileDialog::showImages() const { return filebox->showImages(); } // Show or hide preview images void FXFileDialog::showImages(FXbool flag){ filebox->showImages(flag); } // Return images preview size FXint FXFileDialog::getImageSize() const { return filebox->getImageSize(); } // Change images preview size void FXFileDialog::setImageSize(FXint size){ filebox->setImageSize(size); } // Show readonly button void FXFileDialog::showReadOnly(FXbool flag){ filebox->showReadOnly(flag); } // Return true if readonly is shown FXbool FXFileDialog::shownReadOnly() const { return filebox->shownReadOnly(); } // Set initial state of readonly button void FXFileDialog::setReadOnly(FXbool flag){ filebox->setReadOnly(flag); } // Get readonly state FXbool FXFileDialog::getReadOnly() const { return filebox->getReadOnly(); } // Allow or disallow navigation void FXFileDialog::allowNavigation(FXbool flag){ filebox->allowNavigation(flag); } // Is navigation allowed? FXbool FXFileDialog::allowNavigation() const{ return filebox->allowNavigation(); } // Set draggable files void FXFileDialog::setDraggableFiles(FXbool flag){ filebox->setDraggableFiles(flag); } // Are files draggable? FXbool FXFileDialog::getDraggableFiles() const { return filebox->getDraggableFiles(); } // Set file time format void FXFileDialog::setTimeFormat(const FXString& fmt){ filebox->setTimeFormat(fmt); } // Return file time format FXString FXFileDialog::getTimeFormat() const { return filebox->getTimeFormat(); } // Change file associations void FXFileDialog::setAssociations(FXFileAssociations* assoc,FXbool owned){ filebox->setAssociations(assoc,owned); } // Return file associations FXFileAssociations* FXFileDialog::getAssociations() const { return filebox->getAssociations(); } // Change icon loader void FXFileDialog::setIconSource(FXIconSource* src){ filebox->setIconSource(src); } // Return icon loader FXIconSource* FXFileDialog::getIconSource() const { return filebox->getIconSource(); } // Save data void FXFileDialog::save(FXStream& store) const { FXDialogBox::save(store); store << filebox; } // Load data void FXFileDialog::load(FXStream& store){ FXDialogBox::load(store); store >> filebox; } // Cleanup FXFileDialog::~FXFileDialog(){ destroy(); filebox=(FXFileSelector*)-1L; } // Open existing filename FXString FXFileDialog::getOpenFilename(FXWindow* owner,const FXString& caption,const FXString& path,const FXString& patterns,FXint initial){ FXFileDialog opendialog(owner,caption); FXString filename; opendialog.setSelectMode(SELECTFILE_EXISTING); opendialog.setPatternList(patterns); opendialog.setFilename(path); opendialog.setCurrentPattern(initial); if(opendialog.execute()){ filename=opendialog.getFilename(); if(FXStat::isFile(filename)) return filename; } return FXString::null; } // Save to filename FXString FXFileDialog::getSaveFilename(FXWindow* owner,const FXString& caption,const FXString& path,const FXString& patterns,FXint initial){ FXFileDialog savedialog(owner,caption); savedialog.setSelectMode(SELECTFILE_ANY); savedialog.setPatternList(patterns); savedialog.setFilename(path); savedialog.setCurrentPattern(initial); if(savedialog.execute()){ return savedialog.getFilename(); } return FXString::null; } // Open multiple existing files FXString* FXFileDialog::getOpenFilenames(FXWindow* owner,const FXString& caption,const FXString& path,const FXString& patterns,FXint initial){ FXFileDialog opendialog(owner,caption); opendialog.setSelectMode(SELECTFILE_MULTIPLE); opendialog.setPatternList(patterns); opendialog.setFilename(path); opendialog.setCurrentPattern(initial); if(opendialog.execute()){ return opendialog.getFilenames(); } return nullptr; } // Open existing directory name FXString FXFileDialog::getOpenDirectory(FXWindow* owner,const FXString& caption,const FXString& path){ FXFileDialog dirdialog(owner,caption); FXString dirname; dirdialog.setSelectMode(SELECTFILE_DIRECTORY); dirdialog.setFilename(path); if(dirdialog.execute()){ dirname=dirdialog.getFilename(); if(FXStat::isDirectory(dirname)) return dirname; } return FXString::null; } } gogglesmm-gogglesmm-0b8cb53/cfox/lib/FXFileList.cpp000066400000000000000000001730461455751074500222740ustar00rootroot00000000000000/******************************************************************************** * * * F i l e L i s t O b j e c t * * * ********************************************************************************* * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. * ********************************************************************************* * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see * ********************************************************************************/ #include "xincs.h" #include "fxver.h" #include "fxdefs.h" #include "fxmath.h" #include "fxkeys.h" #include "fxascii.h" #include "fxunicode.h" #include "FXArray.h" #include "FXHash.h" #include "FXMutex.h" #include "FXStream.h" #include "FXObjectList.h" #include "FXString.h" #include "FXSize.h" #include "FXPoint.h" #include "FXRectangle.h" #include "FXSystem.h" #include "FXPath.h" #include "FXIO.h" #include "FXStat.h" #include "FXFile.h" #include "FXDir.h" #include "FXURL.h" #include "FXStringDictionary.h" #include "FXSettings.h" #include "FXRegistry.h" #include "FXFont.h" #include "FXEvent.h" #include "FXWindow.h" #include "FXApp.h" #include "FXIcon.h" #include "FXGIFIcon.h" #include "FXScrollBar.h" #include "FXIconSource.h" #include "FXShell.h" #include "FXPopup.h" #include "FXMenuPane.h" #include "FXMenuCaption.h" #include "FXMenuCommand.h" #include "FXMenuCascade.h" #include "FXMenuRadio.h" #include "FXMenuCheck.h" #include "FXMenuSeparator.h" #include "FXDictionary.h" #include "FXDictionaryOf.h" #include "FXIconCache.h" #include "FXFileAssociations.h" #include "FXHeader.h" #include "FXIconList.h" #include "FXFileList.h" #include "FXFileProgressDialog.h" #include "FXMessageBox.h" #include "icons.h" /* Notes: - Share icons with other widgets; upgrade icons to some nicer ones. - Should some of these icons move to FXFileAssociations? - Clipboard of filenames. - Clipboard, DND, etc. support. - When being dragged over, if hovering over a directory item for some time we need to open it. - We should generate SEL_INSERTED, SEL_DELETED, SEL_CHANGED messages as the FXFileList updates itself from the file system. - The solution currently used to determine whether or not to blend the icon isn't so great; this class shouldn't have to know about FXPNGIcon. - If you land in a large directory with images, things are a tad slow; need to speed this up some how. */ #define OPENDIRDELAY 700000000 // Delay before opening directory #define REFRESHINTERVAL 1000000000 // Interval between refreshes #define REFRESHCOUNT 30 // Refresh every REFRESHCOUNT-th time using namespace FX; /*******************************************************************************/ namespace FX { // Object implementation FXIMPLEMENT(FXFileItem,FXIconItem,nullptr,0) // Map FXDEFMAP(FXFileList) FXFileListMap[]={ FXMAPFUNC(SEL_DND_ENTER,0,FXFileList::onDNDEnter), FXMAPFUNC(SEL_DND_LEAVE,0,FXFileList::onDNDLeave), FXMAPFUNC(SEL_DND_DROP,0,FXFileList::onDNDDrop), FXMAPFUNC(SEL_DND_MOTION,0,FXFileList::onDNDMotion), FXMAPFUNC(SEL_DND_REQUEST,0,FXFileList::onDNDRequest), FXMAPFUNC(SEL_BEGINDRAG,0,FXFileList::onBeginDrag), FXMAPFUNC(SEL_DRAGGED,0,FXFileList::onDragged), FXMAPFUNC(SEL_ENDDRAG,0,FXFileList::onEndDrag), FXMAPFUNC(SEL_CLIPBOARD_LOST,0,FXFileList::onClipboardLost), FXMAPFUNC(SEL_CLIPBOARD_REQUEST,0,FXFileList::onClipboardRequest), FXMAPFUNC(SEL_CHORE,FXFileList::ID_PREVIEWCHORE,FXFileList::onPreviewChore), FXMAPFUNC(SEL_TIMEOUT,FXFileList::ID_OPENTIMER,FXFileList::onOpenTimer), FXMAPFUNC(SEL_TIMEOUT,FXFileList::ID_REFRESHTIMER,FXFileList::onRefreshTimer), FXMAPFUNC(SEL_UPDATE,FXFileList::ID_DIRECTORY_UP,FXFileList::onUpdDirectoryUp), FXMAPFUNC(SEL_UPDATE,FXFileList::ID_SORT_BY_NAME,FXFileList::onUpdSortByName), FXMAPFUNC(SEL_UPDATE,FXFileList::ID_SORT_BY_TYPE,FXFileList::onUpdSortByType), FXMAPFUNC(SEL_UPDATE,FXFileList::ID_SORT_BY_SIZE,FXFileList::onUpdSortBySize), FXMAPFUNC(SEL_UPDATE,FXFileList::ID_SORT_BY_TIME,FXFileList::onUpdSortByTime), FXMAPFUNC(SEL_UPDATE,FXFileList::ID_SORT_BY_USER,FXFileList::onUpdSortByUser), FXMAPFUNC(SEL_UPDATE,FXFileList::ID_SORT_BY_GROUP,FXFileList::onUpdSortByGroup), FXMAPFUNC(SEL_UPDATE,FXFileList::ID_SORT_REVERSE,FXFileList::onUpdSortReverse), FXMAPFUNC(SEL_UPDATE,FXFileList::ID_SORT_CASE,FXFileList::onUpdSortCase), FXMAPFUNC(SEL_UPDATE,FXFileList::ID_SET_PATTERN,FXFileList::onUpdSetPattern), FXMAPFUNC(SEL_UPDATE,FXFileList::ID_SET_DIRECTORY,FXFileList::onUpdSetDirectory), FXMAPFUNC(SEL_UPDATE,FXFileList::ID_SHOW_HIDDEN,FXFileList::onUpdShowHidden), FXMAPFUNC(SEL_UPDATE,FXFileList::ID_HIDE_HIDDEN,FXFileList::onUpdHideHidden), FXMAPFUNC(SEL_UPDATE,FXFileList::ID_TOGGLE_HIDDEN,FXFileList::onUpdToggleHidden), FXMAPFUNC(SEL_UPDATE,FXFileList::ID_TOGGLE_IMAGES,FXFileList::onUpdToggleImages), FXMAPFUNC(SEL_UPDATE,FXFileList::ID_HEADER,FXFileList::onUpdHeader), FXMAPFUNC(SEL_UPDATE,FXFileList::ID_CUT_SEL,FXFileList::onUpdHaveSel), FXMAPFUNC(SEL_UPDATE,FXFileList::ID_COPY_SEL,FXFileList::onUpdHaveSel), FXMAPFUNC(SEL_UPDATE,FXFileList::ID_DELETE_SEL,FXFileList::onUpdHaveSel), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_HEADER,FXFileList::onCmdHeader), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_DIRECTORY_UP,FXFileList::onCmdDirectoryUp), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_SORT_BY_NAME,FXFileList::onCmdSortByName), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_SORT_BY_TYPE,FXFileList::onCmdSortByType), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_SORT_BY_SIZE,FXFileList::onCmdSortBySize), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_SORT_BY_TIME,FXFileList::onCmdSortByTime), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_SORT_BY_USER,FXFileList::onCmdSortByUser), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_SORT_BY_GROUP,FXFileList::onCmdSortByGroup), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_SORT_REVERSE,FXFileList::onCmdSortReverse), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_SORT_CASE,FXFileList::onCmdSortCase), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_SET_PATTERN,FXFileList::onCmdSetPattern), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_SET_DIRECTORY,FXFileList::onCmdSetDirectory), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_SETVALUE,FXFileList::onCmdSetValue), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_SETSTRINGVALUE,FXFileList::onCmdSetStringValue), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_GETSTRINGVALUE,FXFileList::onCmdGetStringValue), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_SHOW_HIDDEN,FXFileList::onCmdShowHidden), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_HIDE_HIDDEN,FXFileList::onCmdHideHidden), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_TOGGLE_HIDDEN,FXFileList::onCmdToggleHidden), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_TOGGLE_IMAGES,FXFileList::onCmdToggleImages), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_REFRESH,FXFileList::onCmdRefresh), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_CUT_SEL,FXFileList::onCmdCutSel), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_COPY_SEL,FXFileList::onCmdCopySel), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_DELETE_SEL,FXFileList::onCmdDeleteSel), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_PASTE_SEL,FXFileList::onCmdPasteSel), FXMAPFUNC(SEL_CHORE,FXFileList::ID_DROPASK,FXFileList::onCmdDropAsk), FXMAPFUNC(SEL_CHORE,FXFileList::ID_DROPCOPY,FXFileList::onCmdDropCopy), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_DROPCOPY,FXFileList::onCmdDropCopy), FXMAPFUNC(SEL_CHORE,FXFileList::ID_DROPMOVE,FXFileList::onCmdDropMove), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_DROPMOVE,FXFileList::onCmdDropMove), FXMAPFUNC(SEL_CHORE,FXFileList::ID_DROPLINK,FXFileList::onCmdDropLink), FXMAPFUNC(SEL_COMMAND,FXFileList::ID_DROPLINK,FXFileList::onCmdDropLink), }; // Object implementation FXIMPLEMENT(FXFileList,FXIconList,FXFileListMap,ARRAYNUMBER(FXFileListMap)) // For serialization FXFileList::FXFileList(){ dropEnable(); associations=nullptr; iconloader=nullptr; list=nullptr; big_folder=nullptr; mini_folder=nullptr; big_doc=nullptr; mini_doc=nullptr; big_app=nullptr; mini_app=nullptr; #ifdef WIN32 matchmode=FXPath::PathName|FXPath::NoEscape|FXPath::CaseFold; setSortFunc(ascendingCase); #else matchmode=FXPath::PathName|FXPath::NoEscape; setSortFunc(ascending); #endif dropaction=DRAG_COPY; matchmode=0; imagesize=32; timestamp=0; counter=0; clipcut=false; draggable=true; } // File List FXFileList::FXFileList(FXComposite *p,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h):FXIconList(p,tgt,sel,opts,x,y,w,h),directory(PATHSEPSTRING),pattern("*"){ dropEnable(); appendHeader(tr("Name\tName"),nullptr,200); appendHeader(tr("Type\tFile type"),nullptr,100); appendHeader(tr("Size\tFile size"),nullptr,60); appendHeader(tr("Modified Date\tDate when last modified"),nullptr,150); appendHeader(tr("User\tUser name"),nullptr,50); appendHeader(tr("Group\tGroup name"),nullptr,50); appendHeader(tr("Attributes\tFile attributes"),nullptr,100); #ifndef WIN32 appendHeader(tr("Link\tSymbolic link to"),nullptr,200); #endif associations=nullptr; if(!(options&FILELIST_NO_OWN_ASSOC)) associations=new FXFileAssociations(getApp()); iconloader=&FXIconSource::defaultIconSource; list=nullptr; big_folder=new FXGIFIcon(getApp(),bigfolder); mini_folder=new FXGIFIcon(getApp(),minifolder); big_doc=new FXGIFIcon(getApp(),bigdoc); mini_doc=new FXGIFIcon(getApp(),minidoc); big_app=new FXGIFIcon(getApp(),bigapp); mini_app=new FXGIFIcon(getApp(),miniapp); timeformat=tr(FXSystem::defaultTimeFormat); dropaction=DRAG_COPY; #ifdef WIN32 matchmode=FXPath::PathName|FXPath::NoEscape|FXPath::CaseFold; setSortFunc(ascendingCase); #else matchmode=FXPath::PathName|FXPath::NoEscape; setSortFunc(ascending); #endif imagesize=32; timestamp=0; counter=0; clipcut=false; draggable=true; } // Starts the timer void FXFileList::create(){ FXIconList::create(); getApp()->addTimeout(this,ID_REFRESHTIMER,REFRESHINTERVAL); big_folder->create(); mini_folder->create(); big_doc->create(); mini_doc->create(); big_app->create(); mini_app->create(); } // Detach disconnects the icons void FXFileList::detach(){ FXIconList::detach(); getApp()->removeTimeout(this,ID_REFRESHTIMER); getApp()->removeTimeout(this,ID_OPENTIMER); big_folder->detach(); mini_folder->detach(); big_doc->detach(); mini_doc->detach(); big_app->detach(); mini_app->detach(); deleteType=0; urilistType=0; actionType=0; } // Destroy zaps the icons void FXFileList::destroy(){ FXIconList::destroy(); getApp()->removeTimeout(this,ID_REFRESHTIMER); getApp()->removeTimeout(this,ID_OPENTIMER); big_folder->destroy(); mini_folder->destroy(); big_doc->destroy(); mini_doc->destroy(); big_app->destroy(); mini_app->destroy(); } // Create custom item FXIconItem *FXFileList::createItem(const FXString& text,FXIcon *big,FXIcon* mini,void* ptr){ return new FXFileItem(text,big,mini,ptr); } /*******************************************************************************/ // Compare string and string with natural interpretation of decimal numbers FXint FXFileList::compareSectionNatural(const FXchar* s1,const FXchar* s2,FXint s,FXbool ci){ const FXchar *ns1,*ne1,*ns2,*ne2; FXint diff=0,c1=0,c2=0,d; for(d=s; d && *s1; d-=(*s1++=='\t')){} for(d=s; d && *s2; d-=(*s2++=='\t')){} while((c1=(FXuchar)*s1)>=' ' && (c2=(FXuchar)*s2)>=' '){ // Both are numbers: special treatment if(c1<='9' && c2<='9' && '0'<=c1 && '0'<=c2){ // Parse over leading zeroes for(ns1=s1; *ns1=='0'; ++ns1){ } for(ns2=s2; *ns2=='0'; ++ns2){ } // Use number of leading zeroes as tie-breaker if(diff==0){ diff=(ns1-s1)-(ns2-s2); } // Parse over numbers for(ne1=ns1; '0'<=*ne1 && *ne1<='9'; ++ne1){ } for(ne2=ns2; '0'<=*ne2 && *ne2<='9'; ++ne2){ } // Check length difference of the numbers if((d=(ne1-ns1)-(ne2-ns2))!=0){ return d; } // Compare the numbers while(ns1(b)->isDirectory() - static_cast(a)->isDirectory(); if(diff==0){ diff=compareSectionNatural(a->label.text(),b->label.text(),0,false); } return diff; } // Reversed compare file name FXint FXFileList::descending(const FXIconItem* a,const FXIconItem* b){ FXint diff=static_cast(b)->isDirectory() - static_cast(a)->isDirectory(); if(diff==0){ diff=compareSectionNatural(b->label.text(),a->label.text(),0,false); } return diff; } // Compare file names, case insensitive FXint FXFileList::ascendingCase(const FXIconItem* a,const FXIconItem* b){ FXint diff=static_cast(b)->isDirectory() - static_cast(a)->isDirectory(); if(diff==0){ diff=compareSectionNatural(a->label.text(),b->label.text(),0,true); } return diff; } // Reversed compare file name, case insensitive FXint FXFileList::descendingCase(const FXIconItem* a,const FXIconItem* b){ FXint diff=static_cast(b)->isDirectory() - static_cast(a)->isDirectory(); if(diff==0){ diff=compareSectionNatural(b->label.text(),a->label.text(),0,true); } return diff; } // Compare file types FXint FXFileList::ascendingType(const FXIconItem* a,const FXIconItem* b){ FXint diff=static_cast(b)->isDirectory() - static_cast(a)->isDirectory(); if(diff==0){ diff=compareSection(a->label.text(),b->label.text(),1); if(diff==0){ diff=compareSection(a->label.text(),b->label.text(),0); } } return diff; } // Reversed compare file type FXint FXFileList::descendingType(const FXIconItem* a,const FXIconItem* b){ FXint diff=static_cast(b)->isDirectory() - static_cast(a)->isDirectory(); if(diff==0){ diff=compareSection(b->label.text(),a->label.text(),1); if(diff==0){ diff=compareSection(b->label.text(),a->label.text(),0); } } return diff; } // Compare file size FXint FXFileList::ascendingSize(const FXIconItem* a,const FXIconItem* b){ FXint diff=static_cast(b)->isDirectory() - static_cast(a)->isDirectory(); if(diff==0){ diff=FXSGNZ(static_cast(a)->size - static_cast(b)->size); if(diff==0){ diff=compareSection(a->label.text(),b->label.text(),0); } } return diff; } // Reversed compare file size FXint FXFileList::descendingSize(const FXIconItem* a,const FXIconItem* b){ FXint diff=static_cast(b)->isDirectory() - static_cast(a)->isDirectory(); if(diff==0){ diff=FXSGNZ(static_cast(b)->size - static_cast(a)->size); if(diff==0){ diff=compareSection(b->label.text(),a->label.text(),0); } } return diff; } // Compare file time FXint FXFileList::ascendingTime(const FXIconItem* a,const FXIconItem* b){ FXint diff=(FXint)((const FXFileItem*)b)->isDirectory() - (FXint)((const FXFileItem*)a)->isDirectory(); if(diff==0){ diff=FXSGNZ(static_cast(a)->date - static_cast(b)->date); if(diff==0){ diff=compareSection(a->label.text(),b->label.text(),0); } } return diff; } // Reversed compare file time FXint FXFileList::descendingTime(const FXIconItem* a,const FXIconItem* b){ FXint diff=(FXint)((const FXFileItem*)b)->isDirectory() - (FXint)((const FXFileItem*)a)->isDirectory(); if(diff==0){ diff=FXSGNZ(static_cast(b)->date - static_cast(a)->date); if(diff==0){ diff=compareSection(b->label.text(),a->label.text(),0); } } return diff; } // Compare file user FXint FXFileList::ascendingUser(const FXIconItem* a,const FXIconItem* b){ FXint diff=static_cast(b)->isDirectory() - static_cast(a)->isDirectory(); if(diff==0){ diff=compareSection(a->label.text(),b->label.text(),4); if(diff==0){ diff=compareSection(a->label.text(),b->label.text(),0); } } return diff; } // Reversed compare file user FXint FXFileList::descendingUser(const FXIconItem* a,const FXIconItem* b){ FXint diff=static_cast(b)->isDirectory() - static_cast(a)->isDirectory(); if(diff==0){ diff=compareSection(b->label.text(),a->label.text(),4); if(diff==0){ diff=compareSection(b->label.text(),a->label.text(),0); } } return diff; } // Compare file group FXint FXFileList::ascendingGroup(const FXIconItem* a,const FXIconItem* b){ FXint diff=static_cast(b)->isDirectory() - static_cast(a)->isDirectory(); if(diff==0){ diff=compareSection(a->label.text(),b->label.text(),5); if(diff==0){ diff=compareSection(a->label.text(),b->label.text(),0); } } return diff; } // Reversed compare file group FXint FXFileList::descendingGroup(const FXIconItem* a,const FXIconItem* b){ FXint diff=static_cast(b)->isDirectory() - static_cast(a)->isDirectory(); if(diff==0){ diff=compareSection(b->label.text(),a->label.text(),5); if(diff==0){ diff=compareSection(b->label.text(),a->label.text(),0); } } return diff; } /*******************************************************************************/ // Select files matching wildcard pattern FXbool FXFileList::selectMatching(const FXString& ptrn,FXuint mode,FXbool notify){ FXbool changes=false; for(FXint i=0; ihandle(this,FXSEL(SEL_COMMAND,ID_ENABLE),nullptr); return 1; } } sender->handle(this,FXSEL(SEL_COMMAND,ID_DISABLE),nullptr); return 1; } /*******************************************************************************/ // Delete selection long FXFileList::onCmdDeleteSel(FXObject*,FXSelector,void*){ FXString delfiles=getSelectedFiles(); delete_files(delfiles); // FIXME confirmation would be nice return 1; } // Paste clipboard long FXFileList::onCmdPasteSel(FXObject*,FXSelector,void*){ FXString files,action; if(getDNDData(FROM_CLIPBOARD,urilistType,files)){ if(getDNDData(FROM_CLIPBOARD,actionType,action)){ FXTRACE((100,"%s::onCmdPasteSel(): Action: %s Files: %s\n",getClassName(),action.text(),files.text())); if(action[0]=='1'){ move_files(directory,files); } else{ // FXint count=files.contains("\r\n"); // FXTRACE((1,"number of files=%d\n",count)); //FXFileProgressDialog fileprogress(this,"Copying Files","Copying 10 files (100MB)",big_folder,DECOR_TITLE|DECOR_BORDER|DECOR_RESIZE,0,0,600,0); //fileprogress.execute(); copy_files(directory,files); } return 1; } } getApp()->beep(); return 1; } // Cut long FXFileList::onCmdCutSel(FXObject*,FXSelector,void*){ FXDragType types[2]={urilistType,actionType}; if(acquireClipboard(types,ARRAYNUMBER(types))){ clipfiles=getSelectedFiles(); clipcut=true; } return 1; } // Copy long FXFileList::onCmdCopySel(FXObject*,FXSelector,void*){ FXDragType types[2]={urilistType,actionType}; if(acquireClipboard(types,ARRAYNUMBER(types))){ clipfiles=getSelectedFiles(); clipcut=false; } return 1; } // We lost the selection somehow long FXFileList::onClipboardLost(FXObject* sender,FXSelector sel,void* ptr){ FXIconList::onClipboardLost(sender,sel,ptr); FXTRACE((100,"deleting clipfiles\n")); clipfiles=FXString::null; clipcut=false; return 1; } // Somebody wants our selection long FXFileList::onClipboardRequest(FXObject* sender,FXSelector sel,void* ptr){ // Try base class first if(FXIconList::onClipboardRequest(sender,sel,ptr)) return 1; // Return list of filenames as a uri-list if(((FXEvent*)ptr)->target==urilistType){ FXTRACE((100,"Returning urilistType\n")); setDNDData(FROM_CLIPBOARD,urilistType,clipfiles); return 1; } // Return type of clipboard action if(((FXEvent*)ptr)->target==actionType){ FXTRACE((100,"Returning actionType\n")); setDNDData(FROM_CLIPBOARD,actionType,clipcut?"1":"0"); return 1; } return 0; } /*******************************************************************************/ // Delete files from the systems void FXFileList::delete_files(const FXString& files){ FXString filename; FXint beg,end; for(beg=0; begflush(); getApp()->runModalWhileEvents(&progress,500000000); getApp()->flush(); for(beg=0; begflush(); getApp()->runModalWhileEvents(&progress,500000000); FXThread::sleep(100000000); // FXFile::copyFiles(filesrc,filedst,false); /* ok=FXFile::copyFiles(filesrc,filedst,(ans==MBOX_CLICKED_YESALL)); if(!ok && (ans!=MBOX_CLICKED_NOALL)){ if(ans!=MBOX_CLICKED_YESALL && ans!=MBOX_CLICKED_NOALL){ ans=FXMessageBox::question(this,MBOX_YES_YESALL_NO_NOALL_CANCEL,tr("Overwrite File"),tr("Overwrite existing file or directory: %s?"),filedst.text()); if(ans==MBOX_CLICKED_CANCEL) break; if((ans==MBOX_CLICKED_YESALL) || (ans==MBOX_CLICKED_YES)){ ok=FXFile::copyFiles(filesrc,filedst,true); } } } */ } #endif /*******************************************************************************/ // Copy files to drop directory long FXFileList::onCmdDropCopy(FXObject*,FXSelector,void*){ copy_files(dropdirectory,dropfiles); dropdirectory=FXString::null; dropfiles=FXString::null; dropaction=DRAG_REJECT; return 1; } // Move files to drop directory long FXFileList::onCmdDropMove(FXObject*,FXSelector,void*){ move_files(dropdirectory,dropfiles); dropdirectory=FXString::null; dropfiles=FXString::null; dropaction=DRAG_REJECT; return 1; } // Link to files from dropdirectory long FXFileList::onCmdDropLink(FXObject*,FXSelector,void*){ FXString filedst,filesrc; FXint beg,end; for(beg=0; begroot_x,((FXEvent*)ptr)->root_y); getApp()->runModalWhileShown(&dropmenu); dropdirectory=FXString::null; dropfiles=FXString::null; dropaction=DRAG_REJECT; return 1; } /*******************************************************************************/ // Change directory when hovering over a folder // Remember current directory prior to change long FXFileList::onOpenTimer(FXObject*,FXSelector,void*){ FXint xx,yy,index; FXuint buttons; getCursorPosition(xx,yy,buttons); index=getItemAt(xx,yy); if(0<=index && isItemDirectory(index)){ if(startdirectory.empty()){ startdirectory=getDirectory(); } dropdirectory=getItemPathname(index); setDirectory(dropdirectory,true); } return 1; } // Handle drag-and-drop enter, remember current directory long FXFileList::onDNDEnter(FXObject* sender,FXSelector sel,void* ptr){ FXIconList::onDNDEnter(sender,sel,ptr); return 1; } // Handle drag-and-drop leave // Restore current directory and scroll position prior drag long FXFileList::onDNDLeave(FXObject* sender,FXSelector sel,void* ptr){ FXIconList::onDNDLeave(sender,sel,ptr); getApp()->removeTimeout(this,ID_OPENTIMER); stopAutoScroll(); if(!startdirectory.empty()){ setDirectory(startdirectory,true); startdirectory=FXString::null; } dropdirectory=FXString::null; dropfiles=FXString::null; dropaction=DRAG_REJECT; return 1; } // Handle drag-and-drop motion long FXFileList::onDNDMotion(FXObject* sender,FXSelector sel,void* ptr){ FXEvent *event=(FXEvent*)ptr; FXint index=-1; // Cancel open up timer getApp()->removeTimeout(this,ID_OPENTIMER); // Start autoscrolling if(startAutoScroll(event,false)) return 1; // Give base class a shot if(FXIconList::onDNDMotion(sender,sel,ptr)) return 1; // Dropping list of filenames if(offeredDNDType(FROM_DRAGNDROP,urilistType)){ // Drop in the background dropdirectory=getDirectory(); // Drop action to be performed dropaction=inquireDNDAction(); // We will open up a folder if we can hover over it for a while index=getItemAt(event->win_x,event->win_y); if(0<=index && isItemDirectory(index)){ // Start open up timer when hovering over item getApp()->addTimeout(this,ID_OPENTIMER,OPENDIRDELAY); // Directory where to drop, or directory to open up dropdirectory=getItemPathname(index); } // See if dropdirectory is writable if(FXStat::isAccessible(dropdirectory,FXIO::ReadOnly|FXIO::WriteOnly)){ acceptDrop(DRAG_ACCEPT); } return 1; } return 0; } // Handle drag-and-drop drop long FXFileList::onDNDDrop(FXObject* sender,FXSelector sel,void* ptr){ // Cancel open up timer getApp()->removeTimeout(this,ID_OPENTIMER); // Stop scrolling stopAutoScroll(); // Restore start directory and scroll position if(!startdirectory.empty()){ setDirectory(startdirectory,true); startdirectory=FXString::null; } // Perhaps target wants to deal with it if(FXIconList::onDNDDrop(sender,sel,ptr)) return 1; // Get list of files as uri-list if(getDNDData(FROM_DRAGNDROP,urilistType,dropfiles)){ if(!dropfiles.empty()){ switch(dropaction){ case DRAG_COPY: getApp()->addChore(this,ID_DROPCOPY,ptr); break; case DRAG_MOVE: getApp()->addChore(this,ID_DROPMOVE,ptr); break; case DRAG_LINK: getApp()->addChore(this,ID_DROPLINK,ptr); break; default: getApp()->addChore(this,ID_DROPASK,ptr); break; } return 1; } } return 0; } // Somebody wants our dragged data long FXFileList::onDNDRequest(FXObject* sender,FXSelector sel,void* ptr){ // Perhaps the target wants to supply its own data if(FXIconList::onDNDRequest(sender,sel,ptr)) return 1; // Return list of filenames as a uri-list if(((FXEvent*)ptr)->target==urilistType){ setDNDData(FROM_DRAGNDROP,urilistType,dragfiles); return 1; } // Delete selected files if(((FXEvent*)ptr)->target==deleteType){ FXTRACE((100,"Delete files not yet implemented\n")); return 1; } return 0; } // Start a drag operation long FXFileList::onBeginDrag(FXObject* sender,FXSelector sel,void* ptr){ if(!FXIconList::onBeginDrag(sender,sel,ptr)){ beginDrag(&urilistType,1); dragfiles=getSelectedFiles(); } return 1; } // Dragged stuff around long FXFileList::onDragged(FXObject* sender,FXSelector sel,void* ptr){ FXEvent* event=(FXEvent*)ptr; if(!FXIconList::onDragged(sender,sel,ptr)){ FXDragAction action=DRAG_ASK; if(event->state&CONTROLMASK) action=DRAG_COPY; if(event->state&SHIFTMASK) action=DRAG_MOVE; if(event->state&ALTMASK) action=DRAG_LINK; handleDrag(event->root_x,event->root_y,action); action=didAccept(); switch(action){ case DRAG_COPY: setDragCursor(getApp()->getDefaultCursor(DEF_DNDCOPY_CURSOR)); break; case DRAG_MOVE: setDragCursor(getApp()->getDefaultCursor(DEF_DNDMOVE_CURSOR)); break; case DRAG_LINK: setDragCursor(getApp()->getDefaultCursor(DEF_DNDLINK_CURSOR)); break; case DRAG_ASK: setDragCursor(getApp()->getDefaultCursor(DEF_DNDASK_CURSOR)); break; default: setDragCursor(getApp()->getDefaultCursor(DEF_DNDSTOP_CURSOR)); break; } } return 1; } // End drag operation long FXFileList::onEndDrag(FXObject* sender,FXSelector sel,void* ptr){ if(!FXIconList::onEndDrag(sender,sel,ptr)){ endDrag((didAccept()!=DRAG_REJECT)); setDragCursor(getDefaultCursor()); dragfiles=FXString::null; } return 1; } /*******************************************************************************/ // Cycle through items that represent images long FXFileList::onPreviewChore(FXObject*,FXSelector,void* ptr){ FXint index=(FXint)(FXival)ptr; if(showImages() && iconloader && indexloadScaledIconFile(getApp(),getItemPathname(index),imagesize); if(icon){ icon->create(); setItemBigIcon(index,icon,true); setItemMiniIcon(index,icon,false); } if(++indexaddChore(this,ID_PREVIEWCHORE,(void*)(FXival)index); } } return 1; } /*******************************************************************************/ // Set value from a message long FXFileList::onCmdSetValue(FXObject*,FXSelector,void* ptr){ setCurrentFile((const FXchar*)ptr,true); return 1; } // Set current directory from dir part of filename long FXFileList::onCmdSetStringValue(FXObject*,FXSelector,void* ptr){ setCurrentFile(*((FXString*)ptr),true); return 1; } // Get current file name (NULL if no current file) long FXFileList::onCmdGetStringValue(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getCurrentFile(); return 1; } // Toggle hidden files display long FXFileList::onCmdToggleHidden(FXObject*,FXSelector,void*){ showHiddenFiles(!showHiddenFiles(),true); return 1; } // Update toggle hidden files widget long FXFileList::onUpdToggleHidden(FXObject* sender,FXSelector,void*){ sender->handle(this,showHiddenFiles()?FXSEL(SEL_COMMAND,ID_CHECK):FXSEL(SEL_COMMAND,ID_UNCHECK),nullptr); return 1; } // Show hidden files long FXFileList::onCmdShowHidden(FXObject*,FXSelector,void*){ showHiddenFiles(true,true); return 1; } // Update show hidden files widget long FXFileList::onUpdShowHidden(FXObject* sender,FXSelector,void*){ sender->handle(this,showHiddenFiles()?FXSEL(SEL_COMMAND,ID_CHECK):FXSEL(SEL_COMMAND,ID_UNCHECK),nullptr); return 1; } // Hide hidden files long FXFileList::onCmdHideHidden(FXObject*,FXSelector,void*){ showHiddenFiles(false,true); return 1; } // Update hide hidden files widget long FXFileList::onUpdHideHidden(FXObject* sender,FXSelector,void*){ sender->handle(this,showHiddenFiles()?FXSEL(SEL_COMMAND,ID_UNCHECK):FXSEL(SEL_COMMAND,ID_CHECK),nullptr); return 1; } // Toggle image preview long FXFileList::onCmdToggleImages(FXObject*,FXSelector,void*){ showImages(!showImages(),true); return 1; } // Update image preview long FXFileList::onUpdToggleImages(FXObject* sender,FXSelector,void*){ sender->handle(this,showImages()?FXSEL(SEL_COMMAND,ID_CHECK):FXSEL(SEL_COMMAND,ID_UNCHECK),nullptr); return 1; } // Move up one level long FXFileList::onCmdDirectoryUp(FXObject*,FXSelector,void*){ setDirectory(FXPath::upLevel(directory),true); return 1; } // Determine if we can still go up more long FXFileList::onUpdDirectoryUp(FXObject* sender,FXSelector,void*){ sender->handle(this,FXPath::isTopDirectory(directory)?FXSEL(SEL_COMMAND,ID_DISABLE):FXSEL(SEL_COMMAND,ID_ENABLE),nullptr); return 1; } // Change pattern long FXFileList::onCmdSetPattern(FXObject*,FXSelector,void* ptr){ setPattern((const char*)ptr,true); return 1; } // Update pattern long FXFileList::onUpdSetPattern(FXObject* sender,FXSelector,void*){ sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_SETVALUE),(void*)pattern.text()); return 1; } // Change directory long FXFileList::onCmdSetDirectory(FXObject*,FXSelector,void* ptr){ setDirectory((const char*)ptr,true); return 1; } // Update directory long FXFileList::onUpdSetDirectory(FXObject* sender,FXSelector,void*){ sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_SETVALUE),(void*)directory.text()); return 1; } // Sort by name long FXFileList::onCmdSortByName(FXObject*,FXSelector,void*){ #ifdef WIN32 if(getSortFunc()==ascending) setSortFunc(descending); else if(getSortFunc()==ascendingCase) setSortFunc(descendingCase); else if(getSortFunc()==descending) setSortFunc(ascending); else setSortFunc(ascendingCase); #else if(getSortFunc()==ascending) setSortFunc(descending); else if(getSortFunc()==ascendingCase) setSortFunc(descendingCase); else if(getSortFunc()==descending) setSortFunc(ascending); else setSortFunc(ascending); #endif sortItems(); return 1; } // Update sender long FXFileList::onUpdSortByName(FXObject* sender,FXSelector,void*){ sender->handle(this,(getSortFunc()==ascending || getSortFunc()==descending || getSortFunc()==ascendingCase || getSortFunc()==descendingCase) ? FXSEL(SEL_COMMAND,ID_CHECK) : FXSEL(SEL_COMMAND,ID_UNCHECK),nullptr); return 1; } // Sort by type long FXFileList::onCmdSortByType(FXObject*,FXSelector,void*){ setSortFunc((getSortFunc()==ascendingType) ? descendingType : ascendingType); sortItems(); return 1; } // Update sender long FXFileList::onUpdSortByType(FXObject* sender,FXSelector,void*){ sender->handle(this,(getSortFunc()==ascendingType || getSortFunc()==descendingType) ? FXSEL(SEL_COMMAND,ID_CHECK) : FXSEL(SEL_COMMAND,ID_UNCHECK),nullptr); return 1; } // Sort by size long FXFileList::onCmdSortBySize(FXObject*,FXSelector,void*){ setSortFunc((getSortFunc()==ascendingSize) ? descendingSize : ascendingSize); sortItems(); return 1; } // Update sender long FXFileList::onUpdSortBySize(FXObject* sender,FXSelector,void*){ sender->handle(this,(getSortFunc()==ascendingSize || getSortFunc()==descendingSize) ? FXSEL(SEL_COMMAND,ID_CHECK) : FXSEL(SEL_COMMAND,ID_UNCHECK),nullptr); return 1; } // Sort by time long FXFileList::onCmdSortByTime(FXObject*,FXSelector,void*){ setSortFunc((getSortFunc()==ascendingTime) ? descendingTime : ascendingTime); sortItems(); return 1; } // Update sender long FXFileList::onUpdSortByTime(FXObject* sender,FXSelector,void*){ sender->handle(this,(getSortFunc()==ascendingTime || getSortFunc()==descendingTime) ? FXSEL(SEL_COMMAND,ID_CHECK) : FXSEL(SEL_COMMAND,ID_UNCHECK),nullptr); return 1; } // Sort by user long FXFileList::onCmdSortByUser(FXObject*,FXSelector,void*){ setSortFunc((getSortFunc()==ascendingUser) ? descendingUser : ascendingUser); sortItems(); return 1; } // Update sender long FXFileList::onUpdSortByUser(FXObject* sender,FXSelector,void*){ sender->handle(this,(getSortFunc()==ascendingUser || getSortFunc()==descendingUser) ? FXSEL(SEL_COMMAND,ID_CHECK) : FXSEL(SEL_COMMAND,ID_UNCHECK),nullptr); return 1; } // Sort by group long FXFileList::onCmdSortByGroup(FXObject*,FXSelector,void*){ setSortFunc((getSortFunc()==ascendingGroup) ? descendingGroup : ascendingGroup); sortItems(); return 1; } // Update sender long FXFileList::onUpdSortByGroup(FXObject* sender,FXSelector,void*){ sender->handle(this,(getSortFunc()==ascendingGroup || getSortFunc()==descendingGroup) ? FXSEL(SEL_COMMAND,ID_CHECK) : FXSEL(SEL_COMMAND,ID_UNCHECK),nullptr); return 1; } // Reverse sort order long FXFileList::onCmdSortReverse(FXObject*,FXSelector,void*){ if(getSortFunc()==ascending) setSortFunc(descending); else if(getSortFunc()==descending) setSortFunc(ascending); else if(getSortFunc()==ascendingCase) setSortFunc(descendingCase); else if(getSortFunc()==descendingCase) setSortFunc(ascendingCase); else if(getSortFunc()==ascendingType) setSortFunc(descendingType); else if(getSortFunc()==descendingType) setSortFunc(ascendingType); else if(getSortFunc()==ascendingSize) setSortFunc(descendingSize); else if(getSortFunc()==descendingSize) setSortFunc(ascendingSize); else if(getSortFunc()==ascendingTime) setSortFunc(descendingTime); else if(getSortFunc()==descendingTime) setSortFunc(ascendingTime); else if(getSortFunc()==ascendingUser) setSortFunc(descendingUser); else if(getSortFunc()==descendingUser) setSortFunc(ascendingUser); else if(getSortFunc()==ascendingGroup) setSortFunc(descendingGroup); else if(getSortFunc()==descendingGroup) setSortFunc(ascendingGroup); sortItems(); return 1; } // Update sender long FXFileList::onUpdSortReverse(FXObject* sender,FXSelector,void*){ FXSelector selector=FXSEL(SEL_COMMAND,ID_UNCHECK); if(getSortFunc()==descending) selector=FXSEL(SEL_COMMAND,ID_CHECK); else if(getSortFunc()==descendingCase) selector=FXSEL(SEL_COMMAND,ID_CHECK); else if(getSortFunc()==descendingType) selector=FXSEL(SEL_COMMAND,ID_CHECK); else if(getSortFunc()==descendingSize) selector=FXSEL(SEL_COMMAND,ID_CHECK); else if(getSortFunc()==descendingTime) selector=FXSEL(SEL_COMMAND,ID_CHECK); else if(getSortFunc()==descendingUser) selector=FXSEL(SEL_COMMAND,ID_CHECK); else if(getSortFunc()==descendingGroup) selector=FXSEL(SEL_COMMAND,ID_CHECK); sender->handle(this,selector,nullptr); return 1; } // Toggle case sensitivity long FXFileList::onCmdSortCase(FXObject*,FXSelector,void*){ if(getSortFunc()==ascending) setSortFunc(ascendingCase); else if(getSortFunc()==ascendingCase) setSortFunc(ascending); else if(getSortFunc()==descending) setSortFunc(descendingCase); else if(getSortFunc()==descendingCase) setSortFunc(descending); sortItems(); return 1; } // Check if case sensitive long FXFileList::onUpdSortCase(FXObject* sender,FXSelector,void*){ sender->handle(this,(getSortFunc()==ascendingCase || getSortFunc()==descendingCase) ? FXSEL(SEL_COMMAND,ID_CHECK) : FXSEL(SEL_COMMAND,ID_UNCHECK),nullptr); sender->handle(this,(getSortFunc()==ascendingCase || getSortFunc()==ascending || getSortFunc()==descendingCase || getSortFunc()==descending) ? FXSEL(SEL_COMMAND,ID_ENABLE) : FXSEL(SEL_COMMAND,ID_DISABLE),nullptr); return 1; } // Clicked header button long FXFileList::onCmdHeader(FXObject*,FXSelector,void* ptr){ if(((FXuint)(FXuval)ptr)<6) handle(this,FXSEL(SEL_COMMAND,(ID_SORT_BY_NAME+(FXuint)(FXuval)ptr)),nullptr); return 1; } // Clicked header button long FXFileList::onUpdHeader(FXObject*,FXSelector,void*){ header->setArrowDir(0,(getSortFunc()==ascending || getSortFunc()==ascendingCase) ? FXHeaderItem::ARROW_DOWN : (getSortFunc()==descending || getSortFunc()==descendingCase) ? FXHeaderItem::ARROW_UP : FXHeaderItem::ARROW_NONE); // Name header->setArrowDir(1,(getSortFunc()==ascendingType) ? FXHeaderItem::ARROW_DOWN : (getSortFunc()==descendingType) ? FXHeaderItem::ARROW_UP : FXHeaderItem::ARROW_NONE); // Type header->setArrowDir(2,(getSortFunc()==ascendingSize) ? FXHeaderItem::ARROW_DOWN : (getSortFunc()==descendingSize) ? FXHeaderItem::ARROW_UP : FXHeaderItem::ARROW_NONE); // Size header->setArrowDir(3,(getSortFunc()==ascendingTime) ? FXHeaderItem::ARROW_DOWN : (getSortFunc()==descendingTime) ? FXHeaderItem::ARROW_UP : FXHeaderItem::ARROW_NONE); // Date header->setArrowDir(4,(getSortFunc()==ascendingUser) ? FXHeaderItem::ARROW_DOWN : (getSortFunc()==descendingUser) ? FXHeaderItem::ARROW_UP : FXHeaderItem::ARROW_NONE); // User header->setArrowDir(5,(getSortFunc()==ascendingGroup) ? FXHeaderItem::ARROW_DOWN : (getSortFunc()==descendingGroup)? FXHeaderItem::ARROW_UP : FXHeaderItem::ARROW_NONE); // Group return 1; } /*******************************************************************************/ // Periodically check to see if directory was changed, and update the list if it was. long FXFileList::onRefreshTimer(FXObject*,FXSelector,void*){ if(flags&FLAG_UPDATE){ counter+=1; if(!listItems((counter==REFRESHCOUNT),true)){ setDirectory(FXPath::validPath(directory),true); } } getApp()->addTimeout(this,ID_REFRESHTIMER,REFRESHINTERVAL); return 0; } // Force an immediate update of the list long FXFileList::onCmdRefresh(FXObject*,FXSelector,void*){ listItems(true,true); return 1; } // Compare till '\t' or '\0' static FXbool fileequal(const FXchar* p1,const FXchar* p2){ FXint c1,c2; do{ c1=*p1++; c2=*p2++; } while((c1==c2) && ('\t'