├── .gitignore ├── CMake ├── mingw.cmake └── mingw64.cmake ├── CMakeLists.txt ├── Doxyfile.in ├── LICENSE ├── README ├── build ├── font │ ├── LICENSE │ ├── README │ ├── SourceSansPro-It.ttf │ ├── SourceSansPro-Regular.ttf │ ├── SourceSansPro-Semibold.ttf │ └── SourceSansPro-SemiboldIt.ttf ├── runvalgrind.sh ├── valgrind.supp └── win_dep │ ├── FTL.TXT │ ├── GPL.TXT │ ├── LICENSE.TXT │ ├── PATENTS │ ├── README │ ├── include │ ├── freetype │ │ ├── config │ │ │ ├── ftconfig.h │ │ │ ├── ftheader.h │ │ │ ├── ftmodule.h │ │ │ ├── ftoption.h │ │ │ └── ftstdlib.h │ │ ├── freetype.h │ │ ├── ftadvanc.h │ │ ├── ftbbox.h │ │ ├── ftbdf.h │ │ ├── ftbitmap.h │ │ ├── ftbzip2.h │ │ ├── ftcache.h │ │ ├── ftchapters.h │ │ ├── ftcid.h │ │ ├── fterrdef.h │ │ ├── fterrors.h │ │ ├── ftgasp.h │ │ ├── ftglyph.h │ │ ├── ftgxval.h │ │ ├── ftgzip.h │ │ ├── ftimage.h │ │ ├── ftincrem.h │ │ ├── ftlcdfil.h │ │ ├── ftlist.h │ │ ├── ftlzw.h │ │ ├── ftmac.h │ │ ├── ftmm.h │ │ ├── ftmodapi.h │ │ ├── ftmoderr.h │ │ ├── ftotval.h │ │ ├── ftoutln.h │ │ ├── ftpfr.h │ │ ├── ftrender.h │ │ ├── ftsizes.h │ │ ├── ftsnames.h │ │ ├── ftstroke.h │ │ ├── ftsynth.h │ │ ├── ftsystem.h │ │ ├── fttrigon.h │ │ ├── fttypes.h │ │ ├── ftwinfnt.h │ │ ├── ftxf86.h │ │ ├── internal │ │ │ ├── autohint.h │ │ │ ├── ftcalc.h │ │ │ ├── ftdebug.h │ │ │ ├── ftdriver.h │ │ │ ├── ftgloadr.h │ │ │ ├── ftmemory.h │ │ │ ├── ftobjs.h │ │ │ ├── ftpic.h │ │ │ ├── ftrfork.h │ │ │ ├── ftserv.h │ │ │ ├── ftstream.h │ │ │ ├── fttrace.h │ │ │ ├── ftvalid.h │ │ │ ├── internal.h │ │ │ ├── psaux.h │ │ │ ├── pshints.h │ │ │ ├── services │ │ │ │ ├── svbdf.h │ │ │ │ ├── svcid.h │ │ │ │ ├── svgldict.h │ │ │ │ ├── svgxval.h │ │ │ │ ├── svkern.h │ │ │ │ ├── svmm.h │ │ │ │ ├── svotval.h │ │ │ │ ├── svpfr.h │ │ │ │ ├── svpostnm.h │ │ │ │ ├── svpscmap.h │ │ │ │ ├── svpsinfo.h │ │ │ │ ├── svsfnt.h │ │ │ │ ├── svttcmap.h │ │ │ │ ├── svtteng.h │ │ │ │ ├── svttglyf.h │ │ │ │ ├── svwinfnt.h │ │ │ │ └── svxf86nm.h │ │ │ ├── sfnt.h │ │ │ ├── t1types.h │ │ │ └── tttypes.h │ │ ├── t1tables.h │ │ ├── ttnameid.h │ │ ├── tttables.h │ │ ├── tttags.h │ │ └── ttunpat.h │ └── ft2build.h │ ├── x64 │ ├── libfreetype-6.dll │ ├── libfreetype.a │ ├── libfreetype.dll.lib │ └── libfreetype.la │ └── x86 │ ├── libfreetype-6.dll │ ├── libfreetype.a │ ├── libfreetype.dll.lib │ └── libfreetype.la ├── core ├── CMakeLists.txt ├── include │ ├── sgui.h │ ├── sgui_canvas.h │ ├── sgui_context.h │ ├── sgui_d3d11.h │ ├── sgui_d3d9.h │ ├── sgui_event.h │ ├── sgui_font.h │ ├── sgui_font_cache.h │ ├── sgui_icon_cache.h │ ├── sgui_internal.h │ ├── sgui_keycodes.h │ ├── sgui_model.h │ ├── sgui_pixmap.h │ ├── sgui_predef.h │ ├── sgui_rect.h │ ├── sgui_skin.h │ ├── sgui_utf8.h │ ├── sgui_widget.h │ └── sgui_window.h └── src │ ├── WIN32 │ ├── direct3d11.c │ ├── direct3d11.h │ ├── direct3d9.c │ ├── direct3d9.h │ ├── font.c │ ├── font.h │ ├── opengl.c │ ├── opengl.h │ ├── platform.c │ ├── platform.h │ ├── window.c │ └── window.h │ ├── X11 │ ├── canvas.c │ ├── canvas.h │ ├── font.c │ ├── font.h │ ├── keycode_translate.c │ ├── keycode_translate.h │ ├── opengl.c │ ├── opengl.h │ ├── pixmap.c │ ├── pixmap.h │ ├── platform.c │ ├── platform.h │ ├── window.c │ └── window.h │ ├── canvas.c │ ├── event.c │ ├── font_cache.c │ ├── icon_cache.c │ ├── mem_canvas.c │ ├── mem_pixmap.c │ ├── model.c │ ├── pixmap.c │ ├── rect.c │ ├── skin.c │ ├── skin_default.c │ ├── utf8.c │ ├── widget.c │ └── window.c ├── dialogs ├── CMakeLists.txt ├── include │ ├── sgui_color_dialog.h │ ├── sgui_dialog.h │ └── sgui_messagebox.h └── src │ ├── color_dialog.c │ ├── dialog.c │ ├── messagebox.c │ ├── messagebox_w32.c │ └── messagebox_x11.c ├── doc ├── adv.direct3d.html ├── adv.opengl.html ├── compiling.html ├── dialogs.html ├── dialogwins.html ├── hacking.build.html ├── hacking.canvas.html ├── hacking.class.html ├── hacking.event.html ├── hacking.font.html ├── hacking.html ├── hacking.oop.html ├── hacking.skin.html ├── hacking.widget.html ├── hacking.window.html ├── images │ ├── button.png │ ├── check.png │ ├── children.png │ ├── cmake.png │ ├── colorpicker.png │ ├── coords.png │ ├── edit.png │ ├── frame.png │ ├── gldemo.png │ ├── glwidget.png │ ├── group.png │ ├── iconview.png │ ├── messagebox.png │ ├── progress.png │ ├── sample1.png │ ├── sample2.png │ ├── shot1.png │ ├── shot2.png │ ├── slider.png │ ├── static.png │ ├── tab.png │ ├── tree.dia │ └── tree.svg ├── index.html ├── intro.html ├── style.css ├── thread.html ├── using.children.html ├── using.events.html ├── using.html ├── using.widgets.html ├── using.windows.html └── widgets.html ├── extras ├── CMakeLists.txt ├── clipboard.c ├── ctx_wm.c ├── d3d11_0.c ├── d3d11_1.c ├── d3d11_2.c ├── d3d11_3.c ├── d3d9_0.c ├── d3d9_1.c ├── d3d9_2.c ├── d3d9_3.c ├── demo.c ├── dialogs.c ├── events.c ├── gl0.c ├── gl1.c ├── gl2.c ├── gl3.c ├── sguiicon.c ├── simple.c ├── texcanvas.c ├── texcanvas_d3d11.c ├── texcanvas_d3d9.c └── widget.c ├── sgui_config.in ├── subwm ├── CMakeLists.txt ├── include │ ├── sgui_ctx_window.h │ ├── sgui_ctx_wm.h │ ├── sgui_subwm_predef.h │ ├── sgui_subwm_skin.h │ └── sgui_tex_canvas.h └── src │ ├── D3D11 │ ├── d3d11_canvas.c │ ├── d3d11_canvas.h │ ├── d3d11_wm.c │ └── d3d11_wm.h │ ├── D3D9 │ ├── d3d9_canvas.c │ ├── d3d9_canvas.h │ ├── d3d9_wm.c │ └── d3d9_wm.h │ ├── GL │ ├── gl_canvas.c │ ├── gl_canvas.h │ ├── gl_wm.c │ └── gl_wm.h │ ├── ctx_mesh.c │ ├── ctx_mesh.h │ ├── ctx_window.c │ ├── ctx_wm.c │ ├── skin.c │ └── tex_canvas.c ├── tests ├── CMakeLists.txt └── test_model.c └── widgets ├── CMakeLists.txt ├── include ├── sgui_button.h ├── sgui_color_picker.h ├── sgui_edit_box.h ├── sgui_frame.h ├── sgui_group_box.h ├── sgui_icon_view.h ├── sgui_image.h ├── sgui_label.h ├── sgui_numeric_edit.h ├── sgui_pass_box.h ├── sgui_progress_bar.h ├── sgui_scroll_bar.h ├── sgui_slider.h ├── sgui_subview.h └── sgui_tab.h └── src ├── button.c ├── color_picker.c ├── edit_box.c ├── frame.c ├── group_box.c ├── icon_view.c ├── image.c ├── label.c ├── numeric_edit.c ├── pass_box.c ├── progress_bar.c ├── scroll_bar.c ├── slider.c ├── subview.c └── tab.c /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | build/ 3 | 4 | -------------------------------------------------------------------------------- /CMake/mingw.cmake: -------------------------------------------------------------------------------- 1 | set( CMAKE_SYSTEM_NAME Windows ) 2 | 3 | set( CMAKE_C_COMPILER i686-w64-mingw32-gcc ) 4 | set( CMAKE_RC_COMPILER i686-w64-mingw32-windres ) 5 | set( CMAKE_AR i686-w64-mingw32-ar ) 6 | set( CMAKE_RANLIB i686-w64-mingw32-ranlib ) 7 | set( CMAKE_STRIP i686-w64-mingw32-strip ) 8 | 9 | set( CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32 ) 10 | 11 | set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) 12 | set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) 13 | set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) 14 | -------------------------------------------------------------------------------- /CMake/mingw64.cmake: -------------------------------------------------------------------------------- 1 | set( CMAKE_SYSTEM_NAME Windows ) 2 | 3 | set( CMAKE_C_COMPILER x86_64-w64-mingw32-gcc ) 4 | set( CMAKE_RC_COMPILER x86_64-w64-mingw32-windres ) 5 | set( CMAKE_AR x86_64-w64-mingw32-ar ) 6 | set( CMAKE_RANLIB x86_64-w64-mingw32-ranlib ) 7 | set( CMAKE_STRIP x86_64-w64-mingw32-strip ) 8 | 9 | set( CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32 ) 10 | 11 | set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) 12 | set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) 13 | set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2012 - David Oberhollenzer 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | 21 | -------------------------------------------------------------------------------- /build/font/README: -------------------------------------------------------------------------------- 1 | 2 | The TrueType font files in this directory are part of the Adobe 3 | SourceSansPro font package, released under the terms and conditions of the 4 | SIL Open Font License 1.1. 5 | 6 | For more information on terms and conditions, see LICENSE 7 | 8 | For more information on SourceSansPro, see: 9 | http://blogs.adobe.com/typblography/2012/08/source-sans-pro.html 10 | 11 | -------------------------------------------------------------------------------- /build/font/SourceSansPro-It.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/build/font/SourceSansPro-It.ttf -------------------------------------------------------------------------------- /build/font/SourceSansPro-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/build/font/SourceSansPro-Regular.ttf -------------------------------------------------------------------------------- /build/font/SourceSansPro-Semibold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/build/font/SourceSansPro-Semibold.ttf -------------------------------------------------------------------------------- /build/font/SourceSansPro-SemiboldIt.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/build/font/SourceSansPro-SemiboldIt.ttf -------------------------------------------------------------------------------- /build/runvalgrind.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | current=$(pwd) 4 | 5 | cd "./$(dirname $1)" 6 | valgrind --leak-check=full --show-reachable=yes\ 7 | --suppressions=$current/valgrind.supp\ 8 | "./$(basename $1)" 9 | 10 | -------------------------------------------------------------------------------- /build/valgrind.supp: -------------------------------------------------------------------------------- 1 | # 2 | # X Input Method leaks 3 | # 4 | 5 | { 6 | Ignore XIM leaks. 7 | Memcheck:Leak 8 | ... 9 | fun:_XOpenLC 10 | ... 11 | } 12 | 13 | { 14 | Ignore XIM leaks 2. 15 | Memcheck:Leak 16 | ... 17 | fun:_XimOpenIM 18 | ... 19 | } 20 | 21 | # 22 | # OpenGL related leaks 23 | # 24 | 25 | { 26 | Ignore XextCreateExtension/dlopen leak in DRI. 27 | Memcheck:Leak 28 | ... 29 | fun:glXGetFBConfigs 30 | ... 31 | } 32 | 33 | { 34 | Ignore dlopen leaks. 35 | Memcheck:Leak 36 | ... 37 | fun:_dl_open 38 | ... 39 | } 40 | 41 | -------------------------------------------------------------------------------- /build/win_dep/FTL.TXT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/build/win_dep/FTL.TXT -------------------------------------------------------------------------------- /build/win_dep/LICENSE.TXT: -------------------------------------------------------------------------------- 1 | 2 | The FreeType 2 font engine is copyrighted work and cannot be used 3 | legally without a software license. In order to make this project 4 | usable to a vast majority of developers, we distribute it under two 5 | mutually exclusive open-source licenses. 6 | 7 | This means that *you* must choose *one* of the two licenses described 8 | below, then obey all its terms and conditions when using FreeType 2 in 9 | any of your projects or products. 10 | 11 | - The FreeType License, found in the file `FTL.TXT', which is similar 12 | to the original BSD license *with* an advertising clause that forces 13 | you to explicitly cite the FreeType project in your product's 14 | documentation. All details are in the license file. This license 15 | is suited to products which don't use the GNU General Public 16 | License. 17 | 18 | - The GNU General Public License version 2, found in `GPL.TXT' (any 19 | later version can be used also), for programs which already use the 20 | GPL. Note that the FTL is incompatible with the GPL due to its 21 | advertisement clause. 22 | 23 | The contributed PCF driver comes with a license similar to that of the X 24 | Window System. It is compatible to the above two licenses (see file 25 | src/pcf/readme). 26 | 27 | 28 | --- end of LICENSE.TXT --- 29 | -------------------------------------------------------------------------------- /build/win_dep/PATENTS: -------------------------------------------------------------------------------- 1 | 2 | FreeType Patents Disclaimer 3 | August 1999 4 | 5 | 6 | 7 | WE HAVE DISCOVERED THAT APPLE OWNS SEVERAL PATENTS RELATED TO THE 8 | RENDERING OF TRUETYPE FONTS. THIS COULD MEAN THAT THE FREE USE OF 9 | FREETYPE MIGHT BE ILLEGAL IN THE USA, JAPAN, AND POSSIBLY OTHER 10 | COUNTRIES, BE IT IN PROPRIETARY OR FREE SOFTWARE PRODUCTS. 11 | 12 | FOR MORE DETAILS, WE STRONGLY ADVISE YOU TO GO TO THE FREETYPE 13 | PATENTS PAGE AT THE FOLLOWING WEB ADDRESS: 14 | 15 | http://www.freetype.org/patents.html 16 | 17 | WE WILL NOT PLACE INFORMATION IN THIS FILE AS THE SITUATION IS STILL 18 | UNDETERMINED FOR NOW. AT THE TIME THESE LINES ARE WRITTEN, WE HAVE 19 | CONTACTED APPLE'S LEGAL DEPARTMENT AND ARE STILL WAITING FOR THEIR 20 | ANSWER ON THE SUBJECT. 21 | 22 | PLEASE READ THE `INSTALL' FILE TO SEE HOW TO DISABLE THE ENGINE'S 23 | BYTECODE INTERPRETER IN ORDER TO BUILD A PATENT-FREE ENGINE, AT THE 24 | COST OF RENDERING QUALITY. 25 | 26 | 27 | --- end of PATENTS --- 28 | -------------------------------------------------------------------------------- /build/win_dep/README: -------------------------------------------------------------------------------- 1 | 2 | This directory contains a mingw cross build build of freetype 2.4.10. 3 | 4 | The directory contains only the headers and the compiled libraries for cross 5 | compiling sgui using mingw. 6 | 7 | To access the original FreeType 2 library and source, see freetype.org 8 | 9 | -------------------------------------------------------------------------------- /build/win_dep/include/freetype/config/ftmodule.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file registers the FreeType modules compiled into the library. 3 | * 4 | * If you use GNU make, this file IS NOT USED! Instead, it is created in 5 | * the objects directory (normally `/objs/') based on information 6 | * from `/modules.cfg'. 7 | * 8 | * Please read `docs/INSTALL.ANY' and `docs/CUSTOMIZE' how to compile 9 | * FreeType without GNU make. 10 | * 11 | */ 12 | 13 | FT_USE_MODULE( FT_Module_Class, autofit_module_class ) 14 | FT_USE_MODULE( FT_Driver_ClassRec, tt_driver_class ) 15 | FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class ) 16 | FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class ) 17 | FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class ) 18 | FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class ) 19 | FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class ) 20 | FT_USE_MODULE( FT_Driver_ClassRec, winfnt_driver_class ) 21 | FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class ) 22 | FT_USE_MODULE( FT_Module_Class, psaux_module_class ) 23 | FT_USE_MODULE( FT_Module_Class, psnames_module_class ) 24 | FT_USE_MODULE( FT_Module_Class, pshinter_module_class ) 25 | FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class ) 26 | FT_USE_MODULE( FT_Module_Class, sfnt_module_class ) 27 | FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class ) 28 | FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcd_renderer_class ) 29 | FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcdv_renderer_class ) 30 | FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class ) 31 | 32 | /* EOF */ 33 | -------------------------------------------------------------------------------- /build/win_dep/include/freetype/internal/ftpic.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftpic.h */ 4 | /* */ 5 | /* The FreeType position independent code services (declaration). */ 6 | /* */ 7 | /* Copyright 2009 by */ 8 | /* Oran Agra and Mickey Gabel. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | /*************************************************************************/ 19 | /* */ 20 | /* Modules that ordinarily have const global data that need address */ 21 | /* can instead define pointers here. */ 22 | /* */ 23 | /*************************************************************************/ 24 | 25 | 26 | #ifndef __FTPIC_H__ 27 | #define __FTPIC_H__ 28 | 29 | 30 | FT_BEGIN_HEADER 31 | 32 | #ifdef FT_CONFIG_OPTION_PIC 33 | 34 | typedef struct FT_PIC_Container_ 35 | { 36 | /* pic containers for base */ 37 | void* base; 38 | /* pic containers for modules */ 39 | void* autofit; 40 | void* cff; 41 | void* pshinter; 42 | void* psnames; 43 | void* raster; 44 | void* sfnt; 45 | void* smooth; 46 | void* truetype; 47 | } FT_PIC_Container; 48 | 49 | /* Initialize the various function tables, structs, etc. stored in the container. */ 50 | FT_BASE( FT_Error ) 51 | ft_pic_container_init( FT_Library library ); 52 | 53 | 54 | /* Destroy the contents of the container. */ 55 | FT_BASE( void ) 56 | ft_pic_container_destroy( FT_Library library ); 57 | 58 | #endif /* FT_CONFIG_OPTION_PIC */ 59 | 60 | /* */ 61 | 62 | FT_END_HEADER 63 | 64 | #endif /* __FTPIC_H__ */ 65 | 66 | 67 | /* END */ 68 | -------------------------------------------------------------------------------- /build/win_dep/include/freetype/internal/internal.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* internal.h */ 4 | /* */ 5 | /* Internal header files (specification only). */ 6 | /* */ 7 | /* Copyright 1996-2001, 2002, 2003, 2004 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | /*************************************************************************/ 20 | /* */ 21 | /* This file is automatically included by `ft2build.h'. */ 22 | /* Do not include it manually! */ 23 | /* */ 24 | /*************************************************************************/ 25 | 26 | 27 | #define FT_INTERNAL_OBJECTS_H 28 | #define FT_INTERNAL_PIC_H 29 | #define FT_INTERNAL_STREAM_H 30 | #define FT_INTERNAL_MEMORY_H 31 | #define FT_INTERNAL_DEBUG_H 32 | #define FT_INTERNAL_CALC_H 33 | #define FT_INTERNAL_DRIVER_H 34 | #define FT_INTERNAL_TRACE_H 35 | #define FT_INTERNAL_GLYPH_LOADER_H 36 | #define FT_INTERNAL_SFNT_H 37 | #define FT_INTERNAL_SERVICE_H 38 | #define FT_INTERNAL_RFORK_H 39 | #define FT_INTERNAL_VALIDATE_H 40 | 41 | #define FT_INTERNAL_TRUETYPE_TYPES_H 42 | #define FT_INTERNAL_TYPE1_TYPES_H 43 | 44 | #define FT_INTERNAL_POSTSCRIPT_AUX_H 45 | #define FT_INTERNAL_POSTSCRIPT_HINTS_H 46 | #define FT_INTERNAL_POSTSCRIPT_GLOBALS_H 47 | 48 | #define FT_INTERNAL_AUTOHINT_H 49 | 50 | 51 | /* END */ 52 | -------------------------------------------------------------------------------- /build/win_dep/include/freetype/internal/services/svbdf.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svbdf.h */ 4 | /* */ 5 | /* The FreeType BDF services (specification). */ 6 | /* */ 7 | /* Copyright 2003, 2009, 2012 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef __SVBDF_H__ 20 | #define __SVBDF_H__ 21 | 22 | #include FT_BDF_H 23 | #include FT_INTERNAL_SERVICE_H 24 | 25 | 26 | FT_BEGIN_HEADER 27 | 28 | 29 | #define FT_SERVICE_ID_BDF "bdf" 30 | 31 | typedef FT_Error 32 | (*FT_BDF_GetCharsetIdFunc)( FT_Face face, 33 | const char* *acharset_encoding, 34 | const char* *acharset_registry ); 35 | 36 | typedef FT_Error 37 | (*FT_BDF_GetPropertyFunc)( FT_Face face, 38 | const char* prop_name, 39 | BDF_PropertyRec *aproperty ); 40 | 41 | 42 | FT_DEFINE_SERVICE( BDF ) 43 | { 44 | FT_BDF_GetCharsetIdFunc get_charset_id; 45 | FT_BDF_GetPropertyFunc get_property; 46 | }; 47 | 48 | 49 | #ifndef FT_CONFIG_OPTION_PIC 50 | 51 | #define FT_DEFINE_SERVICE_BDFRec( class_, \ 52 | get_charset_id_, \ 53 | get_property_ ) \ 54 | static const FT_Service_BDFRec class_ = \ 55 | { \ 56 | get_charset_id_, get_property_ \ 57 | }; 58 | 59 | #else /* FT_CONFIG_OPTION_PIC */ 60 | 61 | #define FT_DEFINE_SERVICE_BDFRec( class_, \ 62 | get_charset_id_, \ 63 | get_property_ ) \ 64 | void \ 65 | FT_Init_Class_ ## class_( FT_Service_BDFRec* clazz ) \ 66 | { \ 67 | clazz->get_charset_id = get_charset_id_; \ 68 | clazz->get_property = get_property_; \ 69 | } 70 | 71 | #endif /* FT_CONFIG_OPTION_PIC */ 72 | 73 | /* */ 74 | 75 | 76 | FT_END_HEADER 77 | 78 | 79 | #endif /* __SVBDF_H__ */ 80 | 81 | 82 | /* END */ 83 | -------------------------------------------------------------------------------- /build/win_dep/include/freetype/internal/services/svgldict.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svgldict.h */ 4 | /* */ 5 | /* The FreeType glyph dictionary services (specification). */ 6 | /* */ 7 | /* Copyright 2003, 2009, 2012 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef __SVGLDICT_H__ 20 | #define __SVGLDICT_H__ 21 | 22 | #include FT_INTERNAL_SERVICE_H 23 | 24 | 25 | FT_BEGIN_HEADER 26 | 27 | 28 | /* 29 | * A service used to retrieve glyph names, as well as to find the 30 | * index of a given glyph name in a font. 31 | * 32 | */ 33 | 34 | #define FT_SERVICE_ID_GLYPH_DICT "glyph-dict" 35 | 36 | 37 | typedef FT_Error 38 | (*FT_GlyphDict_GetNameFunc)( FT_Face face, 39 | FT_UInt glyph_index, 40 | FT_Pointer buffer, 41 | FT_UInt buffer_max ); 42 | 43 | typedef FT_UInt 44 | (*FT_GlyphDict_NameIndexFunc)( FT_Face face, 45 | FT_String* glyph_name ); 46 | 47 | 48 | FT_DEFINE_SERVICE( GlyphDict ) 49 | { 50 | FT_GlyphDict_GetNameFunc get_name; 51 | FT_GlyphDict_NameIndexFunc name_index; /* optional */ 52 | }; 53 | 54 | 55 | #ifndef FT_CONFIG_OPTION_PIC 56 | 57 | #define FT_DEFINE_SERVICE_GLYPHDICTREC( class_, \ 58 | get_name_, \ 59 | name_index_) \ 60 | static const FT_Service_GlyphDictRec class_ = \ 61 | { \ 62 | get_name_, name_index_ \ 63 | }; 64 | 65 | #else /* FT_CONFIG_OPTION_PIC */ 66 | 67 | #define FT_DEFINE_SERVICE_GLYPHDICTREC( class_, \ 68 | get_name_, \ 69 | name_index_) \ 70 | void \ 71 | FT_Init_Class_ ## class_( FT_Library library, \ 72 | FT_Service_GlyphDictRec* clazz ) \ 73 | { \ 74 | FT_UNUSED( library ); \ 75 | \ 76 | clazz->get_name = get_name_; \ 77 | clazz->name_index = name_index_; \ 78 | } 79 | 80 | #endif /* FT_CONFIG_OPTION_PIC */ 81 | 82 | /* */ 83 | 84 | 85 | FT_END_HEADER 86 | 87 | 88 | #endif /* __SVGLDICT_H__ */ 89 | -------------------------------------------------------------------------------- /build/win_dep/include/freetype/internal/services/svgxval.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svgxval.h */ 4 | /* */ 5 | /* FreeType API for validating TrueTypeGX/AAT tables (specification). */ 6 | /* */ 7 | /* Copyright 2004, 2005 by */ 8 | /* Masatake YAMATO, Red Hat K.K., */ 9 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 10 | /* */ 11 | /* This file is part of the FreeType project, and may only be used, */ 12 | /* modified, and distributed under the terms of the FreeType project */ 13 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 14 | /* this file you indicate that you have read the license and */ 15 | /* understand and accept it fully. */ 16 | /* */ 17 | /***************************************************************************/ 18 | 19 | /***************************************************************************/ 20 | /* */ 21 | /* gxvalid is derived from both gxlayout module and otvalid module. */ 22 | /* Development of gxlayout is supported by the Information-technology */ 23 | /* Promotion Agency(IPA), Japan. */ 24 | /* */ 25 | /***************************************************************************/ 26 | 27 | 28 | #ifndef __SVGXVAL_H__ 29 | #define __SVGXVAL_H__ 30 | 31 | #include FT_GX_VALIDATE_H 32 | #include FT_INTERNAL_VALIDATE_H 33 | 34 | FT_BEGIN_HEADER 35 | 36 | 37 | #define FT_SERVICE_ID_GX_VALIDATE "truetypegx-validate" 38 | #define FT_SERVICE_ID_CLASSICKERN_VALIDATE "classickern-validate" 39 | 40 | typedef FT_Error 41 | (*gxv_validate_func)( FT_Face face, 42 | FT_UInt gx_flags, 43 | FT_Bytes tables[FT_VALIDATE_GX_LENGTH], 44 | FT_UInt table_length ); 45 | 46 | 47 | typedef FT_Error 48 | (*ckern_validate_func)( FT_Face face, 49 | FT_UInt ckern_flags, 50 | FT_Bytes *ckern_table ); 51 | 52 | 53 | FT_DEFINE_SERVICE( GXvalidate ) 54 | { 55 | gxv_validate_func validate; 56 | }; 57 | 58 | FT_DEFINE_SERVICE( CKERNvalidate ) 59 | { 60 | ckern_validate_func validate; 61 | }; 62 | 63 | /* */ 64 | 65 | 66 | FT_END_HEADER 67 | 68 | 69 | #endif /* __SVGXVAL_H__ */ 70 | 71 | 72 | /* END */ 73 | -------------------------------------------------------------------------------- /build/win_dep/include/freetype/internal/services/svkern.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svkern.h */ 4 | /* */ 5 | /* The FreeType Kerning service (specification). */ 6 | /* */ 7 | /* Copyright 2006 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef __SVKERN_H__ 20 | #define __SVKERN_H__ 21 | 22 | #include FT_INTERNAL_SERVICE_H 23 | #include FT_TRUETYPE_TABLES_H 24 | 25 | 26 | FT_BEGIN_HEADER 27 | 28 | #define FT_SERVICE_ID_KERNING "kerning" 29 | 30 | 31 | typedef FT_Error 32 | (*FT_Kerning_TrackGetFunc)( FT_Face face, 33 | FT_Fixed point_size, 34 | FT_Int degree, 35 | FT_Fixed* akerning ); 36 | 37 | FT_DEFINE_SERVICE( Kerning ) 38 | { 39 | FT_Kerning_TrackGetFunc get_track; 40 | }; 41 | 42 | /* */ 43 | 44 | 45 | FT_END_HEADER 46 | 47 | 48 | #endif /* __SVKERN_H__ */ 49 | 50 | 51 | /* END */ 52 | -------------------------------------------------------------------------------- /build/win_dep/include/freetype/internal/services/svotval.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svotval.h */ 4 | /* */ 5 | /* The FreeType OpenType validation service (specification). */ 6 | /* */ 7 | /* Copyright 2004, 2006 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef __SVOTVAL_H__ 20 | #define __SVOTVAL_H__ 21 | 22 | #include FT_OPENTYPE_VALIDATE_H 23 | #include FT_INTERNAL_VALIDATE_H 24 | 25 | FT_BEGIN_HEADER 26 | 27 | 28 | #define FT_SERVICE_ID_OPENTYPE_VALIDATE "opentype-validate" 29 | 30 | 31 | typedef FT_Error 32 | (*otv_validate_func)( FT_Face volatile face, 33 | FT_UInt ot_flags, 34 | FT_Bytes *base, 35 | FT_Bytes *gdef, 36 | FT_Bytes *gpos, 37 | FT_Bytes *gsub, 38 | FT_Bytes *jstf ); 39 | 40 | 41 | FT_DEFINE_SERVICE( OTvalidate ) 42 | { 43 | otv_validate_func validate; 44 | }; 45 | 46 | /* */ 47 | 48 | 49 | FT_END_HEADER 50 | 51 | 52 | #endif /* __SVOTVAL_H__ */ 53 | 54 | 55 | /* END */ 56 | -------------------------------------------------------------------------------- /build/win_dep/include/freetype/internal/services/svpfr.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svpfr.h */ 4 | /* */ 5 | /* Internal PFR service functions (specification). */ 6 | /* */ 7 | /* Copyright 2003, 2006 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef __SVPFR_H__ 20 | #define __SVPFR_H__ 21 | 22 | #include FT_PFR_H 23 | #include FT_INTERNAL_SERVICE_H 24 | 25 | 26 | FT_BEGIN_HEADER 27 | 28 | 29 | #define FT_SERVICE_ID_PFR_METRICS "pfr-metrics" 30 | 31 | 32 | typedef FT_Error 33 | (*FT_PFR_GetMetricsFunc)( FT_Face face, 34 | FT_UInt *aoutline, 35 | FT_UInt *ametrics, 36 | FT_Fixed *ax_scale, 37 | FT_Fixed *ay_scale ); 38 | 39 | typedef FT_Error 40 | (*FT_PFR_GetKerningFunc)( FT_Face face, 41 | FT_UInt left, 42 | FT_UInt right, 43 | FT_Vector *avector ); 44 | 45 | typedef FT_Error 46 | (*FT_PFR_GetAdvanceFunc)( FT_Face face, 47 | FT_UInt gindex, 48 | FT_Pos *aadvance ); 49 | 50 | 51 | FT_DEFINE_SERVICE( PfrMetrics ) 52 | { 53 | FT_PFR_GetMetricsFunc get_metrics; 54 | FT_PFR_GetKerningFunc get_kerning; 55 | FT_PFR_GetAdvanceFunc get_advance; 56 | 57 | }; 58 | 59 | /* */ 60 | 61 | FT_END_HEADER 62 | 63 | #endif /* __SVPFR_H__ */ 64 | 65 | 66 | /* END */ 67 | -------------------------------------------------------------------------------- /build/win_dep/include/freetype/internal/services/svpostnm.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svpostnm.h */ 4 | /* */ 5 | /* The FreeType PostScript name services (specification). */ 6 | /* */ 7 | /* Copyright 2003, 2007, 2009, 2012 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef __SVPOSTNM_H__ 20 | #define __SVPOSTNM_H__ 21 | 22 | #include FT_INTERNAL_SERVICE_H 23 | 24 | 25 | FT_BEGIN_HEADER 26 | 27 | /* 28 | * A trivial service used to retrieve the PostScript name of a given 29 | * font when available. The `get_name' field should never be NULL. 30 | * 31 | * The corresponding function can return NULL to indicate that the 32 | * PostScript name is not available. 33 | * 34 | * The name is owned by the face and will be destroyed with it. 35 | */ 36 | 37 | #define FT_SERVICE_ID_POSTSCRIPT_FONT_NAME "postscript-font-name" 38 | 39 | 40 | typedef const char* 41 | (*FT_PsName_GetFunc)( FT_Face face ); 42 | 43 | 44 | FT_DEFINE_SERVICE( PsFontName ) 45 | { 46 | FT_PsName_GetFunc get_ps_font_name; 47 | }; 48 | 49 | 50 | #ifndef FT_CONFIG_OPTION_PIC 51 | 52 | #define FT_DEFINE_SERVICE_PSFONTNAMEREC( class_, get_ps_font_name_ ) \ 53 | static const FT_Service_PsFontNameRec class_ = \ 54 | { \ 55 | get_ps_font_name_ \ 56 | }; 57 | 58 | #else /* FT_CONFIG_OPTION_PIC */ 59 | 60 | #define FT_DEFINE_SERVICE_PSFONTNAMEREC( class_, get_ps_font_name_ ) \ 61 | void \ 62 | FT_Init_Class_ ## class_( FT_Library library, \ 63 | FT_Service_PsFontNameRec* clazz ) \ 64 | { \ 65 | FT_UNUSED( library ); \ 66 | \ 67 | clazz->get_ps_font_name = get_ps_font_name_; \ 68 | } 69 | 70 | #endif /* FT_CONFIG_OPTION_PIC */ 71 | 72 | /* */ 73 | 74 | 75 | FT_END_HEADER 76 | 77 | 78 | #endif /* __SVPOSTNM_H__ */ 79 | 80 | 81 | /* END */ 82 | -------------------------------------------------------------------------------- /build/win_dep/include/freetype/internal/services/svsfnt.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svsfnt.h */ 4 | /* */ 5 | /* The FreeType SFNT table loading service (specification). */ 6 | /* */ 7 | /* Copyright 2003, 2004, 2009, 2012 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef __SVSFNT_H__ 20 | #define __SVSFNT_H__ 21 | 22 | #include FT_INTERNAL_SERVICE_H 23 | #include FT_TRUETYPE_TABLES_H 24 | 25 | 26 | FT_BEGIN_HEADER 27 | 28 | 29 | /* 30 | * SFNT table loading service. 31 | */ 32 | 33 | #define FT_SERVICE_ID_SFNT_TABLE "sfnt-table" 34 | 35 | 36 | /* 37 | * Used to implement FT_Load_Sfnt_Table(). 38 | */ 39 | typedef FT_Error 40 | (*FT_SFNT_TableLoadFunc)( FT_Face face, 41 | FT_ULong tag, 42 | FT_Long offset, 43 | FT_Byte* buffer, 44 | FT_ULong* length ); 45 | 46 | /* 47 | * Used to implement FT_Get_Sfnt_Table(). 48 | */ 49 | typedef void* 50 | (*FT_SFNT_TableGetFunc)( FT_Face face, 51 | FT_Sfnt_Tag tag ); 52 | 53 | 54 | /* 55 | * Used to implement FT_Sfnt_Table_Info(). 56 | */ 57 | typedef FT_Error 58 | (*FT_SFNT_TableInfoFunc)( FT_Face face, 59 | FT_UInt idx, 60 | FT_ULong *tag, 61 | FT_ULong *offset, 62 | FT_ULong *length ); 63 | 64 | 65 | FT_DEFINE_SERVICE( SFNT_Table ) 66 | { 67 | FT_SFNT_TableLoadFunc load_table; 68 | FT_SFNT_TableGetFunc get_table; 69 | FT_SFNT_TableInfoFunc table_info; 70 | }; 71 | 72 | 73 | #ifndef FT_CONFIG_OPTION_PIC 74 | 75 | #define FT_DEFINE_SERVICE_SFNT_TABLEREC( class_, load_, get_, info_ ) \ 76 | static const FT_Service_SFNT_TableRec class_ = \ 77 | { \ 78 | load_, get_, info_ \ 79 | }; 80 | 81 | #else /* FT_CONFIG_OPTION_PIC */ 82 | 83 | #define FT_DEFINE_SERVICE_SFNT_TABLEREC( class_, load_, get_, info_ ) \ 84 | void \ 85 | FT_Init_Class_ ## class_( FT_Service_SFNT_TableRec* clazz ) \ 86 | { \ 87 | clazz->load_table = load_; \ 88 | clazz->get_table = get_; \ 89 | clazz->table_info = info_; \ 90 | } 91 | 92 | #endif /* FT_CONFIG_OPTION_PIC */ 93 | 94 | /* */ 95 | 96 | 97 | FT_END_HEADER 98 | 99 | 100 | #endif /* __SVSFNT_H__ */ 101 | 102 | 103 | /* END */ 104 | -------------------------------------------------------------------------------- /build/win_dep/include/freetype/internal/services/svtteng.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svtteng.h */ 4 | /* */ 5 | /* The FreeType TrueType engine query service (specification). */ 6 | /* */ 7 | /* Copyright 2006 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef __SVTTENG_H__ 20 | #define __SVTTENG_H__ 21 | 22 | #include FT_INTERNAL_SERVICE_H 23 | #include FT_MODULE_H 24 | 25 | 26 | FT_BEGIN_HEADER 27 | 28 | 29 | /* 30 | * SFNT table loading service. 31 | */ 32 | 33 | #define FT_SERVICE_ID_TRUETYPE_ENGINE "truetype-engine" 34 | 35 | /* 36 | * Used to implement FT_Get_TrueType_Engine_Type 37 | */ 38 | 39 | FT_DEFINE_SERVICE( TrueTypeEngine ) 40 | { 41 | FT_TrueTypeEngineType engine_type; 42 | }; 43 | 44 | /* */ 45 | 46 | 47 | FT_END_HEADER 48 | 49 | 50 | #endif /* __SVTTENG_H__ */ 51 | 52 | 53 | /* END */ 54 | -------------------------------------------------------------------------------- /build/win_dep/include/freetype/internal/services/svttglyf.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svttglyf.h */ 4 | /* */ 5 | /* The FreeType TrueType glyph service. */ 6 | /* */ 7 | /* Copyright 2007, 2009, 2012 by David Turner. */ 8 | /* */ 9 | /* This file is part of the FreeType project, and may only be used, */ 10 | /* modified, and distributed under the terms of the FreeType project */ 11 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 12 | /* this file you indicate that you have read the license and */ 13 | /* understand and accept it fully. */ 14 | /* */ 15 | /***************************************************************************/ 16 | 17 | #ifndef __SVTTGLYF_H__ 18 | #define __SVTTGLYF_H__ 19 | 20 | #include FT_INTERNAL_SERVICE_H 21 | #include FT_TRUETYPE_TABLES_H 22 | 23 | 24 | FT_BEGIN_HEADER 25 | 26 | 27 | #define FT_SERVICE_ID_TT_GLYF "tt-glyf" 28 | 29 | 30 | typedef FT_ULong 31 | (*TT_Glyf_GetLocationFunc)( FT_Face face, 32 | FT_UInt gindex, 33 | FT_ULong *psize ); 34 | 35 | FT_DEFINE_SERVICE( TTGlyf ) 36 | { 37 | TT_Glyf_GetLocationFunc get_location; 38 | }; 39 | 40 | 41 | #ifndef FT_CONFIG_OPTION_PIC 42 | 43 | #define FT_DEFINE_SERVICE_TTGLYFREC( class_, get_location_ ) \ 44 | static const FT_Service_TTGlyfRec class_ = \ 45 | { \ 46 | get_location_ \ 47 | }; 48 | 49 | #else /* FT_CONFIG_OPTION_PIC */ 50 | 51 | #define FT_DEFINE_SERVICE_TTGLYFREC( class_, get_location_ ) \ 52 | void \ 53 | FT_Init_Class_ ## class_( FT_Service_TTGlyfRec* clazz ) \ 54 | { \ 55 | clazz->get_location = get_location_; \ 56 | } 57 | 58 | #endif /* FT_CONFIG_OPTION_PIC */ 59 | 60 | /* */ 61 | 62 | 63 | FT_END_HEADER 64 | 65 | #endif /* __SVTTGLYF_H__ */ 66 | 67 | 68 | /* END */ 69 | -------------------------------------------------------------------------------- /build/win_dep/include/freetype/internal/services/svwinfnt.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svwinfnt.h */ 4 | /* */ 5 | /* The FreeType Windows FNT/FONT service (specification). */ 6 | /* */ 7 | /* Copyright 2003 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef __SVWINFNT_H__ 20 | #define __SVWINFNT_H__ 21 | 22 | #include FT_INTERNAL_SERVICE_H 23 | #include FT_WINFONTS_H 24 | 25 | 26 | FT_BEGIN_HEADER 27 | 28 | 29 | #define FT_SERVICE_ID_WINFNT "winfonts" 30 | 31 | typedef FT_Error 32 | (*FT_WinFnt_GetHeaderFunc)( FT_Face face, 33 | FT_WinFNT_HeaderRec *aheader ); 34 | 35 | 36 | FT_DEFINE_SERVICE( WinFnt ) 37 | { 38 | FT_WinFnt_GetHeaderFunc get_header; 39 | }; 40 | 41 | /* */ 42 | 43 | 44 | FT_END_HEADER 45 | 46 | 47 | #endif /* __SVWINFNT_H__ */ 48 | 49 | 50 | /* END */ 51 | -------------------------------------------------------------------------------- /build/win_dep/include/freetype/internal/services/svxf86nm.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svxf86nm.h */ 4 | /* */ 5 | /* The FreeType XFree86 services (specification only). */ 6 | /* */ 7 | /* Copyright 2003 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef __SVXF86NM_H__ 20 | #define __SVXF86NM_H__ 21 | 22 | #include FT_INTERNAL_SERVICE_H 23 | 24 | 25 | FT_BEGIN_HEADER 26 | 27 | 28 | /* 29 | * A trivial service used to return the name of a face's font driver, 30 | * according to the XFree86 nomenclature. Note that the service data 31 | * is a simple constant string pointer. 32 | */ 33 | 34 | #define FT_SERVICE_ID_XF86_NAME "xf86-driver-name" 35 | 36 | #define FT_XF86_FORMAT_TRUETYPE "TrueType" 37 | #define FT_XF86_FORMAT_TYPE_1 "Type 1" 38 | #define FT_XF86_FORMAT_BDF "BDF" 39 | #define FT_XF86_FORMAT_PCF "PCF" 40 | #define FT_XF86_FORMAT_TYPE_42 "Type 42" 41 | #define FT_XF86_FORMAT_CID "CID Type 1" 42 | #define FT_XF86_FORMAT_CFF "CFF" 43 | #define FT_XF86_FORMAT_PFR "PFR" 44 | #define FT_XF86_FORMAT_WINFNT "Windows FNT" 45 | 46 | /* */ 47 | 48 | 49 | FT_END_HEADER 50 | 51 | 52 | #endif /* __SVXF86NM_H__ */ 53 | 54 | 55 | /* END */ 56 | -------------------------------------------------------------------------------- /build/win_dep/include/freetype/ttunpat.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ttunpat.h */ 4 | /* */ 5 | /* Definitions for the unpatented TrueType hinting system */ 6 | /* */ 7 | /* Copyright 2003, 2006 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* Written by Graham Asher */ 11 | /* */ 12 | /* This file is part of the FreeType project, and may only be used, */ 13 | /* modified, and distributed under the terms of the FreeType project */ 14 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 15 | /* this file you indicate that you have read the license and */ 16 | /* understand and accept it fully. */ 17 | /* */ 18 | /***************************************************************************/ 19 | 20 | 21 | #ifndef __TTUNPAT_H__ 22 | #define __TTUNPAT_H__ 23 | 24 | 25 | #include 26 | #include FT_FREETYPE_H 27 | 28 | #ifdef FREETYPE_H 29 | #error "freetype.h of FreeType 1 has been loaded!" 30 | #error "Please fix the directory search order for header files" 31 | #error "so that freetype.h of FreeType 2 is found first." 32 | #endif 33 | 34 | 35 | FT_BEGIN_HEADER 36 | 37 | 38 | /*************************************************************************** 39 | * 40 | * @constant: 41 | * FT_PARAM_TAG_UNPATENTED_HINTING 42 | * 43 | * @description: 44 | * A constant used as the tag of an @FT_Parameter structure to indicate 45 | * that unpatented methods only should be used by the TrueType bytecode 46 | * interpreter for a typeface opened by @FT_Open_Face. 47 | * 48 | */ 49 | #define FT_PARAM_TAG_UNPATENTED_HINTING FT_MAKE_TAG( 'u', 'n', 'p', 'a' ) 50 | 51 | /* */ 52 | 53 | FT_END_HEADER 54 | 55 | 56 | #endif /* __TTUNPAT_H__ */ 57 | 58 | 59 | /* END */ 60 | -------------------------------------------------------------------------------- /build/win_dep/include/ft2build.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ft2build.h */ 4 | /* */ 5 | /* FreeType 2 build and setup macros. */ 6 | /* (Generic version) */ 7 | /* */ 8 | /* Copyright 1996-2001, 2006 by */ 9 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 10 | /* */ 11 | /* This file is part of the FreeType project, and may only be used, */ 12 | /* modified, and distributed under the terms of the FreeType project */ 13 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 14 | /* this file you indicate that you have read the license and */ 15 | /* understand and accept it fully. */ 16 | /* */ 17 | /***************************************************************************/ 18 | 19 | 20 | /*************************************************************************/ 21 | /* */ 22 | /* This file corresponds to the default `ft2build.h' file for */ 23 | /* FreeType 2. It uses the `freetype' include root. */ 24 | /* */ 25 | /* Note that specific platforms might use a different configuration. */ 26 | /* See builds/unix/ft2unix.h for an example. */ 27 | /* */ 28 | /*************************************************************************/ 29 | 30 | 31 | #ifndef __FT2_BUILD_GENERIC_H__ 32 | #define __FT2_BUILD_GENERIC_H__ 33 | 34 | #include 35 | 36 | #endif /* __FT2_BUILD_GENERIC_H__ */ 37 | 38 | 39 | /* END */ 40 | -------------------------------------------------------------------------------- /build/win_dep/x64/libfreetype-6.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/build/win_dep/x64/libfreetype-6.dll -------------------------------------------------------------------------------- /build/win_dep/x64/libfreetype.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/build/win_dep/x64/libfreetype.a -------------------------------------------------------------------------------- /build/win_dep/x64/libfreetype.dll.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/build/win_dep/x64/libfreetype.dll.lib -------------------------------------------------------------------------------- /build/win_dep/x64/libfreetype.la: -------------------------------------------------------------------------------- 1 | # libfreetype.la - a libtool library file 2 | # Generated by libtool (GNU libtool) 2.4.2 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # The name that we can dlopen(3). 8 | dlname='libfreetype-6.dll' 9 | 10 | # Names of this library. 11 | library_names='libfreetype.dll.a' 12 | 13 | # The name of the static archive. 14 | old_library='libfreetype.a' 15 | 16 | # Linker flags that can not go in dependency_libs. 17 | inherited_linker_flags='' 18 | 19 | # Libraries that this one depends upon. 20 | dependency_libs='' 21 | 22 | # Names of additional weak libraries provided by this library 23 | weak_library_names='' 24 | 25 | # Version information for libfreetype. 26 | current=15 27 | age=9 28 | revision=0 29 | 30 | # Is this an already installed library? 31 | installed=no 32 | 33 | # Should we warn about portability when linking against -modules? 34 | shouldnotlink=no 35 | 36 | # Files to dlopen/dlpreopen 37 | dlopen='' 38 | dlpreopen='' 39 | 40 | # Directory that this library needs to be installed in: 41 | libdir='/usr/local/lib' 42 | -------------------------------------------------------------------------------- /build/win_dep/x86/libfreetype-6.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/build/win_dep/x86/libfreetype-6.dll -------------------------------------------------------------------------------- /build/win_dep/x86/libfreetype.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/build/win_dep/x86/libfreetype.a -------------------------------------------------------------------------------- /build/win_dep/x86/libfreetype.dll.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/build/win_dep/x86/libfreetype.dll.lib -------------------------------------------------------------------------------- /build/win_dep/x86/libfreetype.la: -------------------------------------------------------------------------------- 1 | # libfreetype.la - a libtool library file 2 | # Generated by libtool (GNU libtool) 2.4.2 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # The name that we can dlopen(3). 8 | dlname='libfreetype-6.dll' 9 | 10 | # Names of this library. 11 | library_names='libfreetype.dll.a' 12 | 13 | # The name of the static archive. 14 | old_library='libfreetype.a' 15 | 16 | # Linker flags that can not go in dependency_libs. 17 | inherited_linker_flags='' 18 | 19 | # Libraries that this one depends upon. 20 | dependency_libs='' 21 | 22 | # Names of additional weak libraries provided by this library 23 | weak_library_names='' 24 | 25 | # Version information for libfreetype. 26 | current=15 27 | age=9 28 | revision=0 29 | 30 | # Is this an already installed library? 31 | installed=no 32 | 33 | # Should we warn about portability when linking against -modules? 34 | shouldnotlink=no 35 | 36 | # Files to dlopen/dlpreopen 37 | dlopen='' 38 | dlpreopen='' 39 | 40 | # Directory that this library needs to be installed in: 41 | libdir='/usr/local/lib' 42 | -------------------------------------------------------------------------------- /core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------- 2 | # This file is part of the sgui buildsystem. I, David Oberhollenzer, 3 | # author of this file hereby place the contents of this file into 4 | # the public domain. 5 | #-------------------------------------------------------------------- 6 | 7 | if( UNIX AND NOT APPLE ) 8 | set( CORE_PLATFORM_SRC 9 | ${CMAKE_CURRENT_SOURCE_DIR}/src/X11/canvas.c 10 | ${CMAKE_CURRENT_SOURCE_DIR}/src/X11/font.c 11 | ${CMAKE_CURRENT_SOURCE_DIR}/src/X11/keycode_translate.c 12 | ${CMAKE_CURRENT_SOURCE_DIR}/src/X11/opengl.c 13 | ${CMAKE_CURRENT_SOURCE_DIR}/src/X11/pixmap.c 14 | ${CMAKE_CURRENT_SOURCE_DIR}/src/X11/platform.c 15 | ${CMAKE_CURRENT_SOURCE_DIR}/src/X11/window.c ) 16 | elseif( WIN32 ) 17 | set( CORE_PLATFORM_SRC 18 | ${CMAKE_CURRENT_SOURCE_DIR}/src/WIN32/font.c 19 | ${CMAKE_CURRENT_SOURCE_DIR}/src/WIN32/opengl.c 20 | ${CMAKE_CURRENT_SOURCE_DIR}/src/WIN32/platform.c 21 | ${CMAKE_CURRENT_SOURCE_DIR}/src/WIN32/direct3d9.c 22 | ${CMAKE_CURRENT_SOURCE_DIR}/src/WIN32/direct3d11.c 23 | ${CMAKE_CURRENT_SOURCE_DIR}/src/WIN32/window.c ) 24 | endif( ) 25 | 26 | 27 | 28 | set( CORE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/canvas.c 29 | ${CMAKE_CURRENT_SOURCE_DIR}/src/event.c 30 | ${CMAKE_CURRENT_SOURCE_DIR}/src/font_cache.c 31 | ${CMAKE_CURRENT_SOURCE_DIR}/src/icon_cache.c 32 | ${CMAKE_CURRENT_SOURCE_DIR}/src/mem_canvas.c 33 | ${CMAKE_CURRENT_SOURCE_DIR}/src/mem_pixmap.c 34 | ${CMAKE_CURRENT_SOURCE_DIR}/src/model.c 35 | ${CMAKE_CURRENT_SOURCE_DIR}/src/pixmap.c 36 | ${CMAKE_CURRENT_SOURCE_DIR}/src/rect.c 37 | ${CMAKE_CURRENT_SOURCE_DIR}/src/skin.c 38 | ${CMAKE_CURRENT_SOURCE_DIR}/src/skin_default.c 39 | ${CMAKE_CURRENT_SOURCE_DIR}/src/utf8.c 40 | ${CMAKE_CURRENT_SOURCE_DIR}/src/widget.c 41 | ${CMAKE_CURRENT_SOURCE_DIR}/src/window.c 42 | 43 | ${CORE_PLATFORM_SRC} 44 | PARENT_SCOPE ) 45 | 46 | -------------------------------------------------------------------------------- /core/include/sgui_d3d9.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sgui_d3d9.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * \file sgui_d3d9.h 28 | * 29 | * \brief Contains the Direct3D 9 context implementation. 30 | */ 31 | #ifndef SGUI_D3D9_H 32 | #define SGUI_D3D9_H 33 | 34 | 35 | 36 | #include "sgui_context.h" 37 | #include "sgui_window.h" 38 | 39 | #ifndef SGUI_DOXYGEN 40 | #define WIN32_LEAN_AND_MEAN 41 | #endif 42 | #include 43 | #include 44 | 45 | 46 | 47 | /** 48 | * \struct sgui_d3d9_context 49 | * 50 | * \implements sgui_context 51 | * 52 | * \brief A Direct3D 9 context implementation 53 | */ 54 | typedef struct 55 | { 56 | #ifndef SGUI_DOXYGEN 57 | sgui_context super; 58 | #endif 59 | 60 | sgui_window* wnd; 61 | 62 | /** \brief A pointer to the Direct3D device structure */ 63 | IDirect3DDevice9* device; 64 | 65 | /** \brief The present parameters used */ 66 | D3DPRESENT_PARAMETERS present; 67 | } 68 | sgui_d3d9_context; 69 | 70 | 71 | 72 | #endif /* SGUI_D3D9_H */ 73 | 74 | -------------------------------------------------------------------------------- /core/include/sgui_predef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sgui_predef.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * \file sgui_predef.h 28 | * 29 | * \brief Contains forward declarations of all datatypes. 30 | */ 31 | #ifndef SGUI_PREDEF_H 32 | #define SGUI_PREDEF_H 33 | 34 | 35 | 36 | #include "sgui_config.h" 37 | #include 38 | 39 | 40 | 41 | #ifdef SGUI_WINDOWS 42 | #ifdef SGUI_BUILDING_DLL 43 | #define SGUI_DLL __declspec(dllexport) 44 | #else 45 | #define SGUI_DLL __declspec(dllimport) 46 | #endif 47 | #else 48 | #define SGUI_DLL 49 | #endif 50 | 51 | #ifdef _MSC_VER 52 | #define SGUI_INLINE __forceinline 53 | #define sgui_strdup _strdup 54 | #else 55 | #define SGUI_INLINE __inline__ __attribute__((always_inline)) 56 | #define sgui_strdup strdup 57 | #endif 58 | 59 | 60 | 61 | typedef struct sgui_icon sgui_icon; 62 | typedef struct sgui_icon_cache sgui_icon_cache; 63 | typedef struct sgui_font sgui_font; 64 | typedef struct sgui_rect sgui_rect; 65 | typedef struct sgui_canvas sgui_canvas; 66 | typedef struct sgui_widget sgui_widget; 67 | typedef struct sgui_window sgui_window; 68 | typedef struct sgui_pixmap sgui_pixmap; 69 | typedef struct sgui_skin sgui_skin; 70 | typedef struct sgui_context sgui_context; 71 | typedef struct sgui_event sgui_event; 72 | typedef struct sgui_window_description sgui_window_description; 73 | typedef struct sgui_model sgui_model; 74 | typedef struct sgui_item sgui_item; 75 | typedef struct sgui_dialog sgui_dialog; 76 | 77 | typedef void(* sgui_funptr )( ); 78 | 79 | 80 | 81 | #endif /* SGUI_PREDEF_H */ 82 | 83 | -------------------------------------------------------------------------------- /core/include/sgui_utf8.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sgui_utf8.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * \file sgui_utf8.h 28 | * 29 | * \brief Contains helper functions for UTF-8 string handling. 30 | */ 31 | #ifndef SGUI_UTF8_H 32 | #define SGUI_UTF8_H 33 | 34 | 35 | 36 | #include "sgui_predef.h" 37 | 38 | 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /** 45 | * \brief Get the unicode code point for a UTF8 encoded character 46 | * 47 | * \param utf8 A string holding the UTF8 character 48 | * \param length An optional pointer to an integer returning the length of the 49 | * UTF8 encoded character in bytes 50 | * 51 | * \return The decoded unicode code point 52 | */ 53 | SGUI_DLL unsigned int sgui_utf8_decode( const char* utf8, 54 | unsigned int* length ); 55 | 56 | /** 57 | * \brief Get the UTF8 encoding of a unicode code point 58 | * 59 | * \param cp The unicode code point 60 | * \param str A pointer to a buffer to write the UTF8 encoding to. Buffer 61 | * must be able to hold at least 4 bytes. 62 | * 63 | * \return The number of bytes written to the buffer 64 | */ 65 | SGUI_DLL unsigned int sgui_utf8_encode( unsigned int cp, char* str ); 66 | 67 | /** 68 | * \brief Get the number of characters in an UTF8 encoded string 69 | * 70 | * In a string using UTF8 encoding, the number of bytes does not have to match 71 | * the number of characters, as characters can be up to 6 bytes long (unless 72 | * you use plain ASCII which is part of UTF8). Using the regular strlen 73 | * function on such a string yields the number of bytes, excluding the null 74 | * terminator, but not the number of actual characters. 75 | * 76 | * \param utf8 A string using UTF8 encoding 77 | * 78 | * \return The number of actual characters in the string 79 | */ 80 | SGUI_DLL unsigned int sgui_utf8_strlen( const char* utf8 ); 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif /* SGUI_UTF8_H */ 87 | 88 | -------------------------------------------------------------------------------- /core/src/WIN32/direct3d11.h: -------------------------------------------------------------------------------- 1 | /* 2 | * direct3d11.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef SGUI_DIRECT3D11_H 26 | #define SGUI_DIRECT3D11_H 27 | 28 | #include "sgui_context.h" 29 | #include "sgui_internal.h" 30 | 31 | #ifndef SGUI_NO_D3D11 32 | #include "sgui_d3d11.h" 33 | #endif 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /* resize swapchain and depth/stencil buffer after window resize */ 40 | void d3d11_resize( sgui_context* ctx ); 41 | 42 | /* create a Direct3D 11 context context */ 43 | sgui_context* d3d11_context_create( sgui_window* wnd, 44 | const sgui_window_description* desc ); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif /* SGUI_DIRECT3D11_H */ 51 | 52 | -------------------------------------------------------------------------------- /core/src/WIN32/direct3d9.h: -------------------------------------------------------------------------------- 1 | /* 2 | * direct3d9.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef SGUI_DIRECT3D9_H 26 | #define SGUI_DIRECT3D9_H 27 | 28 | #include "sgui_context.h" 29 | #include "sgui_internal.h" 30 | 31 | #ifndef SGUI_NO_D3D9 32 | #include "sgui_d3d9.h" 33 | #endif 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /* create a Direct3D 9 context context */ 40 | sgui_context* d3d9_context_create( sgui_window* wnd, 41 | const sgui_window_description* desc ); 42 | 43 | void send_event_if_d3d9_lost( sgui_window* wnd ); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif /* SGUI_DIRECT3D9_H */ 50 | 51 | -------------------------------------------------------------------------------- /core/src/WIN32/font.h: -------------------------------------------------------------------------------- 1 | /* 2 | * font.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef W32_FONT_H 26 | #define W32_FONT_H 27 | 28 | #include 29 | #include FT_FREETYPE_H 30 | 31 | #include "sgui_font.h" 32 | 33 | #define SYS_FONT_PATH "C:\\Windows\\Fonts\\" 34 | 35 | typedef struct 36 | { 37 | sgui_font super; 38 | 39 | FT_Face face; 40 | void* buffer; 41 | unsigned int current_glyph; 42 | } 43 | sgui_w32_font; 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | int font_init( void ); 50 | 51 | void font_deinit( void ); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | #endif /* W32_FONT_H */ 58 | 59 | -------------------------------------------------------------------------------- /core/src/WIN32/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * internal.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef PLATFORM_H 26 | #define PLATFORM_H 27 | 28 | 29 | 30 | #include "sgui_skin.h" 31 | #include "sgui_canvas.h" 32 | #include "sgui_rect.h" 33 | #include "sgui_internal.h" 34 | #include "sgui_pixmap.h" 35 | 36 | #include "font.h" 37 | #include "window.h" 38 | #include "opengl.h" 39 | #include "direct3d9.h" 40 | #include "direct3d11.h" 41 | 42 | #define WIN32_LEAN_AND_MEAN 43 | #include 44 | 45 | #include 46 | #include 47 | #include 48 | 49 | #if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) ||\ 50 | defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64) 51 | 52 | #define SET_USER_PTR( hwnd, ptr )\ 53 | SetWindowLongPtrA( hwnd, GWLP_USERDATA, (LONG_PTR)ptr ) 54 | 55 | #define GET_USER_PTR( hwnd ) GetWindowLongPtrA( hwnd, GWLP_USERDATA ) 56 | #else 57 | #define SET_USER_PTR( hwnd, ptr )\ 58 | SetWindowLongA( hwnd, GWL_USERDATA, (LONG)ptr ) 59 | 60 | #define GET_USER_PTR( hwnd ) GetWindowLongA( hwnd, GWL_USERDATA ) 61 | #endif 62 | 63 | #ifndef MAPVK_VSC_TO_VK_EX 64 | #define MAPVK_VSC_TO_VK_EX 3 65 | #endif 66 | 67 | 68 | 69 | extern struct w32_state 70 | { 71 | HINSTANCE hInstance; /* instance handle */ 72 | const char* wndclass; /* window class name */ 73 | sgui_window_w32* list; /* global list of all windows */ 74 | CRITICAL_SECTION mutex; /* global sgui mutex */ 75 | char* clipboard; /* clipboard translaton buffer */ 76 | } 77 | w32; 78 | 79 | 80 | 81 | #ifdef __cplusplus 82 | extern "C" { 83 | #endif 84 | 85 | /* convert an UTF-8 string to UTF-16 */ 86 | WCHAR* utf8_to_utf16( const char* utf8, int rdbytes ); 87 | 88 | /* convert an UTF-16 string to UTF-8 */ 89 | char* utf16_to_utf8( WCHAR* utf16 ); 90 | 91 | /* implementation of the clipboard write function */ 92 | void w32_window_write_clipboard( sgui_window* wnd, const char* text, 93 | unsigned int length ); 94 | 95 | /* implementation of the clipboard read function */ 96 | const char* w32_window_read_clipboard( sgui_window* wnd ); 97 | 98 | /* add a window to the list used by the main loop */ 99 | void add_window( sgui_window_w32* wnd ); 100 | 101 | /* remove a window from the list used by the main loop */ 102 | void remove_window( sgui_window_w32* wnd ); 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | 108 | #endif /* PLATFORM_H */ 109 | 110 | -------------------------------------------------------------------------------- /core/src/WIN32/window.h: -------------------------------------------------------------------------------- 1 | /* 2 | * window.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef W32_WINDOW_H 26 | #define W32_WINDOW_H 27 | 28 | #include "sgui_internal.h" 29 | #include "sgui_window.h" 30 | 31 | #define TO_W32( window ) ((sgui_window_w32*)window) 32 | 33 | #define WIN32_LEAN_AND_MEAN 34 | #include 35 | 36 | 37 | 38 | typedef struct _sgui_window_w32 39 | { 40 | sgui_window super; 41 | 42 | HWND hWnd; 43 | HDC hDC; 44 | 45 | void* data; 46 | BITMAPINFO info; 47 | HBITMAP bitmap; 48 | HBRUSH bgbrush; 49 | 50 | struct _sgui_window_w32* next; 51 | } 52 | sgui_window_w32; 53 | 54 | 55 | 56 | #ifdef __cplusplus 57 | extern "C" { 58 | #endif 59 | 60 | /* in window.c: invalidate all dirty rects of the canvas */ 61 | void update_window( sgui_window_w32* wnd ); 62 | 63 | /* in window.c: handle window messages */ 64 | int handle_window_events( sgui_window_w32* wnd, UINT msg, 65 | WPARAM wp, LPARAM lp ); 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif /* W32_WINDOW_H */ 72 | 73 | -------------------------------------------------------------------------------- /core/src/X11/canvas.h: -------------------------------------------------------------------------------- 1 | /* 2 | * canvas.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef X11_CANVAS_H 26 | #define X11_CANVAS_H 27 | 28 | #include "sgui_canvas.h" 29 | #include "sgui_font_cache.h" 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include 37 | 38 | 39 | /* default size of the font cache pixmap */ 40 | #define FONT_MAP_WIDTH 256 41 | #define FONT_MAP_HEIGHT 256 42 | 43 | 44 | typedef struct sgui_canvas_x11 45 | { 46 | sgui_canvas super; 47 | Drawable wnd; 48 | 49 | sgui_icon_cache* cache; /* a font cache by the canvas */ 50 | 51 | void(* set_clip_rect )( struct sgui_canvas_x11* cv, 52 | int left, int top, int width, int height ); 53 | } 54 | sgui_canvas_x11; 55 | 56 | typedef struct 57 | { 58 | sgui_canvas_x11 super; 59 | Picture pic; 60 | 61 | Picture pen; 62 | Pixmap penmap; 63 | } 64 | sgui_canvas_xrender; 65 | 66 | typedef struct 67 | { 68 | sgui_canvas_x11 super; 69 | GC gc; 70 | unsigned char bg[4]; 71 | } 72 | sgui_canvas_xlib; 73 | 74 | #ifdef __cplusplus 75 | extern "C" { 76 | #endif 77 | 78 | sgui_canvas* canvas_x11_create( Drawable wnd, unsigned int width, 79 | unsigned int height, int sendexpose ); 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif /* X11_CANVAS_H */ 86 | 87 | -------------------------------------------------------------------------------- /core/src/X11/font.h: -------------------------------------------------------------------------------- 1 | /* 2 | * font.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef X11_FONT_H 26 | #define X11_FONT_H 27 | 28 | 29 | 30 | #include "sgui_font.h" 31 | 32 | #include 33 | #include FT_FREETYPE_H 34 | 35 | #ifdef SGUI_UNIX 36 | #define SYS_FONT_PATH "/usr/share/fonts/TTF/" 37 | #elif defined SGUI_WINDOWS 38 | #define SYS_FONT_PATH "C:\\Windows\\Fonts\\" 39 | #else 40 | #define NO_SYS_FONT_PATH 1 41 | #endif 42 | 43 | 44 | 45 | typedef struct 46 | { 47 | sgui_font super; 48 | FT_Face face; 49 | void* buffer; 50 | unsigned int current_glyph; 51 | } 52 | sgui_x11_font; 53 | 54 | 55 | 56 | #ifdef __cplusplus 57 | extern "C" { 58 | #endif 59 | 60 | /* called by sgui_init( ) to initialize the font rendering system */ 61 | int font_init( void ); 62 | 63 | /* called by sgui_deinit( ) to clean up the font rendering system */ 64 | void font_deinit( void ); 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif /* X11_FONT_H */ 71 | 72 | -------------------------------------------------------------------------------- /core/src/X11/keycode_translate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * keycode_translate.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef X11_KEYCODE_TRANSLATE_H 26 | #define X11_KEYCODE_TRANSLATE_H 27 | 28 | #include "sgui_keycodes.h" 29 | 30 | #include 31 | #include 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* initialise keycode symbol lookup table */ 38 | void init_keycodes( ); 39 | 40 | /* convert KeySym to an sgui key code */ 41 | int key_entries_translate( KeySym key ); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif /* X11_KEYCODE_TRANSLATE_H */ 48 | 49 | -------------------------------------------------------------------------------- /core/src/X11/opengl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * opengl.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef X11_OPENGL_H 26 | #define X11_OPENGL_H 27 | 28 | #include "sgui_window.h" 29 | #include "sgui_context.h" 30 | #include "sgui_internal.h" 31 | 32 | #include 33 | 34 | #ifndef SGUI_NO_OPENGL 35 | #include 36 | #endif 37 | 38 | #define LOAD_GLFUN( name ) glXGetProcAddress( (const GLubyte*)(name) ) 39 | 40 | #ifndef GLX_ARB_create_context 41 | #define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 42 | #define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 43 | #define GLX_CONTEXT_FLAGS_ARB 0x2094 44 | 45 | #define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001 46 | #define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 47 | #endif 48 | 49 | #ifndef GLX_ARB_create_context_profile 50 | #define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 51 | #define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 52 | #define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 53 | #endif 54 | 55 | #ifdef __cplusplus 56 | extern "C" { 57 | #endif 58 | 59 | /* set the GLXFBConfig of an sgui_xlib_window and create a window */ 60 | Window create_glx_window( sgui_window* wnd, 61 | const sgui_window_description* desc, 62 | Window parent ); 63 | 64 | /* create an OpenGL context for an Xlib window */ 65 | sgui_context* gl_context_create( sgui_window* wnd, int backend, 66 | sgui_context* share ); 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* X11_OPENGL_H */ 73 | 74 | -------------------------------------------------------------------------------- /core/src/X11/pixmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pixmap.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef X11_PIXMAP_H 26 | #define X11_PIXMAP_H 27 | 28 | 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include 36 | 37 | #include "sgui_pixmap.h" 38 | 39 | #include "canvas.h" 40 | 41 | 42 | 43 | typedef struct 44 | { 45 | sgui_pixmap super; 46 | 47 | Pixmap pix; 48 | Picture pic; 49 | } 50 | xrender_pixmap; 51 | 52 | typedef struct 53 | { 54 | sgui_pixmap super; 55 | int is_stencil; 56 | 57 | sgui_canvas_xlib* owner; 58 | 59 | union 60 | { 61 | Pixmap xpm; 62 | unsigned char* pixels; 63 | } 64 | data; 65 | } 66 | xlib_pixmap; 67 | 68 | 69 | 70 | #ifdef __cplusplus 71 | extern "C" { 72 | #endif 73 | 74 | /* create an xrender pixmap */ 75 | sgui_pixmap* xrender_pixmap_create( sgui_canvas* canvas, unsigned int width, 76 | unsigned int height, int format ); 77 | 78 | /* create an xlib pixmap */ 79 | sgui_pixmap* xlib_pixmap_create( sgui_canvas* cv, unsigned int width, 80 | unsigned int height, int format ); 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif /* X11_PIXMAP_H */ 87 | 88 | -------------------------------------------------------------------------------- /core/src/X11/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * platform.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef X11_PLATFORM_H 26 | #define X11_PLATFORM_H 27 | 28 | 29 | 30 | #include "sgui_skin.h" 31 | #include "sgui_rect.h" 32 | 33 | #include "opengl.h" 34 | #include "window.h" 35 | #include "canvas.h" 36 | #include "pixmap.h" 37 | #include "font.h" 38 | #include "keycode_translate.h" 39 | 40 | #include 41 | #include 42 | 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | #include 49 | 50 | 51 | #define DPY_WIDTH DisplayWidth( x11.dpy, x11.screen ) 52 | #define DPY_HEIGHT DisplayHeight( x11.dpy, x11.screen ) 53 | 54 | #define DOUBLE_CLICK_MS 750 55 | 56 | extern struct x11_state 57 | { 58 | XIM im; /* X11 input method */ 59 | Display* dpy; /* X11 Display connection */ 60 | Window root; /* root window */ 61 | int screen; /* default screen of root window */ 62 | 63 | char* clipboard_buffer; 64 | unsigned int clipboard_size; 65 | unsigned int clipboard_strlen; 66 | 67 | Atom atom_wm_delete; 68 | Atom atom_targets; 69 | Atom atom_text; 70 | Atom atom_pty; 71 | Atom atom_inc; 72 | Atom atom_UTF8; 73 | Atom atom_clipboard; 74 | 75 | sgui_window_xlib* clicked; /* last window clicked for double click */ 76 | unsigned long click_time; /* last click time for double click */ 77 | 78 | pthread_mutex_t mutex; /* global mutex */ 79 | 80 | sgui_window_xlib* list; /* internal list of Xlib windows */ 81 | } 82 | x11; 83 | 84 | #ifdef __cplusplus 85 | extern "C" { 86 | #endif 87 | 88 | /* implementation of window clipboard_write */ 89 | void xlib_window_clipboard_write( sgui_window* super, const char* text, 90 | unsigned int length ); 91 | 92 | /* implementation of window clipboard_read */ 93 | const char* xlib_window_clipboard_read( sgui_window* super ); 94 | 95 | /* add a window to the list for the main loop */ 96 | void add_window( sgui_window_xlib* window ); 97 | 98 | /* remove a window from the list */ 99 | void remove_window( sgui_window_xlib* window ); 100 | 101 | /* called from window.c when window is clicked, 102 | returns non-zero if double click */ 103 | int check_double_click( sgui_window_xlib* window ); 104 | 105 | /* called from window.c when mouse moves or 106 | otherwise interrupts double click */ 107 | void interrupt_double_click( void ); 108 | 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | 113 | #endif /* X11_PLATFORM_H */ 114 | 115 | -------------------------------------------------------------------------------- /core/src/X11/window.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * window.h 4 | * This file is part of sgui 5 | * 6 | * Copyright (C) 2012 - David Oberhollenzer 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a 9 | * copy of this software and associated documentation files (the "Software"), 10 | * to deal in the Software without restriction, including without limitation 11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | * and/or sell copies of the Software, and to permit persons to whom the 13 | * Software is furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | * DEALINGS IN THE SOFTWARE. 25 | */ 26 | #ifndef X11_WINDOW_H 27 | #define X11_WINDOW_H 28 | 29 | 30 | 31 | #include "sgui_internal.h" 32 | #include "sgui_window.h" 33 | 34 | #include "opengl.h" 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | 42 | 43 | #define TO_X11( window ) ((sgui_window_xlib*)window) 44 | #define IS_CHILD 0x8000 45 | #define X11_EVENT_MASK (ExposureMask|StructureNotifyMask|PointerMotionMask|\ 46 | KeyPressMask|FocusChangeMask|ButtonReleaseMask|\ 47 | KeyReleaseMask|PropertyChangeMask|ButtonPressMask) 48 | 49 | 50 | 51 | typedef struct _sgui_window_xlib 52 | { 53 | sgui_window super; 54 | 55 | Window wnd; 56 | XIC ic; 57 | 58 | unsigned int mouse_warped;/* mouse warp counter */ 59 | 60 | #ifndef SGUI_NO_OPENGL 61 | GLXFBConfig cfg; 62 | #endif 63 | 64 | struct _sgui_window_xlib* next; /* linked list stuff */ 65 | } 66 | sgui_window_xlib; 67 | 68 | 69 | #ifdef __cplusplus 70 | extern "C" { 71 | #endif 72 | 73 | /* process an XEvent */ 74 | void handle_window_events( sgui_window_xlib* wnd, XEvent* e ); 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif /* X11_WINDOW_H */ 81 | 82 | -------------------------------------------------------------------------------- /core/src/pixmap.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pixmap.c 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #define SGUI_BUILDING_DLL 26 | #include "sgui_pixmap.h" 27 | #include "sgui_internal.h" 28 | 29 | 30 | 31 | void sgui_pixmap_load( sgui_pixmap* this, int dstx, int dsty, 32 | const unsigned char* data, int srcx, int srcy, 33 | unsigned int width, unsigned int height, 34 | unsigned int scan, int format ) 35 | { 36 | int bpp = format==SGUI_RGBA8 ? 4 : 37 | (format==SGUI_RGB8 ? 3 : 1); 38 | 39 | if( !width || !height || srcx>=(int)scan ) 40 | return; 41 | 42 | if( dstx>=(int)this->width || dsty>=(int)this->height ) 43 | return; 44 | 45 | if( (srcx+width)>=scan ) 46 | width = scan - srcx; 47 | 48 | if( (dstx+width)>=this->width ) 49 | width = this->width - dstx; 50 | 51 | if( (dsty+height)>=this->height ) 52 | height = this->height - dsty; 53 | 54 | data += (srcy*scan + srcx) * bpp; 55 | this->load( this, dstx, dsty, data, scan, width, height, format ); 56 | } 57 | 58 | -------------------------------------------------------------------------------- /core/src/rect.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sgui_rect.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #define SGUI_BUILDING_DLL 26 | #include "sgui_internal.h" 27 | #include "sgui_rect.h" 28 | 29 | 30 | 31 | void sgui_rect_repair( sgui_rect* r ) 32 | { 33 | int temp; 34 | 35 | if( r->left > r->right ) 36 | { 37 | temp = r->left; 38 | r->left = r->right; 39 | r->right = temp; 40 | } 41 | 42 | if( r->top > r->bottom ) 43 | { 44 | temp = r->top; 45 | r->top = r->bottom; 46 | r->bottom = temp; 47 | } 48 | } 49 | 50 | void sgui_rect_set_size( sgui_rect* r, int left, int top, 51 | unsigned int width, unsigned int height ) 52 | { 53 | r->left = left; 54 | r->top = top; 55 | r->right = left + (int)width - 1; 56 | r->bottom = top + (int)height - 1; 57 | } 58 | 59 | int sgui_rect_get_intersection( sgui_rect* r, const sgui_rect* a, 60 | const sgui_rect* b ) 61 | { 62 | /* check if a is to the right or below b */ 63 | if( (a->left > b->right) || (a->top > b->bottom) ) 64 | goto fail; 65 | 66 | /* check if a is to the left or above b */ 67 | if( (a->right < b->left) || (a->bottom < b->top) ) 68 | goto fail; 69 | 70 | /* set the intersection rectangle */ 71 | if( r ) 72 | { 73 | r->left = MAX( a->left, b->left ); 74 | r->top = MAX( a->top, b->top ); 75 | r->right = MIN( a->right, b->right ); 76 | r->bottom = MIN( a->bottom, b->bottom ); 77 | } 78 | 79 | return 1; 80 | fail: 81 | if( r ) 82 | { 83 | r->left = r->top = r->bottom = r->right = 0; 84 | } 85 | return 0; 86 | } 87 | 88 | int sgui_rect_join( sgui_rect* acc, const sgui_rect* r, int only_if_touch ) 89 | { 90 | if( only_if_touch ) 91 | { 92 | if( r->left > acc->right || r->top > acc->bottom || 93 | r->right < acc->left || r->bottom < acc->top ) 94 | { 95 | return 0; 96 | } 97 | } 98 | 99 | acc->left = MIN( acc->left, r->left ); 100 | acc->top = MIN( acc->top, r->top ); 101 | acc->right = MAX( acc->right, r->right ); 102 | acc->bottom = MAX( acc->bottom, r->bottom ); 103 | return 1; 104 | } 105 | 106 | int sgui_rect_is_point_inside( const sgui_rect* r, int x, int y ) 107 | { 108 | return x>=r->left && x<=r->right && y>=r->top && y<=r->bottom; 109 | } 110 | 111 | -------------------------------------------------------------------------------- /core/src/utf8.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sgui_utf8.c 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #define SGUI_BUILDING_DLL 26 | #include "sgui_utf8.h" 27 | #include 28 | #include 29 | 30 | 31 | 32 | #define INVALID_CHARACTER 0xFFFD 33 | 34 | 35 | 36 | unsigned int sgui_utf8_decode( const char* utf8, unsigned int* length ) 37 | { 38 | unsigned int ch = 0, i = 0, len = 0; 39 | 40 | len = 1; 41 | ch = *(utf8++); 42 | 43 | if( (ch & 0xFE) == 0xFC ) { len = 6; ch &= 0x01; } 44 | else if( (ch & 0xFC) == 0xF8 ) { len = 5; ch &= 0x03; } 45 | else if( (ch & 0xF8) == 0xF0 ) { len = 4; ch &= 0x07; } 46 | else if( (ch & 0xF0) == 0xE0 ) { len = 3; ch &= 0x0F; } 47 | else if( (ch & 0xE0) == 0xC0 ) { len = 2; ch &= 0x1F; } 48 | 49 | for( i=1; i 0x10FFFF || cp==0xFFFE || cp==0xFEFF ) 70 | cp = INVALID_CHARACTER; 71 | 72 | /* UTF16 surrogate pairs */ 73 | if( cp>=0xD800 && cp<=0xDFFF ) 74 | cp = INVALID_CHARACTER; 75 | 76 | /* 0x00000080 - 0x000007FF: 110aaaaa 10bbbbbb */ 77 | if( cp < 0x800 ) 78 | { 79 | *(str++) = (0xC0 | (cp >> 6)); 80 | *(str++) = 0x80 | (cp & 0x3F); 81 | return 2; 82 | } 83 | 84 | /* 0x00000800 - 0x0000FFFF: 1110aaaa 10bbbbbb 10cccccc */ 85 | if( cp < 0x10000 ) 86 | { 87 | *(str++) = 0xE0 | (cp >> 12); 88 | *(str++) = 0x80 | ((cp >> 6) & 0x3F); 89 | *(str++) = 0x80 | (cp & 0x3F); 90 | return 3; 91 | } 92 | 93 | /* 0x00010000 - 0x0010FFFF: 11110aaa 10bbbbbb 10cccccc 10dddddd */ 94 | *(str++) = 0xF0 | (cp >> 18); 95 | *(str++) = 0x80 | ((cp >> 12) & 0x3F); 96 | *(str++) = 0x80 | ((cp >> 6) & 0x3F); 97 | *(str++) = 0x80 | (cp & 0x3F); 98 | return 4; 99 | } 100 | 101 | unsigned int sgui_utf8_strlen( const char* utf8 ) 102 | { 103 | unsigned int len; 104 | 105 | for( len=0; *utf8; ++utf8 ) 106 | { 107 | len += ((*utf8) & 0xC0)!=0x80; 108 | } 109 | 110 | return len; 111 | } 112 | 113 | -------------------------------------------------------------------------------- /dialogs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------- 2 | # This file is part of the sgui buildsystem. I, David Oberhollenzer, 3 | # author of this file hereby place the contents of this file into 4 | # the public domain. 5 | #-------------------------------------------------------------------- 6 | 7 | set( DIALOGS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/messagebox.c 8 | ${CMAKE_CURRENT_SOURCE_DIR}/src/messagebox_w32.c 9 | ${CMAKE_CURRENT_SOURCE_DIR}/src/messagebox_x11.c 10 | ${CMAKE_CURRENT_SOURCE_DIR}/src/color_dialog.c 11 | ${CMAKE_CURRENT_SOURCE_DIR}/src/dialog.c 12 | PARENT_SCOPE ) 13 | 14 | -------------------------------------------------------------------------------- /dialogs/include/sgui_color_dialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sgui_color_dialog.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * \file sgui_color_dialog.h 28 | * 29 | * \brief Contains the declarations of the color dialog implementation 30 | */ 31 | #ifndef SGUI_COLOR_DIALOG_H 32 | #define SGUI_COLOR_DIALOG_H 33 | 34 | 35 | 36 | #include "sgui_predef.h" 37 | 38 | 39 | 40 | /** 41 | * \struct sgui_color_dialog 42 | * 43 | * \extends sgui_dialog 44 | * 45 | * \brief A color selector dialog window 46 | * 47 | * \image html colorpicker.png "A color picker dialog" 48 | */ 49 | 50 | 51 | 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | 56 | /** 57 | * \brief Create a color dialog window 58 | * 59 | * \memberof sgui_color_dialog 60 | * 61 | * \param caption The caption to write onto the window 62 | * \param accept The text to write onto the accept button 63 | * \param reject The text to write onto the reject button 64 | * 65 | * \return A pointer to a new color dialog on success, NULL on failure 66 | */ 67 | SGUI_DLL sgui_dialog* sgui_color_dialog_create( const char* caption, 68 | const char* accept, 69 | const char* reject ); 70 | 71 | /** 72 | * \brief Change the currently selected color of a color dialog 73 | * 74 | * \memberof sgui_color_dialog 75 | * 76 | * \param dialog A pointer to a color dialog 77 | * \param rgba A pointer to a 4 component RGBA color vector 78 | */ 79 | SGUI_DLL void sgui_color_dialog_set_rgba( sgui_dialog* dialog, 80 | const unsigned char* rgba ); 81 | 82 | /** 83 | * \brief Change the currently selected color of a color dialog 84 | * 85 | * \memberof sgui_color_dialog 86 | * 87 | * \param dialog A pointer to a color dialog 88 | * \param hsva A pointer to a 4 component HSVA color vector 89 | */ 90 | SGUI_DLL void sgui_color_dialog_set_hsva( sgui_dialog* dialog, 91 | const unsigned char* hsva ); 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /* SGUI_COLOR_DIALOG_H */ 98 | 99 | -------------------------------------------------------------------------------- /dialogs/src/messagebox_w32.c: -------------------------------------------------------------------------------- 1 | /* 2 | * messagebox_w32.c 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #define SGUI_BUILDING_DLL 26 | #include "sgui_messagebox.h" 27 | 28 | #ifdef SGUI_WINDOWS 29 | #define WIN32_LEAN_AND_MEAN 30 | #include 31 | 32 | 33 | 34 | #ifndef SGUI_NO_NATIVE_MESSAGEBOX 35 | void sgui_message_box_emergency( const char* caption, const char* text ) 36 | { 37 | MessageBox( 0, text, caption, MB_OK|MB_ICONEXCLAMATION ); 38 | } 39 | #elif defined(SGUI_NOP_IMPLEMENTATIONS) 40 | void sgui_message_box_emergency( const char* caption, const char* text ) 41 | { 42 | (void)caption; 43 | (void)text; 44 | } 45 | #endif /* !SGUI_NO_NATIVE_MESSAGEBOX */ 46 | 47 | #endif /* SGUI_WINDOWS */ 48 | 49 | -------------------------------------------------------------------------------- /doc/dialogwins.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | SGUI - Using the SGUI library 4 | 5 | 6 | 7 | 8 |

SGUI

9 | 10 |

Using the SGUI library

11 | 12 |

Different types of dialog windows

13 | 14 | This page is supposed to give a short overview over the different kinds of 15 | dialog windows available in SGUI.
16 |
17 |
18 | 19 | 20 | 21 | 25 | 26 | 27 | 32 |
A simple message box that can display text, an icon and multiple 22 | buttons. An event when one of the buttons gets pressed 23 | (SGUI_MESSAGE_BOX_BUTTON*_EVENT). 24 |
A simple color picker that can be used to select a color in RGBA or 28 | HSVA color space. The events SGUI_COLOR_SELECTED_RGBA_EVENT and 29 | SGUI_COLOR_SELECTED_HSVA_EVENT are generated with the selected 30 | color as event argument when the user presses the accept button. 31 |
33 | 34 |
35 | Previous 36 | Back to index 37 | Next 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /doc/hacking.canvas.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | SGUI - Hacking SGUI 4 | 5 | 6 | 7 | 8 |

SGUI

9 | 10 |

Hacking SGUI

11 | 12 |

The canvas data structure

13 | 14 | Every window object has an instance of an sgui_canvas implementation. 15 | The canvas offers rendering functions with legacy-OpenGL® style begin-end 16 | functions.
17 |
18 | Widgets can be added to a canvas. The canvas keeps track of the widgets, 19 | receives events from the window that it redirects to the apropriate widgets, 20 | keeping track of focused widgets, etc...
21 |
22 | The canvas can also accumulate dirty rects from widgets that request 23 | redrawing. When asking the canvas to render widgets, it makes sure child 24 | widgets are rendered with their apropriate offsets and clipped in respect to 25 | their parents.
26 |
27 | This is all done by the interface functions in canvas.c. All an 28 | implementation of a canvas has to do is supplying the callbacks for 29 | drawing, which means: 30 |
    31 |
  • begin/end callbacks (optional) 32 |
  • clearing 33 |
  • drawing boxes 34 |
  • creating an instance of a pixmap implementation 35 |
  • blitting/blending pixmaps 36 |
  • drawing a one line text string with a specified font and color 37 |
38 | Clipping and offseting is taken care of by the interface functions, so the 39 | callbacks always get sane input with absolute coordinates, clipped to the 40 | size of the surface.
41 |
42 | When creating a canvas instance, sgui_canvas_init has to be 43 | used at first to initialize the super structure.
44 |
45 | A canvas implementation will also have to be able to create instances of the 46 | asociated sgui_pixmap implementation. A reference implementation that 47 | copies the pixel data to an internal buffer can be created using 48 | sgui_internal_mem_pixmap_create.
49 |
50 | When creating a new canvas implementation it is adviseable to take a look at 51 | the header files and other existing canvas implementations for details. 52 | 53 |
54 | Previous 55 | Back to index 56 | Next 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /doc/hacking.event.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | SGUI - Hacking SGUI 4 | 5 | 6 | 7 | 8 |

SGUI

9 | 10 |

Hacking SGUI

11 | 12 |

The event system internals

13 | 14 | The file sgui_event.h contains the declaration of the sgui_event 15 | data structure wich encapsulates every possible kind of event by specifying 16 | event source (window and widget), event type (integer ID) and 17 | an optional argument supplied by the source.
18 |
19 | The integer IDs specifying different event types are also declared in the same 20 | file (including widget events).
21 |
22 | Through the functions sgui_event_connect and 23 | sgui_event_disconnect it is possible to create signals-and-slots like 24 | event-action connections. The connections are internally stored in a linked 25 | list. The sgui_event_post function is used by widgets, canvases and 26 | the windows to post events to a global queue.
27 |
28 | The backend implementations use functions declared in sgui_internal.h 29 | to control the event queue: 30 |
    31 |
  • sgui_internal_reset_events is used to reset the entire event system 32 | to an initial state. It is used by both sgui_init and 33 | sgui_deinit to initialize and cleanup the event system. 34 |
  • sgui_internal_process_events is called by the main loop functions 35 | sgui_mail_loop and sgui_main_loop_step to fetch all 36 | events from the queue, look up matching connections from the list and 37 | call the registered callbacks. 38 |
39 | 40 |
41 | Previous 42 | Back to index 43 | Next 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /doc/hacking.font.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | SGUI - Hacking SGUI 4 | 5 | 6 | 7 | 8 |

SGUI

9 | 10 |

Hacking SGUI

11 | 12 |

Font rasterization

13 | 14 | The backend also has to supply an implementation of the sgui_font data 15 | structure. There are two functions in sgui_font.h that are implemented 16 | directly in the backend. One for loading an abstract font data structure from 17 | a file and one for loading it from memory.
18 |
19 | The implementations in the Windows® and X11 backends use the FreeType 20 | library to rasterize true type fonts, but one could also implement a simple, 21 | static font bitmap.
22 |
23 | The sgui_font abstract data structure supports the 24 | following operations: 25 |
    26 |
  • Resolve a unicode code point to a glyph from the in-memory representation. 27 |
  • Get the dimensions of a previously loaded glyph. 28 |
  • Get a pointer to a buffer containing the previously loaded, 29 | rasterized glyph. 30 |
31 | The font data structure is used by a canvas implementations to rasterize text. 32 | However, a canvas might also use an sgui_font_cache that caches glyph 33 | in an sgui_pixmap to minimize glyph loading and rasterizing and instead 34 | blend the already loaded glyphs. The font cache uses an RB-Tree internally to 35 | store loaded glyphs and their area on the cache pixmap. It only loads glyphs 36 | if they cannot be found in the tree. 37 | 38 |
39 | Previous 40 | Back to index 41 | Next 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /doc/hacking.skin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | SGUI - Hacking SGUI 4 | 5 | 6 | 7 | 8 |

SGUI

9 | 10 |

Hacking SGUI

11 | 12 |

The skinning system

13 | 14 | The SGUI widget implementations use functions declared in sgui_skin.h 15 | to actually draw the widgets or to get outlines of a typical widget type in 16 | order to determine their own geometry in the constructor. The functions 17 | (implemented in skin.c) internally redirect the calls to callbacks from 18 | the currently set sgui_skin structure. The gui skin is actually a set 19 | of hard coded functions that use the canvas drawing functions.
20 |
21 | The default skin is implemented in skin_default.c and exposed as a 22 | global variable.
23 |
24 | A new skin can be implemented fairly easily by simply implementing the skin 25 | structure callbacks. One could theoretically also extend the skin structure, 26 | and add a lua state object, so skin callbacks could be redirected to 27 | Lua code, dynamically loaded and compiled at runtime.
28 |
29 | In order to set a certain skin implementation, the function 30 | sgui_skin_set is used. If given a NULL argument, it resets the 31 | skin to default.
32 |
33 | Changing skins while widgets are still existing is generally bad, as widgets 34 | use skin information in their constructor to compute their outlines. 35 | 36 |
37 | Previous 38 | Back to index 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /doc/hacking.widget.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | SGUI - Hacking SGUI 4 | 5 | 6 | 7 | 8 |

SGUI

9 | 10 |

Hacking SGUI

11 | 12 |

The widget data structure

13 | 14 | A widget has an area that it occupies (parent relative), pointers to the 15 | parent widget and to the first child widget. Children are stored in a linked 16 | list, as there can be a variable numer of children, thus there is also a 17 | pointer to the next child on the current level.
18 |
19 | Other than that, a widget has a pointer to the canvas that it is currently 20 | attached to, a flag field on how the widget handles keyboard focus and a 21 | visibillity flag (non-zero if the widget should be drawn, zero if not).
22 |
23 | The widget structure has four interesting callback functions: 24 |
    25 |
  • A destroy callback holding a pointer to the destructor function 26 |
  • A draw callback that is used for rendering the widget 27 |
  • An event callback that is used to send an event to the widget 28 |
  • A state change callback that is called, when the widget visibillity 29 | or position changes, or when children get attached/removed, when the 30 | parent changes or when the canvas attachment changes. 31 |
32 | The child-parent tree handling, event propagation, etc is already implemented 33 | by the basic interface functions. To initialize the super structure, a derived 34 | data type can use the sgui_widget_init function.
35 |
36 | What a dervied widget has to do at minimum is to implement the beforementioned 37 | callbacks. Please note that in the draw callback, widgets normaly don't 38 | use the canvas drawing functions directly, but instead use the functions of 39 | the skinning subsystem.
40 |
41 | The flag field of the widget can contain the following flags: 42 |
    43 |
  • SGUI_FOCUS_ACCEPT The widget accepts keyboard focus. 44 |
  • SGUI_FOCUS_DRAW The canvas is allowed to draw a border around 45 | the widgets bounding box to indicate keyboard focus. 46 |
  • SGUI_FOCUS_DROP_ESC When the escape key is pressed, the canvas is 47 | allowed to remove keyboard focus from the widget. 48 |
  • SGUI_FOCUS_DROP_TAB When the tab key is pressed, the canvas is 49 | allowd to move focus to the next widget in focus order, which is 50 | determined using sgui_widget_find_next_focus 51 |
  • SGUI_WIDGET_VISIBLE This flag is set when the widget is visible. 52 |
53 | The focus order that the sgui_widget_find_next_focus function dictates 54 | depends on the order in which widgets are attached to their parent widget. 55 | The function tries to find a visible child widget which accepts focus. If it 56 | can't find any, it it moves on to the next widget on the current level of the 57 | hirarchy and repeates the process. If this is still unsuccessful, it goes to 58 | the next neightbour widget of the parent and repeates the entire process. If 59 | it reaches the root window without finding a widget that acceps focus, it 60 | gives up, in which case the canvas gives it another try by calling the 61 | function on the root window in order to find the first widget in the focus 62 | order. 63 |
64 |
65 | An example implementation of a small custum widget is given in the 66 | directory extras/widget.c. 67 | 68 |
69 | Previous 70 | Back to index 71 | Next 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /doc/hacking.window.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | SGUI - Hacking SGUI 4 | 5 | 6 | 7 | 8 |

SGUI

9 | 10 |

Hacking SGUI

11 | 12 |

The backend window system abstraction

13 | 14 | In the source directory of the core module, there is one subdirectory for each 15 | backend implementation. There is no backend loading, the library is compiled 16 | with exactely one active backend implementation.
17 |
18 | The functions sgui_init, sgui_deinit, sgui_main_loop and 19 | sgui_main_loop_step are implemented directly in the backend. The 20 | currently existing X11 and Windows® backend implement the functions in 21 | a file called platform.c.
22 |
23 | The init and deinit functions have to at least reset the event queue and the 24 | skinning system (sgui_skin_set( NULL ), 25 | sgui_interal_skin_deinit_default( ), 26 | sgui_internal_reset_events( )).
27 |
28 | The platform file typically also implements the functions 29 | sgui_internal_lock_mutex and sgui_internal_unlock_mutex that 30 | lock and unlock the global mutex.
31 |
32 |

The window implementation

33 | To create a window, the backend provides the function 34 | sgui_window_create_desc that creates a structure derived from 35 | sgui_window with the appropriate super callbacks set.
36 |
37 | If the backend supports hardware accelerated rendering contexts, there is at 38 | least one implementation of the sgui_context structure, declared in 39 | sgui_context.h. The different kinds of rendering contexts are 40 | enumerated in sgui_window.h.
41 |
42 | For convenience, the function sgui_internal_window_post_init can be 43 | used at the end of the window creation function to do typcial tasks like 44 | storing the window size and clearing the window canvas.
45 |
46 | When the window receives an event in the backend event processing function, 47 | the event has to be translated to an sgui_event (if possible) and sent 48 | to the sgui_internal_window_fire_event function that takes care of 49 | sending the event to the canvas, adding it to the event queue and tracking 50 | keyboard modifyers.
51 |
52 | As already mentioned, every window has an instance of an sgui_canvas 53 | implementation that manages widgets and supplies 2D rendering functions.
54 |
55 | If a backend doesn't have special drawing functions, it can use the memory 56 | canvas reference implementation that draws to a memory buffer. It can be 57 | created using sgui_memory_canvas_create.
58 |
59 | When creating a new implementation of a backend, it is adviseable to look at 60 | another existing backend implementation for details and hints. 61 | 62 |
63 | Previous 64 | Back to index 65 | Next 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /doc/images/button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/button.png -------------------------------------------------------------------------------- /doc/images/check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/check.png -------------------------------------------------------------------------------- /doc/images/children.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/children.png -------------------------------------------------------------------------------- /doc/images/cmake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/cmake.png -------------------------------------------------------------------------------- /doc/images/colorpicker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/colorpicker.png -------------------------------------------------------------------------------- /doc/images/coords.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/coords.png -------------------------------------------------------------------------------- /doc/images/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/edit.png -------------------------------------------------------------------------------- /doc/images/frame.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/frame.png -------------------------------------------------------------------------------- /doc/images/gldemo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/gldemo.png -------------------------------------------------------------------------------- /doc/images/glwidget.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/glwidget.png -------------------------------------------------------------------------------- /doc/images/group.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/group.png -------------------------------------------------------------------------------- /doc/images/iconview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/iconview.png -------------------------------------------------------------------------------- /doc/images/messagebox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/messagebox.png -------------------------------------------------------------------------------- /doc/images/progress.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/progress.png -------------------------------------------------------------------------------- /doc/images/sample1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/sample1.png -------------------------------------------------------------------------------- /doc/images/sample2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/sample2.png -------------------------------------------------------------------------------- /doc/images/shot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/shot1.png -------------------------------------------------------------------------------- /doc/images/shot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/shot2.png -------------------------------------------------------------------------------- /doc/images/slider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/slider.png -------------------------------------------------------------------------------- /doc/images/static.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/static.png -------------------------------------------------------------------------------- /doc/images/tab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/tab.png -------------------------------------------------------------------------------- /doc/images/tree.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AgentD/sgui/79eb7bf78aca8b6079cd2904eae5478b5cb793d7/doc/images/tree.dia -------------------------------------------------------------------------------- /doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | SGUI - index 4 | 5 | 6 | 7 |

SGUI

8 | 9 |

Index

10 |
    11 |
  1. Index
  2. 12 | 13 |
  3. Introduction
  4. 14 | 15 |
      16 |
    1. Supported platforms
    2. 17 |
    3. People involved
    4. 18 |
    5. Licensing
    6. 19 |
    20 | 21 |
  5. Compiling the SGUI library
  6. 22 | 23 |
  7. Using the SGUI library
  8. 24 | 25 |
      26 |
    1. Initialisation and the main loop
    2. 27 |
    3. Compiling
    4. 28 |
    5. Creating and using windows
    6. 29 |
    7. Creating and using widgets
    8. 30 |
    9. Event callbacks
    10. 31 |
    11. The widget coordinate system
    12. 32 |
    13. The widget hirarchy
    14. 33 |
    15. Different types of widgets available
    16. 34 |
    17. Different types of dialog windows
    18. 35 |
    19. Dialog Windows
    20. 36 |
    37 | 38 |
  9. Advanced usage
  10. 39 |
      40 |
    1. SGUI & OpenGL®
    2. 41 |
    3. SGUI & Direct3D®
    4. 42 |
    5. Using SGUI in multithreaded programs
    6. 43 |
    44 | 45 |
  11. Hacking SGUI
  12. 46 | 47 |
      48 |
    1. Crash course: Object orientation in C for C++ and Java people
    2. 49 |
    3. A typicall SGUI class
    4. 50 |
    5. Architectural overview
    6. 51 |
    7. Coding style
    8. 52 |
    9. The SGUI build system
    10. 53 |
    11. The event system internals
    12. 54 |
    13. The backend window system abstraction
    14. 55 |
    15. The canvas data structure
    16. 56 |
    17. Font rasterization
    18. 57 |
    19. The widget data structure
    20. 58 |
    21. The skinning system
    22. 59 |
    60 | 61 |
62 | 63 |
64 | Previous 65 | Back to index 66 | Next 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /doc/intro.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | SGUI - introduction 4 | 5 | 6 | 7 |

SGUI

8 | 9 |

Introduction

10 | 11 | 12 | 13 |
14 | 15 | SGUI is a small, simple, cross platform GUI library, written in plain 16 | ANSI C (C89), with the aim to create a simple, easy to use "just-works" GUI 17 | library for small applications and test programs that just need a simple GUI. 18 |
19 | Major design goals are simplicity, small code size and correctness (concerning 20 | the standards involved and memory leaks).
21 |
22 | Above you can see screenshots of the SGUI test program.
23 |
24 | The idea of creating a small GUI library emerged after being unsatisfied with 25 | the existing GUI libraries that tend to be extremely bloated, resource hungry, 26 | complicated and very slow on older systems.
27 |
28 | The project originally emerged from an Xlib play pen written out of plain 29 | boredomness in school. 30 | 31 |

Supported platforms

32 | 33 | So far, SGUI has a Windows® and an Xlib back end. The demo application has 34 | been successfully compiled and run under Wine, Windows® 98, XP, 7 (32bit 35 | and 64 bit), Ubuntu 32 bit, Arch 64 bit, CentOS 6 32 bit and 64 bit.
36 |
37 | The OpenGL® support of the library has been successfully used with 38 | variuous ATI and nVidia cards (proprietary implementation) as well an 39 | integrated Intel GPU (via Mesa and proprietary implementation). 40 | 41 |

People involved

42 | 43 | Currently, I, David Oberhollenzer, do everything around here. Suggestions for 44 | improvements, forks, pull requests, bug reports or other help are very 45 | welcome. 46 | 47 |

Licensing

48 | 49 | The SGUI library is made available under the following terms and conditions:
50 |
51 |
52 | Permission is hereby granted, free of charge, to any person obtaining a copy
53 | of this software and associated documentation files (the "Software"), to deal
54 | in the Software without restriction, including without limitation the rights
55 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
56 | copies of the Software, and to permit persons to whom the Software is
57 | furnished to do so, subject to the following conditions:
58 |
59 | The above copyright notice and this permission notice shall be included in
60 | all copies or substantial portions of the Software.
61 |
62 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
63 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
64 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
65 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
66 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
67 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
68 | THE SOFTWARE.
69 | 70 |
71 | Previous 72 | Back to index 73 | Next 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /doc/style.css: -------------------------------------------------------------------------------- 1 | p.code 2 | { 3 | border-width: 1px; 4 | border-spacing: 2px; 5 | border-style: solid; 6 | border-color: black; 7 | border-collapse: separate; 8 | background-color: #C0C0C0; 9 | } 10 | 11 | font.cpp 12 | { 13 | color: #0000FF 14 | } 15 | 16 | font.keyword 17 | { 18 | color: #0000FF 19 | } 20 | 21 | font.number 22 | { 23 | color: #D00000 24 | } 25 | 26 | font.string 27 | { 28 | color: #D00000 29 | } 30 | 31 | font.comment 32 | { 33 | color: #00A000 34 | } 35 | 36 | font.command 37 | { 38 | color: #ce5c00 39 | } 40 | 41 | -------------------------------------------------------------------------------- /doc/thread.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | SGUI - Advanced usage 4 | 5 | 6 | 7 | 8 |

SGUI

9 | 10 |

Advanced usage

11 | 12 |

Using SGUI in multithreaded programs

13 | 14 | There is not much to say here. All SGUI functions that alter object state use 15 | an internal global mutex to lock the entire library. It's not very effictient 16 | as some things could actually be done concurrently, but it should work as a 17 | simple way of ensuring thread safety and allow access to SGUI functions from 18 | different threads. At some point it is neccessary, as some backend APIs aren't 19 | thread safe.
20 |
21 | There are a few things to keep in mind, however: 22 |
    23 |
  • sgui_init, sgui_deinit, sgui_main_loop and sgui_main_loop_step have to be 24 | called from the same thread. 25 |
  • All event processing happens in the thread that the main loop runs in. 26 |
  • When an event callback is called, it has exclusive access to the entire 27 | library and runs in the thread that called sgui_main_loop. 28 |
29 | 30 | 31 | 32 |
33 | Previous 34 | Back to index 35 | Next 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /doc/using.events.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | SGUI - Using the SGUI library 4 | 5 | 6 | 7 | 8 |

SGUI

9 | 10 |

Using the SGUI library

11 | 12 |

Event callbacks

13 | 14 | The SGUI library provides two mechanisms for receiving events: 15 |
    16 |
  • Signals & slots like callback system. The library can be told to 17 | react to a specific event by calling a function on an object with 18 | given arguments (even arguments passed on by the event source). 19 |
  • Window callbacks can be registered directly to windows to receive 20 | notifications about window resize events, key press-release events, 21 | mouse movements, etc... concerning the window that it was registered to. 22 | Every window can have exactely one callback. 23 |
24 | 25 | Lets take a look at the first option to make our close button actually close 26 | the window.
27 |
28 | The sgui_event_connect function is used to connect an event with a 29 | response. We simply add this before calling sgui_init: 30 | 31 |

32 | ...
33 | sgui_event_connect( button, SGUI_BUTTON_OUT_EVENT, sgui_window_set_visible, wnd, SGUI_INT, SGUI_INVISIBLE );
34 | ...
35 |

36 | The first argument is the source of the event. In this case the button widget. 37 | The second argument is the specific event to react to, when triggered by the 38 | given souce.
39 |
40 | What follows is the function to call when reacting to the event, in our case 41 | we want to turn the window invisible, hence sgui_window_set_visible. The 42 | next argument is the object to use the function on, our window. 43 | SGUI_INT specifies, that an additional integer argument should be 44 | passed to the function. The additional integer argument is set to 45 | SGUI_INVISIBLE in order to thide the window.
46 |
47 | And that's it! That is everything required to connect the button click to the 48 | window close action. Or any other event to any other action for that matter. 49 |
50 |
51 |
52 |
53 | Now lets take a look at window callbacks. In our example, we want to print out 54 | every character entered while our window has focus. The function that does 55 | this, with the signature of sgui_window_callback is given below: 56 | 57 |

58 | void window_callback( void* user, const sgui_event* event )
59 | {
60 |     if( event->type == SGUI_CHAR_EVENT )
61 |     {
62 |         printf( "%s\n", event->arg.utf8 );
63 |     }
64 | }
65 |

66 | 67 | All that's left to do now is to register that callback to our window: 68 | 69 |

70 |     ...
71 |     sgui_window_on_event( wnd, window_callback );
72 |     ... 73 |

74 | 75 | Alternatively, the same thing could also be done this way: 76 | 77 |

78 | ...
79 | sgui_event_connect( wnd, SGUI_CHAR_EVENT, printf, "%s\n", SGUI_FROM_EVENT, SGUI_UTF8 );
80 | ...
81 |

82 | 83 |
84 | Previous 85 | Back to index 86 | Next 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /extras/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------- 2 | # This file is part of the sgui buildsystem. I, David Oberhollenzer, 3 | # author of this file hereby place the contents of this file into 4 | # the public domain. 5 | #-------------------------------------------------------------------- 6 | 7 | if( OPENGL ) 8 | add_executable( gl0 gl0.c ) 9 | add_executable( gl1 gl1.c ) 10 | add_executable( gl2 gl2.c ) 11 | add_executable( gl3 gl3.c ) 12 | add_executable( texcanvas texcanvas.c ) 13 | target_link_libraries( gl0 sgui ) 14 | target_link_libraries( gl1 sgui ) 15 | target_link_libraries( gl2 sgui ) 16 | target_link_libraries( gl3 sgui ) 17 | target_link_libraries( texcanvas sgui sguisubwm ) 18 | 19 | if( UNIX ) 20 | target_link_libraries( texcanvas m ) 21 | endif( ) 22 | endif( ) 23 | 24 | if( WIN32 AND DIRECT3D9 ) 25 | add_executable( d3d9_0 d3d9_0.c ) 26 | add_executable( d3d9_1 d3d9_1.c ) 27 | add_executable( d3d9_2 d3d9_2.c ) 28 | add_executable( d3d9_3 d3d9_3.c ) 29 | add_executable( texcanvas_d3d9 texcanvas_d3d9.c ) 30 | target_link_libraries( d3d9_0 sgui ) 31 | target_link_libraries( d3d9_1 sgui ) 32 | target_link_libraries( d3d9_2 sgui ) 33 | target_link_libraries( d3d9_3 sgui ) 34 | 35 | target_link_libraries( texcanvas_d3d9 sgui sguisubwm ) 36 | endif( ) 37 | 38 | if( WIN32 AND DIRECT3D11 ) 39 | add_executable( d3d11_0 d3d11_0.c ) 40 | add_executable( d3d11_1 d3d11_1.c ) 41 | add_executable( d3d11_2 d3d11_2.c ) 42 | add_executable( d3d11_3 d3d11_3.c ) 43 | add_executable( texcanvas_d3d11 texcanvas_d3d11.c ) 44 | target_link_libraries( d3d11_0 sgui d3dcompiler_43 ) 45 | target_link_libraries( d3d11_1 sgui d3dcompiler_43 ) 46 | target_link_libraries( d3d11_2 sgui d3dcompiler_43 ) 47 | target_link_libraries( d3d11_3 sgui d3dcompiler_43 ) 48 | target_link_libraries( texcanvas_d3d11 sgui sguisubwm d3dcompiler_43 ) 49 | endif( ) 50 | 51 | add_executable( demo demo.c ) 52 | add_executable( events events.c ) 53 | add_executable( simple simple.c ) 54 | add_executable( clipboard clipboard.c ) 55 | add_executable( widget widget.c ) 56 | add_executable( dialogs dialogs.c ) 57 | add_executable( ctx_wm ctx_wm.c ) 58 | 59 | target_link_libraries( demo sgui ) 60 | target_link_libraries( events sgui ) 61 | target_link_libraries( simple sgui ) 62 | target_link_libraries( clipboard sgui ) 63 | target_link_libraries( widget sgui ) 64 | target_link_libraries( dialogs sgui ) 65 | target_link_libraries( ctx_wm sgui sguisubwm ) 66 | 67 | if( UNIX ) 68 | target_link_libraries( ctx_wm m ) 69 | endif( ) 70 | 71 | add_executable( sguiicon sguiicon.c ) 72 | 73 | -------------------------------------------------------------------------------- /extras/clipboard.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the sgui samples collection. I, David Oberhollenzer, 3 | author of this file hereby place the contents of this file into 4 | the public domain. 5 | */ 6 | /* 7 | This small programm is supposed to demonstrate how the systems clipboard 8 | can be accessed through sgui. 9 | */ 10 | #include "sgui.h" 11 | 12 | #include 13 | #include 14 | 15 | 16 | 17 | void read_clipboard( sgui_window* wnd ) 18 | { 19 | const char* text = sgui_window_read_clipboard( wnd ); 20 | 21 | if( text ) 22 | puts( text ); 23 | } 24 | 25 | void write_clipboard( sgui_window* wnd, sgui_widget* editbox ) 26 | { 27 | const char* text = sgui_edit_box_get_text( editbox ); 28 | 29 | sgui_window_write_clipboard( wnd, text, strlen(text) ); 30 | } 31 | 32 | int main( void ) 33 | { 34 | sgui_window* wnd; 35 | sgui_widget* rb; 36 | sgui_widget* wb; 37 | sgui_widget* eb; 38 | 39 | sgui_init( ); 40 | 41 | /* create a window */ 42 | wnd = sgui_window_create( NULL, 320, 150, 0 ); 43 | 44 | sgui_window_set_title( wnd, "Clipboard" ); 45 | sgui_window_move_center( wnd ); 46 | sgui_window_set_visible( wnd, SGUI_VISIBLE ); 47 | 48 | /* create some widgets */ 49 | rb = sgui_button_create( 30, 30, 120, 30, "Read Clipboard", 0 ); 50 | wb = sgui_button_create( 30, 70, 120, 30, "Write Clipboard", 0 ); 51 | eb = sgui_edit_box_create( 160, 70, 120, 128 ); 52 | 53 | /* add widgets to the window */ 54 | sgui_window_add_widget( wnd, rb ); 55 | sgui_window_add_widget( wnd, wb ); 56 | sgui_window_add_widget( wnd, eb ); 57 | 58 | /* hook event callbacks */ 59 | sgui_event_connect( rb, SGUI_BUTTON_OUT_EVENT, 60 | read_clipboard, wnd, SGUI_VOID ); 61 | 62 | sgui_event_connect( wb, SGUI_BUTTON_OUT_EVENT, 63 | write_clipboard, wnd, SGUI_POINTER, eb ); 64 | 65 | /* main loop */ 66 | sgui_main_loop( ); 67 | 68 | /* clean up */ 69 | sgui_window_destroy( wnd ); 70 | sgui_widget_destroy( rb ); 71 | sgui_widget_destroy( wb ); 72 | sgui_widget_destroy( eb ); 73 | sgui_deinit( ); 74 | 75 | return 0; 76 | } 77 | 78 | -------------------------------------------------------------------------------- /extras/d3d9_0.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the sgui samples collection. I, David Oberhollenzer, 3 | author of this file hereby place the contents of this file into 4 | the public domain. 5 | */ 6 | /* 7 | This small programm is supposed to demonstrate how to create a window 8 | with a Direct3D 9 rendering context through sgui. 9 | */ 10 | #include "sgui.h" 11 | #include "sgui_d3d9.h" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | 18 | 19 | typedef struct 20 | { 21 | FLOAT x, y, z, rhw; 22 | DWORD color; 23 | } 24 | CUSTOMVERTEX; 25 | 26 | CUSTOMVERTEX vertices[] = 27 | { 28 | { 150.0f, 50.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(0, 0, 255) }, 29 | { 250.0f, 250.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(0, 255, 0) }, 30 | { 50.0f, 250.0f, 1.0f, 1.0f, D3DCOLOR_XRGB(255, 0, 0) } 31 | }; 32 | 33 | LPDIRECT3DVERTEXBUFFER9 v_buffer; 34 | 35 | #define CUSTOMFVF (D3DFVF_XYZRHW | D3DFVF_DIFFUSE) 36 | 37 | 38 | 39 | void draw_callback( sgui_window* window ) 40 | { 41 | /* get the context from the window */ 42 | sgui_d3d9_context* ctx = 43 | (sgui_d3d9_context*)sgui_window_get_context( window ); 44 | 45 | /* clear the screen, begin drawing */ 46 | IDirect3DDevice9_Clear( ctx->device, 0, NULL, D3DCLEAR_TARGET, 47 | D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0 ); 48 | 49 | IDirect3DDevice9_BeginScene( ctx->device ); 50 | 51 | /* draw the scene */ 52 | IDirect3DDevice9_SetFVF( ctx->device, CUSTOMFVF ); 53 | IDirect3DDevice9_SetStreamSource( ctx->device, 0, v_buffer, 0, 54 | sizeof(CUSTOMVERTEX) ); 55 | 56 | IDirect3DDevice9_DrawPrimitive( ctx->device, D3DPT_TRIANGLELIST, 0, 1 ); 57 | 58 | IDirect3DDevice9_EndScene( ctx->device ); 59 | 60 | /* swap front and back buffer */ 61 | sgui_window_swap_buffers( window ); 62 | } 63 | 64 | 65 | 66 | int main( void ) 67 | { 68 | sgui_window_description desc; 69 | IDirect3DDevice9* dev; 70 | sgui_context* ctx; 71 | sgui_window* wnd; 72 | VOID* pVoid; 73 | 74 | sgui_init( ); 75 | 76 | /* create a window. See gl0.c for furhter explanation */ 77 | desc.parent = NULL; 78 | desc.share = NULL; 79 | desc.width = 300; 80 | desc.height = 300; 81 | desc.flags = SGUI_FIXED_SIZE|SGUI_DOUBLEBUFFERED; 82 | desc.backend = SGUI_DIRECT3D_9; 83 | desc.bits_per_pixel = 32; 84 | desc.depth_bits = 16; 85 | desc.stencil_bits = 0; 86 | desc.samples = 0; 87 | 88 | wnd = sgui_window_create_desc( &desc ); 89 | 90 | /* make the window visible */ 91 | sgui_window_set_title( wnd, "Direct3D 9 Sample" ); 92 | sgui_window_move_center( wnd ); 93 | sgui_window_set_visible( wnd, SGUI_VISIBLE ); 94 | 95 | /* create a vertex buffer */ 96 | ctx = sgui_window_get_context( wnd ); 97 | dev = ctx->get_internal( ctx ); 98 | 99 | IDirect3DDevice9_CreateVertexBuffer( dev, 3*sizeof(CUSTOMVERTEX), 0, 100 | CUSTOMFVF, D3DPOOL_MANAGED, 101 | &v_buffer, NULL ); 102 | 103 | /* load vertex data */ 104 | IDirect3DVertexBuffer9_Lock( v_buffer, 0, 0, (void**)&pVoid, 0 ); 105 | memcpy( pVoid, vertices, sizeof(vertices) ); 106 | IDirect3DVertexBuffer9_Unlock( v_buffer ); 107 | 108 | /* hook event callbacks. See gl0.c for furhter explanation */ 109 | sgui_event_connect( wnd, SGUI_EXPOSE_EVENT, 110 | draw_callback, wnd, SGUI_VOID ); 111 | 112 | sgui_event_connect( wnd, SGUI_EXPOSE_EVENT, 113 | puts, "Readraw!", SGUI_VOID ); 114 | 115 | /* main loop */ 116 | sgui_main_loop( ); 117 | 118 | /* clean up */ 119 | IDirect3DVertexBuffer9_Release( v_buffer ); 120 | 121 | sgui_window_destroy( wnd ); 122 | sgui_deinit( ); 123 | 124 | return 0; 125 | } 126 | 127 | -------------------------------------------------------------------------------- /extras/gl0.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the sgui samples collection. I, David Oberhollenzer, 3 | author of this file hereby place the contents of this file into 4 | the public domain. 5 | */ 6 | /* 7 | This small programm is supposed to demonstrate how to create a window 8 | with a OpenGL rendering context through sgui. 9 | */ 10 | #include "sgui.h" 11 | 12 | #ifdef SGUI_WINDOWS 13 | #include 14 | #endif 15 | #include 16 | #include 17 | 18 | 19 | 20 | void draw_callback( sgui_window* window ) 21 | { 22 | unsigned int w, h; 23 | 24 | /* 25 | Make the OpenGL context of the window current. 26 | */ 27 | sgui_window_get_size( window, &w, &h ); 28 | sgui_window_make_current( window ); 29 | 30 | /* 31 | Draw a triangle. Rotate it a little, so we can 32 | notice window redraws. 33 | */ 34 | glViewport( 0, 0, w, h ); 35 | glClear( GL_COLOR_BUFFER_BIT ); 36 | 37 | glMatrixMode( GL_MODELVIEW ); 38 | glRotatef( 5.0f, 0.0f, 1.0f, 0.0f ); 39 | 40 | glBegin( GL_TRIANGLES ); 41 | glColor3f( 1.0f, 0.0f, 0.0f ); 42 | glVertex2f( -0.5f, -0.5f ); 43 | glColor3f( 0.0f, 1.0f, 0.0f ); 44 | glVertex2f( 0.5f, -0.5f ); 45 | glColor3f( 0.0f, 0.0f, 1.0f ); 46 | glVertex2f( 0.0f, 0.5f ); 47 | glEnd( ); 48 | 49 | /* 50 | Swap the front and back buffers of the window and 51 | release the OpenGL context again. 52 | */ 53 | sgui_window_swap_buffers( window ); 54 | sgui_window_release_current( window ); 55 | } 56 | 57 | 58 | 59 | int main( void ) 60 | { 61 | sgui_window* wnd; 62 | sgui_window_description desc; 63 | 64 | sgui_init( ); 65 | 66 | /* 67 | Create a window. 68 | 69 | Since we need to set a few "advanced" parameters, we use the 70 | sgui_window_create_desc function that takes a pointer to a window 71 | description structure. 72 | */ 73 | desc.parent = NULL; /* parent window pointer */ 74 | desc.share = NULL; /* window to share context data with */ 75 | desc.width = 300; 76 | desc.height = 300; 77 | desc.flags = SGUI_DOUBLEBUFFERED; 78 | desc.backend = SGUI_OPENGL_COMPAT; 79 | desc.bits_per_pixel = 32; 80 | desc.depth_bits = 16; 81 | desc.stencil_bits = 0; 82 | desc.samples = 0; 83 | 84 | wnd = sgui_window_create_desc( &desc ); 85 | 86 | /* set window title, move to center and make visible */ 87 | sgui_window_set_title( wnd, "OpenGL Sample" ); 88 | sgui_window_move_center( wnd ); 89 | sgui_window_set_visible( wnd, SGUI_VISIBLE ); 90 | 91 | /* 92 | A window with a rendering context object generates 93 | an SGUI_EXPOSE_EVENT every time the window systems 94 | aks the window to redraw itself. 95 | 96 | Redirect the redraw request to our redraw callback 97 | and print a string to show that we are redrawing. 98 | */ 99 | sgui_event_connect( wnd, SGUI_EXPOSE_EVENT, 100 | draw_callback, wnd, SGUI_VOID ); 101 | 102 | sgui_event_connect( wnd, SGUI_EXPOSE_EVENT, 103 | puts, "Readraw!", SGUI_VOID ); 104 | 105 | /* main loop */ 106 | sgui_main_loop( ); 107 | 108 | /* clean up */ 109 | sgui_window_release_current( wnd ); 110 | sgui_window_destroy( wnd ); 111 | sgui_deinit( ); 112 | 113 | return 0; 114 | } 115 | 116 | -------------------------------------------------------------------------------- /extras/gl1.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the sgui samples collection. I, David Oberhollenzer, 3 | author of this file hereby place the contents of this file into 4 | the public domain. 5 | */ 6 | /* 7 | This small programm is supposed to demonstrate how to create a window 8 | with a OpenGL rendering context through sgui and how to use a manual 9 | event/drawing loop for real-time rendering applications. 10 | */ 11 | #include "sgui.h" 12 | 13 | #ifdef SGUI_WINDOWS 14 | #include 15 | #endif 16 | #include 17 | #include 18 | 19 | 20 | 21 | int main( void ) 22 | { 23 | sgui_window* wnd; 24 | sgui_window_description desc; 25 | 26 | sgui_init( ); 27 | 28 | /* create a window */ 29 | desc.parent = NULL; 30 | desc.share = NULL; 31 | desc.width = 300; 32 | desc.height = 300; 33 | desc.flags = SGUI_FIXED_SIZE|SGUI_DOUBLEBUFFERED; 34 | desc.backend = SGUI_OPENGL_COMPAT; 35 | desc.bits_per_pixel = 32; 36 | desc.depth_bits = 16; 37 | desc.stencil_bits = 0; 38 | desc.samples = 0; 39 | 40 | wnd = sgui_window_create_desc( &desc ); 41 | 42 | /* set window title and make it visible */ 43 | sgui_window_set_title( wnd, "OpenGL Sample" ); 44 | sgui_window_move_center( wnd ); 45 | sgui_window_set_visible( wnd, SGUI_VISIBLE ); 46 | 47 | /* 48 | Make the rendering context of the window current and force the 49 | window to synchronize buffer swapping with vertical retrace. 50 | */ 51 | sgui_window_make_current( wnd ); 52 | sgui_window_set_vsync( wnd, 1 ); 53 | 54 | /* 55 | Enter a manuall drawing loop. 56 | 57 | The function sgui_main_loop_step( ) fetches a message from the window 58 | systems, processes it and flushes the internal message queue. 59 | 60 | The function does not wait for system messages and returns 61 | immediately, even if there were no messages. 62 | 63 | If at least one window is visible, the function returns non-zero. It 64 | returns zero after the last window got set invisible. 65 | */ 66 | while( sgui_main_loop_step( ) ) 67 | { 68 | /* draw a triangle, rotate it a bit every frame */ 69 | glClear( GL_COLOR_BUFFER_BIT ); 70 | 71 | glMatrixMode( GL_MODELVIEW ); 72 | glRotatef( 5.0f, 0.0f, 1.0f, 0.0f ); 73 | 74 | glBegin( GL_TRIANGLES ); 75 | glColor3f( 1.0f, 0.0f, 0.0f ); 76 | glVertex2f( -0.5f, -0.5f ); 77 | glColor3f( 0.0f, 1.0f, 0.0f ); 78 | glVertex2f( 0.5f, -0.5f ); 79 | glColor3f( 0.0f, 0.0f, 1.0f ); 80 | glVertex2f( 0.0f, 0.5f ); 81 | glEnd( ); 82 | 83 | /* swap the front and back buffers */ 84 | sgui_window_swap_buffers( wnd ); 85 | } 86 | 87 | /* clean up */ 88 | sgui_window_release_current( wnd ); 89 | sgui_window_destroy( wnd ); 90 | sgui_deinit( ); 91 | 92 | return 0; 93 | } 94 | 95 | -------------------------------------------------------------------------------- /extras/gl2.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of the sgui samples collection. I, David Oberhollenzer, 3 | author of this file hereby place the contents of this file into 4 | the public domain. 5 | */ 6 | /* 7 | This small programm is supposed to demonstrate how to create a window 8 | an embedded OpenGL rendering widget through sgui. 9 | */ 10 | #include "sgui.h" 11 | 12 | #include 13 | 14 | #ifdef SGUI_WINDOWS 15 | #include 16 | #endif 17 | #include 18 | 19 | 20 | 21 | void glview_on_draw( sgui_widget* glview ) 22 | { 23 | unsigned int w, h; 24 | 25 | sgui_widget_get_size( glview, &w, &h ); 26 | 27 | glViewport( 0, 0, w, h ); 28 | glClear( GL_COLOR_BUFFER_BIT ); 29 | 30 | glMatrixMode( GL_MODELVIEW ); 31 | glRotatef( 5.0f, 0.0f, 1.0f, 0.0f ); 32 | 33 | glBegin( GL_TRIANGLES ); 34 | glColor3f( 1.0f, 0.0f, 0.0f ); 35 | glVertex2f( -0.5f, -0.5f ); 36 | glColor3f( 0.0f, 1.0f, 0.0f ); 37 | glVertex2f( 0.5f, -0.5f ); 38 | glColor3f( 0.0f, 0.0f, 1.0f ); 39 | glVertex2f( 0.0f, 0.5f ); 40 | glEnd( ); 41 | } 42 | 43 | int main( void ) 44 | { 45 | sgui_window* wnd; 46 | sgui_widget* button; 47 | sgui_widget* text; 48 | sgui_widget* gl_view; 49 | 50 | sgui_init( ); 51 | 52 | /* create a normal window and make it visible */ 53 | wnd = sgui_window_create( NULL, 200, 200, SGUI_FIXED_SIZE ); 54 | 55 | sgui_window_set_title( wnd, "OpenGL widget" ); 56 | sgui_window_move_center( wnd ); 57 | sgui_window_set_visible( wnd, SGUI_VISIBLE ); 58 | 59 | /* create some widgets */ 60 | text = sgui_label_create(10, 130, "OpenGL\302\256 subview widget"); 61 | button = sgui_button_create( 10, 155, 75, 30, "Refresh", 0 ); 62 | 63 | /* 64 | Create a sub view widget. The sub-view widget manages a sub-window. 65 | 66 | The first argument is the parent window. The second and third 67 | arguments are the position of the sub view widget (10,10), followed 68 | by the size of the sub-window (180x120). 69 | 70 | The sixth argument is the window backend to use (OpenGL compatibillity 71 | profile). 72 | 73 | The last argument would allow us to supply a supply a window 74 | description structure for more fine grained controll. We don't 75 | use this, so we set it to NULL. 76 | */ 77 | gl_view = sgui_subview_create( wnd, 10, 10, 180, 120, 78 | SGUI_OPENGL_COMPAT, NULL ); 79 | 80 | /* 81 | The sub-view widget has a callback that it calls when the 82 | window it manages wants to be redrawn. 83 | */ 84 | sgui_subview_set_draw_callback( gl_view, glview_on_draw ); 85 | 86 | /* 87 | The functon sgui_subview_refresh forces the window of the 88 | sub-view to redraw itself. 89 | */ 90 | sgui_event_connect( button, SGUI_BUTTON_OUT_EVENT, 91 | sgui_subview_refresh, gl_view, SGUI_VOID ); 92 | 93 | /* add widgets to the window */ 94 | sgui_window_add_widget( wnd, text ); 95 | sgui_window_add_widget( wnd, button ); 96 | sgui_window_add_widget( wnd, gl_view ); 97 | 98 | /* main loop */ 99 | sgui_main_loop( ); 100 | 101 | /* clean up */ 102 | sgui_window_destroy( wnd ); 103 | sgui_widget_destroy( gl_view ); 104 | sgui_widget_destroy( text ); 105 | sgui_widget_destroy( button ); 106 | sgui_deinit( ); 107 | 108 | return 0; 109 | } 110 | 111 | -------------------------------------------------------------------------------- /sgui_config.in: -------------------------------------------------------------------------------- 1 | /* 2 | * sgui_config.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef SGUI_CONFIG_H 26 | #define SGUI_CONFIG_H 27 | 28 | 29 | 30 | /* defined if no floatingpoint calculations should be used */ 31 | #cmakedefine SGUI_NO_FLOAT 32 | 33 | /* defined if Direct3D 9 support is disabled */ 34 | #cmakedefine SGUI_NO_D3D9 35 | 36 | /* defined if Direct3D 11 support is disabled */ 37 | #cmakedefine SGUI_NO_D3D11 38 | 39 | /* defined if OpenGL support is disabled */ 40 | #cmakedefine SGUI_NO_OPENGL 41 | 42 | /* defined if the message box is disabled */ 43 | #cmakedefine SGUI_NO_MESSAGEBOX 44 | 45 | /* defined if native message boxes are disabled */ 46 | #cmakedefine SGUI_NO_NATIVE_MESSAGEBOX 47 | 48 | /* defined if icon cache is disabled */ 49 | #cmakedefine SGUI_NO_ICON_CACHE 50 | 51 | /* defined if icon view widget is disabled */ 52 | #cmakedefine SGUI_NO_ICON_VIEW 53 | 54 | /* defined if subview widget is disabled */ 55 | #cmakedefine SGUI_NO_SUBVIEW 56 | 57 | /* defined if tab and tab group widgets are disabled */ 58 | #cmakedefine SGUI_NO_TABS 59 | 60 | /* defined if frame widget is disabled */ 61 | #cmakedefine SGUI_NO_FRAME 62 | 63 | /* defined if group box widget is disabled */ 64 | #cmakedefine SGUI_NO_GROUP_BOX 65 | 66 | /* defined if color picke is disabled */ 67 | #cmakedefine SGUI_NO_COLOR_PICKER 68 | 69 | /* defined if color dialog is disabled */ 70 | #cmakedefine SGUI_NO_COLOR_DIALOG 71 | 72 | /* defined if MVC data structures are disabled */ 73 | #cmakedefine SGUI_NO_MODEL 74 | 75 | /* defined if non-implemented functions should be replaced by NOPs */ 76 | #cmakedefine SGUI_NOP_IMPLEMENTATIONS 77 | 78 | /* defined if memory canvas is disabled */ 79 | #cmakedefine SGUI_NO_MEM_CANVAS 80 | 81 | /* set if compiling for MS windows */ 82 | #cmakedefine SGUI_WINDOWS 83 | 84 | /* set if compiling for a Unix like system (not defined for OS X) */ 85 | #cmakedefine SGUI_UNIX 86 | 87 | /* set if compiling for Mac OS X */ 88 | #cmakedefine SGUI_OSX 89 | 90 | /* set if X11 backend should not use the Xrender API */ 91 | #cmakedefine SGUI_NO_XRENDER 92 | 93 | /* static maximum of canvas dirty rects */ 94 | #define SGUI_CANVAS_MAX_DIRTY 10 95 | 96 | 97 | 98 | #endif /* SGUI_CONFIG_H */ 99 | 100 | -------------------------------------------------------------------------------- /subwm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------- 2 | # This file is part of the sgui buildsystem. I, David Oberhollenzer, 3 | # author of this file hereby place the contents of this file into 4 | # the public domain. 5 | #-------------------------------------------------------------------- 6 | 7 | if( WIN32 AND DIRECT3D9 ) 8 | set( SUBWM_OS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/D3D9/d3d9_canvas.c 9 | ${CMAKE_CURRENT_SOURCE_DIR}/src/D3D9/d3d9_wm.c ) 10 | endif( ) 11 | 12 | if( WIN32 AND DIRECT3D11 ) 13 | set( SUBWM_OS_SRC ${SUBWM_OS_SRC} 14 | ${CMAKE_CURRENT_SOURCE_DIR}/src/D3D11/d3d11_canvas.c 15 | ${CMAKE_CURRENT_SOURCE_DIR}/src/D3D11/d3d11_wm.c ) 16 | endif( ) 17 | 18 | set( SUBWM_OS_SRC ${SUBWM_OS_SRC} 19 | ${CMAKE_CURRENT_SOURCE_DIR}/src/GL/gl_canvas.c 20 | ${CMAKE_CURRENT_SOURCE_DIR}/src/GL/gl_wm.c ) 21 | 22 | set( SUBWM_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/tex_canvas.c 23 | ${CMAKE_CURRENT_SOURCE_DIR}/src/ctx_window.c 24 | ${CMAKE_CURRENT_SOURCE_DIR}/src/ctx_wm.c 25 | ${CMAKE_CURRENT_SOURCE_DIR}/src/skin.c 26 | ${CMAKE_CURRENT_SOURCE_DIR}/src/ctx_mesh.c 27 | ${SUBWM_OS_SRC} 28 | PARENT_SCOPE ) 29 | 30 | -------------------------------------------------------------------------------- /subwm/include/sgui_subwm_predef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sgui_subwm_predef.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | /** 26 | * \file sgui_subwm_predef.h 27 | * 28 | * \brief Forwad declarations for the sgui subwm library 29 | */ 30 | #ifndef SGUI_SUBWM_PREDEF_H 31 | #define SGUI_SUBWM_PREDEF_H 32 | 33 | 34 | 35 | #include "sgui_predef.h" 36 | 37 | 38 | 39 | typedef struct sgui_tex_canvas sgui_tex_canvas; 40 | typedef struct sgui_ctx_window sgui_ctx_window; 41 | typedef struct sgui_ctx_wm sgui_ctx_wm; 42 | typedef struct sgui_subwm_skin sgui_subwm_skin; 43 | 44 | 45 | 46 | #endif /* SGUI_SUBWM_PREDEF_H */ 47 | 48 | -------------------------------------------------------------------------------- /subwm/src/D3D11/d3d11_canvas.h: -------------------------------------------------------------------------------- 1 | /* 2 | * d3d11_canvas.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef D3D11_CANVAS_H 26 | #define D3D11_CANVAS_H 27 | 28 | 29 | 30 | #include "sgui_tex_canvas.h" 31 | #include "sgui_context.h" 32 | #include "sgui_canvas.h" 33 | 34 | 35 | 36 | #if !defined(SGUI_NO_D3D11) && defined(SGUI_WINDOWS) 37 | #include "sgui_d3d11.h" 38 | 39 | 40 | 41 | typedef struct 42 | { 43 | sgui_tex_canvas super; 44 | 45 | sgui_rect locked; 46 | unsigned char* buffer; 47 | ID3D11Texture2D* tex; 48 | ID3D11DeviceContext* ctx; 49 | } 50 | sgui_d3d11_canvas; 51 | 52 | 53 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | sgui_canvas* sgui_d3d11_canvas_create( sgui_context* ctx, 59 | unsigned width, unsigned int height ); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif /* !SGUI_NO_D3D11 && SGUI_WINDOWS */ 66 | 67 | #endif /* D3D11_CANVAS_H */ 68 | 69 | -------------------------------------------------------------------------------- /subwm/src/D3D11/d3d11_wm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * d3d11_wm.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef D3D11_WM_H 26 | #define D3D11_WM_H 27 | 28 | 29 | 30 | #include "sgui_predef.h" 31 | 32 | 33 | 34 | #if defined(SGUI_WINDOWS) && !defined(SGUI_NO_D3D11) 35 | #include "sgui_ctx_window.h" 36 | #include "sgui_window.h" 37 | #include "sgui_ctx_wm.h" 38 | #include "sgui_d3d11.h" 39 | 40 | 41 | 42 | typedef struct 43 | { 44 | sgui_ctx_wm super; 45 | ID3D11Texture2D* skintex; 46 | ID3D11SamplerState* sampler; 47 | ID3D11ShaderResourceView* view; 48 | } 49 | sgui_d3d11_wm; 50 | 51 | 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | sgui_ctx_wm* d3d11_wm_create( sgui_window* wnd ); 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif /* SGUI_WINDOWS && !SGUI_NO_D3D11 */ 64 | 65 | #endif /* D3D11_WM_H */ 66 | 67 | -------------------------------------------------------------------------------- /subwm/src/D3D9/d3d9_canvas.c: -------------------------------------------------------------------------------- 1 | /* 2 | * d3d9_canvas.c 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #include "d3d9_canvas.h" 26 | 27 | 28 | 29 | #if !defined(SGUI_NO_D3D9) && defined(SGUI_WINDOWS) 30 | void* d3d9_canvas_get_texture( sgui_canvas* this ) 31 | { 32 | return ((sgui_d3d9_canvas*)this)->tex; 33 | } 34 | 35 | void d3d9_canvas_destroy( sgui_canvas* this ) 36 | { 37 | IDirect3DTexture9_Release( ((sgui_d3d9_canvas*)this)->tex ); 38 | free( this ); 39 | } 40 | 41 | int d3d9_canvas_begin( sgui_canvas* super, sgui_rect* r ) 42 | { 43 | sgui_d3d9_canvas* this = (sgui_d3d9_canvas*)super; 44 | D3DLOCKED_RECT lr; 45 | HRESULT status; 46 | RECT wr; 47 | 48 | wr.left = r->left; 49 | wr.top = r->top; 50 | wr.right = r->right; 51 | wr.bottom = r->bottom; 52 | 53 | status = IDirect3DTexture9_LockRect( this->tex, 0, &lr, &wr, 0 ); 54 | 55 | if( status!=D3D_OK ) 56 | return 0; 57 | 58 | ((sgui_mem_canvas*)this)->data = lr.pBits; 59 | ((sgui_mem_canvas*)this)->startx = r->left; 60 | ((sgui_mem_canvas*)this)->starty = r->top; 61 | ((sgui_mem_canvas*)this)->pitch = lr.Pitch; 62 | return 1; 63 | } 64 | 65 | void d3d9_canvas_end( sgui_canvas* super ) 66 | { 67 | sgui_d3d9_canvas* this = (sgui_d3d9_canvas*)super; 68 | 69 | IDirect3DTexture9_UnlockRect( this->tex, 0 ); 70 | } 71 | 72 | 73 | 74 | sgui_canvas* sgui_d3d9_canvas_create( sgui_context* ctx, 75 | unsigned width, unsigned int height ) 76 | { 77 | sgui_d3d9_canvas* this = calloc( 1, sizeof(sgui_d3d9_canvas) ); 78 | sgui_d3d9_context* ctx9 = (sgui_d3d9_context*)ctx; 79 | HRESULT status; 80 | 81 | if( !this ) 82 | return NULL; 83 | 84 | /* initialize base structure */ 85 | if( !sgui_memory_canvas_init( (sgui_canvas*)this, NULL, 86 | width, height, SGUI_RGBA8, 1 ) ) 87 | { 88 | free( this ); 89 | return NULL; 90 | } 91 | 92 | /* create a texture */ 93 | status = IDirect3DDevice9_CreateTexture( ctx9->device, width, height, 1, 94 | D3DUSAGE_DYNAMIC, 95 | D3DFMT_A8R8G8B8, 96 | D3DPOOL_SYSTEMMEM, 97 | &this->tex, NULL ); 98 | 99 | if( status != D3D_OK ) 100 | { 101 | free( this ); 102 | return NULL; 103 | } 104 | 105 | /* hook callbacks */ 106 | ((sgui_tex_canvas*)this)->get_texture = d3d9_canvas_get_texture; 107 | ((sgui_canvas*)this)->destroy = d3d9_canvas_destroy; 108 | ((sgui_canvas*)this)->begin = d3d9_canvas_begin; 109 | ((sgui_canvas*)this)->end = d3d9_canvas_end; 110 | 111 | return (sgui_canvas*)this; 112 | } 113 | #endif 114 | 115 | -------------------------------------------------------------------------------- /subwm/src/D3D9/d3d9_canvas.h: -------------------------------------------------------------------------------- 1 | /* 2 | * d3d9_canvas.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef D3D9_CANVAS_H 26 | #define D3D9_CANVAS_H 27 | 28 | 29 | 30 | #include "sgui_tex_canvas.h" 31 | #include "sgui_context.h" 32 | #include "sgui_canvas.h" 33 | 34 | 35 | 36 | #if !defined(SGUI_NO_D3D9) && defined(SGUI_WINDOWS) 37 | #include "sgui_d3d9.h" 38 | 39 | 40 | 41 | typedef struct 42 | { 43 | sgui_tex_canvas super; 44 | IDirect3DTexture9* tex; 45 | } 46 | sgui_d3d9_canvas; 47 | 48 | 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | sgui_canvas* sgui_d3d9_canvas_create( sgui_context* ctx, 55 | unsigned width, unsigned int height ); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* !SGUI_NO_D3D9 && SGUI_WINDOWS */ 62 | 63 | #endif /* D3D9_CANVAS_H */ 64 | 65 | -------------------------------------------------------------------------------- /subwm/src/D3D9/d3d9_wm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * d3d9_wm.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef D3D9_WM_H 26 | #define D3D9_WM_H 27 | 28 | 29 | 30 | #include "sgui_predef.h" 31 | 32 | 33 | 34 | #if defined(SGUI_WINDOWS) && !defined(SGUI_NO_D3D9) 35 | #include "sgui_ctx_window.h" 36 | #include "sgui_window.h" 37 | #include "sgui_ctx_wm.h" 38 | #include "sgui_d3d9.h" 39 | 40 | 41 | 42 | typedef struct 43 | { 44 | sgui_ctx_wm super; 45 | IDirect3DTexture9* skintex; 46 | } 47 | sgui_d3d9_wm; 48 | 49 | typedef struct 50 | { 51 | FLOAT x, y, z, rhw; 52 | DWORD color; 53 | FLOAT u, v; 54 | } 55 | WINDOWVERTEX; 56 | 57 | #define WINDOWFVF (D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1) 58 | 59 | 60 | 61 | #ifdef __cplusplus 62 | extern "C" { 63 | #endif 64 | 65 | sgui_ctx_wm* d3d9_wm_create( sgui_window* wnd ); 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif /* SGUI_WINDOWS && !SGUI_NO_D3D9 */ 72 | 73 | #endif /* D3D9_WM_H */ 74 | 75 | -------------------------------------------------------------------------------- /subwm/src/GL/gl_canvas.h: -------------------------------------------------------------------------------- 1 | /* 2 | * gl_canvas.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef GL_CANVAS_H 26 | #define GL_CANVAS_H 27 | 28 | 29 | 30 | #include "sgui_tex_canvas.h" 31 | #include "sgui_canvas.h" 32 | 33 | 34 | 35 | #ifndef SGUI_NO_OPENGL 36 | #ifdef SGUI_WINDOWS 37 | #include 38 | #endif 39 | 40 | #ifdef SGUI_OS_X 41 | #include 42 | #else 43 | #include 44 | #endif 45 | 46 | 47 | 48 | typedef struct 49 | { 50 | sgui_tex_canvas super; 51 | 52 | sgui_rect locked; 53 | unsigned char* buffer; 54 | GLuint tex; 55 | } 56 | sgui_gl_canvas; 57 | 58 | 59 | 60 | #ifdef __cplusplus 61 | extern "C" { 62 | #endif 63 | 64 | sgui_canvas* sgui_gl_canvas_create( unsigned width, unsigned int height ); 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif /* SGUI_NO_OPENGL */ 71 | 72 | #endif /* GL_CANVAS_H */ 73 | 74 | -------------------------------------------------------------------------------- /subwm/src/ctx_mesh.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ctx_mesh.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef SGUI_CTX_MESH_H 26 | #define SGUI_CTX_MESH_H 27 | 28 | 29 | 30 | #include "sgui_predef.h" 31 | #include "sgui_subwm_predef.h" 32 | 33 | 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | void ctx_get_window_vertices( unsigned int width, unsigned int height, 40 | float* vbo, sgui_subwm_skin* skin, int offset ); 41 | 42 | unsigned int ctx_get_window_indices( unsigned short** indexbuffer ); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif /* SGUI_CTX_MESH_H */ 49 | 50 | -------------------------------------------------------------------------------- /subwm/src/tex_canvas.c: -------------------------------------------------------------------------------- 1 | /* 2 | * tex_canvas.c 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #include "sgui_tex_canvas.h" 26 | #include "sgui_context.h" 27 | #include "sgui_window.h" 28 | 29 | #include "GL/gl_canvas.h" 30 | #include "D3D9/d3d9_canvas.h" 31 | #include "D3D11/d3d11_canvas.h" 32 | 33 | #include 34 | 35 | 36 | 37 | sgui_canvas* sgui_tex_canvas_create( sgui_window* wnd, sgui_context* ctx, 38 | unsigned width, unsigned int height ) 39 | { 40 | (void)ctx; 41 | 42 | if( !wnd || !width || !height ) 43 | return NULL; 44 | 45 | switch( wnd->backend ) 46 | { 47 | #ifndef SGUI_NO_OPENGL 48 | case SGUI_OPENGL_CORE: 49 | case SGUI_OPENGL_COMPAT: 50 | (void)wnd; (void)ctx; 51 | return sgui_gl_canvas_create( width, height ); 52 | #endif 53 | 54 | #if defined(SGUI_WINDOWS) && !defined(SGUI_NO_D3D9) 55 | case SGUI_DIRECT3D_9: 56 | (void)wnd; 57 | return sgui_d3d9_canvas_create( ctx, width, height ); 58 | #endif 59 | 60 | #if defined(SGUI_WINDOWS) && !defined(SGUI_NO_D3D11) 61 | case SGUI_DIRECT3D_11: 62 | (void)wnd; 63 | return sgui_d3d11_canvas_create( ctx, width, height ); 64 | #endif 65 | } 66 | 67 | return NULL; 68 | } 69 | 70 | void* sgui_tex_canvas_get_texture( sgui_canvas* this ) 71 | { 72 | return this ? ((sgui_tex_canvas*)this)->get_texture( this ) : NULL; 73 | } 74 | 75 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable( test_model test_model.c ) 2 | 3 | target_link_libraries( test_model sgui ) 4 | 5 | set_target_properties( test_model PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests" ) 6 | 7 | add_test( NAME sgui_model COMMAND test_model ) 8 | 9 | -------------------------------------------------------------------------------- /widgets/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------- 2 | # This file is part of the sgui buildsystem. I, David Oberhollenzer, 3 | # author of this file hereby place the contents of this file into 4 | # the public domain. 5 | #-------------------------------------------------------------------- 6 | 7 | set( WIDGETS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/button.c 8 | ${CMAKE_CURRENT_SOURCE_DIR}/src/edit_box.c 9 | ${CMAKE_CURRENT_SOURCE_DIR}/src/frame.c 10 | ${CMAKE_CURRENT_SOURCE_DIR}/src/group_box.c 11 | ${CMAKE_CURRENT_SOURCE_DIR}/src/icon_view.c 12 | ${CMAKE_CURRENT_SOURCE_DIR}/src/image.c 13 | ${CMAKE_CURRENT_SOURCE_DIR}/src/progress_bar.c 14 | ${CMAKE_CURRENT_SOURCE_DIR}/src/scroll_bar.c 15 | ${CMAKE_CURRENT_SOURCE_DIR}/src/label.c 16 | ${CMAKE_CURRENT_SOURCE_DIR}/src/subview.c 17 | ${CMAKE_CURRENT_SOURCE_DIR}/src/tab.c 18 | ${CMAKE_CURRENT_SOURCE_DIR}/src/slider.c 19 | ${CMAKE_CURRENT_SOURCE_DIR}/src/pass_box.c 20 | ${CMAKE_CURRENT_SOURCE_DIR}/src/numeric_edit.c 21 | ${CMAKE_CURRENT_SOURCE_DIR}/src/color_picker.c 22 | 23 | PARENT_SCOPE ) 24 | 25 | -------------------------------------------------------------------------------- /widgets/include/sgui_frame.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sgui_frame.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * \file sgui_frame.h 28 | * 29 | * \brief Contains the declarations of the sgui_frame widget 30 | */ 31 | #ifndef SGUI_FRAME_H 32 | #define SGUI_FRAME_H 33 | 34 | 35 | 36 | #include "sgui_predef.h" 37 | 38 | 39 | 40 | /** 41 | * \struct sgui_frame 42 | * 43 | * \extends sgui_widget 44 | * 45 | * \brief A scrollable container widget 46 | * 47 | * \image html frame.png "A frame with multiple children inside" 48 | */ 49 | 50 | 51 | 52 | #ifdef __cplusplus 53 | extern "C" 54 | { 55 | #endif 56 | 57 | /** 58 | * \brief Create a frame widget 59 | * 60 | * \memberof sgui_frame 61 | * 62 | * A frame is a simple widget that can contain other widgets. A frame uses a 63 | * scroll bar in case there are more widgets than it can display at once. 64 | * 65 | * \param x The horizontal component of the frames position 66 | * \param y The vertical component of the frames position 67 | * \param width The width of the frame 68 | * \param height The height of the frame 69 | * 70 | * \return A pointer to a new frame widget 71 | */ 72 | SGUI_DLL sgui_widget* sgui_frame_create( int x, int y, unsigned int width, 73 | unsigned int height ); 74 | 75 | /** 76 | * \brief Override dynamic internal scrollbar enabling/disabling of a frame 77 | * 78 | * \memberof sgui_frame 79 | * 80 | * \param frame A pointer to a frame widget 81 | * \param always_draw If non-zero, the scroll bars of a frame are always 82 | * drawn, even if they aren't required 83 | */ 84 | SGUI_DLL void sgui_frame_override_scrollbars( sgui_widget* frame, 85 | int always_draw ); 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif /* SGUI_FRAME_H */ 92 | 93 | -------------------------------------------------------------------------------- /widgets/include/sgui_group_box.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sgui_group_box.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * \file sgui_group_box.h 28 | * 29 | * \brief Contains the declarations of the sgui_group_box widget 30 | */ 31 | #ifndef SGUI_GROUP_BOX_H 32 | #define SGUI_GROUP_BOX_H 33 | 34 | 35 | 36 | #include "sgui_predef.h" 37 | 38 | 39 | 40 | /** 41 | * \struct sgui_group_box 42 | * 43 | * \extends sgui_widget 44 | * 45 | * \brief A container widget that draws a box with a caption around 46 | * its children 47 | * 48 | * \image html group.png "Radio buttons grouped together in a group box" 49 | */ 50 | 51 | 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | /** 58 | * \brief Create a group box 59 | * 60 | * \memberof sgui_group_box 61 | * 62 | * A group box is a very simple widget that may group other widgets 63 | * (e.g. radio buttons for a radio button menu). A group box has a border that 64 | * seperates the contained widgets and a caption. 65 | * 66 | * \param x The horizontal component of the group box position 67 | * \param y The vertical component of the group box position 68 | * \param width The width of the group box 69 | * \param height The height of the group box 70 | * \param caption The caption of the group box 71 | * 72 | * \return A pointer to a new group box widget 73 | */ 74 | SGUI_DLL sgui_widget* sgui_group_box_create( int x, int y, 75 | unsigned int width, 76 | unsigned int height, 77 | const char* caption ); 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | 83 | #endif /* SGUI_GROUP_BOX_H */ 84 | 85 | -------------------------------------------------------------------------------- /widgets/include/sgui_image.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sgui_image.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * \file sgui_image.h 28 | * 29 | * \brief Contains the declarations of the sgui_image widget 30 | */ 31 | #ifndef SGUI_IMAGE_H 32 | #define SGUI_IMAGE_H 33 | 34 | 35 | 36 | #include "sgui_predef.h" 37 | 38 | 39 | 40 | /** 41 | * \struct sgui_image 42 | * 43 | * \extends sgui_widget 44 | * 45 | * \brief A widget that displays a staticially assigned bitmap image 46 | * 47 | * \image html static.png "Two image widgets, with and without transparency" 48 | */ 49 | 50 | 51 | 52 | #ifdef __cplusplus 53 | extern "C" 54 | { 55 | #endif 56 | 57 | /** 58 | * \brief Create an image widget 59 | * 60 | * \memberof sgui_image 61 | * 62 | * \param x Distance from the left of the window to the left of the image 63 | * \param y Distance from the top of the window to the top of the image 64 | * \param width Width of the image 65 | * \param height Height of the image 66 | * \param data The RGB or RGBA image data 67 | * \param format The color format used by the image 68 | * \param blend Non-zero if the image should be blended instead of blitted 69 | * \param useptr Non-zero if the given pointer should be used instead of 70 | * creating an internal buffer to safe memory 71 | */ 72 | SGUI_DLL sgui_widget* sgui_image_create( int x, int y, 73 | unsigned int width, 74 | unsigned int height, 75 | const void* data, int format, 76 | int blend, int useptr ); 77 | 78 | /** 79 | * \brief Reload a portion of an image 80 | * 81 | * \memberof sgui_image 82 | * 83 | * If a portion of an image has changed, reupload the data to the underlying 84 | * pixmap and ask the canvas to redraw the image. This way, dynamic, animated 85 | * images can be displayed based on a simple sgui_image. 86 | * 87 | * \param image A pointer to an image widget 88 | * \param x A distance from the left of the image 89 | * \param y A distance from the top of the image 90 | * \param width The width of the altered are in pixels 91 | * \param height The height of the altered are in pixels 92 | */ 93 | SGUI_DLL void sgui_image_reload( sgui_widget* image, 94 | unsigned int x, unsigned int y, 95 | unsigned int width, unsigned int height ); 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif /* SGUI_IMAGE_H */ 102 | 103 | -------------------------------------------------------------------------------- /widgets/include/sgui_label.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sgui_label.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * \file sgui_label.h 28 | * 29 | * \brief Contains the declarations of the sgui_label widget 30 | */ 31 | #ifndef SGUI_LABEL_H 32 | #define SGUI_LABEL_H 33 | 34 | 35 | 36 | #include "sgui_predef.h" 37 | 38 | 39 | 40 | /** 41 | * \struct sgui_label 42 | * 43 | * \extends sgui_widget 44 | * 45 | * \brief A widget that draws a statically assigned text string 46 | * 47 | * \image html static.png "A multi line text displayed by a label widget" 48 | */ 49 | 50 | 51 | 52 | #ifdef __cplusplus 53 | extern "C" 54 | { 55 | #endif 56 | 57 | /** 58 | * \brief Create a label widget that can display static text 59 | * 60 | * \memberof sgui_label 61 | * 62 | * \param x The x component of the widget position. 63 | * \param y The y component of the widget position. 64 | * \param text The UTF8 text to print. The LF ('\n') character can be used 65 | * for line wraps, the \ \ and \ \ for writing 66 | * text bold or italic. A \ tag can be used to 67 | * switch text color. The color value "default" switches back to 68 | * the default color. 69 | */ 70 | SGUI_DLL sgui_widget* sgui_label_create( int x, int y, const char* text ); 71 | 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | 76 | #endif /* SGUI_STATIC_TEXT_H */ 77 | 78 | -------------------------------------------------------------------------------- /widgets/include/sgui_pass_box.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sgui_pass_box.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * \file sgui_pass_box.h 28 | * 29 | * \brief Contains the declarations of the sgui_pass_box widget 30 | */ 31 | #ifndef SGUI_PASS_BOX_H 32 | #define SGUI_PASS_BOX_H 33 | 34 | 35 | 36 | #include "sgui_predef.h" 37 | #include "sgui_edit_box.h" 38 | 39 | 40 | 41 | /** 42 | * \struct sgui_pass_box 43 | * 44 | * \extends sgui_edit_box 45 | * 46 | * \brief A password entry edit box that does not display the entered text 47 | */ 48 | 49 | 50 | 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | 55 | /** 56 | * \brief Create a password entry box 57 | * 58 | * \memberof sgui_pass_box 59 | * 60 | * A password entry box is an edit box that does not display the entered text. 61 | * A sequence of replacement characters (something like '*') is displayed 62 | * instead. The entered text can not be cut or copied by the user. 63 | * 64 | * \param x The distance from the left of the parent widget 65 | * \param y The distance from the top of the parent widget 66 | * \param width The width of the box in pixels 67 | * \param max_chars The maximum number of characters that can be entered 68 | * 69 | * \return A pointer to a password edit box on success, NULL on failure 70 | */ 71 | SGUI_DLL sgui_widget* sgui_pass_box_create( int x, int y, unsigned int width, 72 | unsigned int max_chars ); 73 | 74 | /** 75 | * \brief Get the text currently entered into a password edit box 76 | * 77 | * \memberof sgui_pass_box 78 | * 79 | * \param pbox A pointer to a password edit box 80 | * 81 | * \return A pointer to the actual entered text 82 | */ 83 | SGUI_DLL const char* sgui_pass_box_get_text( sgui_widget* pbox ); 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif /* SGUI_PASS_BOX_H */ 90 | 91 | -------------------------------------------------------------------------------- /widgets/include/sgui_progress_bar.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sgui_progress_bar.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * \file sgui_progress_bar.h 28 | * 29 | * \brief Contains the declarations of the sgui_progress_bar widget 30 | */ 31 | #ifndef SGUI_PROGRESS_BAR_H 32 | #define SGUI_PROGRESS_BAR_H 33 | 34 | 35 | 36 | #include "sgui_predef.h" 37 | 38 | 39 | 40 | #define SGUI_PROGRESS_BAR_CONTINUOUS 1 41 | #define SGUI_PROGRESS_BAR_STIPPLED 0 42 | #define SGUI_PROGRESS_BAR_HORIZONTAL 0 43 | #define SGUI_PROGRESS_BAR_VERTICAL 1 44 | 45 | 46 | /** 47 | * \struct sgui_progress_bar 48 | * 49 | * \extends sgui_widget 50 | * 51 | * \brief A progress bar widget 52 | * 53 | * \image html progress.png "Two types of horizontal progress bars" 54 | */ 55 | 56 | 57 | #ifdef __cplusplus 58 | extern "C" { 59 | #endif 60 | 61 | /** 62 | * \brief Create a progress bar widget 63 | * 64 | * \memberof sgui_progress_bar 65 | * 66 | * \param x Distance from the left of the window. 67 | * \param y Distance from the top of the window. 68 | * \param style SGUI_PROGRESS_BAR_CONTINUOUS for a continous bar, 69 | * SGUI_PROGRESS_BAR_STIPPLED for a bar out of discrete 70 | * slices. 71 | * \param vertical Non-zero for a vertical bar, zero for a horizontal bar. 72 | * \param progress Initial progress for the bar (value between 0 and 100) 73 | * \param length The length of the bar in pixels. 74 | */ 75 | SGUI_DLL sgui_widget* sgui_progress_bar_create( int x, int y, int style, 76 | int vertical, 77 | unsigned int progress, 78 | unsigned int length ); 79 | 80 | /** 81 | * \brief Set the progress on a progress bar 82 | * 83 | * \memberof sgui_progress_bar 84 | * 85 | * \param bar The progress bar to alter. 86 | * \param progress Value between 0 and 100 for the bar to display. 87 | */ 88 | SGUI_DLL void sgui_progress_bar_set_progress( sgui_widget* bar, 89 | unsigned int progress ); 90 | 91 | /** 92 | * \brief Get the progress on a progress bar 93 | * 94 | * \memberof sgui_progress_bar 95 | * 96 | * \param bar The progress bar. 97 | * 98 | + \return Progress value (percentage, value between 0 and 100) 99 | */ 100 | SGUI_DLL unsigned int sgui_progress_bar_get_progress( sgui_widget* bar ); 101 | 102 | #ifdef __cplusplus 103 | } 104 | #endif 105 | 106 | #endif /* SGUI_PROGRESS_BAR_H */ 107 | 108 | -------------------------------------------------------------------------------- /widgets/include/sgui_slider.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sgui_slider.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * \file sgui_slider.h 28 | * 29 | * \brief Contains the declarations of the sgui_slider widget 30 | */ 31 | #ifndef SGUI_SLIDER_H 32 | #define SGUI_SLIDER_H 33 | 34 | 35 | 36 | #include "sgui_predef.h" 37 | 38 | 39 | 40 | #define SGUI_SLIDER_VERTICAL 1 41 | #define SGUI_SLIDER_HORIZONTAL 0 42 | #define SGUI_SLIDER_CONTINUOUS 0 43 | 44 | 45 | 46 | /** 47 | * \struct sgui_slider 48 | * 49 | * \extends sgui_widget 50 | * 51 | * \brief A widget with an object that can be draged around to enter values 52 | * 53 | * \image html slider.png "Two types of vertical sliders" 54 | * 55 | * An SGUI_SLIDER_CHANGED_EVENT is fired (with integer argument set to the 56 | * current value) when the value changes. 57 | */ 58 | 59 | 60 | 61 | #ifdef __cplusplus 62 | extern "C" { 63 | #endif 64 | 65 | /** 66 | * \brief Create a slider widget 67 | * 68 | * \memberof sgui_slider 69 | * 70 | * \param x The distance from the left of the parent 71 | * \param y The distance from the top of the parent 72 | * \param length The length of the widget in pixels 73 | * \param vertical Zero (or SGUI_SLIDER_HORIZONTAL) for a horizontal dragging 74 | * area, non-zero (or SGUI_SLIDER_VERTICAL) for a vertical 75 | * dragging area 76 | * \param min The minimum value selectable 77 | * \param max Tha maximum value selectable 78 | * \param steps The number of discrete steps in the dragging area, or 0 79 | * (aka SGUI_SLIDER_CONTINUOUS) for a continuous slider 80 | * 81 | * \return A pointer to a slider widget on success, NULL on failure 82 | */ 83 | SGUI_DLL sgui_widget* sgui_slider_create( int x, int y, unsigned int length, 84 | int vertical, 85 | int min, int max, 86 | unsigned int steps ); 87 | 88 | /** 89 | * \brief Get the currently set value of a slider widget 90 | * 91 | * \memberof sgui_slider 92 | * 93 | * \param slider A pointer to a slider widget 94 | */ 95 | SGUI_DLL int sgui_slider_get_value( sgui_widget* slider ); 96 | 97 | /** 98 | * \brief Change the currently set value of a slider widget 99 | * 100 | * \memberof sgui_slider 101 | * 102 | * \note Calling this function does not trigger an SGUI_SLIDER_CHANGED_EVENT 103 | * 104 | * \param slider A pointer to a slider widget 105 | * \param value The new value to set 106 | */ 107 | SGUI_DLL void sgui_slider_set_value( sgui_widget* slider, int value ); 108 | 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | 113 | #endif /* SGUI_SLIDER_H */ 114 | 115 | -------------------------------------------------------------------------------- /widgets/include/sgui_tab.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sgui_tab.h 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * \file sgui_tab.h 28 | * 29 | * \brief Contains the declarations of the sgui_tab and sgui_tab_group widgets 30 | */ 31 | #ifndef SGUI_TAB_H 32 | #define SGUI_TAB_H 33 | 34 | 35 | 36 | #include "sgui_predef.h" 37 | 38 | 39 | 40 | /** 41 | * \struct sgui_tab 42 | * 43 | * \extends sgui_widget 44 | * 45 | * \brief A single tab in a tab group 46 | * 47 | * \image html tab.png "Multiple tabs in a tab group" 48 | */ 49 | 50 | /** 51 | * \struct sgui_tab_group 52 | * 53 | * \extends sgui_widget 54 | * 55 | * \brief Manages a group of tab widgets 56 | * 57 | * \image html tab.png "A tab group managing multiple tabs" 58 | */ 59 | 60 | 61 | 62 | #ifdef __cplusplus 63 | extern "C" { 64 | #endif 65 | 66 | /** 67 | * \brief Create a tab group widget 68 | * 69 | * \memberof sgui_tab_group 70 | * 71 | * This creates a new tab group widget. Tabs have to be added to the widget by 72 | * creating them using sgui_tab_create and attaching them using 73 | * sgui_widget_add_child. Widgets can be added to the tab by using 74 | * sgui_widget_add_child on the tab widget. A tab can be selected by using 75 | * sgui_widget_set_visible. 76 | * 77 | * \param x Horizontal component of the tab groups position 78 | * \param y Vertical component of the tab groups position 79 | * \param width Width of the tab 80 | * \param height Height of the tab 81 | * 82 | * \return A pointer to a new tab group widget 83 | */ 84 | SGUI_DLL sgui_widget* sgui_tab_group_create( int x, int y, 85 | unsigned int width, 86 | unsigned int height ); 87 | 88 | /** 89 | * \brief Create a tab widget 90 | * 91 | * \memberof sgui_tab 92 | * 93 | * This creates a new tab widget. The tab widget has to be added to a tab 94 | * group manually using sgui_widget_add_child. Widget can be added to the 95 | * tab by using sgui_widget_add_child. A tab can be selected by using 96 | * sgui_widget_set_visible. 97 | * 98 | * \param parent A pointer to the parent group to copy the size from. The new 99 | * widget is not added to the tab group. 100 | * \param caption A caption to print onto the new tab widget. 101 | */ 102 | SGUI_DLL sgui_widget* sgui_tab_create( sgui_widget* parent, 103 | const char* caption ); 104 | 105 | #ifdef __cplusplus 106 | } 107 | #endif 108 | 109 | #endif /* SGUI_TAB_H */ 110 | 111 | -------------------------------------------------------------------------------- /widgets/src/group_box.c: -------------------------------------------------------------------------------- 1 | /* 2 | * group_box.c 3 | * This file is part of sgio 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #define SGUI_BUILDING_DLL 26 | #include "sgui_group_box.h" 27 | #include "sgui_skin.h" 28 | #include "sgui_canvas.h" 29 | #include "sgui_internal.h" 30 | #include "sgui_widget.h" 31 | #include "sgui_utf8.h" 32 | 33 | #include 34 | #include 35 | 36 | 37 | 38 | #ifndef SGUI_NO_GROUP_BOX 39 | typedef struct 40 | { 41 | sgui_widget super; 42 | char* caption; 43 | } 44 | sgui_group_box; 45 | 46 | 47 | 48 | static void group_box_draw( sgui_widget* super ) 49 | { 50 | sgui_group_box* this = (sgui_group_box*)super; 51 | sgui_skin* skin = sgui_skin_get( ); 52 | 53 | skin->draw_group_box(skin, super->canvas, &(super->area), this->caption); 54 | } 55 | 56 | static void group_box_destroy( sgui_widget* super ) 57 | { 58 | sgui_group_box* this = (sgui_group_box*)super; 59 | 60 | free( this->caption ); 61 | free( this ); 62 | } 63 | 64 | 65 | 66 | sgui_widget* sgui_group_box_create( int x, int y, 67 | unsigned int width, unsigned int height, 68 | const char* caption ) 69 | { 70 | sgui_group_box* this = calloc( 1, sizeof(sgui_group_box) ); 71 | sgui_widget* super = (sgui_widget*)this; 72 | 73 | if( !this ) 74 | return NULL; 75 | 76 | /* try to store the caption string */ 77 | if( !(this->caption = sgui_strdup( caption )) ) 78 | { 79 | free( this ); 80 | return NULL; 81 | } 82 | 83 | /* initialize widget base struct */ 84 | sgui_widget_init( super, x, y, width, height ); 85 | 86 | super->draw = group_box_draw; 87 | super->destroy = group_box_destroy; 88 | super->flags = SGUI_WIDGET_VISIBLE; 89 | 90 | return super; 91 | } 92 | #elif defined(SGUI_NOP_IMPLEMENTATIONS) 93 | sgui_widget* sgui_group_box_create( int x, int y, 94 | unsigned int width, unsigned int height, 95 | const char* caption ) 96 | { 97 | (void)x; (void)y; (void)width; (void)height; (void)caption; 98 | return NULL; 99 | } 100 | #endif /* !SGUI_NO_GROUP_BOX */ 101 | 102 | -------------------------------------------------------------------------------- /widgets/src/label.c: -------------------------------------------------------------------------------- 1 | /* 2 | * label.c 3 | * This file is part of sgui 4 | * 5 | * Copyright (C) 2012 - David Oberhollenzer 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #define SGUI_BUILDING_DLL 26 | #include "sgui_label.h" 27 | #include "sgui_canvas.h" 28 | #include "sgui_skin.h" 29 | #include "sgui_font.h" 30 | #include "sgui_internal.h" 31 | #include "sgui_utf8.h" 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | 38 | 39 | typedef struct 40 | { 41 | sgui_widget super; 42 | 43 | char* text; 44 | } 45 | sgui_label; 46 | 47 | 48 | 49 | static void label_draw( sgui_widget* super ) 50 | { 51 | sgui_label* this = (sgui_label*)super; 52 | 53 | sgui_skin_draw_text( super->canvas, super->area.left, super->area.top, 54 | this->text ); 55 | } 56 | 57 | static void label_destroy( sgui_widget* this ) 58 | { 59 | free( ((sgui_label*)this)->text ); 60 | free( this ); 61 | } 62 | 63 | 64 | 65 | sgui_widget* sgui_label_create( int x, int y, const char* text ) 66 | { 67 | sgui_label* this; 68 | sgui_widget* super; 69 | 70 | /* create widget */ 71 | this = calloc( 1, sizeof(sgui_label) ); 72 | super = (sgui_widget*)this; 73 | 74 | if( !this || !(this->text = sgui_strdup( text )) ) 75 | { 76 | free( this ); 77 | return NULL; 78 | } 79 | 80 | /* initialise the base widget */ 81 | sgui_widget_init( (sgui_widget*)this, 0, 0, 0, 0 ); 82 | 83 | super->draw = label_draw; 84 | super->destroy = label_destroy; 85 | super->flags = SGUI_WIDGET_VISIBLE; 86 | 87 | /* compute the text area */ 88 | sgui_skin_get_text_extents( text, &super->area ); 89 | sgui_rect_set_position( &super->area, x, y ); 90 | 91 | return (sgui_widget*)this; 92 | } 93 | 94 | --------------------------------------------------------------------------------