├── include.xml ├── samples ├── 2-keystate │ ├── test.hxml │ └── Test.hx ├── 3-dialogs │ ├── test.hxml │ └── Test.hx ├── 4-registry │ ├── test.hxml │ └── Test.hx ├── 7-dialogs-folder │ ├── test.hxml │ └── Test.hx ├── 6-dialogs-savefile │ ├── test.hxml │ └── Test.hx ├── 9-win-Tools-createProcess │ ├── test.hxml │ └── Test.hx ├── 8-win-Tools-replaceExeIcon │ ├── test.hxml │ └── Test.hx ├── 10-win-menus │ ├── swhx_16x16.ico │ ├── compile.hxml │ ├── sample.xml │ ├── Flash.hx │ └── App.hx ├── 5-dialogs-openfile │ ├── test.hxml │ └── Test.hx └── 1-clipboard │ ├── test.hxml │ └── Test.hx ├── .gitignore ├── ndll ├── Mac │ ├── systools.ndll │ └── systools-debug.ndll ├── Linux │ └── systools.ndll ├── Linux64 │ └── systools.ndll ├── Mac64 │ ├── systools.ndll │ └── systools-debug.ndll └── Windows │ └── systools.ndll ├── haxelib.xml ├── haxelib.json ├── .gitattributes ├── systools ├── Loader.hx ├── FileUtils.hx ├── Display.hx ├── Key.hx ├── Browser.hx ├── Clipboard.hx ├── win │ ├── Tray.hx │ ├── Tools.hx │ ├── Display.hx │ ├── Menus.hx │ └── Events.hx ├── Misc.hx ├── Registry.hx ├── Dialogs.hx └── SWFInfo.hx ├── README.md ├── project ├── src │ ├── misc.h │ ├── clipboard.h │ ├── win │ │ ├── misc.c │ │ ├── win.h │ │ ├── display.h │ │ ├── fileutils.c │ │ ├── browser.c │ │ ├── registry.c │ │ ├── menus.h │ │ ├── display.c │ │ ├── clipboard.c │ │ ├── win.c │ │ ├── icons.h │ │ ├── menus.c │ │ └── dialogs.c │ ├── display.h │ ├── registry.h │ ├── api.h │ ├── linux │ │ ├── misc.c │ │ ├── fileutils.c │ │ ├── clipboard.c │ │ ├── registry.c │ │ └── dialogs.c │ ├── mac │ │ ├── misc.m │ │ ├── display.m │ │ ├── fileutils.m │ │ ├── browser.m │ │ ├── clipboard.m │ │ ├── registry.m │ │ └── dialogs.m │ ├── browser.h │ ├── fileutils.h │ ├── dialogs.h │ └── api.cpp ├── Makefile └── build.xml ├── CHANGES.txt └── LICENSE.txt /include.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/2-keystate/test.hxml: -------------------------------------------------------------------------------- 1 | -neko app.n 2 | -main Test 3 | -lib systools -------------------------------------------------------------------------------- /samples/3-dialogs/test.hxml: -------------------------------------------------------------------------------- 1 | -neko app.n 2 | -main Test 3 | -lib systools -------------------------------------------------------------------------------- /samples/4-registry/test.hxml: -------------------------------------------------------------------------------- 1 | -lib systools 2 | -neko app.n 3 | -main Test -------------------------------------------------------------------------------- /samples/7-dialogs-folder/test.hxml: -------------------------------------------------------------------------------- 1 | -lib systools 2 | -neko app.n 3 | -main Test 4 | -------------------------------------------------------------------------------- /samples/6-dialogs-savefile/test.hxml: -------------------------------------------------------------------------------- 1 | -lib systools 2 | -neko app.n 3 | -main Test 4 | -------------------------------------------------------------------------------- /samples/9-win-Tools-createProcess/test.hxml: -------------------------------------------------------------------------------- 1 | -lib systools 2 | -neko app.n 3 | -main Test -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | obj 2 | *.o 3 | *.n 4 | bin 5 | 6 | # OSX objects 7 | all_objs 8 | .DS_Store 9 | -------------------------------------------------------------------------------- /samples/8-win-Tools-replaceExeIcon/test.hxml: -------------------------------------------------------------------------------- 1 | -lib systools 2 | -neko app.n 3 | -main Test 4 | -------------------------------------------------------------------------------- /ndll/Mac/systools.ndll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waneck/systools/HEAD/ndll/Mac/systools.ndll -------------------------------------------------------------------------------- /ndll/Linux/systools.ndll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waneck/systools/HEAD/ndll/Linux/systools.ndll -------------------------------------------------------------------------------- /ndll/Linux64/systools.ndll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waneck/systools/HEAD/ndll/Linux64/systools.ndll -------------------------------------------------------------------------------- /ndll/Mac64/systools.ndll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waneck/systools/HEAD/ndll/Mac64/systools.ndll -------------------------------------------------------------------------------- /ndll/Windows/systools.ndll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waneck/systools/HEAD/ndll/Windows/systools.ndll -------------------------------------------------------------------------------- /ndll/Mac/systools-debug.ndll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waneck/systools/HEAD/ndll/Mac/systools-debug.ndll -------------------------------------------------------------------------------- /ndll/Mac64/systools-debug.ndll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waneck/systools/HEAD/ndll/Mac64/systools-debug.ndll -------------------------------------------------------------------------------- /samples/10-win-menus/swhx_16x16.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waneck/systools/HEAD/samples/10-win-menus/swhx_16x16.ico -------------------------------------------------------------------------------- /samples/5-dialogs-openfile/test.hxml: -------------------------------------------------------------------------------- 1 | -lib systools 2 | -neko app.n 3 | -main Test 4 | --next 5 | -lib systools 6 | -cpp app 7 | -main Test 8 | -------------------------------------------------------------------------------- /samples/1-clipboard/test.hxml: -------------------------------------------------------------------------------- 1 | -neko app.n 2 | -main Test 3 | -lib systools 4 | --next 5 | -cpp bin 6 | -main Test 7 | -lib systools 8 | -D HXCPP_M64 9 | --remap neko:cpp 10 | -------------------------------------------------------------------------------- /samples/10-win-menus/compile.hxml: -------------------------------------------------------------------------------- 1 | -main App 2 | -neko app.n 3 | -lib swhx 4 | -lib systools 5 | 6 | --next 7 | -main Flash 8 | -swf ui.swf 9 | -swf-header 400:300:20:EEEEFF 10 | -lib swhx 11 | -------------------------------------------------------------------------------- /samples/10-win-menus/sample.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | compile.hxml 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /samples/10-win-menus/Flash.hx: -------------------------------------------------------------------------------- 1 | 2 | class Flash { 3 | 4 | static var enabledCom = swhx.Connection; 5 | 6 | static function main() { 7 | trace("Run this sample from console to see window messages being printed."); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples/7-dialogs-folder/Test.hx: -------------------------------------------------------------------------------- 1 | import systools.Dialogs; 2 | 3 | class Test { 4 | 5 | static function main() { 6 | var result = Dialogs.folder 7 | ( "Select a folder" 8 | , "This additional message will only be shown on OSX" 9 | ); 10 | trace(result); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /haxelib.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | A cross-platform extension to the Neko VM for accessing system APIs 4 | Haxe 3 support. Alpha 5 | 6 | -------------------------------------------------------------------------------- /samples/6-dialogs-savefile/Test.hx: -------------------------------------------------------------------------------- 1 | import systools.Dialogs; 2 | 3 | class Test { 4 | 5 | static function main() { 6 | var result = Dialogs.saveFile 7 | ( "Select a file please, or type name" 8 | , "This additional message will only be shown on OSX" 9 | , "c:/" // initial path, for windows only 10 | ); 11 | trace(result); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/3-dialogs/Test.hx: -------------------------------------------------------------------------------- 1 | import systools.Dialogs; 2 | 3 | class Test { 4 | 5 | static function main() { 6 | Dialogs.message("neko-systools","Hello World!",false); 7 | trace("confirm: "+Dialogs.confirm("neko-systools","Please confirm?",false)); 8 | Dialogs.message("neko-systools","Message error test", true); 9 | trace("confirm error: "+Dialogs.confirm("neko-systools","Confirm error test", true)); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /haxelib.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "systools", 3 | "url": "https://github.com/waneck/systools", 4 | "license": "LGPL", 5 | "tags": ["neko","cpp","system"], 6 | "description": "A cross-platform extension to the Neko VM for accessing system APIs", 7 | "version": "1.1.0", 8 | "releasenote": "Many fixes, new Mac version using Cocoa", 9 | "contributors": ["waneck", "heardtheword"], 10 | "dependencies": { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /samples/2-keystate/Test.hx: -------------------------------------------------------------------------------- 1 | import systools.Key; 2 | import systools.Misc; 3 | class Test { 4 | 5 | static function main() { 6 | trace("Press ALT to end sample"); 7 | while (!Misc.getKeyState(Key.Alt)) { 8 | // sleep for 25 milliseconds 9 | Sys.sleep(0.0025); 10 | 11 | if ( Misc.getKeyState(Key.LeftCtrl) 12 | || Misc.getKeyState(Key.RightCtrl) 13 | ) 14 | trace("CTRL is down"); 15 | 16 | if ( Misc.getKeyState(Key.LeftShift) 17 | || Misc.getKeyState(Key.RightShift) 18 | ) 19 | trace("SHIFT is down"); 20 | 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /samples/5-dialogs-openfile/Test.hx: -------------------------------------------------------------------------------- 1 | import systools.Dialogs; 2 | 3 | class Test { 4 | 5 | static function main() { 6 | var filters: FILEFILTERS = 7 | { count: 2 8 | , descriptions: ["Text files", "JPEG files"] 9 | , extensions: ["*.txt","*.jpg;*.jpeg"] 10 | }; 11 | var result = Dialogs.openFile 12 | ( "Select a file please!" 13 | , "Please select one or more files, so we can see if this method works" 14 | , filters 15 | ); 16 | trace(result); 17 | 18 | var result = Dialogs.saveFile 19 | ( "Select a file please!" 20 | , "Please select one or more files, so we can see if this method works" 21 | , Sys.getCwd() 22 | , filters 23 | ); 24 | trace(result); 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /samples/1-clipboard/Test.hx: -------------------------------------------------------------------------------- 1 | class Test { 2 | 3 | static function main() { 4 | var cbtext: String = systools.Clipboard.getText(); 5 | trace("Current text on clipboard: "+ cbtext); 6 | 7 | systools.Clipboard.clear(); 8 | trace("Cleared clipboard"); 9 | 10 | cbtext = systools.Clipboard.getText(); 11 | trace("Current text on clipboard: "+ cbtext); 12 | 13 | trace("Setting clipboard text to: Hello World"); 14 | systools.Clipboard.setText("Hello World"); 15 | 16 | cbtext = systools.Clipboard.getText(); 17 | trace("Current text on clipboard: "+ cbtext); 18 | 19 | systools.Clipboard.clear(); 20 | trace("Cleared clipboard (again)"); 21 | 22 | cbtext = systools.Clipboard.getText(); 23 | trace("Current text on clipboard: "+ cbtext); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /systools/Loader.hx: -------------------------------------------------------------------------------- 1 | package systools; 2 | #if cpp 3 | import cpp.Lib; 4 | #elseif neko 5 | import neko.Lib; 6 | #end 7 | 8 | class Loader 9 | { 10 | private static var init = false; 11 | 12 | public static function load(lib:String, s:String, n:Int):Dynamic 13 | { 14 | 15 | if (!init) 16 | { 17 | #if neko 18 | loadNekoAPI(); 19 | #end 20 | Lib.load("systools","systools_init",0)(); 21 | init = true; 22 | } 23 | 24 | return Lib.load(lib,s,n); 25 | } 26 | 27 | #if neko 28 | public static function loadNekoAPI() 29 | { 30 | var i = Lib.load("systools","neko_init", 5); 31 | if (i != null) 32 | { 33 | i(function(s) return new String(s), function(len:Int) { var r = []; if (len > 0) r[len - 1] = null; return r; }, null, true, false); 34 | } 35 | } 36 | #end 37 | } 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | systools 2 | ======== 3 | 4 | fork of neko-systools ( https://code.google.com/p/neko-systools ) for Haxe 3/Neko 2 5 | 6 | 7 | ### Status ### 8 | The files are updated and are _mostly working_ for all platforms - which means that it should be working as well as the old systools; For my own project goals, its current status is enough. I will, however, try to maintain it the best I can, if any issues are reported. 9 | 10 | You are welcome to ask for new features; A broader version of systools is planned to be made from scratch, and with a more permissive license. 11 | 12 | ### Neko usage with OpenFL ### 13 | OpenFL will not include **systools.ndll** by default when building for the Neko or cpp platforms. To solve this you must include an additional line in your `project.xml` file, just after the `` tag: 14 | ```xml 15 | 16 | ``` 17 | -------------------------------------------------------------------------------- /samples/9-win-Tools-createProcess/Test.hx: -------------------------------------------------------------------------------- 1 | /** 2 | * systools.win.Tools.createProcess 3 | * 4 | */ 5 | 6 | import systools.Registry; 7 | 8 | class Test { 9 | 10 | static function main() { 11 | var os = Sys.systemName(); 12 | var args = "Test.hx"; 13 | var app = "C:\\Windows\\Notepad.exe"; 14 | var workingdir = Sys.getCwd(); 15 | 16 | trace("Launching "+app+", args: "+args+", working dir: "+workingdir); 17 | 18 | // Launch application: 19 | var result = systools.win.Tools.createProcess 20 | ( app // app. path 21 | , args // app. args 22 | , workingdir // app. working directory 23 | , false // do not hide the window 24 | , false // do not wait for the application to terminate 25 | ); 26 | // Show result: 27 | trace 28 | ( if (result==0) "Successfuly launched application" 29 | else "Failed launching application. Error code: "+result 30 | ); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /samples/8-win-Tools-replaceExeIcon/Test.hx: -------------------------------------------------------------------------------- 1 | import systools.Dialogs; 2 | import systools.win.Tools; 3 | 4 | class Test { 5 | 6 | static function main() { 7 | var exefilter: FILEFILTERS = 8 | { count: 1 9 | , descriptions: ["executables"] 10 | , extensions: ["*.exe"] 11 | }; 12 | var icofilter: FILEFILTERS = 13 | { count: 1 14 | , descriptions: ["icons"] 15 | , extensions: ["*.ico"] 16 | }; 17 | 18 | // collect exe target file: 19 | var exefile = Dialogs.openFile("Select file","",exefilter); 20 | if (exefile==null) { 21 | trace("No executable file selected"); 22 | return; 23 | } 24 | 25 | // collect ico source file: 26 | var icofile = Dialogs.openFile("Select a new icon file","ignore",icofilter); 27 | if (icofile==null) { 28 | trace("No icon file selected"); 29 | return; 30 | } 31 | 32 | // replace icon: 33 | if (systools.win.Tools.replaceExeIcon(exefile[0],icofile[0])) 34 | trace("Successfully replaced "+exefile[0]+"'s icon."); 35 | else 36 | trace("Failed to replace "+exefile[0]+"'s icon."); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /project/src/misc.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ************************************************************************ */ 18 | 19 | int systools_misc_get_key_state( int key ); 20 | void systools_misc_initialize(); 21 | -------------------------------------------------------------------------------- /project/src/clipboard.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ************************************************************************ */ 18 | 19 | #include 20 | 21 | int systools_clipboard_set_text( const char *text ); 22 | char* systools_clipboard_get_text(); 23 | void systools_clipboard_clear(); 24 | -------------------------------------------------------------------------------- /samples/4-registry/Test.hx: -------------------------------------------------------------------------------- 1 | /** 2 | * For x-plat compatibility, always specify a Windows 3 | * root key identifier (Registry.HKEY_xxx_xxx). The 4 | * value is ignored on OSX, but required on Windows. 5 | * 6 | * Mac registry entries (or 'Preferences') require a 7 | * non-empty key name. For example: 8 | * 9 | * Registry.setValue(Registry.HKEY_CLASSES_ROOT, "myApp//someData", "", "Hello"); 10 | * 11 | * will fail on OSX. 12 | */ 13 | 14 | import systools.Registry; 15 | 16 | class Test { 17 | 18 | static function main() { 19 | var path: String = "org\\nekovm\\systools"; 20 | var key: String = "Greeting"; 21 | 22 | // Write a registry entry: 23 | Registry.setValue(Registry.HKEY_CLASSES_ROOT, path, key,"Hello World!"); 24 | 25 | // Read back and trace the entry: 26 | var value: String = Registry.getValue(Registry.HKEY_CLASSES_ROOT, path, key); 27 | trace( "Greeting (from registry) is '"+value+"'"); 28 | 29 | // Remove all values listed at our path: 30 | Registry.deleteKey(Registry.HKEY_CLASSES_ROOT, path); 31 | 32 | // Try to read once more, sh 33 | value = Registry.getValue(Registry.HKEY_CLASSES_ROOT, path, key); 34 | trace( "Greeting (after delete) is '"+value+"'"); 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /project/Makefile: -------------------------------------------------------------------------------- 1 | 2 | PROJECT:=systools 3 | 4 | LBITS := $(shell getconf LONG_BIT) 5 | ifeq ($(LBITS),64) 6 | NDLL:=../ndll/Linux64/$(PROJECT).ndll 7 | else 8 | NDLL:=../ndll/Linux/$(PROJECT).ndll 9 | endif 10 | OBJDIR=obj 11 | 12 | SRC_PATHS:=src src/linux 13 | C_SRCS:=$(foreach PATH,$(SRC_PATHS), $(wildcard $(PATH)/*.c)) 14 | CPP_SRCS:=$(foreach PATH,$(SRC_PATHS), $(wildcard $(PATH)/*.cpp)) 15 | C_OBJS:=${C_SRCS:.c=.o} 16 | CPP_OBJS:=${CPP_SRCS:.cpp=.o} 17 | OBJS:=$(C_OBJS) $(CPP_OBJS) 18 | 19 | HEADERS:=$(foreach PATH,$(SRC_PATHS), $(wildcard $(PATH)/*.h)) 20 | HXCPP=$(shell haxelib path hxcpp | head -1) 21 | 22 | CC:=g++ -Isrc 23 | GTK_FLAGS:=$(shell pkg-config --libs --cflags gtk+-2.0) 24 | GCONF_FLAGS:=$(shell pkg-config --libs --cflags gconf-2.0) 25 | NEKO_FLAGS:=-fpic -fPIC -DHX_LINUX -DHXCPP_VISIT_ALLOCS -I$(HXCPP)/include -ldl -fvisibility=hidden -O2 26 | 27 | CPPFLAGS += $(GTK_FLAGS) $(GCONF_FLAGS) $(NEKO_FLAGS) 28 | CFLAGS += $(GTK_FLAGS) $(GCONF_FLAGS) $(NEKO_FLAGS) 29 | LDFLAGS +=-fPIC -shared -L/usr/lib -lz -ldl -rdynamic -g3 -Xlinker --no-undefined $(GTK_FLAGS) $(GCONF_FLAGS) 30 | 31 | all: $(NDLL) 32 | 33 | clean: 34 | @- $(RM) $(NDLL) 35 | @- $(RM) $(OBJS) 36 | 37 | $(NDLL): $(OBJS) 38 | $(CC) $(CFLAGS) $(OBJS) -o $(NDLL) $(LDFLAGS) 39 | -------------------------------------------------------------------------------- /project/src/win/misc.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ************************************************************************ */ 18 | 19 | #include "../misc.h" 20 | #include 21 | 22 | void systools_misc_initialize() 23 | { 24 | } 25 | 26 | int systools_misc_get_key_state(int key) { 27 | return (GetAsyncKeyState(key) & 0x8000) > 0; 28 | } -------------------------------------------------------------------------------- /project/src/win/win.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ************************************************************************ */ 18 | 19 | #include "../api.h" 20 | 21 | int systools_win_replaceExeIcon( const char *exe, const char *ico, int resourceID ); 22 | int systools_win_create_process( const char *app, const char *args, const char *wd, int hide, int wait ); -------------------------------------------------------------------------------- /project/src/display.h: -------------------------------------------------------------------------------- 1 | /* ******************************************************************************** */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Lee McColl-Sylvester, Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom, */ 6 | /* Ian Thomas */ 7 | /* */ 8 | /* This library is free software; you can redistribute it and/or */ 9 | /* modify it under the terms of the GNU Lesser General Public */ 10 | /* License as published by the Free Software Foundation; either */ 11 | /* version 2.1 of the License, or (at your option) any later version. */ 12 | /* */ 13 | /* This library is distributed in the hope that it will be useful, */ 14 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 15 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 16 | /* Lesser General Public License or the LICENSE file for more details. */ 17 | /* */ 18 | /* ******************************************************************************** */ 19 | 20 | typedef struct { 21 | int width; 22 | int height; 23 | } dimensions; 24 | 25 | void systools_display_get_screen_size(dimensions *pDim); -------------------------------------------------------------------------------- /project/src/registry.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ************************************************************************ */ 18 | 19 | void systools_registry_set_value( int key, const char * subkey, const char * valuename, const char * value); 20 | char * systools_registry_get_value( int key, const char * subkey, const char * valuename ); 21 | void systools_registry_delete_key( int key, const char * subkey ); 22 | -------------------------------------------------------------------------------- /project/src/win/display.h: -------------------------------------------------------------------------------- 1 | /* ******************************************************************************** */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Lee McColl-Sylvester, Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom, */ 6 | /* Ian Thomas */ 7 | /* */ 8 | /* This library is free software; you can redistribute it and/or */ 9 | /* modify it under the terms of the GNU Lesser General Public */ 10 | /* License as published by the Free Software Foundation; either */ 11 | /* version 2.1 of the License, or (at your option) any later version. */ 12 | /* */ 13 | /* This library is distributed in the hope that it will be useful, */ 14 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 15 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 16 | /* Lesser General Public License or the LICENSE file for more details. */ 17 | /* */ 18 | /* ******************************************************************************** */ 19 | 20 | int systools_win_display_set_mode(int width, int height, int depth); 21 | void systools_win_display_set_default_mode(); 22 | int systools_win_display_is_mode_supported(int width, int height, int depth); -------------------------------------------------------------------------------- /project/src/api.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ************************************************************************ */ 18 | 19 | #ifndef _SYSTOOLS_API_H 20 | #define _SYSTOOLS_API_H 21 | 22 | // result types: 23 | struct RES_STRINGLIST { 24 | long count; 25 | char **strings; 26 | }; 27 | 28 | // argument types: 29 | struct ARG_FILEFILTERS { 30 | long count; 31 | const char **descriptions; 32 | const char **extensions; 33 | }; 34 | 35 | #endif // _SYSTOOLS_API_H 36 | -------------------------------------------------------------------------------- /project/src/linux/misc.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ************************************************************************ */ 18 | 19 | #include 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | #include "misc.h" 26 | 27 | void systools_misc_initialize() { 28 | gtk_init(NULL,NULL); 29 | gconf_init(0,NULL,NULL); 30 | } 31 | /* DEFINE_ENTRY_POINT(systools_misc_initialize); */ 32 | 33 | int systools_misc_get_key_state( int code ) { 34 | printf("SYSTOOLS: systools_misc_get_key_state NYI\n"); 35 | return 0; 36 | } 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /project/src/mac/misc.m: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ************************************************************************ */ 18 | 19 | #include "misc.h" 20 | #if CARBON 21 | #include 22 | #else 23 | #include 24 | #endif 25 | 26 | void systools_misc_initialize() 27 | { 28 | } 29 | 30 | int systools_misc_get_key_state( int code ) { 31 | #if CARBON 32 | KeyMap theKeys; 33 | unsigned char *keybytes; 34 | if (code >= 0 && code <= 127) { 35 | GetKeys(theKeys); 36 | keybytes = (unsigned char *) theKeys; 37 | return (keybytes[code>>3] & (1 << (code&7))); 38 | } 39 | #endif 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /project/src/browser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Edwin van Rijkom, Nicolas Cannasse, Lee McColl-Sylvester, Ian Thomas 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * - Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR 17 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 23 | * DAMAGE. 24 | */ 25 | 26 | #include "api.h" 27 | 28 | int systools_browser_launch( const char *url); 29 | -------------------------------------------------------------------------------- /project/src/fileutils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Edwin van Rijkom, Nicolas Cannasse, Lee McColl-Sylvester, Ian Thomas 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * - Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR 17 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 23 | * DAMAGE. 24 | */ 25 | 26 | #include "api.h" 27 | 28 | char * systools_fileutils_get_temp_folder(); 29 | -------------------------------------------------------------------------------- /project/src/dialogs.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ************************************************************************ */ 18 | 19 | #include "api.h" 20 | 21 | void systools_dialogs_message_box( const char *title, const char *message, int error ); 22 | int systools_dialogs_dialog_box( const char *title, const char *message, int error ); 23 | void systools_dialogs_open_file( const char *title, const char *msg, struct ARG_FILEFILTERS *filters, int multi, struct RES_STRINGLIST *result) ; 24 | char* systools_dialogs_save_file( const char *title, const char *msg, const char *initialdir, struct ARG_FILEFILTERS *filters); 25 | char* systools_dialogs_folder( const char *title, const char *msg ); 26 | -------------------------------------------------------------------------------- /project/src/mac/display.m: -------------------------------------------------------------------------------- 1 | /* ******************************************************************************** */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Lee McColl-Sylvester, Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom, */ 6 | /* Ian Thomas */ 7 | /* */ 8 | /* This library is free software; you can redistribute it and/or */ 9 | /* modify it under the terms of the GNU Lesser General Public */ 10 | /* License as published by the Free Software Foundation; either */ 11 | /* version 2.1 of the License, or (at your option) any later version. */ 12 | /* */ 13 | /* This library is distributed in the hope that it will be useful, */ 14 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 15 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 16 | /* Lesser General Public License or the LICENSE file for more details. */ 17 | /* */ 18 | /* ******************************************************************************** */ 19 | 20 | #include "../display.h" 21 | #if CARBON 22 | #include 23 | #else 24 | #include 25 | #endif 26 | 27 | void systools_display_get_screen_size(dimensions *pDim) 28 | { 29 | #if CARBON 30 | pDim->width=CGDisplayPixelsWide(CGMainDisplayID()); 31 | pDim->height=CGDisplayPixelsHigh(CGMainDisplayID()); 32 | #else 33 | NSRect screenRect = [[NSScreen mainScreen] frame]; 34 | pDim->width = screenRect.size.width; 35 | pDim->height = screenRect.size.height; 36 | #endif 37 | } -------------------------------------------------------------------------------- /project/src/mac/fileutils.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Edwin van Rijkom, Nicolas Cannasse, Lee McColl-Sylvester, Ian Thomas 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * - Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR 17 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 23 | * DAMAGE. 24 | */ 25 | 26 | #include "../fileutils.h" 27 | #include 28 | #include 29 | 30 | char * systools_fileutils_get_temp_folder() { 31 | char *result = strdup(P_tmpdir); 32 | return result; 33 | } -------------------------------------------------------------------------------- /project/src/win/fileutils.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Edwin van Rijkom, Nicolas Cannasse, Lee McColl-Sylvester, Ian Thomas 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * - Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR 17 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 23 | * DAMAGE. 24 | */ 25 | 26 | #include "../fileutils.h" 27 | #include 28 | 29 | char * systools_fileutils_get_temp_folder() { 30 | char temp_path[MAX_PATH]; 31 | char *out=NULL; 32 | if (GetTempPath(sizeof(temp_path), temp_path)){ 33 | out = _strdup(temp_path); 34 | } 35 | return out; 36 | } -------------------------------------------------------------------------------- /project/src/linux/fileutils.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Edwin van Rijkom, Nicolas Cannasse, Lee McColl-Sylvester, Ian Thomas 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * - Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR 17 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 23 | * DAMAGE. 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | #include "../fileutils.h" 33 | 34 | char * systools_fileutils_get_temp_folder() { 35 | char *result = strdup(P_tmpdir); 36 | return result; 37 | } 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /systools/FileUtils.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Edwin van Rijkom, Nicolas Cannasse, Lee McColl-Sylvester, Ian Thomas 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * - Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR 17 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 23 | * DAMAGE. 24 | */ 25 | 26 | package systools; 27 | 28 | class FileUtils { 29 | 30 | /** 31 | * Get the value of the system's temporary path. 32 | */ 33 | static public function getTempFolder() : String { 34 | return _fileutils_get_temp_folder(); 35 | } 36 | 37 | static var _fileutils_get_temp_folder = systools.Loader.load("systools","fileutils_get_temp_folder", 0); 38 | } 39 | -------------------------------------------------------------------------------- /project/src/linux/clipboard.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ************************************************************************ */ 18 | 19 | #include 20 | #include 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | #include "clipboard.h" 25 | 26 | static GtkClipboard *getClipboard() 27 | { 28 | static GtkClipboard *sClipboard = NULL; 29 | if ( sClipboard == NULL ) 30 | { 31 | sClipboard = gtk_clipboard_get( GDK_SELECTION_CLIPBOARD ); 32 | } 33 | return sClipboard; 34 | } 35 | 36 | int systools_clipboard_set_text( const char * text ) { 37 | gtk_clipboard_set_text( getClipboard(), text, strlen(text) ); 38 | return 0; 39 | } 40 | 41 | char* systools_clipboard_get_text() { 42 | char* result = gtk_clipboard_wait_for_text( getClipboard() ); 43 | return result; 44 | } 45 | 46 | void systools_clipboard_clear() { 47 | gtk_clipboard_clear( getClipboard() ); 48 | } 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | -------------------------------------------------------------------------------- /systools/Display.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Edwin van Rijkom, Nicolas Cannasse, Lee McColl-Sylvester, Ian Thomas 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * - Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR 17 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 23 | * DAMAGE. 24 | */ 25 | 26 | package systools; 27 | 28 | class Display { 29 | 30 | /** 31 | Retrieves the screen dimensions of the primary device and returns as an object with the 32 | fields h and w for height and width respectively 33 | **/ 34 | public static function getScreenSize() 35 | { 36 | return _get_screen_size(); 37 | } 38 | 39 | static var _get_screen_size = systools.Loader.load("systools","display_get_screen_size",0); 40 | } 41 | -------------------------------------------------------------------------------- /project/src/win/browser.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Edwin van Rijkom, Nicolas Cannasse, Lee McColl-Sylvester, Ian Thomas 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * - Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR 17 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 23 | * DAMAGE. 24 | */ 25 | 26 | #include "../browser.h" 27 | #include 28 | 29 | int systools_browser_launch( const char *url) { 30 | 31 | int result; 32 | char *escapedURL=malloc(8192); 33 | 34 | escapedURL[0]=0; 35 | strcat(escapedURL,"\""); 36 | strcat(escapedURL,url); 37 | strcat(escapedURL,"\""); 38 | 39 | result = (int)ShellExecute(NULL, "open", escapedURL ,NULL, NULL, SW_SHOWNORMAL); 40 | 41 | free(escapedURL); 42 | 43 | return (result>32); 44 | } -------------------------------------------------------------------------------- /CHANGES.txt: -------------------------------------------------------------------------------- 1 | 2013-05-28 2 | Updated to Neko 2 and Hxcpp 3 | 4 | 2009-03-10 5 | Changed systools.win.Tools to not crash on non-Windows unless methods are 6 | actually called. [IT] 7 | 0.17 Recompiled and uploaded to haxeLib to include replaceExeIcon() changes. [IT] 8 | 9 | 2008-10-08 10 | Added optional iconResourceID to systools.win.Tools.replaceExeIcon(). [IT] 11 | 12 | 2008-10-02 13 | 0.15 Rebuilt Windows .ndll - some odd build compatability crept in 14 | last time around making it so the DLL didn't load on Win98. Now fixed. [IT] 15 | 16 | 2008-02-14 17 | Added quotes round browser URL in Browser.launchURL() to deal with spaces in Windows urls. [IT] 18 | 19 | 2007-06-15 20 | Added systools.Display.getScreenSize() for Mac and Windows [IT] 21 | 22 | 2007-06-12 Beta 0.0.11 [IT] 23 | 24 | 2007-06-12 25 | Added SWFInfo (cross-platform) [IT] 26 | 27 | 2007-04-24 28 | Added FileUtils.getTempFolder() for Windows, Mac, Linux [IT] 29 | 30 | 2007-04-18 31 | Added Browser.launchURL() for Windows, Mac [IT] 32 | 33 | 2007-03-14 34 | Migrated win/registry.c to use non-deprecated Win32 functions (for closer Vista compatability). 35 | Corrected Registry.getValue() to return a null rather than the string 'null' when the key doesn't 36 | exist. [IT] 37 | 38 | 2007-03-09 39 | Moved systools.win.Tools.getScreenSize() to systools.win.Display. [IT] 40 | 41 | 2007-03-08 42 | Added systools.win.Display and supporting code for changing screen mode on Windows. [IT] 43 | 44 | 2006-11-28 45 | Initial Linux port: 46 | Clipboard and Dialogs using GTK 47 | Registry using gconf 48 | 49 | 2006-10-20: Beta 0.0.8 50 | Implemented create process for Windows 51 | 52 | 2006-10-06: Beta 0.0.7 53 | Fixed 'openDialog' returning faulty first entry on 54 | multiple files selection. 55 | Fixed .ndll not loading correctly with OSX 10.3.9 56 | 57 | 2006-09-29: Beta 0.0.6 58 | Implemented exe icon replacement for Windows 59 | Implemented browse for folder 60 | 61 | 2006-09-28: Beta 0.0.5 62 | APIs now returning haXe strings 63 | -------------------------------------------------------------------------------- /systools/Key.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Edwin van Rijkom, Nicolas Cannasse 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * - Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR 17 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 23 | * DAMAGE. 24 | */ 25 | package systools; 26 | 27 | /** 28 | * Special modifier keys. 29 | * To detect the "Alt Gr" key on some keyboards, check whether both Alt and 30 | * a Ctrl key is pressed at the same time. Notice also, that if you only check 31 | * if Ctrl is down and ignore Alt, it might be because "Alt Gr" is down. 32 | * Therefore, you should always check if both Alt and Ctrl is down at the 33 | * same time to distinguish between Alt, Ctrl and Alt Gr. 34 | */ 35 | enum Key { 36 | LeftCtrl; 37 | RightCtrl; 38 | LeftShift; 39 | RightShift; 40 | Alt; 41 | Custom( code : Int ); 42 | } 43 | -------------------------------------------------------------------------------- /systools/Browser.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Edwin van Rijkom, Nicolas Cannasse, Lee McColl-Sylvester, Ian Thomas 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * - Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR 17 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 23 | * DAMAGE. 24 | */ 25 | 26 | package systools; 27 | 28 | class Browser { 29 | 30 | /** Launches the default browser and opens it at the target URL. 31 | Mac or Windows only at present. 32 | @param targetURL 33 | @return true if successful 34 | */ 35 | public static function launch(targetURL:String):Bool 36 | { 37 | var sys:String=Sys.systemName(); 38 | if ((sys!="Mac")&&(sys!="Windows")) 39 | throw "systools.Browser.launch() only works on Mac or Windows"; 40 | 41 | return _browser_launch(targetURL); 42 | } 43 | 44 | static var _browser_launch = systools.Loader.load("systools","browser_launch",1); 45 | } 46 | -------------------------------------------------------------------------------- /systools/Clipboard.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, 3 | * Asger Ottar Alstrup, Edwin van Rijkom, Nicolas Cannasse 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY 16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR 19 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 25 | * DAMAGE. 26 | */ 27 | 28 | package systools; 29 | 30 | class Clipboard { 31 | static public function setText( text : String ) : Void { 32 | _set_clipboard_data(untyped text); 33 | } 34 | 35 | static public function getText() : String { 36 | return _get_clipboard_data(); 37 | } 38 | 39 | static public function clear() : Void { 40 | _clear_clipboard(); 41 | } 42 | 43 | static var _set_clipboard_data = systools.Loader.load("systools","clipboard_set_text",1); 44 | static var _get_clipboard_data = systools.Loader.load("systools","clipboard_get_text",0); 45 | static var _clear_clipboard = systools.Loader.load("systools","clipboard_clear",0); 46 | } 47 | -------------------------------------------------------------------------------- /systools/win/Tray.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Edwin van Rijkom, Nicolas Cannasse, Lee McColl-Sylvester 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * - Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR 17 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 23 | * DAMAGE. 24 | */ 25 | 26 | package systools.win; 27 | 28 | import systools.win.Events; 29 | 30 | class Tray { 31 | 32 | var t : Void; 33 | 34 | static var _systray_create_icon = systools.Loader.load("systools","systray_create_icon",3); 35 | static var _systray_menu_callback = systools.Loader.load("systools","systray_menu_callback",0); 36 | public function new( w : swhx.Window, iconPath : String, tooltip : String ) 37 | { 38 | t = _systray_create_icon(w.handle,iconPath,tooltip); 39 | } 40 | 41 | static var _systray_destroy_icon = systools.Loader.load("systools","systray_destroy_icon",1); 42 | public function dispose() 43 | { 44 | return _systray_destroy_icon(t); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /project/src/win/registry.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ************************************************************************ */ 18 | 19 | #include "../registry.h" 20 | #include 21 | 22 | void systools_registry_set_value( int key, const char * subkey, const char * valuename, const char * value) { 23 | HKEY k; 24 | HKEY hkey = (HKEY) (key | 0x80000000); 25 | if (RegCreateKeyEx(hkey, subkey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &k, NULL) == ERROR_SUCCESS) 26 | { 27 | RegSetValueEx(k, valuename, 0, REG_SZ, value, (DWORD)(strlen(value)+1)); 28 | RegCloseKey(k); 29 | } 30 | } 31 | 32 | char * systools_registry_get_value( int key, const char * subkey, const char * valuename ) { 33 | HKEY k; 34 | DWORD ktype; 35 | DWORD ksize = 16000; 36 | char kdata[16000]; 37 | HKEY hkey = (HKEY) (key | 0x80000000); 38 | char *out = NULL; 39 | 40 | if (RegOpenKeyEx(hkey, subkey, 0, KEY_READ, &k) == ERROR_SUCCESS) 41 | { 42 | if (RegQueryValueEx(k, valuename, NULL, &ktype,(LPBYTE)kdata,&ksize) == ERROR_SUCCESS) 43 | { 44 | out = _strdup(kdata); 45 | } 46 | RegCloseKey(k); 47 | } 48 | return out; 49 | } 50 | 51 | void systools_registry_delete_key( int key, const char * subkey ) { 52 | HKEY hkey = (HKEY) (key | 0x80000000); 53 | RegDeleteKey(hkey, subkey); 54 | } 55 | -------------------------------------------------------------------------------- /project/src/mac/browser.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Edwin van Rijkom, Nicolas Cannasse, Lee McColl-Sylvester, Ian Thomas 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * - Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR 17 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 23 | * DAMAGE. 24 | */ 25 | 26 | #include "../browser.h" 27 | #if CARBON 28 | #include 29 | #else 30 | #include 31 | #endif 32 | 33 | int systools_browser_launch( const char *url) 34 | { 35 | #if CARBON 36 | OSStatus err; 37 | ICInstance inst; 38 | long selStart, selEnd; 39 | err = ICStart(&inst,'????'); // No known creator code 40 | if (err == noErr) 41 | { 42 | selStart=0; 43 | selEnd=strlen(url); 44 | err = ICLaunchURL(inst, "\p", url, strlen(url),&selStart,&selEnd); 45 | ICStop(inst); 46 | } 47 | return (err==0); 48 | #else 49 | NSURL *nsurl = [NSURL URLWithString:[NSString stringWithUTF8String:url]]; 50 | return [[NSWorkspace sharedWorkspace] openURL:nsurl] ? 1 : 0; 51 | #endif 52 | } -------------------------------------------------------------------------------- /project/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /systools/Misc.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Edwin van Rijkom, Nicolas Cannasse 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * - Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR 17 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 23 | * DAMAGE. 24 | */ 25 | package systools; 26 | import systools.Key; 27 | 28 | class Misc { 29 | 30 | private static function keymapMac(c) { 31 | return switch( c ) { 32 | case LeftCtrl: 0x3B; 33 | case RightCtrl: 0x3B; 34 | case LeftShift: 0x38; 35 | case RightShift: 0x38; 36 | case Alt: 0x3A; 37 | case Custom(code): code; 38 | } 39 | } 40 | 41 | private static function keymapWin(c) { 42 | return switch( c ) { 43 | case LeftCtrl: 0xA2; 44 | case RightCtrl: 0xA3; 45 | case LeftShift: 0xA0; 46 | case RightShift: 0xA1; 47 | case Alt: 0x12; 48 | case Custom(code): code; 49 | } 50 | } 51 | 52 | 53 | public static function getKeyState( key: Key ) : Bool { 54 | var sysname = Sys.systemName(); 55 | return _misc_get_key_state(switch( sysname ) { 56 | case "Mac": keymapMac(key); 57 | case "Windows": keymapWin(key); 58 | default: throw "Not supported "+sysname; 59 | }) != 0; 60 | } 61 | static var _misc_get_key_state = systools.Loader.load("systools","misc_get_key_state",1); 62 | 63 | } 64 | 65 | -------------------------------------------------------------------------------- /project/src/win/menus.h: -------------------------------------------------------------------------------- 1 | /* ******************************************************************************** */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Lee McColl-Sylvester, Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ******************************************************************************** */ 18 | 19 | #include 20 | 21 | typedef void* (*_tray_menu_cb)(void* custom, void* id1, void *id2, void* p1, void* p2); 22 | 23 | typedef struct _tray_icon { 24 | NOTIFYICONDATA* icon_data; 25 | HICON icon_handle; 26 | _tray_menu_cb msg_callback; 27 | } tray_icon; 28 | 29 | 30 | // ---------------- Type Conversion ----------------------- 31 | 32 | DEFINE_KIND(k_icondata); 33 | DEFINE_KIND(k_menu); 34 | DEFINE_KIND(k_void_pointer); 35 | DEFINE_KIND(k_tray_icon); 36 | DEFINE_KIND(k_window_msg_cb); 37 | 38 | extern const char tray_icon_error[255]; 39 | 40 | #define val_tray_icon(x) ((tray_icon*)val_data(x)) 41 | #define val_hwnd(x) ((HWND*)val_data(x)) 42 | #define val_menu(x) ((HMENU*)val_data(x)) 43 | 44 | tray_icon *systools_win_create_tray_icon(HWND *wnd,const char *ico,const char *tooltip); 45 | //tray_icon *systools_create_set_tray_icon(HWND* wnd,const char* ico,const char* tooltip); 46 | void systools_win_destroy_tray_icon(tray_icon *tray); 47 | void* tray_menu_cb(void* custom, void* id1, void *id2, void* p1, void* p2); 48 | 49 | HMENU *systools_menu_create(); 50 | HMENU *systools_popup_menu_create(); 51 | void systools_menu_destroy( HMENU *hmenu ); 52 | int systools_menu_add_item( HMENU* hmenu, const char* caption, DWORD callbackID ); 53 | int systools_menu_add_submenu( HMENU *hmenu, HMENU *submenu, const char *caption, DWORD callbackID ); 54 | int systools_popup_menu_show( HWND *hwnd, HMENU *hmenu ); 55 | int systools_menu_show( HWND *hwnd, HMENU *hmenu ); 56 | -------------------------------------------------------------------------------- /project/src/win/display.c: -------------------------------------------------------------------------------- 1 | /* ******************************************************************************** */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Lee McColl-Sylvester, Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom, */ 6 | /* Ian Thomas */ 7 | /* */ 8 | /* This library is free software; you can redistribute it and/or */ 9 | /* modify it under the terms of the GNU Lesser General Public */ 10 | /* License as published by the Free Software Foundation; either */ 11 | /* version 2.1 of the License, or (at your option) any later version. */ 12 | /* */ 13 | /* This library is distributed in the hope that it will be useful, */ 14 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 15 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 16 | /* Lesser General Public License or the LICENSE file for more details. */ 17 | /* */ 18 | /* ******************************************************************************** */ 19 | 20 | #include 21 | #include "../display.h" 22 | #include "display.h" 23 | 24 | /** Set the screen resolution (set temporarily - when the app quits the 25 | screen mode will be restored. */ 26 | int systools_win_display_set_mode(int width, int height, int depth) { 27 | 28 | DEVMODE devMode; 29 | LONG error; 30 | 31 | devMode.dmSize = sizeof(devMode); 32 | devMode.dmPelsWidth=width; 33 | devMode.dmPelsHeight=height; 34 | devMode.dmBitsPerPel=depth; 35 | devMode.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT; 36 | 37 | error=ChangeDisplaySettingsEx(NULL,&devMode,NULL,CDS_FULLSCREEN,NULL); 38 | 39 | return (error==DISP_CHANGE_SUCCESSFUL); 40 | } 41 | 42 | /** Set the screen resolution to default */ 43 | void systools_win_display_set_default_mode() { 44 | ChangeDisplaySettingsEx(NULL,NULL,NULL,0,NULL); 45 | } 46 | 47 | /** Tests to see if a specific screen resolution is supported */ 48 | int systools_win_display_is_mode_supported(int width, int height, int depth) { 49 | 50 | DEVMODE devMode; 51 | LONG error; 52 | 53 | devMode.dmSize = sizeof(devMode); 54 | devMode.dmPelsWidth=width; 55 | devMode.dmPelsHeight=height; 56 | devMode.dmBitsPerPel=depth; 57 | devMode.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT; 58 | 59 | error=ChangeDisplaySettingsEx(NULL,&devMode,NULL,CDS_FULLSCREEN|CDS_TEST,NULL); 60 | 61 | return (error==DISP_CHANGE_SUCCESSFUL); 62 | } 63 | 64 | void systools_display_get_screen_size(dimensions *pDim) 65 | { 66 | pDim->width=GetSystemMetrics(SM_CXSCREEN); 67 | pDim->height=GetSystemMetrics(SM_CYSCREEN); 68 | } -------------------------------------------------------------------------------- /systools/Registry.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, 3 | * Asger Ottar Alstrup, Edwin van Rijkom, Nicolas Cannasse 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY 16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR 19 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 25 | * DAMAGE. 26 | */ 27 | package systools; 28 | 29 | class Registry { 30 | 31 | /** 32 | * HKEY_xxx_xxx values ignored on MacOS 33 | */ 34 | static public var HKEY_CLASSES_ROOT = 0; 35 | static public var HKEY_CURRENT_USER = 1; 36 | static public var HKEY_LOCAL_MACHINE = 2; 37 | static public var HKEY_USERS = 3; 38 | static public var HKEY_PERFORMANCE_DATA = 4; 39 | static public var HKEY_CURRENT_CONFIG = 5; 40 | static public var HKEY_DYN_DATA = 6; 41 | 42 | /** 43 | * Set a value in the registry. If it does not exist, it is created first. 44 | */ 45 | static public function setValue( key : Int, subKey : String, valuename : String, value : String) : Void { 46 | _set_value( key, subKey, valuename, value); 47 | } 48 | 49 | /** 50 | * Get the value of a key in registry. 51 | */ 52 | static public function getValue( key : Int, subKey : String, valuename : String ) : String { 53 | return _get_value( key, subKey, valuename); 54 | } 55 | 56 | static public function deleteKey( key : Int, subKey : String) : Void { 57 | _delete_key( key, subKey); 58 | } 59 | 60 | static var _set_value = systools.Loader.load("systools","registry_set_value", 4); 61 | static var _get_value = systools.Loader.load("systools","registry_get_value", 3); 62 | static var _delete_key = systools.Loader.load("systools","registry_delete_key", 2); 63 | } 64 | -------------------------------------------------------------------------------- /project/src/win/clipboard.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ************************************************************************ */ 18 | 19 | #include "../clipboard.h" 20 | #include 21 | 22 | int systools_clipboard_set_text( const char * text ) { 23 | size_t textlength; 24 | char * textcopy; 25 | HGLOBAL hglbCopy; 26 | 27 | if (!OpenClipboard(NULL)) { 28 | return 1; 29 | } 30 | EmptyClipboard(); 31 | 32 | // Allocate global memory for the text 33 | textlength = strlen(text); 34 | hglbCopy = GlobalAlloc(GMEM_MOVEABLE, textlength + 1); 35 | if (hglbCopy == NULL) { 36 | CloseClipboard(); 37 | return 1; 38 | } 39 | 40 | // Lock the handle and copy the text to the buffer. 41 | textcopy = GlobalLock(hglbCopy); 42 | memcpy(textcopy, text, textlength); 43 | textcopy[textlength] = 0; // null character 44 | 45 | // Place the handle on the clipboard. 46 | // Format is now set fixed to text. Supporting other formats will require 47 | // returning an array, for string will not work well with data containing 48 | // zeros 49 | SetClipboardData(CF_TEXT, hglbCopy); 50 | GlobalUnlock(hglbCopy); 51 | 52 | CloseClipboard(); 53 | 54 | return 0; 55 | } 56 | 57 | char* systools_clipboard_get_text() { 58 | char* result = 0; 59 | HGLOBAL hglb; 60 | 61 | if (!OpenClipboard(NULL)) 62 | return 0; 63 | 64 | // Format is now set fixed to text. Supporting other formats will require 65 | // returning an array, for string will not work well with data containing 66 | // zeros 67 | hglb = GetClipboardData(CF_TEXT); 68 | if (hglb != NULL) { 69 | char* globtext = GlobalLock(hglb); 70 | if (globtext != NULL) { 71 | result = strdup(globtext); 72 | GlobalUnlock(hglb); 73 | } 74 | } 75 | CloseClipboard(); 76 | return result; 77 | } 78 | 79 | void systools_clipboard_clear() { 80 | OpenClipboard(NULL); 81 | EmptyClipboard(); 82 | CloseClipboard(); 83 | } -------------------------------------------------------------------------------- /systools/win/Tools.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Edwin van Rijkom, Nicolas Cannasse 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * - Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR 17 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 23 | * DAMAGE. 24 | */ 25 | 26 | package systools.win; 27 | 28 | class Tools { 29 | 30 | /** 31 | Optional iconResourceID argument is the _target_ ID of the icon i.e. the resource ID that 32 | the supplied icon will be given in the resulting .exe. Defaults to 1 - normally 33 | the main icon. 34 | Peculiarly, the current SWHX.exe icon is at 104. 35 | */ 36 | public static function replaceExeIcon(exe: String, icon: String, ?iconResourceID: Int) : Bool { 37 | 38 | if (iconResourceID==null) 39 | iconResourceID=1; 40 | 41 | // Only tries to load this if called. 42 | if (_win_replace_exe_icon==null) 43 | { 44 | if (Sys.systemName()!="Windows") 45 | throw "Windows is required to run systools.win.Tools.replaceExeIcon"; 46 | 47 | _win_replace_exe_icon=systools.Loader.load("systools","win_replace_exe_icon",3); 48 | } 49 | 50 | return if(_win_replace_exe_icon(exe, icon,iconResourceID)) true else false; 51 | } 52 | static var _win_replace_exe_icon; 53 | 54 | 55 | public static function createProcess( app: String, cmds: String, workingdir: String, hide: Bool, wait: Bool): Int { 56 | 57 | if (_win_create_process==null) 58 | { 59 | if (Sys.systemName()!="Windows") 60 | throw "Windows is required to run systools.win.Tools.createProcess"; 61 | 62 | _win_create_process=systools.Loader.load("systools","win_create_process",5); 63 | } 64 | 65 | return _win_create_process 66 | ( app 67 | , cmds 68 | , workingdir 69 | , if (hide) 1 else 0 70 | , if (wait) 1 else 0 71 | ); 72 | } 73 | static var _win_create_process; 74 | } 75 | -------------------------------------------------------------------------------- /systools/win/Display.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Edwin van Rijkom, Nicolas Cannasse, Lee McColl-Sylvester, Ian Thomas 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * - Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR 17 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 23 | * DAMAGE. 24 | */ 25 | 26 | package systools.win; 27 | 28 | class Display { 29 | /** Set the screen resolution (set temporarily - when the neko app quits the screen mode will be restored.) 30 | @param width Width in pixels 31 | @param height Height in pixels 32 | @param depth Bit-depth (usual is 16 or 32) 33 | @return true if successful 34 | */ 35 | public static function setMode(width:Int,height:Int,depth:Int):Bool 36 | { 37 | return _display_set_mode(width,height,depth); 38 | } 39 | 40 | /** Sets the display back to the default resolution. */ 41 | public static function setDefaultMode():Void 42 | { 43 | _display_set_default_mode(); 44 | } 45 | 46 | /** Check if a screen resolution is supported 47 | @param width Width in pixels 48 | @param height Height in pixels 49 | @param depth Bit-depth (usual is 16 or 32) 50 | @return true if the mode is supported, false otherwise 51 | */ 52 | public static function isModeSupported(width:Int,height:Int,depth:Int):Bool 53 | { 54 | return _display_is_mode_supported(width,height,depth); 55 | } 56 | 57 | /** 58 | Retrieves the screen dimensions of the primary device and returns as an object with the 59 | fields h and w for height and width respectively 60 | **/ 61 | public static function getScreenSize() 62 | { 63 | return _get_screen_size(); 64 | } 65 | 66 | static var _get_screen_size = systools.Loader.load("systools","display_get_screen_size",0); 67 | static var _display_set_mode = systools.Loader.load("systools","display_set_mode",3); 68 | static var _display_set_default_mode = systools.Loader.load("systools","display_set_default_mode",0); 69 | static var _display_is_mode_supported = systools.Loader.load("systools","display_is_mode_supported",3); 70 | } 71 | -------------------------------------------------------------------------------- /project/src/linux/registry.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ************************************************************************ */ 18 | 19 | #include 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | static GConfClient *getRegistry() 26 | { 27 | static GConfClient *sRegistry = NULL; 28 | if ( sRegistry == NULL ) 29 | { 30 | sRegistry = gconf_client_get_default(); 31 | } 32 | return sRegistry; 33 | } 34 | 35 | gchar *makeGConfKey( const char *subkey, const char *valuename ) { 36 | char *result = NULL; 37 | if( valuename ) { 38 | result = g_strdup_printf("/%s/%s",subkey,valuename); 39 | } else { 40 | result = g_strdup_printf("/%s",subkey); 41 | } 42 | char *r = result; 43 | while( r[0] ) { 44 | if( r[0]=='\\' ) r[0]='/'; 45 | r++; 46 | } 47 | return result; 48 | } 49 | 50 | void gconf_client_unset_recursive( GConfClient *client, const char *dir ) { 51 | // recursively unset directories 52 | GSList *list = gconf_client_all_dirs( client, dir, NULL ); 53 | while( list ) { 54 | const char *key = (const char *)list->data; 55 | gconf_client_unset_recursive( client, key ); 56 | g_free( list->data ); 57 | list = list->next; 58 | } 59 | g_slist_free( list ); 60 | 61 | // unset keys in this directory 62 | list = gconf_client_all_entries( client, dir, NULL ); 63 | while( list ) { 64 | const char *key = ((GConfEntry *)list->data)->key; 65 | gconf_client_unset( client, key, NULL ); 66 | g_free( list->data ); 67 | list = list->next; 68 | } 69 | g_slist_free( list ); 70 | } 71 | 72 | void systools_registry_set_value(int _, const char *subkey, const char *valuename, const char *value) { 73 | gchar *key = makeGConfKey( subkey, valuename ); 74 | gconf_client_set_string( getRegistry(), key, value, NULL ); 75 | g_free( key ); 76 | } 77 | 78 | char* systools_registry_get_value( int _, const char *subkey, const char *valuename ) { 79 | gchar *key = makeGConfKey( subkey, valuename ); 80 | char *result = gconf_client_get_string( getRegistry(), key, NULL ); 81 | g_free( key ); 82 | return result; 83 | } 84 | 85 | void systools_registry_delete_key( int _, const char * subkey ) { 86 | gchar *key = makeGConfKey( subkey, NULL ); 87 | gconf_client_unset_recursive( getRegistry(), key ); 88 | g_free( key ); 89 | } 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | -------------------------------------------------------------------------------- /systools/win/Menus.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Edwin van Rijkom, Nicolas Cannasse, Lee McColl-Sylvester 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * - Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR 17 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 23 | * DAMAGE. 24 | */ 25 | 26 | package systools.win; 27 | 28 | class Menus { 29 | var m : Void; 30 | 31 | public function new( isPopup : Bool ) 32 | { 33 | if ( isPopup ) 34 | m = _win_popup_menu_create(); 35 | else 36 | m = _win_menu_create(); 37 | } 38 | 39 | public function dispose() 40 | { 41 | _win_destroy_menu( m ); 42 | } 43 | 44 | public function addItem( caption : String, msgid : Int ) : Void 45 | { 46 | _win_add_menu_item( m, caption, msgid ); 47 | } 48 | 49 | public function addDivider( msgid : Int ) : Void 50 | { 51 | _win_add_menu_divider( m, msgid ); 52 | } 53 | 54 | public function addSubmenu( menu : Menus, caption : String, msgid : Int ) : Void 55 | { 56 | _win_add_menu_submenu( m, menu.getHandle(), caption, msgid ); 57 | } 58 | 59 | public function show( hwnd : Void ) 60 | { 61 | return _win_show_menu( hwnd, m ); 62 | } 63 | 64 | public function showPopup( hwnd : Void ) 65 | { 66 | return _win_show_popup_menu( hwnd, m ); 67 | } 68 | 69 | public function getHandle() : Dynamic 70 | { 71 | return m; 72 | } 73 | 74 | static var _win_menu_create = systools.Loader.load("systools", "win_menu_create", 0); 75 | static var _win_popup_menu_create = systools.Loader.load("systools", "win_popup_menu_create", 0); 76 | static var _win_destroy_menu = systools.Loader.load("systools","win_destroy_menu",1); 77 | static var _win_add_menu_item = systools.Loader.load("systools","win_add_menu_item",3); 78 | static var _win_add_menu_submenu = systools.Loader.load("systools", "win_add_menu_submenu", 4); 79 | static var _win_add_menu_divider = systools.Loader.load("systools","win_add_menu_divider",2); 80 | static var _win_show_menu = systools.Loader.load("systools","win_show_menu",2); 81 | static var _win_show_popup_menu = systools.Loader.load("systools","win_show_popup_menu",2); 82 | } 83 | -------------------------------------------------------------------------------- /systools/Dialogs.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Edwin van Rijkom, Nicolas Cannasse 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * - Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR 17 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 23 | * DAMAGE. 24 | */ 25 | 26 | package systools; 27 | 28 | typedef FILEFILTERS = { 29 | var count: Int; 30 | var descriptions: Array; 31 | var extensions: Array; 32 | } 33 | 34 | class Dialogs { 35 | 36 | static var _message_box = systools.Loader.load("systools","dialogs_message_box",3); 37 | public static function message( title : String, msg : String, isError : Bool ) { 38 | _message_box(title, msg, isError); 39 | } 40 | 41 | static var _dialog_box = systools.Loader.load("systools","dialogs_dialog_box",3); 42 | public static function confirm( title : String, msg : String, isError : Bool ) : Bool { 43 | return _dialog_box(title, msg, isError); 44 | } 45 | 46 | static var _dialog_save_file = null; 47 | public static function saveFile( title : String, msg: String, initialDir : String,mask:FILEFILTERS=null) : String { 48 | if (_dialog_save_file == null) 49 | { 50 | try 51 | { 52 | _dialog_save_file = systools.Loader.load("systools","dialogs_save_file",4); 53 | } 54 | catch(e:Dynamic) 55 | { 56 | var savef = systools.Loader.load("systools","dialogs_save_file",3); 57 | _dialog_save_file = function(title,msg,initialDir,mask) return savef(title,msg,initialDir); 58 | } 59 | } 60 | var cwd:String = Sys.getCwd(); //grab current working directory before it changes 61 | var str:String = _dialog_save_file(title, msg, initialDir,mask); 62 | Sys.setCwd(cwd); //reset it afterwards 63 | return str; 64 | } 65 | 66 | static var _dialog_open_file = null; 67 | public static function openFile( title : String, msg : String, mask : FILEFILTERS, multi:Bool=true ) : Array { 68 | if (_dialog_open_file == null) 69 | { 70 | try { 71 | _dialog_open_file = systools.Loader.load("systools","dialogs_open_file",4); 72 | } 73 | catch(e:Dynamic) 74 | { 75 | var openf = systools.Loader.load("systools","dialogs_open_file",3); 76 | _dialog_open_file = function(title,msg,mask,multi) return openf(title,msg,mask); 77 | } 78 | } 79 | 80 | var cwd:String = Sys.getCwd(); //grab current working directory before it changes 81 | var arr:Array = _dialog_open_file(title, msg, mask, multi); 82 | Sys.setCwd(cwd); //reset it afterwards 83 | return arr; 84 | } 85 | 86 | static var _dialog_folder = systools.Loader.load("systools","dialogs_folder",2); 87 | public static function folder( title : String, msg: String ) : String { 88 | return _dialog_folder(title,msg); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /project/src/mac/clipboard.m: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ************************************************************************ */ 18 | 19 | #include "clipboard.h" 20 | 21 | #if CARBON 22 | 23 | #include 24 | 25 | static PasteboardRef getPasteboard() 26 | { 27 | static PasteboardRef sPasteboard = NULL; 28 | if ( sPasteboard == NULL ) 29 | { 30 | PasteboardCreate( kPasteboardClipboard, &sPasteboard ); 31 | } 32 | return sPasteboard; 33 | } 34 | 35 | int systools_clipboard_set_text( const char * text ) { 36 | CFDataRef data = CFDataCreate(kCFAllocatorDefault,(const UInt8*)text,strlen(text)); 37 | 38 | PasteboardClear(getPasteboard()); 39 | PasteboardSynchronize(getPasteboard()); 40 | 41 | return PasteboardPutItemFlavor(getPasteboard(),(PasteboardItemID)1,CFSTR("utf8"),data,kPasteboardFlavorNoFlags); 42 | } 43 | 44 | char* systools_clipboard_get_text() { 45 | OSStatus err; 46 | CFDataRef data; 47 | ItemCount itemCount; 48 | UInt32 itemIndex = 1; 49 | char* result = 0; 50 | 51 | PasteboardSynchronize(getPasteboard()); 52 | 53 | err = PasteboardGetItemCount(getPasteboard(), &itemCount ); 54 | if (err != noErr || itemCount == 0) 55 | return result; 56 | 57 | for(; itemIndex <= itemCount; itemIndex++) { 58 | PasteboardItemID itemID; 59 | err = PasteboardGetItemIdentifier(getPasteboard(),itemIndex,&itemID); 60 | if (err == noErr) { 61 | PasteboardFlavorFlags flavorFlags; 62 | err = PasteboardGetItemFlavorFlags(getPasteboard(),itemID,CFSTR("utf8"),&flavorFlags ); 63 | if (err == noErr) { 64 | err = PasteboardCopyItemFlavorData(getPasteboard(),itemID,CFSTR("utf8"),&data); 65 | if (err == noErr) { 66 | CFIndex length = CFDataGetLength(data); 67 | result = malloc(length+1); 68 | memcpy(result,CFDataGetBytePtr(data),length); 69 | result[length] = 0; 70 | } 71 | CFRelease(data); 72 | } 73 | if (result) break; 74 | } 75 | } 76 | return result; 77 | } 78 | 79 | void systools_clipboard_clear() { 80 | PasteboardSynchronize(getPasteboard()); 81 | PasteboardClear(getPasteboard()); 82 | } 83 | 84 | #else 85 | 86 | #include 87 | 88 | 89 | int systools_clipboard_set_text( const char * text ) { 90 | NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; 91 | [pasteboard clearContents]; 92 | [pasteboard writeObjects:[NSArray arrayWithObject:[NSString stringWithUTF8String:text]]]; 93 | return 0; 94 | } 95 | char* systools_clipboard_get_text() { 96 | NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; 97 | NSArray *classes = [[NSArray alloc] initWithObjects:[NSString class], nil]; 98 | NSArray *strings = [pasteboard readObjectsForClasses:classes options:nil]; 99 | if ([strings count] > 0) { 100 | NSString * value = [strings objectAtIndex:0]; 101 | char *string = malloc([value length]); 102 | strcpy(string, [value UTF8String]); 103 | return string; 104 | } 105 | return 0; 106 | } 107 | void systools_clipboard_clear() { 108 | NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; 109 | [pasteboard clearContents]; 110 | } 111 | 112 | #endif 113 | -------------------------------------------------------------------------------- /systools/SWFInfo.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, Edwin van Rijkom, Nicolas Cannasse, Lee McColl-Sylvester, Ian Thomas 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * - Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR 17 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 23 | * DAMAGE. 24 | */ 25 | package systools; 26 | 27 | import neko.FileSystem; 28 | import neko.io.File; 29 | import neko.io.FileInput; 30 | import neko.io.StringInput; 31 | 32 | class SWFInfo 33 | { 34 | public var width:Int; 35 | public var height:Int; 36 | public var version:Int; 37 | public var frameRate:Float; 38 | public var totalFrames:Int; 39 | 40 | /** Creates a new SWFInfo object and reads in the header of the file. 41 | * Note if it's a compressed file, the entire file has to be read in. 42 | * This only works for local files, not URLs 43 | */ 44 | public function new(file:String) 45 | { 46 | if (!FileSystem.exists(file)) 47 | throw "SWFInfo: Can't find SWF file '"+file+"'"; 48 | 49 | var f:FileInput=File.read(file,true); 50 | var magic:String=f.read(3); 51 | if ((magic!="FWS")&&(magic!="CWS")) 52 | throw "SWFInfo: Not a SWF file '"+file+"'"; 53 | 54 | version=f.readChar(); // SWF Version 55 | f.read(4); // Skip file length 56 | 57 | // If it's a compressed file, we'll need to decompress 58 | var buffer:String; 59 | if (magic=="CWS") 60 | buffer=neko.zip.Uncompress.run(f.readAll()); // Got to decompress the file *sigh* 61 | else 62 | buffer=f.read(24); // Should be plenty 63 | 64 | // Can close the file now 65 | f.close(); 66 | 67 | // Rect structure consists of a 5-bit size for the fields, followed by 4 fields of that size 68 | var b:Int=readBits(buffer,0,5); // Read the number of bits allocated to each rect entry 69 | var rectXMin:Int=readBits(buffer,5,b); 70 | var rectXMax:Int=readBits(buffer,5+b,b); 71 | var rectYMin:Int=readBits(buffer,5+b*2,b); 72 | var rectYMax:Int=readBits(buffer,5+b*3,b); 73 | 74 | width=Std.int((rectXMax-rectXMin)/20); // Convert from Twips 75 | height=Std.int((rectYMax-rectYMin)/20); // Convert from Twips 76 | 77 | // Now having done odd bit-field stuff, realign 78 | var rectLength:Int=Std.int((5+b*4)/8)+1; // That's how many chars the rect was stored in 79 | 80 | // Start a new input stream (so we can use it's methods) 81 | var input:StringInput=new StringInput(buffer,rectLength); 82 | 83 | // Frame rate stored as fixed point 8.8 (little-endian) 84 | var lsb:Int=input.readInt8(); 85 | var msb:Int=input.readInt8(); 86 | frameRate=Std.parseFloat(msb+"."+lsb); 87 | 88 | // Total frames - nice simply 2-byte value 89 | totalFrames=input.readInt16(); 90 | } 91 | 92 | // Extracts arbitrary-bit-length values from a string buffer starting at a particular pos (in bits) 93 | private function readBits(buffer:String,pos:Int,count:Int):Int 94 | { 95 | var loop:Int=pos; 96 | var result:Int=0; 97 | while(loop 20 | #include "win.h" 21 | #include "icons.h" 22 | 23 | /* 24 | * Based on: 25 | * http://www.koders.com/c/fidFB995E4CBABD7E2D87CD5C771C59EBF4EBB5B803.aspx 26 | * Copyright: (c) 2000, 2001, 2002, 2003 Thomas Heller 27 | */ 28 | int systools_win_replaceExeIcon( const char *exe, const char *ico, int iconResourceID ) { 29 | /* from the .ico file */ 30 | ICONDIRHEADER *pidh; 31 | WORD idh_size; 32 | /* for the resources */ 33 | GRPICONDIRHEADER *pgidh = NULL; 34 | WORD gidh_size; 35 | HANDLE hUpdate = NULL; 36 | int i; 37 | char *icodata; 38 | DWORD icosize; 39 | icodata = MapExistingFile(ico, &icosize); 40 | if (!icodata) 41 | return 0; 42 | 43 | pidh = (ICONDIRHEADER *)icodata; 44 | idh_size = sizeof(ICONDIRHEADER) + sizeof(ICONDIRENTRY) * pidh->idCount; 45 | 46 | pgidh = CreateGrpIconDirHeader(pidh, 1); 47 | gidh_size = sizeof(GRPICONDIRHEADER) + sizeof(GRPICONDIRENTRY) * pgidh->idCount; 48 | 49 | hUpdate = BeginUpdateResource(exe, FALSE); 50 | if (!hUpdate) goto failed; 51 | 52 | if (!UpdateResource 53 | ( hUpdate 54 | , MAKEINTRESOURCE(RT_GROUP_ICON) 55 | , MAKEINTRESOURCE(iconResourceID) 56 | , MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) 57 | , pgidh, gidh_size)) 58 | goto failed; 59 | 60 | for (i = 0; i < pidh->idCount; ++i) { 61 | char *cp = &icodata[pidh->idEntries[i].dwImageOffset]; 62 | int cBytes = pidh->idEntries[i].dwBytesInRes; 63 | if (!UpdateResource 64 | ( hUpdate 65 | , MAKEINTRESOURCE(RT_ICON) 66 | , MAKEINTRESOURCE(i+1) 67 | , MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) 68 | , cp, cBytes)) 69 | goto failed; 70 | } 71 | 72 | free(pgidh); 73 | UnmapViewOfFile(icodata); 74 | 75 | if (!EndUpdateResource(hUpdate, FALSE)) 76 | return 0; 77 | return 1; 78 | 79 | failed: 80 | if (pgidh) 81 | free(pgidh); 82 | if (hUpdate) 83 | EndUpdateResource(hUpdate, TRUE); 84 | if (icodata) 85 | UnmapViewOfFile(icodata); 86 | return 0; 87 | } 88 | 89 | int systools_win_create_process( const char *app, const char *args, const char *wd, int hide, int wait ) { 90 | STARTUPINFO si; 91 | PROCESS_INFORMATION pi; 92 | char *cmdline = malloc(32*1024); 93 | char wdir[MAX_PATH]; 94 | DWORD wdir_ok; 95 | 96 | sprintf(cmdline,"\"%s\" %s",app,args? args : ""); 97 | wdir_ok = wd ? GetShortPathName(wd,&wdir,MAX_PATH) : 0; 98 | 99 | memset(&si,0,sizeof(STARTUPINFO)); 100 | memset(&pi,0,sizeof(PROCESS_INFORMATION)); 101 | si.cb = sizeof(STARTUPINFO); 102 | si.dwX = si.dwY = si.dwXSize = si.dwYSize = CW_USEDEFAULT; 103 | si.wShowWindow = hide ? SW_HIDE : SW_SHOW; 104 | si.dwFlags 105 | = STARTF_USEPOSITION 106 | | STARTF_USESIZE 107 | | STARTF_USESHOWWINDOW 108 | | STARTF_FORCEONFEEDBACK; 109 | 110 | if (CreateProcess 111 | ( NULL 112 | , cmdline 113 | , NULL,NULL,0 114 | , CREATE_DEFAULT_ERROR_MODE 115 | , NULL 116 | , wdir_ok? wdir : NULL 117 | , &si, &pi)) { 118 | free(cmdline); 119 | if (wait) { 120 | WaitForInputIdle(pi.hProcess,INFINITE); 121 | WaitForSingleObject(pi.hProcess,INFINITE); 122 | } 123 | return 0; 124 | } 125 | free(cmdline); 126 | return GetLastError(); 127 | } -------------------------------------------------------------------------------- /project/src/win/icons.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ */ 2 | /* */ 3 | /* Systools - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ************************************************************************ */ 18 | 19 | /* 20 | * Based on: 21 | * http://www.koders.com/c/fidFB995E4CBABD7E2D87CD5C771C59EBF4EBB5B803.aspx 22 | * Copyright: (c) 2000, 2001, 2002, 2003 Thomas Heller 23 | */ 24 | 25 | /* 26 | * Ref for the icon code, from MSDN: 27 | * Icons in Win32 28 | * John Hornick 29 | * Microsoft Corporation 30 | * Created: September 29, 1995 31 | */ 32 | 33 | #pragma pack(2) 34 | 35 | /* Structure of .ico files */ 36 | 37 | typedef struct { 38 | BYTE bWidth; 39 | BYTE bHeight; 40 | BYTE bColorCount; 41 | BYTE bReserved; 42 | WORD wPlanes; 43 | WORD wBitCount; 44 | DWORD dwBytesInRes; 45 | DWORD dwImageOffset; 46 | } ICONDIRENTRY; 47 | 48 | typedef struct { 49 | WORD idReserved; /* Must be 0 */ 50 | WORD idType; /* Should check that this is 1 for icons */ 51 | WORD idCount; /* Number os ICONDIRENTRYs to follow */ 52 | ICONDIRENTRY idEntries[0]; 53 | } ICONDIRHEADER; 54 | 55 | /* Format of RT_GROUP_ICON resources */ 56 | 57 | typedef struct { 58 | BYTE bWidth; 59 | BYTE bHeight; 60 | BYTE bColorCount; 61 | BYTE bReserved; 62 | WORD wPlanes; 63 | WORD wBitCount; 64 | DWORD dwBytesInRes; 65 | WORD nID; 66 | } GRPICONDIRENTRY; 67 | 68 | typedef struct { 69 | WORD idReserved; 70 | WORD idType; 71 | WORD idCount; 72 | GRPICONDIRENTRY idEntries[0]; 73 | } GRPICONDIRHEADER; 74 | 75 | #pragma pack() 76 | 77 | /* 78 | * Map a file into memory for reading. 79 | * 80 | * Pointer returned must be freed with UnmapViewOfFile(). 81 | */ 82 | static char *MapExistingFile (const char*path, DWORD *psize) 83 | { 84 | HANDLE hFile, hFileMapping; 85 | DWORD nSizeLow, nSizeHigh; 86 | char *data; 87 | 88 | hFile = CreateFile 89 | ( path,GENERIC_READ, FILE_SHARE_READ, NULL 90 | , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL 91 | ); 92 | if (hFile == INVALID_HANDLE_VALUE) 93 | return NULL; 94 | nSizeLow = GetFileSize(hFile, &nSizeHigh); 95 | hFileMapping = CreateFileMapping(hFile, 96 | NULL, PAGE_READONLY, 0, 0, NULL); 97 | CloseHandle (hFile); 98 | 99 | if (hFileMapping == INVALID_HANDLE_VALUE) 100 | return NULL; 101 | 102 | data = MapViewOfFile(hFileMapping,FILE_MAP_READ, 0, 0, 0); 103 | 104 | CloseHandle(hFileMapping); 105 | *psize = nSizeLow; 106 | return data; 107 | } 108 | 109 | /* 110 | * Create a GRPICONDIRHEADER from an ICONDIRHEADER. 111 | * 112 | * Returns malloc()'d memory. 113 | */ 114 | static GRPICONDIRHEADER *CreateGrpIconDirHeader(ICONDIRHEADER *pidh, int icoid) 115 | { 116 | GRPICONDIRHEADER *pgidh; 117 | size_t size; 118 | int i; 119 | 120 | size = sizeof(GRPICONDIRHEADER) + sizeof(GRPICONDIRENTRY) * pidh->idCount; 121 | pgidh = (GRPICONDIRHEADER *)malloc(size); 122 | pgidh->idReserved = pidh->idReserved; 123 | pgidh->idType = pidh->idType; 124 | pgidh->idCount = pidh->idCount; 125 | 126 | for (i = 0; i < pidh->idCount; ++i) { 127 | pgidh->idEntries[i].bWidth = pidh->idEntries[i].bWidth; 128 | pgidh->idEntries[i].bHeight = pidh->idEntries[i].bHeight; 129 | pgidh->idEntries[i].bColorCount = pidh->idEntries[i].bColorCount; 130 | pgidh->idEntries[i].bReserved = pidh->idEntries[i].bReserved; 131 | pgidh->idEntries[i].wPlanes = pidh->idEntries[i].wPlanes; 132 | pgidh->idEntries[i].wBitCount = pidh->idEntries[i].wBitCount; 133 | pgidh->idEntries[i].dwBytesInRes = pidh->idEntries[i].dwBytesInRes; 134 | pgidh->idEntries[i].nID = icoid + i ; 135 | } 136 | return pgidh; 137 | } -------------------------------------------------------------------------------- /samples/10-win-menus/App.hx: -------------------------------------------------------------------------------- 1 | import systools.win.Tray; 2 | import systools.win.Menus; 3 | import systools.win.Events; 4 | 5 | class App { 6 | 7 | static var flash : swhx.Flash; 8 | static var cnx: swhx.Connection; 9 | static var window: swhx.Window; 10 | static var hook: swhx.MessageHook; 11 | static var thook: swhx.MessageHook; 12 | static var mhook: swhx.MessageHook; 13 | static var tray: Tray; 14 | static var m: Menus; 15 | static var mm: Menus; 16 | static var ms1: Menus; 17 | static var ms11: Menus; 18 | static var ms2: Menus; 19 | static var ms3: Menus; 20 | 21 | static function main() { 22 | // initialize ScreenWeaver HX 23 | swhx.Application.init(); 24 | 25 | // create a 400x300 window 26 | window = new swhx.Window("Window Message Hooks",400,300); 27 | 28 | window.onRightClick = function() { 29 | return false; 30 | } 31 | 32 | // clean up after ourselves: 33 | window.onClose = cleanUp; 34 | 35 | // create an incoming communication Server 36 | var server = new neko.net.RemotingServer(); 37 | 38 | // share the App object 39 | server.addObject("App",App); 40 | 41 | // create a flash object inside this window 42 | // pass the server as parameter 43 | flash = new swhx.Flash(window,server); 44 | 45 | // set the HTML attributes of this flash object 46 | flash.setAttribute("src","ui.swf"); 47 | 48 | // capture loaded event: 49 | flash.onSourceLoaded = onSourceLoaded; 50 | 51 | // activate the Flash object 52 | flash.start(); 53 | 54 | // enter the system event loop (will exit when window is closed) 55 | swhx.Application.loop(); 56 | 57 | // cleanup SWHX properly 58 | swhx.Application.cleanup(); 59 | } 60 | 61 | static function onSourceLoaded() { 62 | cnx = swhx.Connection.flashConnect(flash); 63 | window.show(true); 64 | trace("Window handle is:"+window.handle+" (will be readable when passed to an .ndll)"); 65 | 66 | /* 67 | * The numeric value passed to addItem, addDivider and addSubmenu dictate where 68 | * the item will be placed as well as what value is returned to the window hook 69 | * handler. Make sure these are unique throughout the entire menu hierarchy 70 | */ 71 | 72 | mm = new systools.win.Menus( false ); 73 | 74 | ms1 = new systools.win.Menus( true ); 75 | ms1.addItem( "sub 1-1", 4 ); 76 | ms1.addItem( "sub 1-2", 5 ); 77 | ms1.addItem( "sub 1-3", 6 ); 78 | 79 | ms11 = new systools.win.Menus( true ); 80 | ms11.addItem( "sub 1-4-1", 4 ); 81 | ms11.addItem( "sub 1-4-2", 5 ); 82 | ms11.addItem( "sub 1-4-3", 6 ); 83 | 84 | ms1.addSubmenu( ms11, "sub 1-4", 13 ); 85 | 86 | ms2 = new systools.win.Menus( true ); 87 | ms2.addItem( "sub 2-1", 7 ); 88 | ms2.addItem( "sub 2-2", 8 ); 89 | ms2.addItem( "sub 2-3", 9 ); 90 | 91 | ms3 = new systools.win.Menus( true ); 92 | ms3.addItem( "sub 3-1", 10 ); 93 | ms3.addItem( "sub 3-2", 11 ); 94 | ms3.addItem( "sub 3-3", 12 ); 95 | 96 | mm.addSubmenu( ms1, "option 1", 1 ); 97 | mm.addSubmenu( ms2, "option 2", 2 ); 98 | mm.addSubmenu( ms3, "option 3", 3 ); 99 | 100 | mm.show( window.handle ); 101 | m = new systools.win.Menus( true ); 102 | m.addItem( "option 1", 1 ); 103 | m.addItem( "option 2", 2 ); 104 | m.addItem( "option 3", 3 ); 105 | 106 | hook = window.addMessageHook(untyped Events.RBUTTONUP); 107 | hook.setNekoCallback(mouseMoveHook); 108 | mhook = window.addMessageHook(untyped Events.MENUEVENT); 109 | mhook.setNekoCallback(menuClickHook); 110 | thook = window.addMessageHook(untyped Events.TRAYEVENT); 111 | thook.setNekoCallback(mouseRightClickHook); 112 | 113 | tray = new Tray(window,"swhx_16x16.ico","Hello Tray!"); 114 | } 115 | 116 | static function mouseMoveHook() { 117 | trace( "Option " + m.showPopup( window.handle ) + " was selected!" ); 118 | return 0; 119 | } 120 | 121 | static function menuClickHook() { 122 | trace( "Option " + mhook.p1 + ", " + mhook.p2 + ", " + hook.callbackData + " was clicked!"); 123 | return 0; 124 | } 125 | 126 | static function mouseRightClickHook() { 127 | if ( Std.string(thook.p2) == Std.string(Events.RBUTTONUP) ) 128 | trace( "Option " + m.showPopup( window.handle ) + " was selected!" ); 129 | return 0; 130 | } 131 | 132 | static function cleanUp() { 133 | /* 134 | All release methods fire exceptions!Needs looking into ... 135 | */ 136 | 137 | //ms11.dispose(); 138 | //ms1.dispose(); 139 | //ms2.dispose(); 140 | //ms3.dispose(); 141 | //mm.dispose(); 142 | //m.dispose(); 143 | window.removeMessageHook(hook); 144 | window.removeMessageHook(mhook); 145 | window.removeMessageHook(thook); 146 | //tray.dispose(); 147 | // allow window to close: 148 | return true; 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /project/src/mac/registry.m: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ************************************************************************ */ 18 | 19 | // debug 20 | // #define DEBUG_REGISTRY 21 | 22 | // helper macro 23 | #ifdef CARBON 24 | 25 | #import 26 | 27 | #define CONVERT_APP\ 28 | CFMutableStringRef app = CFStringCreateMutableCopy(NULL,0,CFStringCreateWithCString(NULL,subkey,kCFStringEncodingUTF8));\ 29 | CFRange range = CFRangeMake(0,CFStringGetLength(app));\ 30 | CFStringFindAndReplace(app,CFSTR("\\"),CFSTR("."),range,0);\ 31 | 32 | void systools_registry_set_value(int _, const char *subkey, const char *valuename, const char *value) { 33 | CONVERT_APP; 34 | 35 | #ifdef DEBUG_REGISTRY 36 | char capp[1024]; 37 | CFStringGetCString(app,capp,1024,kCFStringEncodingUTF8); 38 | printf("set: (%s - %s)\n[%s]\n",subkey,valuename,capp); 39 | #endif 40 | 41 | if (strlen(valuename)) { 42 | CFStringRef key = CFStringCreateWithCString(0,valuename,kCFStringEncodingUTF8); 43 | CFPreferencesSetAppValue 44 | ( key 45 | , strlen(value)? CFStringCreateWithCString(0,value,kCFStringEncodingUTF8) : CFSTR("") 46 | , app); 47 | CFPreferencesAppSynchronize(app); 48 | } 49 | } 50 | 51 | char * systools_registry_get_value( int _, const char *subkey, const char *valuename ) { 52 | char *result = NULL; 53 | CONVERT_APP; 54 | CFPreferencesAppSynchronize(app); 55 | 56 | #ifdef DEBUG_REGISTRY 57 | char capp[1024]; 58 | CFStringGetCString(app,capp,1024,kCFStringEncodingUTF8); 59 | printf("get: (%s - %s)\n[%s]\n",subkey,valuename,capp); 60 | #endif 61 | 62 | if (strlen(valuename)) { 63 | CFStringRef key = CFStringCreateWithCString(NULL,valuename,kCFStringEncodingUTF8); 64 | CFPropertyListRef property = CFPreferencesCopyAppValue(key,app); 65 | 66 | if (property && CFGetTypeID(property) == CFGetTypeID(CFSTR(""))) { 67 | CFStringRef cfvalue = (CFStringRef) property; 68 | CFIndex length = CFStringGetMaximumSizeForEncoding(CFStringGetLength(cfvalue),kCFStringEncodingUTF8); 69 | result = malloc(length+1); 70 | CFStringGetCString(cfvalue,result,length,kCFStringEncodingUTF8); 71 | result[length] = 0; 72 | CFRelease(property); 73 | } 74 | } 75 | return result; 76 | } 77 | 78 | void systools_registry_delete_key( int _, const char * subkey ) { 79 | CONVERT_APP; 80 | CFIndex i = 0; 81 | CFPreferencesAppSynchronize(app); 82 | 83 | #ifdef DEBUG_REGISTRY 84 | char capp[1024]; 85 | CFStringGetCString(app,capp,1024,kCFStringEncodingUTF8); 86 | printf("del: (%s)\n[%s]\n",subkey,capp); 87 | #endif 88 | 89 | CFArrayRef keys = CFPreferencesCopyKeyList(app,kCFPreferencesCurrentUser,kCFPreferencesAnyHost); 90 | if(keys) { 91 | while(i < CFArrayGetCount(keys)) { 92 | CFStringRef key = CFArrayGetValueAtIndex(keys,i); 93 | CFRetain(key); 94 | if (key) { 95 | char ckey[1024]; 96 | CFStringGetCString(key,ckey,1024,kCFStringEncodingUTF8); 97 | CFPreferencesSetAppValue(key,NULL,app); 98 | i++; 99 | } 100 | CFRelease(key); 101 | } 102 | CFRelease(keys); 103 | } 104 | CFPreferencesAppSynchronize(app); 105 | } 106 | 107 | #else 108 | 109 | // use Cocoa instead 110 | #import 111 | 112 | void systools_registry_set_value(int key, const char *subkey, const char *valuename, const char *value) { 113 | NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; 114 | [userDefaults setObject:[NSString stringWithUTF8String:value] forKey:[NSString stringWithUTF8String:valuename]]; 115 | } 116 | 117 | char *systools_registry_get_value(int key, const char *subkey, const char *valuename) { 118 | NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; 119 | NSString *obj = [userDefaults stringForKey:[NSString stringWithUTF8String:valuename]]; 120 | char *string = malloc([obj length]); 121 | strcpy(string, [obj UTF8String]); 122 | return string; 123 | } 124 | 125 | void systools_registry_delete_key(int key, const char * subkey) { 126 | NSLog(@"Registry deletion not supported on OSX"); 127 | } 128 | 129 | #endif -------------------------------------------------------------------------------- /project/src/linux/dialogs.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom, */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ************************************************************************ */ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | #include "dialogs.h" 29 | 30 | void systools_dialogs_message_box( const char *title, const char *message, int error ) { 31 | GtkWidget *dialog = gtk_message_dialog_new( NULL, 32 | (GtkDialogFlags) 0, 33 | error > 0 ? GTK_MESSAGE_ERROR : GTK_MESSAGE_INFO, 34 | GTK_BUTTONS_OK, "%s", message ); 35 | 36 | gtk_dialog_run( GTK_DIALOG(dialog) ); 37 | gtk_widget_destroy( dialog ); 38 | while (gtk_events_pending()) gtk_main_iteration(); 39 | } 40 | 41 | int systools_dialogs_dialog_box( const char *title, const char *message, int error ) { 42 | GtkWidget *dialog = gtk_message_dialog_new( NULL, 43 | (GtkDialogFlags) 0, 44 | error > 0 ? GTK_MESSAGE_WARNING : GTK_MESSAGE_QUESTION, 45 | GTK_BUTTONS_OK_CANCEL, "%s", message ); 46 | 47 | gint response = gtk_dialog_run( GTK_DIALOG(dialog) ); 48 | gtk_widget_destroy( dialog ); 49 | while (gtk_events_pending()) gtk_main_iteration(); 50 | return (response==GTK_RESPONSE_OK)?1:0; 51 | } 52 | 53 | char* systools_dialogs_save_file( const char *title, const char* msg, const char *initialdir, struct ARG_FILEFILTERS *filters ) { 54 | char *result = NULL; 55 | 56 | GtkWidget *dialog; 57 | 58 | dialog = gtk_file_chooser_dialog_new (title, 59 | NULL, 60 | GTK_FILE_CHOOSER_ACTION_SAVE, 61 | GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, 62 | GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, 63 | NULL); 64 | 65 | if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { 66 | result = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(dialog) ); 67 | } 68 | 69 | gtk_widget_destroy (dialog); 70 | while (gtk_events_pending()) gtk_main_iteration(); 71 | 72 | return result; 73 | } 74 | 75 | void systools_dialogs_open_file( const char *title, const char *msg, struct ARG_FILEFILTERS *filters, int multi, struct RES_STRINGLIST *result) { 76 | result->count = 0; 77 | result->strings = NULL; 78 | 79 | /* NOTE: GtkFileChooserDialog doesnt seem to support filetype descriptions? 80 | we put all extensions into a GtkFileFilter */ 81 | GtkFileFilter *filter = gtk_file_filter_new(); 82 | int i = filters->count; 83 | int j; 84 | while( i>0 ) { 85 | i--; 86 | j=0; 87 | char **globs = g_strsplit(filters->extensions[i],";",0); 88 | while( globs[j]!=NULL ) { 89 | gtk_file_filter_add_pattern( filter, globs[j] ); 90 | j++; 91 | } 92 | g_strfreev( globs ); 93 | } 94 | 95 | 96 | GtkWidget *dialog; 97 | 98 | dialog = gtk_file_chooser_dialog_new (title, 99 | NULL, 100 | GTK_FILE_CHOOSER_ACTION_OPEN, 101 | GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, 102 | GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, 103 | NULL); 104 | gtk_file_chooser_set_select_multiple( GTK_FILE_CHOOSER (dialog), TRUE ); 105 | gtk_file_chooser_set_filter( GTK_FILE_CHOOSER (dialog), filter ); 106 | 107 | if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { 108 | GSList *files = gtk_file_chooser_get_filenames( GTK_FILE_CHOOSER(dialog) ); 109 | long i = result->count = g_slist_length( files ); 110 | result->strings = (char**)malloc( i * sizeof(char*) ); 111 | while( i ) { 112 | i--; 113 | result->strings[i] = (gchar*)g_slist_nth_data( files, i ); 114 | } 115 | g_slist_free( files ); 116 | } 117 | 118 | gtk_widget_destroy (dialog); 119 | while (gtk_events_pending()) gtk_main_iteration(); 120 | } 121 | 122 | char* systools_dialogs_folder( const char *title, const char *msg ) { 123 | char *result = NULL; 124 | 125 | GtkWidget *dialog; 126 | 127 | dialog = gtk_file_chooser_dialog_new (title, 128 | NULL, 129 | GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, 130 | GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, 131 | GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, 132 | NULL); 133 | 134 | if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { 135 | result = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(dialog) ); 136 | } 137 | 138 | gtk_widget_destroy (dialog); 139 | while (gtk_events_pending()) gtk_main_iteration(); 140 | 141 | return result; 142 | } 143 | #ifdef __cplusplus 144 | } 145 | #endif 146 | -------------------------------------------------------------------------------- /project/src/win/menus.c: -------------------------------------------------------------------------------- 1 | /* ******************************************************************************** */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Lee McColl-Sylvester, Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ******************************************************************************** */ 18 | 19 | #include "menus.h" 20 | #include 21 | #include 22 | 23 | const char tray_icon_error[255]; 24 | #define set_tray_error(x) strcpy((char*)&tray_icon_error,x) 25 | 26 | tray_icon *systools_win_create_tray_icon(HWND *wnd,const char *ico,const char *tooltip){ 27 | 28 | HICON hIcon = 0; 29 | 30 | if (!ico && !tooltip) { 31 | set_tray_error("SetTrayIcon; invalid arguments"); 32 | return NULL; 33 | } 34 | 35 | if (strlen (ico) == 0) { 36 | set_tray_error("SetTrayIcon; invalid icon path"); 37 | return NULL; 38 | } 39 | 40 | hIcon = (HICON) LoadImage( 0, ico, IMAGE_ICON, 0, 0, LR_LOADFROMFILE ); 41 | 42 | if (hIcon==NULL) { 43 | set_tray_error("SetTrayIcon; failed loading icon"); 44 | return NULL; 45 | } else { 46 | long nid_size = sizeof(NOTIFYICONDATA); 47 | tray_icon *tray = malloc(sizeof(tray_icon)); 48 | DWORD dwSetType = NIM_ADD; 49 | tray->icon_data = malloc(nid_size); 50 | tray->icon_handle = hIcon; 51 | tray->msg_callback = tray_menu_cb; 52 | 53 | tray->icon_data->cbSize = nid_size; 54 | tray->icon_data->hWnd = wnd; // handle to window: 55 | tray->icon_data->uID = 0; // unique id, for support of more than 1 tray icon at the same, not using this. 56 | tray->icon_data->uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; // flags 57 | tray->icon_data->uCallbackMessage = 9001; // WMU_TRAYICON_HOVER callback 58 | tray->icon_data->hIcon = hIcon; // the icon 59 | strcpy( tray->icon_data->szTip, tooltip ); // tooltip: 60 | 61 | if( !Shell_NotifyIcon( dwSetType, tray->icon_data ) ) { 62 | free(tray->icon_data); 63 | free(tray); 64 | set_tray_error("SetTrayIcon Failed"); 65 | return NULL; 66 | } 67 | return tray; 68 | } 69 | return 0; 70 | } 71 | 72 | void systools_win_destroy_tray_icon( tray_icon *icon ) 73 | { 74 | Shell_NotifyIcon( NIM_DELETE, icon->icon_data ); 75 | DestroyIcon(icon->icon_handle); 76 | free(icon->icon_data); 77 | free(icon); 78 | } 79 | 80 | void* tray_menu_cb( void* data, void* msgid, void* msgid2, void* p1, void* p2 ) 81 | { 82 | tray_icon *tray = (tray_icon*) data; 83 | printf( "%i - %i - %i - %i\n", msgid, msgid2, p1, p2 ); 84 | } 85 | 86 | 87 | 88 | // Menus code 89 | HMENU *systools_menu_create() 90 | { 91 | HMENU *hmenu = malloc(sizeof(HMENU)); 92 | *hmenu = CreateMenu(); 93 | return hmenu; 94 | } 95 | 96 | HMENU *systools_popup_menu_create() 97 | { 98 | HMENU *hmenu = malloc(sizeof(HMENU)); 99 | *hmenu = CreatePopupMenu(); 100 | return hmenu; 101 | } 102 | 103 | void systools_menu_destroy( HMENU *hmenu ) 104 | { 105 | DestroyMenu( *hmenu ); 106 | } 107 | 108 | int systools_menu_add_item( HMENU *hmenu, const char *caption, DWORD callbackID ) 109 | { 110 | int bResult = 0; 111 | 112 | if (caption) 113 | { 114 | MENUITEMINFO mii; 115 | memset(&mii, 0, sizeof(MENUITEMINFO)); 116 | mii.cbSize = sizeof( MENUITEMINFO ); 117 | mii.fMask = MIIM_TYPE | MIIM_ID; 118 | if (strcmp(caption,"--")) 119 | mii.fType = MFT_STRING; 120 | else 121 | mii.fType = MFT_SEPARATOR; 122 | mii.dwTypeData = caption; 123 | mii.wID = callbackID; 124 | mii.hSubMenu = *hmenu; 125 | 126 | InsertMenuItem( 127 | *hmenu, 128 | callbackID, 129 | TRUE, 130 | &mii ); 131 | 132 | bResult = 1; 133 | } 134 | 135 | return bResult; 136 | } 137 | 138 | int systools_menu_add_submenu( HMENU *hmenu, HMENU *submenu, const char *caption, DWORD callbackID ) 139 | { 140 | int bResult = 0; 141 | 142 | if (caption) 143 | { 144 | InsertMenu(*hmenu, callbackID, MF_STRING | MF_POPUP, (UINT)*submenu, caption); 145 | bResult = 1; 146 | } 147 | 148 | return bResult; 149 | } 150 | 151 | int systools_popup_menu_show( HWND *hwnd, HMENU *hmenu ) 152 | { 153 | int t; 154 | POINT pt; 155 | GetCursorPos(&pt); 156 | t = TrackPopupMenu(*hmenu, 157 | TPM_RIGHTBUTTON | TPM_RETURNCMD, 158 | pt.x, 159 | pt.y, 160 | 0, 161 | hwnd, 162 | NULL); 163 | return t; 164 | } 165 | 166 | int systools_menu_show( HWND *hwnd, HMENU *hmenu ) 167 | { 168 | int t; 169 | POINT pt; 170 | GetCursorPos(&pt); 171 | t = SetMenu(hwnd, *hmenu); 172 | return t; 173 | } -------------------------------------------------------------------------------- /systools/win/Events.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Edwin van Rijkom, Nicolas Cannasse, Lee McColl-Sylvester 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * - Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR 17 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 23 | * DAMAGE. 24 | */ 25 | 26 | package systools.win; 27 | 28 | class Events { 29 | public static var TRAYEVENT = 0x2329; 30 | public static var COMMAND = 0x0111; 31 | public static var RBUTTONUP = 0x0204; 32 | public static var LBUTTONUP = 0x0205; 33 | 34 | public static var CREATE = 0x0001; 35 | public static var DESTROY = 0x0002; 36 | public static var MOVE = 0x0003; 37 | public static var SIZE = 0x0005; 38 | public static var ACTIVATE = 0x0006; 39 | public static var SETFOCUS = 0x0007; 40 | public static var KILLFOCUS = 0x0008; 41 | public static var ENABLE = 0x000A; 42 | public static var PAINT = 0x000F; 43 | public static var CLOSE = 0x0010; 44 | public static var QUIT = 0x0012; 45 | public static var SHOWWINDOW = 0x0018; 46 | public static var MOUSEACTIVATE = 0x0021; 47 | public static var WINDOWPOSCHANGING = 0x0046; 48 | public static var WINDOWPOSCHANGED = 0x0047; 49 | public static var CONTEXTMENU = 0x007B; 50 | public static var DISPLAYCHANGE = 0x007E; 51 | public static var NCCREATE = 0x0081; 52 | public static var NCDESTROY = 0x0082; 53 | public static var NCCALCSIZE = 0x0083; 54 | public static var NCHITTEST = 0x0084; 55 | public static var NCPAINT = 0x0085; 56 | public static var NCACTIVATE = 0x0086; 57 | public static var NCMOUSEMOVE = 0x00A0; 58 | public static var NCLBUTTONDOWN = 0x00A1; 59 | public static var NCLBUTTONUP = 0x00A2; 60 | public static var NCLBUTTONDBLCLK = 0x00A3; 61 | public static var NCRBUTTONDOWN = 0x00A4; 62 | public static var NCRBUTTONUP = 0x00A5; 63 | public static var NCRBUTTONDBLCLK = 0x00A6; 64 | public static var NCMBUTTONDOWN = 0x00A7; 65 | public static var NCMBUTTONUP = 0x00A8; 66 | public static var NCMBUTTONDBLCLK = 0x00A9; 67 | public static var NCXBUTTONDOWN = 0x00AB; 68 | public static var NCXBUTTONUP = 0x00AC; 69 | public static var NCXBUTTONDBLCLK = 0x00AD; 70 | public static var KEYDOWN = 0x0100; 71 | public static var KEYUP = 0x0101; 72 | public static var SYSKEYDOWN = 0x0104; 73 | public static var SYSKEYUP = 0x0105; 74 | public static var INITDIALOG = 0x0110; 75 | public static var INITMENU = 0x0116; 76 | public static var INITMENUPOPUP = 0x0117; 77 | public static var MENUSELECT = 0x011F; 78 | public static var MENUCHAR = 0x0120; 79 | public static var ENTERIDLE = 0x0121; 80 | public static var MENURBUTTONUP = 0x0122; 81 | public static var MENUDRAG = 0x0123; 82 | public static var MENUGETOBJECT = 0x0124; 83 | public static var UNINITMENUPOPUP = 0x0125; 84 | public static var MENUCOMMAND = 0x0126; 85 | public static var MOUSEFIRST = 0x0200; 86 | public static var MOUSEMOVE = 0x0200; 87 | public static var LBUTTONDOWN = 0x0201; 88 | public static var LBUTTONDBLCLK = 0x0203; 89 | public static var RBUTTONDOWN = 0x0204; 90 | public static var RBUTTONDBLCLK = 0x0206; 91 | public static var MBUTTONDOWN = 0x0207; 92 | public static var MBUTTONUP = 0x0208; 93 | public static var MBUTTONDBLCLK = 0x0209; 94 | public static var XBUTTONDOWN = 0x020B; 95 | public static var XBUTTONUP = 0x020C; 96 | public static var XBUTTONDBLCLK = 0x020D; 97 | public static var ENTERMENULOOP = 0x0211; 98 | public static var EXITMENULOOP = 0x0212; 99 | public static var SIZING = 0x0214; 100 | public static var CAPTURECHANGED = 0x0215; 101 | public static var MOVING = 0x0216; 102 | public static var ENTERSIZEMOVE = 0x0231; 103 | public static var EXITSIZEMOVE = 0x0232; 104 | public static var DROPFILES = 0x0233; 105 | public static var MOUSEHOVER = 0x02A1; 106 | public static var MOUSELEAVE = 0x02A3; 107 | public static var NCMOUSEHOVER = 0x02A0; 108 | public static var NCMOUSELEAVE = 0x02A2; 109 | public static var CUT = 0x0300; 110 | public static var COPY = 0x0301; 111 | public static var PASTE = 0x0302; 112 | public static var CLEAR = 0x0303; 113 | public static var UNDO = 0x0304; 114 | } -------------------------------------------------------------------------------- /project/src/win/dialogs.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ************************************************************************ */ 18 | 19 | #include "../dialogs.h" 20 | #include 21 | #include "shlobj.h" 22 | 23 | void systools_dialogs_message_box( const char *title, const char *message, int error ) { 24 | MessageBox(NULL,message,title,MB_OK | (error ? MB_ICONERROR : MB_ICONINFORMATION)); 25 | } 26 | 27 | int systools_dialogs_dialog_box( const char *title, const char *message, int error ) { 28 | return MessageBox(NULL,message,title,MB_TASKMODAL | MB_OK | MB_YESNO | (error ? MB_ICONERROR : MB_ICONINFORMATION)) == IDYES; 29 | } 30 | 31 | char* systools_dialogs_save_file( const char *title, const char *_, const char *initialdir, struct ARG_FILEFILTERS *mask) { 32 | char* result = 0; 33 | OPENFILENAME ofn; 34 | 35 | memset(&ofn,0,sizeof(ofn)); 36 | ofn.lStructSize = sizeof(ofn); 37 | ofn.lpstrTitle = (char*) title; 38 | ofn.lpstrInitialDir = (char*) initialdir; 39 | ofn.Flags = OFN_PATHMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER; 40 | ofn.nMaxFile = 8192; /* This is madnes: Windows wants us to 41 | predict how many characters the user 42 | selected files will be at max. Let me 43 | fetch my glass ball... 44 | Using 8k for now. */ 45 | ofn.lpstrFile = malloc(8192); 46 | ofn.lpstrFile[0] = 0; 47 | 48 | if (mask && mask->count) { 49 | long i = mask->count; 50 | size_t s = 0, el = 0, dl = 0; 51 | 52 | while (i) { 53 | i--; 54 | el = +strlen(mask->extensions[i])+1; 55 | dl = strlen(mask->descriptions[i])+1; 56 | ofn.lpstrFilter = realloc 57 | ( ofn.lpstrFilter 58 | , s + dl + el + (i==0? 1 : 0) 59 | ); 60 | strcpy(ofn.lpstrFilter+(s),mask->descriptions[i]); 61 | strcpy(ofn.lpstrFilter+(s+=dl),mask->extensions[i]); 62 | s+=el; 63 | // last pass, add term. zero: 64 | if (i==0) 65 | memset(ofn.lpstrFilter+s,0,1); 66 | } 67 | } 68 | 69 | if( GetSaveFileName(&ofn ) ){ 70 | result = strdup( ofn.lpstrFile ); 71 | free(ofn.lpstrFile); 72 | return result; 73 | }else{ 74 | return NULL; 75 | } 76 | } 77 | 78 | void systools_dialogs_open_file( const char *title, const char *msg, struct ARG_FILEFILTERS *mask , int multi, struct RES_STRINGLIST *r){ 79 | OPENFILENAME ofn; 80 | r->count = 0; 81 | r->strings = NULL; 82 | 83 | memset(&ofn,0,sizeof(ofn)); 84 | ofn.lStructSize = sizeof(ofn); 85 | ofn.lpstrTitle = (char*) title; 86 | 87 | if(multi){ 88 | ofn.Flags = OFN_PATHMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER | OFN_HIDEREADONLY; 89 | }else{ 90 | ofn.Flags = OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_HIDEREADONLY; 91 | } 92 | 93 | ofn.nMaxFile = 8192; /* This is madnes: Windows wants us to 94 | predict how many characters the user 95 | selected files will be at max. Let me 96 | fetch my glass ball... 97 | Using 8k for now. */ 98 | ofn.lpstrFile = malloc(8192); 99 | memset(ofn.lpstrFile, 0, 8192);//zero memory is always good 100 | ofn.lpstrFile[0] = 0; 101 | 102 | if (mask && mask->count) { 103 | long i = mask->count; 104 | size_t s = 0, el = 0, dl = 0; 105 | 106 | while (i) { 107 | i--; 108 | el = +strlen(mask->extensions[i])+1; 109 | dl = strlen(mask->descriptions[i])+1; 110 | ofn.lpstrFilter = realloc 111 | ( ofn.lpstrFilter 112 | , s + dl + el + (i==0? 1 : 0) 113 | ); 114 | strcpy(ofn.lpstrFilter+(s),mask->descriptions[i]); 115 | strcpy(ofn.lpstrFilter+(s+=dl),mask->extensions[i]); 116 | s+=el; 117 | // last pass, add term. zero: 118 | if (i==0) 119 | memset(ofn.lpstrFilter+s,0,1); 120 | } 121 | } 122 | 123 | if (GetOpenFileName(&ofn)) { 124 | char* file = ofn.lpstrFile; 125 | char* folder = NULL; 126 | long pass = 1; 127 | while(*file!=0) { 128 | size_t len = strlen(file); 129 | len++; 130 | if (pass==1) { 131 | r->strings = realloc(r->strings,sizeof(char*)*(r->count+1)); 132 | r->strings[r->count] = strdup(file); 133 | folder = file; 134 | r->count++; 135 | } else if (pass==2) { 136 | r->strings[0] = realloc(r->strings[0],strlen(r->strings[0])+strlen(file)+2); 137 | strcat(r->strings[0], "\\"); 138 | strcat(r->strings[0], file); 139 | } else { 140 | r->strings = realloc(r->strings,sizeof(char*)*(r->count+1)); 141 | r->strings[r->count] = malloc(strlen(folder)+strlen(file)+2); 142 | strcpy(r->strings[r->count], folder); 143 | strcat(r->strings[r->count], "\\"); 144 | strcat(r->strings[r->count], file); 145 | r->count++; 146 | } 147 | file += len; 148 | pass++; 149 | } 150 | } 151 | free(ofn.lpstrFile); 152 | } 153 | 154 | char* systools_dialogs_folder( const char *title, const char *msg ) { 155 | BROWSEINFO bi; 156 | LPCITEMIDLIST folderID; 157 | TCHAR szFolderDisplay[MAX_PATH]; 158 | TCHAR szFolderPath[MAX_PATH]; 159 | 160 | memset( szFolderDisplay, 0, MAX_PATH); 161 | memset( szFolderPath, 0, MAX_PATH); 162 | 163 | bi.hwndOwner = NULL; // handle of parent window 164 | bi.pidlRoot = NULL; // Starting directory..NULL for "My Computer" 165 | bi.pszDisplayName = szFolderDisplay; // buffer which recieves the path of chosen directory. 166 | bi.lpszTitle = title; // text displayed in dialog's static control. 167 | bi.ulFlags = BIF_RETURNONLYFSDIRS; // flag saying only directory's can be returned. 168 | bi.lpfn = NULL; // NULL meaning no hook proc. 169 | 170 | folderID= SHBrowseForFolder(&bi); 171 | 172 | if(folderID) 173 | { 174 | SHGetPathFromIDList(folderID,szFolderPath); 175 | return strdup(szFolderPath); 176 | } 177 | return NULL; 178 | } -------------------------------------------------------------------------------- /project/src/mac/dialogs.m: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ************************************************************************ */ 18 | 19 | #include "dialogs.h" 20 | #ifdef CARBON 21 | #include 22 | #else 23 | #include 24 | #endif 25 | 26 | #define PATH_SIZE 2048 27 | 28 | // helpers: 29 | #if CARBON 30 | static Boolean filterProc(AEDesc * theItem, void * info, void * callBackUD, NavFilterModes filterMode); 31 | static OSStatus GetFSRefFromAEDesc( FSRef *fsRef, AEDesc* theItem ); 32 | #endif 33 | 34 | // main: 35 | 36 | void systools_dialogs_message_box( const char *title, const char *message, int error ) { 37 | #ifdef CARBON 38 | CFOptionFlags result; 39 | CFUserNotificationDisplayAlert 40 | ( 0, error? 0 : kCFUserNotificationCautionAlertLevel 41 | , 0, 0, 0 42 | , CFStringCreateWithCString(NULL,title,kCFStringEncodingUTF8) 43 | , CFStringCreateWithCString(NULL,message,kCFStringEncodingUTF8) 44 | , 0, 0, 0 45 | , &result ); 46 | #else 47 | NSAlert *alert = [[NSAlert alloc] init]; 48 | [alert setMessageText:[NSString stringWithUTF8String:title]]; 49 | [alert setInformativeText:[NSString stringWithUTF8String:message]]; 50 | [alert runModal]; 51 | #endif 52 | } 53 | 54 | int systools_dialogs_dialog_box( const char *title, const char *message, int error ) { 55 | #ifdef CARBON 56 | CFOptionFlags result; 57 | CFUserNotificationDisplayAlert 58 | ( 0, error? 0 : kCFUserNotificationCautionAlertLevel 59 | , 0, 0, 0 60 | , CFStringCreateWithCString(NULL,title,kCFStringEncodingUTF8) 61 | , CFStringCreateWithCString(NULL,message,kCFStringEncodingUTF8) 62 | , CFSTR("Yes"), CFSTR("No"), 0 63 | , &result ); 64 | 65 | return kCFUserNotificationDefaultResponse == result ? 1 : 0; 66 | #else 67 | NSAlert *alert = [[NSAlert alloc] init]; 68 | [alert setMessageText:[NSString stringWithUTF8String:title]]; 69 | [alert setInformativeText:[NSString stringWithUTF8String:message]]; 70 | [alert addButtonWithTitle:@"OK"]; 71 | [alert addButtonWithTitle:@"Cancel"]; 72 | return [alert runModal] == NSAlertFirstButtonReturn ? 1 : 0; 73 | #endif 74 | } 75 | 76 | char* systools_dialogs_save_file( const char *title, const char* msg, const char *initialdir, struct ARG_FILEFILTERS *filters ) { 77 | #ifdef CARBON 78 | char *result = NULL; 79 | NavDialogRef ref; 80 | NavDialogCreationOptions opt; 81 | 82 | NavGetDefaultDialogCreationOptions(&opt); 83 | opt.clientName = CFStringCreateWithCString(NULL,title,kCFStringEncodingUTF8); 84 | opt.message = CFStringCreateWithCString(NULL,msg,kCFStringEncodingUTF8); 85 | opt.modality = kWindowModalityAppModal; 86 | 87 | if (NavCreatePutFileDialog(&opt,0,kNavGenericSignature,NULL,NULL,&ref) == noErr) { 88 | 89 | if (NavDialogRun(ref) == noErr) { 90 | if (NavDialogGetUserAction(ref) == kNavUserActionSaveAs) { 91 | NavReplyRecord reply; 92 | if (NavDialogGetReply(ref,&reply) == kNavNormalState) { 93 | FSRef fsref; 94 | result = malloc(PATH_SIZE); 95 | memset(result,0,PATH_SIZE); 96 | GetFSRefFromAEDesc(&fsref,&reply.selection); 97 | if (FSRefMakePath (&fsref,(UInt8*)result,PATH_SIZE)==noErr) { 98 | strcat(result,"/"); 99 | CFStringGetCString(reply.saveFileName,result+strlen(result),PATH_SIZE-strlen(result),kCFStringEncodingUTF8); 100 | } else { 101 | free(result); 102 | result = NULL; 103 | } 104 | NavDisposeReply(&reply); 105 | } 106 | } 107 | } 108 | NavDialogDispose(ref); 109 | } 110 | return result; 111 | #else 112 | NSSavePanel *savePanel = [NSSavePanel savePanel]; 113 | [savePanel setTitle:[NSString stringWithUTF8String:title]]; 114 | [savePanel setMessage:[NSString stringWithUTF8String:msg]]; 115 | [savePanel setDirectoryURL:[NSURL fileURLWithFileSystemRepresentation:initialdir isDirectory:YES relativeToURL:nil]]; 116 | 117 | if (filters) 118 | { 119 | NSMutableArray *nsFilters = [[NSMutableArray alloc] init]; 120 | for (int i = 0; i < filters->count; i++) 121 | { 122 | NSString *extension = [[NSString stringWithUTF8String:filters->extensions[i]] pathExtension]; 123 | [nsFilters addObject:extension]; 124 | } 125 | [savePanel setAllowedFileTypes:[NSArray arrayWithArray:nsFilters]]; 126 | } 127 | 128 | NSWindow *keyWindow = [NSApp keyWindow]; 129 | 130 | if ([savePanel runModal] == NSOKButton) 131 | { 132 | NSString *path = [[savePanel URL] path]; 133 | if (path) 134 | { 135 | char *result = malloc([path length]); 136 | strcpy(result, [path UTF8String]); 137 | [keyWindow makeKeyWindow]; 138 | return result; 139 | } 140 | } 141 | 142 | [keyWindow makeKeyWindow]; 143 | 144 | return 0; 145 | #endif 146 | } 147 | 148 | void systools_dialogs_open_file( const char *title, const char *msg, struct ARG_FILEFILTERS *filters, int multi, struct RES_STRINGLIST *result) { 149 | #ifdef CARBON 150 | result->count = 0; 151 | result->strings = NULL; 152 | NavDialogRef ref; 153 | NavDialogCreationOptions opt; 154 | 155 | NavGetDefaultDialogCreationOptions(&opt); 156 | opt.clientName = CFStringCreateWithCString(NULL,title,kCFStringEncodingUTF8); 157 | opt.message = CFStringCreateWithCString(NULL,msg,kCFStringEncodingUTF8); 158 | opt.modality = kWindowModalityAppModal; 159 | 160 | if (NavCreateGetFileDialog(&opt,NULL,NULL,NULL,filterProc,filters,&ref) == noErr) { 161 | 162 | if (NavDialogRun(ref) == noErr) { 163 | if (NavDialogGetUserAction(ref)==kNavUserActionOpen) { 164 | NavReplyRecord reply; 165 | if (NavDialogGetReply(ref,&reply) == kNavNormalState) { 166 | long count; 167 | AEKeyword keyword; 168 | DescType type; 169 | Size size; 170 | 171 | AECountItems(&reply.selection, &count); 172 | if (count) { 173 | result->count = count; 174 | result->strings = malloc(count*sizeof(char*)); 175 | while(count>0) { 176 | count--; 177 | AEGetNthPtr(&reply.selection,count+1,typeFileURL,&keyword,&type,0,0,&size); 178 | result->strings[count] = malloc(size); 179 | AEGetNthPtr(&reply.selection,count+1,typeFileURL,&keyword,&type,result->strings[count],size,&size); 180 | result->strings[count][size]=0; 181 | if(strncmp(result->strings[count], "file://localhost", 16) == 0) { 182 | memmove(result->strings[count],result->strings[count]+16,size-16); 183 | result->strings[count][size-16]=0; 184 | } 185 | } 186 | } 187 | NavDisposeReply(&reply); 188 | } 189 | } 190 | } 191 | NavDialogDispose(ref); 192 | } 193 | #else 194 | NSOpenPanel *openPanel = [[NSOpenPanel alloc] init]; 195 | [openPanel setTitle:[NSString stringWithUTF8String:title]]; 196 | [openPanel setMessage:[NSString stringWithUTF8String:msg]]; 197 | 198 | if (filters) 199 | { 200 | NSMutableArray *nsFilters = [[NSMutableArray alloc] init]; 201 | for (int i = 0; i < filters->count; i++) 202 | { 203 | NSString *extension = [[NSString stringWithUTF8String:filters->extensions[i]] pathExtension]; 204 | [nsFilters addObject:extension]; 205 | } 206 | [openPanel setAllowedFileTypes:[NSArray arrayWithArray:nsFilters]]; 207 | } 208 | 209 | NSWindow *keyWindow = [NSApp keyWindow]; 210 | 211 | if ([openPanel runModal] == NSOKButton) { 212 | result->count = [openPanel.URLs count]; 213 | int count = result->count; 214 | result->strings = malloc(count*sizeof(char*)); 215 | while (count) { 216 | count--; 217 | NSString *path = [[openPanel.URLs objectAtIndex:count] path]; 218 | if (path) { 219 | result->strings[count] = malloc([path length]); 220 | strcpy(result->strings[count], [path UTF8String]); 221 | } else { 222 | result->strings[count] = 0; 223 | } 224 | } 225 | } else { 226 | result->count = 0; 227 | } 228 | 229 | [keyWindow makeKeyWindow]; 230 | #endif 231 | } 232 | 233 | char* systools_dialogs_folder( const char *title, const char *msg ) { 234 | #ifdef CARBON 235 | char *result = NULL; 236 | NavDialogRef ref; 237 | NavDialogCreationOptions opt; 238 | 239 | NavGetDefaultDialogCreationOptions(&opt); 240 | opt.clientName = CFStringCreateWithCString(NULL,title,kCFStringEncodingUTF8); 241 | opt.message = CFStringCreateWithCString(NULL,msg,kCFStringEncodingUTF8); 242 | opt.modality = kWindowModalityAppModal; 243 | 244 | if (NavCreateChooseFolderDialog(&opt,NULL,NULL,NULL,&ref) == noErr) { 245 | 246 | if (NavDialogRun(ref) == noErr) { 247 | NavUserAction action = NavDialogGetUserAction(ref); 248 | if ( action != kNavUserActionCancel && action != kNavUserActionNone) { 249 | NavReplyRecord reply; 250 | if (NavDialogGetReply(ref,&reply) == kNavNormalState) { 251 | AEKeyword keyword; 252 | AEDesc desc; 253 | FSRef fsref; 254 | 255 | AEGetNthDesc(&reply.selection, 1, typeFSRef, &keyword, &desc); 256 | 257 | result = malloc(PATH_SIZE); 258 | memset(result,0,PATH_SIZE); 259 | GetFSRefFromAEDesc(&fsref,&reply.selection); 260 | if (FSRefMakePath (&fsref,(UInt8*)result,PATH_SIZE)!=noErr) { 261 | free(result); 262 | result = NULL; 263 | } 264 | NavDisposeReply(&reply); 265 | } 266 | } 267 | } 268 | NavDialogDispose(ref); 269 | } 270 | return result; 271 | #else 272 | NSOpenPanel *openPanel = [[NSOpenPanel alloc] init]; 273 | [openPanel setTitle:[NSString stringWithUTF8String:title]]; 274 | [openPanel setMessage:[NSString stringWithUTF8String:msg]]; 275 | [openPanel setCanChooseFiles:NO]; 276 | [openPanel setCanChooseDirectories:YES]; 277 | 278 | NSWindow *keyWindow = [NSApp keyWindow]; 279 | 280 | if ([openPanel runModal] == NSOKButton) { 281 | NSString *path = [[openPanel.URLs objectAtIndex:0] path]; 282 | if (path) { 283 | char *result = malloc([path length]); 284 | strcpy(result, [path UTF8String]); 285 | [keyWindow makeKeyWindow]; 286 | return result; 287 | } 288 | } 289 | 290 | [keyWindow makeKeyWindow]; 291 | 292 | return 0; 293 | #endif 294 | } 295 | 296 | // helpers: 297 | #ifdef CARBON 298 | static OSStatus GetFSRefFromAEDesc( FSRef *fsRef, AEDesc* theItem ) { 299 | OSStatus err = noErr; 300 | AEDesc coerceDesc= { 0, NULL }; 301 | if ( theItem->descriptorType != typeFSRef ) { 302 | err = AECoerceDesc( theItem, typeFSRef, &coerceDesc ); 303 | if ( err == noErr ) 304 | theItem = &coerceDesc; 305 | } 306 | if ( err == noErr ) 307 | err = AEGetDescData( theItem, fsRef, sizeof(*fsRef) ); 308 | AEDisposeDesc( &coerceDesc ); 309 | 310 | if ( err != noErr ) { 311 | FSSpec fsSpec; 312 | AEDesc coerceDesc2 = {0, NULL}; 313 | if ( theItem->descriptorType != typeFSS ) { 314 | err = AECoerceDesc( theItem, typeFSS, &coerceDesc2 ); 315 | theItem = &coerceDesc2; 316 | } 317 | if ( err == noErr ) 318 | err = AEGetDescData( theItem, &fsSpec, sizeof(fsSpec) ); 319 | AEDisposeDesc( &coerceDesc2 ); 320 | if ( err == noErr ) 321 | err = FSpMakeFSRef( &fsSpec, fsRef ); 322 | } 323 | return(err); 324 | } 325 | 326 | static Boolean filterProc(AEDesc * theItem, void * info, void * callBackUD, NavFilterModes filterMode) { 327 | struct ARG_FILEFILTERS *filters = (struct ARG_FILEFILTERS *) callBackUD; 328 | if (!filters) 329 | return 1; 330 | 331 | NavFileOrFolderInfo *i = (NavFileOrFolderInfo*) info; 332 | if (i->isFolder) 333 | return 1; 334 | 335 | if (theItem->descriptorType==typeFSRef) { 336 | FSRef f; 337 | UInt8 path[PATH_SIZE]; 338 | 339 | GetFSRefFromAEDesc(&f,theItem); 340 | if (FSRefMakePath (&f,path,PATH_SIZE)==noErr) { 341 | char *ext = NULL; 342 | char *next = (char*) path; 343 | while(next) { 344 | next = strstr(next,"."); 345 | if (next) 346 | ext = ++next; 347 | } 348 | if(ext) { 349 | long j = filters->count; 350 | while(j) { 351 | if (strcasestr(filters->extensions[--j],ext) !=0) 352 | return 1; 353 | } 354 | } 355 | } 356 | return 0; 357 | } 358 | return 1; 359 | } 360 | #endif 361 | 362 | -------------------------------------------------------------------------------- /project/src/api.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************ */ 2 | /* */ 3 | /* Systool - a Neko VM library */ 4 | /* Copyright (c)2006 */ 5 | /* Asger Ottar Alstrup, Nicolas Cannasse, Edwin van Rijkom, Ian Thomas */ 6 | /* */ 7 | /* This library is free software; you can redistribute it and/or */ 8 | /* modify it under the terms of the GNU Lesser General Public */ 9 | /* License as published by the Free Software Foundation; either */ 10 | /* version 2.1 of the License, or (at your option) any later version. */ 11 | /* */ 12 | /* This library is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 15 | /* Lesser General Public License or the LICENSE file for more details. */ 16 | /* */ 17 | /* ************************************************************************ */ 18 | 19 | #ifndef STATIC_LINK 20 | #define IMPLEMENT_API 21 | #endif 22 | #if defined(HX_WINDOWS) || defined(HX_MACOS) || defined(HX_LINUX) 23 | #define NEKO_COMPATIBLE 24 | #endif 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | extern "C" 31 | { 32 | #include "api.h" 33 | #include "clipboard.h" 34 | #include "misc.h" 35 | #include "registry.h" 36 | #include "dialogs.h" 37 | #include "fileutils.h" 38 | #ifndef HX_LINUX 39 | #include "browser.h" 40 | #include "display.h" 41 | #endif 42 | } 43 | 44 | // init 45 | 46 | static value systools_init() 47 | { 48 | systools_misc_initialize(); 49 | return val_null; 50 | } 51 | DEFINE_PRIM(systools_init,0); 52 | 53 | // ---------------- Dialog methods ------------------------------------------- 54 | 55 | 56 | static value dialogs_message_box( value title, value msg, value error ) { 57 | val_check(title,string); 58 | val_check(msg,string); 59 | val_check(error,bool); 60 | systools_dialogs_message_box(val_string(title),val_string(msg),val_bool(error)); 61 | return val_null; 62 | } 63 | DEFINE_PRIM(dialogs_message_box,3); 64 | 65 | 66 | static value dialogs_dialog_box( value title, value msg, value error ) { 67 | int r; 68 | val_check(title,string); 69 | val_check(msg,string); 70 | val_check(error,bool); 71 | r = systools_dialogs_dialog_box(val_string(title),val_string(msg),val_bool(error)); 72 | return alloc_bool(r); 73 | } 74 | DEFINE_PRIM(dialogs_dialog_box,3); 75 | 76 | static value dialogs_save_file( value title, value msg, value initialdir, value mask) { 77 | char * v; 78 | struct ARG_FILEFILTERS filters = {0,0,0}; 79 | 80 | value result = val_null; 81 | val_check(title, string); 82 | val_check(msg, string); 83 | val_check(initialdir, string); 84 | 85 | if (val_is_object(mask)) { 86 | value count = val_field(mask,val_id("count")); 87 | value descriptions = val_field(mask,val_id("descriptions")); 88 | value extensions = val_field(mask,val_id("extensions")); 89 | 90 | val_check(count,int); 91 | val_check(descriptions,array); 92 | val_check(extensions,array); 93 | 94 | filters.count = val_int(count); 95 | if (filters.count) { 96 | long i = filters.count; 97 | filters.descriptions = (const char**) malloc(i*sizeof(char*)); 98 | filters.extensions = (const char**) malloc(i*sizeof(char*)); 99 | while(i) { 100 | i--; 101 | filters.descriptions[i] = val_string(val_array_i(descriptions,i)); 102 | filters.extensions[i] = val_string(val_array_i(extensions,i)); 103 | } 104 | } 105 | } 106 | 107 | result = val_null; 108 | v = systools_dialogs_save_file(val_string(title),val_string(msg),val_string(initialdir),filters.count? &filters : NULL); 109 | if (v) { 110 | result = alloc_string(v); 111 | free((void*)v); 112 | } 113 | 114 | // clean up allocated mem. for filters: 115 | if (val_is_object(mask)) { 116 | free(filters.descriptions); 117 | free(filters.extensions); 118 | } 119 | 120 | return result; 121 | 122 | } 123 | DEFINE_PRIM(dialogs_save_file,4); 124 | 125 | static value dialogs_open_file( value title, value msg, value mask,value multi) { 126 | value result = val_null; 127 | struct ARG_FILEFILTERS filters = {0,0,0}; 128 | struct RES_STRINGLIST files; 129 | 130 | val_check(title,string); 131 | val_check(msg,string); 132 | val_check(multi,bool); 133 | 134 | if (val_is_object(mask)) { 135 | value count = val_field(mask,val_id("count")); 136 | value descriptions = val_field(mask,val_id("descriptions")); 137 | value extensions = val_field(mask,val_id("extensions")); 138 | 139 | val_check(count,int); 140 | val_check(descriptions,array); 141 | val_check(extensions,array); 142 | 143 | filters.count = val_int(count); 144 | if (filters.count) { 145 | long i = filters.count; 146 | filters.descriptions = (const char**) malloc(i*sizeof(char*)); 147 | filters.extensions = (const char**) malloc(i*sizeof(char*)); 148 | while(i) { 149 | i--; 150 | filters.descriptions[i] = val_string(val_array_i(descriptions,i)); 151 | filters.extensions[i] = val_string(val_array_i(extensions,i)); 152 | } 153 | } 154 | } 155 | 156 | systools_dialogs_open_file(val_string(title),val_string(msg),filters.count? &filters : NULL ,val_bool(multi) ,&files); 157 | if (files.count) { 158 | result = alloc_array(files.count); 159 | while(files.count) { 160 | files.count--; 161 | val_array_set_i(result, files.count, alloc_string(files.strings[files.count])); 162 | free(files.strings[files.count]); 163 | } 164 | free(files.strings); 165 | } 166 | 167 | // clean up allocated mem. for filters: 168 | if (val_is_object(mask)) { 169 | free(filters.descriptions); 170 | free(filters.extensions); 171 | } 172 | 173 | 174 | 175 | return result; 176 | } 177 | DEFINE_PRIM(dialogs_open_file,4);//note this 178 | 179 | static value dialogs_folder( value title, value msg ) { 180 | char * v; 181 | value result = val_null; 182 | val_check(title, string); 183 | val_check(msg, string); 184 | result = val_null; 185 | v = systools_dialogs_folder(val_string(title),val_string(msg)); 186 | if (v) { 187 | result = alloc_string(v); 188 | free(v); 189 | } 190 | return result; 191 | 192 | } 193 | DEFINE_PRIM(dialogs_folder,2); 194 | 195 | 196 | // ---------------- Clipboard methods ---------------------------------------- 197 | 198 | 199 | static value clipboard_set_text( value text ) { 200 | val_check(text, string); 201 | return alloc_int(systools_clipboard_set_text(val_string(text))); 202 | } 203 | DEFINE_PRIM(clipboard_set_text,1); 204 | 205 | 206 | static value clipboard_get_text() { 207 | value result = val_null; 208 | char* v = systools_clipboard_get_text(); 209 | if (v) { 210 | result = alloc_string(v); 211 | free((void*)v); 212 | } 213 | return result; 214 | } 215 | DEFINE_PRIM(clipboard_get_text,0); 216 | 217 | 218 | static value clipboard_clear( ) { 219 | systools_clipboard_clear(); 220 | return val_null; 221 | } 222 | DEFINE_PRIM(clipboard_clear,0); 223 | 224 | 225 | // ---------------- Miscellanious tools -------------------------------------- 226 | 227 | 228 | static value misc_get_key_state( value key ) { 229 | int r; 230 | val_check(key,int); 231 | r = systools_misc_get_key_state(val_int(key)); 232 | return alloc_int(r); 233 | } 234 | DEFINE_PRIM(misc_get_key_state,1); 235 | 236 | // ---------------- Browser tools --------------------------------------- 237 | static value browser_launch( value url ) 238 | { 239 | #ifndef HX_LINUX 240 | int r; 241 | val_check(url, string); 242 | r=systools_browser_launch(val_string(url)); 243 | return alloc_bool(r); 244 | #else 245 | val_throw(alloc_string("this function is not available for this platform")); 246 | return val_null; 247 | #endif 248 | } 249 | DEFINE_PRIM(browser_launch,1); 250 | 251 | // ---------------- File Utils --------------------------------------- 252 | static value fileutils_get_temp_folder() 253 | { 254 | char * v; 255 | value result = val_null; 256 | v = systools_fileutils_get_temp_folder(); 257 | if (v) { 258 | result = alloc_string(v); 259 | free((void*)v); 260 | } 261 | return result; 262 | } 263 | DEFINE_PRIM(fileutils_get_temp_folder,0); 264 | 265 | // ---------------- Display tools -------------------- 266 | 267 | // Display specific code 268 | static value display_get_screen_size() 269 | { 270 | #ifndef HX_LINUX 271 | dimensions dim; 272 | value w; 273 | value h; 274 | value o = alloc_empty_object(); 275 | systools_display_get_screen_size(&dim); 276 | w=alloc_int(dim.width); 277 | h=alloc_int(dim.height); 278 | alloc_field( o, val_id("w"), w ); 279 | alloc_field( o, val_id("h"), h ); 280 | return o; 281 | #else 282 | val_throw(alloc_string("function not available for this platform")); 283 | return val_null; 284 | #endif 285 | } 286 | DEFINE_PRIM(display_get_screen_size,0); 287 | 288 | // ---------------- Registry tools -------------------------------------- 289 | 290 | 291 | static value registry_set_value( value key, value subkey, value valuename, value v) { 292 | val_check(key, int); 293 | val_check(subkey, string); 294 | val_check(valuename, string); 295 | val_check(v, string); 296 | systools_registry_set_value(val_int(key), val_string(subkey), val_string(valuename), val_string(v)); 297 | return val_null; 298 | } 299 | DEFINE_PRIM(registry_set_value,4); 300 | 301 | static value registry_get_value( value key, value subkey, value valuename) { 302 | char * v; 303 | value result = val_null; 304 | val_check(key, int); 305 | val_check(subkey, string); 306 | val_check(valuename, string); 307 | result = val_null; 308 | v = systools_registry_get_value(val_int(key), val_string(subkey), val_string(valuename)); 309 | if (v) { 310 | result = alloc_string(v); 311 | free((void*)v); 312 | } 313 | return result; 314 | } 315 | DEFINE_PRIM(registry_get_value,3); 316 | 317 | static value registry_delete_key( value key, value subkey) { 318 | val_check(key, int); 319 | val_check(subkey, string); 320 | systools_registry_delete_key(val_int(key), val_string(subkey)); 321 | return val_null; 322 | } 323 | DEFINE_PRIM(registry_delete_key,2); 324 | 325 | 326 | // -- Windows specific 327 | 328 | 329 | #ifdef NEKO_WINDOWS 330 | 331 | extern "C" 332 | { 333 | #include "win/win.h" 334 | #include "win/menus.h" 335 | #include "win/display.h" 336 | } 337 | 338 | static value win_replace_exe_icon( value exe, value icon, value iconResourceID) { 339 | int r = 0; 340 | value result = val_null; 341 | val_check(exe, string); 342 | val_check(icon, string); 343 | val_check(iconResourceID,int); 344 | r = systools_win_replaceExeIcon(val_string(exe),val_string(icon),val_int(iconResourceID)); 345 | return r==1? val_true : val_false; 346 | } 347 | DEFINE_PRIM(win_replace_exe_icon,3); 348 | 349 | static value win_create_process( value app, value args, value wd, value hide, value wait) { 350 | int r; 351 | const char *_args = 0; 352 | const char *_wd = 0; 353 | val_check(app,string); 354 | val_check(hide,int); 355 | val_check(wait,int); 356 | if (args != val_null) { 357 | val_check(args,string); 358 | _args = val_string(args); 359 | } 360 | if (wd != val_null) { 361 | val_check(wd,string); 362 | _wd = val_string(wd); 363 | } 364 | r = systools_win_create_process 365 | ( val_string(app) 366 | , _args 367 | , _wd 368 | , val_int(hide) 369 | , val_int(wait) 370 | ); 371 | return alloc_int(r); 372 | } 373 | DEFINE_PRIM(win_create_process,5); 374 | 375 | 376 | // Tray Icon specific code 377 | 378 | 379 | static value systray_create_icon( value w, value iconpath, value tooltip ) 380 | { 381 | val_check(tooltip,string); 382 | if ( !(val_is_string(iconpath) || val_is_null(iconpath)) ) 383 | val_throw(alloc_string(tray_icon_error)); 384 | else { 385 | tray_icon *tray = systools_win_create_tray_icon(val_hwnd(w),val_string(iconpath),val_string(tooltip)); 386 | if (!tray) 387 | val_throw(alloc_string(tray_icon_error)); 388 | 389 | return alloc_abstract(k_tray_icon,tray); 390 | } 391 | return val_null; 392 | } 393 | DEFINE_PRIM(systray_create_icon,3); 394 | 395 | static value systray_destroy_icon( value tray ) 396 | { 397 | val_check_kind(tray,k_tray_icon); 398 | systools_win_destroy_tray_icon(val_tray_icon(tray)); 399 | return val_null; 400 | } 401 | DEFINE_PRIM(systray_destroy_icon,1); 402 | 403 | static value systray_menu_callback() 404 | { 405 | return alloc_abstract(k_window_msg_cb,&tray_menu_cb); 406 | } 407 | DEFINE_PRIM(systray_menu_callback,0); 408 | 409 | // Menu specific code 410 | static value win_menu_create() 411 | { 412 | return alloc_abstract(k_menu,systools_menu_create()); 413 | } 414 | DEFINE_PRIM(win_menu_create,0); 415 | 416 | static value win_popup_menu_create() 417 | { 418 | return alloc_abstract(k_menu,systools_popup_menu_create()); 419 | } 420 | DEFINE_PRIM(win_popup_menu_create,0); 421 | 422 | static void win_destroy_menu( value menu ) 423 | { 424 | val_check_kind(menu,k_menu); 425 | systools_menu_destroy(val_menu(menu)); 426 | } 427 | DEFINE_PRIM(win_destroy_menu,1); 428 | 429 | static value win_destroy_tray_icon( value ico ) 430 | { 431 | val_check_kind(ico,k_icondata); 432 | systools_win_destroy_tray_icon(val_tray_icon(ico)); 433 | return val_null; 434 | } 435 | DEFINE_PRIM(win_destroy_tray_icon,1); 436 | 437 | static value win_add_menu_item( value menu, value caption, value callbackid ) 438 | { 439 | val_check_kind(menu,k_menu); 440 | val_check(caption,string); 441 | val_check(callbackid,int); 442 | systools_menu_add_item(val_menu(menu), val_string(caption), val_int(callbackid)); 443 | return val_null; 444 | } 445 | DEFINE_PRIM(win_add_menu_item,3); 446 | 447 | static value win_add_menu_submenu( value menu, value submenu, value caption, value callbackid ) 448 | { 449 | val_check_kind(menu,k_menu); 450 | val_check_kind(submenu,k_menu); 451 | val_check(caption,string); 452 | val_check(callbackid,int); 453 | systools_menu_add_submenu(val_menu(menu), val_menu(submenu), val_string(caption), val_int(callbackid)); 454 | return val_null; 455 | } 456 | DEFINE_PRIM(win_add_menu_submenu,4); 457 | 458 | static value win_add_menu_divider( value menu, value callbackid ) 459 | { 460 | val_check_kind(menu,k_menu); 461 | val_check(callbackid,int); 462 | systools_menu_add_item(val_menu(menu), (char*)"--", val_int(callbackid)); 463 | return val_null; 464 | } 465 | DEFINE_PRIM(win_add_menu_divider,2); 466 | 467 | static value win_show_menu( value w, value m ) 468 | { 469 | val_check_kind(m,k_menu); 470 | return alloc_int(systools_menu_show( val_hwnd(w), val_menu(m) )); 471 | } 472 | DEFINE_PRIM(win_show_menu,2); 473 | 474 | static value win_show_popup_menu( value w, value m ) 475 | { 476 | val_check_kind(m,k_menu); 477 | return alloc_int(systools_popup_menu_show( val_hwnd(w), val_menu(m) )); 478 | } 479 | DEFINE_PRIM(win_show_popup_menu,2); 480 | 481 | static value display_set_mode( value width, value height, value depth ) 482 | { 483 | int r; 484 | val_check(width,int); 485 | val_check(height,int); 486 | val_check(depth,int); 487 | r=systools_win_display_set_mode(val_int(width),val_int(height),val_int(depth)); 488 | return alloc_bool(r); 489 | } 490 | DEFINE_PRIM(display_set_mode,3); 491 | 492 | static value display_set_default_mode() 493 | { 494 | systools_win_display_set_default_mode(); 495 | return val_null; 496 | } 497 | DEFINE_PRIM(display_set_default_mode,0); 498 | 499 | static value display_is_mode_supported( value width, value height, value depth ) 500 | { 501 | int r; 502 | val_check(width,int); 503 | val_check(height,int); 504 | val_check(depth,int); 505 | r=systools_win_display_is_mode_supported(val_int(width),val_int(height),val_int(depth)); 506 | return alloc_bool(r); 507 | } 508 | DEFINE_PRIM(display_is_mode_supported,3); 509 | 510 | #endif 511 | 512 | // Neko specific code 513 | 514 | extern "C" void systools_main() 515 | { 516 | val_int(0); // fix neko init 517 | } 518 | DEFINE_ENTRY_POINT(systools_main); 519 | 520 | extern "C" int systools_register_prims () { return 0; } 521 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The Neko-Systools LGPL License : 2 | ----------------------- 3 | 4 | 5 | GNU LESSER GENERAL PUBLIC LICENSE 6 | Version 2.1, February 1999 7 | 8 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 9 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 10 | Everyone is permitted to copy and distribute verbatim copies 11 | of this license document, but changing it is not allowed. 12 | 13 | [This is the first released version of the Lesser GPL. It also counts 14 | as the successor of the GNU Library Public License, version 2, hence 15 | the version number 2.1.] 16 | 17 | Preamble 18 | 19 | The licenses for most software are designed to take away your 20 | freedom to share and change it. By contrast, the GNU General Public 21 | Licenses are intended to guarantee your freedom to share and change 22 | free software--to make sure the software is free for all its users. 23 | 24 | This license, the Lesser General Public License, applies to some 25 | specially designated software packages--typically libraries--of the 26 | Free Software Foundation and other authors who decide to use it. You 27 | can use it too, but we suggest you first think carefully about whether 28 | this license or the ordinary General Public License is the better 29 | strategy to use in any particular case, based on the explanations below. 30 | 31 | When we speak of free software, we are referring to freedom of use, 32 | not price. Our General Public Licenses are designed to make sure that 33 | you have the freedom to distribute copies of free software (and charge 34 | for this service if you wish); that you receive source code or can get 35 | it if you want it; that you can change the software and use pieces of 36 | it in new free programs; and that you are informed that you can do 37 | these things. 38 | 39 | To protect your rights, we need to make restrictions that forbid 40 | distributors to deny you these rights or to ask you to surrender these 41 | rights. These restrictions translate to certain responsibilities for 42 | you if you distribute copies of the library or if you modify it. 43 | 44 | For example, if you distribute copies of the library, whether gratis 45 | or for a fee, you must give the recipients all the rights that we gave 46 | you. You must make sure that they, too, receive or can get the source 47 | code. If you link other code with the library, you must provide 48 | complete object files to the recipients, so that they can relink them 49 | with the library after making changes to the library and recompiling 50 | it. And you must show them these terms so they know their rights. 51 | 52 | We protect your rights with a two-step method: (1) we copyright the 53 | library, and (2) we offer you this license, which gives you legal 54 | permission to copy, distribute and/or modify the library. 55 | 56 | To protect each distributor, we want to make it very clear that 57 | there is no warranty for the free library. Also, if the library is 58 | modified by someone else and passed on, the recipients should know 59 | that what they have is not the original version, so that the original 60 | author's reputation will not be affected by problems that might be 61 | introduced by others. 62 | 63 | Finally, software patents pose a constant threat to the existence of 64 | any free program. We wish to make sure that a company cannot 65 | effectively restrict the users of a free program by obtaining a 66 | restrictive license from a patent holder. Therefore, we insist that 67 | any patent license obtained for a version of the library must be 68 | consistent with the full freedom of use specified in this license. 69 | 70 | Most GNU software, including some libraries, is covered by the 71 | ordinary GNU General Public License. This license, the GNU Lesser 72 | General Public License, applies to certain designated libraries, and 73 | is quite different from the ordinary General Public License. We use 74 | this license for certain libraries in order to permit linking those 75 | libraries into non-free programs. 76 | 77 | When a program is linked with a library, whether statically or using 78 | a shared library, the combination of the two is legally speaking a 79 | combined work, a derivative of the original library. The ordinary 80 | General Public License therefore permits such linking only if the 81 | entire combination fits its criteria of freedom. The Lesser General 82 | Public License permits more lax criteria for linking other code with 83 | the library. 84 | 85 | We call this license the "Lesser" General Public License because it 86 | does Less to protect the user's freedom than the ordinary General 87 | Public License. It also provides other free software developers Less 88 | of an advantage over competing non-free programs. These disadvantages 89 | are the reason we use the ordinary General Public License for many 90 | libraries. However, the Lesser license provides advantages in certain 91 | special circumstances. 92 | 93 | For example, on rare occasions, there may be a special need to 94 | encourage the widest possible use of a certain library, so that it becomes 95 | a de-facto standard. To achieve this, non-free programs must be 96 | allowed to use the library. A more frequent case is that a free 97 | library does the same job as widely used non-free libraries. In this 98 | case, there is little to gain by limiting the free library to free 99 | software only, so we use the Lesser General Public License. 100 | 101 | In other cases, permission to use a particular library in non-free 102 | programs enables a greater number of people to use a large body of 103 | free software. For example, permission to use the GNU C Library in 104 | non-free programs enables many more people to use the whole GNU 105 | operating system, as well as its variant, the GNU/Linux operating 106 | system. 107 | 108 | Although the Lesser General Public License is Less protective of the 109 | users' freedom, it does ensure that the user of a program that is 110 | linked with the Library has the freedom and the wherewithal to run 111 | that program using a modified version of the Library. 112 | 113 | The precise terms and conditions for copying, distribution and 114 | modification follow. Pay close attention to the difference between a 115 | "work based on the library" and a "work that uses the library". The 116 | former contains code derived from the library, whereas the latter must 117 | be combined with the library in order to run. 118 | 119 | GNU LESSER GENERAL PUBLIC LICENSE 120 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 121 | 122 | 0. This License Agreement applies to any software library or other 123 | program which contains a notice placed by the copyright holder or 124 | other authorized party saying it may be distributed under the terms of 125 | this Lesser General Public License (also called "this License"). 126 | Each licensee is addressed as "you". 127 | 128 | A "library" means a collection of software functions and/or data 129 | prepared so as to be conveniently linked with application programs 130 | (which use some of those functions and data) to form executables. 131 | 132 | The "Library", below, refers to any such software library or work 133 | which has been distributed under these terms. A "work based on the 134 | Library" means either the Library or any derivative work under 135 | copyright law: that is to say, a work containing the Library or a 136 | portion of it, either verbatim or with modifications and/or translated 137 | straightforwardly into another language. (Hereinafter, translation is 138 | included without limitation in the term "modification".) 139 | 140 | "Source code" for a work means the preferred form of the work for 141 | making modifications to it. For a library, complete source code means 142 | all the source code for all modules it contains, plus any associated 143 | interface definition files, plus the scripts used to control compilation 144 | and installation of the library. 145 | 146 | Activities other than copying, distribution and modification are not 147 | covered by this License; they are outside its scope. The act of 148 | running a program using the Library is not restricted, and output from 149 | such a program is covered only if its contents constitute a work based 150 | on the Library (independent of the use of the Library in a tool for 151 | writing it). Whether that is true depends on what the Library does 152 | and what the program that uses the Library does. 153 | 154 | 1. You may copy and distribute verbatim copies of the Library's 155 | complete source code as you receive it, in any medium, provided that 156 | you conspicuously and appropriately publish on each copy an 157 | appropriate copyright notice and disclaimer of warranty; keep intact 158 | all the notices that refer to this License and to the absence of any 159 | warranty; and distribute a copy of this License along with the 160 | Library. 161 | 162 | You may charge a fee for the physical act of transferring a copy, 163 | and you may at your option offer warranty protection in exchange for a 164 | fee. 165 | 166 | 2. You may modify your copy or copies of the Library or any portion 167 | of it, thus forming a work based on the Library, and copy and 168 | distribute such modifications or work under the terms of Section 1 169 | above, provided that you also meet all of these conditions: 170 | 171 | a) The modified work must itself be a software library. 172 | 173 | b) You must cause the files modified to carry prominent notices 174 | stating that you changed the files and the date of any change. 175 | 176 | c) You must cause the whole of the work to be licensed at no 177 | charge to all third parties under the terms of this License. 178 | 179 | d) If a facility in the modified Library refers to a function or a 180 | table of data to be supplied by an application program that uses 181 | the facility, other than as an argument passed when the facility 182 | is invoked, then you must make a good faith effort to ensure that, 183 | in the event an application does not supply such function or 184 | table, the facility still operates, and performs whatever part of 185 | its purpose remains meaningful. 186 | 187 | (For example, a function in a library to compute square roots has 188 | a purpose that is entirely well-defined independent of the 189 | application. Therefore, Subsection 2d requires that any 190 | application-supplied function or table used by this function must 191 | be optional: if the application does not supply it, the square 192 | root function must still compute square roots.) 193 | 194 | These requirements apply to the modified work as a whole. If 195 | identifiable sections of that work are not derived from the Library, 196 | and can be reasonably considered independent and separate works in 197 | themselves, then this License, and its terms, do not apply to those 198 | sections when you distribute them as separate works. But when you 199 | distribute the same sections as part of a whole which is a work based 200 | on the Library, the distribution of the whole must be on the terms of 201 | this License, whose permissions for other licensees extend to the 202 | entire whole, and thus to each and every part regardless of who wrote 203 | it. 204 | 205 | Thus, it is not the intent of this section to claim rights or contest 206 | your rights to work written entirely by you; rather, the intent is to 207 | exercise the right to control the distribution of derivative or 208 | collective works based on the Library. 209 | 210 | In addition, mere aggregation of another work not based on the Library 211 | with the Library (or with a work based on the Library) on a volume of 212 | a storage or distribution medium does not bring the other work under 213 | the scope of this License. 214 | 215 | 3. You may opt to apply the terms of the ordinary GNU General Public 216 | License instead of this License to a given copy of the Library. To do 217 | this, you must alter all the notices that refer to this License, so 218 | that they refer to the ordinary GNU General Public License, version 2, 219 | instead of to this License. (If a newer version than version 2 of the 220 | ordinary GNU General Public License has appeared, then you can specify 221 | that version instead if you wish.) Do not make any other change in 222 | these notices. 223 | 224 | Once this change is made in a given copy, it is irreversible for 225 | that copy, so the ordinary GNU General Public License applies to all 226 | subsequent copies and derivative works made from that copy. 227 | 228 | This option is useful when you wish to copy part of the code of 229 | the Library into a program that is not a library. 230 | 231 | 4. You may copy and distribute the Library (or a portion or 232 | derivative of it, under Section 2) in object code or executable form 233 | under the terms of Sections 1 and 2 above provided that you accompany 234 | it with the complete corresponding machine-readable source code, which 235 | must be distributed under the terms of Sections 1 and 2 above on a 236 | medium customarily used for software interchange. 237 | 238 | If distribution of object code is made by offering access to copy 239 | from a designated place, then offering equivalent access to copy the 240 | source code from the same place satisfies the requirement to 241 | distribute the source code, even though third parties are not 242 | compelled to copy the source along with the object code. 243 | 244 | 5. A program that contains no derivative of any portion of the 245 | Library, but is designed to work with the Library by being compiled or 246 | linked with it, is called a "work that uses the Library". Such a 247 | work, in isolation, is not a derivative work of the Library, and 248 | therefore falls outside the scope of this License. 249 | 250 | However, linking a "work that uses the Library" with the Library 251 | creates an executable that is a derivative of the Library (because it 252 | contains portions of the Library), rather than a "work that uses the 253 | library". The executable is therefore covered by this License. 254 | Section 6 states terms for distribution of such executables. 255 | 256 | When a "work that uses the Library" uses material from a header file 257 | that is part of the Library, the object code for the work may be a 258 | derivative work of the Library even though the source code is not. 259 | Whether this is true is especially significant if the work can be 260 | linked without the Library, or if the work is itself a library. The 261 | threshold for this to be true is not precisely defined by law. 262 | 263 | If such an object file uses only numerical parameters, data 264 | structure layouts and accessors, and small macros and small inline 265 | functions (ten lines or less in length), then the use of the object 266 | file is unrestricted, regardless of whether it is legally a derivative 267 | work. (Executables containing this object code plus portions of the 268 | Library will still fall under Section 6.) 269 | 270 | Otherwise, if the work is a derivative of the Library, you may 271 | distribute the object code for the work under the terms of Section 6. 272 | Any executables containing that work also fall under Section 6, 273 | whether or not they are linked directly with the Library itself. 274 | 275 | 6. As an exception to the Sections above, you may also combine or 276 | link a "work that uses the Library" with the Library to produce a 277 | work containing portions of the Library, and distribute that work 278 | under terms of your choice, provided that the terms permit 279 | modification of the work for the customer's own use and reverse 280 | engineering for debugging such modifications. 281 | 282 | You must give prominent notice with each copy of the work that the 283 | Library is used in it and that the Library and its use are covered by 284 | this License. You must supply a copy of this License. If the work 285 | during execution displays copyright notices, you must include the 286 | copyright notice for the Library among them, as well as a reference 287 | directing the user to the copy of this License. Also, you must do one 288 | of these things: 289 | 290 | a) Accompany the work with the complete corresponding 291 | machine-readable source code for the Library including whatever 292 | changes were used in the work (which must be distributed under 293 | Sections 1 and 2 above); and, if the work is an executable linked 294 | with the Library, with the complete machine-readable "work that 295 | uses the Library", as object code and/or source code, so that the 296 | user can modify the Library and then relink to produce a modified 297 | executable containing the modified Library. (It is understood 298 | that the user who changes the contents of definitions files in the 299 | Library will not necessarily be able to recompile the application 300 | to use the modified definitions.) 301 | 302 | b) Use a suitable shared library mechanism for linking with the 303 | Library. A suitable mechanism is one that (1) uses at run time a 304 | copy of the library already present on the user's computer system, 305 | rather than copying library functions into the executable, and (2) 306 | will operate properly with a modified version of the library, if 307 | the user installs one, as long as the modified version is 308 | interface-compatible with the version that the work was made with. 309 | 310 | c) Accompany the work with a written offer, valid for at 311 | least three years, to give the same user the materials 312 | specified in Subsection 6a, above, for a charge no more 313 | than the cost of performing this distribution. 314 | 315 | d) If distribution of the work is made by offering access to copy 316 | from a designated place, offer equivalent access to copy the above 317 | specified materials from the same place. 318 | 319 | e) Verify that the user has already received a copy of these 320 | materials or that you have already sent this user a copy. 321 | 322 | For an executable, the required form of the "work that uses the 323 | Library" must include any data and utility programs needed for 324 | reproducing the executable from it. However, as a special exception, 325 | the materials to be distributed need not include anything that is 326 | normally distributed (in either source or binary form) with the major 327 | components (compiler, kernel, and so on) of the operating system on 328 | which the executable runs, unless that component itself accompanies 329 | the executable. 330 | 331 | It may happen that this requirement contradicts the license 332 | restrictions of other proprietary libraries that do not normally 333 | accompany the operating system. Such a contradiction means you cannot 334 | use both them and the Library together in an executable that you 335 | distribute. 336 | 337 | 7. You may place library facilities that are a work based on the 338 | Library side-by-side in a single library together with other library 339 | facilities not covered by this License, and distribute such a combined 340 | library, provided that the separate distribution of the work based on 341 | the Library and of the other library facilities is otherwise 342 | permitted, and provided that you do these two things: 343 | 344 | a) Accompany the combined library with a copy of the same work 345 | based on the Library, uncombined with any other library 346 | facilities. This must be distributed under the terms of the 347 | Sections above. 348 | 349 | b) Give prominent notice with the combined library of the fact 350 | that part of it is a work based on the Library, and explaining 351 | where to find the accompanying uncombined form of the same work. 352 | 353 | 8. You may not copy, modify, sublicense, link with, or distribute 354 | the Library except as expressly provided under this License. Any 355 | attempt otherwise to copy, modify, sublicense, link with, or 356 | distribute the Library is void, and will automatically terminate your 357 | rights under this License. However, parties who have received copies, 358 | or rights, from you under this License will not have their licenses 359 | terminated so long as such parties remain in full compliance. 360 | 361 | 9. You are not required to accept this License, since you have not 362 | signed it. However, nothing else grants you permission to modify or 363 | distribute the Library or its derivative works. These actions are 364 | prohibited by law if you do not accept this License. Therefore, by 365 | modifying or distributing the Library (or any work based on the 366 | Library), you indicate your acceptance of this License to do so, and 367 | all its terms and conditions for copying, distributing or modifying 368 | the Library or works based on it. 369 | 370 | 10. Each time you redistribute the Library (or any work based on the 371 | Library), the recipient automatically receives a license from the 372 | original licensor to copy, distribute, link with or modify the Library 373 | subject to these terms and conditions. You may not impose any further 374 | restrictions on the recipients' exercise of the rights granted herein. 375 | You are not responsible for enforcing compliance by third parties with 376 | this License. 377 | 378 | 11. If, as a consequence of a court judgment or allegation of patent 379 | infringement or for any other reason (not limited to patent issues), 380 | conditions are imposed on you (whether by court order, agreement or 381 | otherwise) that contradict the conditions of this License, they do not 382 | excuse you from the conditions of this License. If you cannot 383 | distribute so as to satisfy simultaneously your obligations under this 384 | License and any other pertinent obligations, then as a consequence you 385 | may not distribute the Library at all. For example, if a patent 386 | license would not permit royalty-free redistribution of the Library by 387 | all those who receive copies directly or indirectly through you, then 388 | the only way you could satisfy both it and this License would be to 389 | refrain entirely from distribution of the Library. 390 | 391 | If any portion of this section is held invalid or unenforceable under any 392 | particular circumstance, the balance of the section is intended to apply, 393 | and the section as a whole is intended to apply in other circumstances. 394 | 395 | It is not the purpose of this section to induce you to infringe any 396 | patents or other property right claims or to contest validity of any 397 | such claims; this section has the sole purpose of protecting the 398 | integrity of the free software distribution system which is 399 | implemented by public license practices. Many people have made 400 | generous contributions to the wide range of software distributed 401 | through that system in reliance on consistent application of that 402 | system; it is up to the author/donor to decide if he or she is willing 403 | to distribute software through any other system and a licensee cannot 404 | impose that choice. 405 | 406 | This section is intended to make thoroughly clear what is believed to 407 | be a consequence of the rest of this License. 408 | 409 | 12. If the distribution and/or use of the Library is restricted in 410 | certain countries either by patents or by copyrighted interfaces, the 411 | original copyright holder who places the Library under this License may add 412 | an explicit geographical distribution limitation excluding those countries, 413 | so that distribution is permitted only in or among countries not thus 414 | excluded. In such case, this License incorporates the limitation as if 415 | written in the body of this License. 416 | 417 | 13. The Free Software Foundation may publish revised and/or new 418 | versions of the Lesser General Public License from time to time. 419 | Such new versions will be similar in spirit to the present version, 420 | but may differ in detail to address new problems or concerns. 421 | 422 | Each version is given a distinguishing version number. If the Library 423 | specifies a version number of this License which applies to it and 424 | "any later version", you have the option of following the terms and 425 | conditions either of that version or of any later version published by 426 | the Free Software Foundation. If the Library does not specify a 427 | license version number, you may choose any version ever published by 428 | the Free Software Foundation. 429 | 430 | 14. If you wish to incorporate parts of the Library into other free 431 | programs whose distribution conditions are incompatible with these, 432 | write to the author to ask for permission. For software which is 433 | copyrighted by the Free Software Foundation, write to the Free 434 | Software Foundation; we sometimes make exceptions for this. Our 435 | decision will be guided by the two goals of preserving the free status 436 | of all derivatives of our free software and of promoting the sharing 437 | and reuse of software generally. 438 | 439 | NO WARRANTY 440 | 441 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 442 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 443 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 444 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 445 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 446 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 447 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 448 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 449 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 450 | 451 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 452 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 453 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 454 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 455 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 456 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 457 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 458 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 459 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 460 | DAMAGES. 461 | 462 | END OF TERMS AND CONDITIONS 463 | --------------------------------------------------------------------------------