From 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d Mon Sep 17 00:00:00 2001 From: Jef Date: Tue, 24 Sep 2024 14:54:57 +0200 Subject: Initial community commit --- Src/Wasabi/api/apiconfig.h | 176 + Src/Wasabi/api/apiinit.cpp | 548 ++ Src/Wasabi/api/apiinit.h | 255 + Src/Wasabi/api/application/api_application.cpp | 12 + Src/Wasabi/api/application/api_application.h | 416 ++ Src/Wasabi/api/application/api_applicationi.cpp | 204 + Src/Wasabi/api/application/api_applicationi.h | 49 + Src/Wasabi/api/application/api_applicationx.cpp | 33 + Src/Wasabi/api/application/api_applicationx.h | 42 + .../api/application/ifc_messageprocessor.cpp | 1 + Src/Wasabi/api/application/ifc_messageprocessor.h | 26 + .../api/application/ifc_messageprocessori.cpp | 7 + Src/Wasabi/api/application/ifc_messageprocessori.h | 13 + Src/Wasabi/api/application/ipcs.cpp | 97 + Src/Wasabi/api/application/ipcs.h | 60 + Src/Wasabi/api/application/pathmgr.cpp | 14 + Src/Wasabi/api/application/pathmgr.h | 15 + Src/Wasabi/api/application/version.cpp | 47 + Src/Wasabi/api/application/version.h | 12 + Src/Wasabi/api/application/wkc.cpp | 12 + Src/Wasabi/api/application/wkc.h | 61 + Src/Wasabi/api/config/api_config.cpp | 12 + Src/Wasabi/api/config/api_config.h | 149 + Src/Wasabi/api/config/api_configi.cpp | 124 + Src/Wasabi/api/config/api_configi.h | 46 + Src/Wasabi/api/config/api_configx.cpp | 37 + Src/Wasabi/api/config/api_configx.h | 44 + Src/Wasabi/api/config/cfglist.cpp | 50 + Src/Wasabi/api/config/cfglist.h | 23 + Src/Wasabi/api/config/cfgscriptobj.cpp | 371 ++ Src/Wasabi/api/config/cfgscriptobj.h | 198 + Src/Wasabi/api/config/config.cpp | 329 ++ Src/Wasabi/api/config/config.h | 43 + Src/Wasabi/api/config/configapi.cpp | 95 + Src/Wasabi/api/config/configapi.h | 32 + Src/Wasabi/api/config/filetypes.cpp | 576 ++ Src/Wasabi/api/config/filetypes.h | 46 + Src/Wasabi/api/config/items/attrbool.h | 65 + Src/Wasabi/api/config/items/attrcb.h | 127 + Src/Wasabi/api/config/items/attrfloat.h | 52 + Src/Wasabi/api/config/items/attrfn.h | 15 + Src/Wasabi/api/config/items/attrhandler.h | 129 + Src/Wasabi/api/config/items/attribs.h | 12 + Src/Wasabi/api/config/items/attribute.cpp | 131 + Src/Wasabi/api/config/items/attribute.h | 218 + Src/Wasabi/api/config/items/attrint.h | 65 + Src/Wasabi/api/config/items/attrstr.cpp | 14 + Src/Wasabi/api/config/items/attrstr.h | 85 + Src/Wasabi/api/config/items/cfgitem.h | 233 + Src/Wasabi/api/config/items/cfgitemi.cpp | 274 + Src/Wasabi/api/config/items/cfgitemi.h | 158 + Src/Wasabi/api/config/items/cfgitemx.cpp | 27 + Src/Wasabi/api/config/items/cfgitemx.h | 42 + Src/Wasabi/api/config/items/intarray.cpp | 49 + Src/Wasabi/api/config/items/intarray.h | 18 + Src/Wasabi/api/config/options.cpp | 211 + Src/Wasabi/api/config/options.h | 64 + Src/Wasabi/api/config/uioptions.cpp | 109 + Src/Wasabi/api/config/uioptions.h | 13 + Src/Wasabi/api/console/console.cpp | 33 + Src/Wasabi/api/console/console.h | 19 + Src/Wasabi/api/core/api_core.cpp | 51 + Src/Wasabi/api/core/api_core.h | 371 ++ Src/Wasabi/api/core/buttons.h | 18 + Src/Wasabi/api/core/coreactions.cpp | 181 + Src/Wasabi/api/core/coreactions.h | 47 + Src/Wasabi/api/core/corehandle.cpp | 304 ++ Src/Wasabi/api/core/corehandle.h | 560 ++ Src/Wasabi/api/core/sequence.cpp | 92 + Src/Wasabi/api/core/sequence.h | 123 + Src/Wasabi/api/dependency/api_dependent.cpp | 2 + Src/Wasabi/api/dependency/api_dependent.h | 54 + Src/Wasabi/api/dependency/api_dependentviewer.cpp | 2 + Src/Wasabi/api/dependency/api_dependentviewer.h | 30 + Src/Wasabi/api/filereader/api_filereader.cpp | 20 + Src/Wasabi/api/filereader/api_filereader.h | 104 + Src/Wasabi/api/filereader/api_readercallback.h | 22 + Src/Wasabi/api/filereader/filereaderapi.cpp | 53 + Src/Wasabi/api/filereader/filereaderapi.h | 25 + Src/Wasabi/api/filereader/local/fileread.cpp | 132 + Src/Wasabi/api/filereader/local/fileread.h | 23 + Src/Wasabi/api/filereader/svc_filereadI.h | 100 + Src/Wasabi/api/filereader/zip/zipread.cpp | 176 + Src/Wasabi/api/filereader/zip/zipread.h | 39 + Src/Wasabi/api/font/FontCreator.h | 7 + Src/Wasabi/api/font/FontSvcEnum.h | 18 + Src/Wasabi/api/font/api_font.cpp | 11 + Src/Wasabi/api/font/api_font.h | 36 + Src/Wasabi/api/font/bitmapfont.cpp | 394 ++ Src/Wasabi/api/font/bitmapfont.h | 70 + Src/Wasabi/api/font/font.cpp | 637 +++ Src/Wasabi/api/font/font.h | 55 + Src/Wasabi/api/font/fontapi.cpp | 32 + Src/Wasabi/api/font/fontapi.h | 20 + Src/Wasabi/api/font/linux/truetypefont_linux.cpp | 472 ++ Src/Wasabi/api/font/linux/truetypefont_linux.h | 65 + Src/Wasabi/api/font/skinfont.cpp | 43 + Src/Wasabi/api/font/skinfont.h | 17 + Src/Wasabi/api/font/svc_fontI.h | 39 + Src/Wasabi/api/font/truetypefontdef.h | 56 + Src/Wasabi/api/font/win32/truetypefont_win32.cpp | 561 ++ Src/Wasabi/api/font/win32/truetypefont_win32.h | 61 + Src/Wasabi/api/imgldr/ImgLoaderEnum.h | 24 + Src/Wasabi/api/imgldr/api_imgldr.cpp | 20 + Src/Wasabi/api/imgldr/api_imgldr.h | 98 + Src/Wasabi/api/imgldr/imggen/grad.cpp | 60 + Src/Wasabi/api/imgldr/imggen/grad.h | 15 + Src/Wasabi/api/imgldr/imggen/imggen.cpp | 29 + Src/Wasabi/api/imgldr/imggen/imggen.h | 14 + Src/Wasabi/api/imgldr/imggen/osedge.cpp | 95 + Src/Wasabi/api/imgldr/imggen/osedge.h | 13 + Src/Wasabi/api/imgldr/imggen/poly.cpp | 59 + Src/Wasabi/api/imgldr/imggen/poly.h | 13 + Src/Wasabi/api/imgldr/imggen/shadowwnd.cpp | 152 + Src/Wasabi/api/imgldr/imggen/shadowwnd.h | 40 + Src/Wasabi/api/imgldr/imggen/solid.cpp | 67 + Src/Wasabi/api/imgldr/imggen/solid.h | 14 + Src/Wasabi/api/imgldr/imgldr.cpp | 554 ++ Src/Wasabi/api/imgldr/imgldr.h | 86 + Src/Wasabi/api/imgldr/imgldrapi.cpp | 81 + Src/Wasabi/api/imgldr/imgldrapi.h | 23 + Src/Wasabi/api/imgldr/skinbmps.h | 122 + Src/Wasabi/api/imgldr/winbmp.h | 47 + Src/Wasabi/api/locales/LocalesInfo.cpp | 41 + Src/Wasabi/api/locales/LocalesInfo.h | 30 + Src/Wasabi/api/locales/api_locales.cpp | 12 + Src/Wasabi/api/locales/api_locales.h | 80 + Src/Wasabi/api/locales/api_localesi.cpp | 47 + Src/Wasabi/api/locales/api_localesi.h | 23 + Src/Wasabi/api/locales/api_localesx.cpp | 26 + Src/Wasabi/api/locales/api_localesx.h | 31 + Src/Wasabi/api/locales/localesmgr.cpp | 462 ++ Src/Wasabi/api/locales/localesmgr.h | 173 + Src/Wasabi/api/locales/xlatstr.h | 68 + Src/Wasabi/api/memmgr/api_memmgr.cpp | 13 + Src/Wasabi/api/memmgr/api_memmgr.h | 78 + Src/Wasabi/api/metrics/metricscb.h | 37 + Src/Wasabi/api/script/api_maki.cpp | 12 + Src/Wasabi/api/script/api_maki.h | 392 ++ Src/Wasabi/api/script/api_makidebug.cpp | 20 + Src/Wasabi/api/script/api_makidebug.h | 134 + Src/Wasabi/api/script/api_makii.cpp | 264 + Src/Wasabi/api/script/api_makii.h | 93 + Src/Wasabi/api/script/api_makix.cpp | 72 + Src/Wasabi/api/script/api_makix.h | 81 + Src/Wasabi/api/script/debugger/api_makidebug.cpp | 20 + Src/Wasabi/api/script/debugger/api_makidebug.h | 134 + Src/Wasabi/api/script/debugger/debugapi.cpp | 62 + Src/Wasabi/api/script/debugger/debugapi.h | 28 + Src/Wasabi/api/script/debugger/debuggerui.cpp | 11 + Src/Wasabi/api/script/debugger/debuggerui.h | 42 + Src/Wasabi/api/script/debugger/debugsymbols.cpp | 75 + Src/Wasabi/api/script/debugger/debugsymbols.h | 38 + Src/Wasabi/api/script/debugger/disasm.cpp | 193 + Src/Wasabi/api/script/debugger/disasm.h | 38 + Src/Wasabi/api/script/debugger/jitd.cpp | 176 + Src/Wasabi/api/script/debugger/jitd.h | 71 + Src/Wasabi/api/script/debugger/jitdbreak.cpp | 27 + Src/Wasabi/api/script/debugger/jitdbreak.h | 22 + Src/Wasabi/api/script/debugger/sdebuggerui.cpp | 437 ++ Src/Wasabi/api/script/debugger/sdebuggerui.h | 65 + Src/Wasabi/api/script/debugger/sourcecodeline.cpp | 69 + Src/Wasabi/api/script/debugger/sourcecodeline.h | 100 + Src/Wasabi/api/script/debugger/vcpudebug.cpp | 99 + Src/Wasabi/api/script/debugger/vcpudebug.h | 39 + Src/Wasabi/api/script/guru.cpp | 216 + Src/Wasabi/api/script/guru.h | 51 + Src/Wasabi/api/script/makiapi.cpp | 248 + Src/Wasabi/api/script/makiapi.h | 66 + Src/Wasabi/api/script/objcontroller.cpp | 156 + Src/Wasabi/api/script/objcontroller.h | 316 ++ Src/Wasabi/api/script/objcontrollert.cpp | 1 + Src/Wasabi/api/script/objcontrollert.h | 67 + .../api/script/objects/PlaylistScriptObject.cpp | 438 ++ .../api/script/objects/PlaylistScriptObject.h | 102 + .../api/script/objects/c_script/c_browser.cpp | 127 + Src/Wasabi/api/script/objects/c_script/c_browser.h | 49 + .../api/script/objects/c_script/c_button.cpp | 104 + Src/Wasabi/api/script/objects/c_script/c_button.h | 45 + .../api/script/objects/c_script/c_checkbox.cpp | 84 + .../api/script/objects/c_script/c_checkbox.h | 39 + .../api/script/objects/c_script/c_container.cpp | 179 + .../api/script/objects/c_script/c_container.h | 61 + .../api/script/objects/c_script/c_dropdownlist.cpp | 184 + .../api/script/objects/c_script/c_dropdownlist.h | 63 + Src/Wasabi/api/script/objects/c_script/c_edit.cpp | 135 + Src/Wasabi/api/script/objects/c_script/c_edit.h | 53 + Src/Wasabi/api/script/objects/c_script/c_group.cpp | 99 + Src/Wasabi/api/script/objects/c_script/c_group.h | 43 + .../api/script/objects/c_script/c_grouplist.cpp | 85 + .../api/script/objects/c_script/c_grouplist.h | 39 + .../api/script/objects/c_script/c_guilist.cpp | 722 +++ Src/Wasabi/api/script/objects/c_script/c_guilist.h | 189 + .../api/script/objects/c_script/c_guiobject.cpp | 739 +++ .../api/script/objects/c_script/c_guiobject.h | 193 + .../api/script/objects/c_script/c_guitree.cpp | 491 ++ Src/Wasabi/api/script/objects/c_script/c_guitree.h | 131 + .../api/script/objects/c_script/c_layout.cpp | 236 + Src/Wasabi/api/script/objects/c_script/c_layout.h | 79 + .../api/script/objects/c_script/c_menubutton.cpp | 80 + .../api/script/objects/c_script/c_menubutton.h | 39 + .../api/script/objects/c_script/c_querylist.cpp | 49 + .../api/script/objects/c_script/c_querylist.h | 31 + .../api/script/objects/c_script/c_rootobj.cpp | 64 + Src/Wasabi/api/script/objects/c_script/c_rootobj.h | 33 + .../api/script/objects/c_script/c_slider.cpp | 100 + Src/Wasabi/api/script/objects/c_script/c_slider.h | 43 + .../api/script/objects/c_script/c_tabsheet.cpp | 59 + .../api/script/objects/c_script/c_tabsheet.h | 33 + Src/Wasabi/api/script/objects/c_script/c_text.cpp | 89 + Src/Wasabi/api/script/objects/c_script/c_text.h | 40 + .../api/script/objects/c_script/c_togglebutton.cpp | 59 + .../api/script/objects/c_script/c_togglebutton.h | 33 + .../api/script/objects/c_script/c_treeitem.cpp | 310 ++ .../api/script/objects/c_script/c_treeitem.h | 99 + Src/Wasabi/api/script/objects/c_script/gen.m | 22 + .../api/script/objects/c_script/h_browser.cpp | 85 + Src/Wasabi/api/script/objects/c_script/h_browser.h | 35 + .../api/script/objects/c_script/h_button.cpp | 62 + Src/Wasabi/api/script/objects/c_script/h_button.h | 35 + .../api/script/objects/c_script/h_checkbox.cpp | 56 + .../api/script/objects/c_script/h_checkbox.h | 31 + .../api/script/objects/c_script/h_container.cpp | 65 + .../api/script/objects/c_script/h_container.h | 37 + .../api/script/objects/c_script/h_dropdownlist.cpp | 56 + .../api/script/objects/c_script/h_dropdownlist.h | 31 + Src/Wasabi/api/script/objects/c_script/h_edit.cpp | 65 + Src/Wasabi/api/script/objects/c_script/h_edit.h | 37 + Src/Wasabi/api/script/objects/c_script/h_group.cpp | 56 + Src/Wasabi/api/script/objects/c_script/h_group.h | 31 + .../api/script/objects/c_script/h_grouplist.cpp | 53 + .../api/script/objects/c_script/h_grouplist.h | 29 + .../api/script/objects/c_script/h_guilist.cpp | 83 + Src/Wasabi/api/script/objects/c_script/h_guilist.h | 49 + .../api/script/objects/c_script/h_guiobject.cpp | 117 + .../api/script/objects/c_script/h_guiobject.h | 71 + .../api/script/objects/c_script/h_guitree.cpp | 80 + Src/Wasabi/api/script/objects/c_script/h_guitree.h | 47 + .../api/script/objects/c_script/h_layout.cpp | 80 + Src/Wasabi/api/script/objects/c_script/h_layout.h | 47 + .../api/script/objects/c_script/h_menubutton.cpp | 62 + .../api/script/objects/c_script/h_menubutton.h | 35 + .../api/script/objects/c_script/h_querylist.cpp | 54 + .../api/script/objects/c_script/h_querylist.h | 31 + .../api/script/objects/c_script/h_rootobj.cpp | 41 + Src/Wasabi/api/script/objects/c_script/h_rootobj.h | 30 + .../api/script/objects/c_script/h_slider.cpp | 62 + Src/Wasabi/api/script/objects/c_script/h_slider.h | 35 + .../api/script/objects/c_script/h_tabsheet.cpp | 53 + .../api/script/objects/c_script/h_tabsheet.h | 29 + Src/Wasabi/api/script/objects/c_script/h_text.cpp | 56 + Src/Wasabi/api/script/objects/c_script/h_text.h | 31 + .../api/script/objects/c_script/h_togglebutton.cpp | 56 + .../api/script/objects/c_script/h_togglebutton.h | 31 + .../api/script/objects/c_script/h_treeitem.cpp | 89 + .../api/script/objects/c_script/h_treeitem.h | 53 + .../api/script/objects/c_script/scripthook.cpp | 47 + .../api/script/objects/c_script/scripthook.h | 49 + Src/Wasabi/api/script/objects/compoobj.cpp | 361 ++ Src/Wasabi/api/script/objects/compoobj.h | 119 + .../api/script/objects/core/coreadminobj.cpp | 184 + Src/Wasabi/api/script/objects/core/coreadminobj.h | 67 + Src/Wasabi/api/script/objects/core/coreobj.cpp | 1151 ++++ Src/Wasabi/api/script/objects/core/coreobj.h | 192 + .../api/script/objects/core/svc_scriptcore.cpp | 38 + .../api/script/objects/core/svc_scriptcore.h | 27 + Src/Wasabi/api/script/objects/guiobj.cpp | 2880 ++++++++++ Src/Wasabi/api/script/objects/guiobj.h | 423 ++ Src/Wasabi/api/script/objects/guiobject.h | 855 +++ Src/Wasabi/api/script/objects/guiobjectx.cpp | 131 + Src/Wasabi/api/script/objects/guiobjectx.h | 177 + Src/Wasabi/api/script/objects/rootobj.cpp | 42 + Src/Wasabi/api/script/objects/rootobj.h | 40 + Src/Wasabi/api/script/objects/rootobjcb.cpp | 12 + Src/Wasabi/api/script/objects/rootobjcb.h | 40 + Src/Wasabi/api/script/objects/rootobjcbi.cpp | 3 + Src/Wasabi/api/script/objects/rootobjcbi.h | 15 + Src/Wasabi/api/script/objects/rootobjcbx.cpp | 20 + Src/Wasabi/api/script/objects/rootobjcbx.h | 29 + .../api/script/objects/rootobjcontroller.cpp | 81 + Src/Wasabi/api/script/objects/rootobjcontroller.h | 36 + Src/Wasabi/api/script/objects/rootobject.cpp | 12 + Src/Wasabi/api/script/objects/rootobject.h | 71 + Src/Wasabi/api/script/objects/rootobjecti.cpp | 46 + Src/Wasabi/api/script/objects/rootobjecti.h | 32 + Src/Wasabi/api/script/objects/rootobjectx.cpp | 22 + Src/Wasabi/api/script/objects/rootobjectx.h | 35 + Src/Wasabi/api/script/objects/sapplication.cpp | 213 + Src/Wasabi/api/script/objects/sapplication.h | 57 + Src/Wasabi/api/script/objects/sbitlist.cpp | 118 + Src/Wasabi/api/script/objects/sbitlist.h | 56 + Src/Wasabi/api/script/objects/scolor.cpp | 236 + Src/Wasabi/api/script/objects/scolor.h | 66 + Src/Wasabi/api/script/objects/scolormgr.cpp | 235 + Src/Wasabi/api/script/objects/scolormgr.h | 66 + Src/Wasabi/api/script/objects/sfile.cpp | 119 + Src/Wasabi/api/script/objects/sfile.h | 53 + Src/Wasabi/api/script/objects/sgammagroup.cpp | 235 + Src/Wasabi/api/script/objects/sgammagroup.h | 66 + Src/Wasabi/api/script/objects/sgammaset.cpp | 201 + Src/Wasabi/api/script/objects/sgammaset.h | 62 + Src/Wasabi/api/script/objects/slist.cpp | 172 + Src/Wasabi/api/script/objects/slist.h | 62 + Src/Wasabi/api/script/objects/smap.cpp | 205 + Src/Wasabi/api/script/objects/smap.h | 74 + Src/Wasabi/api/script/objects/spopup.cpp | 140 + Src/Wasabi/api/script/objects/spopup.h | 60 + Src/Wasabi/api/script/objects/sprivate.cpp | 258 + Src/Wasabi/api/script/objects/sprivate.h | 47 + Src/Wasabi/api/script/objects/sregion.cpp | 256 + Src/Wasabi/api/script/objects/sregion.h | 92 + Src/Wasabi/api/script/objects/svcwnd.cpp | 239 + Src/Wasabi/api/script/objects/svcwnd.h | 89 + Src/Wasabi/api/script/objects/sxmldoc.cpp | 231 + Src/Wasabi/api/script/objects/sxmldoc.h | 76 + Src/Wasabi/api/script/objects/systemobj.cpp | 3500 ++++++++++++ Src/Wasabi/api/script/objects/systemobj.h | 397 ++ Src/Wasabi/api/script/objects/timer.cpp | 165 + Src/Wasabi/api/script/objects/timer.h | 77 + Src/Wasabi/api/script/objects/wacobj.cpp | 161 + Src/Wasabi/api/script/objects/wacobj.h | 75 + Src/Wasabi/api/script/objecttable.cpp | 748 +++ Src/Wasabi/api/script/objecttable.h | 144 + Src/Wasabi/api/script/opcodes.h | 64 + Src/Wasabi/api/script/script.cpp | 269 + Src/Wasabi/api/script/script.h | 86 + Src/Wasabi/api/script/scriptguid.h | 143 + Src/Wasabi/api/script/scriptmgr.cpp | 602 ++ Src/Wasabi/api/script/scriptmgr.h | 81 + Src/Wasabi/api/script/scriptobj.cpp | 12 + Src/Wasabi/api/script/scriptobj.h | 139 + Src/Wasabi/api/script/scriptobji.cpp | 305 ++ Src/Wasabi/api/script/scriptobji.h | 134 + Src/Wasabi/api/script/scriptobjx.cpp | 34 + Src/Wasabi/api/script/scriptobjx.h | 44 + Src/Wasabi/api/script/scriptvar.h | 35 + Src/Wasabi/api/script/vcpu.cpp | 2069 +++++++ Src/Wasabi/api/script/vcpu.h | 171 + Src/Wasabi/api/script/vcputypes.h | 78 + Src/Wasabi/api/service/api_service.cpp | 12 + Src/Wasabi/api/service/api_service.h | 184 + Src/Wasabi/api/service/api_servicei.cpp | 83 + Src/Wasabi/api/service/api_servicei.h | 150 + Src/Wasabi/api/service/api_servicex.cpp | 35 + Src/Wasabi/api/service/api_servicex.h | 44 + Src/Wasabi/api/service/service.h | 16 + Src/Wasabi/api/service/servicei.cpp | 5 + Src/Wasabi/api/service/servicei.h | 180 + Src/Wasabi/api/service/services.h | 76 + Src/Wasabi/api/service/svc_enum.cpp | 2 + Src/Wasabi/api/service/svc_enum.h | 24 + Src/Wasabi/api/service/svccache.cpp | 35 + Src/Wasabi/api/service/svccache.h | 43 + Src/Wasabi/api/service/svcenum.cpp | 45 + Src/Wasabi/api/service/svcenum.h | 37 + Src/Wasabi/api/service/svcenumbyguid.cpp | 5 + Src/Wasabi/api/service/svcenumbyguid.h | 37 + Src/Wasabi/api/service/svcenumt.cpp | 5 + Src/Wasabi/api/service/svcenumt.h | 30 + Src/Wasabi/api/service/svcmgr.cpp | 365 ++ Src/Wasabi/api/service/svcmgr.h | 41 + Src/Wasabi/api/service/svcs/svc_accessibility.cpp | 10 + Src/Wasabi/api/service/svcs/svc_accessibility.h | 43 + Src/Wasabi/api/service/svcs/svc_accroleserver.cpp | 70 + Src/Wasabi/api/service/svcs/svc_accroleserver.h | 132 + Src/Wasabi/api/service/svcs/svc_action.cpp | 38 + Src/Wasabi/api/service/svcs/svc_action.h | 154 + Src/Wasabi/api/service/svcs/svc_burner.cpp | 70 + Src/Wasabi/api/service/svcs/svc_burner.h | 243 + Src/Wasabi/api/service/svcs/svc_collection.cpp | 194 + Src/Wasabi/api/service/svcs/svc_collection.h | 226 + Src/Wasabi/api/service/svcs/svc_console.cpp | 10 + Src/Wasabi/api/service/svcs/svc_console.h | 36 + Src/Wasabi/api/service/svcs/svc_contextCmd.cpp | 16 + Src/Wasabi/api/service/svcs/svc_contextCmd.h | 127 + Src/Wasabi/api/service/svcs/svc_coreadmin.cpp | 70 + Src/Wasabi/api/service/svcs/svc_coreadmin.h | 230 + Src/Wasabi/api/service/svcs/svc_db.cpp | 78 + Src/Wasabi/api/service/svcs/svc_db.h | 512 ++ Src/Wasabi/api/service/svcs/svc_debuggerui.cpp | 10 + Src/Wasabi/api/service/svcs/svc_debuggerui.h | 44 + Src/Wasabi/api/service/svcs/svc_device.h | 54 + Src/Wasabi/api/service/svcs/svc_droptarget.cpp | 11 + Src/Wasabi/api/service/svcs/svc_droptarget.h | 82 + Src/Wasabi/api/service/svcs/svc_eval.cpp | 11 + Src/Wasabi/api/service/svcs/svc_eval.h | 64 + Src/Wasabi/api/service/svcs/svc_export.h | 32 + Src/Wasabi/api/service/svcs/svc_fileread.cpp | 30 + Src/Wasabi/api/service/svcs/svc_fileread.h | 199 + Src/Wasabi/api/service/svcs/svc_filesel.cpp | 15 + Src/Wasabi/api/service/svcs/svc_filesel.h | 89 + Src/Wasabi/api/service/svcs/svc_font.cpp | 27 + Src/Wasabi/api/service/svcs/svc_font.h | 178 + Src/Wasabi/api/service/svcs/svc_fontmaker.cpp | 9 + Src/Wasabi/api/service/svcs/svc_fontmaker.h | 73 + Src/Wasabi/api/service/svcs/svc_fontrender.cpp | 16 + Src/Wasabi/api/service/svcs/svc_fontrender.h | 126 + Src/Wasabi/api/service/svcs/svc_imggen.cpp | 11 + Src/Wasabi/api/service/svcs/svc_imggen.h | 68 + Src/Wasabi/api/service/svcs/svc_imgload.cpp | 14 + Src/Wasabi/api/service/svcs/svc_imgload.h | 101 + Src/Wasabi/api/service/svcs/svc_imgwrite.h | 101 + Src/Wasabi/api/service/svcs/svc_itemmgr.cpp | 20 + Src/Wasabi/api/service/svcs/svc_itemmgr.h | 112 + Src/Wasabi/api/service/svcs/svc_loadlib.h | 16 + Src/Wasabi/api/service/svcs/svc_mediaconverter.cpp | 23 + Src/Wasabi/api/service/svcs/svc_mediaconverter.h | 161 + Src/Wasabi/api/service/svcs/svc_mediacore.cpp | 45 + Src/Wasabi/api/service/svcs/svc_mediacore.h | 172 + Src/Wasabi/api/service/svcs/svc_metadata.cpp | 14 + Src/Wasabi/api/service/svcs/svc_metadata.h | 97 + Src/Wasabi/api/service/svcs/svc_minibrowser.cpp | 12 + Src/Wasabi/api/service/svcs/svc_minibrowser.h | 69 + Src/Wasabi/api/service/svcs/svc_objectdir.cpp | 32 + Src/Wasabi/api/service/svcs/svc_objectdir.h | 294 + Src/Wasabi/api/service/svcs/svc_player.h | 35 + Src/Wasabi/api/service/svcs/svc_playlist.cpp | 28 + Src/Wasabi/api/service/svcs/svc_playlist.h | 216 + Src/Wasabi/api/service/svcs/svc_redir.cpp | 10 + Src/Wasabi/api/service/svcs/svc_redir.h | 63 + Src/Wasabi/api/service/svcs/svc_scriptobj.cpp | 10 + Src/Wasabi/api/service/svcs/svc_scriptobj.h | 29 + Src/Wasabi/api/service/svcs/svc_scriptobji.h | 51 + Src/Wasabi/api/service/svcs/svc_skinfilter.cpp | 10 + Src/Wasabi/api/service/svcs/svc_skinfilter.h | 56 + Src/Wasabi/api/service/svcs/svc_storagevolenum.cpp | 30 + Src/Wasabi/api/service/svcs/svc_storagevolenum.h | 96 + .../api/service/svcs/svc_stringconverter.cpp | 12 + Src/Wasabi/api/service/svcs/svc_stringconverter.h | 94 + Src/Wasabi/api/service/svcs/svc_stringtypes.h | 35 + Src/Wasabi/api/service/svcs/svc_textfeed.cpp | 18 + Src/Wasabi/api/service/svcs/svc_textfeed.h | 21 + Src/Wasabi/api/service/svcs/svc_tooltips.cpp | 10 + Src/Wasabi/api/service/svcs/svc_tooltips.h | 30 + Src/Wasabi/api/service/svcs/svc_wndcreate.cpp | 16 + Src/Wasabi/api/service/svcs/svc_wndcreate.h | 120 + Src/Wasabi/api/service/svcs/svc_xmlprov.cpp | 10 + Src/Wasabi/api/service/svcs/svc_xmlprov.h | 56 + Src/Wasabi/api/service/svcs/svc_xuiobject.cpp | 12 + Src/Wasabi/api/service/svcs/svc_xuiobject.h | 76 + Src/Wasabi/api/service/waservicefactory.cpp | 12 + Src/Wasabi/api/service/waservicefactory.h | 109 + Src/Wasabi/api/service/waservicefactorybase.cpp | 5 + Src/Wasabi/api/service/waservicefactorybase.h | 76 + Src/Wasabi/api/service/waservicefactoryi.cpp | 2 + Src/Wasabi/api/service/waservicefactoryi.h | 73 + Src/Wasabi/api/service/waservicefactoryt.cpp | 5 + Src/Wasabi/api/service/waservicefactoryt.h | 28 + Src/Wasabi/api/service/waservicefactorytsingle.cpp | 5 + Src/Wasabi/api/service/waservicefactorytsingle.h | 47 + Src/Wasabi/api/service/waservicefactoryx.cpp | 32 + Src/Wasabi/api/service/waservicefactoryx.h | 37 + Src/Wasabi/api/skin/SkinElementAlias.cpp | 8 + Src/Wasabi/api/skin/SkinElementAlias.h | 65 + Src/Wasabi/api/skin/SkinVersion.cpp | 42 + Src/Wasabi/api/skin/SkinVersion.h | 18 + Src/Wasabi/api/skin/api_colorthemes.cpp | 3 + Src/Wasabi/api/skin/api_colorthemes.h | 161 + Src/Wasabi/api/skin/api_palette.cpp | 1 + Src/Wasabi/api/skin/api_palette.h | 273 + Src/Wasabi/api/skin/api_skin.cpp | 63 + Src/Wasabi/api/skin/api_skin.h | 429 ++ Src/Wasabi/api/skin/colorthemes.h | 87 + Src/Wasabi/api/skin/cursormgr.cpp | 29 + Src/Wasabi/api/skin/cursormgr.h | 18 + Src/Wasabi/api/skin/feeds/TextFeedEnum.h | 35 + Src/Wasabi/api/skin/feeds/api_textfeed.cpp | 2 + Src/Wasabi/api/skin/feeds/api_textfeed.h | 66 + Src/Wasabi/api/skin/feeds/ezfeed.h | 27 + Src/Wasabi/api/skin/feeds/feedwatch.cpp | 90 + Src/Wasabi/api/skin/feeds/feedwatch.h | 54 + Src/Wasabi/api/skin/feeds/feedwatcherso.cpp | 136 + Src/Wasabi/api/skin/feeds/feedwatcherso.h | 64 + Src/Wasabi/api/skin/feeds/textfeed.cpp | 116 + Src/Wasabi/api/skin/feeds/textfeed.h | 57 + Src/Wasabi/api/skin/feeds/textfeedcb.cpp | 9 + Src/Wasabi/api/skin/feeds/textfeedcb.h | 34 + Src/Wasabi/api/skin/gammamgr.cpp | 135 + Src/Wasabi/api/skin/gammamgr.h | 91 + Src/Wasabi/api/skin/group.h | 366 ++ Src/Wasabi/api/skin/groupmgr.cpp | 51 + Src/Wasabi/api/skin/groupmgr.h | 42 + Src/Wasabi/api/skin/groupwndcreate.cpp | 51 + Src/Wasabi/api/skin/groupwndcreate.h | 25 + Src/Wasabi/api/skin/guitree.cpp | 379 ++ Src/Wasabi/api/skin/guitree.h | 171 + Src/Wasabi/api/skin/nakedobject.cpp | 34 + Src/Wasabi/api/skin/nakedobject.h | 24 + Src/Wasabi/api/skin/objectactuator.cpp | 106 + Src/Wasabi/api/skin/objectactuator.h | 49 + Src/Wasabi/api/skin/regioncache.cpp | 32 + Src/Wasabi/api/skin/regioncache.h | 53 + Src/Wasabi/api/skin/skin.cpp | 812 +++ Src/Wasabi/api/skin/skin.h | 150 + Src/Wasabi/api/skin/skinapi.cpp | 347 ++ Src/Wasabi/api/skin/skinapi.h | 79 + Src/Wasabi/api/skin/skinbmps.h | 122 + Src/Wasabi/api/skin/skinelem.cpp | 316 ++ Src/Wasabi/api/skin/skinelem.h | 106 + Src/Wasabi/api/skin/skinfilter.cpp | 18 + Src/Wasabi/api/skin/skinfilter.h | 12 + Src/Wasabi/api/skin/skinfont.cpp | 48 + Src/Wasabi/api/skin/skinfont.h | 17 + Src/Wasabi/api/skin/skinitem.cpp | 14 + Src/Wasabi/api/skin/skinitem.h | 66 + Src/Wasabi/api/skin/skinparse.cpp | 1822 +++++++ Src/Wasabi/api/skin/skinparse.h | 337 ++ Src/Wasabi/api/skin/widgets.cpp | 451 ++ Src/Wasabi/api/skin/widgets.h | 35 + Src/Wasabi/api/skin/widgets/animlayer.cpp | 880 +++ Src/Wasabi/api/skin/widgets/animlayer.h | 214 + Src/Wasabi/api/skin/widgets/button.cpp | 508 ++ Src/Wasabi/api/skin/widgets/button.h | 134 + Src/Wasabi/api/skin/widgets/checkbox.cpp | 262 + Src/Wasabi/api/skin/widgets/checkbox.h | 246 + Src/Wasabi/api/skin/widgets/combobox.cpp | 270 + Src/Wasabi/api/skin/widgets/combobox.h | 121 + Src/Wasabi/api/skin/widgets/compbuck2.cpp | 611 +++ Src/Wasabi/api/skin/widgets/compbuck2.h | 156 + Src/Wasabi/api/skin/widgets/customobject.cpp | 8 + Src/Wasabi/api/skin/widgets/customobject.h | 78 + Src/Wasabi/api/skin/widgets/db/autofilterlist.cpp | 406 ++ Src/Wasabi/api/skin/widgets/db/autofilterlist.h | 447 ++ Src/Wasabi/api/skin/widgets/db/autoquerylist.cpp | 111 + Src/Wasabi/api/skin/widgets/db/autoquerylist.h | 109 + Src/Wasabi/api/skin/widgets/db/queryline.cpp | 32 + Src/Wasabi/api/skin/widgets/db/queryline.h | 64 + Src/Wasabi/api/skin/widgets/db/xuiquerydrag.cpp | 103 + Src/Wasabi/api/skin/widgets/db/xuiquerydrag.h | 53 + Src/Wasabi/api/skin/widgets/db/xuiqueryline.cpp | 73 + Src/Wasabi/api/skin/widgets/db/xuiqueryline.h | 35 + Src/Wasabi/api/skin/widgets/db/xuiquerylist.cpp | 119 + Src/Wasabi/api/skin/widgets/db/xuiquerylist.h | 72 + Src/Wasabi/api/skin/widgets/dropdownlist.cpp | 747 +++ Src/Wasabi/api/skin/widgets/dropdownlist.h | 531 ++ Src/Wasabi/api/skin/widgets/edit.cpp | 312 ++ Src/Wasabi/api/skin/widgets/edit.h | 100 + Src/Wasabi/api/skin/widgets/fx.h | 12 + Src/Wasabi/api/skin/widgets/fx_dmove.cpp | 409 ++ Src/Wasabi/api/skin/widgets/fx_dmove.h | 48 + Src/Wasabi/api/skin/widgets/group.cpp | 1753 ++++++ Src/Wasabi/api/skin/widgets/group.h | 365 ++ Src/Wasabi/api/skin/widgets/groupclickwnd.cpp | 84 + Src/Wasabi/api/skin/widgets/groupclickwnd.h | 226 + Src/Wasabi/api/skin/widgets/grouplist.cpp | 228 + Src/Wasabi/api/skin/widgets/grouplist.h | 79 + Src/Wasabi/api/skin/widgets/grouptgbutton.cpp | 109 + Src/Wasabi/api/skin/widgets/grouptgbutton.h | 101 + Src/Wasabi/api/skin/widgets/grouptips.cpp | 92 + Src/Wasabi/api/skin/widgets/grouptips.h | 23 + Src/Wasabi/api/skin/widgets/guiradiogroup.cpp | 36 + Src/Wasabi/api/skin/widgets/guiradiogroup.h | 53 + Src/Wasabi/api/skin/widgets/historyeditbox.cpp | 152 + Src/Wasabi/api/skin/widgets/historyeditbox.h | 58 + Src/Wasabi/api/skin/widgets/layer.cpp | 1727 ++++++ Src/Wasabi/api/skin/widgets/layer.h | 287 + Src/Wasabi/api/skin/widgets/mb/iebrowser.cpp | 637 +++ Src/Wasabi/api/skin/widgets/mb/iebrowser.h | 102 + Src/Wasabi/api/skin/widgets/mb/mainminibrowser.cpp | 70 + Src/Wasabi/api/skin/widgets/mb/mainminibrowser.h | 24 + Src/Wasabi/api/skin/widgets/mb/mbsvc.cpp | 48 + Src/Wasabi/api/skin/widgets/mb/mbsvc.h | 26 + Src/Wasabi/api/skin/widgets/mb/mbsvcwac.cpp | 26 + Src/Wasabi/api/skin/widgets/mb/mbsvcwac.h | 24 + Src/Wasabi/api/skin/widgets/mb/minibrowser.cpp | 36 + Src/Wasabi/api/skin/widgets/mb/minibrowser.h | 215 + Src/Wasabi/api/skin/widgets/mb/minibrowserwnd.cpp | 173 + Src/Wasabi/api/skin/widgets/mb/minibrowserwnd.h | 57 + Src/Wasabi/api/skin/widgets/mb/scriptbrowser.cpp | 180 + Src/Wasabi/api/skin/widgets/mb/scriptbrowser.h | 63 + .../api/skin/widgets/mb/sharedminibrowser.cpp | 39 + Src/Wasabi/api/skin/widgets/mb/sharedminibrowser.h | 33 + Src/Wasabi/api/skin/widgets/mb/xuibrowser.cpp | 385 ++ Src/Wasabi/api/skin/widgets/mb/xuibrowser.h | 106 + Src/Wasabi/api/skin/widgets/mouseredir.cpp | 221 + Src/Wasabi/api/skin/widgets/mouseredir.h | 88 + Src/Wasabi/api/skin/widgets/objdirwnd.cpp | 227 + Src/Wasabi/api/skin/widgets/objdirwnd.h | 90 + Src/Wasabi/api/skin/widgets/pathpicker.cpp | 111 + Src/Wasabi/api/skin/widgets/pathpicker.h | 183 + Src/Wasabi/api/skin/widgets/pslider.cpp | 371 ++ Src/Wasabi/api/skin/widgets/pslider.h | 110 + Src/Wasabi/api/skin/widgets/sa.cpp | 735 +++ Src/Wasabi/api/skin/widgets/sa.h | 157 + Src/Wasabi/api/skin/widgets/seeker.h | 22 + Src/Wasabi/api/skin/widgets/seqband.cpp | 121 + Src/Wasabi/api/skin/widgets/seqband.h | 47 + Src/Wasabi/api/skin/widgets/seqpreamp.cpp | 44 + Src/Wasabi/api/skin/widgets/seqpreamp.h | 28 + Src/Wasabi/api/skin/widgets/seqvis.cpp | 367 ++ Src/Wasabi/api/skin/widgets/seqvis.h | 104 + Src/Wasabi/api/skin/widgets/spanbar.cpp | 58 + Src/Wasabi/api/skin/widgets/spanbar.h | 31 + Src/Wasabi/api/skin/widgets/sseeker.cpp | 128 + Src/Wasabi/api/skin/widgets/sseeker.h | 56 + Src/Wasabi/api/skin/widgets/sstatus.cpp | 172 + Src/Wasabi/api/skin/widgets/sstatus.h | 100 + Src/Wasabi/api/skin/widgets/stats/statswnd.cpp | 38 + Src/Wasabi/api/skin/widgets/stats/statswnd.h | 18 + Src/Wasabi/api/skin/widgets/stats/xuistats.cpp | 149 + Src/Wasabi/api/skin/widgets/stats/xuistats.h | 43 + Src/Wasabi/api/skin/widgets/svolbar.cpp | 55 + Src/Wasabi/api/skin/widgets/svolbar.h | 30 + Src/Wasabi/api/skin/widgets/text.cpp | 1767 ++++++ Src/Wasabi/api/skin/widgets/text.h | 240 + Src/Wasabi/api/skin/widgets/textbase.cpp | 345 ++ Src/Wasabi/api/skin/widgets/textbase.h | 95 + Src/Wasabi/api/skin/widgets/tgbutton.cpp | 313 ++ Src/Wasabi/api/skin/widgets/tgbutton.h | 136 + Src/Wasabi/api/skin/widgets/title.cpp | 261 + Src/Wasabi/api/skin/widgets/title.h | 87 + Src/Wasabi/api/skin/widgets/titlebox.cpp | 183 + Src/Wasabi/api/skin/widgets/titlebox.h | 95 + Src/Wasabi/api/skin/widgets/wa2/xuiwa2slider.cpp | 186 + Src/Wasabi/api/skin/widgets/wa2/xuiwa2slider.h | 63 + Src/Wasabi/api/skin/widgets/xuiaddparams.cpp | 41 + Src/Wasabi/api/skin/widgets/xuiaddparams.h | 34 + Src/Wasabi/api/skin/widgets/xuibookmarklist.cpp | 50 + Src/Wasabi/api/skin/widgets/xuibookmarklist.h | 36 + Src/Wasabi/api/skin/widgets/xuicheckbox.cpp | 165 + Src/Wasabi/api/skin/widgets/xuicheckbox.h | 81 + Src/Wasabi/api/skin/widgets/xuicombobox.cpp | 7 + Src/Wasabi/api/skin/widgets/xuicombobox.h | 10 + Src/Wasabi/api/skin/widgets/xuicustomobject.cpp | 64 + Src/Wasabi/api/skin/widgets/xuicustomobject.h | 40 + Src/Wasabi/api/skin/widgets/xuidownloadslist.cpp | 411 ++ Src/Wasabi/api/skin/widgets/xuidownloadslist.h | 77 + Src/Wasabi/api/skin/widgets/xuidropdownlist.cpp | 7 + Src/Wasabi/api/skin/widgets/xuidropdownlist.h | 10 + Src/Wasabi/api/skin/widgets/xuieditbox.cpp | 6 + Src/Wasabi/api/skin/widgets/xuieditbox.h | 21 + Src/Wasabi/api/skin/widgets/xuiframe.cpp | 241 + Src/Wasabi/api/skin/widgets/xuiframe.h | 97 + Src/Wasabi/api/skin/widgets/xuigradientwnd.cpp | 66 + Src/Wasabi/api/skin/widgets/xuigradientwnd.h | 26 + Src/Wasabi/api/skin/widgets/xuigrid.cpp | 297 + Src/Wasabi/api/skin/widgets/xuigrid.h | 59 + Src/Wasabi/api/skin/widgets/xuigroupxfade.cpp | 120 + Src/Wasabi/api/skin/widgets/xuigroupxfade.h | 40 + Src/Wasabi/api/skin/widgets/xuihideobject.cpp | 50 + Src/Wasabi/api/skin/widgets/xuihideobject.h | 40 + Src/Wasabi/api/skin/widgets/xuihistoryedit.cpp | 7 + Src/Wasabi/api/skin/widgets/xuihistoryedit.h | 10 + Src/Wasabi/api/skin/widgets/xuilist.cpp | 1734 ++++++ Src/Wasabi/api/skin/widgets/xuilist.h | 221 + Src/Wasabi/api/skin/widgets/xuimenu.cpp | 384 ++ Src/Wasabi/api/skin/widgets/xuimenu.h | 110 + Src/Wasabi/api/skin/widgets/xuimenuso.cpp | 271 + Src/Wasabi/api/skin/widgets/xuimenuso.h | 76 + Src/Wasabi/api/skin/widgets/xuiobjdirwnd.cpp | 57 + Src/Wasabi/api/skin/widgets/xuiobjdirwnd.h | 32 + Src/Wasabi/api/skin/widgets/xuioswndhost.cpp | 306 ++ Src/Wasabi/api/skin/widgets/xuioswndhost.h | 78 + Src/Wasabi/api/skin/widgets/xuipathpicker.cpp | 73 + Src/Wasabi/api/skin/widgets/xuipathpicker.h | 53 + Src/Wasabi/api/skin/widgets/xuiprogressgrid.cpp | 162 + Src/Wasabi/api/skin/widgets/xuiprogressgrid.h | 59 + Src/Wasabi/api/skin/widgets/xuiradiogroup.cpp | 17 + Src/Wasabi/api/skin/widgets/xuiradiogroup.h | 30 + Src/Wasabi/api/skin/widgets/xuirect.cpp | 186 + Src/Wasabi/api/skin/widgets/xuirect.h | 43 + Src/Wasabi/api/skin/widgets/xuisendparams.cpp | 37 + Src/Wasabi/api/skin/widgets/xuisendparams.h | 36 + Src/Wasabi/api/skin/widgets/xuistatus.cpp | 98 + Src/Wasabi/api/skin/widgets/xuistatus.h | 54 + Src/Wasabi/api/skin/widgets/xuitabsheet.cpp | 217 + Src/Wasabi/api/skin/widgets/xuitabsheet.h | 91 + Src/Wasabi/api/skin/widgets/xuithemeslist.cpp | 365 ++ Src/Wasabi/api/skin/widgets/xuithemeslist.h | 128 + Src/Wasabi/api/skin/widgets/xuititlebox.cpp | 59 + Src/Wasabi/api/skin/widgets/xuititlebox.h | 44 + Src/Wasabi/api/skin/widgets/xuitree.cpp | 2644 +++++++++ Src/Wasabi/api/skin/widgets/xuitree.h | 326 ++ Src/Wasabi/api/skin/widgets/xuiwndholder.cpp | 272 + Src/Wasabi/api/skin/widgets/xuiwndholder.h | 80 + Src/Wasabi/api/skin/xmlobject.cpp | 174 + Src/Wasabi/api/skin/xmlobject.h | 132 + Src/Wasabi/api/syscb/api_syscb.cpp | 14 + Src/Wasabi/api/syscb/api_syscb.h | 77 + Src/Wasabi/api/syscb/api_syscbi.cpp | 35 + Src/Wasabi/api/syscb/api_syscbi.h | 28 + Src/Wasabi/api/syscb/api_syscbx.cpp | 22 + Src/Wasabi/api/syscb/api_syscbx.h | 32 + Src/Wasabi/api/syscb/callbacks/authcb.h | 20 + Src/Wasabi/api/syscb/callbacks/browsercb.cpp | 2 + Src/Wasabi/api/syscb/callbacks/browsercb.h | 11 + Src/Wasabi/api/syscb/callbacks/browsercbi.h | 32 + Src/Wasabi/api/syscb/callbacks/consolecb.cpp | 14 + Src/Wasabi/api/syscb/callbacks/consolecb.h | 24 + Src/Wasabi/api/syscb/callbacks/corecb.cpp | 79 + Src/Wasabi/api/syscb/callbacks/corecb.h | 71 + Src/Wasabi/api/syscb/callbacks/corecbi.h | 67 + Src/Wasabi/api/syscb/callbacks/gccb.h | 31 + Src/Wasabi/api/syscb/callbacks/metacb.h | 41 + Src/Wasabi/api/syscb/callbacks/playlistcb.cpp | 10 + Src/Wasabi/api/syscb/callbacks/playlistcb.h | 26 + Src/Wasabi/api/syscb/callbacks/runlevelcb.h | 39 + Src/Wasabi/api/syscb/callbacks/skincb.cpp | 20 + Src/Wasabi/api/syscb/callbacks/skincb.h | 41 + Src/Wasabi/api/syscb/callbacks/svccb.h | 12 + Src/Wasabi/api/syscb/callbacks/svccbi.h | 34 + Src/Wasabi/api/syscb/callbacks/syscb.cpp | 12 + Src/Wasabi/api/syscb/callbacks/syscb.h | 73 + Src/Wasabi/api/syscb/callbacks/syscbi.cpp | 4 + Src/Wasabi/api/syscb/callbacks/syscbi.h | 46 + Src/Wasabi/api/syscb/callbacks/syscbx.cpp | 21 + Src/Wasabi/api/syscb/callbacks/syscbx.h | 30 + Src/Wasabi/api/syscb/callbacks/sysmemcb.h | 53 + Src/Wasabi/api/syscb/callbacks/wndcb.cpp | 36 + Src/Wasabi/api/syscb/callbacks/wndcb.h | 43 + Src/Wasabi/api/syscb/cbmgr.cpp | 41 + Src/Wasabi/api/syscb/cbmgr.h | 18 + Src/Wasabi/api/timer/api_timer.h | 47 + Src/Wasabi/api/timer/osx_timer.cpp | 38 + Src/Wasabi/api/timer/osx_timer.h | 17 + Src/Wasabi/api/timer/timerclient.cpp | 108 + Src/Wasabi/api/timer/timerclient.h | 183 + Src/Wasabi/api/timer/timeslicer.cpp | 62 + Src/Wasabi/api/timer/timeslicer.h | 64 + Src/Wasabi/api/util/savefile.cpp | 228 + Src/Wasabi/api/util/savefile.h | 31 + Src/Wasabi/api/util/selectfile.cpp | 111 + Src/Wasabi/api/util/selectfile.h | 41 + Src/Wasabi/api/util/systray.cpp | 93 + Src/Wasabi/api/util/systray.h | 23 + Src/Wasabi/api/util/varmgr.cpp | 111 + Src/Wasabi/api/util/varmgr.h | 17 + Src/Wasabi/api/wac/compdb.h | 28 + Src/Wasabi/api/wac/compon.cpp | 480 ++ Src/Wasabi/api/wac/compon.h | 56 + Src/Wasabi/api/wac/main.h | 134 + Src/Wasabi/api/wac/papi.h | 12 + Src/Wasabi/api/wac/wac.h | 266 + Src/Wasabi/api/wac/waclient.cpp | 347 ++ Src/Wasabi/api/wnd/PaintCanvas.h | 3 + Src/Wasabi/api/wnd/accessible.cpp | 16 + Src/Wasabi/api/wnd/accessible.h | 622 +++ Src/Wasabi/api/wnd/api_canvas.cpp | 2 + Src/Wasabi/api/wnd/api_canvas.h | 163 + Src/Wasabi/api/wnd/api_region.cpp | 2 + Src/Wasabi/api/wnd/api_region.h | 200 + Src/Wasabi/api/wnd/api_window.cpp | 3 + Src/Wasabi/api/wnd/api_window.h | 1277 +++++ Src/Wasabi/api/wnd/api_wnd.cpp | 57 + Src/Wasabi/api/wnd/api_wnd.h | 390 ++ Src/Wasabi/api/wnd/basewnd.cpp | 5743 ++++++++++++++++++++ Src/Wasabi/api/wnd/basewnd.h | 944 ++++ Src/Wasabi/api/wnd/bitmap.cpp | 1584 ++++++ Src/Wasabi/api/wnd/bitmap.h | 7 + Src/Wasabi/api/wnd/blending.cpp | 56 + Src/Wasabi/api/wnd/blending.h | 536 ++ Src/Wasabi/api/wnd/bltcanvas.h | 5 + Src/Wasabi/api/wnd/bucketitem.h | 76 + Src/Wasabi/api/wnd/canvas.cpp | 3 + Src/Wasabi/api/wnd/canvas.h | 5 + Src/Wasabi/api/wnd/contextmenu.cpp | 170 + Src/Wasabi/api/wnd/contextmenu.h | 42 + Src/Wasabi/api/wnd/cursor.cpp | 48 + Src/Wasabi/api/wnd/cursor.h | 62 + Src/Wasabi/api/wnd/cwndtrack.h | 11 + Src/Wasabi/api/wnd/deactivatemgr.cpp | 55 + Src/Wasabi/api/wnd/deactivatemgr.h | 22 + Src/Wasabi/api/wnd/di.cpp | 46 + Src/Wasabi/api/wnd/drag.h | 75 + Src/Wasabi/api/wnd/dragitem.h | 23 + Src/Wasabi/api/wnd/dragitemi.cpp | 36 + Src/Wasabi/api/wnd/dragitemi.h | 58 + Src/Wasabi/api/wnd/fakedrag.h | 12 + Src/Wasabi/api/wnd/findobjectcb.cpp | 8 + Src/Wasabi/api/wnd/findobjectcb.h | 44 + Src/Wasabi/api/wnd/fontdef.h | 15 + Src/Wasabi/api/wnd/ifc_bitmap.h | 51 + Src/Wasabi/api/wnd/keyboard.cpp | 570 ++ Src/Wasabi/api/wnd/keyboard.h | 77 + Src/Wasabi/api/wnd/minibrowser.cpp | 28 + Src/Wasabi/api/wnd/minibrowser.h | 1 + Src/Wasabi/api/wnd/notifmsg.h | 109 + Src/Wasabi/api/wnd/paintcb.cpp | 52 + Src/Wasabi/api/wnd/paintcb.h | 73 + Src/Wasabi/api/wnd/paintset.cpp | 603 ++ Src/Wasabi/api/wnd/paintset.h | 18 + Src/Wasabi/api/wnd/paintsets.h | 18 + Src/Wasabi/api/wnd/platform/osx/PaintCanvas.cpp | 51 + Src/Wasabi/api/wnd/platform/osx/PaintCanvas.h | 45 + Src/Wasabi/api/wnd/platform/osx/bltcanvas.h | 26 + Src/Wasabi/api/wnd/platform/osx/canvas.h | 69 + .../api/wnd/platform/osx/osx_bitmap_cgimage.cpp | 220 + .../api/wnd/platform/osx/osx_bitmap_cgimage.h | 47 + .../api/wnd/platform/osx/osx_canvas_layer.cpp | 95 + .../api/wnd/platform/osx/osx_canvas_quartz.cpp | 275 + .../api/wnd/platform/osx/osx_region_hishape.cpp | 217 + Src/Wasabi/api/wnd/platform/osx/region.h | 115 + Src/Wasabi/api/wnd/platform/win32/bitmap.h | 81 + Src/Wasabi/api/wnd/platform/win32/canvas.h | 1 + Src/Wasabi/api/wnd/platform/win32/region.h | 135 + Src/Wasabi/api/wnd/popexitcb.cpp | 8 + Src/Wasabi/api/wnd/popexitcb.h | 40 + Src/Wasabi/api/wnd/popexitchecker.cpp | 79 + Src/Wasabi/api/wnd/popexitchecker.h | 39 + Src/Wasabi/api/wnd/popup.cpp | 1720 ++++++ Src/Wasabi/api/wnd/popup.h | 341 ++ Src/Wasabi/api/wnd/region.cpp | 1 + Src/Wasabi/api/wnd/region.h | 5 + Src/Wasabi/api/wnd/resizable.h | 21 + Src/Wasabi/api/wnd/rootwnd.cpp | 197 + Src/Wasabi/api/wnd/rootwnd.h | 275 + Src/Wasabi/api/wnd/textalign.h | 32 + Src/Wasabi/api/wnd/usermsg.h | 23 + Src/Wasabi/api/wnd/virtualwnd.cpp | 672 +++ Src/Wasabi/api/wnd/virtualwnd.h | 84 + Src/Wasabi/api/wnd/wndapi.cpp | 384 ++ Src/Wasabi/api/wnd/wndapi.h | 101 + Src/Wasabi/api/wnd/wndclass/SelItemList.cpp | 72 + Src/Wasabi/api/wnd/wndclass/SelItemList.h | 31 + Src/Wasabi/api/wnd/wndclass/abstractwndhold.cpp | 287 + Src/Wasabi/api/wnd/wndclass/abstractwndhold.h | 267 + Src/Wasabi/api/wnd/wndclass/appbarwnd.cpp | 1113 ++++ Src/Wasabi/api/wnd/wndclass/appbarwnd.h | 155 + Src/Wasabi/api/wnd/wndclass/backbufferwnd.cpp | 86 + Src/Wasabi/api/wnd/wndclass/backbufferwnd.h | 53 + Src/Wasabi/api/wnd/wndclass/blankwnd.cpp | 24 + Src/Wasabi/api/wnd/wndclass/blankwnd.h | 41 + Src/Wasabi/api/wnd/wndclass/bufferpaintwnd.cpp | 113 + Src/Wasabi/api/wnd/wndclass/bufferpaintwnd.h | 40 + Src/Wasabi/api/wnd/wndclass/buttbar.cpp | 208 + Src/Wasabi/api/wnd/wndclass/buttbar.h | 168 + Src/Wasabi/api/wnd/wndclass/buttwnd.cpp | 761 +++ Src/Wasabi/api/wnd/wndclass/buttwnd.h | 602 ++ Src/Wasabi/api/wnd/wndclass/clickwnd.cpp | 319 ++ Src/Wasabi/api/wnd/wndclass/clickwnd.h | 74 + Src/Wasabi/api/wnd/wndclass/ddrawwnd.cpp | 219 + Src/Wasabi/api/wnd/wndclass/ddrawwnd.h | 60 + Src/Wasabi/api/wnd/wndclass/editwnd.cpp | 1001 ++++ Src/Wasabi/api/wnd/wndclass/editwnd.h | 134 + Src/Wasabi/api/wnd/wndclass/editwndstring.cpp | 17 + Src/Wasabi/api/wnd/wndclass/editwndstring.h | 24 + Src/Wasabi/api/wnd/wndclass/embeddedxui.cpp | 143 + Src/Wasabi/api/wnd/wndclass/embeddedxui.h | 88 + Src/Wasabi/api/wnd/wndclass/foreignwnd.cpp | 60 + Src/Wasabi/api/wnd/wndclass/foreignwnd.h | 56 + Src/Wasabi/api/wnd/wndclass/framewnd.cpp | 777 +++ Src/Wasabi/api/wnd/wndclass/framewnd.h | 124 + Src/Wasabi/api/wnd/wndclass/gradientwnd.cpp | 82 + Src/Wasabi/api/wnd/wndclass/gradientwnd.h | 31 + Src/Wasabi/api/wnd/wndclass/guiobjwnd.cpp | 476 ++ Src/Wasabi/api/wnd/wndclass/guiobjwnd.h | 237 + Src/Wasabi/api/wnd/wndclass/itemlistwnd.cpp | 286 + Src/Wasabi/api/wnd/wndclass/itemlistwnd.h | 426 ++ Src/Wasabi/api/wnd/wndclass/labelwnd.cpp | 203 + Src/Wasabi/api/wnd/wndclass/labelwnd.h | 46 + Src/Wasabi/api/wnd/wndclass/listwnd.cpp | 2151 ++++++++ Src/Wasabi/api/wnd/wndclass/listwnd.h | 459 ++ Src/Wasabi/api/wnd/wndclass/oswnd.cpp | 32 + Src/Wasabi/api/wnd/wndclass/oswnd.h | 19 + Src/Wasabi/api/wnd/wndclass/oswndhost.cpp | 14 + Src/Wasabi/api/wnd/wndclass/oswndhost.h | 53 + Src/Wasabi/api/wnd/wndclass/qpaintwnd.cpp | 357 ++ Src/Wasabi/api/wnd/wndclass/qpaintwnd.h | 154 + Src/Wasabi/api/wnd/wndclass/rootwndholder.cpp | 113 + Src/Wasabi/api/wnd/wndclass/rootwndholder.h | 41 + Src/Wasabi/api/wnd/wndclass/scbkgwnd.cpp | 869 +++ Src/Wasabi/api/wnd/wndclass/scbkgwnd.h | 463 ++ Src/Wasabi/api/wnd/wndclass/scrollbar.cpp | 679 +++ Src/Wasabi/api/wnd/wndclass/scrollbar.h | 423 ++ Src/Wasabi/api/wnd/wndclass/sepwnd.cpp | 63 + Src/Wasabi/api/wnd/wndclass/sepwnd.h | 27 + Src/Wasabi/api/wnd/wndclass/slider.cpp | 705 +++ Src/Wasabi/api/wnd/wndclass/slider.h | 451 ++ Src/Wasabi/api/wnd/wndclass/status.cpp | 242 + Src/Wasabi/api/wnd/wndclass/status.h | 178 + Src/Wasabi/api/wnd/wndclass/svcwndhold.cpp | 53 + Src/Wasabi/api/wnd/wndclass/svcwndhold.h | 51 + Src/Wasabi/api/wnd/wndclass/tabsheet.cpp | 544 ++ Src/Wasabi/api/wnd/wndclass/tabsheet.h | 268 + Src/Wasabi/api/wnd/wndclass/tabsheetbar.cpp | 130 + Src/Wasabi/api/wnd/wndclass/tabsheetbar.h | 39 + Src/Wasabi/api/wnd/wndclass/textbar.cpp | 148 + Src/Wasabi/api/wnd/wndclass/textbar.h | 219 + Src/Wasabi/api/wnd/wndclass/tooltip.cpp | 47 + Src/Wasabi/api/wnd/wndclass/tooltip.h | 18 + Src/Wasabi/api/wnd/wndclass/treewnd.cpp | 1645 ++++++ Src/Wasabi/api/wnd/wndclass/treewnd.h | 624 +++ Src/Wasabi/api/wnd/wndclass/typesheet.cpp | 38 + Src/Wasabi/api/wnd/wndclass/typesheet.h | 49 + Src/Wasabi/api/wnd/wndclass/virtualhostwnd.cpp | 198 + Src/Wasabi/api/wnd/wndclass/virtualhostwnd.h | 51 + Src/Wasabi/api/wnd/wndclass/wndholder.cpp | 369 ++ Src/Wasabi/api/wnd/wndclass/wndholder.h | 285 + Src/Wasabi/api/wnd/wndevent.h | 5 + Src/Wasabi/api/wnd/wndtrack.cpp | 945 ++++ Src/Wasabi/api/wnd/wndtrack.h | 104 + Src/Wasabi/api/wndmgr/alphamgr.cpp | 661 +++ Src/Wasabi/api/wndmgr/alphamgr.h | 136 + Src/Wasabi/api/wndmgr/animate.cpp | 96 + Src/Wasabi/api/wndmgr/animate.h | 11 + Src/Wasabi/api/wndmgr/api_wndmgr.cpp | 47 + Src/Wasabi/api/wndmgr/api_wndmgr.h | 305 ++ Src/Wasabi/api/wndmgr/appcmds.cpp | 61 + Src/Wasabi/api/wndmgr/appcmds.h | 89 + Src/Wasabi/api/wndmgr/autopopup.cpp | 157 + Src/Wasabi/api/wndmgr/autopopup.h | 76 + Src/Wasabi/api/wndmgr/container.cpp | 919 ++++ Src/Wasabi/api/wndmgr/container.h | 231 + Src/Wasabi/api/wndmgr/gc.cpp | 24 + Src/Wasabi/api/wndmgr/gc.h | 19 + Src/Wasabi/api/wndmgr/guistatuscb.cpp | 15 + Src/Wasabi/api/wndmgr/guistatuscb.h | 83 + Src/Wasabi/api/wndmgr/layout.cpp | 2586 +++++++++ Src/Wasabi/api/wndmgr/layout.h | 465 ++ Src/Wasabi/api/wndmgr/msgbox.cpp | 251 + Src/Wasabi/api/wndmgr/msgbox.h | 49 + Src/Wasabi/api/wndmgr/resize.cpp | 383 ++ Src/Wasabi/api/wndmgr/resize.h | 48 + Src/Wasabi/api/wndmgr/skinembed.cpp | 733 +++ Src/Wasabi/api/wndmgr/skinembed.h | 76 + Src/Wasabi/api/wndmgr/skinwnd.cpp | 99 + Src/Wasabi/api/wndmgr/skinwnd.h | 42 + Src/Wasabi/api/wndmgr/snappnt.cpp | 181 + Src/Wasabi/api/wndmgr/snappnt.h | 49 + Src/Wasabi/api/wndmgr/wndmgrapi.cpp | 279 + Src/Wasabi/api/wndmgr/wndmgrapi.h | 59 + Src/Wasabi/api/xml/LoadXML.cpp | 92 + Src/Wasabi/api/xml/LoadXML.h | 7 + Src/Wasabi/api/xml/XMLAutoInclude.cpp | 87 + Src/Wasabi/api/xml/XMLAutoInclude.h | 22 + Src/Wasabi/api/xml/api_xmlreadercallback.cpp | 2 + Src/Wasabi/api/xml/xmlparams.cpp | 12 + Src/Wasabi/api/xml/xmlparams.h | 103 + Src/Wasabi/api/xml/xmlparamsi.cpp | 119 + Src/Wasabi/api/xml/xmlparamsi.h | 52 + Src/Wasabi/api/xml/xmlparamsx.cpp | 32 + Src/Wasabi/api/xml/xmlparamsx.h | 38 + Src/Wasabi/api/xml/xmlparse.h | 23 + Src/Wasabi/api/xml/xmlreader.cpp | 197 + Src/Wasabi/api/xml/xmlreader.h | 75 + Src/Wasabi/api/xml/xmlwrite.cpp | 262 + Src/Wasabi/api/xml/xmlwrite.h | 45 + 937 files changed, 150769 insertions(+) create mode 100644 Src/Wasabi/api/apiconfig.h create mode 100644 Src/Wasabi/api/apiinit.cpp create mode 100644 Src/Wasabi/api/apiinit.h create mode 100644 Src/Wasabi/api/application/api_application.cpp create mode 100644 Src/Wasabi/api/application/api_application.h create mode 100644 Src/Wasabi/api/application/api_applicationi.cpp create mode 100644 Src/Wasabi/api/application/api_applicationi.h create mode 100644 Src/Wasabi/api/application/api_applicationx.cpp create mode 100644 Src/Wasabi/api/application/api_applicationx.h create mode 100644 Src/Wasabi/api/application/ifc_messageprocessor.cpp create mode 100644 Src/Wasabi/api/application/ifc_messageprocessor.h create mode 100644 Src/Wasabi/api/application/ifc_messageprocessori.cpp create mode 100644 Src/Wasabi/api/application/ifc_messageprocessori.h create mode 100644 Src/Wasabi/api/application/ipcs.cpp create mode 100644 Src/Wasabi/api/application/ipcs.h create mode 100644 Src/Wasabi/api/application/pathmgr.cpp create mode 100644 Src/Wasabi/api/application/pathmgr.h create mode 100644 Src/Wasabi/api/application/version.cpp create mode 100644 Src/Wasabi/api/application/version.h create mode 100644 Src/Wasabi/api/application/wkc.cpp create mode 100644 Src/Wasabi/api/application/wkc.h create mode 100644 Src/Wasabi/api/config/api_config.cpp create mode 100644 Src/Wasabi/api/config/api_config.h create mode 100644 Src/Wasabi/api/config/api_configi.cpp create mode 100644 Src/Wasabi/api/config/api_configi.h create mode 100644 Src/Wasabi/api/config/api_configx.cpp create mode 100644 Src/Wasabi/api/config/api_configx.h create mode 100644 Src/Wasabi/api/config/cfglist.cpp create mode 100644 Src/Wasabi/api/config/cfglist.h create mode 100644 Src/Wasabi/api/config/cfgscriptobj.cpp create mode 100644 Src/Wasabi/api/config/cfgscriptobj.h create mode 100644 Src/Wasabi/api/config/config.cpp create mode 100644 Src/Wasabi/api/config/config.h create mode 100644 Src/Wasabi/api/config/configapi.cpp create mode 100644 Src/Wasabi/api/config/configapi.h create mode 100644 Src/Wasabi/api/config/filetypes.cpp create mode 100644 Src/Wasabi/api/config/filetypes.h create mode 100644 Src/Wasabi/api/config/items/attrbool.h create mode 100644 Src/Wasabi/api/config/items/attrcb.h create mode 100644 Src/Wasabi/api/config/items/attrfloat.h create mode 100644 Src/Wasabi/api/config/items/attrfn.h create mode 100644 Src/Wasabi/api/config/items/attrhandler.h create mode 100644 Src/Wasabi/api/config/items/attribs.h create mode 100644 Src/Wasabi/api/config/items/attribute.cpp create mode 100644 Src/Wasabi/api/config/items/attribute.h create mode 100644 Src/Wasabi/api/config/items/attrint.h create mode 100644 Src/Wasabi/api/config/items/attrstr.cpp create mode 100644 Src/Wasabi/api/config/items/attrstr.h create mode 100644 Src/Wasabi/api/config/items/cfgitem.h create mode 100644 Src/Wasabi/api/config/items/cfgitemi.cpp create mode 100644 Src/Wasabi/api/config/items/cfgitemi.h create mode 100644 Src/Wasabi/api/config/items/cfgitemx.cpp create mode 100644 Src/Wasabi/api/config/items/cfgitemx.h create mode 100644 Src/Wasabi/api/config/items/intarray.cpp create mode 100644 Src/Wasabi/api/config/items/intarray.h create mode 100644 Src/Wasabi/api/config/options.cpp create mode 100644 Src/Wasabi/api/config/options.h create mode 100644 Src/Wasabi/api/config/uioptions.cpp create mode 100644 Src/Wasabi/api/config/uioptions.h create mode 100644 Src/Wasabi/api/console/console.cpp create mode 100644 Src/Wasabi/api/console/console.h create mode 100644 Src/Wasabi/api/core/api_core.cpp create mode 100644 Src/Wasabi/api/core/api_core.h create mode 100644 Src/Wasabi/api/core/buttons.h create mode 100644 Src/Wasabi/api/core/coreactions.cpp create mode 100644 Src/Wasabi/api/core/coreactions.h create mode 100644 Src/Wasabi/api/core/corehandle.cpp create mode 100644 Src/Wasabi/api/core/corehandle.h create mode 100644 Src/Wasabi/api/core/sequence.cpp create mode 100644 Src/Wasabi/api/core/sequence.h create mode 100644 Src/Wasabi/api/dependency/api_dependent.cpp create mode 100644 Src/Wasabi/api/dependency/api_dependent.h create mode 100644 Src/Wasabi/api/dependency/api_dependentviewer.cpp create mode 100644 Src/Wasabi/api/dependency/api_dependentviewer.h create mode 100644 Src/Wasabi/api/filereader/api_filereader.cpp create mode 100644 Src/Wasabi/api/filereader/api_filereader.h create mode 100644 Src/Wasabi/api/filereader/api_readercallback.h create mode 100644 Src/Wasabi/api/filereader/filereaderapi.cpp create mode 100644 Src/Wasabi/api/filereader/filereaderapi.h create mode 100644 Src/Wasabi/api/filereader/local/fileread.cpp create mode 100644 Src/Wasabi/api/filereader/local/fileread.h create mode 100644 Src/Wasabi/api/filereader/svc_filereadI.h create mode 100644 Src/Wasabi/api/filereader/zip/zipread.cpp create mode 100644 Src/Wasabi/api/filereader/zip/zipread.h create mode 100644 Src/Wasabi/api/font/FontCreator.h create mode 100644 Src/Wasabi/api/font/FontSvcEnum.h create mode 100644 Src/Wasabi/api/font/api_font.cpp create mode 100644 Src/Wasabi/api/font/api_font.h create mode 100644 Src/Wasabi/api/font/bitmapfont.cpp create mode 100644 Src/Wasabi/api/font/bitmapfont.h create mode 100644 Src/Wasabi/api/font/font.cpp create mode 100644 Src/Wasabi/api/font/font.h create mode 100644 Src/Wasabi/api/font/fontapi.cpp create mode 100644 Src/Wasabi/api/font/fontapi.h create mode 100644 Src/Wasabi/api/font/linux/truetypefont_linux.cpp create mode 100644 Src/Wasabi/api/font/linux/truetypefont_linux.h create mode 100644 Src/Wasabi/api/font/skinfont.cpp create mode 100644 Src/Wasabi/api/font/skinfont.h create mode 100644 Src/Wasabi/api/font/svc_fontI.h create mode 100644 Src/Wasabi/api/font/truetypefontdef.h create mode 100644 Src/Wasabi/api/font/win32/truetypefont_win32.cpp create mode 100644 Src/Wasabi/api/font/win32/truetypefont_win32.h create mode 100644 Src/Wasabi/api/imgldr/ImgLoaderEnum.h create mode 100644 Src/Wasabi/api/imgldr/api_imgldr.cpp create mode 100644 Src/Wasabi/api/imgldr/api_imgldr.h create mode 100644 Src/Wasabi/api/imgldr/imggen/grad.cpp create mode 100644 Src/Wasabi/api/imgldr/imggen/grad.h create mode 100644 Src/Wasabi/api/imgldr/imggen/imggen.cpp create mode 100644 Src/Wasabi/api/imgldr/imggen/imggen.h create mode 100644 Src/Wasabi/api/imgldr/imggen/osedge.cpp create mode 100644 Src/Wasabi/api/imgldr/imggen/osedge.h create mode 100644 Src/Wasabi/api/imgldr/imggen/poly.cpp create mode 100644 Src/Wasabi/api/imgldr/imggen/poly.h create mode 100644 Src/Wasabi/api/imgldr/imggen/shadowwnd.cpp create mode 100644 Src/Wasabi/api/imgldr/imggen/shadowwnd.h create mode 100644 Src/Wasabi/api/imgldr/imggen/solid.cpp create mode 100644 Src/Wasabi/api/imgldr/imggen/solid.h create mode 100644 Src/Wasabi/api/imgldr/imgldr.cpp create mode 100644 Src/Wasabi/api/imgldr/imgldr.h create mode 100644 Src/Wasabi/api/imgldr/imgldrapi.cpp create mode 100644 Src/Wasabi/api/imgldr/imgldrapi.h create mode 100644 Src/Wasabi/api/imgldr/skinbmps.h create mode 100644 Src/Wasabi/api/imgldr/winbmp.h create mode 100644 Src/Wasabi/api/locales/LocalesInfo.cpp create mode 100644 Src/Wasabi/api/locales/LocalesInfo.h create mode 100644 Src/Wasabi/api/locales/api_locales.cpp create mode 100644 Src/Wasabi/api/locales/api_locales.h create mode 100644 Src/Wasabi/api/locales/api_localesi.cpp create mode 100644 Src/Wasabi/api/locales/api_localesi.h create mode 100644 Src/Wasabi/api/locales/api_localesx.cpp create mode 100644 Src/Wasabi/api/locales/api_localesx.h create mode 100644 Src/Wasabi/api/locales/localesmgr.cpp create mode 100644 Src/Wasabi/api/locales/localesmgr.h create mode 100644 Src/Wasabi/api/locales/xlatstr.h create mode 100644 Src/Wasabi/api/memmgr/api_memmgr.cpp create mode 100644 Src/Wasabi/api/memmgr/api_memmgr.h create mode 100644 Src/Wasabi/api/metrics/metricscb.h create mode 100644 Src/Wasabi/api/script/api_maki.cpp create mode 100644 Src/Wasabi/api/script/api_maki.h create mode 100644 Src/Wasabi/api/script/api_makidebug.cpp create mode 100644 Src/Wasabi/api/script/api_makidebug.h create mode 100644 Src/Wasabi/api/script/api_makii.cpp create mode 100644 Src/Wasabi/api/script/api_makii.h create mode 100644 Src/Wasabi/api/script/api_makix.cpp create mode 100644 Src/Wasabi/api/script/api_makix.h create mode 100644 Src/Wasabi/api/script/debugger/api_makidebug.cpp create mode 100644 Src/Wasabi/api/script/debugger/api_makidebug.h create mode 100644 Src/Wasabi/api/script/debugger/debugapi.cpp create mode 100644 Src/Wasabi/api/script/debugger/debugapi.h create mode 100644 Src/Wasabi/api/script/debugger/debuggerui.cpp create mode 100644 Src/Wasabi/api/script/debugger/debuggerui.h create mode 100644 Src/Wasabi/api/script/debugger/debugsymbols.cpp create mode 100644 Src/Wasabi/api/script/debugger/debugsymbols.h create mode 100644 Src/Wasabi/api/script/debugger/disasm.cpp create mode 100644 Src/Wasabi/api/script/debugger/disasm.h create mode 100644 Src/Wasabi/api/script/debugger/jitd.cpp create mode 100644 Src/Wasabi/api/script/debugger/jitd.h create mode 100644 Src/Wasabi/api/script/debugger/jitdbreak.cpp create mode 100644 Src/Wasabi/api/script/debugger/jitdbreak.h create mode 100644 Src/Wasabi/api/script/debugger/sdebuggerui.cpp create mode 100644 Src/Wasabi/api/script/debugger/sdebuggerui.h create mode 100644 Src/Wasabi/api/script/debugger/sourcecodeline.cpp create mode 100644 Src/Wasabi/api/script/debugger/sourcecodeline.h create mode 100644 Src/Wasabi/api/script/debugger/vcpudebug.cpp create mode 100644 Src/Wasabi/api/script/debugger/vcpudebug.h create mode 100644 Src/Wasabi/api/script/guru.cpp create mode 100644 Src/Wasabi/api/script/guru.h create mode 100644 Src/Wasabi/api/script/makiapi.cpp create mode 100644 Src/Wasabi/api/script/makiapi.h create mode 100644 Src/Wasabi/api/script/objcontroller.cpp create mode 100644 Src/Wasabi/api/script/objcontroller.h create mode 100644 Src/Wasabi/api/script/objcontrollert.cpp create mode 100644 Src/Wasabi/api/script/objcontrollert.h create mode 100644 Src/Wasabi/api/script/objects/PlaylistScriptObject.cpp create mode 100644 Src/Wasabi/api/script/objects/PlaylistScriptObject.h create mode 100644 Src/Wasabi/api/script/objects/c_script/c_browser.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/c_browser.h create mode 100644 Src/Wasabi/api/script/objects/c_script/c_button.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/c_button.h create mode 100644 Src/Wasabi/api/script/objects/c_script/c_checkbox.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/c_checkbox.h create mode 100644 Src/Wasabi/api/script/objects/c_script/c_container.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/c_container.h create mode 100644 Src/Wasabi/api/script/objects/c_script/c_dropdownlist.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/c_dropdownlist.h create mode 100644 Src/Wasabi/api/script/objects/c_script/c_edit.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/c_edit.h create mode 100644 Src/Wasabi/api/script/objects/c_script/c_group.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/c_group.h create mode 100644 Src/Wasabi/api/script/objects/c_script/c_grouplist.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/c_grouplist.h create mode 100644 Src/Wasabi/api/script/objects/c_script/c_guilist.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/c_guilist.h create mode 100644 Src/Wasabi/api/script/objects/c_script/c_guiobject.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/c_guiobject.h create mode 100644 Src/Wasabi/api/script/objects/c_script/c_guitree.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/c_guitree.h create mode 100644 Src/Wasabi/api/script/objects/c_script/c_layout.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/c_layout.h create mode 100644 Src/Wasabi/api/script/objects/c_script/c_menubutton.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/c_menubutton.h create mode 100644 Src/Wasabi/api/script/objects/c_script/c_querylist.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/c_querylist.h create mode 100644 Src/Wasabi/api/script/objects/c_script/c_rootobj.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/c_rootobj.h create mode 100644 Src/Wasabi/api/script/objects/c_script/c_slider.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/c_slider.h create mode 100644 Src/Wasabi/api/script/objects/c_script/c_tabsheet.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/c_tabsheet.h create mode 100644 Src/Wasabi/api/script/objects/c_script/c_text.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/c_text.h create mode 100644 Src/Wasabi/api/script/objects/c_script/c_togglebutton.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/c_togglebutton.h create mode 100644 Src/Wasabi/api/script/objects/c_script/c_treeitem.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/c_treeitem.h create mode 100644 Src/Wasabi/api/script/objects/c_script/gen.m create mode 100644 Src/Wasabi/api/script/objects/c_script/h_browser.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/h_browser.h create mode 100644 Src/Wasabi/api/script/objects/c_script/h_button.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/h_button.h create mode 100644 Src/Wasabi/api/script/objects/c_script/h_checkbox.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/h_checkbox.h create mode 100644 Src/Wasabi/api/script/objects/c_script/h_container.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/h_container.h create mode 100644 Src/Wasabi/api/script/objects/c_script/h_dropdownlist.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/h_dropdownlist.h create mode 100644 Src/Wasabi/api/script/objects/c_script/h_edit.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/h_edit.h create mode 100644 Src/Wasabi/api/script/objects/c_script/h_group.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/h_group.h create mode 100644 Src/Wasabi/api/script/objects/c_script/h_grouplist.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/h_grouplist.h create mode 100644 Src/Wasabi/api/script/objects/c_script/h_guilist.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/h_guilist.h create mode 100644 Src/Wasabi/api/script/objects/c_script/h_guiobject.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/h_guiobject.h create mode 100644 Src/Wasabi/api/script/objects/c_script/h_guitree.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/h_guitree.h create mode 100644 Src/Wasabi/api/script/objects/c_script/h_layout.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/h_layout.h create mode 100644 Src/Wasabi/api/script/objects/c_script/h_menubutton.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/h_menubutton.h create mode 100644 Src/Wasabi/api/script/objects/c_script/h_querylist.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/h_querylist.h create mode 100644 Src/Wasabi/api/script/objects/c_script/h_rootobj.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/h_rootobj.h create mode 100644 Src/Wasabi/api/script/objects/c_script/h_slider.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/h_slider.h create mode 100644 Src/Wasabi/api/script/objects/c_script/h_tabsheet.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/h_tabsheet.h create mode 100644 Src/Wasabi/api/script/objects/c_script/h_text.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/h_text.h create mode 100644 Src/Wasabi/api/script/objects/c_script/h_togglebutton.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/h_togglebutton.h create mode 100644 Src/Wasabi/api/script/objects/c_script/h_treeitem.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/h_treeitem.h create mode 100644 Src/Wasabi/api/script/objects/c_script/scripthook.cpp create mode 100644 Src/Wasabi/api/script/objects/c_script/scripthook.h create mode 100644 Src/Wasabi/api/script/objects/compoobj.cpp create mode 100644 Src/Wasabi/api/script/objects/compoobj.h create mode 100644 Src/Wasabi/api/script/objects/core/coreadminobj.cpp create mode 100644 Src/Wasabi/api/script/objects/core/coreadminobj.h create mode 100644 Src/Wasabi/api/script/objects/core/coreobj.cpp create mode 100644 Src/Wasabi/api/script/objects/core/coreobj.h create mode 100644 Src/Wasabi/api/script/objects/core/svc_scriptcore.cpp create mode 100644 Src/Wasabi/api/script/objects/core/svc_scriptcore.h create mode 100644 Src/Wasabi/api/script/objects/guiobj.cpp create mode 100644 Src/Wasabi/api/script/objects/guiobj.h create mode 100644 Src/Wasabi/api/script/objects/guiobject.h create mode 100644 Src/Wasabi/api/script/objects/guiobjectx.cpp create mode 100644 Src/Wasabi/api/script/objects/guiobjectx.h create mode 100644 Src/Wasabi/api/script/objects/rootobj.cpp create mode 100644 Src/Wasabi/api/script/objects/rootobj.h create mode 100644 Src/Wasabi/api/script/objects/rootobjcb.cpp create mode 100644 Src/Wasabi/api/script/objects/rootobjcb.h create mode 100644 Src/Wasabi/api/script/objects/rootobjcbi.cpp create mode 100644 Src/Wasabi/api/script/objects/rootobjcbi.h create mode 100644 Src/Wasabi/api/script/objects/rootobjcbx.cpp create mode 100644 Src/Wasabi/api/script/objects/rootobjcbx.h create mode 100644 Src/Wasabi/api/script/objects/rootobjcontroller.cpp create mode 100644 Src/Wasabi/api/script/objects/rootobjcontroller.h create mode 100644 Src/Wasabi/api/script/objects/rootobject.cpp create mode 100644 Src/Wasabi/api/script/objects/rootobject.h create mode 100644 Src/Wasabi/api/script/objects/rootobjecti.cpp create mode 100644 Src/Wasabi/api/script/objects/rootobjecti.h create mode 100644 Src/Wasabi/api/script/objects/rootobjectx.cpp create mode 100644 Src/Wasabi/api/script/objects/rootobjectx.h create mode 100644 Src/Wasabi/api/script/objects/sapplication.cpp create mode 100644 Src/Wasabi/api/script/objects/sapplication.h create mode 100644 Src/Wasabi/api/script/objects/sbitlist.cpp create mode 100644 Src/Wasabi/api/script/objects/sbitlist.h create mode 100644 Src/Wasabi/api/script/objects/scolor.cpp create mode 100644 Src/Wasabi/api/script/objects/scolor.h create mode 100644 Src/Wasabi/api/script/objects/scolormgr.cpp create mode 100644 Src/Wasabi/api/script/objects/scolormgr.h create mode 100644 Src/Wasabi/api/script/objects/sfile.cpp create mode 100644 Src/Wasabi/api/script/objects/sfile.h create mode 100644 Src/Wasabi/api/script/objects/sgammagroup.cpp create mode 100644 Src/Wasabi/api/script/objects/sgammagroup.h create mode 100644 Src/Wasabi/api/script/objects/sgammaset.cpp create mode 100644 Src/Wasabi/api/script/objects/sgammaset.h create mode 100644 Src/Wasabi/api/script/objects/slist.cpp create mode 100644 Src/Wasabi/api/script/objects/slist.h create mode 100644 Src/Wasabi/api/script/objects/smap.cpp create mode 100644 Src/Wasabi/api/script/objects/smap.h create mode 100644 Src/Wasabi/api/script/objects/spopup.cpp create mode 100644 Src/Wasabi/api/script/objects/spopup.h create mode 100644 Src/Wasabi/api/script/objects/sprivate.cpp create mode 100644 Src/Wasabi/api/script/objects/sprivate.h create mode 100644 Src/Wasabi/api/script/objects/sregion.cpp create mode 100644 Src/Wasabi/api/script/objects/sregion.h create mode 100644 Src/Wasabi/api/script/objects/svcwnd.cpp create mode 100644 Src/Wasabi/api/script/objects/svcwnd.h create mode 100644 Src/Wasabi/api/script/objects/sxmldoc.cpp create mode 100644 Src/Wasabi/api/script/objects/sxmldoc.h create mode 100644 Src/Wasabi/api/script/objects/systemobj.cpp create mode 100644 Src/Wasabi/api/script/objects/systemobj.h create mode 100644 Src/Wasabi/api/script/objects/timer.cpp create mode 100644 Src/Wasabi/api/script/objects/timer.h create mode 100644 Src/Wasabi/api/script/objects/wacobj.cpp create mode 100644 Src/Wasabi/api/script/objects/wacobj.h create mode 100644 Src/Wasabi/api/script/objecttable.cpp create mode 100644 Src/Wasabi/api/script/objecttable.h create mode 100644 Src/Wasabi/api/script/opcodes.h create mode 100644 Src/Wasabi/api/script/script.cpp create mode 100644 Src/Wasabi/api/script/script.h create mode 100644 Src/Wasabi/api/script/scriptguid.h create mode 100644 Src/Wasabi/api/script/scriptmgr.cpp create mode 100644 Src/Wasabi/api/script/scriptmgr.h create mode 100644 Src/Wasabi/api/script/scriptobj.cpp create mode 100644 Src/Wasabi/api/script/scriptobj.h create mode 100644 Src/Wasabi/api/script/scriptobji.cpp create mode 100644 Src/Wasabi/api/script/scriptobji.h create mode 100644 Src/Wasabi/api/script/scriptobjx.cpp create mode 100644 Src/Wasabi/api/script/scriptobjx.h create mode 100644 Src/Wasabi/api/script/scriptvar.h create mode 100644 Src/Wasabi/api/script/vcpu.cpp create mode 100644 Src/Wasabi/api/script/vcpu.h create mode 100644 Src/Wasabi/api/script/vcputypes.h create mode 100644 Src/Wasabi/api/service/api_service.cpp create mode 100644 Src/Wasabi/api/service/api_service.h create mode 100644 Src/Wasabi/api/service/api_servicei.cpp create mode 100644 Src/Wasabi/api/service/api_servicei.h create mode 100644 Src/Wasabi/api/service/api_servicex.cpp create mode 100644 Src/Wasabi/api/service/api_servicex.h create mode 100644 Src/Wasabi/api/service/service.h create mode 100644 Src/Wasabi/api/service/servicei.cpp create mode 100644 Src/Wasabi/api/service/servicei.h create mode 100644 Src/Wasabi/api/service/services.h create mode 100644 Src/Wasabi/api/service/svc_enum.cpp create mode 100644 Src/Wasabi/api/service/svc_enum.h create mode 100644 Src/Wasabi/api/service/svccache.cpp create mode 100644 Src/Wasabi/api/service/svccache.h create mode 100644 Src/Wasabi/api/service/svcenum.cpp create mode 100644 Src/Wasabi/api/service/svcenum.h create mode 100644 Src/Wasabi/api/service/svcenumbyguid.cpp create mode 100644 Src/Wasabi/api/service/svcenumbyguid.h create mode 100644 Src/Wasabi/api/service/svcenumt.cpp create mode 100644 Src/Wasabi/api/service/svcenumt.h create mode 100644 Src/Wasabi/api/service/svcmgr.cpp create mode 100644 Src/Wasabi/api/service/svcmgr.h create mode 100644 Src/Wasabi/api/service/svcs/svc_accessibility.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_accessibility.h create mode 100644 Src/Wasabi/api/service/svcs/svc_accroleserver.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_accroleserver.h create mode 100644 Src/Wasabi/api/service/svcs/svc_action.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_action.h create mode 100644 Src/Wasabi/api/service/svcs/svc_burner.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_burner.h create mode 100644 Src/Wasabi/api/service/svcs/svc_collection.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_collection.h create mode 100644 Src/Wasabi/api/service/svcs/svc_console.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_console.h create mode 100644 Src/Wasabi/api/service/svcs/svc_contextCmd.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_contextCmd.h create mode 100644 Src/Wasabi/api/service/svcs/svc_coreadmin.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_coreadmin.h create mode 100644 Src/Wasabi/api/service/svcs/svc_db.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_db.h create mode 100644 Src/Wasabi/api/service/svcs/svc_debuggerui.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_debuggerui.h create mode 100644 Src/Wasabi/api/service/svcs/svc_device.h create mode 100644 Src/Wasabi/api/service/svcs/svc_droptarget.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_droptarget.h create mode 100644 Src/Wasabi/api/service/svcs/svc_eval.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_eval.h create mode 100644 Src/Wasabi/api/service/svcs/svc_export.h create mode 100644 Src/Wasabi/api/service/svcs/svc_fileread.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_fileread.h create mode 100644 Src/Wasabi/api/service/svcs/svc_filesel.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_filesel.h create mode 100644 Src/Wasabi/api/service/svcs/svc_font.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_font.h create mode 100644 Src/Wasabi/api/service/svcs/svc_fontmaker.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_fontmaker.h create mode 100644 Src/Wasabi/api/service/svcs/svc_fontrender.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_fontrender.h create mode 100644 Src/Wasabi/api/service/svcs/svc_imggen.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_imggen.h create mode 100644 Src/Wasabi/api/service/svcs/svc_imgload.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_imgload.h create mode 100644 Src/Wasabi/api/service/svcs/svc_imgwrite.h create mode 100644 Src/Wasabi/api/service/svcs/svc_itemmgr.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_itemmgr.h create mode 100644 Src/Wasabi/api/service/svcs/svc_loadlib.h create mode 100644 Src/Wasabi/api/service/svcs/svc_mediaconverter.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_mediaconverter.h create mode 100644 Src/Wasabi/api/service/svcs/svc_mediacore.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_mediacore.h create mode 100644 Src/Wasabi/api/service/svcs/svc_metadata.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_metadata.h create mode 100644 Src/Wasabi/api/service/svcs/svc_minibrowser.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_minibrowser.h create mode 100644 Src/Wasabi/api/service/svcs/svc_objectdir.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_objectdir.h create mode 100644 Src/Wasabi/api/service/svcs/svc_player.h create mode 100644 Src/Wasabi/api/service/svcs/svc_playlist.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_playlist.h create mode 100644 Src/Wasabi/api/service/svcs/svc_redir.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_redir.h create mode 100644 Src/Wasabi/api/service/svcs/svc_scriptobj.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_scriptobj.h create mode 100644 Src/Wasabi/api/service/svcs/svc_scriptobji.h create mode 100644 Src/Wasabi/api/service/svcs/svc_skinfilter.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_skinfilter.h create mode 100644 Src/Wasabi/api/service/svcs/svc_storagevolenum.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_storagevolenum.h create mode 100644 Src/Wasabi/api/service/svcs/svc_stringconverter.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_stringconverter.h create mode 100644 Src/Wasabi/api/service/svcs/svc_stringtypes.h create mode 100644 Src/Wasabi/api/service/svcs/svc_textfeed.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_textfeed.h create mode 100644 Src/Wasabi/api/service/svcs/svc_tooltips.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_tooltips.h create mode 100644 Src/Wasabi/api/service/svcs/svc_wndcreate.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_wndcreate.h create mode 100644 Src/Wasabi/api/service/svcs/svc_xmlprov.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_xmlprov.h create mode 100644 Src/Wasabi/api/service/svcs/svc_xuiobject.cpp create mode 100644 Src/Wasabi/api/service/svcs/svc_xuiobject.h create mode 100644 Src/Wasabi/api/service/waservicefactory.cpp create mode 100644 Src/Wasabi/api/service/waservicefactory.h create mode 100644 Src/Wasabi/api/service/waservicefactorybase.cpp create mode 100644 Src/Wasabi/api/service/waservicefactorybase.h create mode 100644 Src/Wasabi/api/service/waservicefactoryi.cpp create mode 100644 Src/Wasabi/api/service/waservicefactoryi.h create mode 100644 Src/Wasabi/api/service/waservicefactoryt.cpp create mode 100644 Src/Wasabi/api/service/waservicefactoryt.h create mode 100644 Src/Wasabi/api/service/waservicefactorytsingle.cpp create mode 100644 Src/Wasabi/api/service/waservicefactorytsingle.h create mode 100644 Src/Wasabi/api/service/waservicefactoryx.cpp create mode 100644 Src/Wasabi/api/service/waservicefactoryx.h create mode 100644 Src/Wasabi/api/skin/SkinElementAlias.cpp create mode 100644 Src/Wasabi/api/skin/SkinElementAlias.h create mode 100644 Src/Wasabi/api/skin/SkinVersion.cpp create mode 100644 Src/Wasabi/api/skin/SkinVersion.h create mode 100644 Src/Wasabi/api/skin/api_colorthemes.cpp create mode 100644 Src/Wasabi/api/skin/api_colorthemes.h create mode 100644 Src/Wasabi/api/skin/api_palette.cpp create mode 100644 Src/Wasabi/api/skin/api_palette.h create mode 100644 Src/Wasabi/api/skin/api_skin.cpp create mode 100644 Src/Wasabi/api/skin/api_skin.h create mode 100644 Src/Wasabi/api/skin/colorthemes.h create mode 100644 Src/Wasabi/api/skin/cursormgr.cpp create mode 100644 Src/Wasabi/api/skin/cursormgr.h create mode 100644 Src/Wasabi/api/skin/feeds/TextFeedEnum.h create mode 100644 Src/Wasabi/api/skin/feeds/api_textfeed.cpp create mode 100644 Src/Wasabi/api/skin/feeds/api_textfeed.h create mode 100644 Src/Wasabi/api/skin/feeds/ezfeed.h create mode 100644 Src/Wasabi/api/skin/feeds/feedwatch.cpp create mode 100644 Src/Wasabi/api/skin/feeds/feedwatch.h create mode 100644 Src/Wasabi/api/skin/feeds/feedwatcherso.cpp create mode 100644 Src/Wasabi/api/skin/feeds/feedwatcherso.h create mode 100644 Src/Wasabi/api/skin/feeds/textfeed.cpp create mode 100644 Src/Wasabi/api/skin/feeds/textfeed.h create mode 100644 Src/Wasabi/api/skin/feeds/textfeedcb.cpp create mode 100644 Src/Wasabi/api/skin/feeds/textfeedcb.h create mode 100644 Src/Wasabi/api/skin/gammamgr.cpp create mode 100644 Src/Wasabi/api/skin/gammamgr.h create mode 100644 Src/Wasabi/api/skin/group.h create mode 100644 Src/Wasabi/api/skin/groupmgr.cpp create mode 100644 Src/Wasabi/api/skin/groupmgr.h create mode 100644 Src/Wasabi/api/skin/groupwndcreate.cpp create mode 100644 Src/Wasabi/api/skin/groupwndcreate.h create mode 100644 Src/Wasabi/api/skin/guitree.cpp create mode 100644 Src/Wasabi/api/skin/guitree.h create mode 100644 Src/Wasabi/api/skin/nakedobject.cpp create mode 100644 Src/Wasabi/api/skin/nakedobject.h create mode 100644 Src/Wasabi/api/skin/objectactuator.cpp create mode 100644 Src/Wasabi/api/skin/objectactuator.h create mode 100644 Src/Wasabi/api/skin/regioncache.cpp create mode 100644 Src/Wasabi/api/skin/regioncache.h create mode 100644 Src/Wasabi/api/skin/skin.cpp create mode 100644 Src/Wasabi/api/skin/skin.h create mode 100644 Src/Wasabi/api/skin/skinapi.cpp create mode 100644 Src/Wasabi/api/skin/skinapi.h create mode 100644 Src/Wasabi/api/skin/skinbmps.h create mode 100644 Src/Wasabi/api/skin/skinelem.cpp create mode 100644 Src/Wasabi/api/skin/skinelem.h create mode 100644 Src/Wasabi/api/skin/skinfilter.cpp create mode 100644 Src/Wasabi/api/skin/skinfilter.h create mode 100644 Src/Wasabi/api/skin/skinfont.cpp create mode 100644 Src/Wasabi/api/skin/skinfont.h create mode 100644 Src/Wasabi/api/skin/skinitem.cpp create mode 100644 Src/Wasabi/api/skin/skinitem.h create mode 100644 Src/Wasabi/api/skin/skinparse.cpp create mode 100644 Src/Wasabi/api/skin/skinparse.h create mode 100644 Src/Wasabi/api/skin/widgets.cpp create mode 100644 Src/Wasabi/api/skin/widgets.h create mode 100644 Src/Wasabi/api/skin/widgets/animlayer.cpp create mode 100644 Src/Wasabi/api/skin/widgets/animlayer.h create mode 100644 Src/Wasabi/api/skin/widgets/button.cpp create mode 100644 Src/Wasabi/api/skin/widgets/button.h create mode 100644 Src/Wasabi/api/skin/widgets/checkbox.cpp create mode 100644 Src/Wasabi/api/skin/widgets/checkbox.h create mode 100644 Src/Wasabi/api/skin/widgets/combobox.cpp create mode 100644 Src/Wasabi/api/skin/widgets/combobox.h create mode 100644 Src/Wasabi/api/skin/widgets/compbuck2.cpp create mode 100644 Src/Wasabi/api/skin/widgets/compbuck2.h create mode 100644 Src/Wasabi/api/skin/widgets/customobject.cpp create mode 100644 Src/Wasabi/api/skin/widgets/customobject.h create mode 100644 Src/Wasabi/api/skin/widgets/db/autofilterlist.cpp create mode 100644 Src/Wasabi/api/skin/widgets/db/autofilterlist.h create mode 100644 Src/Wasabi/api/skin/widgets/db/autoquerylist.cpp create mode 100644 Src/Wasabi/api/skin/widgets/db/autoquerylist.h create mode 100644 Src/Wasabi/api/skin/widgets/db/queryline.cpp create mode 100644 Src/Wasabi/api/skin/widgets/db/queryline.h create mode 100644 Src/Wasabi/api/skin/widgets/db/xuiquerydrag.cpp create mode 100644 Src/Wasabi/api/skin/widgets/db/xuiquerydrag.h create mode 100644 Src/Wasabi/api/skin/widgets/db/xuiqueryline.cpp create mode 100644 Src/Wasabi/api/skin/widgets/db/xuiqueryline.h create mode 100644 Src/Wasabi/api/skin/widgets/db/xuiquerylist.cpp create mode 100644 Src/Wasabi/api/skin/widgets/db/xuiquerylist.h create mode 100644 Src/Wasabi/api/skin/widgets/dropdownlist.cpp create mode 100644 Src/Wasabi/api/skin/widgets/dropdownlist.h create mode 100644 Src/Wasabi/api/skin/widgets/edit.cpp create mode 100644 Src/Wasabi/api/skin/widgets/edit.h create mode 100644 Src/Wasabi/api/skin/widgets/fx.h create mode 100644 Src/Wasabi/api/skin/widgets/fx_dmove.cpp create mode 100644 Src/Wasabi/api/skin/widgets/fx_dmove.h create mode 100644 Src/Wasabi/api/skin/widgets/group.cpp create mode 100644 Src/Wasabi/api/skin/widgets/group.h create mode 100644 Src/Wasabi/api/skin/widgets/groupclickwnd.cpp create mode 100644 Src/Wasabi/api/skin/widgets/groupclickwnd.h create mode 100644 Src/Wasabi/api/skin/widgets/grouplist.cpp create mode 100644 Src/Wasabi/api/skin/widgets/grouplist.h create mode 100644 Src/Wasabi/api/skin/widgets/grouptgbutton.cpp create mode 100644 Src/Wasabi/api/skin/widgets/grouptgbutton.h create mode 100644 Src/Wasabi/api/skin/widgets/grouptips.cpp create mode 100644 Src/Wasabi/api/skin/widgets/grouptips.h create mode 100644 Src/Wasabi/api/skin/widgets/guiradiogroup.cpp create mode 100644 Src/Wasabi/api/skin/widgets/guiradiogroup.h create mode 100644 Src/Wasabi/api/skin/widgets/historyeditbox.cpp create mode 100644 Src/Wasabi/api/skin/widgets/historyeditbox.h create mode 100644 Src/Wasabi/api/skin/widgets/layer.cpp create mode 100644 Src/Wasabi/api/skin/widgets/layer.h create mode 100644 Src/Wasabi/api/skin/widgets/mb/iebrowser.cpp create mode 100644 Src/Wasabi/api/skin/widgets/mb/iebrowser.h create mode 100644 Src/Wasabi/api/skin/widgets/mb/mainminibrowser.cpp create mode 100644 Src/Wasabi/api/skin/widgets/mb/mainminibrowser.h create mode 100644 Src/Wasabi/api/skin/widgets/mb/mbsvc.cpp create mode 100644 Src/Wasabi/api/skin/widgets/mb/mbsvc.h create mode 100644 Src/Wasabi/api/skin/widgets/mb/mbsvcwac.cpp create mode 100644 Src/Wasabi/api/skin/widgets/mb/mbsvcwac.h create mode 100644 Src/Wasabi/api/skin/widgets/mb/minibrowser.cpp create mode 100644 Src/Wasabi/api/skin/widgets/mb/minibrowser.h create mode 100644 Src/Wasabi/api/skin/widgets/mb/minibrowserwnd.cpp create mode 100644 Src/Wasabi/api/skin/widgets/mb/minibrowserwnd.h create mode 100644 Src/Wasabi/api/skin/widgets/mb/scriptbrowser.cpp create mode 100644 Src/Wasabi/api/skin/widgets/mb/scriptbrowser.h create mode 100644 Src/Wasabi/api/skin/widgets/mb/sharedminibrowser.cpp create mode 100644 Src/Wasabi/api/skin/widgets/mb/sharedminibrowser.h create mode 100644 Src/Wasabi/api/skin/widgets/mb/xuibrowser.cpp create mode 100644 Src/Wasabi/api/skin/widgets/mb/xuibrowser.h create mode 100644 Src/Wasabi/api/skin/widgets/mouseredir.cpp create mode 100644 Src/Wasabi/api/skin/widgets/mouseredir.h create mode 100644 Src/Wasabi/api/skin/widgets/objdirwnd.cpp create mode 100644 Src/Wasabi/api/skin/widgets/objdirwnd.h create mode 100644 Src/Wasabi/api/skin/widgets/pathpicker.cpp create mode 100644 Src/Wasabi/api/skin/widgets/pathpicker.h create mode 100644 Src/Wasabi/api/skin/widgets/pslider.cpp create mode 100644 Src/Wasabi/api/skin/widgets/pslider.h create mode 100644 Src/Wasabi/api/skin/widgets/sa.cpp create mode 100644 Src/Wasabi/api/skin/widgets/sa.h create mode 100644 Src/Wasabi/api/skin/widgets/seeker.h create mode 100644 Src/Wasabi/api/skin/widgets/seqband.cpp create mode 100644 Src/Wasabi/api/skin/widgets/seqband.h create mode 100644 Src/Wasabi/api/skin/widgets/seqpreamp.cpp create mode 100644 Src/Wasabi/api/skin/widgets/seqpreamp.h create mode 100644 Src/Wasabi/api/skin/widgets/seqvis.cpp create mode 100644 Src/Wasabi/api/skin/widgets/seqvis.h create mode 100644 Src/Wasabi/api/skin/widgets/spanbar.cpp create mode 100644 Src/Wasabi/api/skin/widgets/spanbar.h create mode 100644 Src/Wasabi/api/skin/widgets/sseeker.cpp create mode 100644 Src/Wasabi/api/skin/widgets/sseeker.h create mode 100644 Src/Wasabi/api/skin/widgets/sstatus.cpp create mode 100644 Src/Wasabi/api/skin/widgets/sstatus.h create mode 100644 Src/Wasabi/api/skin/widgets/stats/statswnd.cpp create mode 100644 Src/Wasabi/api/skin/widgets/stats/statswnd.h create mode 100644 Src/Wasabi/api/skin/widgets/stats/xuistats.cpp create mode 100644 Src/Wasabi/api/skin/widgets/stats/xuistats.h create mode 100644 Src/Wasabi/api/skin/widgets/svolbar.cpp create mode 100644 Src/Wasabi/api/skin/widgets/svolbar.h create mode 100644 Src/Wasabi/api/skin/widgets/text.cpp create mode 100644 Src/Wasabi/api/skin/widgets/text.h create mode 100644 Src/Wasabi/api/skin/widgets/textbase.cpp create mode 100644 Src/Wasabi/api/skin/widgets/textbase.h create mode 100644 Src/Wasabi/api/skin/widgets/tgbutton.cpp create mode 100644 Src/Wasabi/api/skin/widgets/tgbutton.h create mode 100644 Src/Wasabi/api/skin/widgets/title.cpp create mode 100644 Src/Wasabi/api/skin/widgets/title.h create mode 100644 Src/Wasabi/api/skin/widgets/titlebox.cpp create mode 100644 Src/Wasabi/api/skin/widgets/titlebox.h create mode 100644 Src/Wasabi/api/skin/widgets/wa2/xuiwa2slider.cpp create mode 100644 Src/Wasabi/api/skin/widgets/wa2/xuiwa2slider.h create mode 100644 Src/Wasabi/api/skin/widgets/xuiaddparams.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuiaddparams.h create mode 100644 Src/Wasabi/api/skin/widgets/xuibookmarklist.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuibookmarklist.h create mode 100644 Src/Wasabi/api/skin/widgets/xuicheckbox.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuicheckbox.h create mode 100644 Src/Wasabi/api/skin/widgets/xuicombobox.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuicombobox.h create mode 100644 Src/Wasabi/api/skin/widgets/xuicustomobject.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuicustomobject.h create mode 100644 Src/Wasabi/api/skin/widgets/xuidownloadslist.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuidownloadslist.h create mode 100644 Src/Wasabi/api/skin/widgets/xuidropdownlist.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuidropdownlist.h create mode 100644 Src/Wasabi/api/skin/widgets/xuieditbox.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuieditbox.h create mode 100644 Src/Wasabi/api/skin/widgets/xuiframe.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuiframe.h create mode 100644 Src/Wasabi/api/skin/widgets/xuigradientwnd.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuigradientwnd.h create mode 100644 Src/Wasabi/api/skin/widgets/xuigrid.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuigrid.h create mode 100644 Src/Wasabi/api/skin/widgets/xuigroupxfade.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuigroupxfade.h create mode 100644 Src/Wasabi/api/skin/widgets/xuihideobject.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuihideobject.h create mode 100644 Src/Wasabi/api/skin/widgets/xuihistoryedit.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuihistoryedit.h create mode 100644 Src/Wasabi/api/skin/widgets/xuilist.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuilist.h create mode 100644 Src/Wasabi/api/skin/widgets/xuimenu.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuimenu.h create mode 100644 Src/Wasabi/api/skin/widgets/xuimenuso.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuimenuso.h create mode 100644 Src/Wasabi/api/skin/widgets/xuiobjdirwnd.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuiobjdirwnd.h create mode 100644 Src/Wasabi/api/skin/widgets/xuioswndhost.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuioswndhost.h create mode 100644 Src/Wasabi/api/skin/widgets/xuipathpicker.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuipathpicker.h create mode 100644 Src/Wasabi/api/skin/widgets/xuiprogressgrid.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuiprogressgrid.h create mode 100644 Src/Wasabi/api/skin/widgets/xuiradiogroup.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuiradiogroup.h create mode 100644 Src/Wasabi/api/skin/widgets/xuirect.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuirect.h create mode 100644 Src/Wasabi/api/skin/widgets/xuisendparams.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuisendparams.h create mode 100644 Src/Wasabi/api/skin/widgets/xuistatus.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuistatus.h create mode 100644 Src/Wasabi/api/skin/widgets/xuitabsheet.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuitabsheet.h create mode 100644 Src/Wasabi/api/skin/widgets/xuithemeslist.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuithemeslist.h create mode 100644 Src/Wasabi/api/skin/widgets/xuititlebox.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuititlebox.h create mode 100644 Src/Wasabi/api/skin/widgets/xuitree.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuitree.h create mode 100644 Src/Wasabi/api/skin/widgets/xuiwndholder.cpp create mode 100644 Src/Wasabi/api/skin/widgets/xuiwndholder.h create mode 100644 Src/Wasabi/api/skin/xmlobject.cpp create mode 100644 Src/Wasabi/api/skin/xmlobject.h create mode 100644 Src/Wasabi/api/syscb/api_syscb.cpp create mode 100644 Src/Wasabi/api/syscb/api_syscb.h create mode 100644 Src/Wasabi/api/syscb/api_syscbi.cpp create mode 100644 Src/Wasabi/api/syscb/api_syscbi.h create mode 100644 Src/Wasabi/api/syscb/api_syscbx.cpp create mode 100644 Src/Wasabi/api/syscb/api_syscbx.h create mode 100644 Src/Wasabi/api/syscb/callbacks/authcb.h create mode 100644 Src/Wasabi/api/syscb/callbacks/browsercb.cpp create mode 100644 Src/Wasabi/api/syscb/callbacks/browsercb.h create mode 100644 Src/Wasabi/api/syscb/callbacks/browsercbi.h create mode 100644 Src/Wasabi/api/syscb/callbacks/consolecb.cpp create mode 100644 Src/Wasabi/api/syscb/callbacks/consolecb.h create mode 100644 Src/Wasabi/api/syscb/callbacks/corecb.cpp create mode 100644 Src/Wasabi/api/syscb/callbacks/corecb.h create mode 100644 Src/Wasabi/api/syscb/callbacks/corecbi.h create mode 100644 Src/Wasabi/api/syscb/callbacks/gccb.h create mode 100644 Src/Wasabi/api/syscb/callbacks/metacb.h create mode 100644 Src/Wasabi/api/syscb/callbacks/playlistcb.cpp create mode 100644 Src/Wasabi/api/syscb/callbacks/playlistcb.h create mode 100644 Src/Wasabi/api/syscb/callbacks/runlevelcb.h create mode 100644 Src/Wasabi/api/syscb/callbacks/skincb.cpp create mode 100644 Src/Wasabi/api/syscb/callbacks/skincb.h create mode 100644 Src/Wasabi/api/syscb/callbacks/svccb.h create mode 100644 Src/Wasabi/api/syscb/callbacks/svccbi.h create mode 100644 Src/Wasabi/api/syscb/callbacks/syscb.cpp create mode 100644 Src/Wasabi/api/syscb/callbacks/syscb.h create mode 100644 Src/Wasabi/api/syscb/callbacks/syscbi.cpp create mode 100644 Src/Wasabi/api/syscb/callbacks/syscbi.h create mode 100644 Src/Wasabi/api/syscb/callbacks/syscbx.cpp create mode 100644 Src/Wasabi/api/syscb/callbacks/syscbx.h create mode 100644 Src/Wasabi/api/syscb/callbacks/sysmemcb.h create mode 100644 Src/Wasabi/api/syscb/callbacks/wndcb.cpp create mode 100644 Src/Wasabi/api/syscb/callbacks/wndcb.h create mode 100644 Src/Wasabi/api/syscb/cbmgr.cpp create mode 100644 Src/Wasabi/api/syscb/cbmgr.h create mode 100644 Src/Wasabi/api/timer/api_timer.h create mode 100644 Src/Wasabi/api/timer/osx_timer.cpp create mode 100644 Src/Wasabi/api/timer/osx_timer.h create mode 100644 Src/Wasabi/api/timer/timerclient.cpp create mode 100644 Src/Wasabi/api/timer/timerclient.h create mode 100644 Src/Wasabi/api/timer/timeslicer.cpp create mode 100644 Src/Wasabi/api/timer/timeslicer.h create mode 100644 Src/Wasabi/api/util/savefile.cpp create mode 100644 Src/Wasabi/api/util/savefile.h create mode 100644 Src/Wasabi/api/util/selectfile.cpp create mode 100644 Src/Wasabi/api/util/selectfile.h create mode 100644 Src/Wasabi/api/util/systray.cpp create mode 100644 Src/Wasabi/api/util/systray.h create mode 100644 Src/Wasabi/api/util/varmgr.cpp create mode 100644 Src/Wasabi/api/util/varmgr.h create mode 100644 Src/Wasabi/api/wac/compdb.h create mode 100644 Src/Wasabi/api/wac/compon.cpp create mode 100644 Src/Wasabi/api/wac/compon.h create mode 100644 Src/Wasabi/api/wac/main.h create mode 100644 Src/Wasabi/api/wac/papi.h create mode 100644 Src/Wasabi/api/wac/wac.h create mode 100644 Src/Wasabi/api/wac/waclient.cpp create mode 100644 Src/Wasabi/api/wnd/PaintCanvas.h create mode 100644 Src/Wasabi/api/wnd/accessible.cpp create mode 100644 Src/Wasabi/api/wnd/accessible.h create mode 100644 Src/Wasabi/api/wnd/api_canvas.cpp create mode 100644 Src/Wasabi/api/wnd/api_canvas.h create mode 100644 Src/Wasabi/api/wnd/api_region.cpp create mode 100644 Src/Wasabi/api/wnd/api_region.h create mode 100644 Src/Wasabi/api/wnd/api_window.cpp create mode 100644 Src/Wasabi/api/wnd/api_window.h create mode 100644 Src/Wasabi/api/wnd/api_wnd.cpp create mode 100644 Src/Wasabi/api/wnd/api_wnd.h create mode 100644 Src/Wasabi/api/wnd/basewnd.cpp create mode 100644 Src/Wasabi/api/wnd/basewnd.h create mode 100644 Src/Wasabi/api/wnd/bitmap.cpp create mode 100644 Src/Wasabi/api/wnd/bitmap.h create mode 100644 Src/Wasabi/api/wnd/blending.cpp create mode 100644 Src/Wasabi/api/wnd/blending.h create mode 100644 Src/Wasabi/api/wnd/bltcanvas.h create mode 100644 Src/Wasabi/api/wnd/bucketitem.h create mode 100644 Src/Wasabi/api/wnd/canvas.cpp create mode 100644 Src/Wasabi/api/wnd/canvas.h create mode 100644 Src/Wasabi/api/wnd/contextmenu.cpp create mode 100644 Src/Wasabi/api/wnd/contextmenu.h create mode 100644 Src/Wasabi/api/wnd/cursor.cpp create mode 100644 Src/Wasabi/api/wnd/cursor.h create mode 100644 Src/Wasabi/api/wnd/cwndtrack.h create mode 100644 Src/Wasabi/api/wnd/deactivatemgr.cpp create mode 100644 Src/Wasabi/api/wnd/deactivatemgr.h create mode 100644 Src/Wasabi/api/wnd/di.cpp create mode 100644 Src/Wasabi/api/wnd/drag.h create mode 100644 Src/Wasabi/api/wnd/dragitem.h create mode 100644 Src/Wasabi/api/wnd/dragitemi.cpp create mode 100644 Src/Wasabi/api/wnd/dragitemi.h create mode 100644 Src/Wasabi/api/wnd/fakedrag.h create mode 100644 Src/Wasabi/api/wnd/findobjectcb.cpp create mode 100644 Src/Wasabi/api/wnd/findobjectcb.h create mode 100644 Src/Wasabi/api/wnd/fontdef.h create mode 100644 Src/Wasabi/api/wnd/ifc_bitmap.h create mode 100644 Src/Wasabi/api/wnd/keyboard.cpp create mode 100644 Src/Wasabi/api/wnd/keyboard.h create mode 100644 Src/Wasabi/api/wnd/minibrowser.cpp create mode 100644 Src/Wasabi/api/wnd/minibrowser.h create mode 100644 Src/Wasabi/api/wnd/notifmsg.h create mode 100644 Src/Wasabi/api/wnd/paintcb.cpp create mode 100644 Src/Wasabi/api/wnd/paintcb.h create mode 100644 Src/Wasabi/api/wnd/paintset.cpp create mode 100644 Src/Wasabi/api/wnd/paintset.h create mode 100644 Src/Wasabi/api/wnd/paintsets.h create mode 100644 Src/Wasabi/api/wnd/platform/osx/PaintCanvas.cpp create mode 100644 Src/Wasabi/api/wnd/platform/osx/PaintCanvas.h create mode 100644 Src/Wasabi/api/wnd/platform/osx/bltcanvas.h create mode 100644 Src/Wasabi/api/wnd/platform/osx/canvas.h create mode 100644 Src/Wasabi/api/wnd/platform/osx/osx_bitmap_cgimage.cpp create mode 100644 Src/Wasabi/api/wnd/platform/osx/osx_bitmap_cgimage.h create mode 100644 Src/Wasabi/api/wnd/platform/osx/osx_canvas_layer.cpp create mode 100644 Src/Wasabi/api/wnd/platform/osx/osx_canvas_quartz.cpp create mode 100644 Src/Wasabi/api/wnd/platform/osx/osx_region_hishape.cpp create mode 100644 Src/Wasabi/api/wnd/platform/osx/region.h create mode 100644 Src/Wasabi/api/wnd/platform/win32/bitmap.h create mode 100644 Src/Wasabi/api/wnd/platform/win32/canvas.h create mode 100644 Src/Wasabi/api/wnd/platform/win32/region.h create mode 100644 Src/Wasabi/api/wnd/popexitcb.cpp create mode 100644 Src/Wasabi/api/wnd/popexitcb.h create mode 100644 Src/Wasabi/api/wnd/popexitchecker.cpp create mode 100644 Src/Wasabi/api/wnd/popexitchecker.h create mode 100644 Src/Wasabi/api/wnd/popup.cpp create mode 100644 Src/Wasabi/api/wnd/popup.h create mode 100644 Src/Wasabi/api/wnd/region.cpp create mode 100644 Src/Wasabi/api/wnd/region.h create mode 100644 Src/Wasabi/api/wnd/resizable.h create mode 100644 Src/Wasabi/api/wnd/rootwnd.cpp create mode 100644 Src/Wasabi/api/wnd/rootwnd.h create mode 100644 Src/Wasabi/api/wnd/textalign.h create mode 100644 Src/Wasabi/api/wnd/usermsg.h create mode 100644 Src/Wasabi/api/wnd/virtualwnd.cpp create mode 100644 Src/Wasabi/api/wnd/virtualwnd.h create mode 100644 Src/Wasabi/api/wnd/wndapi.cpp create mode 100644 Src/Wasabi/api/wnd/wndapi.h create mode 100644 Src/Wasabi/api/wnd/wndclass/SelItemList.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/SelItemList.h create mode 100644 Src/Wasabi/api/wnd/wndclass/abstractwndhold.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/abstractwndhold.h create mode 100644 Src/Wasabi/api/wnd/wndclass/appbarwnd.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/appbarwnd.h create mode 100644 Src/Wasabi/api/wnd/wndclass/backbufferwnd.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/backbufferwnd.h create mode 100644 Src/Wasabi/api/wnd/wndclass/blankwnd.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/blankwnd.h create mode 100644 Src/Wasabi/api/wnd/wndclass/bufferpaintwnd.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/bufferpaintwnd.h create mode 100644 Src/Wasabi/api/wnd/wndclass/buttbar.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/buttbar.h create mode 100644 Src/Wasabi/api/wnd/wndclass/buttwnd.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/buttwnd.h create mode 100644 Src/Wasabi/api/wnd/wndclass/clickwnd.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/clickwnd.h create mode 100644 Src/Wasabi/api/wnd/wndclass/ddrawwnd.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/ddrawwnd.h create mode 100644 Src/Wasabi/api/wnd/wndclass/editwnd.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/editwnd.h create mode 100644 Src/Wasabi/api/wnd/wndclass/editwndstring.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/editwndstring.h create mode 100644 Src/Wasabi/api/wnd/wndclass/embeddedxui.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/embeddedxui.h create mode 100644 Src/Wasabi/api/wnd/wndclass/foreignwnd.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/foreignwnd.h create mode 100644 Src/Wasabi/api/wnd/wndclass/framewnd.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/framewnd.h create mode 100644 Src/Wasabi/api/wnd/wndclass/gradientwnd.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/gradientwnd.h create mode 100644 Src/Wasabi/api/wnd/wndclass/guiobjwnd.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/guiobjwnd.h create mode 100644 Src/Wasabi/api/wnd/wndclass/itemlistwnd.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/itemlistwnd.h create mode 100644 Src/Wasabi/api/wnd/wndclass/labelwnd.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/labelwnd.h create mode 100644 Src/Wasabi/api/wnd/wndclass/listwnd.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/listwnd.h create mode 100644 Src/Wasabi/api/wnd/wndclass/oswnd.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/oswnd.h create mode 100644 Src/Wasabi/api/wnd/wndclass/oswndhost.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/oswndhost.h create mode 100644 Src/Wasabi/api/wnd/wndclass/qpaintwnd.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/qpaintwnd.h create mode 100644 Src/Wasabi/api/wnd/wndclass/rootwndholder.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/rootwndholder.h create mode 100644 Src/Wasabi/api/wnd/wndclass/scbkgwnd.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/scbkgwnd.h create mode 100644 Src/Wasabi/api/wnd/wndclass/scrollbar.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/scrollbar.h create mode 100644 Src/Wasabi/api/wnd/wndclass/sepwnd.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/sepwnd.h create mode 100644 Src/Wasabi/api/wnd/wndclass/slider.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/slider.h create mode 100644 Src/Wasabi/api/wnd/wndclass/status.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/status.h create mode 100644 Src/Wasabi/api/wnd/wndclass/svcwndhold.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/svcwndhold.h create mode 100644 Src/Wasabi/api/wnd/wndclass/tabsheet.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/tabsheet.h create mode 100644 Src/Wasabi/api/wnd/wndclass/tabsheetbar.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/tabsheetbar.h create mode 100644 Src/Wasabi/api/wnd/wndclass/textbar.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/textbar.h create mode 100644 Src/Wasabi/api/wnd/wndclass/tooltip.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/tooltip.h create mode 100644 Src/Wasabi/api/wnd/wndclass/treewnd.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/treewnd.h create mode 100644 Src/Wasabi/api/wnd/wndclass/typesheet.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/typesheet.h create mode 100644 Src/Wasabi/api/wnd/wndclass/virtualhostwnd.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/virtualhostwnd.h create mode 100644 Src/Wasabi/api/wnd/wndclass/wndholder.cpp create mode 100644 Src/Wasabi/api/wnd/wndclass/wndholder.h create mode 100644 Src/Wasabi/api/wnd/wndevent.h create mode 100644 Src/Wasabi/api/wnd/wndtrack.cpp create mode 100644 Src/Wasabi/api/wnd/wndtrack.h create mode 100644 Src/Wasabi/api/wndmgr/alphamgr.cpp create mode 100644 Src/Wasabi/api/wndmgr/alphamgr.h create mode 100644 Src/Wasabi/api/wndmgr/animate.cpp create mode 100644 Src/Wasabi/api/wndmgr/animate.h create mode 100644 Src/Wasabi/api/wndmgr/api_wndmgr.cpp create mode 100644 Src/Wasabi/api/wndmgr/api_wndmgr.h create mode 100644 Src/Wasabi/api/wndmgr/appcmds.cpp create mode 100644 Src/Wasabi/api/wndmgr/appcmds.h create mode 100644 Src/Wasabi/api/wndmgr/autopopup.cpp create mode 100644 Src/Wasabi/api/wndmgr/autopopup.h create mode 100644 Src/Wasabi/api/wndmgr/container.cpp create mode 100644 Src/Wasabi/api/wndmgr/container.h create mode 100644 Src/Wasabi/api/wndmgr/gc.cpp create mode 100644 Src/Wasabi/api/wndmgr/gc.h create mode 100644 Src/Wasabi/api/wndmgr/guistatuscb.cpp create mode 100644 Src/Wasabi/api/wndmgr/guistatuscb.h create mode 100644 Src/Wasabi/api/wndmgr/layout.cpp create mode 100644 Src/Wasabi/api/wndmgr/layout.h create mode 100644 Src/Wasabi/api/wndmgr/msgbox.cpp create mode 100644 Src/Wasabi/api/wndmgr/msgbox.h create mode 100644 Src/Wasabi/api/wndmgr/resize.cpp create mode 100644 Src/Wasabi/api/wndmgr/resize.h create mode 100644 Src/Wasabi/api/wndmgr/skinembed.cpp create mode 100644 Src/Wasabi/api/wndmgr/skinembed.h create mode 100644 Src/Wasabi/api/wndmgr/skinwnd.cpp create mode 100644 Src/Wasabi/api/wndmgr/skinwnd.h create mode 100644 Src/Wasabi/api/wndmgr/snappnt.cpp create mode 100644 Src/Wasabi/api/wndmgr/snappnt.h create mode 100644 Src/Wasabi/api/wndmgr/wndmgrapi.cpp create mode 100644 Src/Wasabi/api/wndmgr/wndmgrapi.h create mode 100644 Src/Wasabi/api/xml/LoadXML.cpp create mode 100644 Src/Wasabi/api/xml/LoadXML.h create mode 100644 Src/Wasabi/api/xml/XMLAutoInclude.cpp create mode 100644 Src/Wasabi/api/xml/XMLAutoInclude.h create mode 100644 Src/Wasabi/api/xml/api_xmlreadercallback.cpp create mode 100644 Src/Wasabi/api/xml/xmlparams.cpp create mode 100644 Src/Wasabi/api/xml/xmlparams.h create mode 100644 Src/Wasabi/api/xml/xmlparamsi.cpp create mode 100644 Src/Wasabi/api/xml/xmlparamsi.h create mode 100644 Src/Wasabi/api/xml/xmlparamsx.cpp create mode 100644 Src/Wasabi/api/xml/xmlparamsx.h create mode 100644 Src/Wasabi/api/xml/xmlparse.h create mode 100644 Src/Wasabi/api/xml/xmlreader.cpp create mode 100644 Src/Wasabi/api/xml/xmlreader.h create mode 100644 Src/Wasabi/api/xml/xmlwrite.cpp create mode 100644 Src/Wasabi/api/xml/xmlwrite.h (limited to 'Src/Wasabi/api') diff --git a/Src/Wasabi/api/apiconfig.h b/Src/Wasabi/api/apiconfig.h new file mode 100644 index 00000000..722bf444 --- /dev/null +++ b/Src/Wasabi/api/apiconfig.h @@ -0,0 +1,176 @@ +#ifndef __API_DEF_CFG_H +#define __API_DEF_CFG_H + +#define WASABINOMAINAPI + +#ifdef WASABI_COMPILE_APP +# define WASABI_API_APP applicationApi +#endif + +#ifdef WASABI_COMPILE_SVC +# define WASABI_API_SVC serviceApi +#endif + +#ifdef WASABI_COMPILE_SYSCB +# define WASABI_API_SYSCB sysCallbackApi +#endif + +#ifdef WASABI_COMPILE_COMPONENTS +# define WASABI_API_COMPONENT componentApi +#endif + +#ifdef WASABI_COMPILE_SCRIPT +# define WASABI_API_MAKI makiApi +#endif + +#ifdef WASABI_COMPILE_UTF +# define WASABI_API_UTF utfApi +#endif + +#ifdef WASABI_COMPILE_WND +# define WASABI_API_WND wndApi +#endif + +#ifdef WASABI_COMPILE_IMGLDR +# define WASABI_API_IMGLDR imgLoaderApi +#endif + +#ifdef WASABI_COMPILE_FILEREADER +# define WASABI_API_FILE fileApi +#endif + +#ifdef WASABI_COMPILE_TIMERS +# define WASABI_API_TIMER timerApi +#endif + +#ifdef WASABI_COMPILE_WNDMGR +# define WASABI_API_WNDMGR wndManagerApi +#endif + +#ifdef WASABI_COMPILE_SKIN +# define WASABI_API_SKIN skinApi +#endif + +#ifdef WASABI_COMPILE_METADB +# define WASABI_API_METADB metadbApi +#endif + +#ifdef WASABI_COMPILE_LOCALES +# define WASABI_API_LOCALE localeApi +#endif + +#ifdef WASABI_COMPILE_CONFIG +# define WASABI_API_CONFIG configApi +#endif + +#ifdef WASABI_COMPILE_FONTS +# define WASABI_API_FONT fontApi +// This sets the static font renderer. If you are compiling with api_config, the attribute to set is { 0x280876cf, 0x48c0, 0x40bc, { 0x8e, 0x86, 0x73, 0xce, 0x6b, 0xb4, 0x62, 0xe5 } }, "Font Renderer" +# if defined(WASABI_FONT_RENDERER_USE_WIN32) +# define WASABI_FONT_RENDERER "" // "" is Win32 +# elif defined(WASABI_FONT_RENDERER_USE_FREETYPE) +# define WASABI_FONT_RENDERER "Freetype" // Freetype lib +# else +# define WASABI_FONT_RENDERER "" // "" default for OS +# endif +#endif + +#ifdef WASABI_COMPILE_MEMMGR +# define WASABI_API_MEMMGR memmgrApi +#endif + +#ifdef WASABI_COMPILE_XMLPARSER +# define WASABI_API_XML xmlApi +#endif + +#ifdef WASABI_COMPILE_MEDIACORE +# define WASABI_API_MEDIACORE coreApi +#endif + +#ifdef WASABI_COMPILE_TEXTMODE +# define WASABI_API_TEXTMODE textmodeApi +#endif + +#ifdef LINUX +# define WASABI_COMPILE_LINUX +# define WASABI_API_LINUX linuxApi +#endif + +#ifdef WASABI_COMPILE_STATSWND +# if defined(_DEBUG) | defined(WASABI_DEBUG) +# define WASABI_COMPILE_STATSWND +# ifndef WASABI_DEBUG +# define WASABI_DEBUG +# endif +# endif +#endif + +#ifdef WASABI_COMPILE_APP +# include +#endif + +#ifdef WASABI_COMPILE_SVC +# include +#endif + +#ifdef WASABI_COMPILE_SYSCB +# include +#endif + +#ifdef WASABI_COMPILE_MEMMGR +# include +#endif + +#ifdef WASABI_COMPILE_SCRIPT +# include +#endif + +#ifdef WASABI_COMPILE_FONTS +# include +#endif + +#ifdef WASABI_COMPILE_WND +# include +#endif + +#ifdef WASABI_COMPILE_IMGLDR +# include +#endif + +#ifdef WASABI_COMPILE_FILEREADER +# include +#endif + +#ifdef WASABI_COMPILE_TIMERS +# include +#endif + +#ifdef WASABI_COMPILE_WNDMGR +# include +#endif + +#ifdef WASABI_COMPILE_LOCALES +# include +#endif + +#ifdef WASABI_COMPILE_CONFIG +# include +#endif + +#ifdef WASABI_COMPILE_SKIN +# include +#endif + +#ifdef WASABI_COMPILE_MAKIDEBUG +# include +#endif + +#ifdef WASABI_COMPILE_TEXTMODE +# include +#endif + +#ifdef WASABI_API_LINUX +#include +#endif + +#endif diff --git a/Src/Wasabi/api/apiinit.cpp b/Src/Wasabi/api/apiinit.cpp new file mode 100644 index 00000000..0b198ad6 --- /dev/null +++ b/Src/Wasabi/api/apiinit.cpp @@ -0,0 +1,548 @@ +#include "./wndmgr/layout.h" + +#include +//" +#include "apiinit.h" +//?> + +#include + +#define WASABI_SAYMYNAME +#include +#undef WASABI_SAYMYNAME + +#include +#include +#include +#include +#ifdef WASABI_COMPILE_FONTS +#include +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef WASABI_COMPILE_FONTS +#ifdef WIN32 +# include +#elif defined(LINUX) +# include +#else +# error port me +#endif // platform +#endif // fonts + +#include + +#ifdef WASABI_COMPILE_MAKIDEBUG +#include +#endif +#ifdef WASABI_COMPILE_MAKIDEBUG +#include +#endif +#ifdef WASABI_COMPILE_FILEREADER +#include +#ifdef WASABI_COMPILE_ZIPREADER +#include +#endif +#endif +#ifdef WASABI_COMPILE_LINUX +#include +#endif +#ifdef WASABI_COMPILE_TEXTMODE +#if defined(WIN32) +#include +#elif defined(LINUX) +#include +#else // dummy +#include +#endif +#endif + + +#if defined(WASABI_COMPILE_COMPONENTS) | defined(GEN_FF) // MULTIAPI-FIXME +#include +#endif + +#include + +#include +#ifndef WASABI_CUSTOM_MODULE_SVCMGR +DECLARE_MODULE_SVCMGR; +#endif + +#ifdef _WIN32 +extern HINSTANCE hInstance; +#endif + +extern StringW g_resourcepath; +api_application *applicationApi = NULL; +timer_api *timerApi = NULL; + +int ApiInit::init(OSMODULEHANDLE hinstance, OSWINDOWHANDLE mainwnd, api_service *wa5_svc) +{ + Tataki::Init(wa5_svc); + serviceApi = wa5_svc; + initcount++; + +#ifndef WA3COMPATIBILITY + + // ------------------------------------------------------------------------ + // Init callback system + // ------------------------------------------------------------------------ + + waServiceFactory *sf = WASABI_API_SVC->service_getServiceByGuid(syscbApiServiceGuid); + if (sf) sysCallbackApi = reinterpret_cast(sf->getInterface()); + + // ------------------------------------------------------------------------ + // Init application API + // ------------------------------------------------------------------------ + + sf = WASABI_API_SVC->service_getServiceByGuid(applicationApiServiceGuid); + if (sf) applicationApi = reinterpret_cast(sf->getInterface()); + +g_resourcepath = StringPathCombine(WASABI_API_APP->path_getAppPath(), WASABI_RESOURCES_SUBDIRECTORY); + + // ------------------------------------------------------------------------ + // Init centralized memory manager api + // ------------------------------------------------------------------------ + + sf = WASABI_API_SVC->service_getServiceByGuid(memMgrApiServiceGuid); + if (sf) WASABI_API_MEMMGR = reinterpret_cast(sf->getInterface()); + +#ifdef WASABI_COMPILE_FILEREADER + // ------------------------------------------------------------------------ + // Init file reader api and optional file readers + // ------------------------------------------------------------------------ + fr = new FileReaderApi(); + fileApi = fr; + WASABI_API_SVC->service_register(frapisvc = new FileReaderApiService()); + //WASABI_API_SVC->service_register(&diskReader); + // set up custom file readers +#ifdef WASABI_COMPILE_ZIPREADER + zipRead = new waServiceTSingle; +#endif +#ifdef WASABI_COMPILE_ZIPREADER + WASABI_API_SVC->service_register(zipRead); +#endif +#endif // WASABI_COMPILE_FILEREADER + + + // ------------------------------------------------------------------------ + // Init config api and register optional config items + // ------------------------------------------------------------------------ +#ifdef WASABI_COMPILE_CONFIG + cfg = new api_configI(); + configApi = cfg; + WASABI_API_SVC->service_register(cfgapisvc = new ConfigApiService()); +#endif + + // if no static service was ever declared, we need to init it so we don't hit null + INIT_MODULE_SVCMGR(); + + DebugStringW(L"Auto-initializing %d services (system pass)\n", staticServiceMgr->__m_modules2.getNumItems()); + MODULE_SVCMGR_ONINIT2(); + +#ifdef WASABI_COMPILE_IMGLDR + // ------------------------------------------------------------------------ + // Init image loading api and optional image formats + // ------------------------------------------------------------------------ + img = new ImgLdrApi(); + imgLoaderApi = img; + WASABI_API_SVC->service_register(imgldrapisvc = new ImgLdrApiService()); + +#endif + +#ifdef WASABI_COMPILE_FONTS + // ------------------------------------------------------------------------ + // Init font rendering api + // ------------------------------------------------------------------------ + font = new FontApi(); + fontApi = font; + win32Font = new FontCreator; + WASABI_API_SVC->service_register(win32Font); + WASABI_API_SVC->service_register(fontapisvc = new FontApiService()); +#endif + + +#ifdef WASABI_COMPILE_LOCALES + // ------------------------------------------------------------------------ + // Init localization + // ------------------------------------------------------------------------ + loc = new api_localesI(); + localesApi = loc; + WASABI_API_SVC->service_register(localesapisvc = new LocalesApiService()); +#endif + + // ------------------------------------------------------------------------ + // Init timer api + // ------------------------------------------------------------------------ + sf = WASABI_API_SVC->service_getServiceByGuid(timerApiServiceGuid); + if (sf) timerApi = reinterpret_cast(sf->getInterface()); + + +#ifdef WASABI_COMPILE_WND + // ------------------------------------------------------------------------ + // Init window api + // ------------------------------------------------------------------------ + wnd = new WndApi(); + wndApi = wnd; +#ifdef _WIN32 + if (mainwnd != NULL) + { + mainWnd = new ForeignWnd(mainwnd, hInstance); + DebugStringW(L"main wnd handle is %x\n", mainWnd->gethWnd()); + wnd->main_setRootWnd(mainWnd); + } + else + { + default_mainWnd = new ClickWnd(); + default_mainWnd->init(hInstance, NULL, TRUE); + wnd->main_setRootWnd(default_mainWnd); + } + #endif + WASABI_API_SVC->service_register(wndapisvc = new WndApiService()); +#endif + + // ------------------------------------------------------------------------ + // Init media core api + // ------------------------------------------------------------------------ +#ifdef WASABI_COMPILE_MEDIACORE + #ifndef WA3COMPATIBILITY + #ifdef WASABI_CUSTOMIMPL_MEDIACORE + coreApi = createCustomCoreApi(); +#else + #error "not done yet" + #endif + #endif + WASABI_API_SVC->service_register(coreapisvc = new CoreApiService()); +#endif + +#ifdef WASABI_COMPILE_WNDMGR + // ------------------------------------------------------------------------ + // Init window manager api + // ------------------------------------------------------------------------ + wndmgr = new WndMgrApi (); + wndManagerApi = wndmgr; + WASABI_API_SVC->service_register(wndmgrapisvc = new WndMgrApiService()); +#endif + + + +#ifdef WASABI_COMPILE_SKIN + // ------------------------------------------------------------------------ + // Init skin + // ------------------------------------------------------------------------ + skin = new SkinApi(); + skinApi = skin; + +#ifdef WASABI_COMPILE_COMPONENTS + groupcreate = new waServiceTSingle; + WASABI_API_SVC->service_register(groupcreate); +#endif + + WASABI_API_SVC->service_register(skinapisvc = new SkinApiService()); + +#endif + +#ifdef WASABI_COMPILE_MAKIDEBUG + // ------------------------------------------------------------------------ + // Init script debugger api + // ------------------------------------------------------------------------ + debug = new MakiDebuggerApi(); + debugApi = debug; + WASABI_API_SVC->service_register(makidebugapisvc = new MakiDebugApiService()); +#endif + +#ifdef WASABI_COMPILE_SKIN + widgets = new Widgets(); +#endif + +#endif + + + DebugStringW(L"Auto-initializing %d services (user pass)\n", staticServiceMgr->__m_modules.getNumItems()); + MODULE_SVCMGR_ONINIT(); + +#ifndef WA3COMPATIBILITY + +#ifdef WASABI_COMPILE_SCRIPT + // ------------------------------------------------------------------------ + // Init scripting api + // ------------------------------------------------------------------------ + maki = new api_makiI(); + makiApi = maki; + WASABI_API_SVC->service_register(makiapisvc = new MakiApiService()); + maki->init(); + + + +#ifdef WASABI_COMPILE_WNDMGR + garbageCollector = new GarbageCollector(); +#endif + + ObjectTable::start(); +#endif + +#endif //wa3compat + + return 1; // success +} + +int ApiInit::shutdown() +{ +#ifndef WA3COMPATIBILITY + + garbageCollector->gccb_onGarbageCollect(); + delete garbageCollector; + +#ifdef WASABI_COMPILE_SKIN + skin->preShutdown(); +#endif + + MODULE_SVCMGR_ONSHUTDOWN(); + +#ifdef _WIN32 + ComponentManager::unloadAll(); +#else +#warning port me? +#endif + + WASABI_API_SVC->service_deregister(skinapisvc); + delete skin; + skinApi = NULL; + + delete skinapisvc; + skinapisvc = 0; + +#ifdef WASABI_COMPILE_SCRIPT + ObjectTable::shutdown(); +#endif + +#ifdef WASABI_COMPILE_SKIN + delete widgets; + widgets = NULL; +#endif + WASABI_API_SVC->service_deregister(makiapisvc); + delete maki; + makiApi = NULL; + + delete makiapisvc; + makiapisvc = 0; + +#ifdef WASABI_COMPILE_COMPONENTS + WASABI_API_SVC->service_deregister(groupcreate); + delete groupcreate; + groupcreate = 0; +#endif + + WASABI_API_SVC->service_deregister(win32Font); + delete win32Font; + win32Font = 0; + +#ifdef WASABI_COMPILE_MEDIACORE + #ifndef WA3COMPATIBILITY + #ifdef WASABI_CUSTOMIMPL_MEDIACORE + destroyCustomCoreApi(coreApi); +#else + #error "not done yet" + #endif + #endif + + WASABI_API_SVC->service_deregister(coreapisvc); + delete coreapisvc; + coreapisvc = 0; +#endif + + + + WASABI_API_SVC->service_deregister(wndmgrapisvc); + delete wndmgr; + wndManagerApi = NULL; + + + delete wndmgrapisvc; + wndmgrapisvc = 0; + + + delete loc; + localesApi = NULL; + + WASABI_API_SVC->service_deregister(localesapisvc); + delete localesapisvc; + localesapisvc = 0; + + +#ifdef WASABI_COMPILE_FILEREADER +#ifdef WASABI_COMPILE_ZIPREADER + WASABI_API_SVC->service_deregister(zipRead); + delete zipRead; +#endif + + + delete fr; + fileApi = NULL; + + WASABI_API_SVC->service_deregister(frapisvc); + delete frapisvc; + frapisvc = 0; +#endif + +#endif + + delete mainWnd; + mainWnd = NULL; + delete default_mainWnd; + default_mainWnd = NULL; + WASABI_API_SVC->service_deregister(wndapisvc); + delete wnd; + wndApi = NULL; + + delete wndapisvc; + wndapisvc = 0; + +#ifdef WASABI_COMPILE_FONTS + WASABI_API_SVC->service_deregister(fontapisvc); + delete font; + fontApi = NULL; + + delete fontapisvc; + fontapisvc = 0; +#endif + +#ifndef WA3COMPATIBILITY + + + delete img; + imgLoaderApi = NULL; + + WASABI_API_SVC->service_deregister(imgldrapisvc); + delete imgldrapisvc; + imgldrapisvc = 0; + +#ifdef WASABI_COMPILE_CONFIG + WASABI_API_SVC->service_deregister(cfgapisvc); + delete cfg; + configApi = NULL; + + delete cfgapisvc; + cfgapisvc = 0; +#endif + + MODULE_SVCMGR_ONSHUTDOWN2(); + + WASABI_API_MEMMGR = NULL; + +applicationApi=NULL; +#endif //wa3compatibility + +#ifdef WASABI_COMPILE_MAKIDEBUG + delete debug; + debugApi = NULL; + + WASABI_API_SVC->service_deregister(makidebugapisvc); + delete makidebugapisvc; + makidebugapisvc = 0; +#endif + + if (alphaMgr) + delete alphaMgr; + alphaMgr=0; + + // TODO: releaseInterface + timerApi = NULL; + + Tataki::Quit(); + sysCallbackApi = NULL; + + return 1; // success +} + +int ApiInit::getInitCount() +{ + return initcount; +} + +#ifdef WASABI_COMPILE_SKIN +#ifdef WASABI_COMPILE_COMPONENTS +waServiceFactoryI * ApiInit::groupcreate = NULL; +#endif +#endif //WASABI_COMPILE_SKIN + +#ifdef WASABI_COMPILE_FONTS +waServiceFactoryI * ApiInit::win32Font = NULL; +FontApiService *ApiInit::fontapisvc = NULL; +#endif //WASABI_COMPILE_FONTS + +#ifdef WASABI_COMPILE_SKIN +Widgets * ApiInit::widgets = NULL; +SkinApiService *ApiInit::skinapisvc = NULL; +#endif + +#ifdef WASABI_COMPILE_CONFIG +api_configI * ApiInit::cfg = NULL; +ConfigApiService *ApiInit::cfgapisvc = NULL; +#endif + +#ifdef WASABI_COMPILE_IMGLDR +ImgLdrApi * ApiInit::img = NULL; +ImgLdrApiService *ApiInit::imgldrapisvc = NULL; +#endif + +#ifdef WASABI_COMPILE_FONTS +FontApi * ApiInit::font = NULL; +#endif + +#ifdef WASABI_COMPILE_FILEREADER +FileReaderApi * ApiInit::fr = NULL; +#ifdef WASABI_COMPILE_ZIPREADER +waServiceFactoryI * ApiInit::zipRead = NULL; +#endif +FileReaderApiService *ApiInit::frapisvc = NULL; +#endif + +#ifdef WASABI_COMPILE_LOCALES +api_localesI * ApiInit::loc = NULL; +LocalesApiService *ApiInit::localesapisvc = NULL; +#endif + +#ifdef WASABI_COMPILE_WND +WndApi * ApiInit::wnd = NULL; +ForeignWnd * ApiInit::mainWnd = NULL; +ClickWnd * ApiInit::default_mainWnd = NULL; +WndApiService *ApiInit::wndapisvc = NULL; +#endif + +#ifdef WASABI_COMPILE_WNDMGR +WndMgrApi * ApiInit::wndmgr = NULL; +WndMgrApiService *ApiInit::wndmgrapisvc = NULL; +#endif + +#ifdef WASABI_COMPILE_SCRIPT +api_makiI * ApiInit::maki = NULL; +MakiApiService *ApiInit::makiapisvc = NULL; +#endif + +#ifdef WASABI_COMPILE_SKIN +SkinApi * ApiInit::skin = NULL; +#endif + +#ifdef WASABI_COMPILE_MAKIDEBUG +MakiDebuggerApi * ApiInit::debug = NULL; +MakiDebugApiService *ApiInit::makidebugapisvc = NULL; +#endif + +#ifdef WASABI_COMPILE_MEDIACORE +CoreApiService *ApiInit::coreapisvc = NULL; +#endif + + +int ApiInit::initcount = 0; + +api_memmgr *memmgrApi = NULL; \ No newline at end of file diff --git a/Src/Wasabi/api/apiinit.h b/Src/Wasabi/api/apiinit.h new file mode 100644 index 00000000..2bf3adae --- /dev/null +++ b/Src/Wasabi/api/apiinit.h @@ -0,0 +1,255 @@ +#ifndef __API_INIT_H +#define __API_INIT_H + +#include +#include +#include +#include +#include + +class api_configI; +class SkinApi; +class api_makiI; +class MemMgrApi; +class TimerApi; +class WndApi; +class ForeignWnd; +class ClickWnd; + +class ImgLdrApi; +#ifdef WASABI_COMPILE_FONTS +class FontApi; +#endif +#ifdef WASABI_COMPILE_WNDMGR +class WndMgrApi; +#endif +#ifdef WASABI_COMPILE_MAKIDEBUG +class MakiDebuggerApi; +#endif +#ifdef WASABI_COMPILE_FILEREADER +class FileReaderApi; +#endif +#ifdef WASABI_COMPILE_LOCALES +class api_localesI; +#endif +#ifndef WA3COMPATIBILITY +#ifdef WASABI_COMPILE_MEDIACORE +class Core; +#endif +#endif + + + +#include + + + + +#ifdef WASABI_COMPILE_MEDIACORE + +#include + +class CoreApiService : public waServiceBase { +public: + CoreApiService() : waServiceBase(coreApiServiceGuid) {} + static const char *getServiceName() { return "Core API"; } + virtual api_core *getService() { return coreApi; } + static FOURCC getServiceType() { return WaSvc::UNIQUE; } +}; + +#endif // WASABI_COMPILE_MEDIACORE + +#ifdef WASABI_COMPILE_FILEREADER + +#include + +class FileReaderApiService : public waServiceBase { +public: + FileReaderApiService() : waServiceBase(fileReaderApiServiceGuid) {} + static const char *getServiceName() { return "FileReader API"; } + virtual api_fileReader *getService() { return fileApi; } + static FOURCC getServiceType() { return WaSvc::UNIQUE; } +}; + +#endif // WASABI_COMPILE_FILEREADER + +#ifdef WASABI_COMPILE_CONFIG + +#include + +class ConfigApiService : public waServiceBase { +public: + ConfigApiService() : waServiceBase(configApiServiceGuid) {} + static const char *getServiceName() { return "Config API"; } + virtual api_config *getService() { return configApi; } + static FOURCC getServiceType() { return WaSvc::UNIQUE; } +}; + +#endif // WASABI_COMPILE_CONFIG + +#ifdef WASABI_COMPILE_IMGLDR + +#include + +class ImgLdrApiService: public waServiceBase { +public: + ImgLdrApiService() : waServiceBase(imgLdrApiServiceGuid) {} + static const char *getServiceName() { return "Image Loading API"; } + virtual imgldr_api *getService() { return imgLoaderApi; } + static FOURCC getServiceType() { return WaSvc::UNIQUE; } +}; + +#endif // WASABI_COMPILE_IMGLDR + +#ifdef WASABI_COMPILE_FONTS + +#include + +class FontApiService : public waServiceBase { +public: + FontApiService() : waServiceBase(fontApiServiceGuid) {} + static const char *getServiceName() { return "Font Rendering API"; } + virtual api_font *getService() { return fontApi; } + static FOURCC getServiceType() { return WaSvc::UNIQUE; } +}; + +#endif // WASABI_COMPILE_FONT + + +#include + +class LocalesApiService : public waServiceBase { +public: + LocalesApiService() : waServiceBase(localesApiServiceGuid) {} + static const char *getServiceName() { return "Locales API"; } + virtual api_locales *getService() { return localesApi; } + static FOURCC getServiceType() { return WaSvc::UNIQUE; } +}; + + + +#include + +class WndApiService : public waServiceBase { +public: + WndApiService() : waServiceBase(wndApiServiceGuid) {} + static const char *getServiceName() { return "Windowing API"; } + virtual wnd_api *getService() { return wndApi; } + static FOURCC getServiceType() { return WaSvc::UNIQUE; } +}; + + +#include + +class WndMgrApiService : public waServiceBase { +public: + WndMgrApiService() : waServiceBase(wndMgrApiServiceGuid) {} + static const char *getServiceName() { return "Window Manager API"; } + virtual wndmgr_api *getService() { return wndManagerApi; } + static FOURCC getServiceType() { return WaSvc::UNIQUE; } +}; + +#include + +class SkinApiService : public waServiceBase { +public: + SkinApiService() : waServiceBase(skinApiServiceGuid) {} + static const char *getServiceName() { return "Skinning API"; } + virtual api_skin *getService() { return skinApi; } + static FOURCC getServiceType() { return WaSvc::UNIQUE; } +}; + +#include + +class MakiApiService : public waServiceBase { +public: + MakiApiService() : waServiceBase(makiApiServiceGuid) {} + static const char *getServiceName() { return "MAKI Scripting API"; } + virtual api_maki *getService() { return makiApi; } + static FOURCC getServiceType() { return WaSvc::UNIQUE; } +}; + +#ifdef WASABI_COMPILE_MAKIDEBUG + +#include + +class MakiDebugApiService : public waServiceBase { +public: + MakiDebugApiService() : waServiceBase(makiDebugApiServiceGuid) {} + static const char *getServiceName() { return "MAKI Debugger API"; } + virtual api_makiDebugger *getService() { return debugApi; } + static FOURCC getServiceType() { return WaSvc::UNIQUE; } +}; + +#endif // WASABI_COMPILE_SKIN + +class ApiInit +{ +public: + static int init(OSMODULEHANDLE hinstance, OSWINDOWHANDLE mainwnd, api_service *wa5_svc); // 0 == error, 1 == success + static int shutdown(); // 0 == error, 1 == success + static int getInitCount(); // if you do init / shutdown more than once in the session, this may be useful to invalid some caches + +private: + #ifdef WASABI_COMPILE_SKIN + #ifdef WASABI_COMPILE_COMPONENTS + static waServiceFactoryI * groupcreate; + #endif //WASABI_COMPILE_COMPONENTS + #endif //WASABI_COMPILE_SKIN + + static waServiceFactoryI * win32Font; + static FontApiService *fontapisvc; + +public: + static Widgets * widgets; +private: + static SkinApiService *skinapisvc; + + static api_configI * cfg; + static ConfigApiService *cfgapisvc; + static ImgLdrApi * img; + static ImgLdrApiService *imgldrapisvc; + + #ifdef WASABI_COMPILE_FONTS + static FontApi * font; + #endif + + #ifdef WASABI_COMPILE_FILEREADER + static FileReaderApi * fr; + #ifdef WASABI_COMPILE_ZIPREADER + static waServiceFactoryI * zipRead; + #endif + static FileReaderApiService *frapisvc; + #endif + + static api_localesI *loc; + static LocalesApiService *localesapisvc; + + static WndApi * wnd; + static ForeignWnd * mainWnd; + static ClickWnd * default_mainWnd; + static WndApiService *wndapisvc; + + static WndMgrApi * wndmgr; + static WndMgrApiService *wndmgrapisvc; + + + static api_makiI * maki; + static MakiApiService *makiapisvc; + + static SkinApi * skin; + + #ifdef WASABI_COMPILE_MAKIDEBUG + static MakiDebuggerApi * debug; + static MakiDebugApiService *makidebugapisvc; + #endif + + #ifdef WASABI_COMPILE_MEDIACORE + static CoreApiService *coreapisvc; + #endif + + static int initcount; +}; + +#endif + diff --git a/Src/Wasabi/api/application/api_application.cpp b/Src/Wasabi/api/application/api_application.cpp new file mode 100644 index 00000000..32cf2e8b --- /dev/null +++ b/Src/Wasabi/api/application/api_application.cpp @@ -0,0 +1,12 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Wed May 07 00:55:56 2003] +// +// File : api_application.cpp +// Class : api_application +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#include +#include "api_application.h" + + diff --git a/Src/Wasabi/api/application/api_application.h b/Src/Wasabi/api/application/api_application.h new file mode 100644 index 00000000..d04ec0b8 --- /dev/null +++ b/Src/Wasabi/api/application/api_application.h @@ -0,0 +1,416 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Wed May 07 00:55:56 2003] +// +// File : api_application.h +// Class : api_application +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#ifndef __API_APPLICATION_H +#define __API_APPLICATION_H + +#include +#include +#include +#ifdef _WIN32 +#include "ifc_messageprocessor.h" +#endif + +// ---------------------------------------------------------------------------- + +enum +{ + API_APPLICATION_SUCCESS = 0, + API_APPLICATION_FAILURE = 1, +}; + +enum +{ + TRANSLATE_MODE_NORMAL = 0, + TRANSLATE_MODE_GLOBAL = 1, + TRANSLATE_MODE_CHILD = 2, +}; + +class NOVTABLE api_application: public Dispatchable +{ +protected: + api_application() {} + ~api_application() {} + +public: + const wchar_t *main_getAppName(); // returns (e.g.) "Winamp" + const wchar_t *main_getVersionString(); // returns (e.g.) "Winamp 5.12" + const wchar_t *main_getVersionNumString(); // returns (e.g.) "5.12" + unsigned int main_getBuildNumber(); // returns (e.g.) 666 + GUID main_getGUID(); + +#ifdef _WIN32 + HANDLE main_getMainThreadHandle(); // This actually gives you a DuplicateHandle, so call CloseHandle() when you are done. + HINSTANCE main_gethInstance(); +#endif // !_WIN32 + + const wchar_t *main_getCommandLine(); + void main_shutdown( int deferred = TRUE ); + void main_cancelShutdown(); + int main_isShuttingDown(); + const wchar_t *path_getAppPath(); + const wchar_t *path_getUserSettingsPath(); + + // added for 5.58+ so gen_ff can fill @SKINSPATH@ in scripts correctly + const wchar_t *path_getSkinSettingsPath(); + int app_getInitCount(); + intptr_t app_messageLoopStep(); + +#ifdef _WIN32 + void app_addMessageProcessor( ifc_messageprocessor *processor ); + void app_removeMessageProcessor( ifc_messageprocessor *processor ); + + /* accelerators are 5.53+ */ + void app_addAccelerators( HWND hwnd, HACCEL *phAccel, INT cAccel, UINT translateMode ); + void app_removeAccelerators( HWND hwnd ); + bool app_translateAccelerators( MSG *msg ); + int app_getAccelerators( HWND hwnd, HACCEL *phAccel, INT cchAccelMax, BOOL bGlobal ); // phAccel == NULL && cchAccelMax == 0 -> returns accels count + + /* register window as part of winamp global group (5.54+) */ + void app_registerGlobalWindow( HWND hwnd ); + void app_unregisterGlobalWindow( HWND hwnd ); + + /* 5.58 + */ + bool DirectMouseWheel_RegisterSkipClass( ATOM klass ); + bool DirectMouseWheel_UnregisterSkipClass( ATOM klass ); + bool DirectMouseWheel_EnableConvertToMouseWheel( HWND hwnd, BOOL enable ); // !!! must be disabled before window destroyed !!! + + /* 5.64 + */ + BOOL DirectMouseWheel_ProcessDialogMessage( HWND hwnd, unsigned int uMsg, WPARAM wParam, LPARAM lParam, const int controls[], int controlslen ); + + /* 5.61 + */ + void ActiveDialog_Register( HWND hwnd ); + void ActiveDialog_Unregister( HWND hwnd ); + HWND ActiveDialog_Get(); + + /* 5.64 + */ + const wchar_t *getATFString(); // returns the current ATF formatting string + + /* 5.66 + */ + // used for dpi scaling so we're consistent in usage throughout the UI, etc + int getScaleX( int x ); + int getScaleY( int y ); + +#endif // !_WIN32 + + /* + note: on windows, these two functions DON'T call Set/GetCurrentDirectory, Winamp maintains it's own path + because calling SetCurrentDirectory locks the folder + Added for 5.34 + */ + const wchar_t *path_getWorkingPath(); // useful to call for populating lpstrInitialDir in GetOpenFileName + void path_setWorkingPath(const wchar_t *newPath); // useful to call for populating lpstrInitialDir in GetOpenFileName + + /* + The following three function return you unique IDs you can use if you need + They are created anonymously, so information cannot be tracked back to a specific person + The main reason for their existence is that a few third party libraries require them + and some online media providers require this info for billing. + You can call this functions with a pointer to any 16 byte data structure cast to a GUID * + Added for 5.35 + */ + // returns an ID unique to this computer, but not unique to the logged in user (two windows accts would share this ID) + int GetMachineID( GUID *id ); + // returns an ID unique to this user. Another user logged in to the computer will have a different ID + // note that if Winamp was installed with "shared settings", the IDs of multiple users will probably be identical + // as we're just storing it in winamp.ini for now + int GetUserID( GUID *id ); + // returns a unique ID for this session. Generated on the fly the first time someone calls this function + int GetSessionID( GUID *id ); + + /* 5.54 + */ + size_t AllocateThreadStorage(); // returns an index, -1 for error + void *GetThreadStorage(size_t index); + void SetThreadStorage(size_t index, void *value); + +protected: + enum + { + API_APPLICATION_MAIN_GETAPPNAME = 10, + API_APPLICATION_MAIN_GETVERSIONSTRING = 20, + API_APPLICATION_MAIN_GETVERSIONSTRING2 = 21, + API_APPLICATION_MAIN_GETBUILDNUMBER = 30, + API_APPLICATION_MAIN_GETGUID = 40, + API_APPLICATION_MAIN_GETMAINTHREADHANDLE = 50, + API_APPLICATION_MAIN_GETHINSTANCE = 60, + API_APPLICATION_MAIN_GETCOMMANDLINE = 70, + API_APPLICATION_MAIN_SHUTDOWN = 80, + API_APPLICATION_MAIN_CANCELSHUTDOWN = 90, + API_APPLICATION_MAIN_ISSHUTTINGDOWN = 100, + API_APPLICATION_PATH_GETAPPPATH = 110, + API_APPLICATION_PATH_GETUSERSETTINGSPATH = 120, + API_APPLICATION_APP_GETINITCOUNT = 130, + API_APPLICATION_APP_MESSAGELOOPSTEP = 140, + API_APPLICATION_APP_ADDMESSAGEPROCESSOR = 150, + API_APPLICATION_APP_REMOVEMESSAGEPROCESSOR = 160, + API_APPLICATION_APP_ADDMODELESSDIALOG = 170, + API_APPLICATION_APP_REMOVEMODELESSDIALOG = 180, + API_APPLICATION_PATH_GETWORKINGPATH = 190, + API_APPLICATION_PATH_SETWORKINGPATH = 200, + API_APPLICATION_GETMACHINEID = 210, + API_APPLICATION_GETUSERID = 220, + API_APPLICATION_GETSESSIONID = 230, + API_APPLICATION_APP_ADDACCELERATORS = 240, + API_APPLICATION_APP_REMOVEACCELERATORS = 250, + API_APPLICATION_APP_TRANSLATEACCELERATORS = 260, + API_APPLICATION_APP_GETACCELERATORS = 270, + API_APPLICATION_APP_REGISTERGLOBALWINDOW = 280, + API_APPLICATION_APP_UNREGISTERGLOBALWINDOW = 290, + API_APPLICATION_ALLOCATETHREADSTORAGE = 300, + API_APPLICATION_GETTHREADSTORAGE = 310, + API_APPLICATION_SETTHREADSTORAGE = 320, + API_APPLICATION_PATH_GETSKINSETTINGSPATH = 330, + API_APPLICATION_DIRECTMOUSEWHEEL_REGISTERSKIPCLASS = 340, + API_APPLICATION_DIRECTMOUSEWHEEL_UNREGISTERSKIPCLASS = 350, + API_APPLICATION_DIRECTMOUSEWHEEL_ENABLECONVERTTOMOUSEWHEEL = 360, + API_APPLICATION_DIRECTMOUSEWHEEL_PROCESSDIALOGMESSAGE = 365, + API_APPLICATION_ACTIVEDIALOG_REGISTER = 370, + API_APPLICATION_ACTIVEDIALOG_UNREGISTER = 380, + API_APPLICATION_ACTIVEDIALOG_GET = 390, + API_APPLICATION_GETATFSTRING = 400, + API_APPLICATION_GETSCALEX = 500, + API_APPLICATION_GETSCALEY = 510, + }; +}; + +// ---------------------------------------------------------------------------- + +inline const wchar_t *api_application::main_getAppName() +{ + const wchar_t *__retval = _call(API_APPLICATION_MAIN_GETAPPNAME, (const wchar_t *)0); + return __retval; +} + +inline const wchar_t *api_application::main_getVersionString() +{ + const wchar_t *__retval = _call(API_APPLICATION_MAIN_GETVERSIONSTRING, (const wchar_t *)0); + return __retval; +} + +inline const wchar_t *api_application::main_getVersionNumString() +{ + return _call(API_APPLICATION_MAIN_GETVERSIONSTRING2, (const wchar_t *)0); +} + +inline unsigned int api_application::main_getBuildNumber() +{ + return _call(API_APPLICATION_MAIN_GETBUILDNUMBER, 0); +} + +inline GUID api_application::main_getGUID() +{ + GUID __retval = _call(API_APPLICATION_MAIN_GETGUID, INVALID_GUID); + return __retval; +} + +#ifdef _WIN32 +inline HANDLE api_application::main_getMainThreadHandle() +{ + HANDLE __retval = _call(API_APPLICATION_MAIN_GETMAINTHREADHANDLE, (HANDLE)NULL); + return __retval; +} + +inline HINSTANCE api_application::main_gethInstance() +{ + HINSTANCE __retval = _call(API_APPLICATION_MAIN_GETHINSTANCE, (HINSTANCE)NULL); + return __retval; +} +#endif + +inline const wchar_t *api_application::main_getCommandLine() +{ + const wchar_t *__retval = _call(API_APPLICATION_MAIN_GETCOMMANDLINE, (const wchar_t *)0); + return __retval; +} + +inline void api_application::main_shutdown(int deferred) +{ + _voidcall(API_APPLICATION_MAIN_SHUTDOWN, deferred); +} + +inline void api_application::main_cancelShutdown() +{ + _voidcall(API_APPLICATION_MAIN_CANCELSHUTDOWN); +} + +inline int api_application::main_isShuttingDown() +{ + int __retval = _call(API_APPLICATION_MAIN_ISSHUTTINGDOWN, (int)0); + return __retval; +} + +inline const wchar_t *api_application::path_getAppPath() +{ + const wchar_t *__retval = _call(API_APPLICATION_PATH_GETAPPPATH, (const wchar_t *)0); + return __retval; +} + +inline const wchar_t *api_application::path_getUserSettingsPath() +{ + return _call(API_APPLICATION_PATH_GETUSERSETTINGSPATH, (const wchar_t *)0); +} + +inline const wchar_t *api_application::path_getSkinSettingsPath() +{ + return _call(API_APPLICATION_PATH_GETSKINSETTINGSPATH, (const wchar_t *)0); +} + +inline int api_application::app_getInitCount() +{ + int __retval = _call(API_APPLICATION_APP_GETINITCOUNT, 0); + return __retval; +} + +inline intptr_t api_application::app_messageLoopStep() +{ + return _call(API_APPLICATION_APP_MESSAGELOOPSTEP, (intptr_t)1); +} + +#ifdef _WIN32 +inline void api_application::app_addMessageProcessor(ifc_messageprocessor *processor) +{ + _voidcall(API_APPLICATION_APP_ADDMESSAGEPROCESSOR, processor); +} + +inline void api_application::app_removeMessageProcessor(ifc_messageprocessor *processor) +{ + _voidcall(API_APPLICATION_APP_REMOVEMESSAGEPROCESSOR, processor); +} + +inline void api_application::app_addAccelerators(HWND hwnd, HACCEL *phAccel, INT cAccel, UINT translateMode) +{ + _voidcall(API_APPLICATION_APP_ADDACCELERATORS, hwnd, phAccel, cAccel, translateMode); +} + +inline void api_application::app_removeAccelerators(HWND hwnd) +{ + _voidcall(API_APPLICATION_APP_REMOVEACCELERATORS, hwnd); +} + +inline bool api_application::app_translateAccelerators(MSG *msg) +{ + return _call(API_APPLICATION_APP_TRANSLATEACCELERATORS, (bool)false, msg); +} + +inline int api_application::app_getAccelerators(HWND hwnd, HACCEL *phAccel, INT cchAccelMax, BOOL bGlobal) +{ + return _call(API_APPLICATION_APP_GETACCELERATORS, (int)0, hwnd, phAccel, cchAccelMax, bGlobal); +} + +inline void api_application::app_registerGlobalWindow(HWND hwnd) +{ + _voidcall(API_APPLICATION_APP_REGISTERGLOBALWINDOW, hwnd); +} + +inline void api_application::app_unregisterGlobalWindow(HWND hwnd) +{ + _voidcall(API_APPLICATION_APP_UNREGISTERGLOBALWINDOW, hwnd); +} + +inline bool api_application::DirectMouseWheel_RegisterSkipClass(ATOM klass) +{ + return _call(API_APPLICATION_DIRECTMOUSEWHEEL_REGISTERSKIPCLASS, (bool)false, klass); +} + +inline bool api_application::DirectMouseWheel_UnregisterSkipClass(ATOM klass) +{ + return _call(API_APPLICATION_DIRECTMOUSEWHEEL_UNREGISTERSKIPCLASS, (bool)false, klass); +} + +inline bool api_application::DirectMouseWheel_EnableConvertToMouseWheel(HWND hwnd, BOOL enable) +{ + return _call(API_APPLICATION_DIRECTMOUSEWHEEL_ENABLECONVERTTOMOUSEWHEEL, (bool)false, hwnd, enable); +} + +inline BOOL api_application::DirectMouseWheel_ProcessDialogMessage(HWND hwnd, unsigned int uMsg, WPARAM wParam, LPARAM lParam, const int controls[], int controlslen) +{ + return _call(API_APPLICATION_DIRECTMOUSEWHEEL_PROCESSDIALOGMESSAGE, (BOOL)FALSE, hwnd, uMsg, wParam, lParam, controls, controlslen); +} + +inline void api_application::ActiveDialog_Register(HWND hwnd) +{ + _voidcall(API_APPLICATION_ACTIVEDIALOG_REGISTER, hwnd); +} + +inline void api_application::ActiveDialog_Unregister(HWND hwnd) +{ + _voidcall(API_APPLICATION_ACTIVEDIALOG_UNREGISTER, hwnd); +} + +inline HWND api_application::ActiveDialog_Get() +{ + return _call(API_APPLICATION_ACTIVEDIALOG_GET, (HWND)NULL); +} + +inline const wchar_t *api_application::getATFString() +{ + return _call(API_APPLICATION_GETATFSTRING, (wchar_t *)0); +} + +inline int api_application::getScaleX(int x) +{ + return _call(API_APPLICATION_GETSCALEX, (int)0, x); +} + +inline int api_application::getScaleY(int y) +{ + return _call(API_APPLICATION_GETSCALEY, (int)0, y); +} +#endif + +inline const wchar_t *api_application::path_getWorkingPath() +{ + return _call(API_APPLICATION_PATH_GETWORKINGPATH, (wchar_t *)0); +} + +inline void api_application::path_setWorkingPath(const wchar_t *newPath) +{ + _voidcall(API_APPLICATION_PATH_SETWORKINGPATH, newPath); +} + +inline int api_application::GetMachineID(GUID *id) +{ + return _call(API_APPLICATION_GETMACHINEID, (int)API_APPLICATION_FAILURE, id); +} + +inline int api_application::GetUserID(GUID *id) +{ + return _call(API_APPLICATION_GETUSERID, (int)API_APPLICATION_FAILURE, id); +} + +inline int api_application::GetSessionID(GUID *id) +{ + return _call(API_APPLICATION_GETSESSIONID, (int)API_APPLICATION_FAILURE, id); +} + +inline size_t api_application::AllocateThreadStorage() +{ + return _call(API_APPLICATION_ALLOCATETHREADSTORAGE, (size_t)-1); +} + +inline void *api_application::GetThreadStorage(size_t index) +{ + return _call(API_APPLICATION_GETTHREADSTORAGE, (void *)0, index); +} + +inline void api_application::SetThreadStorage(size_t index, void *value) +{ + _voidcall(API_APPLICATION_SETTHREADSTORAGE, index, value); +} + +// ---------------------------------------------------------------------------- + +// {23B96771-09D7-46d3-9AE2-20DCEA6C86EA} +static const GUID applicationApiServiceGuid = + { + 0x23b96771, 0x9d7, 0x46d3, { 0x9a, 0xe2, 0x20, 0xdc, 0xea, 0x6c, 0x86, 0xea } + }; + +extern api_application *applicationApi; + +#endif // __API_APPLICATION_H \ No newline at end of file diff --git a/Src/Wasabi/api/application/api_applicationi.cpp b/Src/Wasabi/api/application/api_applicationi.cpp new file mode 100644 index 00000000..694bc865 --- /dev/null +++ b/Src/Wasabi/api/application/api_applicationi.cpp @@ -0,0 +1,204 @@ +#include +//" +#include "api_applicationi.h" +//?> + +#include +#include +#include +#include + +#ifdef WA3COMPATIBILITY +#include // CUT! +#include // CUT! +#include +#endif + +StringW g_resourcepath; + +// {3CBD4483-DC44-11d3-B608-000086340885} +static const GUID _baseGUID = + { 0x3cbd4483, 0xdc44, 0x11d3, { 0xb6, 0x8, 0x0, 0x0, 0x86, 0x34, 0x8, 0x85 } }; + +api_application *applicationApi = NULL; +api_applicationI::api_applicationI(HINSTANCE instance, const wchar_t *_userPath) +: appInstance(instance), mainthread(0), shuttingdown(0) +{ + userPath = _userPath; +#ifndef _WASABIRUNTIME + +#ifdef WASABI_DIRS_FROMEXEPATH + HINSTANCE hInst = GetModuleHandle(0); +#else + HINSTANCE hInst = appInstance; +#endif + + StringW path; + { + wchar_t g[WA_MAX_PATH]; + GetModuleFileNameW(hInst, g, WA_MAX_PATH - 1); + wchar_t *p = wcsrchr(g, '\\'); + if (p) *p = 0; + path = g; + } +#ifdef WIN32 + g_resourcepath = path; +#elif defined(LINUX) + g_resourcepath = "/usr/local/share/"; + g_resourcepath += WasabiVersion::getAppName(); +#endif + +#ifdef LINUX + //char *file = getenv( "WASABI_LOG_FILE" ); + //if (!ACCESS(file, 0)) UNLINK(file); +#endif + + apppath = path; + + g_resourcepath.AddBackslash(); + +#if defined(WASABI_COMPILE_SKIN) || defined(WASABI_COMPILE_IMGLDR) + g_resourcepath.AppendPath(WASABI_RESOURCES_SUBDIRECTORY); +#endif + +#endif + +#ifdef WIN32 + HANDLE h = NULL; + DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &h, 0, FALSE, DUPLICATE_SAME_ACCESS); + mainthread = h; // 32-bit writes assumed atomic +#endif +#ifdef LINUX + DebugString("portme: api main thread handle dup\n"); +#endif +} + +api_applicationI::~api_applicationI() +{ + g_resourcepath.purge(); +} + +const wchar_t *api_applicationI::main_getAppName() +{ + return WasabiVersion::getAppName(); +} + +const wchar_t *api_applicationI::main_getVersionString() +{ + return WasabiVersion::getVersionString(); +} + +unsigned int api_applicationI::main_getBuildNumber() +{ + return WasabiVersion::getBuildNumber(); +} + +GUID api_applicationI::main_getGUID() +{ + return guid; +} + +HANDLE api_applicationI::main_getMainThreadHandle() +{ + if (mainthread == 0) return (HANDLE)0; + HANDLE h = (HANDLE)0; +#ifdef WIN32 + DuplicateHandle(GetCurrentProcess(), mainthread, GetCurrentProcess(), &h, 0, FALSE, DUPLICATE_SAME_ACCESS); +#endif +#ifdef LINUX + DebugString("portme: dup handle\n"); +#endif + return h; +} + +HINSTANCE api_applicationI::main_gethInstance() +{ + return appInstance; +} + +const wchar_t *api_applicationI::main_getCommandLine() +{ + return cmdLine; +} + +void api_applicationI::main_shutdown(int deferred) +{ + int x = 1; +#ifdef WASABI_CHECK_CAN_EXIT + WASABI_CHECK_CAN_EXIT(x) +#endif + if (!x) return ; + shuttingdown = 1; +#ifdef _WASABIRUNTIME + Main::doAction(ACTION_CLOSE, deferred); +#endif +#ifdef WASABI_CUSTOM_QUIT + WASABI_CUSTOM_QUITFN +#endif + +} + +void api_applicationI::main_cancelShutdown() +{ +#ifdef _WASABIRUNTIME + Main::cancelShutdown(); +#endif + shuttingdown = 0; +} + +int api_applicationI::main_isShuttingDown() +{ + return shuttingdown; +} + +const wchar_t *api_applicationI::path_getAppPath() +{ +#ifdef _WASABIRUNTIME + return Main::getMainAppPath(); +#endif + return apppath; +} + +const wchar_t *api_applicationI::path_getUserSettingsPath() +{ + return userPath; + //return PathMgr::getUserSettingsPath(); +} + +void api_applicationI::setHInstance(HINSTANCE instance) +{ + appInstance = instance; +}; + +void api_applicationI::setCommandLine(const wchar_t *cmdline) +{ + cmdLine = cmdline; +} + +void api_applicationI::setGUID(GUID g) +{ + guid = g; +} + +int api_applicationI::app_getInitCount() +{ + return ApiInit::getInitCount(); +} + + +int api_applicationI::app_messageLoopStep() +{ +#if defined(WASABI_COMPILE_TIMERS) || defined(WASABI_COMPILE_WND) + MSG msg; + if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) + { + if (!GetMessage( &msg, NULL, 0, 0 )) return 0; +#ifdef WASABI_COMPILE_WND + TranslateMessage( &msg ); +#endif + DispatchMessage( &msg ); + } +#endif + return 1; +} + diff --git a/Src/Wasabi/api/application/api_applicationi.h b/Src/Wasabi/api/application/api_applicationi.h new file mode 100644 index 00000000..5018250a --- /dev/null +++ b/Src/Wasabi/api/application/api_applicationi.h @@ -0,0 +1,49 @@ +#ifndef __API_APPLICATIONI_IMPL_H +#define __API_APPLICATIONI_IMPL_H + +/**/ +#include "api_application.h" +#include "api_applicationx.h" +/*?>*/ + +/*[interface.header.h] +#include "common/nsGUID.h" +class String; +*/ + +class api_applicationI : public api_applicationX { +public: + NODISPATCH api_applicationI(HINSTANCE instance, const wchar_t *_userPath); + NODISPATCH virtual ~api_applicationI(); + + DISPATCH(10) const wchar_t *main_getAppName(); + DISPATCH(20) const wchar_t *main_getVersionString(); + DISPATCH(30) unsigned int main_getBuildNumber(); + DISPATCH(40) GUID main_getGUID(); + DISPATCH(50) HANDLE main_getMainThreadHandle(); + DISPATCH(60) HINSTANCE main_gethInstance(); + DISPATCH(70) const wchar_t *main_getCommandLine(); + DISPATCH(80) void main_shutdown(int deferred = TRUE); + DISPATCH(90) void main_cancelShutdown(); + DISPATCH(100) int main_isShuttingDown(); + DISPATCH(110) const wchar_t *path_getAppPath(); + DISPATCH(120) const wchar_t *path_getUserSettingsPath(); + DISPATCH(130) int app_getInitCount(); + DISPATCH(140) int app_messageLoopStep(); + + NODISPATCH void setHInstance(HINSTANCE instance); + NODISPATCH void setCommandLine(const wchar_t *cmdline); + NODISPATCH void setGUID(GUID g); + +protected: + + HINSTANCE appInstance; + StringW cmdLine; + StringW userPath; + HANDLE mainthread; + GUID guid; + int shuttingdown; + StringW apppath; +}; + +#endif // __API_APPLICATIONI_IMPL_H diff --git a/Src/Wasabi/api/application/api_applicationx.cpp b/Src/Wasabi/api/application/api_applicationx.cpp new file mode 100644 index 00000000..3c689467 --- /dev/null +++ b/Src/Wasabi/api/application/api_applicationx.cpp @@ -0,0 +1,33 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Wed May 07 00:55:56 2003] +// +// File : api_applicationx.cpp +// Class : api_application +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- +#include + +#include "api_applicationx.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif + +#define CBCLASS api_applicationX +START_DISPATCH; + CB(API_APPLICATION_MAIN_GETAPPNAME, main_getAppName); + CB(API_APPLICATION_MAIN_GETVERSIONSTRING, main_getVersionString); + CB(API_APPLICATION_MAIN_GETBUILDNUMBER, main_getBuildNumber); + CB(API_APPLICATION_MAIN_GETGUID, main_getGUID); + CB(API_APPLICATION_MAIN_GETMAINTHREADHANDLE, main_getMainThreadHandle); + CB(API_APPLICATION_MAIN_GETHINSTANCE, main_gethInstance); + CB(API_APPLICATION_MAIN_GETCOMMANDLINE, main_getCommandLine); + VCB(API_APPLICATION_MAIN_SHUTDOWN, main_shutdown); + VCB(API_APPLICATION_MAIN_CANCELSHUTDOWN, main_cancelShutdown); + CB(API_APPLICATION_MAIN_ISSHUTTINGDOWN, main_isShuttingDown); + CB(API_APPLICATION_PATH_GETAPPPATH, path_getAppPath); + CB(API_APPLICATION_PATH_GETUSERSETTINGSPATH, path_getUserSettingsPath); + CB(API_APPLICATION_APP_GETINITCOUNT, app_getInitCount); + CB(API_APPLICATION_APP_MESSAGELOOPSTEP, app_messageLoopStep); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/application/api_applicationx.h b/Src/Wasabi/api/application/api_applicationx.h new file mode 100644 index 00000000..a95809ca --- /dev/null +++ b/Src/Wasabi/api/application/api_applicationx.h @@ -0,0 +1,42 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Wed May 07 00:55:56 2003] +// +// File : api_applicationx.h +// Class : api_application +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- + +#ifndef __API_APPLICATIONX_H +#define __API_APPLICATIONX_H + +#include "api_application.h" + + + + +// ---------------------------------------------------------------------------- + +class api_applicationX : public api_application { + protected: + api_applicationX() {} + public: + virtual const wchar_t *main_getAppName()=0; + virtual const wchar_t *main_getVersionString()=0; + virtual unsigned int main_getBuildNumber()=0; + virtual GUID main_getGUID()=0; + virtual HANDLE main_getMainThreadHandle()=0; + virtual HINSTANCE main_gethInstance()=0; + virtual const wchar_t *main_getCommandLine()=0; + virtual void main_shutdown(int deferred = TRUE)=0; + virtual void main_cancelShutdown()=0; + virtual int main_isShuttingDown()=0; + virtual const wchar_t *path_getAppPath()=0; + virtual const wchar_t *path_getUserSettingsPath()=0; + virtual int app_getInitCount()=0; + virtual int app_messageLoopStep()=0; + + protected: + RECVS_DISPATCH; +}; + +#endif // __API_APPLICATIONX_H diff --git a/Src/Wasabi/api/application/ifc_messageprocessor.cpp b/Src/Wasabi/api/application/ifc_messageprocessor.cpp new file mode 100644 index 00000000..953b85c0 --- /dev/null +++ b/Src/Wasabi/api/application/ifc_messageprocessor.cpp @@ -0,0 +1 @@ +#include "api_messageprocessor.h" \ No newline at end of file diff --git a/Src/Wasabi/api/application/ifc_messageprocessor.h b/Src/Wasabi/api/application/ifc_messageprocessor.h new file mode 100644 index 00000000..0d61bdc1 --- /dev/null +++ b/Src/Wasabi/api/application/ifc_messageprocessor.h @@ -0,0 +1,26 @@ +#ifndef __WASABI_IFC_MESSAGEPROCESSOR_H +#define __WASABI_IFC_MESSAGEPROCESSOR_H + +#include +#include +class ifc_messageprocessor : public Dispatchable +{ +protected: + ifc_messageprocessor() {} + ~ifc_messageprocessor() {} + +public: + bool ProcessMessage(MSG *msg); // return true to 'eat' the message +public: + DISPATCH_CODES + { + IFC_MESSAGEPROCESSOR_PROCESS_MESSAGE = 10, + }; +}; +inline bool ifc_messageprocessor::ProcessMessage(MSG *msg) +{ + return _call(IFC_MESSAGEPROCESSOR_PROCESS_MESSAGE, false, msg); +} + +typedef ifc_messageprocessor api_messageprocessor; // TODO: CUT! +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/application/ifc_messageprocessori.cpp b/Src/Wasabi/api/application/ifc_messageprocessori.cpp new file mode 100644 index 00000000..38bb15e3 --- /dev/null +++ b/Src/Wasabi/api/application/ifc_messageprocessori.cpp @@ -0,0 +1,7 @@ +#include "ifc_messageprocessori.h" + +#define CBCLASS ifc_messageprocessorI +START_DISPATCH; +CB(IFC_MESSAGEPROCESSOR_PROCESS_MESSAGE, ProcessMessage) +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/application/ifc_messageprocessori.h b/Src/Wasabi/api/application/ifc_messageprocessori.h new file mode 100644 index 00000000..7cb10e55 --- /dev/null +++ b/Src/Wasabi/api/application/ifc_messageprocessori.h @@ -0,0 +1,13 @@ +#ifndef NULLSOFT_WASABI_MESSAGEPROCESSORI_H +#define NULLSOFT_WASABI_MESSAGEPROCESSORI_H + +#include + +class ifc_messageprocessorI: public ifc_messageprocessor +{ +public: + virtual bool ProcessMessage(MSG *msg)=0; +protected: + RECVS_DISPATCH; +}; +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/application/ipcs.cpp b/Src/Wasabi/api/application/ipcs.cpp new file mode 100644 index 00000000..2320a4d8 --- /dev/null +++ b/Src/Wasabi/api/application/ipcs.cpp @@ -0,0 +1,97 @@ +#include +#ifdef WASABI_API_COMPONENT +#include //CUT!!! +#endif +#include "ipcs.h" +#ifdef LINUX +#include +#endif + +using namespace IpcsCommand; + +#ifdef WIN32 +IpcsPtr::IpcsPtr(HWND h) { + hwnd = h; +} +#else +IpcsPtr::IpcsPtr(int q) { + qid = q; +} +#endif + +void IpcsPtr::moveToForeground() { +#ifdef WIN32 + if (IsIconic(hwnd)) ShowWindow(hwnd, SW_RESTORE); +// ShowWindow(hwnd,SW_SHOW); //FG> SW_RESTORE should take care of it and is trapped for taskbar button hiding. Explicitly showing the window will make an iconless button reapear if studio is set to not have a taskbar button + SetForegroundWindow(hwnd); +#else + DebugString( "portme -- IpcsPtr::moveToForeground\n" ); +#endif +} + +void IpcsPtr::sendWasabiCommand(int command, void *param, int paramlen) { +#ifdef WIN32 + COPYDATASTRUCT cd; + cd.dwData=command; + cd.cbData=paramlen; + cd.lpData=param; + SendMessage(hwnd, WM_COPYDATA, NULL, (long)&cd); +#else + wa_msgbuf msg; + msg.mtype = command; + ASSERT( paramlen < IPC_MSGMAX - 4 ); + msg.paramlen = paramlen; + MEMCPY( msg.param, param, paramlen ); + + if ( msgsnd( qid , &msg, IPC_MSGMAX, 0 ) == 1 ) { + perror( "msgsnd" ); + } +#endif +} + +void IpcsPtr::sendWasabiCommand(int command, const char *param) { + sendWasabiCommand(command, (void *)param, STRLEN(param)+1); +} + + +IpcsPtr *Ipcs::getOtherWasabiInstance() { + extern String ipcWindowClassName; + +#ifdef WIN32 + HWND hwnd_instance=FindWindow(ipcWindowClassName,NULL); + if(!hwnd_instance) return NULL; + + return(new IpcsPtr(hwnd_instance)); +#else + int key = ftok( ".", 'w' ); + + int qid = msgget( key, 0 ); + if ( qid == -1 && errno == ENOENT ) { + qid = msgget( key, IPC_CREAT | IPC_EXCL | 0660 ); + + LinuxAPI::setIPCId( qid ); + + return NULL; + } else if ( qid == -1 ) { + return NULL; + } else { + return new IpcsPtr( qid ); + } +#endif +} + +#pragma warning(push) +#pragma warning(disable: 4060) + +int Ipcs::onIpcsMessage(int command, void *param, int paramlen) { + switch(command) { +#ifdef WASABI_API_COMPONENT + case IPC_COMMANDLINE: + Main::processCommandLine((const char *)param); + return 0; +#endif + } + return 0; +} + +#pragma warning(pop) diff --git a/Src/Wasabi/api/application/ipcs.h b/Src/Wasabi/api/application/ipcs.h new file mode 100644 index 00000000..8ef50062 --- /dev/null +++ b/Src/Wasabi/api/application/ipcs.h @@ -0,0 +1,60 @@ +#ifndef _IPCS_H +#define _IPCS_H + +// same value as winamp 2.x +#define WM_WA_IPC WM_USER + +#ifdef LINUX +// Stolen from a webpage, I think Linux's is higher, but to be safe... +#define IPC_MSGMAX 4056 + +struct wa_msgbuf { + long mtype; + int paramlen; + char param[IPC_MSGMAX - 4]; +}; +#endif + +namespace IpcsCommand { + enum { +#ifdef WASABI_API_MEDIACORE + // wa2.x IPC messages + IPC_PLAYFILE=100, +#endif + +#ifdef WASABI_API_COMPONENT + // wa3 IPC messages + IPC_COMMANDLINE=1000, +#endif + }; +}; + +class IpcsPtr { +public: +#ifdef WIN32 + IpcsPtr(HWND hwnd); +#else + IpcsPtr(int qid); +#endif + + void sendWasabiCommand(int command, void *param=0, int paramlen=0); + void sendWasabiCommand(int command, const char *param); + + void moveToForeground(); + +private: +#ifdef WIN32 + HWND hwnd; +#else + int qid; +#endif +}; + +class Ipcs { +public: + static IpcsPtr *getOtherWasabiInstance(); + + static int onIpcsMessage(int command, void *param, int paramlen); +}; + +#endif diff --git a/Src/Wasabi/api/application/pathmgr.cpp b/Src/Wasabi/api/application/pathmgr.cpp new file mode 100644 index 00000000..ffdce62a --- /dev/null +++ b/Src/Wasabi/api/application/pathmgr.cpp @@ -0,0 +1,14 @@ +#include +#include "pathmgr.h" +#include +#include + +#if !defined(WIN32) && !defined(LINUX) +#error port me +#endif + +#ifdef WIN32 +#include +#endif + + diff --git a/Src/Wasabi/api/application/pathmgr.h b/Src/Wasabi/api/application/pathmgr.h new file mode 100644 index 00000000..7b0354e6 --- /dev/null +++ b/Src/Wasabi/api/application/pathmgr.h @@ -0,0 +1,15 @@ +#ifndef _PATHMGR_H +#define _PATHMGR_H + +#include + +class PathMgr +{ +public: + //static const char *getUserSettingsPath(); +#ifdef WASABI_COMPILE_COMPONENTS + static const wchar_t *getComponentDataPath(GUID g); +#endif +}; + +#endif diff --git a/Src/Wasabi/api/application/version.cpp b/Src/Wasabi/api/application/version.cpp new file mode 100644 index 00000000..b2ce69cc --- /dev/null +++ b/Src/Wasabi/api/application/version.cpp @@ -0,0 +1,47 @@ +#include +#include "version.h" +#include + +static int buildno = -1; +static const wchar_t *WASABI_VERSION = L""; + +#define STRFILEVER "1, 0, 0, 502\0" + +static StringW version_string; + +void WasabiVersion::setAppName(const wchar_t *name) +{ + appname = name; +} + +const wchar_t *WasabiVersion::getAppName() +{ + return appname; +} + +const wchar_t *WasabiVersion::getVersionString() +{ + if (appname.isempty()) + appname=L""; + if (version_string.isempty()) + { + if (!appname.isempty()) + version_string = appname.getValue(); + if (wcslen(WASABI_VERSION)) + { + version_string.cat(L" "); + version_string.cat(WASABI_VERSION); + } + } + return version_string; +} + +unsigned int WasabiVersion::getBuildNumber() +{ + if (buildno == -1) + { + PathParser pp(STRFILEVER, ","); + buildno = ATOI(pp.enumString(3)); + } + return buildno; +} diff --git a/Src/Wasabi/api/application/version.h b/Src/Wasabi/api/application/version.h new file mode 100644 index 00000000..bfb68994 --- /dev/null +++ b/Src/Wasabi/api/application/version.h @@ -0,0 +1,12 @@ +#ifndef _VERSION_H +#define _VERSION_H +/* +class WasabiVersion { +public: + static void setAppName(const wchar_t *name); + static const wchar_t *getAppName(); + static const wchar_t *getVersionString(); + static unsigned int getBuildNumber(); +};*/ + +#endif diff --git a/Src/Wasabi/api/application/wkc.cpp b/Src/Wasabi/api/application/wkc.cpp new file mode 100644 index 00000000..05d9f00a --- /dev/null +++ b/Src/Wasabi/api/application/wkc.cpp @@ -0,0 +1,12 @@ +#include + +#include "wkc.h" + +#define CBCLASS WasabiKernelControllerI +START_DISPATCH; + CB(TESTCOMPONENT, testComponent); + CB(TESTSCRIPT, testScript); + CB(TESTSKIN, testSkin); + CB(TESTSKINFILE, testSkinFile); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/application/wkc.h b/Src/Wasabi/api/application/wkc.h new file mode 100644 index 00000000..4f7eee86 --- /dev/null +++ b/Src/Wasabi/api/application/wkc.h @@ -0,0 +1,61 @@ +#ifndef _WKC_H +#define _WKC_H + +#include + +/** + A callback class for the loader so it can determine which resources wasabi.dll should load. +*/ +class NOVTABLE WasabiKernelController : public Dispatchable { +public: +/** + Check if a component should load. +*/ + int testComponent(const char *filename); + int testScript(const char *filename, void *data, int datalen); + int testSkin(const char *skinname); + int testSkinFile(const char *filename); + +protected: + enum { + TESTCOMPONENT=1000, + TESTSCRIPT=2000, + TESTSKIN=3000, + TESTSKINFILE=4000, + }; +}; + +inline +int WasabiKernelController::testComponent(const char *filename) { + return _call(TESTCOMPONENT, TRUE, filename); +} + +inline +int WasabiKernelController::testScript(const char *filename, void *data, int datalen) { + return _call(TESTSCRIPT, TRUE, filename, data, datalen); +} + +inline +int WasabiKernelController::testSkin(const char *skinname) { + return _call(TESTSKIN, TRUE, skinname); +} + +inline +int WasabiKernelController::testSkinFile(const char *filename) { + return _call(TESTSKINFILE, TRUE, filename); +} + +// implementors derive from this one +class WasabiKernelControllerI : public WasabiKernelController { +public: + // default to OK + virtual int testComponent(const char *filename) { return 1; } + virtual int testScript(const char *filename, void *data, int datalen) { return 1; } + virtual int testSkin(const char *skinname) { return 1; } + virtual int testSkinFile(const char *filename) { return 1; } + +protected: + RECVS_DISPATCH; +}; + +#endif diff --git a/Src/Wasabi/api/config/api_config.cpp b/Src/Wasabi/api/config/api_config.cpp new file mode 100644 index 00000000..4cffc910 --- /dev/null +++ b/Src/Wasabi/api/config/api_config.cpp @@ -0,0 +1,12 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Thu May 15 21:06:24 2003] +// +// File : api_config.cpp +// Class : api_config +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#include +#include "api_config.h" + + diff --git a/Src/Wasabi/api/config/api_config.h b/Src/Wasabi/api/config/api_config.h new file mode 100644 index 00000000..ece231b5 --- /dev/null +++ b/Src/Wasabi/api/config/api_config.h @@ -0,0 +1,149 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Thu May 15 21:06:24 2003] +// +// File : api_config.h +// Class : api_config +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#ifndef __API_CONFIG_H +#define __API_CONFIG_H + +#include +#include + +class CfgItem; +class ConfigFile; + + +// ---------------------------------------------------------------------------- + +class NOVTABLE api_config: public Dispatchable +{ + protected: + api_config() {} + ~api_config() {} + public: + void config_registerCfgItem(CfgItem *cfgitem); + void config_deregisterCfgItem(CfgItem *cfgitem); + int config_getNumCfgItems(); + CfgItem *config_enumCfgItem(int n); + CfgItem *config_getCfgItemByGuid(GUID g); + void setIntPrivate(const wchar_t *name, int val); + int getIntPrivate(const wchar_t *name, int def_val); + void setIntArrayPrivate(const wchar_t *name, const int *val, int nval); + int getIntArrayPrivate(const wchar_t *name, int *val, int nval); + void setStringPrivate(const wchar_t *name, const wchar_t *str); + int getStringPrivate(const wchar_t *name, wchar_t *buf, int buf_len, const wchar_t *default_str); + int getStringPrivateLen(const wchar_t *name); + void setIntPublic(const wchar_t *name, int val); + int getIntPublic(const wchar_t *name, int def_val); + void setStringPublic(const wchar_t *name, const wchar_t *str); + int getStringPublic(const wchar_t *name, wchar_t *buf, int buf_len, const wchar_t *default_str); + + protected: + enum { + API_CONFIG_CONFIG_REGISTERCFGITEM = 10, + API_CONFIG_CONFIG_DEREGISTERCFGITEM = 20, + API_CONFIG_CONFIG_GETNUMCFGITEMS = 30, + API_CONFIG_CONFIG_ENUMCFGITEM = 40, + API_CONFIG_CONFIG_GETCFGITEMBYGUID = 50, + API_CONFIG_SETINTPRIVATE = 60, + API_CONFIG_GETINTPRIVATE = 70, + API_CONFIG_SETINTARRAYPRIVATE = 80, + API_CONFIG_GETINTARRAYPRIVATE = 90, + API_CONFIG_SETSTRINGPRIVATE = 100, + API_CONFIG_GETSTRINGPRIVATE = 110, + API_CONFIG_GETSTRINGPRIVATELEN = 120, + API_CONFIG_SETINTPUBLIC = 130, + API_CONFIG_GETINTPUBLIC = 140, + API_CONFIG_SETSTRINGPUBLIC = 150, + API_CONFIG_GETSTRINGPUBLIC = 160, + }; +}; + +// ---------------------------------------------------------------------------- + +inline void api_config::config_registerCfgItem(CfgItem *cfgitem) { + _voidcall(API_CONFIG_CONFIG_REGISTERCFGITEM, cfgitem); +} + +inline void api_config::config_deregisterCfgItem(CfgItem *cfgitem) { + _voidcall(API_CONFIG_CONFIG_DEREGISTERCFGITEM, cfgitem); +} + +inline int api_config::config_getNumCfgItems() { + int __retval = _call(API_CONFIG_CONFIG_GETNUMCFGITEMS, (int)0); + return __retval; +} + +inline CfgItem *api_config::config_enumCfgItem(int n) { + CfgItem *__retval = _call(API_CONFIG_CONFIG_ENUMCFGITEM, (CfgItem *)NULL, n); + return __retval; +} + +inline CfgItem *api_config::config_getCfgItemByGuid(GUID g) { + CfgItem *__retval = _call(API_CONFIG_CONFIG_GETCFGITEMBYGUID, (CfgItem *)NULL, g); + return __retval; +} + +inline void api_config::setIntPrivate(const wchar_t *name, int val) { + _voidcall(API_CONFIG_SETINTPRIVATE, name, val); +} + +inline int api_config::getIntPrivate(const wchar_t *name, int def_val) { + int __retval = _call(API_CONFIG_GETINTPRIVATE, (int)0, name, def_val); + return __retval; +} + +inline void api_config::setIntArrayPrivate(const wchar_t *name, const int *val, int nval) { + _voidcall(API_CONFIG_SETINTARRAYPRIVATE, name, val, nval); +} + +inline int api_config::getIntArrayPrivate(const wchar_t *name, int *val, int nval) { + int __retval = _call(API_CONFIG_GETINTARRAYPRIVATE, (int)0, name, val, nval); + return __retval; +} + +inline void api_config::setStringPrivate(const wchar_t *name, const wchar_t *str) { + _voidcall(API_CONFIG_SETSTRINGPRIVATE, name, str); +} + +inline int api_config::getStringPrivate(const wchar_t *name, wchar_t *buf, int buf_len, const wchar_t *default_str) { + int __retval = _call(API_CONFIG_GETSTRINGPRIVATE, (int)0, name, buf, buf_len, default_str); + return __retval; +} + +inline int api_config::getStringPrivateLen(const wchar_t *name) { + int __retval = _call(API_CONFIG_GETSTRINGPRIVATELEN, (int)0, name); + return __retval; +} + +inline void api_config::setIntPublic(const wchar_t *name, int val) { + _voidcall(API_CONFIG_SETINTPUBLIC, name, val); +} + +inline int api_config::getIntPublic(const wchar_t *name, int def_val) { + int __retval = _call(API_CONFIG_GETINTPUBLIC, (int)0, name, def_val); + return __retval; +} + +inline void api_config::setStringPublic(const wchar_t *name, const wchar_t *str) { + _voidcall(API_CONFIG_SETSTRINGPUBLIC, name, str); +} + +inline int api_config::getStringPublic(const wchar_t *name, wchar_t *buf, int buf_len, const wchar_t *default_str) { + int __retval = _call(API_CONFIG_GETSTRINGPUBLIC, (int)0, name, buf, buf_len, default_str); + return __retval; +} + +// ---------------------------------------------------------------------------- + + +// {470B890C-4747-4113-ABA5-A8F8F4F8AB7E} +static const GUID configApiServiceGuid = +{ 0x470b890c, 0x4747, 0x4113, { 0xab, 0xa5, 0xa8, 0xf8, 0xf4, 0xf8, 0xab, 0x7e } }; + +extern api_config *configApi; + +#endif // __API_CONFIG_H diff --git a/Src/Wasabi/api/config/api_configi.cpp b/Src/Wasabi/api/config/api_configi.cpp new file mode 100644 index 00000000..d6b62189 --- /dev/null +++ b/Src/Wasabi/api/config/api_configi.cpp @@ -0,0 +1,124 @@ +#include +//" +#include "api_configi.h" +//?> + +#include +#include + + +static CfgList cfglist; + +api_config *configApi = NULL; + +api_configI::api_configI() +: public_config(StringPrintfW(INVALID_GUID), L"public data") +{ + public_config.initialize(); +} + +api_configI::~api_configI() +{ +} + +void api_configI::config_registerCfgItem(CfgItem *cfgitem) +{ + cfglist.addItem(cfgitem); +} + +void api_configI::config_deregisterCfgItem(CfgItem *cfgitem) +{ + cfglist.delItem(cfgitem); +} + +int api_configI::config_getNumCfgItems() +{ + return cfglist.getNumItems(); +} + +CfgItem *api_configI::config_enumCfgItem(int n) +{ + return cfglist.enumItem(n); +} + +CfgItem *api_configI::config_getCfgItemByGuid(GUID g) +{ + return cfglist.getByGuid(g); +} + +// The private config functions are currently pointing at the public config item, this is because +// only the monolithic api gets instantiated once per component and thus can know its GUID, this +// version of the config api should eventually be instantiated once per component as well when +// we start making them use the modular apis +void api_configI::setIntPrivate(const wchar_t *name, int val) +{ + public_config.setInt(name, val); +} + +int api_configI::getIntPrivate(const wchar_t *name, int def_val) +{ + int ret = public_config.getInt(name, def_val); + return ret; +} + +void api_configI::setIntArrayPrivate(const wchar_t *name, const int *val, int nval) +{ + if (nval > 256) return; + wchar_t buf[12*256]=L""; + for (int i = 0; i < nval; i++) + { + wcscat(buf, StringPrintfW(L"%d", val[i])); + if (i != nval-1) + wcscat(buf, L","); + } + public_config.setString(name, buf); +} + +int api_configI::getIntArrayPrivate(const wchar_t *name, int *val, int nval) +{ + wchar_t buf[12*256]=L""; + public_config.getString(name, buf, sizeof(buf)/sizeof(*buf), L""); + PathParserW pp(buf, L","); + if (pp.getNumStrings() != nval) return 0; + for (int i = 0; i < nval; i++) { + *val = WTOI(pp.enumString(i)); + val ++; + } + return 1; +} + +void api_configI::setStringPrivate(const wchar_t *name, const wchar_t *str) +{ + public_config.setString(name, str); +} + +int api_configI::getStringPrivate(const wchar_t *name, wchar_t *buf, int buf_len, const wchar_t *default_str) +{ + int ret = public_config.getString(name, buf, buf_len, default_str); + return ret; +} + +int api_configI::getStringPrivateLen(const wchar_t *name) +{ + return public_config.getStringLen(name); +} + +void api_configI::setIntPublic(const wchar_t *name, int val) +{ + public_config.setInt(name, val); +} + +int api_configI::getIntPublic(const wchar_t *name, int def_val) +{ + return public_config.getInt(name, def_val); +} + +void api_configI::setStringPublic(const wchar_t *name, const wchar_t *str) +{ + public_config.setString(name, str); +} + +int api_configI::getStringPublic(const wchar_t *name, wchar_t *buf, int buf_len, const wchar_t *default_str) +{ + return public_config.getString(name, buf, buf_len, default_str); +} diff --git a/Src/Wasabi/api/config/api_configi.h b/Src/Wasabi/api/config/api_configi.h new file mode 100644 index 00000000..d0e5f755 --- /dev/null +++ b/Src/Wasabi/api/config/api_configi.h @@ -0,0 +1,46 @@ +#ifndef __API_CONFIG_IMPL_H +#define __API_CONFIG_IMPL_H + +/**/ +#include "api_config.h" +#include "api_configx.h" +#include + +class CfgItem; +/*?>*/ + +class api_configI : public api_configX +{ +public: + api_configI(); + virtual ~api_configI(); + + DISPATCH(10) virtual void config_registerCfgItem(CfgItem *cfgitem); + DISPATCH(20) virtual void config_deregisterCfgItem(CfgItem *cfgitem); + DISPATCH(30) virtual int config_getNumCfgItems(); + DISPATCH(40) virtual CfgItem *config_enumCfgItem(int n); + DISPATCH(50) virtual CfgItem *config_getCfgItemByGuid(GUID g); + DISPATCH(60) virtual void setIntPrivate(const wchar_t *name, int val); + DISPATCH(70) virtual int getIntPrivate(const wchar_t *name, int def_val); + DISPATCH(80) virtual void setIntArrayPrivate(const wchar_t *name, const int *val, int nval); + DISPATCH(90) virtual int getIntArrayPrivate(const wchar_t *name, int *val, int nval); + DISPATCH(100) virtual void setStringPrivate(const wchar_t *name, const wchar_t *str); + DISPATCH(110) virtual int getStringPrivate(const wchar_t *name, wchar_t *buf, int buf_len, const wchar_t *default_str); + DISPATCH(120) virtual int getStringPrivateLen(const wchar_t *name); + DISPATCH(130) virtual void setIntPublic(const wchar_t *name, int val); + DISPATCH(140) virtual int getIntPublic(const wchar_t *name, int def_val); + DISPATCH(150) virtual void setStringPublic(const wchar_t *name, const wchar_t *str); + DISPATCH(160) virtual int getStringPublic(const wchar_t *name, wchar_t *buf, int buf_len, const wchar_t *default_str); +private: + ConfigFile public_config; +}; + +/*[interface.footer.h] +// {470B890C-4747-4113-ABA5-A8F8F4F8AB7E} +static const GUID configApiServiceGuid = +{ 0x470b890c, 0x4747, 0x4113, { 0xab, 0xa5, 0xa8, 0xf8, 0xf4, 0xf8, 0xab, 0x7e } }; + +extern api_config *configApi; +*/ + +#endif // __API_CONFIG_IMPL_H diff --git a/Src/Wasabi/api/config/api_configx.cpp b/Src/Wasabi/api/config/api_configx.cpp new file mode 100644 index 00000000..8296023e --- /dev/null +++ b/Src/Wasabi/api/config/api_configx.cpp @@ -0,0 +1,37 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Thu May 15 21:06:25 2003] +// +// File : api_configx.cpp +// Class : api_config +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- +#include + +#include "api_configx.h" +#include "api_configi.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif + +#define CBCLASS api_configX +START_DISPATCH; + VCB(API_CONFIG_CONFIG_REGISTERCFGITEM, config_registerCfgItem); + VCB(API_CONFIG_CONFIG_DEREGISTERCFGITEM, config_deregisterCfgItem); + CB(API_CONFIG_CONFIG_GETNUMCFGITEMS, config_getNumCfgItems); + CB(API_CONFIG_CONFIG_ENUMCFGITEM, config_enumCfgItem); + CB(API_CONFIG_CONFIG_GETCFGITEMBYGUID, config_getCfgItemByGuid); + VCB(API_CONFIG_SETINTPRIVATE, setIntPrivate); + CB(API_CONFIG_GETINTPRIVATE, getIntPrivate); + VCB(API_CONFIG_SETINTARRAYPRIVATE, setIntArrayPrivate); + CB(API_CONFIG_GETINTARRAYPRIVATE, getIntArrayPrivate); + VCB(API_CONFIG_SETSTRINGPRIVATE, setStringPrivate); + CB(API_CONFIG_GETSTRINGPRIVATE, getStringPrivate); + CB(API_CONFIG_GETSTRINGPRIVATELEN, getStringPrivateLen); + VCB(API_CONFIG_SETINTPUBLIC, setIntPublic); + CB(API_CONFIG_GETINTPUBLIC, getIntPublic); + VCB(API_CONFIG_SETSTRINGPUBLIC, setStringPublic); + CB(API_CONFIG_GETSTRINGPUBLIC, getStringPublic); +END_DISPATCH; +#undef CBCLASS + diff --git a/Src/Wasabi/api/config/api_configx.h b/Src/Wasabi/api/config/api_configx.h new file mode 100644 index 00000000..d8594b68 --- /dev/null +++ b/Src/Wasabi/api/config/api_configx.h @@ -0,0 +1,44 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Thu May 15 21:06:24 2003] +// +// File : api_configx.h +// Class : api_config +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- + +#ifndef __API_CONFIGX_H +#define __API_CONFIGX_H + +#include "api_config.h" + +class CfgItem; +class ConfigFile; + +// ---------------------------------------------------------------------------- + +class api_configX : public api_config { + protected: + api_configX() {} + public: + virtual void config_registerCfgItem(CfgItem *cfgitem)=0; + virtual void config_deregisterCfgItem(CfgItem *cfgitem)=0; + virtual int config_getNumCfgItems()=0; + virtual CfgItem *config_enumCfgItem(int n)=0; + virtual CfgItem *config_getCfgItemByGuid(GUID g)=0; + virtual void setIntPrivate(const wchar_t *name, int val)=0; + virtual int getIntPrivate(const wchar_t *name, int def_val)=0; + virtual void setIntArrayPrivate(const wchar_t *name, const int *val, int nval)=0; + virtual int getIntArrayPrivate(const wchar_t *name, int *val, int nval)=0; + virtual void setStringPrivate(const wchar_t *name, const wchar_t *str)=0; + virtual int getStringPrivate(const wchar_t *name, wchar_t *buf, int buf_len, const wchar_t *default_str)=0; + virtual int getStringPrivateLen(const wchar_t *name)=0; + virtual void setIntPublic(const wchar_t *name, int val)=0; + virtual int getIntPublic(const wchar_t *name, int def_val)=0; + virtual void setStringPublic(const wchar_t *name, const wchar_t *str)=0; + virtual int getStringPublic(const wchar_t *name, wchar_t *buf, int buf_len, const wchar_t *default_str)=0; + + protected: + RECVS_DISPATCH; +}; + +#endif // __API_CONFIGX_H diff --git a/Src/Wasabi/api/config/cfglist.cpp b/Src/Wasabi/api/config/cfglist.cpp new file mode 100644 index 00000000..b6baaab5 --- /dev/null +++ b/Src/Wasabi/api/config/cfglist.cpp @@ -0,0 +1,50 @@ +#include + +#include "cfglist.h" +#include + +void CfgList::addItem(CfgItem *cfgitem) +{ + if (cfgitem == NULL || + cfgitem->getGuid() == INVALID_GUID || + list.haveItem(cfgitem)) return; + viewer_addViewItem(cfgitem); + list.addItem(cfgitem); + + cfgitem->onRegister(); // recurses children +} + +void CfgList::delItem(CfgItem *cfgitem) +{ + if (cfgitem == NULL || !list.haveItem(cfgitem)) return; + + list.removeItem(cfgitem); + viewer_delViewItem(cfgitem); + + cfgitem->onDeregister(); // recurses children +} + +int CfgList::getNumItems() +{ + return list.getNumItems(); +} + +CfgItem *CfgList::enumItem(int n) +{ + return list[n]; +} + +CfgItem *CfgList::getByGuid(GUID g) +{ + if (g == INVALID_GUID) return NULL; + foreach(list) + if (list.getfor()->getGuid() == g) return list.getfor(); + endfor + return NULL; +} + +int CfgList::viewer_onItemDeleted(CfgItem *item) +{ + list.removeItem(item); + return 1; +} diff --git a/Src/Wasabi/api/config/cfglist.h b/Src/Wasabi/api/config/cfglist.h new file mode 100644 index 00000000..cf456ccc --- /dev/null +++ b/Src/Wasabi/api/config/cfglist.h @@ -0,0 +1,23 @@ +#ifndef _CFGLIST_H +#define _CFGLIST_H + +#include +#include +#include + +class CfgList : public DependentViewerTPtr { +public: + void addItem(CfgItem *cfgitem); + void delItem(CfgItem *cfgitem); + + int getNumItems(); + CfgItem *enumItem(int n); + CfgItem *getByGuid(GUID g); + + virtual int viewer_onItemDeleted(CfgItem *item); + +private: + PtrList list; +}; + +#endif diff --git a/Src/Wasabi/api/config/cfgscriptobj.cpp b/Src/Wasabi/api/config/cfgscriptobj.cpp new file mode 100644 index 00000000..6d220f02 --- /dev/null +++ b/Src/Wasabi/api/config/cfgscriptobj.cpp @@ -0,0 +1,371 @@ +#include +#include "cfgscriptobj.h" + +#include + +#ifndef _WASABIRUNTIME + +BEGIN_SERVICES(ConfigObject_Svc); +DECLARE_SERVICE(ScriptObjectCreator); +END_SERVICES(ConfigObject_Svc, _ConfigObject_Svc); + +#ifdef _X86_ +extern "C" { int _link_ConfigObjectSvc; } +#else +extern "C" { int __link_ConfigObjectSvc; } +#endif + +#endif + +static ConfigScriptObjectController _configController; +ScriptObjectController *configController = &_configController; + +static ConfigItemScriptObjectController _configItemController; +ScriptObjectController *configItemController = &_configItemController; + +static ConfigAttributeScriptObjectController _configAttributeController; +ScriptObjectController *configAttributeController = &_configAttributeController; + + +// ----------------------------------------------------------------------------------------------------- +// Service + +ScriptObjectController *ConfigScriptObjectSvc::getController(int n) +{ + switch (n) { + case 0: + return configController; + case 1: + return configItemController; + case 2: + return configAttributeController; + } + return NULL; +} + +// ----------------------------------------------------------------------------------------------------- +// ConfigObject + +ConfigObject::ConfigObject() { + numobjects++; + getScriptObject()->vcpu_setInterface(CONFIG_SCRIPTOBJECT_GUID, (void *)static_cast(this)); + getScriptObject()->vcpu_setClassName(L"Config"); + getScriptObject()->vcpu_setController(configController); +} + +ConfigObject::~ConfigObject() { + numobjects--; + mylist.deleteAll(); + if (numobjects == 0) { + foreach(ouraddeditems) + WASABI_API_CONFIG->config_deregisterCfgItem(ouraddeditems.getfor()); + endfor + ouraddeditems.deleteAll(); + } +} + +PtrList ConfigObject::ouraddeditems; +int ConfigObject::numobjects=0; + + +function_descriptor_struct ConfigScriptObjectController::exportedFunction[] = { + {L"getItem", 1, (void*)ConfigObject::config_getItem}, + {L"getItemByGuid", 1, (void*)ConfigObject::config_getItemByGuid}, + {L"newItem", 2, (void*)ConfigObject::config_newItem}, +}; + +int ConfigScriptObjectController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +scriptVar ConfigObject::config_newItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar configitem_name, scriptVar configitem_guid) +{ + SCRIPT_FUNCTION_INIT + ConfigObject *co = static_cast(o->vcpu_getInterface(CONFIG_SCRIPTOBJECT_GUID)); + ConfigItemObject *ret=getItem(GET_SCRIPT_STRING(configitem_name), co); + if (!ret) + ret = getItem(GET_SCRIPT_STRING(configitem_guid), co); + if (ret) + return MAKE_SCRIPT_OBJECT(ret->getScriptObject()); + CfgItemI *item = new CfgItemI(GET_SCRIPT_STRING(configitem_name), nsGUID::fromCharW(GET_SCRIPT_STRING(configitem_guid))); + ConfigObject::ouraddeditems.addItem(item); + WASABI_API_CONFIG->config_registerCfgItem(item); + ret = new ConfigItemObject(item); + co->mylist.addItem(ret); + return MAKE_SCRIPT_OBJECT(ret->getScriptObject()); +} + +ConfigItemObject *ConfigObject::getItem(const wchar_t *nameorguid, ConfigObject *co) { + int i=0; + ConfigItemObject *ret=NULL; + GUID g = nsGUID::fromCharW(nameorguid); + for (i=0;;i++) { + CfgItem *item = WASABI_API_CONFIG->config_enumCfgItem(i); + if (!item) break; + GUID ig = item->getGuid(); + if (g == ig || WCSCASEEQLSAFE(nameorguid, item->getName())) + { + ret = new ConfigItemObject(item); + co->mylist.addItem(ret); + break; + } +#if 0//CUT + for (int j=0;jgetNumChildren();j++) { + if (STRCASEEQL(nameorguid, item->enumChild(j)->getName())) { + ret = new ConfigItemObject(item->enumChild(j)); + co->mylist.addItem(ret); + break; + } + } +#endif + } + return ret; +} + +scriptVar ConfigObject::config_getItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar cfgitem_name) +{ + SCRIPT_FUNCTION_INIT + ConfigObject *co = static_cast(o->vcpu_getInterface(CONFIG_SCRIPTOBJECT_GUID)); + ConfigItemObject *ret=getItem(GET_SCRIPT_STRING(cfgitem_name), co); + return MAKE_SCRIPT_OBJECT(ret ? ret->getScriptObject() : NULL); +} + +scriptVar ConfigObject::config_getItemByGuid(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar cfgitem_guid) +{ + SCRIPT_FUNCTION_INIT +// GUID g = nsGUID::fromChar(GET_SCRIPT_STRING(guid)); +// api-> + int i=0; + ConfigItemObject *ret=NULL; + ConfigObject *co = static_cast(o->vcpu_getInterface(CONFIG_SCRIPTOBJECT_GUID)); + + const wchar_t *p = GET_SCRIPT_STRING(cfgitem_guid); + if (p == NULL) { + RETURN_SCRIPT_ZERO; + } + + GUID g = nsGUID::fromCharW(p); + + for (i=0;;i++) { + CfgItem *item = WASABI_API_CONFIG->config_enumCfgItem(i); + if (!item) break; + if (g == item->getGuid()) { + ret = new ConfigItemObject(item); + co->mylist.addItem(ret); + break; + } +#if 0//CUT + for (int j=0;jgetNumChildren();j++) { + if (g == item->enumChild(j)->getName()) { + ret = new ConfigItemObject(item->enumChild(j)); + co->mylist.addItem(ret); + break; + } + } +#endif + } + return MAKE_SCRIPT_OBJECT(ret ? ret->getScriptObject() : NULL); +} + +ScriptObject *ConfigScriptObjectController::instantiate() { + ConfigObject *c = new ConfigObject; + if (!c) return NULL; + return c->getScriptObject(); +} + +void ConfigScriptObjectController::destroy(ScriptObject *o) { + ConfigObject *obj = static_cast(o->vcpu_getInterface(CONFIG_SCRIPTOBJECT_GUID)); + ASSERT(obj != NULL); + delete obj; +} + +void *ConfigScriptObjectController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for config +} + +void ConfigScriptObjectController::deencapsulate(void *) { +} + +// ----------------------------------------------------------------------------------------------------- +// ConfigItem + +function_descriptor_struct ConfigItemScriptObjectController::exportedFunction[] = { + {L"getAttribute", 1, (void*)ConfigItemObject::configItem_getAttribute}, + {L"getGuid", 0, (void*)ConfigItemObject::configItem_getGuid}, + {L"newAttribute", 2, (void*)ConfigItemObject::configItem_newAttribute}, +}; + +int ConfigItemScriptObjectController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +ConfigItemObject::ConfigItemObject(CfgItem *_item) +{ + getScriptObject()->vcpu_setInterface(CONFIGITEM_SCRIPTOBJECT_GUID, (void *)static_cast(this)); + getScriptObject()->vcpu_setClassName(L"ConfigItem"); + getScriptObject()->vcpu_setController(configItemController); + wchar_t strguid[256]; + nsGUID::toCharW(_item->getGuid(), strguid); + guid = strguid; + item = _item; +} + +ConfigAttributeObject *ConfigItemObject::getAttribute(const wchar_t *name) +{ + if (!item) return NULL; + for (int i=0;igetNumAttributes();i++) + { + if (!WCSICMP(item->enumAttribute(i), name)) + { + ConfigAttributeObject *o = new ConfigAttributeObject(item, name, this); + mylist.addItem(o); + return o; + } + } + return NULL; +} + +ConfigAttributeObject *ConfigItemObject::newAttribute(const wchar_t *name, const wchar_t *defaultvalue) +{ + if (!item) return NULL; + ConfigAttributeObject *o = getAttribute(name); + if (o != NULL) return o; + + item->addAttribute(name, defaultvalue); + + ConfigAttributeObject *cao = getAttribute(name); + cao->setAutoDelete(); + return cao; +} + +ConfigItemObject::~ConfigItemObject() +{ + mylist.deleteAll(); +} + +scriptVar ConfigItemObject::configItem_getAttribute(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name) +{ + SCRIPT_FUNCTION_INIT + ConfigItemObject *cio = static_cast(o->vcpu_getInterface(CONFIGITEM_SCRIPTOBJECT_GUID)); + ConfigAttributeObject *cao = NULL; + if (cio) + cao = cio->getAttribute(GET_SCRIPT_STRING(name)); + return MAKE_SCRIPT_OBJECT(cao ? cao->getScriptObject() : NULL); +} + +scriptVar ConfigItemObject::configItem_getGuid(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT + ConfigItemObject *cio = static_cast(o->vcpu_getInterface(CONFIGITEM_SCRIPTOBJECT_GUID)); + if (cio) return MAKE_SCRIPT_STRING(cio->getGuid()); + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar ConfigItemObject::configItem_newAttribute(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name, scriptVar defval) { + SCRIPT_FUNCTION_INIT + ConfigItemObject *cio = static_cast(o->vcpu_getInterface(CONFIGITEM_SCRIPTOBJECT_GUID)); + ConfigAttributeObject *cao = NULL; + if (cio) + cao = cio->newAttribute(GET_SCRIPT_STRING(name), GET_SCRIPT_STRING(defval)); + return MAKE_SCRIPT_OBJECT(cao ? cao->getScriptObject() : NULL); +} + +// ----------------------------------------------------------------------------------------------------- +// ConfigAttribute + +function_descriptor_struct ConfigAttributeScriptObjectController::exportedFunction[] = { + {L"getData", 0, (void*)ConfigAttributeObject::configAttr_getData}, + {L"setData", 1, (void*)ConfigAttributeObject::configAttr_setData}, + {L"onDataChanged", 0, (void*)ConfigAttributeObject::configAttr_onDataChanged}, + {L"getParentItem", 0, (void*)ConfigAttributeObject::configAttr_getParentItem}, + {L"getAttributeName", 0, (void*)ConfigAttributeObject::configAttr_getAttributeName}, +}; + +int ConfigAttributeScriptObjectController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +void ConfigAttributeObject::setData(const wchar_t *data) +{ + if (!item || !attr) return; + item->setData(attr, data); +} + +const wchar_t *ConfigAttributeObject::getData() +{ + if (!item || !attr) return NULL; + static wchar_t t[WA_MAX_PATH]; + item->getData(attr, t, WA_MAX_PATH); + return t; +} + +ConfigAttributeObject::ConfigAttributeObject(CfgItem *_item, const wchar_t *_attr, ConfigItemObject *_parent) +{ + getScriptObject()->vcpu_setInterface(CONFIGATTRIBUTE_SCRIPTOBJECT_GUID, (void *)static_cast(this)); + getScriptObject()->vcpu_setClassName(L"ConfigAttribute"); + getScriptObject()->vcpu_setController(configAttributeController); + attr = _attr; + item = _item; + parent = _parent; + viewer_addViewItem(item); + autodelete = 0; +} + +ConfigAttributeObject::~ConfigAttributeObject() { + if (autodelete) getParentItem()->getCfgItem()->delAttribute(attr); +} + +int ConfigAttributeObject::viewer_onEvent(CfgItem *item, int event, intptr_t param, void *ptr, size_t ptrlen) +{ + if (event == CfgItem::Event_ATTRIBUTE_CHANGED) + { + const wchar_t *_attr = reinterpret_cast(ptr); + if (!WCSICMP(attr, _attr)) + configAttr_onDataChanged(SCRIPT_CALL, getScriptObject()); + } + return 1; +} + +scriptVar ConfigAttributeObject::configAttr_setData(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val) +{ + SCRIPT_FUNCTION_INIT + ConfigAttributeObject *cao = static_cast(o->vcpu_getInterface(CONFIGATTRIBUTE_SCRIPTOBJECT_GUID)); + if (cao) + cao->setData(GET_SCRIPT_STRING(val)); + RETURN_SCRIPT_VOID; +} + +scriptVar ConfigAttributeObject::configAttr_getData(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + ConfigAttributeObject *cao = static_cast(o->vcpu_getInterface(CONFIGATTRIBUTE_SCRIPTOBJECT_GUID)); + if (cao) + return MAKE_SCRIPT_STRING(cao->getData()); + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar ConfigAttributeObject::configAttr_onDataChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS0(o, configAttributeController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar ConfigAttributeObject::configAttr_getParentItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + ConfigAttributeObject *cao = static_cast(o->vcpu_getInterface(CONFIGATTRIBUTE_SCRIPTOBJECT_GUID)); + if (cao) return MAKE_SCRIPT_OBJECT(cao->getParentItem()->getScriptObject()); + return MAKE_SCRIPT_OBJECT(NULL); +} + +scriptVar ConfigAttributeObject::configAttr_getAttributeName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + ConfigAttributeObject *cao = static_cast(o->vcpu_getInterface(CONFIGATTRIBUTE_SCRIPTOBJECT_GUID)); + + if (cao) + return MAKE_SCRIPT_STRING(cao->getAttributeName()); + + return MAKE_SCRIPT_STRING(L""); +} + + + diff --git a/Src/Wasabi/api/config/cfgscriptobj.h b/Src/Wasabi/api/config/cfgscriptobj.h new file mode 100644 index 00000000..e446b618 --- /dev/null +++ b/Src/Wasabi/api/config/cfgscriptobj.h @@ -0,0 +1,198 @@ +#ifndef __CFGSCRIPTOBJ_H +#define __CFGSCRIPTOBJ_H + +#include +#include +#include +#include +#include +#include + +class CfgItem; +class ConfigObject; +class ConfigItemObject; +class ConfigAttributeObject; + +extern ScriptObjectController *configController; +extern ScriptObjectController *configItemController; +extern ScriptObjectController *configAttributeController; + +enum cfgtypes { + CFG_INT = 0, + CFG_BOOL = 1, + CFG_FLOAT = 2, + CFG_STRING = 3, +}; + +// ----------------------------------------------------------------------------------------------------- +// ScriptObject Provider Service + +class ConfigScriptObjectSvc : public svc_scriptObjectI { + +public: + ConfigScriptObjectSvc() {}; + virtual ~ConfigScriptObjectSvc() {}; + + static const char *getServiceName() { return "Config maki object"; } + virtual ScriptObjectController *getController(int n); + + static void addItemObject(ConfigItemObject *item); + static void addAttrObject(ConfigAttributeObject *attr); + static void removeItemObject(ConfigItemObject *item); + static void removeAttrObject(ConfigAttributeObject *attr); +}; + +// ----------------------------------------------------------------------------------------------------- +// Script classes GUIDS + +// {593DBA22-D077-4976-B952-F4713655400B} +static const GUID CONFIG_SCRIPTOBJECT_GUID = +{ 0x593dba22, 0xd077, 0x4976, { 0xb9, 0x52, 0xf4, 0x71, 0x36, 0x55, 0x40, 0xb } }; + +// {D4030282-3AAB-4d87-878D-12326FADFCD5} +static const GUID CONFIGITEM_SCRIPTOBJECT_GUID = +{ 0xd4030282, 0x3aab, 0x4d87, { 0x87, 0x8d, 0x12, 0x32, 0x6f, 0xad, 0xfc, 0xd5 } }; + +// {24DEC283-B76E-4a36-8CCC-9E24C46B6C73} +static const GUID CONFIGATTRIBUTE_SCRIPTOBJECT_GUID = +{ 0x24dec283, 0xb76e, 0x4a36, { 0x8c, 0xcc, 0x9e, 0x24, 0xc4, 0x6b, 0x6c, 0x73 } }; + +// ----------------------------------------------------------------------------------------------------- +// ScriptObject Interfaces + +// Config +class ConfigObject : public RootObjectInstance { + + public: + + ConfigObject(); + virtual ~ConfigObject(); + + static scriptVar config_getItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar configitem_name); + static scriptVar config_getItemByGuid(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar configitem_name); + static scriptVar config_newItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar configitem_name, scriptVar guid); + private: + static ConfigItemObject *getItem(const wchar_t *nameorguid, ConfigObject *co); + PtrList mylist; + static PtrList ouraddeditems; + static int numobjects; +}; + +// ConfigItem +class ConfigItemObject : public RootObjectInstance { + + public: + + ConfigItemObject(CfgItem *item); + virtual ~ConfigItemObject(); + + ConfigAttributeObject *getAttribute(const wchar_t *name); + const wchar_t *getGuid() { return guid; } + ConfigAttributeObject *newAttribute(const wchar_t *name, const wchar_t *defval); + + CfgItem *getCfgItem() { return item; } + + static scriptVar configItem_getAttribute(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar attr_name); + static scriptVar configItem_getGuid(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar configItem_newAttribute(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar attr_name, scriptVar defval); + + private: + CfgItem *item; + StringW guid; + PtrList mylist; +}; + +// ConfigAttribute +class ConfigAttributeObject : public RootObjectInstance, public DependentViewerTPtr { + + public: + + ConfigAttributeObject(CfgItem *item, const wchar_t *attr, ConfigItemObject *parent); + virtual ~ConfigAttributeObject(); + + void setData(const wchar_t *data); + const wchar_t *getData(); + ConfigItemObject *getParentItem() { return parent; } + const wchar_t *getAttributeName() { return attr; } + void setAutoDelete() { autodelete = 1; } + + virtual int viewer_onEvent(CfgItem *item, int event, intptr_t param, void *ptr, size_t ptrlen); + + static scriptVar configAttr_getData(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar configAttr_setData(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val); + static scriptVar configAttr_onDataChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar configAttr_getParentItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar configAttr_getAttributeName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + + private: + CfgItem *item; + StringW attr; + ConfigItemObject *parent; + int autodelete; +}; + +// ----------------------------------------------------------------------------------------------------- +// ScriptObjectControllers for our script classes + +// Config +class ConfigScriptObjectController : public ScriptObjectControllerI { + public: + virtual const wchar_t *getClassName() { return L"Config"; } + virtual const wchar_t *getAncestorClassName() { return L"Object"; } + virtual ScriptObjectController *getAncestorController() { return NULL; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions() { return exportedFunction; } + virtual GUID getClassGuid() { return CONFIG_SCRIPTOBJECT_GUID; } + virtual int getInstantiable() { return 0; } + virtual int getReferenceable() { return 0; } + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + static function_descriptor_struct exportedFunction[]; +}; + +// ConfigItem +class ConfigItemScriptObjectController : public ScriptObjectControllerI { + public: + virtual const wchar_t *getClassName() { return L"ConfigItem"; } + virtual const wchar_t *getAncestorClassName() { return L"Object"; } + virtual ScriptObjectController *getAncestorController() { return NULL; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions() { return exportedFunction; } + virtual GUID getClassGuid() { return CONFIGITEM_SCRIPTOBJECT_GUID; } + virtual int getInstantiable() { return 0; } + virtual int getReferenceable() { return 1; } + virtual ScriptObject *instantiate() { return NULL; }; + virtual void destroy(ScriptObject *o) { }; + virtual void *encapsulate(ScriptObject *o) { return NULL; }; + virtual void deencapsulate(void *o) { }; + + private: + static function_descriptor_struct exportedFunction[]; +}; + +// ConfigAttribute +class ConfigAttributeScriptObjectController : public ScriptObjectControllerI { + public: + virtual const wchar_t *getClassName() { return L"ConfigAttribute"; } + virtual const wchar_t *getAncestorClassName() { return L"Object"; } + virtual ScriptObjectController *getAncestorController() { return NULL; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions() { return exportedFunction; } + virtual GUID getClassGuid() { return CONFIGATTRIBUTE_SCRIPTOBJECT_GUID; } + virtual int getInstantiable() { return 0; } + virtual int getReferenceable() { return 1; } + virtual ScriptObject *instantiate() { return NULL; }; + virtual void destroy(ScriptObject *o) { }; + virtual void *encapsulate(ScriptObject *o) { return NULL; }; + virtual void deencapsulate(void *o) { }; + + private: + static function_descriptor_struct exportedFunction[]; +}; + +#endif + diff --git a/Src/Wasabi/api/config/config.cpp b/Src/Wasabi/api/config/config.cpp new file mode 100644 index 00000000..3b45d934 --- /dev/null +++ b/Src/Wasabi/api/config/config.cpp @@ -0,0 +1,329 @@ +#include + +#include "config.h" +#include +#include +#include +#include + +#include "../xml/ifc_xmlreadercallbackI.h" +#include "../xml/obj_xml.h" +#include +#include + +static StringW iniFile; +#define XNFNAME L"studio.xnf" + +class StringPairCompare +{ +public: + static int compareItem(StringPair *p1, StringPair *p2) + { + int r = wcscmp(p1->a.getValue(), p2->a.getValue()); + if (r == 0) + return CMP3(p1, p2); + else + return r; + } + static int compareAttrib(const wchar_t *attrib, StringPair *item) + { + return wcscmp(attrib, item->a.getValue()); + } +}; + +static PtrListQuickSorted strings; + +class Reader : public ifc_xmlreadercallbackI +{ +public: + ~Reader(); + void xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params); + void xmlReaderOnEndElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag); + + void readem(); + +private: + PtrList sections; +}; + +Reader::~Reader() +{ + sections.deleteAll(); +} + +void Reader::xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params) +{ + if (!WCSICMP(xmltag, L"section")) + { + const wchar_t *name = params->getItemValue(L"name"); + if (name == NULL) + return ; + + StringW *strName = new StringW(name); + Url::decode(*strName); + sections.addItem(strName); + } + else if (!WCSICMP(xmltag, L"entry")) + { + const wchar_t *name = params->getItemValue(L"name"); + const wchar_t *value = params->getItemValue(L"value"); + + // just in case + if (!WCSICMP(name, L"(null)")) name = NULL; + if (!WCSICMP(value, L"(null)")) value = NULL; + + if (name == NULL /*| !*name */ || value == NULL /*|| !*value*/) return ; + StringW strName = name; + Url::decode(strName); + + StringW strValue = value; + Url::decode(strValue); + + StringW n; + for (int i = 0; i < sections.getNumItems(); i++) + { + n.catPostSeparator(*sections[i], '/'); + } + n += strName; + + StringPair *p = new StringPair(n, strValue); + strings.addItem(p); + } +} + +void Reader::xmlReaderOnEndElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag) +{ + if (!WCSICMP(xmltag, L"section")) + { + StringW *last = sections.getLast(); + sections.removeLastItem(); + delete last; + } +} + +void LoadXmlFile(obj_xml *parser, const wchar_t *filename); + +void Reader::readem() +{ + strings.deleteAll(); + + if (iniFile.isempty()) + { + iniFile = StringPathCombine(WASABI_API_APP->path_getUserSettingsPath(), XNFNAME); + } + + waServiceFactory *parserFactory = WASABI_API_SVC->service_getServiceByGuid(obj_xmlGUID); + if (parserFactory) + { + obj_xml *parser = (obj_xml *)parserFactory->getInterface(); + + if (parser) + { + + parser->xmlreader_registerCallback(L"WinampXML\fconfiguration\f*", this); + parser->xmlreader_registerCallback(L"WasabiXML\fconfiguration\f*", this); + parser->xmlreader_open(); + LoadXmlFile(parser, iniFile); + + parser->xmlreader_unregisterCallback(this); + parser->xmlreader_close(); + parserFactory->releaseInterface(parser); + parser = 0; + } + } +} + +StringPair *ConfigFile::getPair(const wchar_t *name) +{ + ASSERT(!sectionname.isempty()); + StringW nname; + nname.catPostSeparator(sectionname.getValue(), '/'); + nname.cat(name); + return strings.findItem(nname.getValue()); // cast to make PtrListSorted happy +} + +StringPair *ConfigFile::makePair(const wchar_t *name, const wchar_t *value) +{ + StringPair *ret = getPair(name); + if (ret == NULL) + { + StringW nname; + nname.catPostSeparator(sectionname.getValue(), '/'); + nname.cat(name); + + ret = new StringPair(nname, value); + strings.addItem(ret); + } + else + { + ret->b.setValue(value); + } + return ret; +} + +static int ninstances, inited; + +ConfigFile::ConfigFile(const wchar_t *section, const wchar_t *name) +{ + sectionname = section; + prettyname = name; + ninstances++; +} + +void ConfigFile::initialize() +{ + Reader().readem(); +} + +ConfigFile::~ConfigFile() +{ + ninstances--; + if (ninstances == 0) + { + FILE *fp = _wfopen(iniFile, WF_WRITE_TEXT); + if (fp != NULL) + { + // write out the file + XMLWrite xml(fp, L"WasabiXML"); + const wchar_t *app = WASABI_API_APP->main_getVersionString(); + if (!app) + app = L"thousands of irascible butt monkeys"; + xml.comment(StringPrintfW(L"Generated by: %s (%d)", app, WASABI_API_APP->main_getBuildNumber())); + xml.pushCategory(L"configuration"); + + PtrList cats; + + for (int i = 0; i < strings.getNumItems(); i++) + { + StringPair *p = strings[i]; + PathParserW pp(p->a); + + int climit = MIN(pp.getNumStrings() - 1, cats.getNumItems()); + int j; + for (j = 0; j < climit; j++) + { + if (WCSICMP(*cats[j], pp.enumString(j))) + { + climit = j; + break; + } + } + + while (cats.getNumItems() > climit) + { + StringW *s = cats.getLast(); + xml.popCategory(); + cats.removeLastItem(); + delete s; + } + for (j = climit; j < pp.getNumStrings() - 1; j++) + { + StringW *s = cats.addItem(new StringW(pp.enumString(j))); + xml.pushCategoryAttrib(L"section"); + StringW enc = *s; + Url::encode(enc, FALSE, URLENCODE_EXCLUDE_ABOVEEQ32); + xml.writeCategoryAttrib(L"name", enc); + xml.closeCategoryAttrib(); + } + + xml.pushCategoryAttrib(L"entry", TRUE); + StringW enc = pp.getLastString(); + Url::encode(enc, FALSE, URLENCODE_EXCLUDE_ABOVEEQ32); + xml.writeCategoryAttrib(L"name", enc); + enc = p->b; + Url::encode(enc, FALSE, URLENCODE_EXCLUDE_ABOVEEQ32); + if (enc.iscaseequal(L"(null)") || enc.getValue() == NULL) + enc.setValue(L""); + xml.writeCategoryAttrib(L"value", enc); + xml.closeCategoryAttrib(); + xml.popCategory(); + } + + while (xml.popCategory()) ; + + strings.deleteAll(); + fclose(fp); + } // fp != NULL + } // ninstances==0 +} + +int verifyName(const wchar_t *str) +{ + for (const wchar_t *p = str; *p; p++) + { + if (!ISALPHA(*p) && + !ISDIGIT(*p) && + !ISPUNCT(*p) && + !ISSPACE(*p) && + *p != '|' && *p != '_') + return 0; + } + return 1; +} + +void ConfigFile::setInt(const wchar_t *name, int val) +{ + INCRITICALSECTION(cs); + if (name == NULL) return ; + if (!verifyName(name)) + { + DebugStringW(L"illegal name given\n"); + //__asm { int 3 }; + return ; + } + makePair(name, StringPrintfW(val)); +} + +int ConfigFile::getInt(const wchar_t *name, int def_val) +{ + INCRITICALSECTION(cs); + if (name == NULL) return def_val; + StringPair *p = getPair(name); + if (p == NULL) return def_val; + return WTOI(p->b.getValue()); +} + +void ConfigFile::setString(const wchar_t *name, const wchar_t *str) +{ + INCRITICALSECTION(cs); + if (name == NULL) return ; + if (!verifyName(name)) + { + DebugStringW(L"illegal name given\n"); + return ; + } + if (str == NULL) + { + StringPair *p = getPair(name); + if (p != NULL) + { + strings.delItem(p); + delete p; + return ; + } + } + makePair(name, str); +} + +int ConfigFile::getString(const wchar_t *name, wchar_t *buf, int buf_len, const wchar_t *def_str) +{ + INCRITICALSECTION(cs); + if (name == NULL || buf == NULL) return -1; + if (def_str == NULL) + def_str = L""; + StringPair *p = getPair(name); + if (p == NULL) + WCSCPYN(buf, def_str, buf_len); + else + WCSCPYN(buf, p->b.getValueSafe(), buf_len); + return 1; +} + +int ConfigFile::getStringLen(const wchar_t *name) +{ + INCRITICALSECTION(cs); + if (name == NULL) return -1; + StringPair *p = getPair(name); + if (p == NULL) return -1; + return wcslen(p->b.getValue()); +} diff --git a/Src/Wasabi/api/config/config.h b/Src/Wasabi/api/config/config.h new file mode 100644 index 00000000..0f027b61 --- /dev/null +++ b/Src/Wasabi/api/config/config.h @@ -0,0 +1,43 @@ +#ifndef _CONFIG_H +#define _CONFIG_H + +#include +#include +#include +#include + +class StringPair : public Pair +{ +public: + StringPair(StringW &_a, const wchar_t *_b) + { + b=_b; + a.swap(_a); + } +}; + +class ConfigFile +{ +public: + ConfigFile(const wchar_t *section, const wchar_t *name); + ~ConfigFile(); + + static void initialize(); + + void setInt(const wchar_t *name, int val); + int getInt(const wchar_t *name, int default_val); + + void setString(const wchar_t *name, const wchar_t *str); + int getString(const wchar_t *name, wchar_t *buf, int buf_len, const wchar_t *default_str); + + int getStringLen(const wchar_t *name); + +private: + StringW sectionname; + StringW prettyname; + StringPair *getPair(const wchar_t *name); + StringPair *makePair(const wchar_t *name, const wchar_t *value); + CriticalSection cs; +}; + +#endif diff --git a/Src/Wasabi/api/config/configapi.cpp b/Src/Wasabi/api/config/configapi.cpp new file mode 100644 index 00000000..e66e00f8 --- /dev/null +++ b/Src/Wasabi/api/config/configapi.cpp @@ -0,0 +1,95 @@ +#include "precomp.h" +#include "configapi.h" +#include "../../studio/config.h" + +#include "../../studio/cfglist.h" + +config_api *configApi = NULL; + +static CfgList cfglist; + +void ConfigApi::config_registerCfgItem(CfgItem *cfgitem) { + cfglist.addItem(cfgitem); +} + +void ConfigApi::config_deregisterCfgItem(CfgItem *cfgitem) { + cfglist.delItem(cfgitem); +} + +int ConfigApi::config_getNumCfgItems() { + return cfglist.getNumItems(); +} + +CfgItem *ConfigApi::config_enumCfgItem(int n) { + return cfglist.enumItem(n); +} + +CfgItem *ConfigApi::config_getCfgItemByGuid(GUID g) { + return NULL;//cfglist.getByGuid(g); +} + +void ConfigApi::setIntPrivate(const char *name, int val) { + //config->setInt(name, val); +} + +int ConfigApi::getIntPrivate(const char *name, int def_val) { +/* int ret = config->getInt(name, def_val); + return ret;*/ + return 0; +} + +void ConfigApi::setIntArrayPrivate(const char *name, const int *val, int nval) { + /*if (nval > 256) return; + char buf[12*256]=""; + for (int i = 0; i < nval; i++) { + STRCAT(buf, StringPrintf("%d", val[i])); + if (i != nval-1) STRCAT(buf, ","); + } + config->setString(name, buf);*/ +} + +int ConfigApi::getIntArrayPrivate(const char *name, int *val, int nval) { +/* char buf[12*256]=""; + config->getString(name, buf, sizeof(buf), ""); + PathParser pp(buf, ","); + if (pp.getNumStrings() != nval) return 0; + for (int i = 0; i < nval; i++) { + *val = ATOI(pp.enumString(i)); + val ++; + } + return 1;*/ + return 1; +} + +void ConfigApi::setStringPrivate(const char *name, const char *str) { + //config->setString(name, str); +} + +int ConfigApi::getStringPrivate(const char *name, char *buf, int buf_len, const char *default_str) { +/* int ret = config->getString(name, buf, buf_len, default_str); + return ret;*/ + return 0; +} + +int ConfigApi::getStringPrivateLen(const char *name) { + //return config->getStringLen(name); + return 0; +} + +void ConfigApi::setIntPublic(const char *name, int val) { + //public_config->setInt(name, val); +} + +int ConfigApi::getIntPublic(const char *name, int def_val) { + //return public_config->getInt(name, def_val); + return 0; +} + +void ConfigApi::setStringPublic(const char *name, const char *str) { +// public_config->setString(name, str); +} +int ConfigApi::getStringPublic(const char *name, char *buf, int buf_len, const char *default_str) { +// return public_config->getString(name, buf, buf_len, default_str); + return 0; +} + diff --git a/Src/Wasabi/api/config/configapi.h b/Src/Wasabi/api/config/configapi.h new file mode 100644 index 00000000..2ea59f46 --- /dev/null +++ b/Src/Wasabi/api/config/configapi.h @@ -0,0 +1,32 @@ +#ifndef __CONFIG_API_H +#define __CONFIG_API_H + +#include "../../bfc/api/api_configi.h" + +class ConfigApi : public config_apiI { + public: + ConfigApi() {} + virtual ~ConfigApi() {} + + virtual void config_registerCfgItem(CfgItem *cfgitem); + virtual void config_deregisterCfgItem(CfgItem *cfgitem); + virtual int config_getNumCfgItems(); + virtual CfgItem *config_enumCfgItem(int n); + virtual CfgItem *config_getCfgItemByGuid(GUID g); + virtual void setIntPrivate(const wchar_t *name, int val); + virtual int getIntPrivate(const wchar_t *name, int def_val); + virtual void setIntArrayPrivate(const wchar_t *name, const int *val, int nval); + virtual int getIntArrayPrivate(const wchar_t *name, int *val, int nval); + virtual void setStringPrivate(const wchar_t *name, const wchar_t *str); + virtual int getStringPrivate(const wchar_t *name, wchar_t *buf, int buf_len, const wchar_t *default_str); + virtual int getStringPrivateLen(const wchar_t *name); + virtual void setIntPublic(const wchar_t *name, int val); + virtual int getIntPublic(const wchar_t *name, int def_val); + virtual void setStringPublic(const wchar_t *name, const wchar_t *str); + virtual int getStringPublic(const wchar_t *name, wchar_t *buf, int buf_len, const wchar_t *default_str); + + protected: +}; + + +#endif diff --git a/Src/Wasabi/api/config/filetypes.cpp b/Src/Wasabi/api/config/filetypes.cpp new file mode 100644 index 00000000..20298b99 --- /dev/null +++ b/Src/Wasabi/api/config/filetypes.cpp @@ -0,0 +1,576 @@ +#include "precomp.h" +#include "filetypes.h" +#include "api.h" +#include "main.h" +#include "core.h" + +#include +#include + +#include "../common/locales.h" +#include "../bfc/paramparser.h" + +// {DB26AA7F-0CF4-4e48-8AC8-49F9B9855A98} +static const GUID winampa_guid = +{ 0xdb26aa7f, 0xcf4, 0x4e48, { 0x8a, 0xc8, 0x49, 0xf9, 0xb9, 0x85, 0x5a, 0x98 } }; + +class Filetypes; + +class ExtensionAttrCallback : public AttrCallback { +public: + ExtensionAttrCallback(const char *extname, Filetypes *ft) : ext(extname), filetypes(ft) {} + virtual void onValueChange(Attribute *attr) { + Filetypes::registerExtension(ext, attr->getValueAsInt()); + api->cmd_sendCommand(winampa_guid,"extchange",0,0,attr,sizeof(attr)); // CT> notifies winampa.wac of the change + // (dunno if there is a better method) + filetypes->updateKeepers(); + } +private: + String ext; + Filetypes *filetypes; +}; + +class KeepersCB : public AttrCallback { +public: + KeepersCB(CfgItemI *_par) : par(_par) { } + virtual void onValueChange(Attribute *attr) { + //CT> This is REAL SLOW, for each attribute modified, you reregister them all, this needs to have + // an old list and just register/unregister what's new + char bufero[WA_MAX_PATH]=""; + char data[WA_MAX_PATH]=""; + attr->getData(bufero, WA_MAX_PATH-1); + ParamParser pp(bufero); + const char *ext=api->core_getSupportedExtensions(); + const char *p=ext; + while(*p!=0 && *(p+1)!=0) { + if(*p) { + int v = !!pp.hasString(p); + int r = par->cfgitem_getData(StringPrintf("extension/%s", p), data, WA_MAX_PATH-1); + if (r == 0 || (!!ATOI(data) != v)) { + par->cfgitem_setData(StringPrintf("extension/%s", p), StringPrintf(v)); + } + } + while(*p!=0) p++; + p++; + } + } +private: + CfgItemI *par; +}; + +#ifdef WIN32 +static void DCM_cb(int v) { + if (v) { + HKEY mp3Key; + char programname[MAX_PATH]; + GetModuleFileName(Main::gethInstance(),programname,sizeof(programname)); + if (RegCreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Classes\\Directory\\shell\\Winamp3.Play",&mp3Key) == ERROR_SUCCESS) { + const char *str=_("&Play in Winamp"); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,(unsigned char*)str,strlen(str) + 1); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Classes\\Directory\\shell\\Winamp3.Play\\command",&mp3Key) == ERROR_SUCCESS) { + StringPrintf mstr("\"%s\" \"%%1\"", programname); + const char *blah = mstr; + const unsigned char *microsoft_sucks_ass = (const unsigned char*)blah; + RegSetValueEx(mp3Key, NULL,0,REG_SZ,microsoft_sucks_ass,mstr.len() + 1); + RegCloseKey(mp3Key); + } + + if (RegCreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Classes\\Directory\\shell\\Winamp3.Enqueue",&mp3Key) == ERROR_SUCCESS) { + const char *str=_("&Enqueue in Winamp"); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,(unsigned char*)str,strlen(str) + 1); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Classes\\Directory\\shell\\Winamp3.Enqueue\\command",&mp3Key) == ERROR_SUCCESS) { + StringPrintf mstr("\"%s\" /ADD \"%%1\"", programname); + const char *blah = mstr; + const unsigned char *microsoft_sucks_ass = (const unsigned char*)blah; + RegSetValueEx(mp3Key, NULL,0,REG_SZ,microsoft_sucks_ass,mstr.len() + 1); + RegCloseKey(mp3Key); + } + } else { + Filetypes::myRegDeleteKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Classes\\Directory\\shell\\Winamp3.Play"); + Filetypes::myRegDeleteKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Classes\\Directory\\shell\\Winamp3.Enqueue"); + } +} +#endif + +// {C30C97E6-77E6-4da4-9F4F-C7F848F8F641} +const GUID filetypes_guid = +{ 0xc30c97e6, 0x77e6, 0x4da4, { 0x9f, 0x4f, 0xc7, 0xf8, 0x48, 0xf8, 0xf6, 0x41 } }; + +Filetypes::Filetypes() : CfgItemI("Filetypes", filetypes_guid) { } + +void Filetypes::registerAttributes() { + const char *ext=api->core_getSupportedExtensions(); + if (ext == NULL) return; //BU + + _bool *wantExtensions; + registerAttribute(wantExtensions = new _bool("Register associations on Winamp startup", TRUE)); + + const char *p=ext; + while(*p!=0 && *(p+1)!=0) { + if(*p) { + _bool *extenabled; + registerAttribute(extenabled = new _bool(StringPrintf("extension/%s", p), FALSE), new ExtensionAttrCallback(p, this)); + if (*wantExtensions) registerExtension(p, *extenabled); + } while(*p!=0) p++; + p++; + } + + registerAttribute(new _string("keepers"), new KeepersCB(this)); + +#ifdef WIN32 + registerAttribute(new _bool("Directory context menus", TRUE), new int_attrCB(DCM_cb)); +#endif + + // Always steal the ".wal" extension. + CfgItem *cift=WASABI_API_CONFIG->config_getCfgItemByGuid(filetypes_guid); + if (cift) { + cift->setDataAsInt("extension/wal",1); + } + + updateKeepers(); +} + +void Filetypes::updateKeepers() { + static int reentry=0; + if (reentry) return; + const char *ext=api->core_getSupportedExtensions(); + if (ext == NULL) return; //BU + + reentry = 1; + const char *p=ext; + String kstr; + while(*p!=0 && *(p+1)!=0) { + if(*p) { + _bool *extenabled = static_cast<_bool *>(getAttributeByName(StringPrintf("extension/%s", p))); + if (*extenabled) { + if (!kstr.isempty()) kstr += ";"; + kstr += p; + } + } while(*p!=0) p++; + p++; + } + _string *k = static_cast<_string *>(getAttributeByName("keepers")); + k->setValue(kstr); + reentry = 0; +} + +LONG Filetypes::myRegDeleteKeyEx(HKEY thiskey, LPCTSTR lpSubKey) +{ +#ifdef WIN32 + HKEY key; + int retval=RegOpenKey(thiskey,lpSubKey,&key); + if (retval==ERROR_SUCCESS) + { + char buffer[1024]; + while (RegEnumKey(key,0,buffer,1024)==ERROR_SUCCESS) + if ((retval=myRegDeleteKeyEx(key,buffer)) != ERROR_SUCCESS) break; + RegCloseKey(key); + retval=RegDeleteKey(thiskey,lpSubKey); + } + return retval; +#else + DebugString( "portme -- Filetypes::myRegDeleteKeyEx\n" ); + return 0; +#endif +} + +int Filetypes::isRegistered(const char *ext) { + char b[256]; + int rval=0; + unsigned long vt,s=sizeof(b); + HKEY key; + SPRINTF(b,".%s",ext); +#ifdef WIN32 + if (RegOpenKey(HKEY_CLASSES_ROOT,b,&key) != ERROR_SUCCESS) return 0; + if (RegQueryValueEx(key,NULL,0,&vt,b,&s) == ERROR_SUCCESS) { + if (vt != REG_SZ || (strcmp(b,"Winamp3.File") && strcmp(b,"Winamp3.PlayList") && strcmp(b,"Winamp3.SkinZip"))) rval=0; + else rval=1; + } else rval=0; + RegCloseKey(key); +#else +DebugString( "portme -- FileTypes::isRegistered\n" ); +#endif + return rval; +} + +void Filetypes::regmimetype(const char *mtype, const char *programname, const char *ext, int nsonly) { +#ifdef WIN32 + HKEY mp3Key; + if (!nsonly) { + char s[MAX_PATH]; + // Changed these to create rather than just open the mimetypes in the database. + if (RegCreateKey(HKEY_CLASSES_ROOT,ext,&mp3Key) == ERROR_SUCCESS) { + RegSetValueEx(mp3Key,"Content Type",0,REG_SZ,mtype,STRLEN(mtype) + 1); + RegCloseKey(mp3Key); + } + wsprintf(s,"MIME\\Database\\Content Type\\%s",mtype); + if (RegCreateKey(HKEY_CLASSES_ROOT,s,&mp3Key) == ERROR_SUCCESS) { + RegDeleteValue(mp3Key,"CLSID"); + RegSetValueEx(mp3Key,"Extension",0,REG_SZ,ext,strlen(ext) + 1); + RegCloseKey(mp3Key); + } + } + if (RegOpenKey(HKEY_CURRENT_USER,"Software\\Netscape\\Netscape Navigator\\Viewers",&mp3Key) == ERROR_SUCCESS) { + int x; + RegSetValueEx(mp3Key, mtype,0,REG_SZ,programname,strlen(programname) + 1); + for (x = 0; x < 999; x ++) { + char st[100]; + DWORD vt; + DWORD s=128; + char b[128]; + wsprintf(st,"TYPE%d",x); + if (RegQueryValueEx(mp3Key,st,0,&vt,b,&s) == ERROR_SUCCESS) { + if (!strcmp(b,mtype)) break; + } else { + RegSetValueEx(mp3Key,st,0,REG_SZ,mtype,strlen(mtype)+1); + break; + } + } + RegCloseKey(mp3Key); + } +#else +DebugString( "portme -- Filetypes::regmimetype\n" ); +#endif +} + +void Filetypes::registerExtension(const char *ext, int reg) { +#ifdef WIN32 + createWinampTypes(); + + char b[128]; + HKEY mp3Key; + char *which_str="Winamp3.File"; + + if (!_stricmp(ext,"m3u") || !_stricmp(ext,"pls")) which_str="Winamp3.PlayList"; + if (!_stricmp(ext,"wsz") || !_stricmp(ext,"wpz") || !_stricmp(ext,"wal")) + which_str="Winamp3.SkinZip"; + wsprintf(b,".%s",ext); + if (reg && !_stricmp(ext,"pls")) { + char programname[MAX_PATH]; + GetModuleFileName(Main::gethInstance(),programname,sizeof(programname)); + regmimetype("audio/x-scpls", programname,".pls",1); + regmimetype("audio/scpls", programname,".pls",1); + } + if (reg && !_stricmp(ext,"wma")) { + char programname[MAX_PATH]; + GetModuleFileName(Main::gethInstance(),programname,sizeof(programname)); + regmimetype("audio/x-ms-wma", programname,".wma",1); + regmimetype("application/x-msdownload", programname,".wma",1); + } + if (reg && !_stricmp(ext,"m3u")) { + char programname[MAX_PATH]; + GetModuleFileName(Main::gethInstance(),programname,sizeof(programname)); + regmimetype("audio/x-mpegurl", programname,".m3u",1); + regmimetype("audio/mpegurl", programname,".m3u",1); + } + if (reg && !_stricmp(ext,"mp3")) { + char programname[MAX_PATH]; + GetModuleFileName(Main::gethInstance(),programname,sizeof(programname)); + regmimetype("audio/x-mpeg", programname,".mp3",1); + regmimetype("audio/x-mp3", programname,".mp3",1); + regmimetype("audio/x-mpg", programname,".mp3",1); + regmimetype("audio/mp3", programname,".mp3",1); + regmimetype("audio/mpg", programname,".mp3",1); + regmimetype("audio/mpeg", programname,".mp3",1); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,b,&mp3Key) == ERROR_SUCCESS) { + if (reg) { + unsigned long s=sizeof(b); + if (RegQueryValueEx(mp3Key,NULL,0,NULL,b,&s) == ERROR_SUCCESS) { + if (strcmp(b,which_str)) { + RegSetValueEx(mp3Key,"Winamp_Back",0,REG_SZ,b,strlen(b)+1); + RegSetValueEx(mp3Key,NULL,0,REG_SZ,which_str,strlen(which_str)+1); + } + } else RegSetValueEx(mp3Key,NULL,0,REG_SZ,which_str,strlen(which_str)+1); + } else { + unsigned long s=sizeof(b); + if (RegQueryValueEx(mp3Key,NULL,0,NULL,b,&s) == ERROR_SUCCESS) { + if (!strcmp(b,which_str)) { + s=sizeof(b); + if (RegQueryValueEx(mp3Key,"Winamp_Back",0,NULL,b,&s) == ERROR_SUCCESS) { + if (RegSetValueEx(mp3Key, NULL,0,REG_SZ,b,strlen(b)+1) == ERROR_SUCCESS) + RegDeleteValue(mp3Key,"Winamp_Back"); + } else { + RegDeleteValue(mp3Key,NULL); + RegCloseKey(mp3Key); + mp3Key=NULL; + wsprintf(b,".%s",ext); + myRegDeleteKeyEx(HKEY_CLASSES_ROOT,b); + } + } + } + } + if (mp3Key) RegCloseKey(mp3Key); + } +#else +DebugString( "portme -- Filetypes::registerExtensions\n" ); +#endif +} + +void Filetypes::createWinampTypes() { +#ifdef WIN32 + HKEY mp3Key; + char programname[MAX_PATH]; + char str[MAX_PATH+32]; + char buf[128]="Winamp3.File"; + char buf2[128]="Winamp3.PlayList"; + char buf3[128]="Winamp3.SkinZip"; + if (!GetModuleFileName(Main::gethInstance(),programname,sizeof(programname))) return; + + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.File",&mp3Key) == ERROR_SUCCESS) { + strcpy(str,"Winamp media file"); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str)+1); + RegCloseKey(mp3Key); + } + + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.File\\DefaultIcon",&mp3Key) == ERROR_SUCCESS) { + wsprintf(str,"%s,%d",programname,whichicon); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str)+1); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.File\\shell",&mp3Key) == ERROR_SUCCESS) { + if (addtolist) + RegSetValueEx(mp3Key, NULL,0,REG_SZ,"Enqueue",8); + else + RegSetValueEx(mp3Key, NULL,0,REG_SZ,"Play",5); + RegCloseKey(mp3Key); + } + + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.File\\shell\\Play",&mp3Key) == ERROR_SUCCESS) { + const char *str=_("&Play in Winamp"); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str)+1); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.File\\shell\\Play\\command",&mp3Key) == ERROR_SUCCESS) { + wsprintf(str,"\"%s\" \"%%1\"",programname); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str) + 1); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.File\\shell\\open",&mp3Key) == ERROR_SUCCESS) { + RegSetValueEx(mp3Key, NULL,0,REG_SZ,"",1); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.File\\shell\\open\\command",&mp3Key) == ERROR_SUCCESS) { + wsprintf(str,"\"%s\" \"%%1\"",programname); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str) + 1); + RegCloseKey(mp3Key); + } + + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.File\\shell\\Enqueue",&mp3Key) == ERROR_SUCCESS) { + const char *str=_("&Enqueue in Winamp"); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str) + 1); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.File\\shell\\Enqueue\\command",&mp3Key) == ERROR_SUCCESS) { + wsprintf(str,"\"%s\" /ADD \"%%1\"",programname); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str) + 1); + RegCloseKey(mp3Key); + } + + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.File\\shell\\ListBookmark",&mp3Key) == ERROR_SUCCESS) { + const char *str=_("Add to Winamp's &Bookmark list"); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str) + 1); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.File\\shell\\ListBookmark\\command",&mp3Key) == ERROR_SUCCESS) { + wsprintf(str,"\"%s\" /BOOKMARK \"%%1\"",programname); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str) + 1); + RegCloseKey(mp3Key); + } + + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.Playlist",&mp3Key) == ERROR_SUCCESS) { + strcpy(str,"Winamp playlist file"); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str)+1); + str[0]=0; + str[1]=0; + str[2]=1; + str[3]=0; + RegSetValueEx(mp3Key, "EditFlags",0,REG_BINARY,str,4); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.PlayList\\DefaultIcon",&mp3Key) == ERROR_SUCCESS) { + wsprintf(str,"%s,%d",programname,whichicon2); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str)+1); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.PlayList\\shell",&mp3Key) == ERROR_SUCCESS) { + if (addtolist) + RegSetValueEx(mp3Key, NULL,0,REG_SZ,"Enqueue",8); + else + RegSetValueEx(mp3Key, NULL,0,REG_SZ,"Play",5); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.PlayList\\shell\\Play",&mp3Key) == ERROR_SUCCESS) { + const char *str=_("&Play in Winamp"); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str)+1); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.PlayList\\shell\\Play\\command",&mp3Key) == ERROR_SUCCESS) { + wsprintf(str,"\"%s\" \"%%1\"",programname); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str) + 1); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.PlayList\\shell\\open",&mp3Key) == ERROR_SUCCESS) { + RegSetValueEx(mp3Key, NULL,0,REG_SZ,"",1); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.PlayList\\shell\\open\\command",&mp3Key) == ERROR_SUCCESS) { + wsprintf(str,"\"%s\" \"%%1\"",programname); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str) + 1); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.PlayList\\shell\\Enqueue",&mp3Key) == ERROR_SUCCESS) { + const char *str=_("&Enqueue in Winamp"); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str)+1); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.PlayList\\shell\\Enqueue\\command",&mp3Key) == ERROR_SUCCESS) { + wsprintf(str,"\"%s\" /ADD \"%%1\"",programname); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str) + 1); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.PlayList\\shell\\ListBookmark",&mp3Key) == ERROR_SUCCESS) { + const char *str=_("Add to Winamp's &Bookmark list"); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str)+1); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.PlayList\\shell\\ListBookmark\\command",&mp3Key) == ERROR_SUCCESS) { + wsprintf(str,"\"%s\" /BOOKMARK \"%%1\"",programname); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str) + 1); + RegCloseKey(mp3Key); + } + + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.SkinZip",&mp3Key) == ERROR_SUCCESS) { + strcpy(str,"Winamp3 skin file"); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str)+1); + str[0]=0; + str[1]=0; + str[2]=1; + str[3]=0; + RegSetValueEx(mp3Key, "EditFlags",0,REG_BINARY,str,4); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.SkinZip\\DefaultIcon",&mp3Key) == ERROR_SUCCESS) { + wsprintf(str,"%s,%d",programname,whichicon); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str)+1); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.SkinZip\\shell",&mp3Key) == ERROR_SUCCESS) { + RegSetValueEx(mp3Key, NULL,0,REG_SZ,"Install and switch to",8); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.SkinZip\\shell\\install",&mp3Key) == ERROR_SUCCESS) { + RegSetValueEx(mp3Key, NULL,0,REG_SZ,"",1); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.SkinZip\\shell\\install\\command",&mp3Key) == ERROR_SUCCESS) { + wsprintf(str,"\"%s\" \"/installskin=%%1\"",programname); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str) + 1); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.SkinZip\\shell\\open",&mp3Key) == ERROR_SUCCESS) { + RegSetValueEx(mp3Key, NULL,0,REG_SZ,"",1); + RegCloseKey(mp3Key); + } + if (RegCreateKey(HKEY_CLASSES_ROOT,"Winamp3.SkinZip\\shell\\open\\command",&mp3Key) == ERROR_SUCCESS) { + wsprintf(str,"\"%s\" \"/installskin=%%1\"",programname); + RegSetValueEx(mp3Key, NULL,0,REG_SZ,str,strlen(str) + 1); + RegCloseKey(mp3Key); + } + + // Register the mimetypes to act like .wal files? + +// regmimetype("interface/x-winamp-skin", programname,".wsz",0); + regmimetype("interface/x-winamp-skin", programname,".wal",0); +// regmimetype("interface/x-winamp3-skin", programname,".wsz",0); + regmimetype("interface/x-winamp3-skin", programname,".wal",0); +// regmimetype("application/x-winamp-plugin", programname,"wpz",0); +#else +DebugString( "portme -- Filetypes::createWinampTypes\n" ); +#endif +} + +int Filetypes::isCdPlayer() { + int r=0; +#ifdef WIN32 + unsigned long s; + HKEY mp3Key; + char buf[MAX_PATH],buf2[MAX_PATH]="\""; + if (!GetModuleFileName(Main::gethInstance(),buf2+1,sizeof(buf2)-8)) return 0; + if (RegOpenKey(HKEY_CLASSES_ROOT,"AudioCD\\shell\\play\\command",&mp3Key) != ERROR_SUCCESS) return 0; + strcat(buf2,"\" /CDA:%1"); + s=sizeof(buf); + if (RegQueryValueEx(mp3Key,NULL,0,NULL,buf,&s) == ERROR_SUCCESS) + { + if (!lstrcmpi(buf,buf2)) r=1; + } + RegCloseKey(mp3Key); +#else +DebugString( "portme -- Filetypes::isCdPlayer\n" ); +#endif + return r; +} + +void Filetypes::registerCdPlayer(int reg) { +#ifdef WIN32 + char b[MAX_PATH]; + char buf2[MAX_PATH]="\""; + HKEY mp3Key; + if (!GetModuleFileName(Main::gethInstance(),buf2+1,sizeof(buf2)-8)) return; + strcat(buf2,"\" /CDA:%1"); + if (RegOpenKey(HKEY_CLASSES_ROOT,"AudioCD\\shell\\play\\command",&mp3Key) == ERROR_SUCCESS) + { + if (reg) + { + unsigned long s=sizeof(b); + if (RegQueryValueEx(mp3Key,NULL,0,NULL,b,&s) == ERROR_SUCCESS) + { + if (_stricmp(b,buf2)) + { + char buf3[MAX_PATH]; + unsigned long st=sizeof(buf3); + if (RegQueryValueEx(mp3Key,"Winamp_Back",0,NULL,buf3,&st) != ERROR_SUCCESS || + _stricmp(buf3,b)) + { + RegSetValueEx(mp3Key,"Winamp_Back",0,REG_SZ,b,strlen(b)+1); + } + RegSetValueEx(mp3Key,NULL,0,REG_SZ,buf2,strlen(buf2)+1); + } + } else RegSetValueEx(mp3Key,NULL,0,REG_SZ,buf2,strlen(buf2)+1); + } + else + { + unsigned long s=sizeof(b); + if (RegQueryValueEx(mp3Key,NULL,0,NULL,b,&s) == ERROR_SUCCESS) + { + if (!strcmp(b,buf2)) + { + s=sizeof(b); + if (RegQueryValueEx(mp3Key,"Winamp_Back",0,NULL,b,&s) == ERROR_SUCCESS) + { + if (!_stricmp(b,buf2)) b[0]=0; + if (RegSetValueEx(mp3Key, NULL,0,REG_SZ,b,strlen(b)+1) == ERROR_SUCCESS) + RegDeleteValue(mp3Key,"Winamp_Back"); + } + else + { + buf2[0]=0; + RegSetValueEx(mp3Key,NULL,0,REG_SZ,buf2,strlen(buf2)+1); + } + } + } + } + RegCloseKey(mp3Key); + } +#else +DebugString( "portme -- Filetypes::isCdPlayer\n" ); +#endif +} + +int Filetypes::whichicon=1; +int Filetypes::whichicon2=1; +int Filetypes::addtolist=0; diff --git a/Src/Wasabi/api/config/filetypes.h b/Src/Wasabi/api/config/filetypes.h new file mode 100644 index 00000000..4d7e6891 --- /dev/null +++ b/Src/Wasabi/api/config/filetypes.h @@ -0,0 +1,46 @@ +#ifndef _FILETYPES_H +#define _FILETYPES_H + +#include + +#define FILETYPES_PARENT CfgItemI +class Filetypes : public FILETYPES_PARENT { +public: + Filetypes(); + void registerAttributes(); + + static int isRegistered(const char *ext); + static void registerExtension(const char *ext, int reg); + static int isCdPlayer(); + static void registerCdPlayer(int reg); + + void updateKeepers(); + +private: + + static void createWinampTypes(); + static void regmimetype(const char *mtype, const char *programname, const char *ext, int nsonly); + + // workaround for (damn) c++ type checking + static LONG RegQueryValueEx(HKEY hKey, LPTSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, char *lpData, LPDWORD lpcbData) { +#ifdef WIN32 + return ::RegQueryValueEx(hKey, lpValueName, lpReserved, lpType, (unsigned char *)lpData, lpcbData); +#endif + } + static LONG RegSetValueEx(HKEY hKey, LPCTSTR lpValueName, DWORD Reserved, DWORD dwType, char *lpData, DWORD cbData) { +#ifdef WIN32 + return ::RegSetValueEx(hKey, lpValueName, Reserved, dwType, (const unsigned char *)lpData, cbData); +#endif + } + static LONG RegSetValueEx(HKEY hKey, LPCTSTR lpValueName, DWORD Reserved, DWORD dwType, const char *lpData, DWORD cbData) { +#ifdef WIN32 + return ::RegSetValueEx(hKey, lpValueName, Reserved, dwType, (const unsigned char *)lpData, cbData); +#endif + } +public: + static LONG myRegDeleteKeyEx(HKEY thiskey, LPCTSTR lpSubKey); + + static int whichicon, whichicon2, addtolist; +}; + +#endif diff --git a/Src/Wasabi/api/config/items/attrbool.h b/Src/Wasabi/api/config/items/attrbool.h new file mode 100644 index 00000000..324a2e11 --- /dev/null +++ b/Src/Wasabi/api/config/items/attrbool.h @@ -0,0 +1,65 @@ +#ifndef _ATTRBOOL_H +#define _ATTRBOOL_H + +#include "attribute.h" + +// inherit from this one, or just use it + +/** + Boolean configuration attributes have two values, true or false. + They can be used like any other config item. + + @short Boolean configuration attribute. + @ver 1.0 + @author Nullsoft + @see _int + @see _string + @see _float +*/ +class _bool : public Attribute { +public: + /** + Optionally set the name and default value of + your configuration attribute during construction. + + @param name Name of the configuration attribute. + @param default_val Default value. + */ + _bool(const wchar_t *name=NULL, int default_val=0) : Attribute(name) { + setValueAsInt(!!default_val, true); + } + + // convenience operators + /** + Get the value of the attribute. + */ + operator bool() { return !!getValueAsInt(); } + + /** + Set the value of the attribute. + */ + bool operator =(int newval) { setValueAsInt(!!newval); return *this; } + + // from Attribute + + /** + Get the attribute type. This will return + a constant representing the attribute type. + + These constants can be: BOOL, FLOAT, STRING and INT. + + @see AttributeType + @ret The attribute type. + */ + virtual int getAttributeType() { return AttributeType::BOOL; } + + /** + Get the configuration group to be used to represent + this attribute in the registry. + + @ret Config group to be used. + */ + virtual const wchar_t *getConfigGroup() { return L"studio.configgroup.bool"; } +}; + +#endif diff --git a/Src/Wasabi/api/config/items/attrcb.h b/Src/Wasabi/api/config/items/attrcb.h new file mode 100644 index 00000000..3aa0e41d --- /dev/null +++ b/Src/Wasabi/api/config/items/attrcb.h @@ -0,0 +1,127 @@ +#ifndef _ATTRCB_H +#define _ATTRCB_H + +#include "attribute.h" + +/** + Enables you to register callbacks on + a specific attribute to monitor if it's + value has been changed by the user or other. + + This class is not meant to be used on it's own. + Please derive from it instead. + + @short Attribute callback + @ver 1.0 + @author Nullsoft + @see Attribute + @see int_attrCB + @see _int + @see _float + @see _string + @see _bool +*/ +class AttrCallback { +public: + /** + Does nothing. + */ + virtual ~AttrCallback() {} + + /** + Event triggered when the value of the attribute, + for which this callback has been registered, changes. + + This is a pure virtual, please override to implement + your custom behavior. + + @param attr Attribute for which the value has changed. + */ + virtual void onValueChange(Attribute *attr)=0; +}; + +/** + Enables you to register callbacks on a specific + integer or boolean attribute to monitor if the + value has been changed by the user or other. + + @short Integer or Boolean attribute Callback. + @ver 1.0 + @author Nullsoft + @see Attribute + @see _int + @see _bool +*/ +class int_attrCB : public AttrCallback { + typedef void (*fnPtrType)(int); +public: + /** + Upon construction, you must specify which + function will be called when the value of + the attribute has indeed changed. + + This is done using a pointer to the function. + The function must accept one parameter of type + int, like so: void myfunc(int val); + + @param _fn Pointer to the function to use on value change. + */ + int_attrCB(fnPtrType _fn) { fnptr = _fn; } + + /** + Event triggered when the value of the attribute, + for which this callback has been registered, changes. + + Override this to implement your own behavior. + The default is to send the new value of the attribute + to a function which you specify upon construction + of this object. + + @param attr Attribute for which the value has changed. + */ + virtual void onValueChange(Attribute *attr) { + ASSERT(attr->getAttributeType() == AttributeType::INT || + attr->getAttributeType() == AttributeType::BOOL); + (*fnptr)(attr->getValueAsInt()); + } +private: + fnPtrType fnptr; +}; + +class string_attrCB : public AttrCallback { + typedef void (*fnPtrType)(const wchar_t *); +public: + /** + Upon construction, you must specify which + function will be called when the value of + the attribute has indeed changed. + + This is done using a pointer to the function. + The function must accept one parameter of type + int, like so: void myfunc(const char *val); + + @param _fn Pointer to the function to use on value change. + */ + string_attrCB(fnPtrType _fn) { fnptr = _fn; } + + /** + Event triggered when the value of the attribute, + for which this callback has been registered, changes. + + Override this to implement your own behavior. + The default is to send the name of the attribute + to a function which you specify upon construction + of this object. + + @param attr Attribute for which the value has changed. + */ + virtual void onValueChange(Attribute *attr) + { + ASSERT(attr->getAttributeType() == AttributeType::STRING); + (*fnptr)(attr->getAttributeName()); + } +private: + fnPtrType fnptr; +}; + +#endif diff --git a/Src/Wasabi/api/config/items/attrfloat.h b/Src/Wasabi/api/config/items/attrfloat.h new file mode 100644 index 00000000..056f0c46 --- /dev/null +++ b/Src/Wasabi/api/config/items/attrfloat.h @@ -0,0 +1,52 @@ +#ifndef _ATTRFLOAT_H +#define _ATTRFLOAT_H + +#include "attribute.h" + +// actually it's a double :) + +class _float : public Attribute { +public: + /** + Optionally set the name and default value of + your configuration attribute during construction. + + @param name Name of the configuration attribute. + @param default_val Default value. + */ + _float(const wchar_t *name=NULL, double default_val=0.f) : Attribute(name) { + setValueAsDouble(default_val, true); + } + + /** + Get the attribute type. This will return + a constant representing the attribute type. + + These constants can be: BOOL, FLOAT, STRING and INT. + + @see AttributeType + @ret The attribute type. + */ + virtual int getAttributeType() { return AttributeType::FLOAT; } + + /** + Get the configuration group to be used to represent + this attribute in the registry. + + @ret Config group to be used. + */ + virtual const wchar_t *getConfigGroup() { return L"studio.configgroup.float"; } + + // convenience operators + /** + Get the value of the attribute. + */ + operator double() { return getValueAsDouble(); } + + /** + Set the value of the attribute. + */ + double operator =(double newval) { return setValueAsDouble(newval) ? newval : getValueAsDouble(); } +}; + +#endif diff --git a/Src/Wasabi/api/config/items/attrfn.h b/Src/Wasabi/api/config/items/attrfn.h new file mode 100644 index 00000000..54f46df0 --- /dev/null +++ b/Src/Wasabi/api/config/items/attrfn.h @@ -0,0 +1,15 @@ +#ifndef _ATTRFN_H +#define _ATTRFN_H + +#include "attrstr.h" + +class _filename : public _string { +public: + _filename(const wchar_t *name, const wchar_t *default_val=L"") + : _string(name, default_val) { } + + virtual int getAttributeType() { return AttributeType::FILENAME; } + virtual const wchar_t *getConfigGroup() { return L"studio.configgroup.filename"; } +}; + +#endif diff --git a/Src/Wasabi/api/config/items/attrhandler.h b/Src/Wasabi/api/config/items/attrhandler.h new file mode 100644 index 00000000..c2624f46 --- /dev/null +++ b/Src/Wasabi/api/config/items/attrhandler.h @@ -0,0 +1,129 @@ +//!## An object to multiplex the callbacks of multiple attributes. +#ifndef _ATTRHANDLER_H +#define _ATTRHANDLER_H + +// This class is meant to be subclassed. The methods you must provide +// are given as pure virtuals. See ExampleAttrib for more details, and +// an example subclass that you can copy for your own use. + +#include "attrcb.h" +#include "attribs.h" +#include + +// +// Forward References +class WAComponentClient; +class Attribute; + + +// +// Class Definition +template +class AttrHandler { +protected: + // Heh, oops. Can't have one AttrCallback handle lots of different attribs, anymore. I fix. + class AttrHandlerChild : public AttrCallback { + public: + AttrHandlerChild(AttrHandler *_parent) : AttrCallback() { + ASSERT(_parent != NULL); + recursion = 0; + callback = NULL; + parent = _parent; + } + + // Here is where we split out the different value types + virtual void onValueChange(Attribute *attr) { + if (!recursion) { + // protect our programmers from stack overflow, please. + recursion = 1; + if ((callback != NULL) && (parent != NULL)) { + int id; + // find the id from the map (friendly) + int success = parent->attribmap.getItem(attr,&id); + if (success) { + // and send it to the proper handling function (poorman's RTTI) + switch (attr->getAttributeType()) { + case AttributeType::INT: + callback->onIntChange(id,*static_cast<_int *>(attr)); + break; + case AttributeType::BOOL: + callback->onBoolChange(id, *static_cast<_bool *>(attr)); + break; + case AttributeType::FLOAT: + callback->onFloatChange(id, *static_cast<_float *>(attr)); + break; + case AttributeType::STRING: + callback->onStringChange(id, *static_cast<_string *>(attr)); + break; + } + } + } + recursion = 0; + } + } + + virtual void bindCallbackObj(TCallback *callbackobj) { + // Be advised, this may be null. That's okay, we test for it above. + callback = callbackobj; + } + private: + int recursion; + TCallback *callback; + AttrHandler *parent; + }; + +public: + AttrHandler() { + component = NULL; + callback = NULL; + } + + // Call this method to bind your component (in your component's constructor) + virtual void bindComponent(WAComponentClient *parentcomponent) { + component = parentcomponent; + } + + // Call this method to bind your callback object (usually your window in its constructor) + virtual void bindCallbackObj(TCallback *callbackobj) { + // Bind ourselves. + callback = callbackobj; + + // Then go through and rebind any children. + int i, num = attrchildren.getNumItems(); + for (i = 0; i < num; i++) { + AttrHandlerChild *child = attrchildren.enumItem(i); + child->bindCallbackObj(callback); + } + } + + // Call this method to register each attribute. + virtual void registerAttribute(Attribute *attr, int id) { + ASSERTPR(component != NULL, "BIND YOUR COMPONENT before registering Attributes to a Handler."); + // register the attrib with a child object as its callback + AttrHandlerChild *child = new AttrHandlerChild(this); + attrchildren.addItem(child); + component->registerAttribute(attr, child); + // and save its id mapping + attribmap.addItem(attr, id); + } + +#if 0 + // Your callback object (probably your primary window class) must implement + // its own versions of these methods here. They will be called by the + // switch statement below. + virtual void onIntChange(int id, int *attr); + virtual void onBoolChange(int id, bool *attr); + virtual void onFloatChange(int id, double *attr); + virtual void onStringChange(int id, const char *attr); +#endif + + +private: + friend AttrHandlerChild; + TCallback *callback; + WAComponentClient *component; + Map< Attribute *, int > attribmap; + PtrList attrchildren; +}; + +#endif // _ATTRHANDLER_H diff --git a/Src/Wasabi/api/config/items/attribs.h b/Src/Wasabi/api/config/items/attribs.h new file mode 100644 index 00000000..1e35f78b --- /dev/null +++ b/Src/Wasabi/api/config/items/attribs.h @@ -0,0 +1,12 @@ +#ifndef _ATTRIBS_H +#define _ATTRIBS_H + +// a convenience header to get all the attrib types in one whack + +#include "attrbool.h" +#include "attrfloat.h" +#include "attrint.h" +#include "attrstr.h" +#include "attrfn.h" + +#endif diff --git a/Src/Wasabi/api/config/items/attribute.cpp b/Src/Wasabi/api/config/items/attribute.cpp new file mode 100644 index 00000000..27b519b6 --- /dev/null +++ b/Src/Wasabi/api/config/items/attribute.cpp @@ -0,0 +1,131 @@ +#include + +#include "attribute.h" +#include + + +Attribute::Attribute(const wchar_t *newname, const wchar_t *_desc) : + NamedW(newname), desc(_desc), cfgitemi(NULL), private_storage(NULL) { } + +Attribute::~Attribute() { + delete private_storage; +} + +const wchar_t *Attribute::getAttributeName() { + return NamedW::getName(); +} + +const wchar_t *Attribute::getAttributeDesc() { + return desc; +} + +int Attribute::getValueAsInt() +{ + wchar_t buf[1024]=L""; + getData(buf, 1024); + return WTOI(buf); +} + +int Attribute::setValueAsInt(int newval, bool def) +{ + return setData(StringPrintfW(newval), def); +} + +double Attribute::getValueAsDouble() +{ + wchar_t buf[1024] = {0}; + getData(buf, 1024); + return WTOF(buf); +} + +double Attribute::setValueAsDouble(double newval, bool def) +{ + return setData(StringPrintfW(newval), def); +} + +int Attribute::getDataLen() { + if (private_storage != NULL) + return (int)private_storage->len()+1; + + ASSERTPR(WASABI_API_CONFIG != NULL, "getDataLen() before API"); + int r = WASABI_API_CONFIG->getStringPrivateLen(mkTag()); + if (r < 0) { + r = (int)default_val.len()+1; + } + return r; +} + +int Attribute::getData(wchar_t *data, int data_len) +{ + if (data == NULL || data_len < 0) + return 0; + if (private_storage != NULL) + { + if (private_storage->isempty()) + { + if (data_len >= 1) { + *data = 0; + return 1; + } + return 0; + } + WCSCPYN(data, private_storage->getValue(), data_len); + return MIN((int)private_storage->len(), data_len); + } + ASSERTPR(WASABI_API_CONFIG != NULL, "can't get without api"); + if (WASABI_API_CONFIG == NULL) return 0; + int r = WASABI_API_CONFIG->getStringPrivate(mkTag(), data, data_len, default_val.isempty() ? L"" : default_val.getValue()); + return r; +} + +int Attribute::setData(const wchar_t *data, bool def) +{ + if (def) { // setting default value + default_val = data; + return 1; + } + ASSERTPR(WASABI_API_CONFIG != NULL, "can't set data before api"); + if (WASABI_API_CONFIG == NULL) return 0; + + int r = setDataNoCB(data); + if (r && cfgitemi != NULL) cfgitemi->cfgitem_onAttribSetValue(this); + return r; +} + +int Attribute::setDataNoCB(const wchar_t *data) +{ + if (private_storage != NULL) { + private_storage->setValue(data); + } else { + WASABI_API_CONFIG->setStringPrivate(mkTag(), data); + } + dependent_sendEvent(Attribute::depend_getClassGuid(), Event_DATACHANGE); + return 1; +} + +void Attribute::setCfgItem(CfgItemI *item) +{ + delete private_storage; private_storage = NULL; + ASSERT(cfgitemi == NULL || item == NULL); + cfgitemi = item; + if (cfgitemi != NULL) + { + if (cfgitemi->cfgitem_usePrivateStorage()) + private_storage = new StringW; + } +} + +StringW Attribute::mkTag() +{ + StringW ret; + if (cfgitemi) + { + ret = cfgitemi->cfgitem_getPrefix(); + } + ret.cat(getName()); + return ret; +} + +void Attribute::disconnect() { + setCfgItem(NULL); +} diff --git a/Src/Wasabi/api/config/items/attribute.h b/Src/Wasabi/api/config/items/attribute.h new file mode 100644 index 00000000..c91e8065 --- /dev/null +++ b/Src/Wasabi/api/config/items/attribute.h @@ -0,0 +1,218 @@ +#ifndef _ATTRIBUTE_H +#define _ATTRIBUTE_H + +#include +#include +#include +#include + +class CfgItemI; + +// lowercase types are reserved for official Nullsoft use +// uppercase are 3rd-party defined +namespace AttributeType { + /** + Attribute types. + */ + enum { + NONE = 0, + INT = MK3CC('i','n','t'), // attrint.h + STRING = MK3CC('s','t','r'), // attrstr.h + BOOL = MK4CC('b','o','o','l'), // attrbool.h + FLOAT = MK4CC('f','l','o','t'), // attrfloat.h + FILENAME = MK2CC('f','n'), // attrfn.h + }; +}; + +/** + Generic configuration attribute. + + Configuration attributes enable you to store + uniquely identifiable values that get pushed + to a configuration file automatically upon shutdown + of any Wasabi application. + + You shouldn't normally use this on + it's own, look at the CfgItemI class + instead. + + @short Generic configuration attribute. + @ver 1.0 + @author Nullsoft + @see _float + @see _int + @see _bool + @see _string + @see CfgItemI +*/ +class NOVTABLE Attribute : public DependentI, private NamedW +{ +public: + static const GUID *depend_getClassGuid() { + // {5AB601D4-1628-4604-808A-7ED899849BEB} + static const GUID ret = + { 0x5ab601d4, 0x1628, 0x4604, { 0x80, 0x8a, 0x7e, 0xd8, 0x99, 0x84, 0x9b, 0xeb } }; + return &ret; + } +protected: + + /** + Optionally set the name and default value of + your configuration attribute during construction. + + @param name Name of the configuration attribute. + @param default_val Default value. + */ + Attribute(const wchar_t *name=NULL, const wchar_t *desc=NULL); + +public: + virtual ~Attribute(); + + /** + Set the name of the configuration + attribute. + + @param newname Name of the attribute. + */ + void setName(const wchar_t *newname); + + /** + Get the name of the configuration + attribute. + + @ret Name of the attribute. + */ + const wchar_t *getAttributeName(); + + /** + Get the attribute's description. + + @ret Attribute's description. + */ + const wchar_t *getAttributeDesc(); + + /** + Get the attribute type. Override + this for your custom attribute type. + + @ret Attribute type. + */ + virtual int getAttributeType()=0; // override me + + /** + Get the configuration group to be used to represent + this attribute in the registry. + + This is only called if the kernel doesn't have a default + config group set for your type already. + + @ret Config group to be used. + */ + virtual const wchar_t *getConfigGroup() { return NULL; } // override me + + /** + Get the attribute's value as signed integer. + + @ret Attribute value, as a signed integer. + */ + int getValueAsInt(); + + /** + Set the attribute's value with a signed integer while + also being able to replace the default value previously + set. + + @param newval Attribute's new value. + @param def true, replace the current default value; false, leave the default value unchanged; + */ + int setValueAsInt(int newval, bool def=false); + + /** + Get the attribute's value as signed double. + + @ret Attribute value, as a signed double. + */ + double getValueAsDouble(); + + /** + Set the attribute's value with a signed double while + also being able to replace the default value previously + set. + + @param newval Attribute's new value. + @param def true, replace the current default value; false, leave the default value unchanged; + */ + double setValueAsDouble(double newval, bool def=false); + + /** + Get the length of the attribute's value (data) + in bytes. + + @ret Attribute value (data) length, in bytes. + */ + int getDataLen(); + + /** + Get the attribute's raw data. + + This will return the data the attribute is storing + in a char buffer you hand to it. + + @ret Attribute value, as a signed double. + @param data Pointer to a char buffer. + @param data_len The maximum amount of bytes the char buffer can hold. + */ + int getData(wchar_t *data, int data_len); + + /** + Set the attribute's value with a zero terminated string. Also + enables you to replace the default value previously + set. + + @param newval Attribute's new value. + @param def true, replace the current default value; false, leave the default value unchanged; + */ + int setData(const wchar_t *data, bool def=false); + + void disconnect(); + + enum { + Event_DATACHANGE=100, + }; +protected: + friend class CfgItemI; + + /** + Set the attribute's value without causing + a callback. + + @ret 1. + @param data Attribute's new value. + */ + int setDataNoCB(const wchar_t *data); + + /** + Set the configuration item associated with this + attribute. + */ + void setCfgItem(CfgItemI *item); + + StringW mkTag(); + +private: + StringW desc; + StringW default_val, *private_storage; + CfgItemI *cfgitemi; +}; + +#define ATTR_PERM_READ 1 +#define ATTR_PERM_WRITE 2 + +#define ATTR_PERM_ALL (~0) + +// render hints for getRenderHint +enum { + ATTR_RENDER_HINT_INT_CHECKMARK +}; + +#endif diff --git a/Src/Wasabi/api/config/items/attrint.h b/Src/Wasabi/api/config/items/attrint.h new file mode 100644 index 00000000..c63af8ce --- /dev/null +++ b/Src/Wasabi/api/config/items/attrint.h @@ -0,0 +1,65 @@ +#ifndef _ATTRINT_H +#define _ATTRINT_H + +#include "attribute.h" + +// inherit from this one, or just use it +/** + Boolean configuration attributes have two values, true or false. + They can be used like any other config item. + + @short Integer configuration attribute. + @ver 1.0 + @author Nullsoft + @see CfgItemI + @see _bool + @see _string + @see _float +*/ +class _int : public Attribute { +public: + /** + Optionally set the name and default value of + your configuration attribute during construction. + + @param name Name of the configuration attribute. + @param default_val Default value. + */ + _int(const wchar_t *name=NULL, int default_val=0) : Attribute(name) { + setValueAsInt(default_val, true); + } + + // from AttributeI + /** + Get the attribute type. This will return + a constant representing the attribute type. + + These constants can be: BOOL, FLOAT, STRING and INT. + + @see AttributeType + @ret The attribute type. + */ + virtual int getAttributeType() { return AttributeType::INT; } + + /** + Get the configuration group to be used to represent + this attribute in the registry. + + @ret Config group to be used. + */ + virtual const wchar_t *getConfigGroup() { return L"studio.configgroup.int"; } +// virtual int getPermissions(); + + // convenience operators + /** + Get the value of the attribute. + */ + operator int() { return getValueAsInt(); } + + /** + Set the value of the attribute. + */ + int operator =(int newval) { return setValueAsInt(newval) ? newval : getValueAsInt(); } +}; + +#endif diff --git a/Src/Wasabi/api/config/items/attrstr.cpp b/Src/Wasabi/api/config/items/attrstr.cpp new file mode 100644 index 00000000..1209e2f3 --- /dev/null +++ b/Src/Wasabi/api/config/items/attrstr.cpp @@ -0,0 +1,14 @@ +#include +#include "attrstr.h" + +#include + +const wchar_t *_string::getValue() +{ + int l = getDataLen(); + if (l <= 0) return L""; + MemBlock mb(l+2); + getData(mb.getMemory(), l+2); + returnval = mb; + return returnval; +} diff --git a/Src/Wasabi/api/config/items/attrstr.h b/Src/Wasabi/api/config/items/attrstr.h new file mode 100644 index 00000000..cde81a64 --- /dev/null +++ b/Src/Wasabi/api/config/items/attrstr.h @@ -0,0 +1,85 @@ +#ifndef _ATTRSTR_H +#define _ATTRSTR_H + +#include "attribute.h" + +#include +#include + +/** + String configuration attributes, can have any string value + of any length. They can be used like any other config item. + + @short String configuration attribute. + @ver 1.0 + @author Nullsoft + @see _int + @see _bool + @see _float +*/ +class _string : public Attribute { +public: + /** + Optionally set the name and default value of + your configuration attribute during construction. + + @param name + @param default_val + */ + _string(const wchar_t *name=NULL, const wchar_t *default_val=NULL) + : Attribute(name) { + setData(default_val, true); + } + + /** + Get the attribute type. This will return + a constant representing the attribute type. + + These constants can be: BOOL, FLOAT, STRING and INT. + + @see AttributeType + @ret The attribute type. + */ + virtual int getAttributeType() { return AttributeType::STRING; } + + /** + Get the configuration group to be used to represent + this attribute in the registry. + + @ret Config group to be used. + */ + virtual const wchar_t *getConfigGroup() { return L"studio.configgroup.string"; } + +//CUT virtual int getPermissions() { return ATTR_PERM_ALL; } + + /** + Get the value of the attribute. + + @ret The value of the attribute + */ + const wchar_t *getValue(); + + /** + Set the value of the attribute. + + @param val The value you want to set. + @ret 1, success; 0, failure; + */ + int setValue(const wchar_t *val) { return setData(val); } + + // convenience operators + /** + Get the value of the attribute. + */ + operator const wchar_t *() { return getValue(); } + + /** + Set the value of the attribute. + */ + const wchar_t *operator =(const wchar_t *newval) { return setValue(newval) ? newval : getValue(); } + +private: + StringW returnval; +}; + +#endif diff --git a/Src/Wasabi/api/config/items/cfgitem.h b/Src/Wasabi/api/config/items/cfgitem.h new file mode 100644 index 00000000..560198f0 --- /dev/null +++ b/Src/Wasabi/api/config/items/cfgitem.h @@ -0,0 +1,233 @@ +#ifndef _CFGITEM_H +#define _CFGITEM_H + +#include +#include +#include +#include + +class ifc_dependent; +class ifc_window; + +/* A CfgItem is a named, possibly unique (if GUID is set) interface to +an object with 0 or more named attributes. If offers api_dependent-based callbacks +when those attributes change. +*/ + +// abstract base class presented to the world +/** + + + @short Base Config Item + @ver 1.0 + @author Nullsoft + @see CfgItemI +*/ +class NOVTABLE CfgItem : public Dispatchable +{ +public: + /** + */ + static const GUID *depend_getClassGuid() { + // {B4BE480E-2005-457c-A445-294F12387E74} + static const GUID ret = + { 0xb4be480e, 0x2005, 0x457c, { 0xa4, 0x45, 0x29, 0x4f, 0x12, 0x38, 0x7e, 0x74 } }; + return &ret; + } + + const wchar_t *getName(); + + /** + Get the GUID + */ + GUID getGuid(); + + /** + Get the number of attributes + associated with this configuration + item. + + @ret Number of attributes for this configuration item. + */ + int getNumAttributes(); + + const wchar_t *enumAttribute(int n); + + // so people can watch you for changes + ifc_dependent *getDependencyPtr(); + + // return * to your config xml if you want to specify it + const wchar_t *getConfigXML(); + void onCfgGroupCreate(ifc_window *cfggroup, const wchar_t *attrname=NULL); + void onCfgGroupDelete(ifc_window *cfggroup); + + // if you have child cfgitems, list them here + int getNumChildren(); + CfgItem *enumChild(int n); + GUID getParentGuid(); + + void onRegister(); // kernel calls these + void onDeregister(); + + int getAttributeType(const wchar_t *name); + const wchar_t *getAttributeConfigGroup(const wchar_t *name); + int getDataLen(const wchar_t *name); + int getData(const wchar_t *name, wchar_t *data, int data_len); + int setData(const wchar_t *name, const wchar_t *data); + + int getDataAsInt(const wchar_t *name, int def_val=0) + { + wchar_t buf[256]; + if (getData(name, buf, sizeof(buf))==-1) return def_val; + return WTOI(buf); + } + void setDataAsInt(const wchar_t *name, int val) { + wchar_t buf[256]; + WCSNPRINTF(buf, 256, L"%d", val); // this uses SPRINTF ON PURPOSE, motherfucker BU + setData(name, buf); + } + + double getDataAsFloat(const wchar_t *name, double def_val=0) { + wchar_t buf[256]; + if (getData(name, buf, sizeof(buf))==-1) return def_val; + return WTOF(buf); + } + void setDataAsFloat(const wchar_t *name, double val) { + wchar_t buf[256]; + WCSNPRINTF(buf, 256, L"%f", val); // this uses SPRINTF ON PURPOSE, motherfucker BU + setData(name, buf); + } + + int addAttribute(const wchar_t *name, const wchar_t *defval); + int delAttribute(const wchar_t *name); + + enum { + Event_ATTRIBUTE_ADDED=100, // ptr is name of attrib + Event_ATTRIBUTE_REMOVED=200,// ptr is name of attrib + Event_ATTRIBUTE_CHANGED=300, // ptr is name of attrib + Event_NAMECHANGE=400, + }; + +protected: + enum { + CFGITEM_GETNAME=100, + CFGITEM_GETGUID=110, + CFGITEM_GETNUMATTRIBUTES=200, + CFGITEM_ENUMATTRIBUTE=210, + CFGITEM_GETDEPENDENCYPTR=300, + CFGITEM_GETNUMCHILDREN=400, + CFGITEM_ENUMCHILD=410, + CFGITEM_GETPARENTGUID=420, + CFGITEM_ONREGISTER=500, + CFGITEM_ONDEREGISTER=510, + CFGITEM_GETCONFIGXML=600, + CFGITEM_ONCFGGROUPCREATE=610, + CFGITEM_ONCFGGROUPDELETE=620, + CFGITEM_GETATTRIBUTETYPE=700, + CFGITEM_GETATTRIBUTECONFIGGROUP=710, + CFGITEM_GETDATALEN=800, + CFGITEM_GETDATA=810, + CFGITEM_SETDATA=820, + CFGITEM_ADDATTRIB=830, + CFGITEM_DELATTRIB=840, + }; +}; + +inline const wchar_t *CfgItem::getName() { + return _call(CFGITEM_GETNAME, L""); +} + +inline GUID CfgItem::getGuid() { + return _call(CFGITEM_GETGUID, INVALID_GUID); +} + +inline int CfgItem::getNumAttributes() { + return _call(CFGITEM_GETNUMATTRIBUTES, 0); +} + +inline const wchar_t *CfgItem::enumAttribute(int n) { + return _call(CFGITEM_ENUMATTRIBUTE, (const wchar_t *)NULL, n); +} + +inline ifc_dependent *CfgItem::getDependencyPtr() { + return _call(CFGITEM_GETDEPENDENCYPTR, (ifc_dependent*)NULL); +} + +inline const wchar_t *CfgItem::getConfigXML() { + return _call(CFGITEM_GETCONFIGXML, (const wchar_t*)NULL); +} + +inline void CfgItem::onCfgGroupCreate(ifc_window *cfggroup, const wchar_t *attrname) { + _voidcall(CFGITEM_ONCFGGROUPCREATE, cfggroup, attrname); +} + +inline void CfgItem::onCfgGroupDelete(ifc_window *cfggroup) { + _voidcall(CFGITEM_ONCFGGROUPDELETE, cfggroup); +} + +inline int CfgItem::getNumChildren() { + return _call(CFGITEM_GETNUMCHILDREN, 0); +} + +inline CfgItem *CfgItem::enumChild(int n) { + return _call(CFGITEM_ENUMCHILD, (CfgItem*)NULL, n); +} + +inline +GUID CfgItem::getParentGuid() { + return _call(CFGITEM_GETPARENTGUID, INVALID_GUID); +} + +inline void CfgItem::onRegister() { _voidcall(CFGITEM_ONREGISTER); } +inline void CfgItem::onDeregister() { _voidcall(CFGITEM_ONDEREGISTER); } + +inline +int CfgItem::getAttributeType(const wchar_t *name) { + return _call(CFGITEM_GETATTRIBUTETYPE, 0, name); +} + +inline +const wchar_t *CfgItem::getAttributeConfigGroup(const wchar_t *name) { + return _call(CFGITEM_GETATTRIBUTECONFIGGROUP, (const wchar_t *)NULL, name); +} + +inline +int CfgItem::getDataLen(const wchar_t *name) { + return _call(CFGITEM_GETDATALEN, -1, name); +} + +inline +int CfgItem::getData(const wchar_t *name, wchar_t *data, int data_len) { + return _call(CFGITEM_GETDATA, -1, name, data, data_len); +} + +inline +int CfgItem::setData(const wchar_t *name, const wchar_t *data) { + return _call(CFGITEM_SETDATA, -1, name, data); +} + +inline +int CfgItem::addAttribute(const wchar_t *name, const wchar_t *defval) { + return _call(CFGITEM_ADDATTRIB, 0, name, defval); +} + +inline +int CfgItem::delAttribute(const wchar_t *name) { + return _call(CFGITEM_DELATTRIB, 0, name); +} + +inline int _intVal(CfgItem *cfgitem, const wchar_t *name, int def_val=0) { + if (cfgitem == NULL) return def_val; + return cfgitem->getDataAsInt(name, def_val); +} + +#define _int_getValue _intVal + +//CUT kill these +inline void _int_setValue(CfgItem *cfgitem, const wchar_t *name, int val) { + cfgitem->setDataAsInt(name, val); +} +// CfgItemI is in cfgitemi.h if you need it + + +#endif diff --git a/Src/Wasabi/api/config/items/cfgitemi.cpp b/Src/Wasabi/api/config/items/cfgitemi.cpp new file mode 100644 index 00000000..b8734031 --- /dev/null +++ b/Src/Wasabi/api/config/items/cfgitemi.cpp @@ -0,0 +1,274 @@ +#include + +#include "cfgitemi.h" +#include +#include + +#include +#include + +CfgItemI::CfgItemI(const wchar_t *name, GUID guid) +:NamedW(name), myguid(guid), parent_guid(INVALID_GUID) { } + +CfgItemI::~CfgItemI() +{ + deregisterAll(); +} + +const wchar_t *CfgItemI::cfgitem_getName() +{ + return NamedW::getName(); +} + +GUID CfgItemI::cfgitem_getGuid() +{ + return myguid; +} + +void CfgItemI::cfgitem_setPrefix(const wchar_t *_prefix) +{ + prefix = _prefix; +} + +const wchar_t *CfgItemI::cfgitem_getPrefix() +{ + return prefix.c_str(); +} + +int CfgItemI::cfgitem_getNumAttributes() +{ + return attributes.getNumItems(); +} + +const wchar_t *CfgItemI::cfgitem_enumAttribute(int n) +{ + Attribute *attr = attributes[n]; + if (attr) return attr->getAttributeName(); + return NULL; +} + +const wchar_t *CfgItemI::cfgitem_getConfigXML() +{ + return cfgxml.c_str(); +} + +int CfgItemI::cfgitem_getNumChildren() +{ + return children.getNumItems(); +} + +CfgItem *CfgItemI::cfgitem_enumChild(int n) +{ + return children[n]; +} + +GUID CfgItemI::cfgitem_getParentGuid() +{ + return parent_guid; +} + +void CfgItemI::cfgitem_onRegister() +{ + foreach(children) + WASABI_API_CONFIG->config_registerCfgItem(children.getfor()); + endfor +} +void CfgItemI::cfgitem_onDeregister() +{ + foreach(children) + WASABI_API_CONFIG->config_deregisterCfgItem(children.getfor()); + endfor +} + +Attribute *CfgItemI::getAttributeByName(const wchar_t *name) +{ + Attribute *attr; + foreach(attributes) + attr = attributes.getfor(); + if (!WCSICMP(name, attr->getAttributeName())) return attr; + endfor + return NULL; +} + +int CfgItemI::cfgitem_getAttributeType(const wchar_t *name) +{ + Attribute *attr = getAttributeByName(name); + if (attr == NULL) return AttributeType::NONE; + return attr->getAttributeType(); +} + +const wchar_t *CfgItemI::cfgitem_getAttributeConfigGroup(const wchar_t *name) +{ + Attribute *attr = getAttributeByName(name); + if (attr == NULL) return NULL; + return attr->getConfigGroup(); +} + +int CfgItemI::cfgitem_getDataLen(const wchar_t *name) +{ + Attribute *attr = getAttributeByName(name); + if (attr == NULL) return -1; + return attr->getDataLen(); +} + +int CfgItemI::cfgitem_getData(const wchar_t *name, wchar_t *data, int data_len) +{ + Attribute *attr = getAttributeByName(name); + if (attr == NULL) return -1; + return attr->getData(data, data_len); +} + +int CfgItemI::cfgitem_setData(const wchar_t *name, const wchar_t *data) +{ + Attribute *attr = getAttributeByName(name); + if (attr == NULL) return -1; + int ret = attr->setDataNoCB(data); + if (ret) cfgitem_onAttribSetValue(attr); + return ret; +} + +int CfgItemI::cfgitem_onAttribSetValue(Attribute *attr) +{ + // notify dependency watchers that an attribute changed + dependent_sendEvent(CfgItem::depend_getClassGuid(), Event_ATTRIBUTE_CHANGED, 0, (void*)attr->getAttributeName()); + + //for (int i = 0; ; i++) + //{ + // AttrCallback *acb; + // if (!callbacks.multiGetItem(attr, i, &acb)) + // break; + // + // acb->onValueChange(attr); + //} + auto elements = callbacks.equal_range(attr); + for (auto& it = elements.first; it != elements.second; ++it) + { + AttrCallback* acb = it->second; + if (acb) + { + acb->onValueChange(attr); + } + } + + return 0; +} + +void CfgItemI::cfgitem_setGUID(GUID guid) +{ + myguid = guid; +} + +int CfgItemI::setName(const wchar_t *name) +{ + NamedW::setName(name); + // notify dependency watchers that name changed? + dependent_sendEvent(CfgItem::depend_getClassGuid(), Event_NAMECHANGE); + return 1; +} + +int CfgItemI::registerAttribute(Attribute *attr, AttrCallback *acb) +{ + if (attributes.haveItem(attr)) return 0; + int ret = attributes.addItem(attr) != NULL; + if (!ret) return ret; + + attr->setCfgItem(this); + + // set optional callback + if (acb != NULL) + { + addCallback(attr, acb); + } + + // notify dependency watchers of new attribute + dependent_sendEvent(CfgItem::depend_getClassGuid(), Event_ATTRIBUTE_ADDED, 0, (void*)attr->getAttributeName()); + + return ret; +} + +int CfgItemI::deregisterAttribute(Attribute *attr) +{ + if (!attributes.haveItem(attr)) return 0; + int ret = attributes.removeItem(attr); + // notify dependency watchers of attribute going away + dependent_sendEvent(CfgItem::depend_getClassGuid(), Event_ATTRIBUTE_REMOVED, 0, (void*)attr->getAttributeName()); + + // remove callbacks + //callbacks.multiDelAllForItem(attr, TRUE); + auto elements = callbacks.equal_range(attr); + for (auto& it = elements.first; it != elements.second; ++it) + { + AttrCallback* acb = it->second; + if (acb) + { + delete acb; + } + } + callbacks.erase(attr); + + + attr->disconnect(); + + return ret; +} + +void CfgItemI::addCallback(Attribute *attr, AttrCallback *acb) +{ + ASSERT(attr != NULL); + ASSERT(acb != NULL); + //callbacks.multiAddItem(attr, acb); + callbacks.insert({ attr, acb }); +} + +void CfgItemI::deregisterAll() +{ + foreach(children) + children.getfor()->deregisterAll(); + endfor + while (attributes.getNumItems()) deregisterAttribute(attributes[0]); +} + +void CfgItemI::addChildItem(CfgItemI *child) +{ + ASSERT(child != NULL); + if (!children.haveItem(child)) + { + children.addItem(child); + child->setParentGuid(myguid); + } +} + +void CfgItemI::setCfgXml(const wchar_t *groupname) +{ + cfgxml = groupname; +} + +void CfgItemI::setParentGuid(GUID guid) +{ + parent_guid = guid; +} + +void *CfgItemI::dependent_getInterface(const GUID *classguid) +{ + HANDLEGETINTERFACE(CfgItem); + return NULL; +} + +int CfgItemI::cfgitem_addAttribute(const wchar_t *name, const wchar_t *defval) +{ + if (getAttributeByName(name)) return 0; + registerAttribute(newattribs.addItem(new _string(name, defval))); + return 1; +} + +int CfgItemI::cfgitem_delAttribute(const wchar_t *name) +{ + Attribute *attr = getAttributeByName(name); + if (!newattribs.haveItem(attr)) return 0; + deregisterAttribute(attr); + delete attr; + newattribs.removeItem(attr); + return 1; +} + + diff --git a/Src/Wasabi/api/config/items/cfgitemi.h b/Src/Wasabi/api/config/items/cfgitemi.h new file mode 100644 index 00000000..7824abf5 --- /dev/null +++ b/Src/Wasabi/api/config/items/cfgitemi.h @@ -0,0 +1,158 @@ +#ifndef _CFGITEMI_H +#define _CFGITEMI_H + +#include "cfgitemx.h" + +#include +#include +#include + +#include +#include + +class AttrCallback; +class Attribute; + +// this is the one you inherit from/use +/** + + @short Configuration Item + @ver 1.0 + @author Nullsoft + @see Attribute + @see _bool + @see _int + @see _float + @see _string +*/ +class CfgItemI : public CfgItemX, public DependentI, private NamedW +{ +public: + /** + Optionally sets the name and the GUID of the + configuration item if they are specified + upon creation of the object. + + @param name Name of the configuration item. + @param guid GUID of the configuration item. + */ + CfgItemI(const wchar_t *name=NULL, GUID guid=INVALID_GUID); + + /** + Does nothing. + */ + virtual ~CfgItemI(); + + /** + Get the name of the configuration item. + + @ret Name of the configuration item. + */ + const wchar_t *cfgitem_getName(); + + /** + Get the GUID of the configuration item. + + @ret GUID of the configuration item. + */ + GUID cfgitem_getGuid(); + + /** + Sets the prefix to be prepended in the config file for all attributes + of this item. + + @see cfgitem_getPrefix + @param prefix The prefix. + */ + void cfgitem_setPrefix(const wchar_t *prefix); +/** + Gets the config prefix, if any was set. + + @see cfgitem_setPrefix + @ret Pointer to the config prefix. +*/ + const wchar_t *cfgitem_getPrefix(); + + /** + Get the number of attributes registered + to this configuration item. + + @ret Number of attributes. + */ + int cfgitem_getNumAttributes(); + + /** + Enumerate the attributes registered + with this configuration item. + + @ret + */ + const wchar_t *cfgitem_enumAttribute(int n); + + const wchar_t *cfgitem_getConfigXML(); + virtual void cfgitem_onCfgGroupCreate(ifc_window *cfggroup, const wchar_t *attrname) {} + virtual void cfgitem_onCfgGroupDelete(ifc_window *cfggroup) {} + + virtual int cfgitem_getNumChildren(); + virtual CfgItem *cfgitem_enumChild(int n); + virtual GUID cfgitem_getParentGuid(); + + virtual void cfgitem_onRegister(); + virtual void cfgitem_onDeregister(); + + int cfgitem_getAttributeType(const wchar_t *name); + const wchar_t *cfgitem_getAttributeConfigGroup(const wchar_t *name); + int cfgitem_getDataLen(const wchar_t *name); + int cfgitem_getData(const wchar_t *name, wchar_t *data, int data_len); + int cfgitem_setData(const wchar_t *name, const wchar_t *data); + + // override these to catch notifications from attribs, call down + virtual int cfgitem_onAttribSetValue(Attribute *attr); + + virtual int cfgitem_usePrivateStorage() { return 0; } //override and return 1 to keep stuff out of system settings + +protected: + void cfgitem_setGUID(GUID guid); + +public: + int setName(const wchar_t *name); + int registerAttribute(Attribute *attr, AttrCallback *acb=NULL); + // does not call delete on the attribute + int deregisterAttribute(Attribute *attr); + void deregisterAll(); + + void addCallback(Attribute *attr, AttrCallback *acb); + + int cfgitem_addAttribute(const wchar_t *name, const wchar_t *defval); + int cfgitem_delAttribute(const wchar_t *name); + +protected: + + // derived classes can override this to catch name changes + virtual void cfgitem_onSetName() { } + + Attribute *getAttributeByName(const wchar_t *name); + + void addChildItem(CfgItemI *child); + + void setCfgXml(const wchar_t *groupname); + + void setParentGuid(GUID guid); + +private: + api_dependent *cfgitem_getDependencyPtr() { return this; }; + virtual void *dependent_getInterface(const GUID *classguid); + + // from Named + virtual void onSetName() { cfgitem_onSetName(); } + + std::wstring prefix; + PtrList attributes; + std::multimap callbacks; //CUT + PtrList children; + std::wstring cfgxml; + GUID myguid, parent_guid; + PtrList newattribs; +}; + +#endif diff --git a/Src/Wasabi/api/config/items/cfgitemx.cpp b/Src/Wasabi/api/config/items/cfgitemx.cpp new file mode 100644 index 00000000..b656dfc9 --- /dev/null +++ b/Src/Wasabi/api/config/items/cfgitemx.cpp @@ -0,0 +1,27 @@ +#include +#include "cfgitemx.h" + +#define CBCLASS CfgItemX +START_DISPATCH + CB(CFGITEM_GETNAME, cfgitem_getName); + CB(CFGITEM_GETGUID, cfgitem_getGuid); + CB(CFGITEM_GETNUMATTRIBUTES, cfgitem_getNumAttributes); + CB(CFGITEM_ENUMATTRIBUTE, cfgitem_enumAttribute); + CB(CFGITEM_GETCONFIGXML, cfgitem_getConfigXML); + VCB(CFGITEM_ONCFGGROUPCREATE, cfgitem_onCfgGroupCreate); + VCB(CFGITEM_ONCFGGROUPDELETE, cfgitem_onCfgGroupDelete); + CB(CFGITEM_GETNUMCHILDREN, cfgitem_getNumChildren); + CB(CFGITEM_ENUMCHILD, cfgitem_enumChild); + CB(CFGITEM_GETPARENTGUID, cfgitem_getParentGuid); + VCB(CFGITEM_ONREGISTER, cfgitem_onRegister); + VCB(CFGITEM_ONDEREGISTER, cfgitem_onDeregister); + CB(CFGITEM_GETATTRIBUTETYPE, cfgitem_getAttributeType); + CB(CFGITEM_GETATTRIBUTECONFIGGROUP, cfgitem_getAttributeConfigGroup); + CB(CFGITEM_GETDATALEN, cfgitem_getDataLen); + CB(CFGITEM_GETDATA, cfgitem_getData); + CB(CFGITEM_SETDATA, cfgitem_setData); + CB(CFGITEM_GETDEPENDENCYPTR, cfgitem_getDependencyPtr); + CB(CFGITEM_ADDATTRIB, cfgitem_addAttribute); + CB(CFGITEM_DELATTRIB, cfgitem_delAttribute); +END_DISPATCH +#undef CBCLASS \ No newline at end of file diff --git a/Src/Wasabi/api/config/items/cfgitemx.h b/Src/Wasabi/api/config/items/cfgitemx.h new file mode 100644 index 00000000..6d5a9408 --- /dev/null +++ b/Src/Wasabi/api/config/items/cfgitemx.h @@ -0,0 +1,42 @@ +#ifndef NULLSOFT_WASABI_CFGITEMX_H +#define NULLSOFT_WASABI_CFGITEMX_H + +#include "cfgitem.h" + +class CfgItemX : public CfgItem +{ +public: + virtual ~CfgItemX() {} + virtual const wchar_t *cfgitem_getName()=0; + virtual GUID cfgitem_getGuid()=0; + virtual int cfgitem_getNumAttributes()=0; + virtual const wchar_t *cfgitem_enumAttribute(int n)=0; + virtual const wchar_t *cfgitem_getConfigXML()=0; + virtual void cfgitem_onCfgGroupCreate(ifc_window *cfggroup, const wchar_t *attrname)=0; + virtual void cfgitem_onCfgGroupDelete(ifc_window *cfggroup)=0; + + virtual int cfgitem_getNumChildren()=0; + virtual CfgItem *cfgitem_enumChild(int n)=0; + virtual GUID cfgitem_getParentGuid()=0; + + virtual void cfgitem_onRegister()=0; + virtual void cfgitem_onDeregister()=0; + + virtual int cfgitem_getAttributeType(const wchar_t *name)=0; + virtual const wchar_t *cfgitem_getAttributeConfigGroup(const wchar_t *name)=0; + + virtual int cfgitem_getDataLen(const wchar_t *name)=0; + virtual int cfgitem_getData(const wchar_t *name, wchar_t *data, int data_len)=0; + virtual int cfgitem_setData(const wchar_t *name, const wchar_t *data)=0; + virtual ifc_dependent *cfgitem_getDependencyPtr()=0; + virtual int cfgitem_delAttribute(const wchar_t *name)=0; + virtual int cfgitem_addAttribute(const wchar_t *name, const wchar_t *defval)=0; + +protected: + RECVS_DISPATCH; + + +}; + + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/config/items/intarray.cpp b/Src/Wasabi/api/config/items/intarray.cpp new file mode 100644 index 00000000..c6ba4676 --- /dev/null +++ b/Src/Wasabi/api/config/items/intarray.cpp @@ -0,0 +1,49 @@ +#include + +#include "intarray.h" + + +enum { MAX_ARRAY=8 }; + +int IntArray::read(const wchar_t *name, int *x1, int *x2, int *x3, int *x4, int *x5, int *x6, int *x7, int *x8) { + PtrList list; + if (x1) { list.addItem(x1); } + if (x2) { list.addItem(x2); } + if (x3) { list.addItem(x3); } + if (x4) { list.addItem(x4); } + if (x5) { list.addItem(x5); } + if (x6) { list.addItem(x6); } + if (x7) { list.addItem(x7); } + if (x8) { list.addItem(x8); } + ASSERT(list.getNumItems() >= 1); + + int array[MAX_ARRAY]; // gcc rules, msvc drools + for (int i = 0; i < list.getNumItems(); i++) { + if (list[i]) array[i] = *list[i]; + } + if (!WASABI_API_CONFIG->getIntArrayPrivate(name, array, list.getNumItems())) return 0; + for (int j = 0; j < list.getNumItems(); j++) { + if (list[j]) *list[j] = array[j]; + } + return 1; +} + +void IntArray::write(const wchar_t *name, int x1) { + int array[] = { x1 }; + WASABI_API_CONFIG->setIntArrayPrivate(name, array, sizeof(array)/sizeof(int)); +} + +void IntArray::write(const wchar_t *name, int x1, int x2) { + int array[] = { x1, x2 }; + WASABI_API_CONFIG->setIntArrayPrivate(name, array, sizeof(array)/sizeof(int)); +} + +void IntArray::write(const wchar_t *name, int x1, int x2, int x3) { + int array[] = { x1, x2, x3 }; + WASABI_API_CONFIG->setIntArrayPrivate(name, array, sizeof(array)/sizeof(int)); +} + +void IntArray::write(const wchar_t *name, int x1, int x2, int x3, int x4) { + int array[] = { x1, x2, x3, x4 }; + WASABI_API_CONFIG->setIntArrayPrivate(name, array, sizeof(array)/sizeof(int)); +} diff --git a/Src/Wasabi/api/config/items/intarray.h b/Src/Wasabi/api/config/items/intarray.h new file mode 100644 index 00000000..edb26322 --- /dev/null +++ b/Src/Wasabi/api/config/items/intarray.h @@ -0,0 +1,18 @@ +#ifndef _INTARRAY_H +#define _INTARRAY_H + +#include +#include +#include + +class IntArray +{ +public: + static int read(const wchar_t *name, int *x1, int *x2=NULL, int *x3=NULL, int *x4=NULL, int *x5=NULL, int *x6=NULL, int *x7=NULL, int *x8=NULL); + static void write(const wchar_t *name, int x1); + static void write(const wchar_t *name, int x1, int x2); + static void write(const wchar_t *name, int x1, int x2, int x3); + static void write(const wchar_t *name, int x1, int x2, int x3, int x4); +}; + +#endif diff --git a/Src/Wasabi/api/config/options.cpp b/Src/Wasabi/api/config/options.cpp new file mode 100644 index 00000000..e5c0d27a --- /dev/null +++ b/Src/Wasabi/api/config/options.cpp @@ -0,0 +1,211 @@ +#include + +#include "options.h" + +//#include //CUT!! +#include + +#include +#include +#include +#include + +#include +#include + +#define ININAME "wasabi.ini" + +// {280876CF-48C0-40bc-8E86-73CE6BB462E5} +const GUID options_guid = +{ 0x280876cf, 0x48c0, 0x40bc, { 0x8e, 0x86, 0x73, 0xce, 0x6b, 0xb4, 0x62, 0xe5 } }; + +#ifndef GEN_FF + +static void setMultipleInstance(int val) +{ + StringPrintf fn("%s%s%s", WASABI_API_APP->path_getAppPath(), DIRCHARSTR, ININAME); + IniFile(fn).setBool("Wasabi", "MultipleInstance", val); +} + +_int forward_skip_time("Forward skip time", 5000); +_int reverse_skip_time("Reverse skip time", 5000); +#endif + +_bool cfg_options_altfonts(L"Alternate Fonts", FALSE); +_bool cfg_options_allowbitmapfonts(L"Use bitmap fonts (no international support)", FALSE); +_string cfg_options_defaultfont(L"Default font", WASABI_DEFAULT_FONTNAMEW L".ttf"); +_int cfg_options_defaultfontscale(L"Default font scale", 100); +_string cfg_options_ttfoverridefont(L"TTF font override", WASABI_DEFAULT_FONTNAMEW L".ttf"); +_int cfg_options_ttfoverridescale(L"TTF Override Scale", 100); +_bool cfg_options_no7bitsttfoverride(L"No 7-bit TTF override", TRUE); +_bool cfg_options_noalt7bitsttfoverride(L"No 7-bit TTF AltFonts", TRUE); +_bool cfg_options_usefontmapper(L"Enable Font Mapper", FALSE); + +#ifdef USEAPPBAR +_bool cfg_options_appbarondrag(L"Dock Appbars on Window Drag", FALSE); +_int cfg_options_appbardockingdistance(L"Appbars Docking Distance", 5); +#endif + +void invalidateAll(int b) { +#ifdef WASABI_COMPILE_WNDMGR + WASABI_API_WNDMGR->wndTrackInvalidateAll(); +#endif +} + +void onDefaultFontChanged(const wchar_t *attribute) { + Font::uninstallAll(1); + Wasabi::Std::setDefaultFont(cfg_options_defaultfont.getValue()); + invalidateAll(1); +} + +void onOverrideFontChanged(const wchar_t *attribute) { + Font::uninstallAll(1); + invalidateAll(1); +} + +void onDefaultFontScaleChanged(int scale) { + Wasabi::Std::setDefaultFontScale(scale); + invalidateAll(1); +} + +void onOverrideFontScaleChanged(int scale) { + invalidateAll(1); +} + +void onFontRendererChanged(const wchar_t *s) { + Font::uninstallAll(1); + invalidateAll(1); +} + +void onFontMapperChanged(int b) { + Font::uninstallAll(1); + invalidateAll(1); +} + +_bool cfg_audiooptions_crossfader(L"Enable crossfading", DEFAULT_CROSSFADE_ENABLED); +_bool cfg_options_alwaysontop(L"Always on top", FALSE); +_bool cfg_options_docking(L"Enable docking", TRUE); +_int cfg_options_dockingdistance(L"Docking distance", DEFAULT_DOCK_DIST); +_string cfg_options_fontrenderer(L"Font Renderer", WASABI_FONT_RENDERER); +_int cfg_options_freetypecharmap(L"Character mapping", -1); + +Options::Options() : CfgItemI(L"Options", options_guid) +{ +#ifdef _WASABIRUNTIME + registerAttribute(&cfg_options_alwaysontop, new int_attrCB(Main::setOnTop)); +#else + extern void setOnTop(int ontop); + registerAttribute(&cfg_options_alwaysontop, new int_attrCB(setOnTop)); +#endif + /* TODO: benski> move to wndmgr.w5s (or wherever it's final home is */ + registerAttribute(&cfg_options_dockingdistance, new int_attrCB(WindowTracker::setDockDistance)); + registerAttribute(&cfg_options_docking, new int_attrCB(WindowTracker::setEnableDocking)); + /* --- END TO MOVE --- */ + registerAttribute(new _bool(L"Find open rect", FALSE)); + registerAttribute(new _bool(L"Animated rects", TRUE)); + registerAttribute(&cfg_options_fontrenderer, new string_attrCB(onFontRendererChanged)); + registerAttribute(&cfg_options_allowbitmapfonts, new int_attrCB(invalidateAll)); + registerAttribute(&cfg_options_altfonts, new int_attrCB(invalidateAll)); + registerAttribute(&cfg_options_defaultfont, new string_attrCB(onDefaultFontChanged)); + registerAttribute(&cfg_options_ttfoverridefont, new string_attrCB(onOverrideFontChanged)); + registerAttribute(&cfg_options_ttfoverridescale, new int_attrCB(onOverrideFontScaleChanged)); + registerAttribute(&cfg_options_defaultfontscale, new int_attrCB(onDefaultFontScaleChanged)); + registerAttribute(&cfg_options_freetypecharmap, new int_attrCB(invalidateAll)); + registerAttribute(&cfg_options_no7bitsttfoverride, new int_attrCB(invalidateAll)); + registerAttribute(&cfg_options_noalt7bitsttfoverride, new int_attrCB(invalidateAll)); + registerAttribute(&cfg_options_usefontmapper, new int_attrCB(onFontMapperChanged)); +#ifdef USEAPPBAR + registerAttribute(&cfg_options_appbarondrag); + registerAttribute(&cfg_options_appbardockingdistance); +#endif +#ifdef _WASABIRUNTIME + registerAttribute(new _bool(L"Allow multiple instances", FALSE), new int_attrCB(setMultipleInstance)); + registerAttribute(new _int(L"Icon mode", 1), new int_attrCB(Main::setIconMode)); + registerAttribute(new _bool(L"Auto-play at startup", FALSE)); + registerAttribute(new _string(L"Language", "English"), new LanguageCB(this)); +#ifdef WIN32 + registerAttribute(new _bool("Associate with audio CDs", TRUE), new int_attrCB(Filetypes::registerCdPlayer)); +#endif + registerAttribute(new _string("Monitor aspect ratio", "4:3")); + registerAttribute(new _int("Internet connection",3)); //3==autodetect + registerAttribute(&forward_skip_time); + registerAttribute(&reverse_skip_time); +#endif + + //registerAttribute(new _bool("Use Mozilla instead of IE for minibrowser", FALSE)); // TODO:move into minibrowser component +/* registerAttribute(new _bool("Force antialias on all TTF", FALSE));*/ + addChildItem(&audio_options); + addChildItem(&ui_options); +} + +void Options::checkCd() { +#ifdef _WASABIRUNTIME +#ifdef WIN32 + if(getDataAsInt("Associate with audio CDs") && !Filetypes::isCdPlayer()) setDataAsInt("Associate with audio CDs",false); +#endif +#endif +} + +// {FC3EAF78-C66E-4ed2-A0AA-1494DFCC13FF} +static const GUID audio_options_guid = +{ 0xfc3eaf78, 0xc66e, 0x4ed2, { 0xa0, 0xaa, 0x14, 0x94, 0xdf, 0xcc, 0x13, 0xff } }; + +AudioOptions::AudioOptions() : CfgItemI(L"Audio options", audio_options_guid) +{ +#ifdef GEN_FF +#ifdef WASABI_COMPILE_MEDIACORE + extern void setCrossfader(int crossfade); + registerAttribute(&cfg_audiooptions_crossfader, new int_attrCB(setCrossfader)); +#endif +#endif +#ifdef _WASABIRUNTIME + registerAttribute(&cfg_audiooptions_crossfader); + int use_dsound=0; +#ifdef WIN32 + //check for Windows version for whether we make DSOUND default + DWORD dwVersion = GetVersion(); + DWORD dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); + if (dwVersion < 0x80000000) { + if(dwWindowsMajorVersion<=4) use_dsound=0; // no dsound on NT4/3.51 + else use_dsound=1; // dsound yes on 2000/XP + } else + use_dsound=0; // no dsound by default on win9x (per PP) +#endif + registerAttribute(new _bool("DirectSound output", use_dsound)); +#endif +} + +#ifdef _WASABIRUNTIME + +// {C1BD5354-5EC4-406c-B5C0-549718D3AF45} +static const GUID setup_guid = +{ 0xc1bd5354, 0x5ec4, 0x406c, { 0xb5, 0xc0, 0x54, 0x97, 0x18, 0xd3, 0xaf, 0x45 } }; + +SetupOptions::SetupOptions() : CfgItemI("Setup", setup_guid) { +#ifdef WIN32 + addChildItem(&filetypes); +#endif +} + +// {99CFD75C-1CA7-49e5-B8C0-7D78AA443C10} +static const GUID installed_guid = +{ 0x99cfd75c, 0x1ca7, 0x49e5, { 0xb8, 0xc0, 0x7d, 0x78, 0xaa, 0x44, 0x3c, 0x10 } }; + +InstalledComponents::InstalledComponents() : CfgItemI("Installed components", installed_guid) { +//CUT setCfgXml("config.components"); +} + +void LanguageCB::onValueChange(Attribute *attr) { + char bufero[WA_MAX_PATH]=""; + attr->getData(bufero, WA_MAX_PATH-1); + const char *locname; + for(int i=0;locname=LocalesManager::enumLoadableLocales(i);i++) { + if (STRCASEEQLSAFE(bufero, locname)) { + LocalesManager::setNewLocaleNum(i); + return; + } + } + WASABI_API_WNDMGR->messageBox(StringPrintf("Internal problem switching to language %s, the language name couldn't be found in the list of loaded resources", bufero), "Error", 0, NULL, NULL); +} + +#endif diff --git a/Src/Wasabi/api/config/options.h b/Src/Wasabi/api/config/options.h new file mode 100644 index 00000000..c86a7f3a --- /dev/null +++ b/Src/Wasabi/api/config/options.h @@ -0,0 +1,64 @@ +#ifndef _OPTIONS_H +#define _OPTIONS_H + +#include +#include + +//#include +#include + +class Options; + +class _string; +class _int; +class _bool; + +extern _string cfg_options_defaultfont; +extern _int cfg_options_ttfoverridescale; +extern _bool cfg_options_no7bitsttfoverride; +extern _bool cfg_options_allowbitmapfonts; +extern _string cfg_options_fontrenderer; + +#ifdef _WASABIRUNTIME + +class SetupOptions : public CfgItemI { +public: + SetupOptions(); + + Filetypes filetypes; +}; + +class InstalledComponents : public CfgItemI { +public: + InstalledComponents(); +}; +#endif + +class AudioOptions : public CfgItemI { +public: + AudioOptions(); +}; + +#define OPTIONS_PARENT CfgItemI +class Options : public OPTIONS_PARENT { +public: + Options(); + void checkCd(); + + AudioOptions audio_options; + UIOptions ui_options; +}; + +#ifdef _WASABIRUNTIME + +class LanguageCB : public AttrCallback { +public: + LanguageCB(CfgItemI *_par) : par(_par) { } + virtual void onValueChange(Attribute *attr); +private: + CfgItemI *par; +}; + +#endif + +#endif diff --git a/Src/Wasabi/api/config/uioptions.cpp b/Src/Wasabi/api/config/uioptions.cpp new file mode 100644 index 00000000..0ccc33f7 --- /dev/null +++ b/Src/Wasabi/api/config/uioptions.cpp @@ -0,0 +1,109 @@ +#include + +#include "uioptions.h" + +#include + +#include +#include + +#include +#include + +// {9149C445-3C30-4e04-8433-5A518ED0FDDE} +const GUID uioptions_guid = +{ 0x9149c445, 0x3c30, 0x4e04, { 0x84, 0x33, 0x5a, 0x51, 0x8e, 0xd0, 0xfd, 0xde } }; + +_bool cfg_uioptions_desktopalpha(L"Enable desktop alpha", DEFAULT_DESKTOPALPHA); +_bool cfg_uioptions_linkratio(L"Link layouts scale", DEFAULT_LINKLAYOUTSCALE); +_bool cfg_uioptions_linkalpha(L"Link layouts alpha", DEFAULT_LINKLAYOUTSALPHA); +_bool cfg_uioptions_linkallalpha(L"Link All layouts alpha", DEFAULT_LINKALLALPHA); +_bool cfg_uioptions_linkallratio(L"Link All layouts scale", DEFAULT_LINKALLRATIO); +_int cfg_uioptions_linkedalpha(L"Linked layouts alpha", DEFAULT_LINKEDALPHA); +_int cfg_uioptions_autoopacitytime(L"Auto Opacity hold time", DEFAULT_AUTOOPACITYTIME); +_int cfg_uioptions_autoopacityfadein(L"Auto Opacity fade in time", DEFAULT_AUTOOPACITYFADEIN); +_int cfg_uioptions_autoopacityfadeout(L"Auto Opacity fade out time", DEFAULT_AUTOOPACITYFADEOUT); +_int cfg_uioptions_autoopacitylinked(L"Use Auto Opacity", DEFAULT_AUTOOPACITYTYPE); +_int cfg_uioptions_extendautoopacity(L"Auto Opacity extend by", DEFAULT_EXTENDAUTOOPACITY); +_bool cfg_uioptions_uselocks(L"Use layout scale locks", DEFAULT_USERATIOLOCKS); +_int cfg_uioptions_timerresolution(L"Multiplexed timers resolution", DEFAULT_TIMERRESOLUTION); +_bool cfg_uioptions_tooltips(L"Enable tooltips", DEFAULT_TOOLTIPS); +_float cfg_uioptions_textspeed(L"Text Ticker Speed", DEFAULT_TEXTSPEED); +_int cfg_uioptions_textincrement(L"Text Ticker Increment", DEFAULT_TEXTINCREMENT); +_int cfg_uioptions_appbarshidetime(L"Appbar Hide Time", DEFAULT_APPBARHIDETIME); +_int cfg_uioptions_appbarsshowtime(L"Appbar Show Time", DEFAULT_APPBARSHOWTIME); + +void onSetOpacityTime(int n) { + Layout *l = SkinParser::getMainLayout(); + if (l) l->getAlphaMgr()->setHoldTime(n); +} + +void onSetOpacityFadeIn(int n) { + Layout *l = SkinParser::getMainLayout(); + if (l) l->getAlphaMgr()->setFadeInTime(n); +} + +void onSetOpacityFadeOut(int n) { + Layout *l = SkinParser::getMainLayout(); + if (l) l->getAlphaMgr()->setFadeOutTime(n); +} + +void onSetAllRatio(int on) { + if (on) { + Layout *l = SkinParser::getMainLayout(); + if (l) l->setRenderRatio(l->getRenderRatio()); + } +} + +void onSetAllAlpha(int on) { + Layout *l = SkinParser::getMainLayout(); + if (l) l->getAlphaMgr()->setAllLinked(on); +} + +void onSetLinkedAlpha(int a) { + Layout *l = SkinParser::getMainLayout(); + if (l) l->getAlphaMgr()->setGlobalAlpha(a); +} + +void onSetLinkedAuto100(int v) { + Layout *l = SkinParser::getMainLayout(); + if (l) l->getAlphaMgr()->setAutoOpacify(v); +} + +void onSetExtendAutoOpacity(int v) { + Layout *l = SkinParser::getMainLayout(); + if (l) l->getAlphaMgr()->setExtendAutoOpacity(v); +} + +UIOptions::UIOptions(const wchar_t *name) : CfgItemI(name ? name : L"Skins and UI Tweaks", uioptions_guid) +{ + registerAttribute(&cfg_uioptions_linkratio); + registerAttribute(&cfg_uioptions_linkalpha); + registerAttribute(&cfg_uioptions_uselocks); + registerAttribute(&cfg_uioptions_autoopacitylinked, new int_attrCB(onSetLinkedAuto100)); + registerAttribute(&cfg_uioptions_linkallratio, new int_attrCB(onSetAllRatio)); + registerAttribute(&cfg_uioptions_linkallalpha, new int_attrCB(onSetAllAlpha)); + registerAttribute(&cfg_uioptions_desktopalpha, new int_attrCB(Layout::onGlobalEnableDesktopAlpha)); + registerAttribute(&cfg_uioptions_linkedalpha, new int_attrCB(onSetLinkedAlpha)); + registerAttribute(&cfg_uioptions_tooltips); + registerAttribute(&cfg_uioptions_timerresolution); + registerAttribute(&cfg_uioptions_textspeed); + registerAttribute(&cfg_uioptions_textincrement); + registerAttribute(&cfg_uioptions_appbarshidetime); + registerAttribute(&cfg_uioptions_appbarsshowtime); + registerAttribute(&cfg_uioptions_autoopacitytime, new int_attrCB(onSetOpacityTime)); + registerAttribute(&cfg_uioptions_autoopacityfadein, new int_attrCB(onSetOpacityFadeIn)); + registerAttribute(&cfg_uioptions_autoopacityfadeout, new int_attrCB(onSetOpacityFadeOut)); + registerAttribute(&cfg_uioptions_extendautoopacity, new int_attrCB(onSetExtendAutoOpacity)); + registerAttribute(new _int(L"Timer refresh rate", 30), new int_attrCB(onTimerRefreshRate)); + registerAttribute(new _int(L"Popup menu alpha", 240)); + registerAttribute(new _int(L"Spectrum analyzer mode",1)); +} + +void UIOptions::onTimerRefreshRate(int rate) { + if(rate==0 || rate<9 || rate>70) return; + int res=1000/rate; + CfgItem *ci=WASABI_API_CONFIG->config_getCfgItemByGuid(uioptions_guid); + if(!ci) return; + ci->setDataAsInt(L"Multiplexed timers resolution",res); +} diff --git a/Src/Wasabi/api/config/uioptions.h b/Src/Wasabi/api/config/uioptions.h new file mode 100644 index 00000000..bf2cb963 --- /dev/null +++ b/Src/Wasabi/api/config/uioptions.h @@ -0,0 +1,13 @@ +#ifndef _UIOPTIONS_H +#define _UIOPTIONS_H + +#include + +#define UIOPTIONS_PARENT CfgItemI +class UIOptions : public UIOPTIONS_PARENT { +public: + UIOptions(const wchar_t *name=NULL); + static void onTimerRefreshRate(int rate); +}; + +#endif diff --git a/Src/Wasabi/api/console/console.cpp b/Src/Wasabi/api/console/console.cpp new file mode 100644 index 00000000..3188ac7d --- /dev/null +++ b/Src/Wasabi/api/console/console.cpp @@ -0,0 +1,33 @@ +#include "console.h" +#include +#include + +void Console::outputString(int severity, const char *string) { + if (!console) { + console = new ConsoleEnum; + } + + if (needscan) { + needscan=0; + console->reset(); + svc_console *con = console->getNext(); + noconsole = (con == NULL); + } + if (noconsole) return; + + console->reset(); + svc_console *con = console->getNext(); + while (con) { + con->outputString(severity, string); + con = console->getNext(); + } +} + +void Console::reset() { + needscan=1; +} + +int Console::needscan=1; +int Console::noconsole=0; + +ConsoleEnum *Console::console = NULL; diff --git a/Src/Wasabi/api/console/console.h b/Src/Wasabi/api/console/console.h new file mode 100644 index 00000000..bece619d --- /dev/null +++ b/Src/Wasabi/api/console/console.h @@ -0,0 +1,19 @@ +#ifndef __CONSOLE_H +#define __CONSOLE_H + +class ConsoleEnum; + +class Console { + public: + + static void outputString(int severity, const char *string); + static void reset(); + + private: + + static ConsoleEnum *console; + static int needscan; + static int noconsole; +}; + +#endif diff --git a/Src/Wasabi/api/core/api_core.cpp b/Src/Wasabi/api/core/api_core.cpp new file mode 100644 index 00000000..6fe6c484 --- /dev/null +++ b/Src/Wasabi/api/core/api_core.cpp @@ -0,0 +1,51 @@ +#include +#include "api_core.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif +#define CBCLASS api_coreI +START_DISPATCH; + CB(API_CORE_GETSUPPORTEDEXTENSIONS, core_getSupportedExtensions); + CB(API_CORE_GETEXTSUPPORTEDEXTENSIONS, core_getExtSupportedExtensions); + CB(API_CORE_CREATE, core_create); + CB(API_CORE_FREE, core_free); + CB(API_CORE_SETNEXTFILE, core_setNextFile); + CB(API_CORE_GETSTATUS, core_getStatus); + CB(API_CORE_GETCURRENT, core_getCurrent); + CB(API_CORE_GETCURPLAYBACKNUMBER, core_getCurPlaybackNumber); + CB(API_CORE_GETPOSITION, core_getPosition); + CB(API_CORE_GETWRITEPOSITION, core_getWritePosition); + CB(API_CORE_SETPOSITION, core_setPosition); + CB(API_CORE_GETLENGTH, core_getLength); + CB(API_CORE_GETPLUGINDATA, core_getPluginData); + CB(API_CORE_GETVOLUME, core_getVolume); + VCB(API_CORE_SETVOLUME, core_setVolume); + CB(API_CORE_GETPAN, core_getPan); + VCB(API_CORE_SETPAN, core_setPan); + VCB(API_CORE_ADDCALLBACK, core_addCallback); + VCB(API_CORE_DELCALLBACK, core_delCallback); + CB(API_CORE_GETVISDATA, core_getVisData); + CB(API_CORE_GETLEFTVUMETER, core_getLeftVuMeter); + CB(API_CORE_GETRIGHTVUMETER, core_getRightVuMeter); + CB(API_CORE_REGISTERSEQUENCER, core_registerSequencer); + CB(API_CORE_DEREGISTERSEQUENCER, core_deregisterSequencer); + VCB(API_CORE_USERBUTTON, core_userButton); + CB(API_CORE_GETEQSTATUS, core_getEqStatus); + VCB(API_CORE_SETEQSTATUS, core_setEqStatus); + CB(API_CORE_GETEQPREAMP, core_getEqPreamp); + VCB(API_CORE_SETEQPREAMP, core_setEqPreamp); + CB(API_CORE_GETEQBAND, core_getEqBand); + VCB(API_CORE_SETEQBAND, core_setEqBand); + CB(API_CORE_GETEQAUTO, core_getEqAuto); + VCB(API_CORE_SETEQAUTO, core_setEqAuto); + VCB(API_CORE_SETCUSTOMMSG, core_setCustomMsg); + VCB(API_CORE_REGISTEREXTENSION, core_registerExtension); + CB(API_CORE_GETEXTENSIONFAMILY, core_getExtensionFamily); + VCB(API_CORE_UNREGISTEREXTENSION, core_unregisterExtension); + CB(API_CORE_GETTITLE, core_getTitle); + CB(API_CORE_GETRATING, core_getRating); + VCB(API_CORE_SETRATING, core_setRating); + CB(API_CORE_GETDECODERNAME, core_getDecoderName); + VCB(API_CORE_SETTITLE, core_setTitle); +END_DISPATCH; \ No newline at end of file diff --git a/Src/Wasabi/api/core/api_core.h b/Src/Wasabi/api/core/api_core.h new file mode 100644 index 00000000..759470a9 --- /dev/null +++ b/Src/Wasabi/api/core/api_core.h @@ -0,0 +1,371 @@ +#ifndef __API_CORE_H +#define __API_CORE_H + +#include + +typedef unsigned int CoreToken; +class CoreCallback; +class ItemSequencer; + +class NOVTABLE api_core : public Dispatchable +{ +public: + const wchar_t *core_getSupportedExtensions(); + const wchar_t *core_getExtSupportedExtensions(); + CoreToken core_create(); + int core_free(CoreToken core); + int core_setNextFile(CoreToken core, const wchar_t *playstring); + int core_getStatus(CoreToken core); + const wchar_t *core_getCurrent(CoreToken core); + int core_getCurPlaybackNumber(CoreToken core); + int core_getPosition(CoreToken core); + int core_getWritePosition(CoreToken core); + int core_setPosition(CoreToken core, int ms); + int core_getLength(CoreToken core); + int core_getPluginData(const wchar_t *playstring, const wchar_t *name, wchar_t *data, int data_len, int data_type = 0); + unsigned int core_getVolume(CoreToken core); + void core_setVolume(CoreToken core, unsigned int vol); + int core_getPan(CoreToken core); + void core_setPan(CoreToken core, int val); + void core_addCallback(CoreToken core, CoreCallback *cb); + void core_delCallback(CoreToken core, CoreCallback *cb); + int core_getVisData(CoreToken core, void *dataptr, int sizedataptr); + int core_getLeftVuMeter(CoreToken core); + int core_getRightVuMeter(CoreToken core); + int core_registerSequencer(CoreToken core, ItemSequencer *seq); + int core_deregisterSequencer(CoreToken core, ItemSequencer *seq); + void core_userButton(CoreToken core, int button); + int core_getEqStatus(CoreToken core); + void core_setEqStatus(CoreToken core, int enable); + int core_getEqPreamp(CoreToken core); + void core_setEqPreamp(CoreToken core, int pre); + int core_getEqBand(CoreToken core, int band); + void core_setEqBand(CoreToken core, int band, int val); + int core_getEqAuto(CoreToken core); + void core_setEqAuto(CoreToken core, int enable); + void core_setCustomMsg(CoreToken core, const wchar_t *text); + void core_registerExtension(const wchar_t *extensions, const wchar_t *extension_name, const wchar_t *family = NULL); + const wchar_t *core_getExtensionFamily(const wchar_t *extension); + void core_unregisterExtension(const wchar_t *extensions); + const wchar_t *core_getTitle(CoreToken core); + void core_setTitle(const wchar_t *new_title); + const wchar_t *core_getDecoderName(const wchar_t *filename); + // these don't necessarily belong here, but api_core is already over-bloated :) + int core_getRating(); + void core_setRating(int newRating); + + enum + { + API_CORE_GETSUPPORTEDEXTENSIONS = 0, + API_CORE_GETEXTSUPPORTEDEXTENSIONS = 10, + API_CORE_CREATE = 20, + API_CORE_FREE = 30, + API_CORE_SETNEXTFILE = 40, + API_CORE_GETSTATUS = 50, + API_CORE_GETCURRENT = 60, + API_CORE_GETCURPLAYBACKNUMBER = 70, + API_CORE_GETPOSITION = 80, + API_CORE_GETWRITEPOSITION = 90, + API_CORE_SETPOSITION = 100, + API_CORE_GETLENGTH = 110, + API_CORE_GETPLUGINDATA = 120, + API_CORE_GETVOLUME = 130, + API_CORE_SETVOLUME = 140, + API_CORE_GETPAN = 150, + API_CORE_SETPAN = 160, + API_CORE_ADDCALLBACK = 170, + API_CORE_DELCALLBACK = 180, + API_CORE_GETVISDATA = 190, + API_CORE_GETLEFTVUMETER = 200, + API_CORE_GETRIGHTVUMETER = 210, + API_CORE_REGISTERSEQUENCER = 220, + API_CORE_DEREGISTERSEQUENCER = 230, + API_CORE_USERBUTTON = 240, + API_CORE_GETEQSTATUS = 250, + API_CORE_SETEQSTATUS = 260, + API_CORE_GETEQPREAMP = 270, + API_CORE_SETEQPREAMP = 280, + API_CORE_GETEQBAND = 290, + API_CORE_SETEQBAND = 300, + API_CORE_GETEQAUTO = 310, + API_CORE_SETEQAUTO = 320, + API_CORE_SETCUSTOMMSG = 330, + API_CORE_REGISTEREXTENSION = 340, + API_CORE_GETEXTENSIONFAMILY = 350, + API_CORE_UNREGISTEREXTENSION = 360, + API_CORE_GETTITLE = 370, + API_CORE_GETRATING = 380, + API_CORE_SETRATING = 390, + API_CORE_GETDECODERNAME = 400, + API_CORE_SETTITLE = 410, + }; +}; + +inline const wchar_t *api_core::core_getSupportedExtensions() +{ + return _call(API_CORE_GETSUPPORTEDEXTENSIONS, (const wchar_t *)0); +} + +inline const wchar_t *api_core::core_getExtSupportedExtensions() +{ + return _call(API_CORE_GETEXTSUPPORTEDEXTENSIONS, (const wchar_t *)0); +} + +inline CoreToken api_core::core_create() +{ + return _call(API_CORE_CREATE, (CoreToken)NULL); +} + +inline int api_core::core_free(CoreToken core) +{ + return _call(API_CORE_FREE, (int)0, core); +} + +inline int api_core::core_setNextFile(CoreToken core, const wchar_t *playstring) +{ + return _call(API_CORE_SETNEXTFILE, (int)0, core, playstring); +} + +inline int api_core::core_getStatus(CoreToken core) +{ + return _call(API_CORE_GETSTATUS, (int)0, core); +} + +inline const wchar_t *api_core::core_getCurrent(CoreToken core) +{ + return _call(API_CORE_GETCURRENT, (const wchar_t *)0, core); +} + +inline int api_core::core_getCurPlaybackNumber(CoreToken core) +{ + return _call(API_CORE_GETCURPLAYBACKNUMBER, (int)0, core); +} + +inline int api_core::core_getPosition(CoreToken core) +{ + return _call(API_CORE_GETPOSITION, (int)0, core); +} + +inline int api_core::core_getWritePosition(CoreToken core) +{ + return _call(API_CORE_GETWRITEPOSITION, (int)0, core); +} + +inline int api_core::core_setPosition(CoreToken core, int ms) +{ + return _call(API_CORE_SETPOSITION, (int)0, core, ms); +} + +inline int api_core::core_getLength(CoreToken core) +{ + return _call(API_CORE_GETLENGTH, (int)0, core); +} + +inline int api_core::core_getPluginData(const wchar_t *playstring, const wchar_t *name, wchar_t *data, int data_len, int data_type) +{ + return _call(API_CORE_GETPLUGINDATA, (int)0, playstring, name, data, data_len, data_type); +} + +inline unsigned int api_core::core_getVolume(CoreToken core) +{ + return _call(API_CORE_GETVOLUME, (unsigned int)0, core); +} + +inline void api_core::core_setVolume(CoreToken core, unsigned int vol) +{ + _voidcall(API_CORE_SETVOLUME, core, vol); +} + +inline int api_core::core_getPan(CoreToken core) +{ + return _call(API_CORE_GETPAN, (int)0, core); +} + +inline void api_core::core_setPan(CoreToken core, int val) +{ + _voidcall(API_CORE_SETPAN, core, val); +} + +inline void api_core::core_addCallback(CoreToken core, CoreCallback *cb) +{ + _voidcall(API_CORE_ADDCALLBACK, core, cb); +} + +inline void api_core::core_delCallback(CoreToken core, CoreCallback *cb) +{ + _voidcall(API_CORE_DELCALLBACK, core, cb); +} + +inline int api_core::core_getVisData(CoreToken core, void *dataptr, int sizedataptr) +{ + return _call(API_CORE_GETVISDATA, (int)0, core, dataptr, sizedataptr); +} + +inline int api_core::core_getLeftVuMeter(CoreToken core) +{ + return _call(API_CORE_GETLEFTVUMETER, (int)0, core); +} + +inline int api_core::core_getRightVuMeter(CoreToken core) +{ + return _call(API_CORE_GETRIGHTVUMETER, (int)0, core); +} + +inline int api_core::core_registerSequencer(CoreToken core, ItemSequencer *seq) +{ + return _call(API_CORE_REGISTERSEQUENCER, (int)0, core, seq); +} + +inline int api_core::core_deregisterSequencer(CoreToken core, ItemSequencer *seq) +{ + return _call(API_CORE_DEREGISTERSEQUENCER, (int)0, core, seq); +} + +inline void api_core::core_userButton(CoreToken core, int button) +{ + _voidcall(API_CORE_USERBUTTON, core, button); +} + +inline int api_core::core_getEqStatus(CoreToken core) +{ + return _call(API_CORE_GETEQSTATUS, (int)0, core); +} + +inline void api_core::core_setEqStatus(CoreToken core, int enable) +{ + _voidcall(API_CORE_SETEQSTATUS, core, enable); +} + +inline int api_core::core_getEqPreamp(CoreToken core) +{ + return _call(API_CORE_GETEQPREAMP, (int)0, core); +} + +inline void api_core::core_setEqPreamp(CoreToken core, int pre) +{ + _voidcall(API_CORE_SETEQPREAMP, core, pre); +} + +inline int api_core::core_getEqBand(CoreToken core, int band) +{ + return _call(API_CORE_GETEQBAND, (int)0, core, band); +} + +inline void api_core::core_setEqBand(CoreToken core, int band, int val) +{ + _voidcall(API_CORE_SETEQBAND, core, band, val); +} + +inline int api_core::core_getEqAuto(CoreToken core) +{ + return _call(API_CORE_GETEQAUTO, (int)0, core); +} + +inline void api_core::core_setEqAuto(CoreToken core, int enable) +{ + _voidcall(API_CORE_SETEQAUTO, core, enable); +} + +inline void api_core::core_setCustomMsg(CoreToken core, const wchar_t *text) +{ + _voidcall(API_CORE_SETCUSTOMMSG, core, text); +} + +inline void api_core::core_registerExtension(const wchar_t *extensions, const wchar_t *extension_name, const wchar_t *family) +{ + _voidcall(API_CORE_REGISTEREXTENSION, extensions, extension_name, family); +} + +inline const wchar_t *api_core::core_getExtensionFamily(const wchar_t *extension) +{ + return _call(API_CORE_GETEXTENSIONFAMILY, (const wchar_t *)0, extension); +} + +inline void api_core::core_unregisterExtension(const wchar_t *extensions) +{ + _voidcall(API_CORE_UNREGISTEREXTENSION, extensions); +} + +inline const wchar_t *api_core::core_getTitle(CoreToken core) +{ + return _call(API_CORE_GETTITLE, (const wchar_t *)0, core); +} + +inline void api_core::core_setTitle(const wchar_t *new_title) +{ + _voidcall(API_CORE_SETTITLE, new_title); +} + +inline int api_core::core_getRating() +{ + return _call(API_CORE_GETRATING, (int)0); +} + + inline void api_core::core_setRating(int newRating) + { + _voidcall(API_CORE_SETRATING, newRating); + } + + inline const wchar_t *api_core::core_getDecoderName(const wchar_t *filename) + { + return _call(API_CORE_GETDECODERNAME, (const wchar_t *)0, filename); + } + +class api_coreI : public api_core +{ +public: + virtual const wchar_t *core_getSupportedExtensions() = 0; + virtual const wchar_t *core_getExtSupportedExtensions() = 0; + virtual CoreToken core_create() = 0; + virtual int core_free(CoreToken core) = 0; + virtual int core_setNextFile(CoreToken core, const wchar_t *playstring) = 0; + virtual int core_getStatus(CoreToken core) = 0; + virtual const wchar_t *core_getCurrent(CoreToken core) = 0; + virtual int core_getCurPlaybackNumber(CoreToken core) = 0; + virtual int core_getPosition(CoreToken core) = 0; + virtual int core_getWritePosition(CoreToken core) = 0; + virtual int core_setPosition(CoreToken core, int ms) = 0; + virtual int core_getLength(CoreToken core) = 0; + virtual int core_getPluginData(const wchar_t *playstring, const wchar_t *name, wchar_t *data, int data_len, int data_type = 0) = 0; + virtual unsigned int core_getVolume(CoreToken core) = 0; + virtual void core_setVolume(CoreToken core, unsigned int vol) = 0; + virtual int core_getPan(CoreToken core) = 0; + virtual void core_setPan(CoreToken core, int val) = 0; + virtual void core_addCallback(CoreToken core, CoreCallback *cb) = 0; + virtual void core_delCallback(CoreToken core, CoreCallback *cb) = 0; + virtual int core_getVisData(CoreToken core, void *dataptr, int sizedataptr) = 0; + virtual int core_getLeftVuMeter(CoreToken core) = 0; + virtual int core_getRightVuMeter(CoreToken core) = 0; + virtual int core_registerSequencer(CoreToken core, ItemSequencer *seq) = 0; + virtual int core_deregisterSequencer(CoreToken core, ItemSequencer *seq) = 0; + virtual void core_userButton(CoreToken core, int button) = 0; + virtual int core_getEqStatus(CoreToken core) = 0; + virtual void core_setEqStatus(CoreToken core, int enable) = 0; + virtual int core_getEqPreamp(CoreToken core) = 0; + virtual void core_setEqPreamp(CoreToken core, int pre) = 0; + virtual int core_getEqBand(CoreToken core, int band) = 0; + virtual void core_setEqBand(CoreToken core, int band, int val) = 0; + virtual int core_getEqAuto(CoreToken core) = 0; + virtual void core_setEqAuto(CoreToken core, int enable) = 0; + virtual void core_setCustomMsg(CoreToken core, const wchar_t *text) = 0; + virtual void core_registerExtension(const wchar_t *extensions, const wchar_t *extension_name, const wchar_t *family = NULL) = 0; + virtual const wchar_t *core_getExtensionFamily(const wchar_t *extension) = 0; + virtual void core_unregisterExtension(const wchar_t *extensions) = 0; + virtual const wchar_t *core_getTitle(CoreToken core) = 0; + virtual void core_setTitle(const wchar_t *new_title) = 0; + virtual int core_getRating()=0; + virtual void core_setRating(int newRating)=0; + virtual const wchar_t *core_getDecoderName(const wchar_t *filename)=0; + + +protected: + RECVS_DISPATCH; +}; + +// {966E3DA1-C2C5-43a9-A931-EB5F8B040A4F} +static const GUID coreApiServiceGuid = + { 0x966e3da1, 0xc2c5, 0x43a9, { 0xa9, 0x31, 0xeb, 0x5f, 0x8b, 0x4, 0xa, 0x4f } }; + +extern api_core *coreApi; + +#endif diff --git a/Src/Wasabi/api/core/buttons.h b/Src/Wasabi/api/core/buttons.h new file mode 100644 index 00000000..dbc43460 --- /dev/null +++ b/Src/Wasabi/api/core/buttons.h @@ -0,0 +1,18 @@ +#ifndef _BUTTONS_H +#define _BUTTONS_H + +// codes for + +namespace UserButton { + enum { + PREV=0, + PLAY, + PAUSE, + STOP, + NEXT, + }; + const int first = PREV; + const int last = NEXT; +}; + +#endif diff --git a/Src/Wasabi/api/core/coreactions.cpp b/Src/Wasabi/api/core/coreactions.cpp new file mode 100644 index 00000000..0a73ff77 --- /dev/null +++ b/Src/Wasabi/api/core/coreactions.cpp @@ -0,0 +1,181 @@ +#include + +#include "coreactions.h" + +#include +#include +#include +#include +#include +#include + +CoreActions::CoreActions() { + registerAction("prev", ACTION_PREV); + registerAction("play", ACTION_PLAY); + registerAction("pause", ACTION_PAUSE); + registerAction("stop", ACTION_STOP); + registerAction("next", ACTION_NEXT); + registerAction("eject", ACTION_EJECT); + registerAction("eject_url", ACTION_EJECTURL); + registerAction("eject_dir", ACTION_EJECTDIR); + registerAction("seek", ACTION_SEEK); + registerAction("volume", ACTION_VOLUME); + registerAction("pan", ACTION_PAN); + registerAction("volume_up", ACTION_VOLUME_UP); + registerAction("volume_down", ACTION_VOLUME_DOWN); + registerAction("rewind_5s", ACTION_REWIND_5S); + registerAction("ffwd_5s", ACTION_FFWD_5S); + registerAction("toggle_repeat", ACTION_TOGGLE_REPEAT); + registerAction("toggle_shuffle", ACTION_TOGGLE_SHUFFLE); + registerAction("toggle_crossfader", ACTION_TOGGLE_CROSSFADER); + registerAction("mute", ACTION_MUTE); + registerAction("eq_preamp", ACTION_EQ_PREAMP); + registerAction("eq_band", ACTION_EQ_BAND); + registerAction("eq_auto", ACTION_EQ_AUTO); + registerAction("eq_reset", ACTION_EQ_RESET); + registerAction("toggle_repeat", ACTION_TOGGLE_REPEAT); + registerAction("toggle_shuffle", ACTION_TOGGLE_SHUFFLE); + registerAction("toggle_crossfader", ACTION_TOGGLE_CROSSFADER); + registerAction("eq_toggle", ACTION_EQ_TOGGLE); + for (int i=0;i<4;i++) + registerAction(StringPrintf("play_cd%d", i+1), ACTION_PLAY_CD+i); +} + +CoreActions::~CoreActions() { +} + +int CoreActions::onActionId(int pvtid, const char *action, const char *param/* =NULL */, int p1/* =0 */, int p2/* =0 */, void *data/* =NULL */, int datalen/* =0 */, api_window *source/* =NULL */) { + int d = ATOI(param); + CoreHandle ch("main"); + switch(pvtid) { + case ACTION_PREV: { if (d==0) ch.prev(); } break; + case ACTION_PLAY: { if (d==0) ch.play(); } break; + case ACTION_PAUSE: { if (d==0) ch.pause(); } break; + case ACTION_STOP: { if (d==0) ch.stop(); } break; + case ACTION_NEXT: { if (d==0) ch.next(); } break; + + case ACTION_EJECT: { + svc_player *sp = SvcEnumByGuid(); + if (d == 0) { + if (sp) sp->openFiles(source, "files"); + } else { + if (sp) sp->openFiles(source); + } + WASABI_API_SVC->service_release(sp); + } + break; + case ACTION_EJECTURL: if (d==0) { + svc_player *sp = SvcEnumByGuid(); + if (sp) sp->openFiles(source, "location"); + api->service_release(sp); + } + break; + case ACTION_EJECTDIR: if (d==0) { + svc_player *sp = SvcEnumByGuid(); + if (sp) sp->openFiles(source, "directory"); + api->service_release(sp); + } + break; + + case ACTION_VOLUME_UP: if (d==0) { + int v=ch.getVolume(); + ch.setVolume(MIN(255,(v+5))); + } + break; + + case ACTION_VOLUME_DOWN: if (d==0) { + int v=ch.getVolume(); + ch.setVolume(MAX(0,(v-5))); + } + break; + + case ACTION_REWIND_5S: if (d==0) { + int p=ch.getPosition(); + ch.setPosition(MAX(0,(p-5000))); + } + break; + + case ACTION_FFWD_5S: if (d==0) { + int p=ch.getPosition(); + int mp=ch.getLength(); + ch.setPosition(MIN(mp,(p+5000))); + } + break; + + case ACTION_EQ_AUTO: + if (d==0) ch.setEqAuto(!ch.getEqAuto()); + break; + + case ACTION_EQ_RESET: { + if (d==0) for(int i=0;i<10;i++) ch.setEqBand(i,0); + } + break; + + case ACTION_EQ_TOGGLE: if (d==0) ch.setEqStatus(!ch.getEqStatus()); break; + + case ACTION_MUTE: if (d==0) { + ch.setMute(!ch.getMute());; + } + break; + + case ACTION_TOGGLE_REPEAT: + case ACTION_TOGGLE_SHUFFLE: if (d==0) { + // {45F3F7C1-A6F3-4ee6-A15E-125E92FC3F8D} + const GUID pledit_guid = + { 0x45f3f7c1, 0xa6f3, 0x4ee6, { 0xa1, 0x5e, 0x12, 0x5e, 0x92, 0xfc, 0x3f, 0x8d } }; + CfgItem *pli=WASABI_API_CONFIG->config_getCfgItemByGuid(pledit_guid); + if(pli) { + if(pvtid==ACTION_TOGGLE_REPEAT) pli->setDataAsInt("Repeat",!pli->getDataAsInt("Repeat")); + if(pvtid==ACTION_TOGGLE_SHUFFLE) pli->setDataAsInt("Shuffle",!pli->getDataAsInt("Shuffle")); + } + } + break; + + case ACTION_TOGGLE_CROSSFADER: if (d==0) { + // {FC3EAF78-C66E-4ED2-A0AA-1494DFCC13FF} + const GUID xfade_guid = + { 0xFC3EAF78, 0xC66E, 0x4ED2, { 0xA0, 0xAA, 0x14, 0x94, 0xDF, 0xCC, 0x13, 0xFF } }; + CfgItem *pli=WASABI_API_CONFIG->config_getCfgItemByGuid(xfade_guid); + if(pli) pli->setDataAsInt("Enable crossfading",!pli->getDataAsInt("Enable crossfading")); + } + break; + } + if (pvtid >= ACTION_PLAY_CD && pvtid < ACTION_PLAY_CD+16) if (d==0) { + const GUID cdda_guid = + { 0x86b40069, 0x126f, 0x4e11, { 0xa8, 0x7f, 0x55, 0x8f, 0xfa, 0x3d, 0xff, 0xa8 } }; +#if 0//BU: need some api to send messages like this + ComponentManager::sendNotify(cdda_guid, 12345, pvtid-ACTION_PLAY_CD); +#endif + } + return 1; +} + +const char *CoreActions::getHelp(int action) { + static String name; + switch (action) { + case ACTION_PREV: name = _("Previous track"); break; + case ACTION_PAUSE: name = _("Pause/Resume playback"); break; + case ACTION_STOP: name = _("Stop playback"); break; + case ACTION_NEXT: name = _("Next track"); break; + case ACTION_EJECT: name = _("Load file"); break; + case ACTION_EJECTURL: name = _("Load URL"); break; + case ACTION_EJECTDIR: name = _("Load directory"); break; + case ACTION_SEEK: name = _("Seek"); break; + case ACTION_VOLUME: name = _("Volume"); break; + case ACTION_PAN: name = _("Panning"); break; + case ACTION_EQ_TOGGLE: name = _("Toggle equalizer"); break; + case ACTION_EQ_PREAMP: name = _("Toggle preamplifier"); break; + case ACTION_EQ_BAND: name = _("Change equalizer band"); break; + case ACTION_EQ_AUTO: name = _("Auto equalizer"); break; + case ACTION_EQ_RESET: name = _("Reset equalizer"); break; + case ACTION_VOLUME_UP: name = _("Volume up"); break; + case ACTION_VOLUME_DOWN: name = _("Volume down"); break; + case ACTION_REWIND_5S: name = _("Rewind 5 seconds"); break; + case ACTION_FFWD_5S: name = _("Fast forward 5 seconds"); break; + case ACTION_MUTE: name = _("Mute/Unmute sound"); break; + case ACTION_TOGGLE_REPEAT: name = _("Toggle repeat"); break; + case ACTION_TOGGLE_SHUFFLE: name = _("Toggle shuffle"); break; + case ACTION_TOGGLE_CROSSFADER: name = _("Toggle crossfader"); break; + } + return name; +} diff --git a/Src/Wasabi/api/core/coreactions.h b/Src/Wasabi/api/core/coreactions.h new file mode 100644 index 00000000..81abc37d --- /dev/null +++ b/Src/Wasabi/api/core/coreactions.h @@ -0,0 +1,47 @@ +#ifndef __COREACTIONS_H +#define __COREACTIONS_H + +#include + +class CoreActions : public svc_actionI { + public : + CoreActions(); + virtual ~CoreActions(); + + static const char *getServiceName() { return "Core Actions"; } + virtual int onActionId(int pvtid, const wchar_t *action, const wchar_t *param=NULL, int p1=0, int p2=0, void *data=NULL, int datalen=0, ifc_window *source=NULL); + virtual const wchar_t *getHelp(int action); + + private: + + enum { + ACTION_PREV = 0, + ACTION_PLAY, + ACTION_PAUSE, + ACTION_STOP, + ACTION_NEXT, + ACTION_EJECT, + ACTION_EJECTURL, + ACTION_EJECTDIR, + ACTION_SEEK, + ACTION_VOLUME, + ACTION_EQ_TOGGLE, + ACTION_EQ_PREAMP, + ACTION_EQ_BAND, + ACTION_VOLUME_UP, + ACTION_VOLUME_DOWN, + ACTION_REWIND_5S, + ACTION_FFWD_5S, + ACTION_PLAY_CD, + ACTION_EQ_AUTO = ACTION_PLAY_CD+16, + ACTION_EQ_RESET, + ACTION_PAN, + ACTION_MUTE, + ACTION_TOGGLE_REPEAT, + ACTION_TOGGLE_SHUFFLE, + ACTION_TOGGLE_CROSSFADER, + ACTION_PREFS, + }; +}; + +#endif diff --git a/Src/Wasabi/api/core/corehandle.cpp b/Src/Wasabi/api/core/corehandle.cpp new file mode 100644 index 00000000..492ef910 --- /dev/null +++ b/Src/Wasabi/api/core/corehandle.cpp @@ -0,0 +1,304 @@ +#include + +#include "corehandle.h" + +#include +#include +#include +#include // for castService + +using namespace UserButton; + +static svc_coreAdmin *da_coreadmin=NULL; +static int instancecount=0; + +static void initDaCoreAdmin() { + if(!da_coreadmin) { + if (WASABI_API_SVC != NULL) { + waServiceFactory *s=WASABI_API_SVC->service_enumService(WaSvc::COREADMIN,0); + if (s != NULL) { +//CUT ASSERTPR(s,"Core Admin non present!"); + da_coreadmin=castService(s); + } + } + } +} + +CoreHandle::CoreHandle(CoreToken tok) { + initDaCoreAdmin(); + instancecount++; + createdcore=0; + token = NO_CORE_TOKEN; + if (da_coreadmin) { + if(da_coreadmin->verifyToken(tok)) token=tok; + else { + token=da_coreadmin->createCore(); + createdcore=1; + } + } +} + +CoreHandle::CoreHandle(const char *name) { + initDaCoreAdmin(); + instancecount++; + createdcore=0; + token = NO_CORE_TOKEN; + if (da_coreadmin) { + token=da_coreadmin->nameToToken(name); + if(token==-1) { + token=da_coreadmin->createCore(name); + createdcore=1; + } + } +} + +CoreHandle::~CoreHandle() { + instancecount--; + if (da_coreadmin) { + if(createdcore) da_coreadmin->freeCoreByToken(token); + if(!instancecount) { + WASABI_API_SVC->service_release(da_coreadmin); + da_coreadmin=NULL; + } + } +} + +int CoreHandle::isCoreLoaded() { + if (!da_coreadmin) return FALSE; + return TRUE; +} + +int CoreHandle::setNextFile(const char *playstring, const char *destination) { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->setNextFile(token, playstring, destination); +} + +void CoreHandle::prev() { + userButton(PREV); +} + +void CoreHandle::play() { + userButton(PLAY); +} + +void CoreHandle::pause() { + userButton(PAUSE); +} + +void CoreHandle::stop() { + userButton(STOP); +} + +void CoreHandle::next() { + userButton(NEXT); +} + +void CoreHandle::userButton(int button) { + if (da_coreadmin == NULL) return; + da_coreadmin->userButton(token, button); +} + +const char *CoreHandle::getSupportedExtensions() { + if (da_coreadmin == NULL) return ""; + return da_coreadmin->getSupportedExtensions(); +} + +const char *CoreHandle::getExtSupportedExtensions() { + if (da_coreadmin == NULL) return ""; + return da_coreadmin->getExtSupportedExtensions(); +} + +const char *CoreHandle::getExtensionFamily(const char *extension) { + if (da_coreadmin == NULL) return ""; + return da_coreadmin->getExtensionFamily(extension); +} + +void CoreHandle::registerExtension(const char *extensions, const char *extension_name) { + if (da_coreadmin == NULL) return; + da_coreadmin->registerExtension(extensions, extension_name); +} + +void CoreHandle::unregisterExtension(const char *extensions) { + if (da_coreadmin == NULL) return; + da_coreadmin->unregisterExtension(extensions); +} + +String CoreHandle::getTitle() { + if (da_coreadmin == NULL) return String(""); + return String(da_coreadmin->getTitle(token)); +} + +int CoreHandle::getStatus() { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->getStatus(token); +} + +const char *CoreHandle::getCurrent() { + if (da_coreadmin == NULL) return ""; + return da_coreadmin->getCurrent(token); +} + +int CoreHandle::getNumTracks() { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->getNumTracks(token); +} + +int CoreHandle::getCurPlaybackNumber() { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->getCurPlaybackNumber(token); +} + +int CoreHandle::getPosition() { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->getPosition(token); +} + +int CoreHandle::getWritePosition() { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->getWritePosition(token); +} + +int CoreHandle::setPosition(int ms) { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->setPosition(token,ms); +} + +int CoreHandle::getLength() { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->getLength(token); +} + +int CoreHandle::getPluginData(const char *playstring, const char *name, char *data, int data_len, int data_type) { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->getPluginData(playstring, name, data, data_len, data_type); +} + +unsigned int CoreHandle::getVolume() { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->getVolume(token); +} + +void CoreHandle::setVolume(unsigned int vol) { + if (da_coreadmin == NULL) return; + da_coreadmin->setVolume(token, vol); +} + +int CoreHandle::getPan() { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->getPan(token); +} + +void CoreHandle::setPan(int bal) { + if (da_coreadmin == NULL) return; + da_coreadmin->setPan(token, bal); +} + +void CoreHandle::setMute(int mute) { + if (da_coreadmin == NULL) return; + da_coreadmin->setMute(token, mute); +} + +int CoreHandle::getMute() { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->getMute(token); +} + +void CoreHandle::addCallback(CoreCallback *cb) { + if (da_coreadmin == NULL) return; + da_coreadmin->addCallback(token, cb); +} + +void CoreHandle::delCallback(CoreCallback *cb) { + if (da_coreadmin == NULL) return; + da_coreadmin->delCallback(token, cb); +} + +int CoreHandle::getVisData(void *dataptr, int sizedataptr) { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->getVisData(token, dataptr, sizedataptr); +} + +int CoreHandle::getLeftVuMeter() { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->getLeftVuMeter(token); +} + +int CoreHandle::getRightVuMeter() { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->getRightVuMeter(token); +} + +int CoreHandle::registerSequencer(ItemSequencer *seq) { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->registerSequencer(token, seq); +} + +int CoreHandle::deregisterSequencer(ItemSequencer *seq) { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->deregisterSequencer(token, seq); +} + +ItemSequencer *CoreHandle::getSequencer() { + if (da_coreadmin == NULL) return NULL; + return da_coreadmin->getSequencer(token); +} + +int CoreHandle::getEqStatus() { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->getEqStatus(token); +} + +void CoreHandle::setEqStatus(int enable) { + if (da_coreadmin == NULL) return; + da_coreadmin->setEqStatus(token, enable); +} + +int CoreHandle::getEqPreamp() { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->getEqPreamp(token); +} + +void CoreHandle::setEqPreamp(int pre) { + if (da_coreadmin == NULL) return; + da_coreadmin->setEqPreamp(token, pre); +} + +int CoreHandle::getEqBand(int band) { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->getEqBand(token, band); +} + +void CoreHandle::setEqBand(int band, int val) { + if (da_coreadmin == NULL) return; + da_coreadmin->setEqBand(token, band, val); +} + +int CoreHandle::getEqAuto() { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->getEqAuto(token); +} + +void CoreHandle::setEqAuto(int enable) { + if (da_coreadmin == NULL) return; + da_coreadmin->setEqAuto(token, enable); +} + +void CoreHandle::setPriority(int priority) { + if (da_coreadmin == NULL) return; + da_coreadmin->setPriority(token, priority); +} + +int CoreHandle::getPriority() { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->getPriority(token); +} + +void CoreHandle::rebuildConvertersChain() { + if (da_coreadmin == NULL) return; + da_coreadmin->rebuildConvertersChain(token); +} + +int CoreHandle::sendConvertersMsg(const char *msg, const char *value) { + if (da_coreadmin == NULL) return 0; + return da_coreadmin->sendConvertersMsg(token, msg, value); +} diff --git a/Src/Wasabi/api/core/corehandle.h b/Src/Wasabi/api/core/corehandle.h new file mode 100644 index 00000000..0dc09eac --- /dev/null +++ b/Src/Wasabi/api/core/corehandle.h @@ -0,0 +1,560 @@ +#ifndef _COREHANDLE_H +#define _COREHANDLE_H + +#include + +// a helper class to access the playback cores within an object for you + +typedef unsigned int CoreToken; +#define NO_CORE_TOKEN (CoreToken)(0xffffffff) + +// Fwd References +class CfgItem; +class ItemSequencer; + +/** + Helper class to access the currently instantiated + playback cores. + + To create a corehandle on the main playback core + use the core token value from the enum ("maincore_token") or + the core name "main". + + Here is an example: + CoreHandle * ch = new CoreHandle("main"); + + @short Access playback cores. + @author Nullsoft + @ver 1.0 + @see Core +*/ +class CoreHandle { +public: + enum { maincore_token=0 }; + + /** + Create a new CoreHandle while optionally + setting the core token to be used. + + Core tokens are handles to cores + currently instantiated. + + @see CoreHandle(const char *name) + @param token Core token of the core to attach to. + */ + CoreHandle(CoreToken token=maincore_token); + + /** + Create a new CoreHandle for a core + using it's name. + + The main core name is "main". + + @see CoreHandle(CoreToken toke=maincore_token) + @param name Name of the core to attach to. + */ + CoreHandle(const wchar_t *name); + + /** + Detaches the CoreHandle from the Core. + */ + virtual ~CoreHandle(); + + int isCoreLoaded(); // are we attached to a core? + + /** + Get the list of supported extensions + from the core. This is a zero delimited list + with double zero termination. + + @see getExtSupportedExtensions() + @see getExtensionFamily() + @ret List of supported extensions. + */ + const char *getSupportedExtensions(); //just the *.mp3 or whatever + + /** + Get the extended list of supported extensions + from the core. This will include the proper + names of the extensions, for example: + "MP3 Files (*.mp3)". + + This is returned as a zero delimited list with double + zero termination. + + @see getSupportedExtensions() + @see getExtensionFamily() + @ret Extended list of supported extensions. + */ + const char *getExtSupportedExtensions(); // including names + + /** + Get the family name to which the extension + is associated with (Families are "Audio", "Video", etc.) + + @see getExtSupportedExtensions() + @see getSupportedExtensions() + @ret Family name of the extension. + @param extension Extension to get family name of. + */ + const wchar_t *getExtensionFamily(const wchar_t *extension); + + /** + Register an extension with the core. + + @see unregisterExtension() + @see getExtSupportedExtensions() + @see getSupportedExtensions() + @see getExtensionFamily() + @param extensions Extension to register. + @param extension_name Name of the extension. + */ + void registerExtension(const char *extensions, const char *extension_name); + + /** + Unregister an extension with the core. + + @see registerExtension() + @see getExtSupportedExtensions() + @see getSupportedExtensions() + @see getExtensionFamily() + @param extensions Extension to unregister. + */ + void unregisterExtension(const char *extensions); + + String getTitle(); + + /** + Set the next file to be played by the core. + + You can manually select the output of this + file. Either "WAVEOUT" or "DIRECTSOUND". If + you do not specify one, it will be automatically + selected for you. + + @ret 1, success; 0, failure; + @param playstring Playstring of the next file to be played. + @param destination Output to be used for the next file. + */ + int setNextFile(const char *playstring, const char *destination=NULL); + + /** + Get the playback status of the core. + + @see pause() + @see play() + @see stop() + @ret -1, Paused; 0, Stopped; 1, Playing; + */ + int getStatus(); // returns -1 if paused, 0 if stopped and 1 if playing + + /** + Get the playstring of the currently playing + item. + + @ret Playstring of the currently playing item. + */ + const char *getCurrent(); + + /** + Get the number of items (tracks) present + in the currently registered sequencer. + + @see getCurPlaybackNumber() + @ret Number of items present in the sequencer. + */ + int getNumTracks(); + + /** + Get the index number of the currently + playing item of the currently registered + sequencer. + + @see getNumTracks() + @ret Index number (in the sequencer) of the item playing. + */ + int getCurPlaybackNumber(); + + /** + Get the playback position of the currently + playing file. + + @see getWritePosition() + @see getLength() + @see setPosition() + @ret Position in the file (in milliseconds). + */ + int getPosition(); + + /** + Help? + + @see getPosition() + @see getLength() + @see setPosition() + @ret Current write position (in milliseconds). + */ + int getWritePosition(); + + /** + Seek to a specific position in the + currently playing item. + + @see getPosition() + @see getLength() + @see getWritePosition() + @ret 1, Success; 0, Failure; + @param ms Position in the file (in milliseconds, 0 being the beginning). + */ + int setPosition(int ms); + + /** + Get the length of the currently + playing item. + + @see getPosition() + @see setPosition() + @see getWritePosition() + @ret Length of the item (in milliseconds). + */ + int getLength(); + + // this method queries the core plugins directly, bypassing the db + /** + */ + int getPluginData(const char *playstring, const char *name, + char *data, int data_len, int data_type=0); // returns size of data + + /** + Get the volume of the core. + + @see setVolume() + @see getMute() + @see setMute() + @ret Volume (0 to 255). + */ + unsigned int getVolume(); // 0..255 + + /** + Set the volume of the core. + + @see getVolume() + @see getMute() + @see setMute() + @param vol Volume (0 to 255). + */ + void setVolume(unsigned int vol); // 0..255 + + /** + Get the panning value of the core. + + @see setPan() + @ret Panning value (-127 [left] to 127 [right]). + */ + int getPan(); // -127..127 + + /** + Set the panning value of the core. + + @see getPan() + @param bal Panning value (-127 [left] to 127 [right]) + */ + void setPan(int bal); // -127..127 + + /** + Mute the output. + + @see getVolume() + @see setVolume() + @see getMute() + @param mute 0, No muting; 1, Mute; + */ + void setMute(int mute); + + /** + Get the mute state of the output. + @see getVolume() + @see setVolume() + @see setMute() + @ret 0, Not muted; 1, Muted; + */ + int getMute(); + + // register here for general callbacks in core status. + /** + Register a callback with the core to + receive core status callbacks. + + @see delCallback() + @param cb Core Callback to register. + */ + void addCallback(CoreCallback *cb); + + /** + Unregister a callback with the core. + + @see addCallback() + @param cb Core Callback to unregister. + */ + void delCallback(CoreCallback *cb); + + // get visualization data, returns 0 if you should blank out + /** + Get visualization data for the currently + playing item. + + We suggest using a struct like this to read the vis + data: + + typedef struct { + enum { + LEFT = 0, + RIGHT = 1 + }; + unsigned char spectrumData[2][576]; + char waveformData[2][576]; + } VisData; + + A call using this struct would like so: + + getVisData(&myVisData, sizeof(VisData)); + + @see getLeftVuMeter() + @see getRightVuMeter() + @ret 0, If there is no VIS data; > 0, VIS data available; + @param dataptr Buffer to receive VIS data. + @param sizedataptr Size of the buffer. + */ + int getVisData(void *dataptr, int sizedataptr); + + /** + Get the value of the left VU meter. + + @see getVisData() + @see getRightVuMeter() + @ret Value of the left VU meter (0 to 255). + */ + int getLeftVuMeter(); + + /** + Get the value of the left VU meter. + + @see getVisData() + @see getLeftVuMeter() + @ret Value of the right VU meter (0 to 255). + */ + int getRightVuMeter(); + + /** + Register an item sequencer with the core. + The item sequencer feeds the playstrings + of the next item to be played to the core. + + @see deregisterSequencer() + @ret 1, Success; 0, Failure; + @param seq Sequencer to register. + */ + int registerSequencer(ItemSequencer *seq); + + /** + Unregister a sequencer with the core. + + @see registerSequencer() + @ret 1, Success; 0, Failure; + @param seq Sequencer to unregister. + */ + int deregisterSequencer(ItemSequencer *seq); + + ItemSequencer *getSequencer(); + + /** + Get the EQ status. + + @see setEqStatus() + @see getEqPreamp() + @see setEqPreamp() + @see getEqBand() + @see setEqBand() + @ret 1, On; 0, Off; + */ + int getEqStatus(); // returns 1 if on, 0 if off + + /** + Set the EQ state. + + @see getEqStatus() + @see getEqPreamp() + @see setEqPreamp() + @see getEqBand() + @see setEqBand() + @param enable 1, On; 0, Off; + */ + void setEqStatus(int enable); + + /** + Get the pre-amp value of the EQ. + + @see setEqStatus() + @see getEqStatus() + @see setEqPreamp() + @see getEqBand() + @see setEqBand() + @ret Pre-amp value (-127 [-20dB] to 127 [+20dB]). + */ + int getEqPreamp(); // -127 to 127 (-20db to +20db) + + /** + Set the pre-amp value of the EQ. + + @see setEqStatus() + @see getEqStatus() + @see getEqPreamp() + @see getEqBand() + @see setEqBand() + @param pre Pre-amp value (-127 [-20dB] to 127 [+20dB]). + */ + void setEqPreamp(int pre); + + /** + Get the value of an EQ band. There + are 10 bands available. + + Here is the list: + + 0 - 60 Hz 1 - 170 Hz + 2 - 310 Hz 3 - 600 Hz + 4 - 1 kHz 5 - 3 kHz + 6 - 6 kHz 7 - 12 kHz + 8 - 14 kHz 9 - 16 kHz + + @see setEqStatus() + @see getEqStatus() + @see getEqPreamp() + @see setEqBand() + @ret EQ band value (-127 [-20dB] to 127 [+20dB]). + @param band EQ band to read (0 to 9). + */ + int getEqBand(int band); // band=0-9 + + /** + Set the value of an EQ band. There + are 10 bands available. + + Here is the list: + + 0 - 60 Hz 1 - 170 Hz + 2 - 310 Hz 3 - 600 Hz + 4 - 1 kHz 5 - 3 kHz + 6 - 6 kHz 7 - 12 kHz + 8 - 14 kHz 9 - 16 kHz + + @see setEqStatus() + @see getEqStatus() + @see getEqPreamp() + @see setEqBand() + @param band EQ band to set (0 to 9) + @param val EQ band value (-127 [-20dB] to 127 [+20dB]). + */ + void setEqBand(int band, int val); + + /** + Get the automatic EQ preset loading state. + + @see setEqAuto() + @ret 1, On; 0, Off; + */ + int getEqAuto(); // returns 1 if on, 0 if off + + /** + Set the automatic EQ preset loading. + + @see getEqAuto() + @param enable 1, On; 0, Off; + */ + void setEqAuto(int enable); + + /** + Trigger the previous event. + + @see next() + @see play() + @see stop() + @see pause() + */ + void prev(); + + /** + Trigger the play event. + + @see prev() + @see next() + @see stop() + @see pause() + */ + void play(); + + /** + Trigger the pause event. + + @see prev() + @see next() + @see stop() + @see play() + */ + void pause(); + + /** + Trigger the stop event. + */ + void stop(); + + /** + Trigger the next event. + + @see prev() + @see stop() + @see play() + @see pause() + */ + void next(); + + /** + Set the thread priority of the core. + + @see getPriority() + @param priority Thread priority. + */ + void setPriority(int priority); + + /** + Get the thread priority of the core. + + @see setPriority() + @ret Thread priority level. + */ + int getPriority(); + + /** + As the function name implies, rebuilds the converters chain (no shit?) + */ + void rebuildConvertersChain(); + + /** + Send a message to all converters in the current + playback chain of a core. + + It's possible to pass any pointer using this messanging + system, as long as the pointer is valid across dll boundries. + + @param msg Message. + @param value Message value. + */ + int sendConvertersMsg(const char *msg, const char *value); + +private: + void userButton(int button); + CoreToken token; + int createdcore; +}; + +#endif diff --git a/Src/Wasabi/api/core/sequence.cpp b/Src/Wasabi/api/core/sequence.cpp new file mode 100644 index 00000000..feea799a --- /dev/null +++ b/Src/Wasabi/api/core/sequence.cpp @@ -0,0 +1,92 @@ +#include "precomp.h" + +#include "sequence.h" + +#define CBCLASS ItemSequencerI +START_DISPATCH; + CB(GETDEPENDENCYPTR, getDependencyPtr); + CB(GETNEXTPLAYITEM, getNextPlayItem); + CB(GETCURRENTPLAYBACKNUMBER, getCurrentPlaybackNumber); + CB(GETNUMITEMS, getNumItems); + CB(REWIND, rewind); + CB(FORWARD, forward); + CB(ONNOTIFY, onNotify); +END_DISPATCH; +#undef CBCLASS + +int ItemSequencerI::onNotify(int msg, int param1, int param2) { + switch (msg) { + case SEQNOTIFY_ONREGISTER: return onRegister(); + case SEQNOTIFY_ONDEREGISTER: return onDeregister(); + case SEQNOTIFY_ONNEXTFILE: return onNextFile(); + case SEQNOTIFY_ONTITLECHANGE: return onTitleChange(); + case SEQNOTIFY_ONSTARTED: return onStarted(); + case SEQNOTIFY_ONSTOPPED: return onStopped(); + case SEQNOTIFY_ONPAUSED: return onPaused(); + case SEQNOTIFY_ONUNPAUSED: return onUnpaused(); + } + return 0; +} + +const char *ListSequencer::getNextPlayItem() { + int pos; + const char *ret; + + pos = getCurrent(); + + if (pos < 0) return NULL; + + ret = enumItem(pos); + + setCurrent(pos); + + return ret; +} + +int ListSequencer::rewind() { + + int pos; + + pos = getCurrent(); + + if (pos < 0) return 0; + + pos--; + + if (pos < 0) { + if (loop()) { + pos = getNumEntries()-1; + } else { + pos++; + } + } + + setCurrent(pos); + return 1; +} + +int ListSequencer::forward() { + + int pos; + + pos = getCurrent(); + + if (pos < 0) return 0; + + pos++; + + if (pos >= getNumEntries()) { + if (loop()) { + pos = 0; + } else { + return 0; + } + } + + setCurrent(pos); + return 1; +} + +int ListSequencer::getNumItems() { + return getNumEntries(); +} diff --git a/Src/Wasabi/api/core/sequence.h b/Src/Wasabi/api/core/sequence.h new file mode 100644 index 00000000..281cd541 --- /dev/null +++ b/Src/Wasabi/api/core/sequence.h @@ -0,0 +1,123 @@ +//PORTABLE +#ifndef _SEQUENCE_H +#define _SEQUENCE_H + +#include +#include + +// abstracted version of a playback order +class ItemSequencer : public Dispatchable { +public: + api_dependent *getDependencyPtr(); + + const char *getNextPlayItem(); + int getCurrentPlaybackNumber(); // 0-based, -1 if you don't know + int getNumItems(); // -1 if you don't know + int rewind(); + int forward(); + + int onNotify(int msg, int param1=0, int param2=0); + +protected: + enum { + GETNEXTPLAYITEM=100, + GETCURRENTPLAYBACKNUMBER=101, + GETNUMITEMS=102, + REWIND=200, + FORWARD=210, + ONNOTIFY=300, + GETDEPENDENCYPTR=400, + }; +}; + +inline api_dependent *ItemSequencer::getDependencyPtr() { + return _call(GETDEPENDENCYPTR, (api_dependent*)NULL); +} + +inline const char *ItemSequencer::getNextPlayItem() { + return _call(GETNEXTPLAYITEM, (const char *)NULL); +} + +inline +int ItemSequencer::getCurrentPlaybackNumber() { + return _call(GETCURRENTPLAYBACKNUMBER, -1); +} + +inline +int ItemSequencer::getNumItems() { + return _call(GETNUMITEMS, -1); +} + +inline int ItemSequencer::rewind() { + return _call(REWIND, 0); +} + +inline int ItemSequencer::forward() { + return _call(FORWARD, 0); +} + +inline int ItemSequencer::onNotify(int msg, int param1, int param2) { + return _call(ONNOTIFY, 0, msg, param1, param2); +} + +#define SEQNOTIFY_ONREGISTER 10 +#define SEQNOTIFY_ONDEREGISTER 20 +#define SEQNOTIFY_ONNEXTFILE 30 +#define SEQNOTIFY_ONTITLECHANGE 40 +#define SEQNOTIFY_ONSTARTED 50 +#define SEQNOTIFY_ONSTOPPED 60 +#define SEQNOTIFY_ONPAUSED 70 +#define SEQNOTIFY_ONUNPAUSED 80 + +// override this one +class ItemSequencerI : public ItemSequencer, public DependentI { +public: + api_dependent *getDependencyPtr() { return this; } + + virtual int rewind()=0; + virtual int forward()=0; + virtual const char *getNextPlayItem()=0; + virtual int getCurrentPlaybackNumber() { return -1; } + virtual int getNumItems() { return -1; } + + // these are optional callbacks + virtual int onRegister() { return 0; }; + virtual int onDeregister() { return 0; }; + virtual int onNextFile() { return 0; }// on transition + virtual int onTitleChange() { return 0; } + virtual int onStarted() { return 0; } + virtual int onStopped() { return 0; } + virtual int onPaused() { return 0; } + virtual int onUnpaused() { return 0; } + +protected: + // default implementation calls above callback methods based on msg + virtual int onNotify(int msg, int param1, int param2); + + RECVS_DISPATCH; +}; + +// also somewhat abstract, but implements playing through some arbitrary +// list. just override the protected stuff +class ListSequencer : public ItemSequencerI { +public: + virtual const char *getNextPlayItem(); + virtual int rewind(); + virtual int forward(); + +protected: + // override these 4 only + virtual int getNumEntries()=0; + virtual const char *enumItem(int pos)=0; + virtual int getCurrent()=0; + virtual int setCurrent(int cur)=0; + +protected: + virtual int loop() { return 0; } // override as necessary + +private: + virtual int getNumItems(); // calls getNumEntries() +}; + +#endif + diff --git a/Src/Wasabi/api/dependency/api_dependent.cpp b/Src/Wasabi/api/dependency/api_dependent.cpp new file mode 100644 index 00000000..9ba862df --- /dev/null +++ b/Src/Wasabi/api/dependency/api_dependent.cpp @@ -0,0 +1,2 @@ +#include +#include "api_dependent.h" \ No newline at end of file diff --git a/Src/Wasabi/api/dependency/api_dependent.h b/Src/Wasabi/api/dependency/api_dependent.h new file mode 100644 index 00000000..23b7a54a --- /dev/null +++ b/Src/Wasabi/api/dependency/api_dependent.h @@ -0,0 +1,54 @@ +#ifndef __WASABI_API_DEPENDENT_H +#define __WASABI_API_DEPENDENT_H + +#include +#include "api_dependentviewer.h" + +// we define some common event codes here. if your object needs more send +// them as parameters to OBJECTSPECIFIC + +// some system-level codes for cb param. You can implement your own events +// with DEPCB_EVENT and the parameters +namespace DependentCB +{ + enum { + DEPCB_NOP = 0, + DEPCB_DELETED = 100, // object being deleted + DEPCB_EVENT = 1000, // object-specific event. use param1 etc to send your messages + }; +}; + +class NOVTABLE ifc_dependent : public Dispatchable +{ +protected: + ifc_dependent() {} + ~ifc_dependent() {} +public: + void dependent_regViewer(ifc_dependentviewer *viewer, int add) ; + void *dependent_getInterface(const GUID *classguid); + + DISPATCH_CODES + { + API_DEPENDENT_REGVIEWER = 10, + API_DEPENDENT_GETINTERFACE = 20, + }; +}; + +inline void ifc_dependent::dependent_regViewer(api_dependentviewer *viewer, int add) + { + _voidcall(API_DEPENDENT_REGVIEWER, viewer, add); + } + inline void *ifc_dependent::dependent_getInterface(const GUID *classguid) + { + return _call(API_DEPENDENT_GETINTERFACE, (void *)0, classguid); + } + + +// this is a helper for dependent_getInterface +#define HANDLEGETINTERFACE(x) { \ + if (*classguid == *x::depend_getClassGuid()) return static_cast(this); \ + } + +typedef ifc_dependent api_dependent; + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/dependency/api_dependentviewer.cpp b/Src/Wasabi/api/dependency/api_dependentviewer.cpp new file mode 100644 index 00000000..df550071 --- /dev/null +++ b/Src/Wasabi/api/dependency/api_dependentviewer.cpp @@ -0,0 +1,2 @@ +#include +#include "api_dependentviewer.h" \ No newline at end of file diff --git a/Src/Wasabi/api/dependency/api_dependentviewer.h b/Src/Wasabi/api/dependency/api_dependentviewer.h new file mode 100644 index 00000000..160bac9d --- /dev/null +++ b/Src/Wasabi/api/dependency/api_dependentviewer.h @@ -0,0 +1,30 @@ +#ifndef __WASABI_API_DEPENDENTVIEWER_H +#define __WASABI_API_DEPENDENTVIEWER_H + +#include +#include +class ifc_dependent; + +class NOVTABLE ifc_dependentviewer : public Dispatchable +{ +protected: + ifc_dependentviewer() {} + ~ifc_dependentviewer() {} +public: + // item calls when it changes or disappears, or whatever + int dependentViewer_callback(ifc_dependent *item, const GUID *classguid, int cb, intptr_t param1 = 0, intptr_t param2 = 0, void *ptr = NULL, size_t ptrlen = 0); + + DISPATCH_CODES + { + DEPENDENTVIEWER_CALLBACK = 10, + }; +}; + +inline int ifc_dependentviewer::dependentViewer_callback(ifc_dependent *item, const GUID *classguid, int cb, intptr_t param1 , intptr_t param2 , void *ptr , size_t ptrlen) +{ + return _call(DEPENDENTVIEWER_CALLBACK, (int)0, item, classguid, cb, param1, param2, ptr, ptrlen); +} + +typedef ifc_dependentviewer api_dependentviewer; + +#endif diff --git a/Src/Wasabi/api/filereader/api_filereader.cpp b/Src/Wasabi/api/filereader/api_filereader.cpp new file mode 100644 index 00000000..50b558b8 --- /dev/null +++ b/Src/Wasabi/api/filereader/api_filereader.cpp @@ -0,0 +1,20 @@ +#include +#include "api_filereader.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif +#define CBCLASS api_fileReaderI +START_DISPATCH; + CB(API_FILEREADER_FILEOPEN, fileOpen); + VCB(API_FILEREADER_FILECLOSE, fileClose); + CB(API_FILEREADER_FILEREAD, fileRead); + CB(API_FILEREADER_FILEWRITE, fileWrite); + CB(API_FILEREADER_FILESEEK, fileSeek); + CB(API_FILEREADER_FILETELL, fileTell); + CB(API_FILEREADER_FILEGETFILESIZE, fileGetFileSize); +// CB(API_FILEREADER_FILEEXISTS, fileExists); + CB(API_FILEREADER_FILEREMOVE, fileRemove); + CB(API_FILEREADER_FILEREMOVEUNDOABLE, fileRemoveUndoable); + CB(API_FILEREADER_FILEMOVE, fileMove); +END_DISPATCH; diff --git a/Src/Wasabi/api/filereader/api_filereader.h b/Src/Wasabi/api/filereader/api_filereader.h new file mode 100644 index 00000000..427c276f --- /dev/null +++ b/Src/Wasabi/api/filereader/api_filereader.h @@ -0,0 +1,104 @@ +#ifndef __API_FILEREADER_H +#define __API_FILEREADER_H + +#include + +class NOVTABLE api_fileReader : public Dispatchable +{ + public: + void *fileOpen(const wchar_t *filename, OSFNCSTR mode); + void fileClose(void *fileHandle); + size_t fileRead(void *buffer, size_t size, void *fileHandle); + size_t fileWrite(const void *buffer, int size, void *fileHandle); + int fileSeek(int64_t offset, int origin, void *fileHandle); + uint64_t fileTell(void *fileHandle); + uint64_t fileGetFileSize(void *fileHandle); + //int fileExists(const wchar_t *filename); + int fileRemove(const wchar_t *filename); + int fileRemoveUndoable(const wchar_t *filename); + int fileMove(const wchar_t *filename, const wchar_t *destfilename); + + enum { + API_FILEREADER_FILEOPEN = 0, + API_FILEREADER_FILECLOSE = 10, + API_FILEREADER_FILEREAD = 20, + API_FILEREADER_FILEWRITE = 30, + API_FILEREADER_FILESEEK = 40, + API_FILEREADER_FILETELL = 50, + API_FILEREADER_FILEGETFILESIZE = 60, + //API_FILEREADER_FILEEXISTS = 70, + API_FILEREADER_FILEREMOVE = 80, + API_FILEREADER_FILEREMOVEUNDOABLE = 90, + API_FILEREADER_FILEMOVE = 100, + }; +}; + +inline void *api_fileReader::fileOpen(const wchar_t *filename, OSFNCSTR mode) { + return _call(API_FILEREADER_FILEOPEN, (void *)NULL, filename, mode); +} + +inline void api_fileReader::fileClose(void *fileHandle) { + _voidcall(API_FILEREADER_FILECLOSE, fileHandle); +} + +inline size_t api_fileReader::fileRead(void *buffer, size_t size, void *fileHandle) { + return _call(API_FILEREADER_FILEREAD, (size_t)0, buffer, size, fileHandle); +} + +inline size_t api_fileReader::fileWrite(const void *buffer, int size, void *fileHandle) { + return _call(API_FILEREADER_FILEWRITE, (size_t)0, buffer, size, fileHandle); +} + +inline int api_fileReader::fileSeek(int64_t offset, int origin, void *fileHandle) { + return _call(API_FILEREADER_FILESEEK, (int)0, offset, origin, fileHandle); +} + +inline uint64_t api_fileReader::fileTell(void *fileHandle) { + return _call(API_FILEREADER_FILETELL, (uint64_t)0, fileHandle); +} + +inline uint64_t api_fileReader::fileGetFileSize(void *fileHandle) { + return _call(API_FILEREADER_FILEGETFILESIZE, (uint64_t)0, fileHandle); +} + +/*inline int api_fileReader::fileExists(const wchar_t *filename) { + return _call(API_FILEREADER_FILEEXISTS, (int)0, filename); +}*/ + +inline int api_fileReader::fileRemove(const wchar_t *filename) { + return _call(API_FILEREADER_FILEREMOVE, (int)0, filename); +} + +inline int api_fileReader::fileRemoveUndoable(const wchar_t *filename) { + return _call(API_FILEREADER_FILEREMOVEUNDOABLE, (int)0, filename); +} + +inline int api_fileReader::fileMove(const wchar_t *filename, const wchar_t *destfilename) { + return _call(API_FILEREADER_FILEMOVE, (int)0, filename, destfilename); +} + +class api_fileReaderI : public api_fileReader { + public: + virtual void *fileOpen(const wchar_t *filename, const wchar_t *mode)=0; + virtual void fileClose(void *fileHandle)=0; + virtual size_t fileRead(void *buffer, size_t size, void *fileHandle)=0; + virtual int fileWrite(const void *buffer, int size, void *fileHandle)=0; + virtual int fileSeek(int64_t offset, int origin, void *fileHandle)=0; + virtual uint64_t fileTell(void *fileHandle)=0; + virtual uint64_t fileGetFileSize(void *fileHandle)=0; + //virtual int fileExists(const wchar_t *filename)=0; + virtual int fileRemove(const wchar_t *filename)=0; + virtual int fileRemoveUndoable(const wchar_t *filename)=0; + virtual int fileMove(const wchar_t *filename, const wchar_t *destfilename)=0; + + protected: + RECVS_DISPATCH; +}; + +// {E357E736-4967-4279-B948-5073A186F565} +static const GUID fileReaderApiServiceGuid = +{ 0xe357e736, 0x4967, 0x4279, { 0xb9, 0x48, 0x50, 0x73, 0xa1, 0x86, 0xf5, 0x65 } }; + +extern api_fileReader *fileApi; + +#endif diff --git a/Src/Wasabi/api/filereader/api_readercallback.h b/Src/Wasabi/api/filereader/api_readercallback.h new file mode 100644 index 00000000..8d88a440 --- /dev/null +++ b/Src/Wasabi/api/filereader/api_readercallback.h @@ -0,0 +1,22 @@ +#ifndef __WASABI_API_READERCALLBACK_H +#define __WASABI_API_READERCALLBACK_H + +#include + +class NOVTABLE api_readercallback : public Dispatchable +{ +public: + void metaDataReader_onData(const char *data, int size); + + enum + { + METADATAREADERONDATA = 10, + }; +}; + +inline void api_readercallback::metaDataReader_onData(const char *data, int size) +{ + _voidcall(METADATAREADERONDATA, data, size); +} + +#endif diff --git a/Src/Wasabi/api/filereader/filereaderapi.cpp b/Src/Wasabi/api/filereader/filereaderapi.cpp new file mode 100644 index 00000000..b6fec99c --- /dev/null +++ b/Src/Wasabi/api/filereader/filereaderapi.cpp @@ -0,0 +1,53 @@ +#include +#include "filereaderapi.h" +#include + +api_fileReader *fileApi = NULL; + + +FileReaderApi::FileReaderApi() { +} + +FileReaderApi::~FileReaderApi() { +} + +void *FileReaderApi::fileOpen(const wchar_t *filename, const wchar_t *mode) { + return FileReaders::open(filename, mode); +} + +void FileReaderApi::fileClose(void *fileHandle) { + FileReaders::close(fileHandle); +} + +size_t FileReaderApi::fileRead(void *buffer, size_t size, void *fileHandle) { + return FileReaders::read(buffer, size, fileHandle); +} + +int FileReaderApi::fileWrite(const void *buffer, int size, void *fileHandle) { + return FileReaders::write(buffer, size, fileHandle); +} + +int FileReaderApi::fileSeek(int64_t offset, int origin, void *fileHandle) { + return FileReaders::seek(offset, origin, fileHandle); +} + +uint64_t FileReaderApi::fileTell(void *fileHandle) { + return FileReaders::tell(fileHandle); +} + +uint64_t FileReaderApi::fileGetFileSize(void *fileHandle) { + return FileReaders::getFileSize(fileHandle); +} + +int FileReaderApi::fileRemove(const wchar_t *filename) { + return FileReaders::remove(filename); +} + +int FileReaderApi::fileRemoveUndoable(const wchar_t *filename) { + return FileReaders::removeUndoable(filename); +} + +int FileReaderApi::fileMove(const wchar_t *filename, const wchar_t *destfilename) { + return FileReaders::move(filename, destfilename); +} + diff --git a/Src/Wasabi/api/filereader/filereaderapi.h b/Src/Wasabi/api/filereader/filereaderapi.h new file mode 100644 index 00000000..ad3e30a0 --- /dev/null +++ b/Src/Wasabi/api/filereader/filereaderapi.h @@ -0,0 +1,25 @@ +#ifndef _FILEREADERAPI_H +#define _FILEREADERAPI_H + +#include + +class FileReaderApi : public api_fileReaderI +{ + public: + FileReaderApi(); + virtual ~FileReaderApi(); + + virtual void *fileOpen(const wchar_t *filename, const wchar_t *mode); + virtual void fileClose(void *fileHandle); + virtual size_t fileRead(void *buffer, size_t size, void *fileHandle); + virtual int fileWrite(const void *buffer, int size, void *fileHandle); + virtual int fileSeek(int64_t offset, int origin, void *fileHandle); + virtual uint64_t fileTell(void *fileHandle); + virtual uint64_t fileGetFileSize(void *fileHandle); + //virtual int fileExists(const wchar_t *filename); + virtual int fileRemove(const wchar_t *filename); + virtual int fileRemoveUndoable(const wchar_t *filename); + virtual int fileMove(const wchar_t *filename, const wchar_t *destfilename); +}; + +#endif diff --git a/Src/Wasabi/api/filereader/local/fileread.cpp b/Src/Wasabi/api/filereader/local/fileread.cpp new file mode 100644 index 00000000..f1107f47 --- /dev/null +++ b/Src/Wasabi/api/filereader/local/fileread.cpp @@ -0,0 +1,132 @@ +#include +#include "fileread.h" +#include + +void *FileReaders::open(const wchar_t *filename, const wchar_t *mode) { + int m=0; + + const wchar_t *p=mode; + wchar_t c; + while(c=*(p++)) + { + switch(c) + { + case 'r': m=SvcFileReader::READ; break; + case 'w': m=SvcFileReader::WRITE; break; + case 'a': m=SvcFileReader::APPEND; break; + case '+': m|=SvcFileReader::PLUS; break; + case 'b': m|=SvcFileReader::BINARY; break; + case 't': m|=SvcFileReader::TEXT; break; + } + } + + return FileReaderEnum(filename, m).getFirst(); +} + +void FileReaders::close(void *handle) +{ + svc_fileReader *fr=(svc_fileReader *)handle; + fr->close(); + SvcEnum::release(fr); +} + +size_t FileReaders::read(void *buffer, size_t size, void *handle) +{ + svc_fileReader *fr=(svc_fileReader *)handle; + return fr->read((int8_t *)buffer,size); +} + +size_t FileReaders::write(const void *buffer, size_t size, void *handle) +{ + svc_fileReader *fr=(svc_fileReader *)handle; + return fr->write((int8_t *)buffer,size); +} + +int FileReaders::seek(int64_t offset, int origin, void *handle) +{ + svc_fileReader *fr=(svc_fileReader *)handle; + if(!fr->canSeek()) return -1; + if(origin==SEEK_SET) return fr->seek(offset); + if(origin==SEEK_CUR) return fr->seek(fr->getPos()+offset); + return fr->seek(fr->getLength()-offset); +} + +uint64_t FileReaders::tell(void *handle) +{ + svc_fileReader *fr=(svc_fileReader *)handle; + return fr->getPos(); +} + +uint64_t FileReaders::getFileSize(void *handle) +{ + svc_fileReader *fr=(svc_fileReader *)handle; + return fr->getLength(); +} + +int FileReaders::exists(const wchar_t *filename) { + // Note that we do not do a system lock on the service since we can just + // release it directly via the factory + waService *s; + for(int i=0;s=WASABI_API_SVC->service_enumService(WaSvc::FILEREADER,i);i++) { + svc_fileReader *fr=(svc_fileReader *)s->getInterface(FALSE); + if(fr->isMine(filename) == 1 || fr->open(filename)) { + int ret=fr->exists(filename); + fr->close(); + s->releaseInterface(fr); fr = NULL; + return ret; + } + s->releaseInterface(fr); fr = NULL; + } + return 0; +} + +int FileReaders::remove(const wchar_t *filename) { + // Note that we do not do a system lock on the service since we can just + // release it directly via the factory + waService *s; + for(int i=0;s=WASABI_API_SVC->service_enumService(WaSvc::FILEREADER,i);i++) { + svc_fileReader *fr=(svc_fileReader *)s->getInterface(FALSE); + if (fr->isMine(filename) == 1 || fr->open(filename)) { + fr->close(); + int ret = fr->remove(filename); + s->releaseInterface(fr); fr = NULL; + return ret; + } + s->releaseInterface(fr); fr = NULL; + } + return 0; +} + +int FileReaders::removeUndoable(const wchar_t *filename) { + // Note that we do not do a system lock on the service since we can just + // release it directly via the factory + waService *s; + for(int i=0;s=WASABI_API_SVC->service_enumService(WaSvc::FILEREADER,i);i++) { + svc_fileReader *fr=(svc_fileReader *)s->getInterface(FALSE); + if(fr->isMine(filename) == 1 || fr->open(filename)) { + fr->close(); + int ret = fr->removeUndoable(filename); + s->releaseInterface(fr); fr = NULL; + return ret; + } + s->releaseInterface(fr); fr = NULL; + } + return 0; +} + +int FileReaders::move(const wchar_t *filename, const wchar_t *destfilename) { + // Note that we do not do a system lock on the service since we can just + // release it directly via the factory + waService *s; + for(int i=0;s=WASABI_API_SVC->service_enumService(WaSvc::FILEREADER,i);i++) { + svc_fileReader *fr=(svc_fileReader *)s->getInterface(FALSE); + if(fr->isMine(filename) == 1 || fr->open(filename)) { + fr->close(); + int ret = fr->move(filename,destfilename); + s->releaseInterface(fr); fr = NULL; + return ret; + } + s->releaseInterface(fr); fr = NULL; + } + return 0; +} diff --git a/Src/Wasabi/api/filereader/local/fileread.h b/Src/Wasabi/api/filereader/local/fileread.h new file mode 100644 index 00000000..14c22f46 --- /dev/null +++ b/Src/Wasabi/api/filereader/local/fileread.h @@ -0,0 +1,23 @@ +#ifndef _FILEREADERS_H +#define _FILEREADERS_H + +#include +#include + +class FileReaders +{ +public: + static void *open(const wchar_t *filename, const wchar_t *mode); + static void close(void *handle); + static size_t read(void *buffer, size_t size, void *handle); + static size_t write(const void *buffer, size_t size, void *handle); + static int seek(int64_t offset, int origin, void *handle); + static uint64_t tell(void *handle); + static uint64_t getFileSize(void *handle); + static int exists(const wchar_t *filename); + static int remove(const wchar_t *filename); + static int removeUndoable(const wchar_t *filename); + static int move(const wchar_t *filename, const wchar_t *destfilename); +}; + +#endif//_FILEREADERS_H diff --git a/Src/Wasabi/api/filereader/svc_filereadI.h b/Src/Wasabi/api/filereader/svc_filereadI.h new file mode 100644 index 00000000..27d4768b --- /dev/null +++ b/Src/Wasabi/api/filereader/svc_filereadI.h @@ -0,0 +1,100 @@ +#ifndef __WASABI_SVC_FILEREADI_H +#define __WASABI_SVC_FILEREADI_H + +#include +#include +// derive from this one +class NOVTABLE svc_fileReaderI : public svc_fileReader +{ +public: + virtual int isMine(const wchar_t *filename, int mode = SvcFileReader::READ) { return -1; } + virtual int open(const wchar_t *filename, int mode = SvcFileReader::READ) = 0; // return 1 on success + virtual size_t read(int8_t *buffer, size_t length) = 0; // return number of bytes read (if < length then eof) + virtual size_t write(const int8_t *buffer, size_t length) = 0; // return number of bytes written + virtual void close() = 0; //must be safe to call even when not open + + virtual int canSetEOF() { return 0; } + virtual int setEOF(uint64_t newlen) { return -1; } + + virtual void abort() { } // tells the reader to abort its current prebuffering/reader + + virtual int getLength() { return -1; } // return -1 on unknown/infinite + virtual int getPos() = 0; + + virtual int canSeek() { return 0; } + virtual int seek(uint64_t position) { return 0; } + virtual uint64_t bytesAvailable(uint64_t requested) { return requested; } + + virtual int hasHeaders() { return 0; } + virtual const char *getHeader(const char *header) { return (const char *)NULL; } + + virtual int exists(const wchar_t *filename) { return 0; } // return 1 if true, 0 if not, -1 if unknown + + virtual int remove(const wchar_t *filename) { return 0; } // return 1 on success, 0 on error + + virtual int removeUndoable(const wchar_t *filename) { return -1; } + + virtual int move(const wchar_t *filename, const wchar_t *destfilename) { return 0; } // return 1 on success, 0 on error + + virtual void setMetaDataCallback(api_readercallback *cb) { } + + virtual int canPrefetch() { return 1; } // return 1 if your reader should prefetch infos about the file in pledit + // (HTTP reader will return 0 here for instance) + +protected: + RECVS_DISPATCH; +}; + + +// derive from this one +class NOVTABLE MetaDataReaderCallbackI : public api_readercallback { +public: + virtual void metaDataReader_onData(const char *data, int size)=0; + +protected: +#undef CBCLASS +#define CBCLASS MetaDataReaderCallbackI +START_DISPATCH_INLINE; + VCB(METADATAREADERONDATA, metaDataReader_onData); +END_DISPATCH; +#undef CBCLASS +}; + +#include +#include // for WA_MAX_PATH but this needs to be in a better place + +#define MAX_FILEREADER_REDIRECT 256 + +// note: this class handles both redirection and calling open() +class FileReaderEnum : public SvcEnumT { +public: + FileReaderEnum(const wchar_t *filename, int mode=SvcFileReader::READ, int allow_redirect=FALSE) : + fn(filename), m(mode) + { + if (allow_redirect) { + for (int done = 0, c = 0; !done && c < MAX_FILEREADER_REDIRECT; done = 1, c++) { + RedirectEnum re(fn); + svc_redirect *svc; + while ((svc = re.getNext(FALSE)) != NULL) { + wchar_t buf[WA_MAX_PATH]=L""; + if (svc->redirect(fn, L"Filename", buf, WA_MAX_PATH)) { + fn = buf; + done = 0; + } + re.getLastFactory()->releaseInterface(svc); + } + } + } + } + virtual int testService(svc_fileReader *svc) { + if (!svc->isMine(fn)) return 0; + return !!svc->open(fn, m); + } + +private: + const wchar_t *fn; + int m; +}; + + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/filereader/zip/zipread.cpp b/Src/Wasabi/api/filereader/zip/zipread.cpp new file mode 100644 index 00000000..f8c66c92 --- /dev/null +++ b/Src/Wasabi/api/filereader/zip/zipread.cpp @@ -0,0 +1,176 @@ +#include +#define REAL_STDIO +#include "zipread.h" +#include +#include +#include + +#define UNZIPBUFSIZE 65536 + +int ZipRead::open(const char *filename, int mode) { + unzFile f=NULL; + int success=0; + + if (WASABI_API_SKIN == NULL) return 0; + PathParser pp1(WASABI_API_SKIN->getSkinsPath()); + PathParser pp2(filename); + int v; + for (v=0;vgetSkinsPath(),walName.getValue()),&zipFi) && + !Std::getFileInfos(zipName=StringPrintf("%s%s.wsz",WASABI_API_SKIN->getSkinsPath(),walName.getValue()),&zipFi) && + !Std::getFileInfos(zipName=StringPrintf("%s%s.zip",WASABI_API_SKIN->getSkinsPath(),walName.getValue()),&zipFi)) + return 0; // zip not found + + if(zipTmpDir.isempty()) { + char tmpPath[WA_MAX_PATH]; + Std::getTempPath(sizeof(tmpPath)-1,tmpPath); + zipTmpDir=StringPrintf("%s_wa3sktmp",tmpPath); + Std::createDirectory(zipTmpDir); + } + + // check in cached opened zip dirs + int badcrc=0; + for(int i=0;igetValue(), walName)) { + if(!MEMCMP(&openedZipHandles[i].checksum,&zipFi,sizeof(zipFi))) { + // try to find it in the dezipped temp dir + handle=openInTempDir(walName,file); + if(handle) return 1; + else return 0; + } else { + // bad checksum + badcrc=1; + break; + } + } + } + + // is the dezipped dir is here? + if(!badcrc) { + StringPrintf tmpf("%s%s%s%s_wa3chksum",zipTmpDir.getValue(),DIRCHARSTR,walName.getValue(),DIRCHARSTR); + FILE *fh=fopen(tmpf,"rb"); + if(fh) { + Std::fileInfoStruct tmpFi={0,}; + fread(&tmpFi,1,sizeof(tmpFi),fh); + fclose(fh); + if(!MEMCMP(&tmpFi,&zipFi,sizeof(tmpFi))) { + // checksum correct + openedZipEntry ze={new String(walName), new String(zipName)}; + ze.checksum=tmpFi; + openedZipHandles.addItem(ze); + handle=openInTempDir(walName,file); + if(handle) return 1; + else return 0; + } + } + } + + // not found, so try to find it in a zip file + f = unzOpen(zipName); + if(!f) return 0; + + StringPrintf zDir("%s%s%s",zipTmpDir.getValue(),DIRCHARSTR,walName.getValue()); + Std::removeDirectory(zDir,1); + + // unpack the zip in temp folder + String dirmask; + unzGoToFirstFile(f); + Std::createDirectory(zDir); + do { + char filename[MAX_PATH]; + unzGetCurrentFileInfo(f,NULL,filename,sizeof(filename),NULL,0,NULL,0); + if (unzOpenCurrentFile(f) == UNZ_OK) { + int l; + dirmask.printf("%s%s%s",zDir.getValue(),DIRCHARSTR,filename); + if (Std::isDirChar(dirmask.lastChar())) { + // create dir + Std::createDirectory(dirmask); + } else { + // create file + FILE *fp = fopen(dirmask,"wb"); + if(!fp) { + String dir=dirmask; + char *p=(char *)Std::filename(dir); + if(p) { + *p=0; + Std::createDirectory(dir); + fp = fopen(dirmask,"wb"); + } + } + if (fp) { + do { + MemBlock buf(UNZIPBUFSIZE); + l=unzReadCurrentFile(f,buf.getMemory(),buf.getSizeInBytes()); + if (l > 0) fwrite(buf.getMemory(),1,l,fp); + } while (l > 0); + fclose(fp); + success=1; + } + } + if (unzCloseCurrentFile(f) == UNZ_CRCERROR) success=0; + } + } while (unzGoToNextFile(f) == UNZ_OK); + unzClose(f); + + // write the checksum file + Std::fileInfoStruct fi; + Std::getFileInfos(zipName, &fi); + FILE *fh=fopen(StringPrintf("%s%s_wa3chksum",zDir.getValue(),DIRCHARSTR),"wt"); + fwrite(&fi,1,sizeof(fi),fh); + fclose(fh); + + openedZipEntry ze={new String(walName), new String(zipName)}; + ze.checksum=fi; + openedZipHandles.addItem(ze); + + // try to find it (again) in the dezipped temp dir + handle=openInTempDir(walName,file); + if(handle) return 1; + return 0; +} + +FILE *ZipRead::openInTempDir(const char *walName, const char *file) { + StringPrintf tmpf("%s%s%s%s%s",zipTmpDir.getValue(),DIRCHARSTR,walName,DIRCHARSTR,file); + FILE *fh=fopen(tmpf,"rb"); + if(fh) return fh; + // okay maybe the file isn't in the root dir of the zip file + fh=fopen(StringPrintf("%s%s%s%s%s%s%s",zipTmpDir.getValue(),DIRCHARSTR,walName,DIRCHARSTR,walName,DIRCHARSTR,file),"rb"); + if(fh) return fh; + // definitely not here + return 0; +} + +void ZipRead::close() { + fclose(handle); +} + +int ZipRead::read(char *buffer, int size) { + return fread(buffer,1,size,handle); +} + +int ZipRead::getPos() { + return ftell(handle); +} + +int ZipRead::getLength() { + int pos=ftell(handle); + fseek(handle,0,SEEK_END); + int length=ftell(handle); + fseek(handle,pos,SEEK_SET); + return length; +} + +using namespace wasabi; + +TList ZipRead::openedZipHandles;; diff --git a/Src/Wasabi/api/filereader/zip/zipread.h b/Src/Wasabi/api/filereader/zip/zipread.h new file mode 100644 index 00000000..7210e6bd --- /dev/null +++ b/Src/Wasabi/api/filereader/zip/zipread.h @@ -0,0 +1,39 @@ +#ifndef _ZIPREAD_H +#define _ZIPREAD_H + +#include +#include +#include +#include +#include +#include + +class ZipRead : public svc_fileReaderI { +public: + // service + static const char *getServiceName() { return "ZIP file reader"; } + + int open(const char *filename, int mode=SvcFileReader::READ); + int read(char *buffer, int length); + int write(const char *buffer, int length) { return 0; } + void close(); + int getPos(); + int getLength(); + +private: + FILE *openInTempDir(const char *walName, const char *file); + + typedef struct { + String *name; + String *zipName; + Std::fileInfoStruct checksum; + } openedZipEntry; + + static wasabi::TList openedZipHandles; + + String zipTmpDir; + + FILE *handle; +}; + +#endif//_ZIPREAD_H diff --git a/Src/Wasabi/api/font/FontCreator.h b/Src/Wasabi/api/font/FontCreator.h new file mode 100644 index 00000000..086ea933 --- /dev/null +++ b/Src/Wasabi/api/font/FontCreator.h @@ -0,0 +1,7 @@ +#include +template +class FontCreator : public waServiceFactoryT +{ +public: + FontCreator(GUID myGuid = INVALID_GUID) : waServiceFactoryT(myGuid) {} +}; diff --git a/Src/Wasabi/api/font/FontSvcEnum.h b/Src/Wasabi/api/font/FontSvcEnum.h new file mode 100644 index 00000000..c01cc9cc --- /dev/null +++ b/Src/Wasabi/api/font/FontSvcEnum.h @@ -0,0 +1,18 @@ +#include +#include + +class FontSvcEnum : public SvcEnumT { +public: + FontSvcEnum(const wchar_t *_svc_name = NULL) : svc_name(_svc_name) {} +protected: + virtual int testService(svc_font *svc) + { + if (!svc_name.len()) + return 1; // blank name returns all services. + return (!WCSICMP(svc->getFontSvcName(),svc_name)); + } +private: + StringW svc_name; +}; + + diff --git a/Src/Wasabi/api/font/api_font.cpp b/Src/Wasabi/api/font/api_font.cpp new file mode 100644 index 00000000..1fd7c551 --- /dev/null +++ b/Src/Wasabi/api/font/api_font.cpp @@ -0,0 +1,11 @@ +#include +#include "api_font.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif +#define CBCLASS api_fontI +START_DISPATCH; + VCB(API_FONT_FONT_TEXTOUT, font_textOut); + CB(API_FONT_FONT_GETINFO, font_getInfo); +END_DISPATCH; diff --git a/Src/Wasabi/api/font/api_font.h b/Src/Wasabi/api/font/api_font.h new file mode 100644 index 00000000..cea0bac1 --- /dev/null +++ b/Src/Wasabi/api/font/api_font.h @@ -0,0 +1,36 @@ +#ifndef __API_FONT_H +#define __API_FONT_H + +#include + +class ifc_canvas; + +class NOVTABLE api_font : public Dispatchable +{ + public: + void font_textOut(ifc_canvas *c, int style, int x, int y, int w, int h, const wchar_t *txt); + int font_getInfo(ifc_canvas *c, const wchar_t *font, int infoid, const wchar_t *txt, int *w, int *h); + + enum { + API_FONT_FONT_TEXTOUT = 0, + API_FONT_FONT_GETINFO = 10, + }; +}; + +inline void api_font::font_textOut(ifc_canvas *c, int style, int x, int y, int w, int h, const wchar_t *txt) +{ + _voidcall(API_FONT_FONT_TEXTOUT, c, style, x, y, w, h, txt); +} + +inline int api_font::font_getInfo(ifc_canvas *c, const wchar_t *font, int infoid, const wchar_t *txt, int *w, int *h) +{ + return _call(API_FONT_FONT_GETINFO, (int)0, c, font, infoid, txt, w, h); +} + +// {1FCA9C7E-5923-4b9c-8906-0F8C331DF21C} +static const GUID fontApiServiceGuid = +{ 0x1fca9c7e, 0x5923, 0x4b9c, { 0x89, 0x6, 0xf, 0x8c, 0x33, 0x1d, 0xf2, 0x1c } }; + +extern api_font *fontApi; + +#endif diff --git a/Src/Wasabi/api/font/bitmapfont.cpp b/Src/Wasabi/api/font/bitmapfont.cpp new file mode 100644 index 00000000..fe85abda --- /dev/null +++ b/Src/Wasabi/api/font/bitmapfont.cpp @@ -0,0 +1,394 @@ +#include "precomp.h" +// ============================================================================================================================================================ +// Font abstract class + statics to install TT fonts and Bitmap fonts +// ============================================================================================================================================================ +#include "bitmapfont.h" +#include +#include +#ifdef WASABI_COMPILE_SKIN +#include +#endif +#ifdef WA3COMPATIBILITY +#endif + +#include +#include +#include + +// ============================================================================================================================================================ +// BitmapFont implementation. +// ============================================================================================================================================================ + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +BitmapFont::BitmapFont() : scriptid(0), char_width(0), char_height(0), hor_spacing(0), vert_spacing(0) { +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +BitmapFont::~BitmapFont() { + +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +int BitmapFont::isBitmap() { + return 1; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +const wchar_t *BitmapFont::getFaceName() { + return getFontId(); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void BitmapFont::textOut(ifc_canvas *c, int x, int y, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialiased) { + do_textOut(this, c, x+xoffset, y+yoffset, -1, -1, txt, size, bold, opaque, underline, italic, STDFONT_LEFT, color, WA_FONT_TEXTOUT_NORMAL); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void BitmapFont::textOut2(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialiased) { + do_textOut(this, c, x+xoffset, y+yoffset, x+xoffset+w, y+yoffset+h, txt, size, bold, opaque, underline, italic, align, color, WA_FONT_TEXTOUT_RECT); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void BitmapFont::textOutEllipsed(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialiased) { + do_textOut(this, c, x+xoffset, y+yoffset, x+xoffset+w, y+yoffset+h, txt, size, bold, opaque, underline, italic, align, color, WA_FONT_TEXTOUT_ELLIPSED); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void BitmapFont::textOutWrapped(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialiased) { + do_textOut(this, c, x+xoffset, y+yoffset, x+xoffset+w, y+yoffset+h, txt, size, bold, opaque, underline, italic, align, color, WA_FONT_TEXTOUT_WRAPPED); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void BitmapFont::textOutWrappedPathed(ifc_canvas *c, int x, int y, int w, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialiased) { + do_textOut(this, c, x+xoffset, y+yoffset, x+xoffset+w, -1, txt, size, bold, opaque, underline, italic, align, color, WA_FONT_TEXTOUT_WRAPPEDPATHED); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void BitmapFont::textOutCentered(ifc_canvas *c, RECT *r, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialiased) { + do_textOut(this, c, r->left, r->top, r->right-r->left, r->bottom-r->top, txt, size, bold, opaque, underline, italic, align, color, WA_FONT_TEXTOUT_CENTERED); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +int BitmapFont::getTextWidth(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialiased) +{ + return wcslen(text) * char_width + wcslen(text)*hor_spacing; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +int BitmapFont::getTextHeight(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialiased) +{ + return char_height; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +int BitmapFont::getTextHeight2(ifc_canvas *c, int size, int bold, int underline, int italic, int antialiased) +{ + return char_height; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void BitmapFont::getTextExtent(ifc_canvas *c, const wchar_t *text, int *w, int *h, int size, int bold, int underline, int italic, int antialiased) +{ + if (w) *w = getTextWidth(c, text, size, bold, underline, italic, antialiased); + if (h) *h = char_height; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void BitmapFont::setFontBitmap(const wchar_t *name_or_element, const wchar_t *path) +{ + StringW pathfile; + if (!wcschr(name_or_element, L':')) + { + pathfile = path; + pathfile.AddBackslash(); + } + pathfile.cat(name_or_element); + if (!WACCESS(pathfile, 0)) + table = pathfile; + else + table = name_or_element; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void BitmapFont::setFontMetrics(int _char_width, int _char_height, int _hor_spacing, int _vert_spacing) { + char_width = _char_width; + char_height = _char_height; + hor_spacing = _hor_spacing; + vert_spacing = _vert_spacing; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +int BitmapFont::getHorizontalSpacing() { + return hor_spacing; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +int BitmapFont::getVerticalSpacing() { + return vert_spacing; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +int BitmapFont::getCharWidth() { + return char_width; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +int BitmapFont::getCharHeight() { + return char_height; +} + +AutoSkinBitmap *BitmapFont::getCharTable() { + return &table; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void BitmapFont::getXYfromChar(wchar_t ic, int *x, int *y) +{ + int c,c2=0; + switch (ic) + { + case L'\u00B0': /*¡*/ ic = L'0'; break; + case L'\u00C6':/*®*/ ic = L'A'; break; + // case '\u00C1':/*ç*/ ic = L'A'; break; + // case '\u00C2': ic = L'A'; break; + case L'\u00C7': /*‚*/ ic = L'C'; break; + case L'\u00C9':/*ƒ*/ ic = L'E'; break; + + case L'\u00E0': /*ˆ*/ case L'\u00E1': /*‡*/ case L'\u00E2': /*‰*/ ic = L'a'; break; + case L'\u00E6':/*¾*/ ic = L'a'; break; + case L'\u00E7': /**/ ic = L'c'; break; + case L'\u00E8': /**/ case L'\u00E9': /*Ž*/ case L'\u00EB': /*‘*/case L'\u00EA':/**/ ic = L'e'; break; + case L'\u00EC':/*“*/ case L'\u00ED':/*’*/ case L'\u00EE':/*”*/ case L'\u00EF':/*•*/ ic = L'i'; break; + +#ifdef _WIN32 + case L'—':/*—*/ case L'˜':/*˜*/ case L'™':/*™*/ ic = L'o'; break; + case L'œ':/*œ*/ case L'':/**/ case L'ž':/*ž*/ ic = L'u'; break; + case L'Ø':/*Ø*/ ic = L'y'; break; + case L'†':/*†*/ ic = L'U'; break; +#else +#warning change these to \u +#endif + case L'\u00D1':/*„*/ ic = L'N'; break; + case L'\u00F1':/*–*/ ic = L'n'; break; + case L'\u00FC': /*Ÿ*/ ic = L'u'; break; + case L'\u0192':/*Ä*/ ic = L'f'; break; + default: break; + } // quick relocations + if (ic <= L'Z' && ic >= L'A') c = (ic-'A'); + else if (ic <= L'z' && ic >= L'a') c = (ic-'a'); + else if (ic == L' ') c = 30; + else { + c2 += char_height; + if (ic == L'\1') c=10; + else if (ic == L'.') c = 11; + else if (ic <= L'9' && ic >= L'0') c = ic - L'0'; + else if (ic == L':') c = 12; + else if (ic == L'(') c = 13; + else if (ic == L')') c = 14; + else if (ic == L'-') c = 15; + else if (ic == L'\'' || ic=='`') c = 16; + else if (ic == L'!') c = 17; + else if (ic == L'_') c = 18; + else if (ic == L'+') c = 19; + else if (ic == L'\\') c = 20; + else if (ic == L'/') c = 21; + else if (ic == L'[' || ic == L'{' || ic == L'<') c = 22; + else if (ic == L']' || ic == L'}' || ic == L'>') c = 23; + else if (ic == L'~' || ic == L'^') c = 24; + else if (ic == L'&') c = 25; + else if (ic == L'%') c = 26; + else if (ic == L',') c = 27; + else if (ic == L'=') c = 28; + else if (ic == L'$') c = 29; + else if (ic == L'#') c = 30; + else + { + c2 += char_height; +#ifdef _WIN32 + if (ic == L'' || ic == L'Œ') c = 0; + else if (ic == L'…' || ic == L'š') c = 1; + else if (ic == L'€' || ic == L'Š') c = 2; + else +#else +#warning change these to \u +#endif + if (ic == L'?') c = 3; + else if (ic == L'*') c = 4; + else { + c2 = 0; + if (ic == L'"') c = 26; + else if (ic == L'@') c = 27; + else c = 30; + } + } + } + c*=char_width; + *x=c; + *y=c2; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +int BitmapFont::getWordLength(const wchar_t *p) { + int n=0; + while (p && *p && *p != L' ') { + p++; + n++; + } + return n; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +wchar_t *BitmapFont::makeLine(const wchar_t *t, BitmapFont *font, int line, int width, int style) { + + static wchar_t str[4096]; + wchar_t *p = (wchar_t *)t; + size_t len = wcslen(t); + + switch (style) { + case WA_FONT_TEXTOUT_NORMAL: + case WA_FONT_TEXTOUT_RECT: + case WA_FONT_TEXTOUT_ELLIPSED: + case WA_FONT_TEXTOUT_CENTERED: + return line == 0 ? (wchar_t *)t : NULL; + case WA_FONT_TEXTOUT_WRAPPEDPATHED: + case WA_FONT_TEXTOUT_WRAPPED: { + size_t maxchar = width / (font->getCharWidth() + font->getVerticalSpacing()); + for (int i = 0; i < line; i++) { + wchar_t *oldp = p; + p += maxchar; + if ((size_t)(p-t) >= len) return NULL; + while (p >= t) { + if (p == t || *(p-1) == L' ') + break; + p--; + } + if (p == oldp) { + p += maxchar; + while (p && *p && *p != L' ') + p++; + } + } + WCSCPYN(str, p, maxchar); + wchar_t *d = &str[maxchar-1]; + int wr=0; + if (wcslen(p) > maxchar && *(p+maxchar) != L' ' && wcschr(str, L' ')) + while (d >= str) { + if (*d == L' ') { + *d = 0; + wr=1; + } + else { + if (wr) break; + d--; + } + } + return str; + } + } + return NULL; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void BitmapFont::do_textOut(BitmapFont *font, ifc_canvas *c, int x, int y, int x2, int y2, const wchar_t *text, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, int style) +{ + static wchar_t *dotdotdot=L"..."; + if (!text) return; + + BaseCloneCanvas canvas; + int ret = canvas.clone(c); + if (!ret) return; + + RECT bounds; + + RECT defbounds={x,y,x2,y2}; + int __w, __h; + c->getDim(&__w, &__h, NULL); + if (x2 == -1) defbounds.right = defbounds.left + __w; + if (y2 == -1) defbounds.bottom = defbounds.top + __h; +#ifdef _WIN32 + RegionI oldclip(&canvas, &defbounds); // get clipping region in oldclip + RegionI *andclip=NULL; + oldclip.getBox(&bounds); // get boundaries +#else + bounds = defbounds; +#warning port me +#endif + +/* if (x2 != -1 && y2 != -1) { + andclip = new RegionI(x, y, x2, y2); // create region for rect + andclip->andRegion(oldclip); // and them + canvas.selectClipRgn(andclip); // select new clipping rect + andclip->getBox(&bounds); // update boundaries + }*/ + + int lc=-1; + wchar_t *p = dotdotdot+3; // just a zero to triger next line + + int _x = x+(font->getHorizontalSpacing()/2); + int _y = y; + + if (style == WA_FONT_TEXTOUT_CENTERED) { + _y += (y2 - y - font->getCharHeight()) / 2; + } + + _y -= font->getCharHeight() + font->getVerticalSpacing(); + + int xp, yp; + + while (p) { + + if (!*p) { + lc++; + p = makeLine(text, font, lc, x2-x, style); + if (!p || !*p) break; + + _x = x+(font->getHorizontalSpacing()/2); + _y += font->getCharHeight() + font->getVerticalSpacing(); + if ((align == STDFONT_RIGHT || align == STDFONT_CENTER) && x2 != -1) { + int l = wcslen(p); + _x -= l * (font->getCharWidth() + font->getHorizontalSpacing()) - (x2-x); + } + if (align == STDFONT_CENTER) + _x = x + (_x - x) / 2; + + } + + if ((style == WA_FONT_TEXTOUT_ELLIPSED || style == WA_FONT_TEXTOUT_WRAPPEDPATHED) && x2 != -1) { + if (_x > x2 - 4 * (font->getCharWidth() + font->getHorizontalSpacing()) && wcslen(p) > 3) { + p = dotdotdot; + } + } + + font->getXYfromChar(*p, &xp, &yp); + + RECT r; + r.left = xp; + r.top = yp; + r.right = xp + font->getCharWidth(); + r.bottom = yp + font->getCharHeight(); + + RECT dst; + dst.left = _x; + dst.top = _y; + dst.right = _x + font->getCharWidth(); + dst.bottom = _y + font->getCharHeight(); + + if (Wasabi::Std::rectIntersect(dst, bounds)) +// if (IntersectRect(&dummy, &dst, &bounds)) // port me / checks clipping, not passed x,y,x2,y2 + font->getCharTable()->stretchToRectAlpha(&canvas, &r, &dst, 255); + + p++; + _x += font->getCharWidth(); + _x += font->getHorizontalSpacing(); + } + +#ifdef _WIN32 + if (andclip) { + canvas.selectClipRgn(&oldclip); // restore previously saved clipping region + delete andclip; + } +#else +#warning port me +#endif +} + diff --git a/Src/Wasabi/api/font/bitmapfont.h b/Src/Wasabi/api/font/bitmapfont.h new file mode 100644 index 00000000..0bedae86 --- /dev/null +++ b/Src/Wasabi/api/font/bitmapfont.h @@ -0,0 +1,70 @@ +#ifndef __BITMAPFONT_H +#define __BITMAPFONT_H + +#include + +//#include "font.h" + +#include +#include +#include +#include +#include + +class Font; + +class BitmapFont : public svc_fontI +{ +friend class Font; + public: + + virtual void textOut(ifc_canvas *c, int x, int y, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialiased); + virtual void textOut2(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialiased); + virtual void textOutEllipsed(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialiased); + virtual void textOutWrapped(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialiased); + virtual void textOutWrappedPathed(ifc_canvas *c, int x, int y, int w, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialiased); + virtual void textOutCentered(ifc_canvas *c, RECT *r, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialiased); + virtual int getTextWidth(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialiased); + virtual int getTextHeight(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialiased); + virtual int getTextHeight2(ifc_canvas *c, int size, int bold, int underline, int italic, int antialiased); + virtual void getTextExtent(ifc_canvas *c, const wchar_t *text, int *w, int *h, int size, int bold, int underline, int italic, int antialiased); + virtual int isBitmap(); + + virtual void setFontBitmap(const wchar_t *name_or_element, const wchar_t *path); + virtual void setFontMetrics(int char_width, int char_height, int hor_spacing, int vert_spacing); + virtual const wchar_t *getFaceName(); + + virtual void setFontId(const wchar_t *id) { font_id = id; } + virtual const wchar_t *getFontId() { return font_id; } + virtual int getScriptId() { return scriptid; } + virtual void setScriptId(int id) { scriptid = id; } + virtual void setFontFace(const wchar_t *face) {} + virtual int addFontResource(OSFILETYPE f, const wchar_t *name) { return 0; /*failure*/} + virtual int addFontResource2(void *mem, int datalen, const wchar_t *name) { return 0; /*failure*/} + + virtual const wchar_t *getFontSvcName() { return L"Bitmap Font"; } + + protected: + BitmapFont(); + virtual ~BitmapFont(); + + AutoSkinBitmap *getCharTable(); + int getCharWidth(); + int getCharHeight(); + int getHorizontalSpacing(); + int getVerticalSpacing(); + void getXYfromChar(wchar_t ic, int *x, int *y); + + protected: + StringW font_id; + int scriptid; + + private: + AutoSkinBitmap table; + int char_width, char_height, hor_spacing, vert_spacing; + static void do_textOut(BitmapFont *font, ifc_canvas *c, int x, int y, int x2, int y2, const wchar_t *text, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, int style); + static int getWordLength(const wchar_t *p); + static wchar_t *makeLine(const wchar_t *t, BitmapFont *font, int line, int physwidth, int style); +}; + +#endif diff --git a/Src/Wasabi/api/font/font.cpp b/Src/Wasabi/api/font/font.cpp new file mode 100644 index 00000000..e45994ce --- /dev/null +++ b/Src/Wasabi/api/font/font.cpp @@ -0,0 +1,637 @@ +#include "precomp.h" +// ============================================================================================================================================================ +// Font abstract class + statics to install TT fonts and Bitmap fonts +// ============================================================================================================================================================ + +#include +#include +#include + +#ifdef WASABI_COMPILE_SKIN + #include + #include +#endif + +#include +#include + +#ifdef WASABI_COMPILE_FONT +#include +//#include "services/svc_fontmaker.h" +#endif + +#ifdef WASABI_API_CONFIG +#include +#include +#include +#include +#endif +#include +#include + +extern _bool cfg_options_usefontmapper; +extern _string cfg_options_ttfoverridefont; +extern _int cfg_options_defaultfontscale; + +PtrList Font::fontlist; +PtrList Font::fontdefs; + +void Font::init() +{ +#ifdef WASABI_API_CONFIG + Wasabi::Std::setDefaultFont(cfg_options_defaultfont.getValue()); + Wasabi::Std::setDefaultFontScale(cfg_options_defaultfontscale.getValueAsInt()); +#endif +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void Font::dispatchTextOut(ifc_canvas *c, int style, int x, int y, int w, int h, const wchar_t *txt) +{ + int isoverride = 0; + if (WASABI_API_APP->main_isShuttingDown()) return; + + int size = c->getTextSize(); + + svc_font *f = requestSkinFont(c->getTextFont(), &size); + + ASSERT(f != NULL); + + // After we get the font we want, check to see if it is bitmap. + // If bitmap fonts are disallowed, use the truetype override font. + if (f->isBitmap() && useTrueTypeOverride(txt)) + { + int gotdefault=0; + svc_font *ttFont = requestSkinFont(getTrueTypeOverride(), &size, &gotdefault); + if (ttFont != NULL) + { + if (!gotdefault) + isoverride = 1; + f = ttFont; + } + } + + if (isoverride) + { + double f = (double)getTrueTypeOverrideScale() / 100.0f; + size = (int)(size*f); + } + int bold = c->getTextBold(); + int opaque = c->getTextOpaque(); + int underline = c->getTextUnderline(); + int italic = c->getTextItalic(); + int align = c->getTextAlign(); + int antialiased = c->getTextAntialias(); + ARGB32 color = c->getTextColor(); + ARGB32 bkcolor = c->getTextBkColor(); + int xoffset=0, yoffset=0; + c->getOffsets(&xoffset, &yoffset); +/* if (!f->isBitmap() && _intVal(Main::enumRootCfgItem(0), "Force antialias on all TTF")) + antialiased = 1;*/ + switch (style) + { + case WA_FONT_TEXTOUT_NORMAL: + f->textOut(c, x, y, txt, size, bold, opaque, underline, italic, color, bkcolor, xoffset, yoffset, antialiased); + break; + case WA_FONT_TEXTOUT_RECT: + f->textOut(c, x, y, w, h, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialiased); + break; + case WA_FONT_TEXTOUT_ELLIPSED: + f->textOutEllipsed(c, x, y, w, h, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialiased); + break; + case WA_FONT_TEXTOUT_WRAPPED: + f->textOutWrapped(c, x, y, w, h, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialiased); + break; + case WA_FONT_TEXTOUT_WRAPPEDPATHED: + f->textOutWrappedPathed(c, x, y, w, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialiased); + break; + case WA_FONT_TEXTOUT_CENTERED: + RECT r; + r.left = x; + r.top = y; + r.right = w; + r.bottom = h; + f->textOutCentered(c, &r, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialiased); + break; + } +} + + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +int Font::dispatchGetInfo(ifc_canvas *c, const wchar_t *font, int infoid, const wchar_t *txt, int *w, int *h) +{ + int isoverride = 0; + if (WASABI_API_APP->main_isShuttingDown()) return 0; + // mig: Let's not crash if we want to see how big a NULL pointer is. + if (txt == NULL) { + if ( infoid == WA_FONT_GETINFO_WIDTHHEIGHT ) { + if (w != NULL) { + *w = 0; + } + if (h != NULL) { + *h = 0; + } + } + return 0; + } + + int size = c->getTextSize(); + + svc_font *f = requestSkinFont(font, &size); + ASSERT(f != NULL); + + // After we get the font we want, check to see if it is bitmap. + // If bitmap fonts are disallowed, use the truetype override font. + if (f->isBitmap() && useTrueTypeOverride(txt)) + { + int gotdefault = 0; + svc_font *ttFont = requestSkinFont(getTrueTypeOverride(), &size, &gotdefault); + if (ttFont != NULL) + { + if (!gotdefault) + isoverride = 1; + f = ttFont; + } + } + + if (isoverride) { + double f = (double)getTrueTypeOverrideScale() / 100.0f; + size = (int)(size*f); + } + int bold = c->getTextBold(); + int underline = c->getTextUnderline(); + int italic = c->getTextItalic(); + int antialiased = c->getTextAntialias(); + switch (infoid) { + case WA_FONT_GETINFO_WIDTH: + return f->getTextWidth(c, txt, size, bold, underline, italic, antialiased); + case WA_FONT_GETINFO_HEIGHT: + return f->getTextHeight(c, txt, size, bold, underline, italic, antialiased); + case WA_FONT_GETINFO_WIDTHHEIGHT: + f->getTextExtent(c, txt, w, h, size, bold, underline, italic, antialiased); + return 0; + } + return 0; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +// Install a truetype font from its filename and associate a script_id to it +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +svc_font *Font::installTrueTypeFont(const wchar_t *filename, const wchar_t *path, const wchar_t *id, int scriptid, int allowmapping, int isttfreload) { + + if (!isttfreload) + { + FontDef *fd = new FontDef; + fd->filename = filename; + fd->path = path; + fd->id = id; + fd->scriptid = scriptid; + fd->isbitmap = 0; + fd->allowmapping = allowmapping; + fontdefs.addItem(fd); + } + + StringW file; + + OSFILETYPE ff=OPEN_FAILED; + if (wcschr(filename, ':')) + ff = WFOPEN(filename, WF_READONLY_BINARY); + + if (ff == OPEN_FAILED) + { + file = StringPathCombine(path, filename); + ff = WFOPEN(file, WF_READONLY_BINARY); + } +#ifdef WASABI_COMPILE_SKIN + if (ff == OPEN_FAILED) + { + file = StringPathCombine(SkinParser::getXmlRootPath(), filename); + ff = WFOPEN(file, WF_READONLY_BINARY); + if (ff == OPEN_FAILED) + { + file = StringPathCombine(Skin::getDefaultSkinPath(), filename); + ff = WFOPEN(file, WF_READONLY_BINARY); + if (ff == OPEN_FAILED) + { + DebugString("Font not found %s\n", filename); + // todo: do something if still not found + } + } + } +#endif + if (ff == OPEN_FAILED) { + DebugString("Could not install font %s\n", filename); + return 0; + } + + StringW fs = filename; + wchar_t *p = wcschr(fs.getNonConstVal(), '.'); + if (p) + *p = 0; + PathParserW pp(fs); + fs = pp.getLastString(); + + svc_font *f = newTrueTypeFont(); + if (f && f->addFontResource( ff, fs) ) + { + f->setFontId(id); + f->setScriptId(scriptid); + fontlist.addItem(f); + } else { + DebugString("font.cpp ====== CAN'T LOAD FONT FILE.\n"); + } + + FCLOSE(ff); + return f; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +// Uninstall all installed fonts +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void Font::uninstallAll(int ttfreload) { + int i; + // delete all by hand + for (i = 0; i < fontlist.getNumItems(); i++) { + svc_font *f = fontlist.enumItem(i); + if (ttfreload && f->isBitmap()) continue; + deleteFont(f); + fontlist.removeByPos(i); + i--; + } + if (!ttfreload) fontdefs.deleteAll(); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +// Uninstall by scriptid +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void Font::uninstallByScriptId(int scriptid) { + for (int i=0;igetScriptId() == scriptid) { + fontlist.removeByPos(i); + deleteFont(f); + i--; + } + } + for (int i=0;iscriptid == scriptid) { + fontdefs.removeByPos(i); + delete fd; + i--; + } + } +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +// Install a bitmap font and associates a script_id to it +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void Font::installBitmapFont(const wchar_t *filename, const wchar_t *path, const wchar_t *id, int cw, int ch, int hs, int vs, int scriptid, int allowmapping) +{ + FontDef *fd = new FontDef; + fd->filename = filename; + fd->path = path; + fd->id = id; + fd->scriptid = scriptid; + fd->isbitmap = 1; + fd->allowmapping = allowmapping; + fontdefs.addItem(fd); + + BitmapFont *f = new BitmapFont; + f->setFontBitmap(filename, path); + f->setFontId(id); + f->setFontMetrics(cw, ch, hs, vs); + f->setScriptId(scriptid); + fontlist.addItem(f); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +// Requests a Font* from its id +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +svc_font *Font::requestSkinFont(const wchar_t *id, int *size, int *gotdefault) +{ + if (gotdefault) *gotdefault = 0; + int oldsize = size ? *size : -1; + const wchar_t *mapped_id = getFontMapping(id, size); + if (mapped_id != NULL) + id = mapped_id; + + // First try to get a font by that id + foreach_reverse(fontlist) + const wchar_t *thisid = fontlist.getfor()->getFontId(); + if (thisid && !WCSICMP(thisid, id)) + return fontlist.getfor(); + endfor + // if it wasnt found, try to load a wa-installed ttfont with this face name + foreach_reverse(fontlist) + const wchar_t *facename=fontlist.getfor()->getFaceName(); + if (facename && !WCSICMP(facename, id)) return fontlist.getfor(); + endfor + + // not found, try to reload it front the list of fonts defined by the skin + foreach(fontdefs) + FontDef *fd = fontdefs.getfor(); + if (!WCSICMP(fd->id, id)) + { + if (!fd->isbitmap) + { + svc_font *f = installTrueTypeFont(fd->filename, fd->path, fd->id, fd->scriptid, fd->allowmapping, 1); + if (f) return f; + } + } + endfor; + + /* + for (i=fontlist.getNumItems()-1;i>=0;i--) { + const char *thisid = fontlist.enumItem(i)->getFontId(); + if (thisid && STRCASEEQL(thisid, "wasabi.font.ttf.default" )) + return fontlist.enumItem(i); + } + */ + + // not found ? try to find it in the windows fonts directory + { + wchar_t *fp = WMALLOC(WA_MAX_PATH); + Wasabi::Std::getFontPath(WA_MAX_PATH, fp); + StringW file; + file.own(fp); +// FREE(fp); // benski> no need because we now own it + file.AppendPath(StringPrintfW(L"%s%s", id, WCSCASESTR(id, L".ttf") == NULL ? L".ttf":L"")); + + if (!WACCESS(file, 0)) + { + svc_font *f = newTrueTypeFont(); + f->setFontFace(id); + f->setFontId(id); + OSFILETYPE ff = WFOPEN(file, WF_READONLY_BINARY); + if (ff != OPEN_FAILED) + { + if (f->addFontResource(ff, id)) + { + DebugStringW(L"font.cpp ====== FONT FOR ID=%s NOT FOUND. USING WIN FONT FILE:\n%s\n", id, file.getValue()); + fontlist.addItem(f); + } + } else { + DebugStringW(L"font.cpp ====== FONT FOR ID=%s NOT FOUND. CANNOT OPEN WIN FONT FILE:\n%s\n", id, file.getValue()); + delete f; + f = NULL; + } + return f; + } + } + + // not found ? ask the Std:: interface for the folder and the + // default fontname (ie: one you know will always be in the OS) + svc_font *f = newTrueTypeFont(); + if (f) { + if (gotdefault) *gotdefault = 1; + if (oldsize != -1 && size) { + *size = oldsize; + double f = (double)Wasabi::Std::getDefaultFontScale() / 100.0; + *size = (int)(*size*f); + } + // Query Std:: and build the path to the default font file. + wchar_t *fontPath = WMALLOC(WA_MAX_PATH); + Wasabi::Std::getFontPath(WA_MAX_PATH, fontPath); + wchar_t fontFile[WA_MAX_PATH] = {0}; + Wasabi::Std::getDefaultFont(WA_MAX_PATH, fontFile); + StringW defaultFont; + defaultFont.own(fontPath); + defaultFont.AppendPath(fontFile); +// FREE(fontFile); + StringW fs = defaultFont; + wchar_t *p = wcschr(fs.getNonConstVal(), '.'); + if (p) *p = 0; + PathParserW pp(fs); + fs = pp.getLastString(); + f->setFontFace(fs); + f->setFontId(id); + // Open it and load it as the font resource. + OSFILETYPE ff = WFOPEN(defaultFont, WF_READONLY_BINARY); + if (ff != OPEN_FAILED) { + if (f->addFontResource(ff, fs)) + { + DebugStringW(L"font.cpp ====== FONT FOR ID=%s NOT FOUND. USING DEFAULT FONT FILE:\n%s\n", id, defaultFont); + fontlist.addItem(f); + } + } else { + DebugStringW(L"font.cpp ====== FONT FOR ID=%s NOT FOUND. CANNOT OPEN FONT FILE:\n%s\n", id, defaultFont); + delete f; + f = NULL; + } + } else { + DebugString("font.cpp ====== CAN'T GET NEW FONT FILE.\n"); + delete f; + f = NULL; + } + + +#ifdef _WIN32 + if (f == NULL) { + // not found :((((( grab the default font data and use this, whatever it is + f = newTrueTypeFont(); + if (f) + { + HDC dc = GetDC(GetDesktopWindow()); + HDC dc2 = CreateCompatibleDC(dc); + SelectObject(dc2, GetStockObject(DEFAULT_GUI_FONT)); + + int datalen = GetFontData(dc2, 0, 0, NULL, 0); + if (datalen > 0) { + void *mem = WASABI_API_MEMMGR->sysMalloc(datalen+1); // freed by the service !! + ASSERT(mem != NULL); + GetFontData(dc2, 0, 0, mem, datalen); + + f->setFontFace(id); + f->setFontId(id); + f->addFontResource2(mem, datalen, id); + + ReleaseDC(GetDesktopWindow(), dc); + DeleteDC(dc2); + fontlist.addItem(f); + return f; + } + delete f; + f = NULL; + } + } +#else +#warning port me +#endif + + if (f == NULL) { + // ok, NOW I'm getting pissed + wchar_t fp[WA_MAX_PATH] = {0}; + Wasabi::Std::getFontPath(WA_MAX_PATH, fp); +#ifdef _WIN32 + Wasabi::Std::messageBox(StringPrintfW(L"Fatal error trying to load truetype fonts.\n\nYou need arial.ttf at the very least, but it does not appear to be in %s", fp), L"Fatal Error", MB_ICONERROR); +#else +#warning port me +#endif + } + + //if (f == NULL) DebugString("font.cpp ====== FALLBACK FOR FONT %s CANNOT BE FOUND IN OUR LISTS.\n",f->getFontId()); + + return f; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +// Intelligently delete the font +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void Font::deleteFont(svc_font *f) +{ + if (f) + { + if (f->isBitmap()) + { + delete static_cast(f); // we delete our own bitmap fonts. + } + else + { + SvcEnum::release(f); + } + } +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +// Intelligently make a new truetype font from the service interfaces +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +svc_font *Font::newTrueTypeFont() +{ +/*#ifdef WASABI_COMPILE_CONFIG + const GUID options_guid = + { 0x280876cf, 0x48c0, 0x40bc, { 0x8e, 0x86, 0x73, 0xce, 0x6b, 0xb4, 0x62, 0xe5 } }; + CfgItem *options = WASABI_API_CONFIG->config_getCfgItemByGuid(options_guid); +#endif*/ + + svc_font *retval = NULL; + const wchar_t *name = NULL; + +#ifdef WASABI_COMPILE_CONFIG + //const wchar_t *attr = L"Font Renderer"; + // First, try to find a font service that matches the attribute. +// if (options) { +// char buf[256]; // WHEEE for stack arrays +// if (options->getData(attr, buf, sizeof buf)) { + if (WASABI_API_SKIN->skin_getVersion() >= 1.3) // hardcode win32 renderer for v1.3+ skins + retval = FontSvcEnum(L"Win32 TextOut").getFirst(); + else + retval = FontSvcEnum(cfg_options_fontrenderer.getValue()).getFirst(); + +#else +#ifndef WASABI_FONT_RENDERER +#error You need to define WASABI_FONT_RENDERER (ie: #define WASABI_FONT_RENDERER "Freetype") +#endif + retval = FontSvcEnum(WASABI_FONT_RENDERER).getFirst(); +#endif +#ifdef WASABI_COMPILE_CONFIG +// } +// } + + // If we can't find one, fallback and just take the first. + if (!retval) + { + retval = FontSvcEnum().getFirst(); + if (retval != NULL) + name = retval->getFontSvcName(); + } + + // If we had to fallback, remember the fallback service in the attribute. + if (name/* && options*/) + { + //options->setData(attr, name); + cfg_options_fontrenderer.setValue(name); + } +#endif + + return retval; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +// Test whether to forbid bitmap fonts. +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +int Font::useTrueTypeOverride(const wchar_t *txt) + +{ + if (cfg_options_no7bitsttfoverride.getValueAsInt()) + { + const wchar_t *p = (const wchar_t *)txt; + while (p && *p) + { + // TODO: benski> some characters above 127 can be handled by the bitmap fonts - it might be worth checking those explicitly + if (*p & 0xFF80) + break; + p++; + } + if (!*p) return 0; + } +#ifdef WASABI_COMPILE_CONFIG +/* // {280876CF-48C0-40bc-8E86-73CE6BB462E5} + const GUID options_guid = + { 0x280876cf, 0x48c0, 0x40bc, { 0x8e, 0x86, 0x73, 0xce, 0x6b, 0xb4, 0x62, 0xe5 } }; + return !_intVal(WASABI_API_CONFIG->config_getCfgItemByGuid(options_guid), "Use bitmap fonts (no international support)", 1);*/ + return !cfg_options_allowbitmapfonts.getValueAsInt(); +#else + return WASABI_FONT_TTFOVERRIDE; +#endif +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +// Get the font to be used to override bitmap fonts. +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +const wchar_t *Font::getTrueTypeOverride() +{ +#ifdef WASABI_COMPILE_CONFIG + return cfg_options_ttfoverridefont.getValue(); +#else + return L"Arial"; +#warning TODO +#endif +} + +int Font::getTrueTypeOverrideScale() +{ +#ifdef WASABI_COMPILE_CONFIG + return cfg_options_ttfoverridescale.getValueAsInt(); +#else + return 1; +#warning TODO +#endif +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +// Returns the font mapping for this font & skin, if font mapper is on and if there is a mapping, otherwise returns null +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +const wchar_t *Font::getFontMapping(const wchar_t *id, int *size) +{ + if (cfg_options_usefontmapper.getValueAsInt()) + { + wchar_t t[256]=L""; + StringW tmp; + tmp.printf(L"Skin:%s/Font Mapping/%s",WASABI_API_SKIN->getSkinName(), id); + WASABI_API_CONFIG->getStringPrivate(tmp, t, 256, L""); + + tmp.printf(L"Skin:%s/Font Mapping/%s_scale",WASABI_API_SKIN->getSkinName(), id); + int v = WASABI_API_CONFIG->getIntPrivate(tmp, -1); + if (!*t) + { + tmp.printf(L"Font Mapping/%s", id); + WASABI_API_CONFIG->getStringPrivate(tmp, t, 256, L""); + tmp.printf(L"Font Mapping/%s_scale", id); + v = WASABI_API_CONFIG->getIntPrivate(tmp, -1); + } + mapping = t; + if (mapping.isempty()) return NULL; + if (size != NULL) + { + if (v != -1) + { + double f = (double)v / 100.0; + *size = (int)((double)*size * f); + } + } + return mapping; + } + return NULL; +} + +StringW Font::mapping; \ No newline at end of file diff --git a/Src/Wasabi/api/font/font.h b/Src/Wasabi/api/font/font.h new file mode 100644 index 00000000..8e1f15f2 --- /dev/null +++ b/Src/Wasabi/api/font/font.h @@ -0,0 +1,55 @@ +#ifndef __FONT_H +#define __FONT_H + +#include +#include + +class ifc_canvas; +class svc_font; +class svc_fontMaker; + +class FontDef { + public: + StringW filename; + StringW path; + StringW id; + int allowmapping; + int isbitmap; + int scriptid; +}; + +class Font { + public: + static void init(); + + static svc_font *installTrueTypeFont(const wchar_t *filename, const wchar_t *path, const wchar_t *id, int scriptid, int allowmapping, int isreload); // call this to install a new font + static void installBitmapFont(const wchar_t *filename, const wchar_t *path, const wchar_t *id, int charwidth, int charheight, int hspacing, int vspacing, int scriptid, int allowmapping); + static void uninstallAll(int isttfreload=0); + static void uninstallByScriptId(int scriptid); + + static svc_font *requestSkinFont(const wchar_t *id, int *size=NULL, int *gotdefault=NULL); // call this to get a Font pointer to a font id, pass your size if you have one, so that the mapper can do its job. + static void dispatchTextOut(ifc_canvas *c, int style, int x, int y, int w, int h, const wchar_t *txt); + static int dispatchGetInfo(ifc_canvas *c, const wchar_t *font, int infoid, const wchar_t *txt, int *w, int *h); + + static int useTrueTypeOverride(const wchar_t *txt); + static const wchar_t *getTrueTypeOverride(); + static int getTrueTypeOverrideScale(); + static int getNumFonts() { return fontlist.getNumItems(); } + + static FontDef *enumFontDef(int n) { return fontdefs.enumItem(n); } + static int getNumFontDefs() { return fontdefs.getNumItems(); } + + static const wchar_t *getFontMapping(const wchar_t *id, int *size); + + private: + static void deleteFont(svc_font *font); + static svc_font *newTrueTypeFont(); + + static PtrList fontlist; + static PtrList fontdefs; + StringW font_id; + int scriptid; + static StringW mapping; +}; + +#endif diff --git a/Src/Wasabi/api/font/fontapi.cpp b/Src/Wasabi/api/font/fontapi.cpp new file mode 100644 index 00000000..c004c65c --- /dev/null +++ b/Src/Wasabi/api/font/fontapi.cpp @@ -0,0 +1,32 @@ +#include +#include "fontapi.h" +#include + +api_font *fontApi = NULL; + +FontApi::FontApi() +{ + Font::init(); +} + +FontApi::~FontApi() +{ + Font::uninstallAll(); +} + +void FontApi::font_textOut(ifc_canvas *c, int style, int x, int y, int w, int h, const wchar_t *txt) +{ + Font::dispatchTextOut(c, style, x, y, w, h, txt); +} + +int FontApi::font_getInfo(ifc_canvas *c, const wchar_t *font, int infoid, const wchar_t *txt, int *w, int *h) +{ + return Font::dispatchGetInfo(c, font, infoid, txt, w, h); +} + +#define CBCLASS FontApi +START_DISPATCH; + VCB(API_FONT_FONT_TEXTOUT, font_textOut); + CB(API_FONT_FONT_GETINFO, font_getInfo); +END_DISPATCH; +#undef CBCLASS \ No newline at end of file diff --git a/Src/Wasabi/api/font/fontapi.h b/Src/Wasabi/api/font/fontapi.h new file mode 100644 index 00000000..3a169ac3 --- /dev/null +++ b/Src/Wasabi/api/font/fontapi.h @@ -0,0 +1,20 @@ +#ifndef __FONTAPI_H +#define __FONTAPI_H + +#include + +class FontApi : public api_font +{ +public: + FontApi(); + ~FontApi(); + void font_textOut(ifc_canvas *c, int style, int x, int y, int w, int h, const wchar_t *txt); + int font_getInfo(ifc_canvas *c, const wchar_t *font, int infoid, const wchar_t *txt, int *w, int *h); + +protected: + RECVS_DISPATCH; +}; + +extern api_font *fontApi; + +#endif diff --git a/Src/Wasabi/api/font/linux/truetypefont_linux.cpp b/Src/Wasabi/api/font/linux/truetypefont_linux.cpp new file mode 100644 index 00000000..188d09b6 --- /dev/null +++ b/Src/Wasabi/api/font/linux/truetypefont_linux.cpp @@ -0,0 +1,472 @@ +// ============================================================================================================================================================ +// Font abstract class + statics to install TT fonts and Bitmap fonts +// ============================================================================================================================================================ + +// what other linux headers need be made? + +#include "truetypefont_linux.h" + +#include +#include "../../bitmap.h" + +// ============================================================================================================================================================ +// TrueTypeFont_Linux implementation. +// ============================================================================================================================================================ + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +TrueTypeFont_Linux::TrueTypeFont_Linux() { + font = NULL; + antialias_canvas = NULL; + DColdstate = NULL; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +TrueTypeFont_Linux::~TrueTypeFont_Linux() { + ASSERT(fontstack.isempty()); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +int TrueTypeFont_Linux::isBitmap() { + return 0; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Linux::addFontResource(FILE *in){ + ASSERT(in != NULL); + OutputDebugString( "portme -- TrueTypeFont_Linux::addFontResource\n" ); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Linux::setFontFace(const char *face) { + face_name = face; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +const char *TrueTypeFont_Linux::getFaceName() { + return face_name; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Linux::prepareCanvas(ifc_canvas *c, int size, int bold, int opaque, int underline, int italic, COLORREF color, COLORREF bkcolor) { + String fontname = StringPrintf( "-*-%s-%s-%s-*--%d-*-*-*-*-*-*-*", + (const char *)face_name, + bold?"bold":"medium", + italic?"i":"r", size * 3/4 ); + font = XLoadQueryFont( Linux::getDisplay(), (const char *)fontname ); + if ( font == NULL ) { + fontname = StringPrintf( "-*-arial-%s-%s-*--%d-*-*-*-*-*-*-*", + bold?"bold":"medium", + italic?"i":"r", size * 3/4 ); + font = XLoadQueryFont( Linux::getDisplay(), (const char *)fontname ); + + if ( font == NULL ) { + fontname = StringPrintf( "-*-courier-%s-%s-*--%d-*-*-*-*-*-*-*", + bold?"bold":"medium", + italic?"i":"r", size * 3/4 ); + font = XLoadQueryFont( Linux::getDisplay(), (const char *)fontname ); + } + } + ASSERTPR( font != NULL, fontname ); + XSetFont( Linux::getDisplay(), c->getHDC()->gc, font->fid ); + XSetForeground( Linux::getDisplay(), c->getHDC()->gc, color ); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Linux::restoreCanvas(ifc_canvas *c) { + if ( font != NULL ) { + XFreeFont( Linux::getDisplay(), font ); + font = NULL; + } +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +ifc_canvas *TrueTypeFont_Linux::prepareAntialias(ifc_canvas *c, int x, int y, const char *txt, int size, int bold, int opaque, int underline, int italic, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int w, int h) { + ASSERT(antialias_canvas == NULL); + BaseCloneCanvas canvas(c); + prepareCanvas(&canvas, size, bold, opaque, underline, italic, color, bkcolor); + al_w = MAX(2,canvas.getTextWidth(txt) * 2 + xoffset*2); + al_h = MAX(2,canvas.getTextHeight()*2 + yoffset*2); + restoreCanvas(&canvas); + if (w != -1) { + al_w = w * 2; + al_dw = w; + } else al_dw = w; + if (h != -1) { + al_h = h * 2; + al_dh = h; + } else al_dh = h; + al_mask=RGB(0,0,0); + if (color == al_mask) al_mask=RGB(255,255,255); + antialias_canvas = new BltCanvas(al_w, al_h); + antialias_canvas->fillBits(0); + prepareCanvas(antialias_canvas, size*2, bold, opaque, underline, italic, color, bkcolor); + if (al_mask != 0) antialias_canvas->fillBits(al_mask); + al_x = x; al_y = y; al_xo = xoffset; al_yo = yoffset; + return antialias_canvas; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Linux::completeAntialias(ifc_canvas *c) { + BaseCloneCanvas canvas(c); + antialias_canvas->maskColor(al_mask, RGB(0,0,0)); + BltCanvas *ac = new BltCanvas(al_w/2, al_h/2); + antialias_canvas->antiAliasTo(ac, al_w/2, al_h/2, 2); + SkinBitmap *b = ac->getSkinBitmap(); + RECT src={0,0,al_w/2,al_h/2}; + RECT dst={al_x+al_xo,al_y+al_yo,al_x+al_xo+al_dw,al_y+al_yo+al_dh}; + b->blitToRect(&canvas, &src, &dst); + delete ac; + restoreCanvas(antialias_canvas); + delete antialias_canvas; + antialias_canvas = NULL; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Linux::textOut(ifc_canvas *c, int x, int y, const char *txt, int size, int bold, int opaque, int underline, int italic, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialiased) { + if (antialiased) { + ifc_canvas *canvas = prepareAntialias(c, x, y, txt, size, bold, opaque, underline, italic, color, bkcolor, xoffset, yoffset, -1, -1); + + HDC hdc = c->getHDC(); + XDrawString( Linux::getDisplay(), hdc->d, hdc->gc, 0, 0, txt, STRLEN(txt) ); + + completeAntialias(c); + } else { + prepareCanvas(c, size, bold, opaque, underline, italic, color, bkcolor); + + int dir, ascent, descent; + XCharStruct overall; + XTextExtents( font, txt, STRLEN( txt ), &dir, &ascent, &descent, &overall ); + + HDC hdc = c->getHDC(); + XDrawString( Linux::getDisplay(), hdc->d, hdc->gc, x+xoffset, y+yoffset+ascent, txt, STRLEN(txt) ); + + + restoreCanvas(c); + } +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Linux::textOut(ifc_canvas *c, int x, int y, int w, int h, const char *txt, int size, int bold, int opaque, int underline, int italic, int align, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialiased) { + if (antialiased) { + ifc_canvas *canvas = prepareAntialias(c, x, y, txt, size, bold, opaque, underline, italic, color, bkcolor, xoffset, yoffset, w, h); + RECT al_r={0,0,w*2,h*2}; + + HDC hdc = c->getHDC(); + XDrawString( Linux::getDisplay(), hdc->d, hdc->gc, al_r.left, al_r.top, txt, STRLEN(txt) ); + + completeAntialias(c); + } else { + RECT r; + r.left = x+xoffset; + r.top = y+yoffset; + r.right = r.left + w; + r.bottom = r.top + h; + prepareCanvas(c, size, bold, opaque, underline, italic, color, bkcolor); + + int dir, ascent, descent; + XCharStruct overall; + XTextExtents( font, txt, STRLEN( txt ), &dir, &ascent, &descent, &overall ); + int xstart = r.left; + + if ( align == DT_RIGHT ) { + int width = XTextWidth( font, txt, STRLEN( txt ) ); + xstart = r.right - width; + + } else if ( align == DT_CENTER ) { + int width = XTextWidth( font, txt, STRLEN( txt ) ); + xstart = (r.right + r.left - width) / 2; + } + + HDC hdc = c->getHDC(); + XDrawString( Linux::getDisplay(), hdc->d, hdc->gc, xstart, r.top + ascent, txt, STRLEN(txt) ); + + restoreCanvas(c); + } +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Linux::textOutEllipsed(ifc_canvas *c, int x, int y, int w, int h, const char *txt, int size, int bold, int opaque, int underline, int italic, int align, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialiased) { + if (antialiased) { + ifc_canvas *canvas = prepareAntialias(c, x, y, txt, size, bold, opaque, underline, italic, color, bkcolor, xoffset, yoffset, w, h); + RECT al_r={0,0,w*2,h*2}; + + OutputDebugString( "portme -- TrueTypeFont_Linux::textoutEllipsed (antialiased)\n" ); + + completeAntialias(c); + } else { + RECT r; + r.left = x+xoffset; + r.top = y+yoffset; + r.right = r.left + w; + r.bottom = r.top + h; + prepareCanvas(c, size, bold, opaque, underline, italic, color, bkcolor); + + if ( txt == NULL ) + return; + + int dir, ascent, descent; + XCharStruct overall; + XTextExtents( font, txt, STRLEN( txt ), &dir, &ascent, &descent, &overall ); + + char *tmp = (char *)MALLOC( STRLEN( txt ) + 3 ); + STRCPY( tmp, txt ); + + if ( XTextWidth( font, tmp, STRLEN( tmp ) ) > r.right - r.left ) { + int len = STRLEN( tmp ); + char *p = tmp + len; + int width = r.right - r.left - XTextWidth( font, "...", 3 ); + while( XTextWidth( font, tmp, len ) > width ) { + *p-- = '\0'; + len--; + } + STRCPY( p, "..." ); + } + + HDC hdc = c->getHDC(); + XDrawString( Linux::getDisplay(), hdc->d, hdc->gc, r.left, r.top + ascent, tmp, STRLEN(tmp) ); + + FREE( tmp ); + + restoreCanvas(c); + } +} + +const char *find_break( int (*width_func)(void *, const char *, int ), + void *f, const char *str, int width ) { + const char *softret, *lastsoft, *hardret; + + if ( width_func( f, str, STRLEN( str ) ) <= width ) + return str + STRLEN( str ); + + for( hardret = str; *hardret; hardret ++ ) + if ( *hardret == '\r' || *hardret == '\n' ) + break; + + if ( hardret && width_func( f, str, hardret - str ) <= width ) { + return hardret; + } + for( softret = str; *softret && !isspace( *softret ); softret++ ) + ; + + if ( width_func( f, str, softret - str ) <= width ) { + do { + lastsoft = softret; + + for( softret = lastsoft+1; *softret && !isspace( *softret ); softret++ ) + ; + + } while ( *lastsoft && width_func( f, str, softret - str ) <= width ); + + softret = lastsoft; + } else { + for( softret = str; *softret; softret++ ) + if ( width_func( f, str, softret - str ) > width ) + break; + + softret--; + } + + return softret; +} + +int xlib_width( void *data, const char *str, int len ) { + return XTextWidth( (XFontStruct *)data, str, len ); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Linux::textOutWrapped(ifc_canvas *c, int x, int y, int w, int h, const char *txt, int size, int bold, int opaque, int underline, int italic, int align, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialiased) { + if (antialiased) { + ifc_canvas *canvas = prepareAntialias(c, x, y, txt, size, bold, opaque, underline, italic, color, bkcolor, xoffset, yoffset, w, h); + RECT al_r={0,0,w*2,h*2}; + + OutputDebugString( "portme -- TrueTypeFont_Linux::textoutWrapped (antialiased)\n" ); + + completeAntialias(c); + } else { + RECT r; + r.left = x+xoffset; + r.top = y+yoffset; + r.right = r.left + w; + r.bottom = r.top + h; + prepareCanvas(c, size, bold, opaque, underline, italic, color, bkcolor); + + + int dir, ascent, descent; + XCharStruct overall; + XTextExtents( font, txt, STRLEN( txt ), &dir, &ascent, &descent, &overall ); + HDC hdc = c->getHDC(); + + int yoff = r.top + ascent; + const char *cur = txt, *next; + int length = STRLEN( txt ); + for (int yoff = r.top + ascent; yoff < r.bottom - descent; yoff += ascent + descent) { + next = find_break(xlib_width, font, cur, r.right - r.left); + XDrawString( Linux::getDisplay(), hdc->d, hdc->gc, r.left, yoff, cur, next - cur ); + for ( cur = next; *cur && isspace( *cur ); cur++ ) + ; + if ( cur >= txt + length ) + break; + } + + + restoreCanvas(c); + } +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Linux::textOutWrappedPathed(ifc_canvas *c, int x, int y, int w, const char *txt, int size, int bold, int opaque, int underline, int italic, int align, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialiased) { + prepareCanvas(c, size, bold, opaque, underline, italic, color, bkcolor); + RECT r; + char *ptr, *d; + const char *s; + ptr = (char *)MALLOC(STRLEN(txt)+1+4); + for (s = txt, d = ptr; *s; s++, d++) { + if (*s == '/') *d = '\\'; + else *d = *s; + } + r.left = x+xoffset; + r.top = y+yoffset; + r.right = r.left + w; + r.bottom = r.top + getTextHeight(c, size, bold, underline, italic, antialiased); + + OutputDebugString( "portme -- TrueTypeFont_Linux::textoutWrappedPathed\n" ); + + for (d = ptr; *d; d++) { + if (*d == '\\') *d = '/'; + } + + if (antialiased) { + restoreCanvas(c); + + ifc_canvas *canvas = prepareAntialias(c, x, y, txt, size, bold, opaque, underline, italic, color, bkcolor, xoffset, yoffset, w, -1); + RECT al_r={0,0,w*2,al_h}; + + OutputDebugString( "portme -- TrueTypeFont_Linux::textoutWrappedPathed (antialised)\n" ); + + completeAntialias(c); + } else { + int dir, ascent, descent; + XCharStruct overall; + XTextExtents( font, txt, STRLEN( txt ), &dir, &ascent, &descent, &overall ); + + HDC hdc = c->getHDC(); + XDrawString( Linux::getDisplay(), hdc->d, hdc->gc, r.left, r.top + ascent, txt, STRLEN(txt) ); + OutputDebugString( "portme -- TrueTypeFont_Linux::textoutWrappedPathed\n" ); + + restoreCanvas(c); + } + + FREE(ptr); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Linux::textOutCentered(ifc_canvas *c, RECT *r, const char *txt, int size, int bold, int opaque, int underline, int italic, int align, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialiased) { + ASSERT(r != NULL); + ASSERT(txt != NULL); + RECT rr=*r; + rr.left += xoffset; + rr.right += xoffset; + rr.top += yoffset; + rr.bottom += yoffset; + + if (antialiased) { + ifc_canvas *canvas = prepareAntialias(c, r->left, r->top, txt, size, bold, opaque, underline, italic, color, bkcolor, xoffset, yoffset, r->right-r->left, r->bottom-r->top); + RECT al_r={0,0,(r->right-r->left)*2,(r->bottom-r->top)*2}; + + OutputDebugString( "portme -- TrueTypeFont_Linux::textoutCentered (antialiased)\n" ); + + completeAntialias(c); + } else { + prepareCanvas(c, size, bold, opaque, underline, italic, color, bkcolor); + + int dir, ascent, descent, width; + XCharStruct overall; + XTextExtents( font, txt, STRLEN( txt ), &dir, &ascent, &descent, &overall ); + width = XTextWidth( font, txt, STRLEN( txt ) ); + + HDC hdc = c->getHDC(); + XDrawString( Linux::getDisplay(), hdc->d, hdc->gc, (rr.right + rr.left - width) / 2, rr.top + ascent, txt, STRLEN(txt) ); + + restoreCanvas(c); + } +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +int TrueTypeFont_Linux::getTextWidth(ifc_canvas *c, const char *text, int size, int bold, int underline, int italic, int antialiased) { + int w; + getTextExtent(c, text, &w, NULL, size, bold, underline, italic, antialiased); + return w; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +int TrueTypeFont_Linux::getTextHeight(ifc_canvas *c, const char *text, int size, int bold, int underline, int italic, int antialiased) { + int h; + getTextExtent(c, text, NULL, &h, size, bold, underline, italic, antialiased); + { + // calcul for multiline text + const char *p=text; + int n=0; + while(*p!=0) if(*p++=='\n') n++; + if(n) h*=(n+1); + } + return h; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Linux::getTextExtent(ifc_canvas *c, const char *txt, int *w, int *h, int size, int bold, int underline, int italic, int antialiased) { + SIZE rsize={0,0}; + ASSERT(txt != NULL); + if (*txt == 0) { + if (w != NULL) *w = 0; + if (h != NULL) *h = 0; + return; + } + + if (antialiased) + prepareCanvas(c, size*2, bold, 0, underline, italic, 0, 0); + else + prepareCanvas(c, size, bold, 0, underline, italic, 0, 0); + + int dir, ascent, descent; + XCharStruct overall; + XTextExtents( font, txt, STRLEN( txt ), &dir, &ascent, &descent, &overall ); + rsize.cy = ascent + descent; + rsize.cx = XTextWidth( font, txt, STRLEN( txt ) ); + + if (w != NULL) *w = rsize.cx; + if (h != NULL) *h = rsize.cy; + + if (antialiased) { + if (w != NULL) *w /= 2; + if (h != NULL) *h /= 2; + } + + restoreCanvas(c); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +int TrueTypeFont_Linux::getTextHeight(ifc_canvas *c, int size, int bold, int underline, int italic, int antialiased) { + return getTextHeight(c, "My", size, bold, underline, italic, antialiased); +} + + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +// code from ftp.microsoft.com/Softlib/MSLFILES/FONTINST.EXE +// retrieves the friendly font name from its filename +char *TrueTypeFont_Linux::filenameToFontFace(const char *pszFile) { + static char lpszLongName[256]; + unsigned i; + char namebuf[255]; + int fp; + unsigned short numNames; + long curseek; + unsigned cTables; + sfnt_OffsetTable OffsetTable; + sfnt_DirectoryEntry Table; + sfnt_NamingTable NamingTable; + sfnt_NameRecord NameRecord; + + OutputDebugString( "portme -- TrueTypeFont_Linux::filenameToFontFace\n" ); + + return FALSE; +} diff --git a/Src/Wasabi/api/font/linux/truetypefont_linux.h b/Src/Wasabi/api/font/linux/truetypefont_linux.h new file mode 100644 index 00000000..b98046c5 --- /dev/null +++ b/Src/Wasabi/api/font/linux/truetypefont_linux.h @@ -0,0 +1,65 @@ +#ifndef __TRUETYPEFONT_LINUX_H +#define __TRUETYPEFONT_LINUX_H + +#include "../../../studio/services/svc_font.h" + +#include "../../string.h" +#include "../../stack.h" +#include "../truetypefontdef.h" + +class ifc_canvas; +class BltCanvas; + +class TrueTypeFont_Linux : public svc_fontI { + public: + TrueTypeFont_Linux(); + virtual ~TrueTypeFont_Linux(); + + virtual void textOut(ifc_canvas *c, int x, int y, const char *txt, int size, int bold, int opaque, int underline, int italic, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialias); + virtual void textOut2(ifc_canvas *c, int x, int y, int w, int h, const char *txt, int size, int bold, int opaque, int underline, int italic, int align, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialias); + virtual void textOutEllipsed(ifc_canvas *c, int x, int y, int w, int h, const char *txt, int size, int bold, int opaque, int underline, int italic, int align, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialias); + virtual void textOutWrapped(ifc_canvas *c, int x, int y, int w, int h, const char *txt, int size, int bold, int opaque, int underline, int italic, int align, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialias); + virtual void textOutWrappedPathed(ifc_canvas *c, int x, int y, int w, const char *txt, int size, int bold, int opaque, int underline, int italic, int align, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialias); + virtual void textOutCentered(ifc_canvas *c, RECT *r, const char *txt, int size, int bold, int opaque, int underline, int italic, int align, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialias); + virtual int getTextWidth(ifc_canvas *c, const char *text, int size, int bold, int underline, int italic, int antialias); + virtual int getTextHeight(ifc_canvas *c, const char *text, int size, int bold, int underline, int italic, int antialias); + virtual int getTextHeight2(ifc_canvas *c, int size, int bold, int underline, int italic, int antialias); + virtual void getTextExtent(ifc_canvas *c, const char *text, int *w, int *h, int size, int bold, int underline, int italic, int antialias); + + virtual void setFontId(const char *id) { font_id = id; } + virtual const char *getFontId() { return font_id; } + virtual int getScriptId() { return scriptid; } + virtual void setScriptId(int id) { scriptid = id; } + + virtual int isBitmap(); + virtual void setFontFace(const char *face); + virtual int addFontResource(FILE *f); + virtual const char *getFaceName(); + + virtual const wchar_t *getFontSvcName() { return "Linux"; } + static const char *getServiceName() { return "Linux font renderer"; } + + protected: + static char *filenameToFontFace(const wchar_t *filename); + void prepareCanvas(ifc_canvas *c, int size, int bold, int opaque, int underline, int italic, COLORREF color, COLORREF bkcolor); + void restoreCanvas(ifc_canvas *c); + + protected: + String font_id; + int scriptid; + + private: + ifc_canvas *prepareAntialias(ifc_canvas *c, int x, int y, const char *txt, int size, int bold, int opaque, int underline, int italic, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int w, int h); + void completeAntialias(ifc_canvas *c); + + String face_name; + String tmpfilename; + int DColdstate; + XFontStruct *font; + Stack fontstack; + BltCanvas *antialias_canvas; + int al_w, al_h, al_x, al_y, al_xo, al_yo, al_dw, al_dh; + COLORREF al_mask; +}; + +#endif diff --git a/Src/Wasabi/api/font/skinfont.cpp b/Src/Wasabi/api/font/skinfont.cpp new file mode 100644 index 00000000..d1987dfa --- /dev/null +++ b/Src/Wasabi/api/font/skinfont.cpp @@ -0,0 +1,43 @@ +#include "precomp.h" +#include "skinfont.h" +#include "api.h" +#include "../bfc/std.h" + +SkinFont::SkinFont() { +} + +SkinFont::~SkinFont() { + if (!tempFn.isempty()) { +#ifdef WIN32 + RemoveFontResource(tempFn); +#else + DebugString( "portme -- SkinFont::~SkinFont\n" ); +#endif + UNLINK(tempFn); + } +} + +int SkinFont::setXmlOption(const char *paramname, const char *strvalue) { + return 0; +} + +void SkinFont::installFont(OSFNSTR filename, OSFNSTR path) { + FILE *in,*out; + StringPrintf temp("%s%s", path, filename); + in = WFOPEN(temp, L"rb"); + if (!in) return; + int len = FGETSIZE(in); + MemBlock m(len); + FREAD(m.getMemory(), len, 1, in); + tempFn = TMPNAM(NULL); + out = FOPEN(tempFn, "wb"); + ASSERT(out); + FWRITE(m.getMemory(), len, 1, out); + FCLOSE(out); + FCLOSE(in); +#ifdef WIN32 + AddFontResource(tempFn); +#else + DebugString( "portme -- SkinFont::installFont\n" ); +#endif +} diff --git a/Src/Wasabi/api/font/skinfont.h b/Src/Wasabi/api/font/skinfont.h new file mode 100644 index 00000000..4780c136 --- /dev/null +++ b/Src/Wasabi/api/font/skinfont.h @@ -0,0 +1,17 @@ +#ifndef _SKINFONT_H +#define _SKINFONT_H + +#include + +class SkinFont : public XmlObjectI +{ +public: + SkinFont(); + ~SkinFont(); + void installFont(const wchar_t *filename, const wchar_t *path); + virtual int setXmlOption(const wchar_t *name, const wchar_t *val); +private: + StringW tempFn; +}; + +#endif diff --git a/Src/Wasabi/api/font/svc_fontI.h b/Src/Wasabi/api/font/svc_fontI.h new file mode 100644 index 00000000..76a9ad9c --- /dev/null +++ b/Src/Wasabi/api/font/svc_fontI.h @@ -0,0 +1,39 @@ +#ifndef NULLSOFT_WASABI_SVC_FONTI_H +#define NULLSOFT_WASABI_SVC_FONTI_H + +#include +//#include +class ifc_canvas; +// implementor derives from this one +class NOVTABLE svc_fontI : public svc_font { +public: + + virtual void textOut(ifc_canvas *c, int x, int y, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias)=0; // abstract interface + virtual void textOut2(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias)=0; + virtual void textOutEllipsed(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias)=0; + virtual void textOutWrapped(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias)=0; + virtual void textOutWrappedPathed(ifc_canvas *c, int x, int y, int w, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias)=0; + virtual void textOutCentered(ifc_canvas *c, RECT *r, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias)=0; + virtual int getTextWidth(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialias)=0; + virtual int getTextHeight(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialias)=0; + virtual int getTextHeight2(ifc_canvas *c, int size, int bold, int underline, int italic, int antialias)=0; + virtual void getTextExtent(ifc_canvas *c, const wchar_t *text, int *w, int *h, int size, int bold, int underline, int italic, int antialias)=0; + + virtual void setFontId(const wchar_t *id)=0; + virtual const wchar_t *getFontId()=0; + virtual const wchar_t *getFaceName()=0; + virtual int isBitmap()=0; + virtual int getScriptId()=0; + virtual void setScriptId(int id)=0; + + virtual void setFontFace(const wchar_t *face)=0; + virtual int addFontResource(OSFILETYPE f, const wchar_t *name)=0; + virtual int addFontResource2(void *mem, int datalen, const wchar_t *name)=0; + + virtual const wchar_t * getFontSvcName()=0; + +protected: + RECVS_DISPATCH; +}; + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/font/truetypefontdef.h b/Src/Wasabi/api/font/truetypefontdef.h new file mode 100644 index 00000000..2b54a045 --- /dev/null +++ b/Src/Wasabi/api/font/truetypefontdef.h @@ -0,0 +1,56 @@ +#ifndef __TRUETYPEFONTDEF_H +#define __TRUETYPEFONTDEF_H + +// Macros for TrueType portability +#define FS_2BYTE(p) ( ((unsigned short)((p)[0]) << 8) | (p)[1]) +#define FS_4BYTE(p) ( FS_2BYTE((p)+2) | ( (FS_2BYTE(p)+0L) << 16) ) +#define SWAPW(a) ((short) FS_2BYTE( (unsigned char FAR*)(&a) )) +#define SWAPL(a) ((long) FS_4BYTE( (unsigned char FAR*)(&a) )) + +typedef short int16; +typedef unsigned short uint16; +typedef long int32; +typedef unsigned long uint32; +typedef long sfnt_TableTag; + +typedef struct { + uint16 platformID; + uint16 specificID; + uint16 languageID; + uint16 nameID; + uint16 length; + uint16 offset; +} sfnt_NameRecord; + +typedef struct { + uint16 format; + uint16 count; + uint16 stringOffset; +} sfnt_NamingTable; + +typedef struct { + sfnt_TableTag tag; + uint32 checkSum; + uint32 offset; + uint32 length; +} sfnt_DirectoryEntry; + +typedef struct { + int32 version; + uint16 numOffsets; + uint16 searchRange; + uint16 entrySelector; + uint16 rangeShift; + sfnt_DirectoryEntry table[1]; +} sfnt_OffsetTable; +#define OFFSETTABLESIZE 12 + +typedef struct { + int dcstate; + HFONT font; + HFONT prevfont; +} fontslot; + +#define tag_NamingTable 0x656d616e /* 'name' */ + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/font/win32/truetypefont_win32.cpp b/Src/Wasabi/api/font/win32/truetypefont_win32.cpp new file mode 100644 index 00000000..46c41ce7 --- /dev/null +++ b/Src/Wasabi/api/font/win32/truetypefont_win32.cpp @@ -0,0 +1,561 @@ +#include "precomp.h" +// ============================================================================================================================================================ +// Font abstract class + statics to install TT fonts and Bitmap fonts +// ============================================================================================================================================================ +#define WIN32_LEAN_AND_MEAN +#include +#include "../nu/ns_wc.h" +#include "truetypefont_win32.h" + +#include +#include +#include +#include +#if UTF8 +#ifdef WANT_UTF8_WARNINGS +#pragma CHAT("mig", "all", "UTF8 is enabled in std.cpp -- Things might be screwy till it's all debugged?") +#endif +# include +#endif +#define VERTICAL_LPADDING 0 +#define VERTICAL_RPADDING 2 +#define VERTICAL_TPADDING 1 +#define VERTICAL_BPADDING 1 + +/** ============================================================================================================================================================ + ** TrueTypeFont_Win32 implementation. + ** + ** TODO: + ** use GDI transformation to draw in 72 DPI + ** fractional point sizes? + ** =========================================================================================================================================================== + */ + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +TrueTypeFont_Win32::TrueTypeFont_Win32() +{ + scriptid = 0; + font = oldFont = NULL; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +TrueTypeFont_Win32::~TrueTypeFont_Win32() +{ + if (!tmpfilename.isempty()) + { + RemoveFontResourceW(tmpfilename); + // explict call to this instead of UNLINK allows correct removal of the temp files + _wunlink(tmpfilename); + } +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +int TrueTypeFont_Win32::isBitmap() +{ + return 0; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +int TrueTypeFont_Win32::addFontResource(OSFILETYPE in, const wchar_t *name) +{ + ASSERT(in != NULL); + + int len = (int)FGETSIZE(in); + OSFILETYPE out; + char *m = (char *)MALLOC(len); + ASSERT(m != NULL); + FREAD(m, len, 1, in); + TmpNameStrW tempfn; + out = WFOPEN(tempfn, L"wb"); + ASSERT(out != OPEN_FAILED); + FWRITE(m, len, 1, out); + FCLOSE(out); + AddFontResourceW(tempfn); + FREE(m); + tmpfilename = tempfn; + setFontFace(filenameToFontFace(tempfn)); + return 1; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +int TrueTypeFont_Win32::addFontResource2(void *data, int datalen, const wchar_t *name) +{ + TmpNameStrW tempfn; + OSFILETYPE out = WFOPEN(tempfn, L"wb"); + ASSERT(out != OPEN_FAILED); + FWRITE(data, datalen, 1, out); + FCLOSE(out); + AddFontResourceW(tempfn); + tmpfilename = tempfn; + setFontFace(filenameToFontFace(tempfn)); + + WASABI_API_MEMMGR->sysFree(data); + + return 1; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Win32::setFontFace(const wchar_t *face) +{ + face_name = face; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +const wchar_t *TrueTypeFont_Win32::getFaceName() +{ + return face_name; +} + +static int IsXp_or_higher() +{ + static int checked=0; + static int isXp=0; + if (!checked) + { + OSVERSIONINFO osver; + osver.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); + isXp = ( ::GetVersionEx(&osver) && osver.dwPlatformId == VER_PLATFORM_WIN32_NT && (osver.dwMajorVersion >= 5 )) ? 1 : 0; + checked=1; + } + return isXp; +} + +#ifndef CLEARTYPE_QUALITY +#define CLEARTYPE_QUALITY 5 +#endif +HFONT TrueTypeFont_Win32::MakeFont(int size, int bold, int underline, int italic, int antialiased) +{ + // TODO: we got the height to be in 72 DPI, but how can we get the width??? + int nHeight = MulDiv(size, 72, 96); // this is lame, but we have to do it to match freetype + + int quality; + if (antialiased) + { + if (IsXp_or_higher()) + quality=CLEARTYPE_QUALITY; + else + quality=ANTIALIASED_QUALITY; + } + else + quality=NONANTIALIASED_QUALITY; + + return CreateFontW(-nHeight, 0, 0, 0, bold ? FW_BOLD : FW_NORMAL, + italic, underline, FALSE, DEFAULT_CHARSET, + OUT_TT_ONLY_PRECIS, + CLIP_DEFAULT_PRECIS, + quality, + DEFAULT_PITCH | FF_DONTCARE, face_name); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Win32::prepareCanvas(BltCanvas *canvas, int size, int bold, int opaque, int underline, int italic, int antialiased) +{ + HDC canvasHDC = canvas->getHDC(); + + font = MakeFont(size, bold, underline, italic, antialiased); + oldFont = (HFONT)SelectObject(canvasHDC, font); + + SetBkColor(canvasHDC, RGB(0, 0, 0)); + //SetBkMode(canvasHDC, TRANSPARENT); + SetTextColor(canvasHDC, RGB(255, 255, 255)); +} + +typedef DWORD ARGB; + +#define MIN_TONE 100.0 +//BYTE min = 255, max=0; +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Win32::restoreCanvas(BltCanvas *canvas, ifc_canvas *dest, int w, int h, COLORREF color, COLORREF bkcolor, int antialiased, int _x, int _y) +{ +#ifndef FE_FONTSMOOTHINGCLEARTYPE +#define FE_FONTSMOOTHINGCLEARTYPE 0x0002 +#endif + +#ifndef SPI_GETFONTSMOOTHINGTYPE +#define SPI_GETFONTSMOOTHINGTYPE 0x200A +#endif + + bool clearType = false; + UINT fontSmoothing; + if (antialiased && SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &fontSmoothing, 0)) + clearType = fontSmoothing == FE_FONTSMOOTHINGCLEARTYPE; + + ARGB32 *buf = static_cast(canvas->getBits()); + + for (int y = 0; y < h; y++) + { + int linewidth = y * w; + + for (int x = 0; x < w; x++) + { + + ARGB32* prgb = &buf[linewidth + x]; + unsigned char *pixel = (unsigned char *)prgb; + if (*prgb == 0) + { + // Do nothing + } + else + { + BYTE alpha = 255; + BYTE rAlpha = 255; + BYTE gAlpha = 255; + BYTE bAlpha = 255; + + if (*prgb != 0xFFFFFF) + { + if (clearType) + { + rAlpha = pixel[2]; + gAlpha = pixel[1]; + bAlpha = pixel[0]; + } + + UINT value = pixel[0] + pixel[1] + pixel[2]; + value = value / 3; + alpha = (BYTE)value; + + if (!clearType) + { + rAlpha = alpha; + gAlpha = alpha; + bAlpha = alpha; + } + + //alpha=pixel[0]; + //alpha = (((float)pixel[0] - MIN_TONE) / (255.0 - MIN_TONE)) * 255 ; + + //min = (min > value) ? value : min; + //max = (max < value) ? value : max; + } + + pixel[3] = (BYTE)alpha; + pixel[2] = ((GetRValue(color) * rAlpha) + 128) / 255; + pixel[1] = ((GetGValue(color) * gAlpha) + 128) / 255; + pixel[0] = ((GetBValue(color) * bAlpha) + 128) / 255; + } + } + } + + canvas->blitAlpha(dest, _x + VERTICAL_LPADDING, _y + VERTICAL_TPADDING); + //SkinBitmap *bitmap = canvas->getSkinBitmap(); + //bitmap->blitAlpha(dest, _x + VERTICAL_LPADDING, _y + VERTICAL_TPADDING); + + SelectObject(canvas->getHDC(), oldFont); + oldFont = 0; + DeleteObject(font); + font = 0; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Win32::textOut(ifc_canvas *c, int x, int y, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialiased) +{ + int w, h; + c->getDim(&w, &h); + + if (!h || !w) return; + + BltCanvas canvas; + prepareCanvas(&canvas, size, bold, opaque, underline, italic, antialiased); + canvas.DestructiveResize(w, h); + + TextOutW(canvas.getHDC(), x + xoffset, y + yoffset, txt, wcslen(txt)); + + restoreCanvas(&canvas, c, w, h, color, bkcolor, antialiased); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Win32::textOut2(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialiased) +{ + if (!h || !w) return; + + BltCanvas canvas; + prepareCanvas(&canvas, size, bold, opaque, underline, italic, antialiased); + canvas.DestructiveResize(/*x +*/ w, /*y +*/ h); + + RECT r = { + /*x +*/ xoffset, + /*y + */yoffset, + /*x + */w, + /*y + */h + }; + + DrawTextW(canvas.getHDC(), txt, -1, &r, align | DT_NOPREFIX | DT_NOCLIP); + + restoreCanvas(&canvas, c, /*x + */w, /*y + */h, color, bkcolor, antialiased, x, y); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Win32::textOutEllipsed(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialiased) +{ + if (!h || !w) return; + + BltCanvas canvas; + prepareCanvas(&canvas, size, bold, opaque, underline, italic, antialiased); + canvas.DestructiveResize(/*x + */w, /*y + */h); + + RECT r = { + /*x + */xoffset, + /*y + */yoffset, + /*x + */w, + /*y + */ h + }; + + DrawTextW(canvas.getHDC(), txt, -1, &r, align | DT_NOPREFIX | DT_END_ELLIPSIS | DT_NOCLIP); + restoreCanvas(&canvas, c,/* x + */w, /*y + */h, color, bkcolor, antialiased, x, y); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Win32::textOutWrapped(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialiased) +{ + if (!h || !w) return; + + BltCanvas canvas; + prepareCanvas(&canvas, size, bold, opaque, underline, italic, antialiased); + canvas.DestructiveResize(w, h); + + RECT r; + r.left = x + xoffset; + r.top = y + yoffset; + r.right = r.left + w; + r.bottom = r.top + h; + + DrawTextW(canvas.getHDC(), txt, -1, &r, align | DT_NOPREFIX | DT_WORDBREAK); + + restoreCanvas(&canvas, c, w, h, color, bkcolor, antialiased); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Win32::textOutWrappedPathed(ifc_canvas *c, int x, int y, int w, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialiased) +{ + int w_dummy, h; + c->getDim(&w_dummy, &h); + + if (!h || !w) return; + + BltCanvas canvas; + prepareCanvas(&canvas, size, bold, opaque, underline, italic, antialiased); + canvas.DestructiveResize(w, h); + + RECT r; + wchar_t *ptr, *d; + const wchar_t *s; + ptr = (wchar_t *)MALLOC(sizeof(wchar_t) * (wcslen(txt) + 1 + 4)); + for (s = txt, d = ptr; *s; s++, d++) + { + if (*s == '/') *d = '\\'; + else *d = *s; + } + r.left = x + xoffset; + r.top = y + yoffset; + r.right = r.left + w; + r.bottom = r.top + getTextHeight2(c, size, bold, underline, italic, antialiased); + + DrawTextW(canvas.getHDC(), ptr, -1, &r, align | DT_NOPREFIX | DT_PATH_ELLIPSIS | DT_SINGLELINE | DT_MODIFYSTRING | DT_CALCRECT); + + for (d = ptr; *d; d++) + { + if (*d == '\\') *d = '/'; + } + + DrawTextW(canvas.getHDC(), ptr, -1, &r, align | DT_NOPREFIX | DT_PATH_ELLIPSIS | DT_SINGLELINE); + restoreCanvas(&canvas, c, w, h, color, bkcolor, antialiased); + + FREE(ptr); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Win32::textOutCentered(ifc_canvas *c, RECT *r, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialiased) +{ + yoffset += 1; + ASSERT(r != NULL); + ASSERT(txt != NULL); + RECT rr = *r; + rr.left += xoffset; + rr.right += xoffset; + rr.top += yoffset; + rr.bottom += yoffset; + + int w = rr.right - rr.left; + int h = rr.bottom - rr.top; + + RECT r2 = {0, 0, w, h}; + + BltCanvas canvas; + prepareCanvas(&canvas, size, bold, opaque, underline, italic, antialiased); + canvas.DestructiveResize(w, h); + + DrawTextW(canvas.getHDC(), txt, -1, &r2, align | DT_CENTER | /*DT_VCENTER | */DT_NOPREFIX | DT_WORDBREAK | DT_SINGLELINE); + + restoreCanvas(&canvas, c, w, h, color, bkcolor, antialiased, rr.left, rr.top); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +int TrueTypeFont_Win32::getTextWidth(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialiased) +{ + int w = 0; + getTextExtent(c, text, &w, NULL, size, bold, underline, italic, antialiased); + return w; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +int TrueTypeFont_Win32::getTextHeight(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialiased) +{ + int h = 0; + getTextExtent(c, text, NULL, &h, size, bold, underline, italic, antialiased); + { + // calcul for multiline text + const wchar_t *p = text; + int n = 0; + while (p && *p != 0) if (*p++ == '\n') n++; + if (n) h *= (n + 1); + } + return h ; +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +void TrueTypeFont_Win32::getTextExtent(ifc_canvas *c, const wchar_t *txt, int *w, int *h, int size, int bold, int underline, int italic, int antialiased) +{ + SIZE rsize = {0, 0}; + ASSERT(txt != NULL); + if (*txt == 0) + { + if (w != NULL) *w = 0; + if (h != NULL) *h = 0; + return ; + } + + HFONT newFont = MakeFont(size, bold, underline, italic, antialiased); + HFONT theOldFont = (HFONT)SelectObject(c->getHDC(), newFont); + GetTextExtentPoint32W(c->getHDC(), txt, wcslen(txt), &rsize); + + SelectObject(c->getHDC(), theOldFont); + DeleteObject(newFont); + + if (w != NULL) *w = rsize.cx + VERTICAL_LPADDING + VERTICAL_RPADDING; + if (h != NULL) *h = rsize.cy + VERTICAL_TPADDING + VERTICAL_BPADDING; + +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +int TrueTypeFont_Win32::getTextHeight2(ifc_canvas *c, int size, int bold, int underline, int italic, int antialiased) +{ + return getTextHeight(c, L"Mg", size, bold, underline, italic, antialiased); +} + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------- +// code from ftp.microsoft.com/Softlib/MSLFILES/FONTINST.EXE +// retrieves the friendly font name from its filename +wchar_t *TrueTypeFont_Win32::filenameToFontFace(const wchar_t *pszFile) +{ + static wchar_t lpszLongName[256]; + unsigned i; + char namebuf[255] = {0}; + int fp; + unsigned short numNames; + long curseek; + unsigned cTables; + sfnt_OffsetTable OffsetTable; + sfnt_DirectoryEntry Table; + sfnt_NamingTable NamingTable; + sfnt_NameRecord NameRecord; + + + lpszLongName[0] = '\0'; + if ((fp = _wopen(pszFile, O_RDONLY | O_BINARY)) == -1) + return NULL; + + /* First off, read the initial directory header on the TTF. We're only + * interested in the "numOffsets" variable to tell us how many tables + * are present in this file. + * + * Remember to always convert from Motorola format (Big Endian to + * Little Endian). + */ + _read(fp, &OffsetTable, sizeof(OffsetTable) - sizeof + (sfnt_DirectoryEntry)); + cTables = (int) SWAPW(OffsetTable.numOffsets); + + for (i = 0; i < cTables && i < 40; i++) + { + if ((read(fp, &Table, sizeof(Table))) != sizeof(Table)) return NULL; + if (Table.tag == tag_NamingTable) /* defined in sfnt_en.h */ { + /* Now that we've found the entry for the name table, seek to that * position in the file and read in the initial header for this * particular table. See "True Type Font Files" for information * on this record layout. + */ + lseek(fp, SWAPL(Table.offset), SEEK_SET); + read(fp, &NamingTable, sizeof(NamingTable)); + numNames = SWAPW(NamingTable.count); + while (numNames--) + { + read(fp, &NameRecord, sizeof(NameRecord)); + curseek = tell(fp); + if (SWAPW(NameRecord.platformID) == 1 && + SWAPW(NameRecord.nameID) == 4) + { + lseek(fp, SWAPW(NameRecord.offset) + + SWAPW(NamingTable.stringOffset) + + SWAPL(Table.offset), SEEK_SET); + read(fp, &namebuf, MIN(255, (int)SWAPW(NameRecord.length))); + namebuf[MIN(255, (int)SWAPW(NameRecord.length))] = '\0'; + MultiByteToWideCharSZ(1252, 0, namebuf, -1, lpszLongName, 256); // TODO: benski> what codepage is TTF using internally? + //CUT: lstrcpy(lpszLongName, namebuf); + lseek(fp, curseek, SEEK_SET); + } + } + close(fp); + return lpszLongName; + } + } + close(fp); + + return NULL; +} + + +/* +TODO: +in order to do anti-aliased stuff, we need to draw onto a Compatible Bitmap, and then get the DIB bits out +we might also be able to create a Compatible HBITMAP and then pass it as the constructor parameter to SkinBitmap + +sample code: +void RenderFont(int x, int y, int size, char *str, char *fontname, + void *buf, int w, int h) + { + + HDC hdc=GetDC(NULL); + HDC mdc = CreateCompatibleDC(hdc); + HBITMAP bm = CreateCompatibleBitmap(hdc,w,h); + + HFONT hf=CreateFont(size, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, + ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, + ANTIALIASED_QUALITY, DEFAULT_PITCH, fontname); + + RECT r; + r.top=0; + r.left=0; + r.right=w; + r.bottom=h; + + SelectObject(mdc, bm); + FillRect(mdc, &r, (HBRUSH)GetStockObject(BLACK_BRUSH)); + + SelectObject(mdc, hf); + SetBkMode(mdc, TRANSPARENT); + SetTextColor(mdc, 0xFFFFFF); + TextOut(mdc, 0, 0, str, strlen(str)); + + BITMAPINFO bmi; + + bmi.bmiHeader.biSize=sizeof(bmi.bmiHeader); + bmi.bmiHeader.biWidth=256; + bmi.bmiHeader.biHeight=256; + bmi.bmiHeader.biPlanes=1; + bmi.bmiHeader.biBitCount=32; + bmi.bmiHeader.biCompression=BI_RGB; + + GetDIBits(mdc,bm,0,256,buf,&bmi,DIB_RGB_COLORS); + + DeleteObject(hf); + DeleteObject(bm); +} +*/ \ No newline at end of file diff --git a/Src/Wasabi/api/font/win32/truetypefont_win32.h b/Src/Wasabi/api/font/win32/truetypefont_win32.h new file mode 100644 index 00000000..e8afff21 --- /dev/null +++ b/Src/Wasabi/api/font/win32/truetypefont_win32.h @@ -0,0 +1,61 @@ +#ifndef __TRUETYPEFONT_WN32_H +#define __TRUETYPEFONT_WN32_H + +#include + +#include +#include +#include +class ifc_canvas; +class BltCanvas; + +class TrueTypeFont_Win32 : public svc_fontI { + public: + TrueTypeFont_Win32(); + virtual ~TrueTypeFont_Win32(); + + virtual void textOut(ifc_canvas *c, int x, int y, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialias); + virtual void textOut2(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialias); + virtual void textOutEllipsed(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialias); + virtual void textOutWrapped(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialias); + virtual void textOutWrappedPathed(ifc_canvas *c, int x, int y, int w, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialias); + virtual void textOutCentered(ifc_canvas *c, RECT *r, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, COLORREF color, COLORREF bkcolor, int xoffset, int yoffset, int antialias); + virtual int getTextWidth(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialias); + virtual int getTextHeight(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialias); + virtual int getTextHeight2(ifc_canvas *c, int size, int bold, int underline, int italic, int antialias); + virtual void getTextExtent(ifc_canvas *c, const wchar_t *text, int *w, int *h, int size, int bold, int underline, int italic, int antialias); + + virtual void setFontId(const wchar_t *id) { font_id = id; } + virtual const wchar_t *getFontId() { return font_id; } + virtual int getScriptId() { return scriptid; } + virtual void setScriptId(int id) { scriptid = id; } + + virtual int isBitmap(); + virtual void setFontFace(const wchar_t *face); + virtual int addFontResource(OSFILETYPE f, const wchar_t *name); + virtual int addFontResource2( void *data, int datalen, const wchar_t *name ); + virtual const wchar_t *getFaceName(); + + virtual const wchar_t *getFontSvcName() { return L"Win32 TextOut"; } + static const char *getServiceName() { return "Win32 Truetype font renderer"; } + + static wchar_t *filenameToFontFace(const wchar_t *filename); + + protected: + void prepareCanvas(BltCanvas *canvas, int size, int bold, int opaque, int underline, int italic, int antialiased); + void restoreCanvas(BltCanvas *canvas, ifc_canvas *dest, int w, int h, COLORREF color, COLORREF bkcolor, int antialiased, int x=0, int y=0); + HFONT MakeFont(int size, int bold, int underline, int italic, int antialiased); + + protected: + StringW font_id; + int scriptid; + + private: + StringW face_name; + StringW tmpfilename; + + HFONT font, oldFont; + +}; + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/imgldr/ImgLoaderEnum.h b/Src/Wasabi/api/imgldr/ImgLoaderEnum.h new file mode 100644 index 00000000..e71f4c4d --- /dev/null +++ b/Src/Wasabi/api/imgldr/ImgLoaderEnum.h @@ -0,0 +1,24 @@ +#ifndef __WASABI_IMGLOADERENUM_H +#define __WASABI_IMGLOADERENUM_H + +#include +#include + +class ImgLoaderEnum : public SvcEnumT { +public: + ImgLoaderEnum(uint8_t *data, int datalen) : mem(datalen, data) { } + ImgLoaderEnum(const wchar_t *filename) : fname(filename) { } + +protected: + virtual int testService(svc_imageLoader *svc) + { + if (!fname.isempty() && !svc->isMine(fname)) return 0; + return svc->testData(mem, mem.getSizeInBytes()); + } + +private: + StringW fname; + MemBlock mem; +}; + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/imgldr/api_imgldr.cpp b/Src/Wasabi/api/imgldr/api_imgldr.cpp new file mode 100644 index 00000000..20d03bcf --- /dev/null +++ b/Src/Wasabi/api/imgldr/api_imgldr.cpp @@ -0,0 +1,20 @@ +#include +#include "api_imgldr.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif +#define CBCLASS imgldr_apiI +START_DISPATCH; + CB(IMGLDR_API_MAKEBMP, imgldr_makeBmp); +#ifdef _WIN32 + CB(IMGLDR_API_MAKEBMP2, imgldr_makeBmp2); +#endif + VCB(IMGLDR_API_RELEASEBMP, imgldr_releaseBmp); +#ifdef WASABI_COMPILE_SKIN + CB(IMGLDR_API_REQUESTSKINBITMAP, imgldr_requestSkinBitmap); + CB(IMGLDR_API_REQUESTSKINREGION, imgldr_requestSkinRegion); + VCB(IMGLDR_API_CACHESKINREGION, imgldr_cacheSkinRegion); + VCB(IMGLDR_API_RELEASESKINBITMAP, imgldr_releaseSkinBitmap); +#endif //WASABI_COMPILE_SKIN +END_DISPATCH; diff --git a/Src/Wasabi/api/imgldr/api_imgldr.h b/Src/Wasabi/api/imgldr/api_imgldr.h new file mode 100644 index 00000000..55e19bec --- /dev/null +++ b/Src/Wasabi/api/imgldr/api_imgldr.h @@ -0,0 +1,98 @@ +#ifndef __API_IMGLOADER_H +#define __API_IMGLOADER_H + +#include +#include + +class RegionServer; +class api_region; + +class imgldr_api : public Dispatchable +{ +public: + ARGB32 *imgldr_makeBmp(const wchar_t *filename, int *has_alpha, int *w, int *h); + ARGB32 *imgldr_makeBmp(OSMODULEHANDLE hInst, int id, int *has_alpha, int *w, int *h, const wchar_t *colorgroup = NULL); + void imgldr_releaseBmp(ARGB32 *bmpbits); + ARGB32 *imgldr_requestSkinBitmap(const wchar_t *file, int *has_alpha, int *x, int *y, int *subw, int *subh, int *w, int *h, int cached); + RegionServer *imgldr_requestSkinRegion(const wchar_t *id); + void imgldr_cacheSkinRegion(const wchar_t *id, api_region *r); + void imgldr_releaseSkinBitmap(ARGB32 *bmpbits); + + DISPATCH_CODES + { + IMGLDR_API_MAKEBMP = 0, + IMGLDR_API_MAKEBMP2 = 10, + IMGLDR_API_RELEASEBMP = 20, + IMGLDR_API_REQUESTSKINBITMAP = 30, + IMGLDR_API_REQUESTSKINREGION = 40, + IMGLDR_API_CACHESKINREGION = 50, + IMGLDR_API_RELEASESKINBITMAP = 60, + }; +}; + +inline ARGB32 *imgldr_api::imgldr_makeBmp(const wchar_t *filename, int *has_alpha, int *w, int *h) +{ + return _call(IMGLDR_API_MAKEBMP, (ARGB32 *)NULL, filename, has_alpha, w, h); +} + +inline ARGB32 *imgldr_api::imgldr_makeBmp(OSMODULEHANDLE hInst, int id, int *has_alpha, int *w, int *h, const wchar_t *colorgroup) +{ + return _call(IMGLDR_API_MAKEBMP2, (ARGB32 *)NULL, hInst, id, has_alpha, w, h, colorgroup); +} + +inline void imgldr_api::imgldr_releaseBmp(ARGB32 *bmpbits) +{ + _voidcall(IMGLDR_API_RELEASEBMP, bmpbits); +} + +#ifdef WASABI_COMPILE_SKIN + +inline ARGB32 *imgldr_api::imgldr_requestSkinBitmap(const wchar_t *file, int *has_alpha, int *x, int *y, int *subw, int *subh, int *w, int *h, int cached) +{ + return _call(IMGLDR_API_REQUESTSKINBITMAP, (ARGB32 *)NULL, file, has_alpha, x, y, subw, subh, w, h, cached); +} + +inline RegionServer *imgldr_api::imgldr_requestSkinRegion(const wchar_t *id) +{ + return _call(IMGLDR_API_REQUESTSKINREGION, (RegionServer *)NULL, id); +} + +inline void imgldr_api::imgldr_cacheSkinRegion(const wchar_t *id, api_region *r) +{ + _voidcall(IMGLDR_API_CACHESKINREGION, id, r); +} + +inline void imgldr_api::imgldr_releaseSkinBitmap(ARGB32 *bmpbits) +{ + _voidcall(IMGLDR_API_RELEASESKINBITMAP, bmpbits); +} + +#endif //WASABI_COMPILE_SKIN + +class imgldr_apiI : public imgldr_api +{ +public: + virtual ARGB32 *imgldr_makeBmp(const wchar_t *filename, int *has_alpha, int *w, int *h) = 0; +#ifdef _WIN32 + virtual ARGB32 *imgldr_makeBmp2(OSMODULEHANDLE hInst, int id, int *has_alpha, int *w, int *h, const wchar_t *colorgroup = NULL) = 0; +#endif + virtual void imgldr_releaseBmp(ARGB32 *bmpbits) = 0; +#ifdef WASABI_COMPILE_SKIN + virtual ARGB32 *imgldr_requestSkinBitmap(const wchar_t *file, int *has_alpha, int *x, int *y, int *subw, int *subh, int *w, int *h, int cached) = 0; + virtual RegionServer *imgldr_requestSkinRegion(const wchar_t *id) = 0; + virtual void imgldr_cacheSkinRegion(const wchar_t *id, api_region *r) = 0; + virtual void imgldr_releaseSkinBitmap(ARGB32 *bmpbits) = 0; +#endif //WASABI_COMPILE_SKIN + +protected: + RECVS_DISPATCH; +}; + +// {703ECC7C-B3D8-4e1e-B8B5-A7563D9D6F30} +static const GUID imgLdrApiServiceGuid = + { 0x703ecc7c, 0xb3d8, 0x4e1e, { 0xb8, 0xb5, 0xa7, 0x56, 0x3d, 0x9d, 0x6f, 0x30 } }; + +extern imgldr_api *imgLoaderApi; + + +#endif diff --git a/Src/Wasabi/api/imgldr/imggen/grad.cpp b/Src/Wasabi/api/imgldr/imggen/grad.cpp new file mode 100644 index 00000000..acec2eab --- /dev/null +++ b/Src/Wasabi/api/imgldr/imggen/grad.cpp @@ -0,0 +1,60 @@ +#include "precomp.h" + +#include "grad.h" + +#include +#include +#ifndef _WASABIRUNTIME + +BEGIN_SERVICES(GradientGen_Svc); +DECLARE_SERVICETSINGLE(svc_imageGenerator, GradientImage); +END_SERVICES(GradientGen_Svc, _GradientGen_Svc); + +#ifdef _X86_ +extern "C" { int _link_GradientGen_Svc; } +#else +extern "C" { int __link_GradientGen_Svc; } +#endif + +#endif + + +int GradientImage::testDesc(const wchar_t *desc) { + return !_wcsicmp(desc, L"$gradient"); +} + +ARGB32 *GradientImage::genImage(const wchar_t *desc, int *has_alpha, int *w, int *h, ifc_xmlreaderparams *params) +{ + int _w = params->getItemValueInt(L"w",1); + if (_w == 0) _w = 1; + int _h = params->getItemValueInt(L"h",1); + if (_h == 0) _h = 1; + if (_w <= 0 || _h <= 0) return NULL; + +#ifdef WASABI_COMPILE_MEMMGR + ARGB32 *ret = (ARGB32*)WASABI_API_MEMMGR->sysMalloc(_w * _h * sizeof(ARGB32)); +#else + ARGB32 *ret = (ARGB32*)MALLOC(_w * _h * sizeof(ARGB32)); +#endif + + setX1((float)WTOF(params->getItemValue(L"gradient_x1"))); + setY1((float)WTOF(params->getItemValue(L"gradient_y1"))); + setX2((float)WTOF(params->getItemValue(L"gradient_x2"))); + setY2((float)WTOF(params->getItemValue(L"gradient_y2"))); + + setPoints(params->getItemValue(L"points")); + + setMode(params->getItemValue(L"mode")); + + setReverseColors(TRUE); // cuz we're imggen + + setAntialias(params->getItemValueInt(L"antialias")); + + renderGradient(ret, _w, _h); + + *w = _w; + *h = _h; + *has_alpha = 1; // will be optimized anyway + + return ret; +} diff --git a/Src/Wasabi/api/imgldr/imggen/grad.h b/Src/Wasabi/api/imgldr/imggen/grad.h new file mode 100644 index 00000000..8ee4c886 --- /dev/null +++ b/Src/Wasabi/api/imgldr/imggen/grad.h @@ -0,0 +1,15 @@ +#ifndef _GRAD_H +#define _GRAD_H + +#include +#include + +class GradientImage : public svc_imageGeneratorI, public Gradient +{ +public: + static const char *getServiceName() { return "Gradient image generator"; } + virtual int testDesc(const wchar_t *desc); + virtual ARGB32 *genImage(const wchar_t *desc, int *has_alpha, int *w, int *h, ifc_xmlreaderparams *params=NULL); +}; + +#endif diff --git a/Src/Wasabi/api/imgldr/imggen/imggen.cpp b/Src/Wasabi/api/imgldr/imggen/imggen.cpp new file mode 100644 index 00000000..bcf0b6d4 --- /dev/null +++ b/Src/Wasabi/api/imgldr/imggen/imggen.cpp @@ -0,0 +1,29 @@ +#include "precomp.h" +#include "imggen.h" + +#include "solid.h" +#include "grad.h" +#include "osedge.h" +#include "poly.h" +#include "shadowwnd.h" + +#include "../studio/services/servicei.h" + +static WACNAME wac; +WAComponentClient *the = &wac; + +// {9C9CB15E-2904-4df2-B8CE-FFBC6CD230DC} +static const GUID guid = +{ 0x9c9cb15e, 0x2904, 0x4df2, { 0xb8, 0xce, 0xff, 0xbc, 0x6c, 0xd2, 0x30, 0xdc } }; + +WACNAME::WACNAME() { + registerService(new waServiceFactoryTSingle); + registerService(new waServiceFactoryTSingle); + registerService(new waServiceFactoryTSingle); + registerService(new waServiceFactoryTSingle); + registerService(new XuiObjectCreator); +} + +GUID WACNAME::getGUID() { + return guid; +} diff --git a/Src/Wasabi/api/imgldr/imggen/imggen.h b/Src/Wasabi/api/imgldr/imggen/imggen.h new file mode 100644 index 00000000..9af473d5 --- /dev/null +++ b/Src/Wasabi/api/imgldr/imggen/imggen.h @@ -0,0 +1,14 @@ +#ifndef _IMGGEN_H +#define _IMGGEN_H + +#include "../studio/wac.h" + +#define WACNAME WACimggen +class WACNAME : public WAComponentClient { +public: + WACNAME(); + + virtual const char *getName() { return "Standard Image Generators"; }; + virtual GUID getGUID(); +}; +#endif diff --git a/Src/Wasabi/api/imgldr/imggen/osedge.cpp b/Src/Wasabi/api/imgldr/imggen/osedge.cpp new file mode 100644 index 00000000..c699a860 --- /dev/null +++ b/Src/Wasabi/api/imgldr/imggen/osedge.cpp @@ -0,0 +1,95 @@ +#include "precomp.h" + +#include "osedge.h" +#include +#include +#include +#ifndef _WASABIRUNTIME + +BEGIN_SERVICES(OsEdgeGen_Svc); +DECLARE_SERVICETSINGLE(svc_imageGenerator, OsEdgeImage); +END_SERVICES(OsEdgeGen_Svc, _OsEdgeGen_Svc); + +#ifdef _X86_ +extern "C" { int _link_OsEdgeGen_Svc; } +#else +extern "C" { int __link_OsEdgeGen_Svc; } +#endif + +#endif + + +int OsEdgeImage::testDesc(const wchar_t *desc) { + return !_wcsicmp(desc, L"$osedge"); +} + +ARGB32 *OsEdgeImage::genImage(const wchar_t *desc, int *has_alpha, int *w, int *h, ifc_xmlreaderparams *params) +{ + int _w = params->getItemValueInt(L"w", 1); + if (_w == 0) _w = 1; + int _h = params->getItemValueInt(L"h", 1); + if (_h == 0) _h = 1; + if (_w <= 0 || _h <= 0) return NULL; + +#ifdef WASABI_COMPILE_MEMMGR + ARGB32 *ret = (ARGB32*)WASABI_API_MEMMGR->sysMalloc(_w * _h * sizeof(ARGB32)); +#else + ARGB32 *ret = (ARGB32*)MALLOC(_w * _h * sizeof(ARGB32)); +#endif + + RECT r = Wasabi::Std::makeRect(0, 0, _w, _h); + + BITMAPINFO bmi; + ZERO(bmi); + bmi.bmiHeader.biSize = sizeof(bmi); + bmi.bmiHeader.biWidth = _w; + bmi.bmiHeader.biHeight = -_h; + bmi.bmiHeader.biPlanes = 1; + bmi.bmiHeader.biBitCount = 32; + bmi.bmiHeader.biCompression = BI_RGB; + // the rest are 0 + ARGB32 *bits; + HBITMAP hbmp = CreateDIBSection(NULL, &bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0); + HDC hdc = CreateCompatibleDC(NULL); + HBITMAP prevbmp = (HBITMAP)SelectObject(hdc, hbmp); + + unsigned long edgev = 0; + if (!_wcsicmp(params->getItemValue(L"edge"), L"bump")) edgev = EDGE_BUMP; + else if (!_wcsicmp(params->getItemValue(L"edge"), L"etched")) edgev = EDGE_ETCHED; + else if (!_wcsicmp(params->getItemValue(L"edge"), L"raised")) edgev = EDGE_RAISED; + else if (!_wcsicmp(params->getItemValue(L"edge"), L"sunken")) edgev = EDGE_SUNKEN; + if (edgev == 0) edgev = EDGE_RAISED; + + unsigned long sides = 0; + PathParserW pp(params->getItemValue(L"sides"), L","); + for (int i = 0; i < pp.getNumStrings(); i++) { + const wchar_t *p = pp.enumString(i); + if (!_wcsicmp(p, L"left")) sides |= BF_LEFT; + if (!_wcsicmp(p, L"top")) sides |= BF_TOP; + if (!_wcsicmp(p, L"right")) sides |= BF_RIGHT; + if (!_wcsicmp(p, L"bottom")) sides |= BF_BOTTOM; + if (!_wcsicmp(p, L"all")) sides |= BF_RECT; + if (!_wcsicmp(p, L"middle")) sides |= BF_MIDDLE; + if (!_wcsicmp(p, L"flat")) sides |= BF_FLAT; + if (!_wcsicmp(p, L"soft")) sides |= BF_SOFT; + if (!_wcsicmp(p, L"mono")) sides |= BF_MONO; + } + +// DO EET + DrawEdge(hdc, &r, edgev, sides); + + MEMCPY(ret, bits, sizeof(ARGB32) * _w * _h); + for (int i = 0; i < _w * _h; i++) { // force alpha + ret[i] |= 0xff000000; + } + + SelectObject(hdc, prevbmp); + DeleteDC(hdc); + DeleteObject(hbmp); + + *w = _w; + *h = _h; + *has_alpha = 1; // will be optimized anyway + + return ret; +} diff --git a/Src/Wasabi/api/imgldr/imggen/osedge.h b/Src/Wasabi/api/imgldr/imggen/osedge.h new file mode 100644 index 00000000..f00771a1 --- /dev/null +++ b/Src/Wasabi/api/imgldr/imggen/osedge.h @@ -0,0 +1,13 @@ +#ifndef _OSEDGE_H +#define _OSEDGE_H + +#include + +class OsEdgeImage : public svc_imageGeneratorI { +public: + static const char *getServiceName() { return "OS Edge image generator"; } + virtual int testDesc(const wchar_t *desc); + virtual ARGB32 *genImage(const wchar_t *desc, int *has_alpha, int *w, int *h, ifc_xmlreaderparams *params=NULL); +}; + +#endif diff --git a/Src/Wasabi/api/imgldr/imggen/poly.cpp b/Src/Wasabi/api/imgldr/imggen/poly.cpp new file mode 100644 index 00000000..086664e8 --- /dev/null +++ b/Src/Wasabi/api/imgldr/imggen/poly.cpp @@ -0,0 +1,59 @@ +#include "precomp.h" + +#include "poly.h" + +#include +#include +#ifndef _WASABIRUNTIME + +BEGIN_SERVICES(PolyGen_Svc); +DECLARE_SERVICETSINGLE(svc_imageGenerator, PolyImage); +END_SERVICES(PolyGen_Svc, _PolyGen_Svc); + +#ifdef _X86_ +extern "C" { int _link_PolyGen_Svc; } +#else +extern "C" { int __link_PolyGen_Svc; } +#endif + +#endif + +int PolyImage::testDesc(const wchar_t *desc) { + return !_wcsicmp(desc, L"$polygon"); +} + +void premultiply(ARGB32 *m_pBits, int nwords); + +#include + +ARGB32 *PolyImage::genImage(const wchar_t *desc, int *has_alpha, int *w, int *h, ifc_xmlreaderparams *params) +{ + int _w = (params->getItemValueInt(L"w", 1)); + if (_w == 0) _w = 1; + int _h = (params->getItemValueInt(L"h", 1)); + if (_h == 0) _h = 1; + if (_w <= 0 || _h <= 0) return NULL; + + const wchar_t *bgcolorstr = params->getItemValue(L"bgcolor"); + ARGB32 bgcolor = (bgcolorstr == NULL || *bgcolorstr=='\0') ? 0 : _byteswap_ulong(WASABI_API_SKIN->parse(params->getItemValue(L"bgcolor"), L"color")<<8); + + unsigned int bgalpha = params->getItemValueInt(L"bgalpha", 0); + bgcolor |= ((bgalpha & 0xff) << 24); + + premultiply(&bgcolor, 1); + +#ifdef WASABI_COMPILE_MEMMGR + ARGB32 *ret = (ARGB32*)WASABI_API_MEMMGR->sysMalloc(_w * _h * sizeof(ARGB32)); +#else + ARGB32 *ret = (ARGB32*)MALLOC(_w * _h * sizeof(ARGB32)); +#endif + + MEMFILL(ret, bgcolor, _w * _h); + + Draw::drawPointList(ret, _w, _h, params->getItemValue(L"points")); + + *w = _w; + *h = _h; + *has_alpha = 1; + return ret; +} diff --git a/Src/Wasabi/api/imgldr/imggen/poly.h b/Src/Wasabi/api/imgldr/imggen/poly.h new file mode 100644 index 00000000..07095056 --- /dev/null +++ b/Src/Wasabi/api/imgldr/imggen/poly.h @@ -0,0 +1,13 @@ +#ifndef _POLY_H +#define _POLY_H + +#include + +class PolyImage : public svc_imageGeneratorI { +public: + static const char *getServiceName() { return "Polygon image generator"; } + virtual int testDesc(const wchar_t *desc); + virtual ARGB32 *genImage(const wchar_t *desc, int *has_alpha, int *w, int *h, ifc_xmlreaderparams *params=NULL); +}; + +#endif diff --git a/Src/Wasabi/api/imgldr/imggen/shadowwnd.cpp b/Src/Wasabi/api/imgldr/imggen/shadowwnd.cpp new file mode 100644 index 00000000..fb61c95c --- /dev/null +++ b/Src/Wasabi/api/imgldr/imggen/shadowwnd.cpp @@ -0,0 +1,152 @@ +#include "precomp.h" + +#include "shadowwnd.h" + +#include "../bfc/canvas.h" +#include "../bfc/region.h" + +enum { TARGET }; + +char XuiShadowWndParams[][]= +{ + "TARGET", +}; +XuiShadowWnd::XuiShadowWnd() { + myxuihandle = newXuiHandle(); + addParam(myxuihandle, XuiShadowWndParams[0], TARGET, XUI_ATTRIBUTE_REQUIRED); + group = NULL; + bltcanvas = NULL; + c_w = c_h = 0; + in_paint = 0; +} + +XuiShadowWnd::~XuiShadowWnd() { + delete bltcanvas; +} + +int XuiShadowWnd::onInit() { + XUISHADOWWND_PARENT::onInit(); + +DebugString("on iniiit"); + + attachToGroup(); +setTimer(10, 50); + + return 1; +} + +void XuiShadowWnd::timerclient_timerCallback(int id) { + if (id == 10) { + if (group == NULL) attachToGroup(); + delete bltcanvas; + RECT r; group->getClientRect(&r); + bltcanvas = new BltCanvas(r.right - r.left, r.bottom - r.top); + in_paint++; + group->paint(bltcanvas); +MEMFILL((unsigned long *)bltcanvas->getBits(), 0xffffffff, (r.right - r.left) * 20); + in_paint--; + invalidate(); + } else + XUISHADOWWND_PARENT::timerclient_timerCallback(id); +} + +int XuiShadowWnd::onPaint(Canvas *canvas) { +#if 0 +if (group == NULL) attachToGroup(); +if (group == NULL) { DebugString("groupNull"); } +if (group == NULL) return 0; + +#endif +DebugString("begin painting"); + +if (in_paint++) { +// RECT cr = clientRect(); +// canvas->fillRect(&cr, RGB(255,0,255)); +//MEMFILL((unsigned long *)canvas->getBits(), 0xffffffff, (cr.right - cr.left) * 20); +DebugString("filla!"); +} else { +#if 0 + RECT cr; + group->getClientRect(&cr); + SkinBitmap *bm +bltcanvas->blit(0, 0, +BltCanvas c(cr.right - cr.left, cr.bottom - cr.top); +group->paint(&c); +#if 0 +c.pushPen(0,255,0); +c.lineDraw(0, 0, cr.right, cr.bottom); +/c.popPen(); +#endif +MEMFILL((unsigned long *)c.getBits(), 0xffffffff, (cr.right - cr.left) * 20); +c.blit(0, 0, canvas, 0, 0, cr.right - cr.left, cr.bottom - cr.top); + +DebugString("get from group!"); +#endif + if (bltcanvas != NULL) { + SkinBitmap *bm = bltcanvas->getSkinBitmap(); + bm->stretchToRectAlpha(canvas, &clientRect(), getPaintingAlpha()); +DebugString("bleet!"); + } +} +in_paint--; + return 1; +} + +int XuiShadowWnd::setXuiParam(int xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *value) { + if (xuihandle != myxuihandle) + return XUISHADOWWND_PARENT::setXuiParam(xuihandle, xmlattributeid, xmlattributename, value); + switch (xmlattributeid) { + case TARGET: + targetname = value; +DebugString("set target %s", value); + if (isPostOnInit()) attachToGroup(); + break; + default: return 0; + } + return 1; +} + +void XuiShadowWnd::attachToGroup() { + if (targetname.isempty()) return; + group = findWindow(targetname); + if (group == NULL) return; + monitorWindow(group); +DebugString("attached to group rw %d", group); + + delete bltcanvas; bltcanvas = NULL; +} + +void XuiShadowWnd::onAfterPaint(PaintCallbackInfo *info) { +DebugString("after paint"); +#if 0 + RECT ncr; + group->getNonClientRect(&ncr); + c_w = ncr.right - ncr.left; + c_h = ncr.bottom - ncr.top; + +DebugString("w %d h %d", c_w, c_h); + + delete bltcanvas; bltcanvas = NULL; + if (c_w != 0 && c_h != 0) bltcanvas = new BltCanvas(c_w, c_h); + + Canvas *c = info->getCanvas(); + api_region *r = info->getRegion(); + // blit what changed + RegionI saved; + c->getClipRgn(&saved); + bltcanvas->selectClipRgn(r); + c->blit(0, 0, bltcanvas, 0, 0, c_w, c_h); + c->selectClipRgn(&saved); + + invalidate(); +#endif +} + +void XuiShadowWnd::onInvalidation(PaintCallbackInfo *info) { +// invalidate(); +DebugString("got invalidate"); +} + +void XuiShadowWnd::onWindowDeleted(api_window *w) { + if (w == group) group = NULL; +} diff --git a/Src/Wasabi/api/imgldr/imggen/shadowwnd.h b/Src/Wasabi/api/imgldr/imggen/shadowwnd.h new file mode 100644 index 00000000..8082dba5 --- /dev/null +++ b/Src/Wasabi/api/imgldr/imggen/shadowwnd.h @@ -0,0 +1,40 @@ +#ifndef _SHADOW_H +#define _SHADOW_H + +#include "../common/guiobjwnd.h" +#include "../bfc/paintcb.h" + +#define XUISHADOWWND_PARENT GuiObjectWnd +class XuiShadowWnd : public XUISHADOWWND_PARENT, public PaintCallback { +public: + static const wchar_t *xuiobject_getXmlTag() { return "Shadow"; } + static const char *xuiobject_getServiceName() { return "Shadow XuiObject"; } + + XuiShadowWnd(); + virtual ~XuiShadowWnd(); + + virtual int onInit(); + + virtual int onPaint(Canvas *canvas); + + virtual int setXuiParam(int xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *value); + + virtual void onAfterPaint(PaintCallbackInfo *info); + virtual void onInvalidation(PaintCallbackInfo *info); +protected: + virtual void onWindowDeleted(BaseWnd *w); + void attachToGroup(); + virtual void timerclient_timerCallback(int id); + +private: + int myxuihandle; + StringW targetname; + api_window *group; + BltCanvas *bltcanvas; + int c_w, c_h; + int in_paint; +}; + +class XuiShadowWndSvc : public XuiObjectSvc2 {}; + +#endif diff --git a/Src/Wasabi/api/imgldr/imggen/solid.cpp b/Src/Wasabi/api/imgldr/imggen/solid.cpp new file mode 100644 index 00000000..7f461eaa --- /dev/null +++ b/Src/Wasabi/api/imgldr/imggen/solid.cpp @@ -0,0 +1,67 @@ +#include "precomp.h" + +#include "solid.h" +#include +#include + +#ifndef _WASABIRUNTIME + +BEGIN_SERVICES(SolidGen_Svc); +DECLARE_SERVICETSINGLE(svc_imageGenerator, SolidImage); +END_SERVICES(SolidGen_Svc, _SolidGen_Svc); + +#ifdef _X86_ +extern "C" { int _link_SolidGen_Svc; } +#else +extern "C" { int __link_SolidGen_Svc; } +#endif + +#endif + +int SolidImage::testDesc(const wchar_t *desc) +{ + return !WCSICMP(desc, L"$solid"); +} + +void premultiply(ARGB32 *m_pBits, int nwords) +{ + for (; nwords > 0; nwords--, m_pBits++) + { + unsigned __int8 *pixel = (unsigned __int8 *)m_pBits; + unsigned int alpha = pixel[3]; + if (alpha == 255) continue; + pixel[0] = (pixel[0] * alpha) >> 8; // blue + pixel[1] = (pixel[1] * alpha) >> 8; // green + pixel[2] = (pixel[2] * alpha) >> 8; // red + } +} + +ARGB32 *SolidImage::genImage(const wchar_t *desc, int *has_alpha, int *w, int *h, ifc_xmlreaderparams *params) +{ + int _w = params->getItemValueInt(L"w", 1); + if (_w == 0) _w = 1; + int _h = params->getItemValueInt(L"h", 1); + if (_h == 0) _h = 1; + if (_w <= 0 || _h <= 0) return NULL; + ARGB32 color = _byteswap_ulong(WASABI_API_SKIN->parse(params->getItemValue(L"color"), L"color") << 8); + + unsigned int alpha = params->getItemValueInt(L"alpha", 255); + color |= ((alpha & 0xff) << 24); + + premultiply(&color, 1); + +#ifdef WASABI_COMPILE_MEMMGR + ARGB32 *ret = (ARGB32*)WASABI_API_MEMMGR->sysMalloc(_w * _h * sizeof(ARGB32)); +#else + ARGB32 *ret = (ARGB32*)MALLOC(_w * _h * sizeof(ARGB32)); +#endif + + MEMFILL(ret, color, _w * _h); + + *w = _w; + *h = _h; + + *has_alpha = (alpha == 255) ? 0 : 1; + + return ret; +} diff --git a/Src/Wasabi/api/imgldr/imggen/solid.h b/Src/Wasabi/api/imgldr/imggen/solid.h new file mode 100644 index 00000000..d810bc1c --- /dev/null +++ b/Src/Wasabi/api/imgldr/imggen/solid.h @@ -0,0 +1,14 @@ +#ifndef _SOLID_H +#define _SOLID_H + +#include + +class SolidImage : public svc_imageGeneratorI +{ +public: + static const char *getServiceName() { return "Solid Color image generator"; } + virtual int testDesc(const wchar_t *desc); + virtual ARGB32 *genImage(const wchar_t *desc, int *has_alpha, int *w, int *h, ifc_xmlreaderparams *params = NULL); +}; + +#endif diff --git a/Src/Wasabi/api/imgldr/imgldr.cpp b/Src/Wasabi/api/imgldr/imgldr.cpp new file mode 100644 index 00000000..d7e33b54 --- /dev/null +++ b/Src/Wasabi/api/imgldr/imgldr.cpp @@ -0,0 +1,554 @@ +#include +#include +#include +#include + +#include +#include +#include // ApplySkinFilters + +#include "imgldr.h" +#ifdef _WIN32 +#include +#endif +#include + +#include +#include +#include + +#include +#include +#include +#include "ImgLoaderEnum.h" +#include +#include +#include + +//#define DEBUG_OUTPUT + +#define IMAGEHEADERLEN 256 + +#ifdef _WIN32 +ARGB32 *imageLoader::makeBmp(OSMODULEHANDLE hInst, int id, int *has_alpha, int *w, int *h, const wchar_t *forcegroup) +{ + ARGB32 *bits = makeBmp(StringPrintfW(L"res://%u,%i", hInst, id), NULL, has_alpha, w, h, NULL, TRUE, NULL); + if (bits && *w > 0 && *h > 0) + { + ApplySkinFilters::apply(StringPrintfW(L"resource:%x,%d", hInst, id), forcegroup, bits, *w, *h); + } + return bits; +} +#endif + +StringW imageLoader::getWallpaper() +{ + StringW ret(L""); +#ifdef WIN32 + HKEY hkey; + static wchar_t file[MAX_PATH]; + file[0] = 0; + if (RegOpenKey(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), &hkey) == ERROR_SUCCESS) + { + unsigned long len = MAX_PATH; + RegQueryValueExW(hkey, L"Wallpaper", 0, NULL, (unsigned char *)&file, &len); + RegCloseKey(hkey); + } + if (file[0] && GetFileAttributesW(file) != (DWORD) - 1) ret = file; +#endif + return ret; +} +extern StringW g_resourcepath; + +ARGB32 *imageLoader::makeBmp(const wchar_t *_filename, const wchar_t *path, int *has_alpha, int *w, int *h, ifc_xmlreaderparams *params, bool addMem, int *force_nocache) +{ + if (!_filename || !*_filename) + return 0; + + + ARGB32 *ret = NULL; + + if (has_alpha != NULL) + *has_alpha = 0; //BU + + // test image generator services FIRST + ImgGeneratorEnum ige(_filename); + svc_imageGenerator *gen; + while ((gen = ige.getNext()) != NULL) + { + ret = gen->genImage(_filename, has_alpha, w, h, params); + int cacheable = gen->outputCacheable(); + ige.release(gen); + if (ret != NULL) + { + ApplySkinFilters::apply(params->getItemValue(L"id"), params->getItemValue(L"gammagroup"), ret, *w, *h); + if (addMem) addMemUsage(_filename, (*w) * (*h) * sizeof(int)); + optimizeHasAlpha(ret, *w * *h, has_alpha); + // don't try to cache generated images + if (force_nocache) *force_nocache = !cacheable; + return ret; + } + } + + StringW wallpaper; + if (!WCSICMP(_filename, L"$wallpaper")) + { + wallpaper = getWallpaper(); + _filename = wallpaper.getValue(); + } + + MemBlock mem; + + wchar_t olddir[PATH_MAX] = {0}; + Wasabi::Std::getCurDir(olddir, PATH_MAX); + Wasabi::Std::setCurDir(WASABI_API_APP->path_getAppPath()); + + StringW file; + + // benski> try language pack first + StringPathCombine skinLocalePath(LocalesManager::getLocaleRoot(), WASABI_API_SKIN->getSkinName()); + file.swap(StringPathCombine(skinLocalePath, _filename)); + OSFILETYPE in = WFOPEN(file, WF_READONLY_BINARY); + + if (in == OPEN_FAILED) + { + // try the language pack's folder itself before falling back to the resource path + file.swap(StringPathCombine(LocalesManager::getLocaleRoot(), _filename)); + in = WFOPEN(file, WF_READONLY_BINARY); + } + + if (in == OPEN_FAILED) + { + if (path) + { + file.swap(StringPathCombine(path, _filename)); + in = WFOPEN(file, WF_READONLY_BINARY); + } + else + in = WFOPEN(file=_filename, WF_READONLY_BINARY); + } + +#ifdef WASABI_COMPILE_SKIN + if (in == OPEN_FAILED) + { + file.swap(StringPathCombine(WASABI_API_SKIN->getSkinPath(), _filename)); + in = WFOPEN(file, WF_READONLY_BINARY); + } + +#if 0 // this isn't used in gen_ff, basically makes it look in C:/Program Files/Winamp/Skins/Default/ + if (in == OPEN_FAILED) + { + file.swap(StringPathCombine(Skin::getDefaultSkinPath(), _filename)); + in = WFOPEN(file, WF_READONLY_BINARY); + } +#endif + + // look in the fallback stuff (in Winamp5, this is c:/program files/winamp/plugins/freeform/xml) + if (in == OPEN_FAILED) + { + file.swap(StringPathCombine(g_resourcepath, _filename)); + in = WFOPEN(file, WF_READONLY_BINARY); + } +#endif + + if (in == OPEN_FAILED && path) + { + in = WFOPEN(file = _filename, WF_READONLY_BINARY); + } + + Wasabi::Std::setCurDir(olddir); + + if (in != OPEN_FAILED) + { + int filelen = (int)FGETSIZE(in); + if (filelen > 0) + { + mem.setSize(filelen); + int len = FREAD(mem, 1, mem.getSizeInBytes(), in); + if (len == filelen) + { + svc_imageLoader *loader = ImgLoaderEnum(mem, len).getNext(); + if (loader != NULL) + { + ret = loader->loadImage(mem, mem.getSizeInBytes(), w, h, params); + if (ret != NULL) + { + if (addMem) + addMemUsage(file, (*w) * (*h) * sizeof(ARGB32)); + optimizeHasAlpha(ret, *w * *h, has_alpha); + } + SvcEnum::release(loader); + } + } + } // filelen > 0 + FCLOSE(in); + } // if file opened + if (ret != NULL) + { + return ret; + } + else if (in != OPEN_FAILED && mem) + { + int m = getFileType(mem); +#ifdef WIN32 + switch (m) + { + case FT_BMP: + { + wchar_t tmpname[WA_MAX_PATH] = L""; + + // FG> if loading bmp from disk, no need to do the copy to disk + HBITMAP hbmp = (HBITMAP)LoadImageW(0, file, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); + + if (!hbmp) + { + // CT> extract/copy the file into temp directory (so we don't have any trouble if the file + // is in a ZIP file). this whole copying thing will go away as soon as we'll get rid of + // the LoadImage win32 function and use our own bmp loading functions + + GetTempPathW(WA_MAX_PATH, tmpname); + wcscat(tmpname, L"wa3tmp"); + OSFILETYPE fs = WFOPEN(file, WF_READONLY_BINARY); + if (fs != OPEN_FAILED) + { + OSFILETYPE fd = WFOPEN(tmpname, L"wb"); + int l; + do + { + char buf[1024] = {0}; + l = FREAD(buf, 1, sizeof(buf), fs); + if (l > 0) FWRITE(buf, 1, l, fd); + } + while (l > 0); + FCLOSE(fs); + FCLOSE(fd); + hbmp = (HBITMAP)LoadImageW(0, tmpname, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); + } + if (!hbmp) + { +#ifdef WASABI_COMPILE_SKIN_WA2 + // bitmap not found or broken (like in the netscape skin) + // try to find it in the Classic skin (wa2) + StringW wa2skinFn = WASABI_API_APP->getSkinsPath(); + wa2skinFn.AppendPath("Classic"); + wa2skinFn.AppendPath(_filename); + fs = WFOPEN(wa2skinFn), WF_READONLY_BINARY); + if (fs != OPEN_FAILED) + { + OSFILETYPE fd = WFOPEN(tmpname, L"wb"); + int l; + do + { + char buf[1024] = {0}; + l = FREAD(buf, 1, sizeof(buf), fs); + if (l > 0) FWRITE(buf, 1, l, fd); + } + while (l > 0); + FCLOSE(fs); + FCLOSE(fd); + hbmp = (HBITMAP)LoadImageW(0, tmpname, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); + } +#endif //WASABI_COMPILE_SKIN_WA2 + } + if (!hbmp) + { + // no luck :( + _wunlink(tmpname); + return 0; + } + } + + BITMAP bm; + HDC hMemDC, hMemDC2; + HBITMAP hprev, hprev2; + HBITMAP hsrcdib; + void *srcdib; + BITMAPINFO srcbmi = {0, }; + int r = GetObject(hbmp, sizeof(BITMAP), &bm); + ASSERT(r != 0); + *w = bm.bmWidth; + *h = ABS(bm.bmHeight); + + ARGB32 *newbits; + srcbmi.bmiHeader.biSize = sizeof(srcbmi.bmiHeader); + srcbmi.bmiHeader.biWidth = *w; + srcbmi.bmiHeader.biHeight = -*h; + srcbmi.bmiHeader.biPlanes = 1; + srcbmi.bmiHeader.biBitCount = 32; + srcbmi.bmiHeader.biCompression = BI_RGB; + + hMemDC = CreateCompatibleDC(NULL); + hMemDC2 = CreateCompatibleDC(NULL); + hsrcdib = CreateDIBSection(hMemDC, &srcbmi, DIB_RGB_COLORS, &srcdib, NULL, 0); + ASSERTPR(hsrcdib != 0, "CreateDIBSection() failed #69"); + hprev2 = (HBITMAP) SelectObject(hMemDC2, hbmp); + hprev = (HBITMAP) SelectObject(hMemDC, hsrcdib); + BitBlt(hMemDC, 0, 0, *w, *h, hMemDC2, 0, 0, SRCCOPY); + newbits = (ARGB32*)MALLOC((*w) * (*h) * sizeof(ARGB32)); + MEMCPY32(newbits, srcdib, (*w)*(*h) /**sizeof(ARGB32)*/); + { + // put the alpha channel to 255 + unsigned char *b = (unsigned char *)newbits; + int l = (*w) * (*h); + for (int i = 0;i < l;i++) + b[(i*4) + 3] = 0xff; + } + SelectObject(hMemDC, hprev); + SelectObject(hMemDC2, hprev2); + DeleteObject(hsrcdib); + DeleteDC(hMemDC2); + DeleteDC(hMemDC); + + DeleteObject(hbmp); + + if (tmpname[0]) + _wunlink(tmpname); // destroy temp extraction + + if (addMem) + addMemUsage(file, (*w)*(*h)*4); + return newbits; + } + } +#endif + } + return ret; +} + +int imageLoader::getFileType(unsigned char *pData) +{ + // Bmp ? +#ifdef WIN32 + WINBITMAPFILEHEADER * pBFH; + pBFH = (WINBITMAPFILEHEADER *) pData; +#ifdef _WINDOWS + if (pBFH->bfType == 0x4d42) +#else + if (pBFH->bfType == 0x424d) +#endif + return FT_BMP; +#endif + return FT_UNKNOWN; +} + +#ifdef WASABI_COMPILE_SKIN + +ARGB32 *imageLoader::requestSkinBitmap(const wchar_t *id, int *has_alpha, int *x, int *y, int *subw, int *subh, int *w, int *h, int cached) +{ + ifc_xmlreaderparams *params = NULL; + const wchar_t *rootpath = NULL; + + const wchar_t *aliastarget = WASABI_API_PALETTE->getElementAlias(id); + + if (aliastarget) + id = aliastarget; + + const wchar_t *efile = WASABI_API_PALETTE->getSkinBitmapFilename(id, x, y, subw, subh, &rootpath, ¶ms); + + if (x && *x == -1) *x = 0; + if (y && *y == -1) *y = 0; + + if (!efile) + efile = id; + + if (cached) + { + StringPathCombine f(rootpath, efile); + f.toupper(); + f.FixSlashes(); + + int pos = -1; + /*skinCacheEntry *entry = */skinCacheList.findItem(f.getValue(), &pos); + if (pos != -1) + { + //find first one + while (pos > 0 && !wcscmp(skinCacheList[pos - 1]->fullpathfilename, f)) pos--; + do + { + skinCacheEntry *entry = skinCacheList[pos]; + if (GammaMgr::gammaEqual(entry->original_element_id, id) && layerEqual(entry->original_element_id, id)) + { + entry->usageCount++; + if (w) *w = entry->width; + if (h) *h = entry->height; + if (has_alpha) *has_alpha = entry->has_alpha; + return entry->bitmapbits; + } + pos++; + if (pos >= skinCacheList.getNumItems()) break; + } + while (!wcscmp(skinCacheList[pos]->fullpathfilename, f)); + } + } + + int force_nocache = 0; + int t_has_alpha = 0; + ARGB32 *bits = makeBmp(efile, rootpath, &t_has_alpha, w, h, params, TRUE, &force_nocache); + if (has_alpha != NULL) *has_alpha = t_has_alpha; + + if (!bits) + return NULL; + + if (force_nocache || !cached) return bits; + + skinCacheEntry *cachedbmp = new skinCacheEntry; + + if (params) + { + for (size_t i = 0;i != params->getNbItems();i++) + cachedbmp->params.addItem(params->getItemName(i), params->getItemValue(i)); + } + + cachedbmp->usageCount = 1; + cachedbmp->bitmapbits = bits; + cachedbmp->filename = efile; + cachedbmp->has_alpha = !!t_has_alpha; + cachedbmp->width = *w; + cachedbmp->height = *h; + cachedbmp->original_element_id = id; + + //needed for findItem above + StringPathCombine b(rootpath, efile); + b.toupper(); + b.FixSlashes(); + cachedbmp->fullpathfilename.swap(b); + + applySkinFilters(cachedbmp); + skinCacheList.addItem(cachedbmp); + + return cachedbmp->bitmapbits; +} +/* +int imageLoader::paramsMatch(ifc_xmlreaderparams *a, ifc_xmlreaderparams *b) +{ + if (!a && !b) return 1; + if ((!a && b) || (!b && a)) return 0; + for (int i = 0;i < a->getNbItems();i++) + { + const wchar_t *name = a->getItemName(i); + if (!_wcsicmp(name, L"w") || !_wcsicmp(name, L"h") || !_wcsicmp(name, L"x") || !_wcsicmp(name, L"y")) continue; + if (_wcsicmp(a->getItemValue(i), b->getItemValue(name))) + return 0; + } + return 1; +} +*/ +int imageLoader::layerEqual(const wchar_t *id1, const wchar_t *id2) +{ + int a = WASABI_API_PALETTE->getLayerFromId(id1); + int b = WASABI_API_PALETTE->getLayerFromId(id2); + return (a == b); +} + +void imageLoader::releaseSkinBitmap(ARGB32 *bitmapbits) +{ //FG + int i; + // TODO: add critical sections + + int ni = skinCacheList.getNumItems(); + for (i = 0;i < ni;i++) + { + skinCacheEntry *entry = skinCacheList.enumItem(i); + if (entry->bitmapbits == bitmapbits) + { + entry->usageCount--; + if (entry->usageCount == 0) + { + subMemUsage(entry->width*entry->height*sizeof(int)); + WASABI_API_MEMMGR->sysFree(entry->bitmapbits); + skinCacheList.removeByPos(i); + delete entry; + if (skinCacheList.getNumItems() == 0) skinCacheList.removeAll(); + } + return ; + } + } + // bitmap was not a cached skin bitmap, simply free it + release(bitmapbits); +} + +#endif //WASABI_COMPILE_SKIN + +void imageLoader::release(ARGB32 *bitmapbits) +{ + WASABI_API_MEMMGR->sysFree(bitmapbits); +} + +void imageLoader::optimizeHasAlpha(ARGB32 *bits, int len, int *has_alpha) +{ + if (len <= 0 || has_alpha == NULL) return ; + for (*has_alpha = 0; len; len--, bits++) + { + ARGB32 v = *bits; + unsigned int alpha = v >> 24; + if (alpha != 255) + { + *has_alpha = 1; + break; + } + } +} + +#ifdef WASABI_COMPILE_SKIN + +void imageLoader::applySkinFilters() +{ //FG + int i; + + Skin::unloadResources(); + for (i = 0; i < skinCacheList.getNumItems(); i++) + { + skinCacheEntry *entry = skinCacheList.q(i); + applySkinFilters(entry); + } + + WASABI_API_PALETTE->newSkinPart(); + Skin::reloadResources(); +} + +void imageLoader::applySkinFilters(skinCacheEntry *entry) +{ + ASSERT(entry != NULL); + + int w = entry->width, h = entry->height; + + ApplySkinFilters::apply(entry->original_element_id, NULL, (ARGB32*)entry->bitmapbits, w, h); +} + +ARGB32 imageLoader::filterSkinColor(ARGB32 color, const wchar_t *element_id, const wchar_t *groupname) +{ + SkinFilterEnum sfe; + + svc_skinFilter *obj; + while (1) + { + obj = sfe.getNext(FALSE); + if (!obj) break; + color = obj->filterColor(color, element_id, groupname); + sfe.getLastFactory()->releaseInterface(obj); + } + + return color; +} + +#endif //WASABI_COMPILE_SKIN + +void imageLoader::addMemUsage(const wchar_t *filename, int size) +{ + totalMemUsage += size; +#ifdef DEBUG_OUTPUT + DebugStringW("Bitmaps memory usage : %s - %d\n", filename, totalMemUsage); +#endif +} + +void imageLoader::subMemUsage(int size) +{ + totalMemUsage -= size; +} + +#ifdef WASABI_COMPILE_SKIN + +//PtrList imageLoader::skinCacheList; +PtrListInsertMultiSorted imageLoader::skinCacheList; +#endif //WASABI_COMPILE_SKIN + +int imageLoader::totalMemUsage = 0; \ No newline at end of file diff --git a/Src/Wasabi/api/imgldr/imgldr.h b/Src/Wasabi/api/imgldr/imgldr.h new file mode 100644 index 00000000..33a64864 --- /dev/null +++ b/Src/Wasabi/api/imgldr/imgldr.h @@ -0,0 +1,86 @@ +#ifndef __IMGLDR_H +#define __IMGLDR_H + +//CUT +#define FT_UNKNOWN 0 +#define FT_BMP 1 +#define FT_JPEG 5 +#define FT_PNG 6 + +#include +#include +#ifdef WASABI_COMPILE_XMLPARSER +#include +#include +#else +class XmlReaderParamsI; +#endif +#ifdef WASABI_COMPILE_SKIN +#include +#include +#endif + +#include + +typedef struct { + ARGB32 *bitmapbits; + StringW filename; + int usageCount; + bool has_alpha; + int width; + int height; + StringW includepath; +// String rootpath; + XmlReaderParamsI params; + StringW original_element_id; + StringW fullpathfilename; +} skinCacheEntry; + +typedef unsigned long ARGB32; + +#ifdef WASABI_COMPILE_SKIN + +class skinCacheComp +{ +public: + static int compareItem(void *p1, void *p2) { + return wcscmp(((skinCacheEntry *)p1)->fullpathfilename, ((skinCacheEntry *)p2)->fullpathfilename); + } + static int compareAttrib(const wchar_t *attrib, void *item) { + return wcscmp(attrib, ((skinCacheEntry *)item)->fullpathfilename); + } +}; + +#endif //WASABI_COMPILE_SKIN + +class imageLoader +{ +public: + static ARGB32 *makeBmp(const wchar_t *filename, const wchar_t *path, int *has_alpha, int *w, int *h, ifc_xmlreaderparams *params, bool addmem, int *force_nocache); +#ifdef _WIN32 + static ARGB32 *makeBmp(OSMODULEHANDLE hInst, int id, int *has_alpha, int *w, int *h, const wchar_t *forcegroup=NULL); +#endif + static int getFileType(uint8_t *pData); + static StringW getWallpaper(); + static void release(ARGB32 *bitmapbits); +#ifdef WASABI_COMPILE_SKIN + static ARGB32 *requestSkinBitmap(const wchar_t *id, int *has_alpha, int *x, int *y, int *subw, int *subh, int *w, int *h, int cached=1); + static void releaseSkinBitmap(ARGB32 *bmpbits); + static void applySkinFilters(); + static void applySkinFilters(skinCacheEntry *entry); + static ARGB32 filterSkinColor(ARGB32 color, const wchar_t *elementid, const wchar_t *groupname); + static int layerEqual(const wchar_t *id1, const wchar_t *id2); +#endif //WASABI_COMPILE_SKIN + static int getMemUsage() { return totalMemUsage; } + static int getNumCached() { return skinCacheList.getNumItems(); } +private: +#ifdef WASABI_COMPILE_SKIN + //static int paramsMatch(ifc_xmlreaderparams *a, ifc_xmlreaderparams *b); + static PtrListInsertMultiSorted skinCacheList; +#endif //WASABI_COMPILE_SKIN + static void optimizeHasAlpha(ARGB32 *bits, int len, int *has_alpha); + static void addMemUsage(const wchar_t *filename, int size); + static void subMemUsage(int size); + static int totalMemUsage; +}; +#endif diff --git a/Src/Wasabi/api/imgldr/imgldrapi.cpp b/Src/Wasabi/api/imgldr/imgldrapi.cpp new file mode 100644 index 00000000..45790615 --- /dev/null +++ b/Src/Wasabi/api/imgldr/imgldrapi.cpp @@ -0,0 +1,81 @@ +#include "precomp.h" +#include +#include "imgldrapi.h" +#include + +#include +imgldr_api *imgLoaderApi = NULL; + +ARGB32 *ImgLdrApi::imgldr_makeBmp(const wchar_t *filename, int *has_alpha, int *w, int *h) +{ + if (filename == NULL) + { + DebugString("illegal param : filename == NULL"); + return NULL; + } + return imageLoader::makeBmp(filename, NULL, has_alpha, w, h, NULL, TRUE, NULL); +} + +#ifdef _WIN32 +ARGB32 *ImgLdrApi::imgldr_makeBmp2(HINSTANCE hInst, int id, int *has_alpha, int *w, int *h, const wchar_t *colorgroup) +{ + return imageLoader::makeBmp(hInst, id, has_alpha,w,h, colorgroup); +} +#endif + +void ImgLdrApi::imgldr_releaseBmp(ARGB32 *bmpbits) +{ + if (bmpbits == NULL) { + DebugString("illegal param : bmpbits == NULL"); + return; + } + imageLoader::release(bmpbits); +} + +#ifdef WASABI_COMPILE_SKIN + +ARGB32 *ImgLdrApi::imgldr_requestSkinBitmap(const wchar_t *file, int *has_alpha, int *x, int *y, int *subw, int *subh, int *w, int *h, int cached) +{ + if (file == NULL) + { + DebugString("illegal param : file == NULL"); + return NULL; + } + return imageLoader::requestSkinBitmap(file, has_alpha, x, y, subw, subh, w, h, cached); +} + +void ImgLdrApi::imgldr_releaseSkinBitmap(ARGB32 *bmpbits) +{ + if (bmpbits == NULL) + { + DebugString("illegal param : bmpbits == NULL"); + return; + } + imageLoader::releaseSkinBitmap(bmpbits); +} + +RegionServer *ImgLdrApi::imgldr_requestSkinRegion(const wchar_t *id) +{ + if (id == NULL) + { + DebugString("illegal param : id == NULL"); + return NULL; + } + return WASABI_API_PALETTE->requestSkinRegion(id); +} + +void ImgLdrApi::imgldr_cacheSkinRegion(const wchar_t *id, api_region *r) +{ + if (id == NULL) + { + DebugString("illegal param : id == NULL"); + } + if (r == NULL) + { + DebugString("illegal param : region == NULL"); + } + WASABI_API_PALETTE->cacheSkinRegion(id, r); +} + +#endif + diff --git a/Src/Wasabi/api/imgldr/imgldrapi.h b/Src/Wasabi/api/imgldr/imgldrapi.h new file mode 100644 index 00000000..b94fdfa5 --- /dev/null +++ b/Src/Wasabi/api/imgldr/imgldrapi.h @@ -0,0 +1,23 @@ +#ifndef __IMGLDRAPI_H +#define __IMGLDRAPI_H + +#include + +class ImgLdrApi : public imgldr_apiI +{ + public: + ARGB32 *imgldr_makeBmp(const wchar_t *filename, int *has_alpha, int *w, int *h); +#ifdef _WIN32 + ARGB32 *imgldr_makeBmp2(OSMODULEHANDLE hInst, int id, int *has_alpha, int *w, int *h, const wchar_t *colorgroup = NULL); +#endif + void imgldr_releaseBmp(ARGB32 *bmpbits); +#ifdef WASABI_COMPILE_SKIN + ARGB32 *imgldr_requestSkinBitmap(const wchar_t *file, int *has_alpha, int *x, int *y, int *subw, int *subh, int *w, int *h, int cached); + RegionServer *imgldr_requestSkinRegion(const wchar_t *id); + void imgldr_cacheSkinRegion(const wchar_t *id, api_region *r); + void imgldr_releaseSkinBitmap(ARGB32 *bmpbits); +#endif //WASABI_COMPILE_SKIN +}; + + +#endif diff --git a/Src/Wasabi/api/imgldr/skinbmps.h b/Src/Wasabi/api/imgldr/skinbmps.h new file mode 100644 index 00000000..dab8568c --- /dev/null +++ b/Src/Wasabi/api/imgldr/skinbmps.h @@ -0,0 +1,122 @@ +#ifndef _SKINBMPS_H +#define _SKINBMPS_H +/* +typedef enum { + SKIN_BITMAP_UNKNOWN, + + // Base texture + SKIN_BITMAP_BASE_TEXTURE, + + // Framewnd + SKIN_BITMAP_FRAME_VERTICAL_DIVIDER, + SKIN_BITMAP_FRAME_HORIZONTAL_DIVIDER, + + // Listwnd/Treewnd + SKIN_BITMAP_LIST_BACKGROUND, + SKIN_BITMAP_TREE_BACKGROUND, + + // Appctrl + SKIN_BITMAP_APPCTRL_LEFTARROW_NONPRESSED, + SKIN_BITMAP_APPCTRL_LEFTARROW_PRESSED, + SKIN_BITMAP_APPCTRL_RIGHTARROW_NONPRESSED, + SKIN_BITMAP_APPCTRL_RIGHTARROW_PRESSED, + SKIN_BITMAP_APPCTRL_WINDOWSIZER, + SKIN_BITMAP_APPCTRL_PLAYERMODE_NONPRESSED, + SKIN_BITMAP_APPCTRL_PLAYERMODE_PRESSED, + SKIN_BITMAP_APPCTRL_MINIMIZE_NONPRESSED, + SKIN_BITMAP_APPCTRL_MINIMIZE_PRESSED, + SKIN_BITMAP_APPCTRL_MAXIMIZE_NONPRESSED, + SKIN_BITMAP_APPCTRL_MAXIMIZE_PRESSED, + SKIN_BITMAP_APPCTRL_CLOSE_NONPRESSED, + SKIN_BITMAP_APPCTRL_CLOSE_PRESSED, + SKIN_BITMAP_APPCTRL_SYSTEMICON, + SKIN_BITMAP_APPCTRL_PLACEHOLDER_LEFT, + SKIN_BITMAP_APPCTRL_PLACEHOLDER_MIDDLE, + SKIN_BITMAP_APPCTRL_PLACEHOLDER_RIGHT, + SKIN_BITMAP_APPCTRL_TITLEBAR, + + // Controls + SKIN_BITMAP_PLAYBACKCONTROLS_PREVIOUS_NONPRESSED, + SKIN_BITMAP_PLAYBACKCONTROLS_PREVIOUS_PRESSED, + SKIN_BITMAP_PLAYBACKCONTROLS_PLAY_NONPRESSED, + SKIN_BITMAP_PLAYBACKCONTROLS_PLAY_PRESSED, + SKIN_BITMAP_PLAYBACKCONTROLS_PAUSE_NONPRESSED, + SKIN_BITMAP_PLAYBACKCONTROLS_PAUSE_PRESSED, + SKIN_BITMAP_PLAYBACKCONTROLS_STOP_NONPRESSED, + SKIN_BITMAP_PLAYBACKCONTROLS_STOP_PRESSED, + SKIN_BITMAP_PLAYBACKCONTROLS_NEXT_NONPRESSED, + SKIN_BITMAP_PLAYBACKCONTROLS_NEXT_PRESSED, + + // Paintset + SKIN_BITMAP_LABEL_UPPERLEFT, + SKIN_BITMAP_LABEL_TOP, + SKIN_BITMAP_LABEL_UPPERRIGHT, + SKIN_BITMAP_LABEL_LEFT, + SKIN_BITMAP_LABEL_MIDDLE, + SKIN_BITMAP_LABEL_RIGHT, + SKIN_BITMAP_LABEL_LOWERLEF, + SKIN_BITMAP_LABEL_BOTTOM, + SKIN_BITMAP_LABEL_LOWERRIGHT, + SKIN_BITMAP_APPBORDER_UPPERLEFT, + SKIN_BITMAP_APPBORDER_TOP, + SKIN_BITMAP_APPBORDER_UPPERRIGHT, + SKIN_BITMAP_APPBORDER_LEFT, + SKIN_BITMAP_APPBORDER_RIGHT, + SKIN_BITMAP_APPBORDER_LOWERLEFT, + SKIN_BITMAP_APPBORDER_BOTTOM, + SKIN_BITMAP_APPBORDER_LOWERRIGHT, + + // Seeker + SKIN_BITMAP_SEEKBAR_LEFT, + SKIN_BITMAP_SEEKBAR_MIDDLE, + SKIN_BITMAP_SEEKBAR_RIGHT, + SKIN_BITMAP_SEEKBAR_BUTTON_NONPRESSED, + SKIN_BITMAP_BUTTON_PRESSED, + + // Status + SKIN_BITMAP_STATUSBAR_LEFT, + SKIN_BITMAP_STATUSBAR_MIDDLE, + SKIN_BITMAP_STATUSBAR_RIGHT, + + // Volbar + SKIN_BITMAP_VOLBAR_LEFT, + SKIN_BITMAP_VOLBAR_MIDDLE, + SKIN_BITMAP_VOLBAR_RIGHT, + SKIN_BITMAP_VOLBAR_BUTTON_NONPRESSED, + SKIN_BITMAP_VOLBAR_BUTTON_PRESSED, + + // Titlewnd + SKIN_BITMAP_COMPONENT_PROP_TOP, + SKIN_BITMAP_COMPONENT_PROP, + SKIN_BITMAP_COMPONENT_PROP_MIDDLE, + SKIN_BITMAP_COMPONENT_PROP_BOTTOM, + + // Videownd + SKIN_BITMAP_MOVIE_BACKGROUND, + + // Seditwnd + SKIN_BITMAP_AVS_SCRIPT_MARKER, + SKIN_BITMAP_AVS_SCRIPT_PLAY_NONPRESSED, + SKIN_BITMAP_AVS_SCRIPT_PLAY_PRESSED, + SKIN_BITMAP_AVS_SCRIPT_PAUSE_NONPRESSED, + SKIN_BITMAP_AVS_SCRIPT_PAUSE_PRESSED, + SKIN_BITMAP_AVS_SCRIPT_STOP_NONPRESSED, + SKIN_BITMAP_AVS_SCRIPT_STOP_PRESSED, + SKIN_BITMAP_AVS_SCRIPT_TIMEARROW, + SKIN_BITMAP_AVS_SCRIPT_BACKGROUND, + SKIN_BITMAP_AVS_SCRIPT_ZOOMER_TOP, + SKIN_BITMAP_AVS_SCRIPT_ZOOMER_MIDDLE, + SKIN_BITMAP_AVS_SCRIPT_ZOOMER_BOTTOM, + SKIN_BITMAP_AVS_SCRIPT_ZOOMER_BUTTON_NONPRESSED, + SKIN_BITMAP_AVS_SCRIPT_ZOOMER_BUTTON_PRESSED, + +// ComponentAPI1 ends here + NUM_SKIN_BITMAP_ELEMENT_IDS +} SkinBitmapElementId; + +typedef struct { + SkinBitmapElementId id; + char *fn; + } SkinBitmapTableElement; +*/ +#endif diff --git a/Src/Wasabi/api/imgldr/winbmp.h b/Src/Wasabi/api/imgldr/winbmp.h new file mode 100644 index 00000000..afcc0784 --- /dev/null +++ b/Src/Wasabi/api/imgldr/winbmp.h @@ -0,0 +1,47 @@ +#ifndef __WINBMP_H +#define __WINBMP_H + +typedef struct tagWINRGBQUAD +{ + BYTE rgbBlue; + BYTE rgbGreen; + BYTE rgbRed; + BYTE rgbReserved; +} WINRGBQUAD; + +typedef struct tagWINBITMAPFILEHEADER +{ + WORD bfType; + LONG bfSize; + WORD bfReserved1; + WORD bfReserved2; + LONG bfOffBits; +} WINBITMAPFILEHEADER; + +typedef struct tagWINBITMAPINFOHEADER +{ + LONG biSize; + LONG biWidth; + LONG biHeight; + WORD biPlanes; + WORD biBitCount; + LONG biCompression; + LONG biSizeImage; + LONG biXPelsPerMeter; + LONG biYPelsPerMeter; + LONG biClrUsed; + LONG biClrImportant; +} WINBITMAPINFOHEADER; + +typedef struct tagWINBITMAPINFO +{ + WINBITMAPINFOHEADER bmiHeader; + WINRGBQUAD bmiColors[1]; +} WINBITMAPINFO; + +#define BI_RGB 0L +#define BI_RLE8 1L +#define BI_RLE4 2L +#define BI_BITFIELDS 3L + +#endif diff --git a/Src/Wasabi/api/locales/LocalesInfo.cpp b/Src/Wasabi/api/locales/LocalesInfo.cpp new file mode 100644 index 00000000..667fb25b --- /dev/null +++ b/Src/Wasabi/api/locales/LocalesInfo.cpp @@ -0,0 +1,41 @@ +#include +#include "LocalesInfo.h" +#include "../xml/obj_xml.h" +#include +#include +#include + +LocalesInfosXmlReader::LocalesInfosXmlReader(const wchar_t *localename) : LocaleItem(localename) +{ + parser = 0; + + waServiceFactory *parserFactory = WASABI_API_SVC->service_getServiceByGuid(obj_xmlGUID); + if (parserFactory) + { + parser = (obj_xml *)parserFactory->getInterface(); + + if (parser) + { + { + XMLAutoInclude include(parser, L"Locales"); + parser->xmlreader_registerCallback(L"WinampLocaleDefinition", this); + parser->xmlreader_open(); + + StringPathCombine fn(L"Locales", localename); + LoadXmlFile(parser, fn); + parser->xmlreader_unregisterCallback(this); + } + parser->xmlreader_close(); + parserFactory->releaseInterface(parser); + parser = 0; + } + + } +} + + +void LocalesInfosXmlReader::xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params) +{ + language = params->getItemValue(L"language"); + author = params->getItemValue(L"author"); +} diff --git a/Src/Wasabi/api/locales/LocalesInfo.h b/Src/Wasabi/api/locales/LocalesInfo.h new file mode 100644 index 00000000..5179d94a --- /dev/null +++ b/Src/Wasabi/api/locales/LocalesInfo.h @@ -0,0 +1,30 @@ +#ifndef NULLSOFT_WASABI_LOCALESINFO_H +#define NULLSOFT_WASABI_LOCALESINFO_H + +#include "../xml/ifc_xmlreadercallbackI.h" +#include +class obj_xml; +class LocaleItem +{ +public: + LocaleItem(const wchar_t *name) : name(name), language(name) { }; + const wchar_t *getName() { return name; } + + const wchar_t *getLanguage() { return language; } + const wchar_t *getAuthor() { return author; } +protected: + StringW name; + StringW language; + StringW author; +}; + + +class LocalesInfosXmlReader : public LocaleItem, public ifc_xmlreadercallbackI // XmlReaderCallbackI +{ +public: + LocalesInfosXmlReader(const wchar_t *skinname); + void xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params); +private: + obj_xml *parser; +}; +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/locales/api_locales.cpp b/Src/Wasabi/api/locales/api_locales.cpp new file mode 100644 index 00000000..26cf75ab --- /dev/null +++ b/Src/Wasabi/api/locales/api_locales.cpp @@ -0,0 +1,12 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Fri Oct 17 16:03:31 2003] +// +// File : api_locales.cpp +// Class : api_locales +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#include +#include "api_locales.h" + + diff --git a/Src/Wasabi/api/locales/api_locales.h b/Src/Wasabi/api/locales/api_locales.h new file mode 100644 index 00000000..0ae75c73 --- /dev/null +++ b/Src/Wasabi/api/locales/api_locales.h @@ -0,0 +1,80 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Fri Oct 17 16:03:31 2003] +// +// File : api_locales.h +// Class : api_locales +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#ifndef __API_LOCALES_H +#define __API_LOCALES_H + +#include +#include + +// ---------------------------------------------------------------------------- + +class NOVTABLE api_locales: public Dispatchable { + protected: + api_locales() {} + ~api_locales() {} + public: + const wchar_t *locales_getTranslation(const wchar_t *str); + void locales_addTranslation(const wchar_t *from, const wchar_t *to); + const wchar_t *locales_getBindFromAction(int action); + int locales_getNumEntries(); + const wchar_t *locales_enumEntry(int n); + void locales_registerAcceleratorSection(const wchar_t *name, ifc_window *wnd, int global = 0); + + protected: + enum { + API_LOCALES_LOCALES_GETTRANSLATION = 10, + API_LOCALES_LOCALES_ADDTRANSLATION = 20, + API_LOCALES_LOCALES_GETBINDFROMACTION = 30, + API_LOCALES_LOCALES_GETNUMENTRIES = 40, + API_LOCALES_LOCALES_ENUMENTRY = 50, + API_LOCALES_LOCALES_REGISTERACCELERATORSECTION = 60, + }; +}; + +// ---------------------------------------------------------------------------- + +inline const wchar_t *api_locales::locales_getTranslation(const wchar_t *str) { + const wchar_t *__retval = _call(API_LOCALES_LOCALES_GETTRANSLATION, (const wchar_t *)0, str); + return __retval; +} + +inline void api_locales::locales_addTranslation(const wchar_t *from, const wchar_t *to) +{ + _voidcall(API_LOCALES_LOCALES_ADDTRANSLATION, from, to); +} + +inline const wchar_t *api_locales::locales_getBindFromAction(int action) { + const wchar_t *__retval = _call(API_LOCALES_LOCALES_GETBINDFROMACTION, (const wchar_t *)0, action); + return __retval; +} + +inline int api_locales::locales_getNumEntries() { + int __retval = _call(API_LOCALES_LOCALES_GETNUMENTRIES, (int)0); + return __retval; +} + +inline const wchar_t *api_locales::locales_enumEntry(int n) +{ + const wchar_t *__retval = _call(API_LOCALES_LOCALES_ENUMENTRY, (const wchar_t *)0, n); + return __retval; +} + +inline void api_locales::locales_registerAcceleratorSection(const wchar_t *name, ifc_window *wnd, int global) { + _voidcall(API_LOCALES_LOCALES_REGISTERACCELERATORSECTION, name, wnd, global); +} + +// ---------------------------------------------------------------------------- + +// {C1251318-A6F5-4cd2-9142-A4CEAA08B846} +static const GUID localesApiServiceGuid = +{ 0xc1251318, 0xa6f5, 0x4cd2, { 0x91, 0x42, 0xa4, 0xce, 0xaa, 0x8, 0xb8, 0x46 } }; + +extern api_locales *localesApi; + +#endif // __API_LOCALES_H \ No newline at end of file diff --git a/Src/Wasabi/api/locales/api_localesi.cpp b/Src/Wasabi/api/locales/api_localesi.cpp new file mode 100644 index 00000000..67c99164 --- /dev/null +++ b/Src/Wasabi/api/locales/api_localesi.cpp @@ -0,0 +1,47 @@ +#include +//" +#include "api_localesi.h" +//?> + +#include +#include + +api_locales *localesApi = NULL; + +api_localesI::api_localesI() { + LocalesManager::init(); +} + +api_localesI::~api_localesI() { + LocalesManager::deinit(); +} + +const wchar_t *api_localesI::locales_getTranslation(const wchar_t *str) +{ + return LocalesManager::getTranslation(str); +} + +void api_localesI::locales_addTranslation(const wchar_t *from, const wchar_t *to) { + LocalesManager::addTranslation(from, to); +} + +const wchar_t *api_localesI::locales_getBindFromAction(int action) +{ + return LocalesManager::getBindFromAction(action); +} + +/* // TODO: benski> maybe hook up to Winamp 5.5's new lang pack stuff +int api_localesI::locales_getNumEntries() +{ + return LocalesManager::getNumLocales(); +} + +const wchar_t *api_localesI::locales_enumEntry(int n) +{ + return LocalesManager::enumLoadableLocales(n); +}*/ + +void api_localesI::locales_registerAcceleratorSection(const wchar_t *name, ifc_window *wnd, int global) +{ + Keyboard::registerAcceleratorSection(name, wnd, global); +} \ No newline at end of file diff --git a/Src/Wasabi/api/locales/api_localesi.h b/Src/Wasabi/api/locales/api_localesi.h new file mode 100644 index 00000000..eea3ac62 --- /dev/null +++ b/Src/Wasabi/api/locales/api_localesi.h @@ -0,0 +1,23 @@ +#ifndef __API_LOCALESI_IMPL_H +#define __API_LOCALESI_IMPL_H + +/**/ +#include "api_locales.h" +#include "api_localesx.h" +/*?>*/ + +class api_localesI : public api_localesX +{ +public: + api_localesI(); + virtual ~api_localesI(); + + DISPATCH(10) const wchar_t *locales_getTranslation(const wchar_t *str); // if not found, returns the str paramer + DISPATCH(20) void locales_addTranslation(const wchar_t *from, const wchar_t *to); + DISPATCH(30) const wchar_t *locales_getBindFromAction(int action); + //DISPATCH(40) int locales_getNumEntries(); + //DISPATCH(50) const wchar_t *locales_enumEntry(int n); + DISPATCH(60) void locales_registerAcceleratorSection(const wchar_t *name, ifc_window *wnd, int global = 0); +}; + +#endif // __API_LOCALESI_IMPL_H \ No newline at end of file diff --git a/Src/Wasabi/api/locales/api_localesx.cpp b/Src/Wasabi/api/locales/api_localesx.cpp new file mode 100644 index 00000000..ff4d4d31 --- /dev/null +++ b/Src/Wasabi/api/locales/api_localesx.cpp @@ -0,0 +1,26 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Fri Oct 17 16:03:31 2003] +// +// File : api_localesx.cpp +// Class : api_locales +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- +#include + +#include "api_localesx.h" +#include "api_localesi.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif + +#define CBCLASS api_localesX +START_DISPATCH; + CB(API_LOCALES_LOCALES_GETTRANSLATION, locales_getTranslation); + VCB(API_LOCALES_LOCALES_ADDTRANSLATION, locales_addTranslation); + CB(API_LOCALES_LOCALES_GETBINDFROMACTION, locales_getBindFromAction); + //CB(API_LOCALES_LOCALES_GETNUMENTRIES, locales_getNumEntries); + //CB(API_LOCALES_LOCALES_ENUMENTRY, locales_enumEntry); + VCB(API_LOCALES_LOCALES_REGISTERACCELERATORSECTION, locales_registerAcceleratorSection); +END_DISPATCH; +#undef CBCLASS \ No newline at end of file diff --git a/Src/Wasabi/api/locales/api_localesx.h b/Src/Wasabi/api/locales/api_localesx.h new file mode 100644 index 00000000..b8efae8e --- /dev/null +++ b/Src/Wasabi/api/locales/api_localesx.h @@ -0,0 +1,31 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Fri Oct 17 16:03:31 2003] +// +// File : api_localesx.h +// Class : api_locales +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- + +#ifndef __API_LOCALESX_H +#define __API_LOCALESX_H + +#include "api_locales.h" + +// ---------------------------------------------------------------------------- + +class api_localesX : public api_locales { + protected: + api_localesX() {} + public: + virtual const wchar_t *locales_getTranslation(const wchar_t *str)=0; + virtual void locales_addTranslation(const wchar_t *from, const wchar_t *to)=0; + virtual const wchar_t *locales_getBindFromAction(int action)=0; + //virtual int locales_getNumEntries()=0; + //virtual const wchar_t *locales_enumEntry(int n)=0; + virtual void locales_registerAcceleratorSection(const wchar_t *name, ifc_window *wnd, int global = 0)=0; + + protected: + RECVS_DISPATCH; +}; + +#endif // __API_LOCALESX_H \ No newline at end of file diff --git a/Src/Wasabi/api/locales/localesmgr.cpp b/Src/Wasabi/api/locales/localesmgr.cpp new file mode 100644 index 00000000..610a0432 --- /dev/null +++ b/Src/Wasabi/api/locales/localesmgr.cpp @@ -0,0 +1,462 @@ +#include +#include +#include "localesmgr.h" +#include +#include +#include +#include +#include "../nu/regexp.h" +#include "../Agave/language/api_language.h" +#include + +struct StringEntry +{ + uint32_t id; + wchar_t *string; +}; + +typedef PtrList StringTable; +struct StringTableData +{ + wchar_t *id; + StringTable entries; +}; + +typedef PtrList StringTables; + +StringTables stringTables; + +void LocalesAcceleratorSectionXmlCallback::xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params) +{ + const wchar_t *section = params->getItemValue(L"section"); + if (!section) + LocalesManager::setAcceleratorSection(L"general"); + else + LocalesManager::setAcceleratorSection(section); +} + +void LocalesAcceleratorSectionXmlCallback::xmlReaderOnEndElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag) +{ + LocalesManager::setAcceleratorSection(L""); +} + +void StringTableXmlCallback::xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params) +{ + const wchar_t *section = params->getItemValue(L"id"); + if (!section) + LocalesManager::SetStringTable(L"nullsoft.wasabi"); + else + LocalesManager::SetStringTable(section); +} + +void StringTableXmlCallback::xmlReaderOnEndElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag) +{ + LocalesManager::SetStringTable(L""); +} + +void StringTableEntryXmlCallback::xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params) +{ + const wchar_t *b = params->getItemValue(L"id"); + const wchar_t *a = params->getItemValue(L"string"); + if (b && a) + LocalesManager::AddString(WTOI(b), a); +} + +/* ------------------------------------------------------------ */ +void LocalesAcceleratorXmlCallback::xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params) +{ + const wchar_t *b = params->getItemValue(L"bind"); + const wchar_t *a = params->getItemValue(L"action"); + if (b && a) + LocalesManager::addAccelerator(b, a); +} + +/* ------------------------------------------------------------ */ +void LocalesTranslationXmlCallback::xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params) +{ + const wchar_t *f = params->getItemValue(L"from"); + const wchar_t *t = params->getItemValue(L"to"); + if (f && t) + LocalesManager::addTranslation(f, t); +} + +int LocalesSkinCallback::skincb_onUnloading() +{ + LocalesManager::ResetStrings(); + LocalesManager::resetAll(); + return 0; +} + +int LocalesSkinCallback::skincb_onReset() +{ + // + return 0; +} + +int LocalesSkinCallback::skincb_onReload() +{ + //LocalesManager::load(); + return 0; +} + +int LocalesSkinCallback::skincb_onBeforeLoadingElements() +{ + LocalesManager::load(); + return 0; +} + +int LocalesSkinCallback::skincb_onGuiLoaded() +{ + LocalesManager::LoadStringTables(); + return 0; +} + +int LocalesSkinCallback::skincb_onLoaded() +{ + // TODO: load string table? + return 0; +} + +/* ------------------------------------------------------------ */ +void LocalesManager::init() +{ + WASABI_API_SYSCB->syscb_registerCallback(&localesSkinCallback); + //load(); +} + +void LocalesManager::load() +{ +#ifdef LOCALES_CUSTOM_LOAD + + LOCALES_CUSTOM_LOAD(localePath); + // TODO: benski> don't load this here. we should set up a syscallback for skin load (maybe skincb_onBeforeLoadingElements?) + // and also we should call deinit() on skin unload (skincb_onReload, skincb_onReset, skincb_onUnloading?) + StringPathCombine filetoload(localePath, L"Wasabi.xml"); + /* + PathParserW pp(localeName); + localeName = pp.getLastString(); + int p = localeName.lFindChar('.'); + if (p > 0) localeName.trunc(p); + */ +#else + wchar_t tmpbuf[WA_MAX_PATH] = L"english"; + + WASABI_API_CONFIG->getStringPrivate(L"LocaleFile", tmpbuf, WA_MAX_PATH, L"english"); + + // FG> ok I have no idea why it doesn't work when i read from cfg instead of stringprivate and frankly i don't have time for this + // so for now it'll work with both a cfgitem and a stringprivate, i couldn't desync them so it should be ok in the meantime. + /* const GUID options_guid = + { 0x280876cf, 0x48c0, 0x40bc, { 0x8e, 0x86, 0x73, 0xce, 0x6b, 0xb4, 0x62, 0xe5 } }; + CfgItem *item = WASABI_API_CONFIG->config_getCfgItemByGuid(options_guid); + if (item != NULL) + item->getData("Language", tmpbuf, WA_MAX_PATH-1);*/ + + localeName = tmpbuf; + englishLocale = !WCSICMP(localeName, L"english"); + loadFile(L"english"); + StringW filetoload = localeName; + if (englishLocale) + filetoload.trunc(0); +#endif + + if (!filetoload.isempty()) + loadFile(filetoload); + +#ifdef WASABI_API_WNDMGR + if (WASABI_API_WNDMGR) + WASABI_API_WNDMGR->wndTrackInvalidateAll(); +#endif +} + +void LocalesManager::deinit() +{ + resetAll(); + WASABI_API_SYSCB->syscb_deregisterCallback(&localesSkinCallback); +} + +void LoadXmlFile(obj_xml *parser, const wchar_t *filename); + +void LocalesManager::LoadStringTables() +{ + StringPathCombine genericStringTable(localePath, L"stringtable.xml"); + LoadStringTable(genericStringTable); + + StringPathCombine skinStringTable(localePath, WASABI_API_SKIN->getSkinName()); + skinStringTable.AppendPath(L"stringtable.xml"); + LoadStringTable(skinStringTable); +} + +void LocalesManager::LoadStringTable(const wchar_t *name) +{ + waServiceFactory *parserFactory = WASABI_API_SVC->service_getServiceByGuid(obj_xmlGUID); + if (parserFactory) + { + obj_xml *parser = (obj_xml *)parserFactory->getInterface(); + + if (parser) + { + { + const wchar_t *file = Wasabi::Std::filename(name); + int fnlen = wcslen(file); + StringW path = name; + path.trunc( -fnlen); + XMLAutoInclude include(parser, path); + parser->xmlreader_registerCallback(L"WinampLocaleDefinition\fStringTable", &stringTableXmlCallback); + parser->xmlreader_registerCallback(L"WinampLocaleDefinition\fStringTable\fStringEntry", &stringTableXmlEntryCallback); + parser->xmlreader_open(); +#ifdef LOCALES_CUSTOM_LOAD + LoadXmlFile(parser, name); +#else + LoadXmlFile(parser, StringPrintfW(L"Locales/%s.xml", name)); +#endif + parser->xmlreader_unregisterCallback(&stringTableXmlCallback); + parser->xmlreader_unregisterCallback(&stringTableXmlEntryCallback); + } + parser->xmlreader_close(); + parserFactory->releaseInterface(parser); + parser = 0; + } + } +} + +void LocalesManager::loadFile(const wchar_t *name) +{ + waServiceFactory *parserFactory = WASABI_API_SVC->service_getServiceByGuid(obj_xmlGUID); + if (parserFactory) + { + obj_xml *parser = (obj_xml *)parserFactory->getInterface(); + + if (parser) + { + { + const wchar_t *file = Wasabi::Std::filename(name); + int fnlen = wcslen(file); + StringW path = name; + path.trunc( -fnlen); + XMLAutoInclude include(parser, path); + parser->xmlreader_registerCallback(L"WinampLocaleDefinition\faccelerators", &accelSectionXmlCallback); + parser->xmlreader_registerCallback(L"WinampLocaleDefinition\faccelerators\faccelerator", &accelXmlCallback); + parser->xmlreader_registerCallback(L"WinampLocaleDefinition\ftranslations\ftranslation", &transXmlCallback); + parser->xmlreader_open(); +#ifdef LOCALES_CUSTOM_LOAD + LoadXmlFile(parser, name); +#else + LoadXmlFile(parser, StringPrintfW(L"Locales/%s.xml", name)); +#endif + parser->xmlreader_unregisterCallback(&accelSectionXmlCallback); + parser->xmlreader_unregisterCallback(&accelXmlCallback); + parser->xmlreader_unregisterCallback(&transXmlCallback); + } + parser->xmlreader_close(); + parserFactory->releaseInterface(parser); + parser = 0; + } + } +} + +void LocalesManager::addTranslation(const wchar_t *from, const wchar_t *to) +{ + LocTrans *t = translationsList.findItem(from); + if (t) + translationsList.removeItem(t); + translationsList.addItem(new LocTrans(from, to)); +} + + +const wchar_t *LocalesManager::lookupString(const wchar_t *from) +{ + if (from == NULL) + return NULL; + + if (*from == L'@') + { + + const wchar_t *findPound = wcschr(from, L'#'); + if (findPound && (findPound-from) < 128) + { + wchar_t table[128] = {0}; + memcpy(table, from+1, sizeof(wchar_t)*(findPound-from-1)); + table[findPound-from-1]=0; + const wchar_t *string = GetString(table, WTOI(findPound+1)); + if (string) + return string; + } + } + return from; +} + +const wchar_t *LocalesManager::getTranslation(const wchar_t *from) +{ + if (!from) + return NULL; + + LocTrans *t = translationsList.findItem(from); + if (t == NULL) + { + return from; + } + return t->getTo(); +} + +void LocalesManager::addAccelerator(const wchar_t *bind, const wchar_t *action) +{ + LocAccel *a = acceleratorsList.findItem(bind); + if (a) // Martin> shouldn't we also check here if it is the same section? + // Hm, now that i look closer, we search our list for a wchar_t but we store LocAccels in the list - does this work? + acceleratorsList.removeItem(a); + acceleratorsList.addItem(new LocAccel(curSection, bind, action)); +} + +void LocalesManager::addAcceleratorFromSkin(const wchar_t *bind, const wchar_t *action) +{ + //TODO> use binary search + int l = acceleratorsList.getNumItems(); + for (int i = 0;i < l;i++) + { + if (0 == WCSICMP(acceleratorsList[i]->getSection(), curSection) && + 0 == WCSICMP(acceleratorsList[i]->getKey(), bind)) + return; + } + acceleratorsList.addItem(new LocAccel(curSection, bind, action)); +} + +const wchar_t *LocalesManager::getBindFromAction(int action) +{ + //TODO> use binary search + int l = acceleratorsList.getNumItems(); + for (int i = 0;i < l;i++) + { + if (acceleratorsList[i]->getActionNum() == action && action != ACTION_NONE) + return acceleratorsList[i]->getRealKey(); + } + return NULL; +} + +const wchar_t *LocalesManager::translateAccelerator(const wchar_t *section, const wchar_t *key) +{ + //TODO> use binary search + int l = acceleratorsList.getNumItems(); + for (int i = 0;i < l;i++) + { + if (!WCSICMP(acceleratorsList[i]->getSection(), section)) + if (!WCSICMP(acceleratorsList[i]->getKey(), key)) + return acceleratorsList[i]->getAction(); + } + return NULL; +} + +#if 0 +void LocalesManager::setNewLocaleFile(const wchar_t *name) +{ + //WASABI_API_CONFIG->setStringPrivate(L"LocaleFile", name); + resetAll(); + init(); +} +#endif + +void LocalesManager::resetAll() +{ + translationsList.deleteAll(); + acceleratorsList.deleteAll(); +} + +void LocalesManager::SetStringTable(const wchar_t *table) +{ + curTable = table; +} + +void LocalesManager::setAcceleratorSection(const wchar_t *section) +{ + curSection = section; +} + +const wchar_t *LocalesManager::getLocaleRoot() +{ + return localePath; +} + +void LocalesManager::ResetStrings() +{ + for (int i=0;i!=stringTables.getNumItems();i++) + { + FREE(stringTables[i]->id); + for (int j=0;j!=stringTables[i]->entries.getNumItems();j++) + { + FREE(stringTables[i]->entries[j]->string); + } + } + stringTables.removeAll(); +} + +const wchar_t *LocalesManager::GetString(const wchar_t *table, uint32_t id) +{ + if (!table) + return 0; + + if (!_wcsicmp(table, L"gen_ff")) + return WASABI_API_LNGSTRINGW(id); + + for (int i=0;i!=stringTables.getNumItems();i++) + { + if (!wcscmp(table, stringTables[i]->id)) + { + for (int j=0;j!=stringTables[i]->entries.getNumItems();j++) + { + if (id == stringTables[i]->entries[j]->id) + return stringTables[i]->entries[j]->string; + } + } + } + return 0; +} + +void LocalesManager::AddString(const wchar_t *table, uint32_t id, const wchar_t *string) +{ + for (int i=0;i!=stringTables.getNumItems();i++) + { + if (!wcscmp(table, stringTables[i]->id)) + { + for (int j=0;j!=stringTables[i]->entries.getNumItems();j++) + { + if (id == stringTables[i]->entries[j]->id) + { + FREE(stringTables[i]->entries[j]->string); + stringTables[i]->entries[j]->string=WCSDUP(string); + return; + } + } + StringEntry *newEntry = new StringEntry; + newEntry->id = id; + newEntry->string = WCSDUP(string); + stringTables[i]->entries.addItem(newEntry); + return; + } + } + StringTableData *newTable = new StringTableData; + newTable->id = WCSDUP(table); + + StringEntry *newEntry = new StringEntry; + newEntry->id = id; + newEntry->string = WCSDUP(string); + stringTables.addItem(newTable); + newTable->entries.addItem(newEntry); +} + +void LocalesManager::AddString(uint32_t id, const wchar_t *string) +{ + AddString(curTable, id, string); +} + +LocalesAcceleratorXmlCallback LocalesManager::accelXmlCallback; +LocalesAcceleratorSectionXmlCallback LocalesManager::accelSectionXmlCallback; +LocalesTranslationXmlCallback LocalesManager::transXmlCallback; +PtrListSorted > LocalesManager::translationsList; +PtrListSorted > LocalesManager::acceleratorsList; +StringW LocalesManager::localePath; +//int LocalesManager::localeListLoaded = 0, LocalesManager::curLocaleNum = -1, LocalesManager::englishLocale; +//PtrList LocalesManager::loadableLocalesList; +StringW LocalesManager::curSection; +LocalesSkinCallback LocalesManager::localesSkinCallback; +StringW LocalesManager::curTable; +StringTableXmlCallback LocalesManager::stringTableXmlCallback; +StringTableEntryXmlCallback LocalesManager::stringTableXmlEntryCallback; \ No newline at end of file diff --git a/Src/Wasabi/api/locales/localesmgr.h b/Src/Wasabi/api/locales/localesmgr.h new file mode 100644 index 00000000..b9495143 --- /dev/null +++ b/Src/Wasabi/api/locales/localesmgr.h @@ -0,0 +1,173 @@ +#ifndef _LOCALESMGR_H +#define _LOCALESMGR_H + +#include "../xml/obj_xml.h" +#include +#include +#include + +#include "LocalesInfo.h" + +class LocTrans +{ +public: + LocTrans(const wchar_t *pfrom, const wchar_t *pto) : from(pfrom), to(pto) + { + //from.toupper(); + } + const wchar_t *getFrom() { return from; } + const wchar_t *getTo() { return to; } +private: + StringW from; + StringW to; +}; + +class PLS_LocTrans +{ +public: + // comparator for sorting + static int compareItem(LocTrans *p1, LocTrans* p2) { + return wcscmp(p1->getFrom(), p2->getFrom()); + } + // comparator for searching + static int compareAttrib(const wchar_t *attrib, LocTrans *item) { + return wcscmp(attrib, item->getFrom()); + } +}; + +class LocAccel +{ +public: + LocAccel(const wchar_t *psec, const wchar_t *pkey, const wchar_t *paction) + : section(psec), key(pkey), realkey(pkey), action(paction) + { + key.tolower(); + actionnum = SkinParser::getAction(paction); + } + const wchar_t *getKey() { return key; } + const wchar_t *getRealKey() { return realkey; } + const wchar_t *getAction() { return action; } + int getActionNum() { return actionnum; } + const wchar_t *getSection() { return section; } +private: + StringW section; + StringW key; + StringW realkey; + StringW action; + int actionnum; +}; + +class PLS_LocAccel +{ +public: + // comparator for sorting + static int compareItem(LocAccel *p1, LocAccel *p2) + { + return wcscmp(p1->getKey(), p2->getKey()); + } + // comparator for searching + static int compareAttrib(const wchar_t *attrib, LocAccel *item) + { + return wcscmp(attrib, item->getKey()); + } +}; + +class LocalesAcceleratorSectionXmlCallback : public ifc_xmlreadercallbackI +{ + void xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params); + void xmlReaderOnEndElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag); +}; + +class LocalesAcceleratorXmlCallback : public ifc_xmlreadercallbackI +{ + void xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params); +}; + +class LocalesTranslationXmlCallback : public ifc_xmlreadercallbackI +{ + void xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params); +}; + +class StringTableXmlCallback : public ifc_xmlreadercallbackI +{ + void xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params); + void xmlReaderOnEndElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag); +}; + +class StringTableEntryXmlCallback : public ifc_xmlreadercallbackI +{ + void xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params); +}; + +class LocalesSkinCallback : public SkinCallbackI +{ +public: + int skincb_onUnloading(); + int skincb_onReset(); + int skincb_onReload(); + int skincb_onBeforeLoadingElements(); + int skincb_onGuiLoaded(); + int skincb_onLoaded(); + +}; + +class LocalesManager +{ +public: + static void init(); + static void load(); + static void deinit(); + + static void loadFile(const wchar_t *name); + + static void addTranslation(const wchar_t *from, const wchar_t *to); + static const wchar_t *getTranslation(const wchar_t *from); // will return the from parameter if not found + static const wchar_t *lookupString(const wchar_t *from); // will return the from parameter if not found + + static void setAcceleratorSection(const wchar_t *section); + static void addAccelerator(const wchar_t *bind, const wchar_t *action); + static void addAcceleratorFromSkin(const wchar_t *bind, const wchar_t *action); + static const wchar_t *getBindFromAction(int action); + static const wchar_t *translateAccelerator(const wchar_t *section, const wchar_t *key); + + //static const wchar_t *enumLoadableLocales(int num); + //static int getNumLocales(); + //static void setNewLocaleFile(const wchar_t *name); + //static void setNewLocaleNum(int num); + //static int isCurrentLocaleNum(int num) { return num == curLocaleNum; } + + static void resetAll(); + + static const wchar_t *getLocaleRoot(); + + static void LoadStringTables(); + static void LoadStringTable(const wchar_t *filename); + static void SetStringTable(const wchar_t *table); + static void ResetStrings(); + static const wchar_t *GetString(const wchar_t *table, uint32_t id); + static void AddString(const wchar_t *table, uint32_t id, const wchar_t *string); + static void AddString(uint32_t id, const wchar_t *string); +private: + static LocalesAcceleratorXmlCallback accelXmlCallback; + static LocalesAcceleratorSectionXmlCallback accelSectionXmlCallback; + static LocalesTranslationXmlCallback transXmlCallback; + + static PtrListSorted > translationsList; + + static PtrListSorted > acceleratorsList; + + static StringW localePath; + + //static PtrList loadableLocalesList; + + //static int localeListLoaded, curLocaleNum, englishLocale; + static StringW curSection; + + static StringW curTable; + + static LocalesSkinCallback localesSkinCallback; + static StringTableXmlCallback stringTableXmlCallback; + static StringTableEntryXmlCallback stringTableXmlEntryCallback; +}; + +#endif//_LOCALESMGR_H \ No newline at end of file diff --git a/Src/Wasabi/api/locales/xlatstr.h b/Src/Wasabi/api/locales/xlatstr.h new file mode 100644 index 00000000..aca8dac1 --- /dev/null +++ b/Src/Wasabi/api/locales/xlatstr.h @@ -0,0 +1,68 @@ +#ifndef _XLATSTR_H +#define _XLATSTR_H + +#include + +/** + Provides string translation for the string + used as the constructor parameter. + + The constructor will automatically lookup + the translated value of the string it receives + in the currently loaded locale. + + @short Translates a string using the currently loaded locale. + @author Nullsoft + @ver 1.0 + @see ComponentAPI::locales_getTranslation() +*/ + +class _ { + public: + /** + Automatically looks up the translated value of the string + it receives as a parameter in the currently loaded + locale. The same string is returned if there's no + translation. + + @param str String to be translated. + @ret Translation found, Translated string; Translation not found, Input string; + */ + +#if defined(WASABI_COMPILE_LOCALES) + _(const wchar_t *str) { s=LocalesManager::getTranslation(str); } +#else + _(const wchar_t *str) { s=str; } +#endif + operator const wchar_t *() const { return s; } + + private: + const wchar_t *s; +}; + + +class __ { + public: + /** + Automatically looks up the translated value of the string + it receives as a parameter in the currently loaded + locale. The same string is returned if there's no + translation. + + @param str String to be translated. + @ret Translation found, Translated string; Translation not found, Input string; + */ + +#if defined(WASABI_COMPILE_LOCALES) + __(const wchar_t *str) { s=LocalesManager::lookupString(str); } +#else + __(const wchar_t *str) { s=str; } +#endif + operator const wchar_t *() const { return s; } + + private: + const wchar_t *s; +}; + + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/memmgr/api_memmgr.cpp b/Src/Wasabi/api/memmgr/api_memmgr.cpp new file mode 100644 index 00000000..e1001185 --- /dev/null +++ b/Src/Wasabi/api/memmgr/api_memmgr.cpp @@ -0,0 +1,13 @@ +#include +#include "api_memmgr.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif +#define CBCLASS api_memmgrI +START_DISPATCH; + CB(API_MEMMGR_SYSMALLOC, sysMalloc); + VCB(API_MEMMGR_SYSFREE, sysFree); + CB(API_MEMMGR_SYSREALLOC, sysRealloc); + VCB(API_MEMMGR_SYSMEMCHANGED, sysMemChanged); +END_DISPATCH; diff --git a/Src/Wasabi/api/memmgr/api_memmgr.h b/Src/Wasabi/api/memmgr/api_memmgr.h new file mode 100644 index 00000000..301d8baa --- /dev/null +++ b/Src/Wasabi/api/memmgr/api_memmgr.h @@ -0,0 +1,78 @@ +#ifndef __API_MEMMGR_H +#define __API_MEMMGR_H + +#include +#include +#include +class NOVTABLE api_memmgr : public Dispatchable +{ +protected: + api_memmgr() {} + ~api_memmgr() {} + +public: + void *sysMalloc(size_t size); + void sysFree(void *ptr); + void *sysRealloc(void *ptr, size_t newsize); + void sysMemChanged(void *ptr); + + DISPATCH_CODES + { + API_MEMMGR_SYSMALLOC = 0, + API_MEMMGR_SYSFREE = 10, + API_MEMMGR_SYSREALLOC = 20, + API_MEMMGR_SYSMEMCHANGED = 30, + }; + + // Some helper templates to new and delete objects with the memory manager + // you need to be cautious with Delete() and inheritance, particularly if you're dealing with a base class + // as the pointer to the derived class might not equal to the pointer to the base class, particularly with multiple inheritance + // e.g. class C : public A, public B {}; C c; assert((A*)&c == (B*)&c); will likely fail + + template + void New(Class **obj) + { + size_t toAlloc = sizeof(Class); + void *mem = sysMalloc(toAlloc); + *obj = new (mem) Class; + } + + template + void Delete(Class *obj) + { + if (obj) + { + obj->~Class(); + sysFree(obj); + } + } +}; + +inline void *api_memmgr::sysMalloc(size_t size) +{ + return _call(API_MEMMGR_SYSMALLOC, (void *)NULL, size); +} + +inline void api_memmgr::sysFree(void *ptr) +{ + _voidcall(API_MEMMGR_SYSFREE, ptr); +} + +inline void *api_memmgr::sysRealloc(void *ptr, size_t newsize) +{ + return _call(API_MEMMGR_SYSREALLOC, (void *)NULL, ptr, newsize); +} + +inline void api_memmgr::sysMemChanged(void *ptr) +{ + _voidcall(API_MEMMGR_SYSMEMCHANGED, ptr); +} + + +// {000CF46E-4DF6-4a43-BBE7-40E7A3EA02ED} +static const GUID memMgrApiServiceGuid = +{ 0xcf46e, 0x4df6, 0x4a43, { 0xbb, 0xe7, 0x40, 0xe7, 0xa3, 0xea, 0x2, 0xed } }; + +extern api_memmgr *memmgrApi; + +#endif diff --git a/Src/Wasabi/api/metrics/metricscb.h b/Src/Wasabi/api/metrics/metricscb.h new file mode 100644 index 00000000..ca99a384 --- /dev/null +++ b/Src/Wasabi/api/metrics/metricscb.h @@ -0,0 +1,37 @@ +#ifndef _METRICSCB_H +#define _METRICSCB_H + +#include + +// metrics codes +namespace Metric { + enum { + TEXTDELTA=10, + }; +}; + +class MetricsCallback : public Dispatchable { +public: + int setMetric(int metricid, int param1=0, int param2=0); + + // class Dispatchable codes + enum { + SETMETRIC=100, + }; +}; + +inline int MetricsCallback::setMetric(int metricid, int param1, int param2) { + return _call(SETMETRIC, 0, metricid, param1, param2); +} + +class MetricsCallbackI : public MetricsCallback { +public: + virtual int metricscb_setTextDelta(int delta) { return 0; } + +protected: + int mcb_setMetric(int metricid, int param1, int param2); + + RECVS_DISPATCH; +}; + +#endif diff --git a/Src/Wasabi/api/script/api_maki.cpp b/Src/Wasabi/api/script/api_maki.cpp new file mode 100644 index 00000000..a7ef8511 --- /dev/null +++ b/Src/Wasabi/api/script/api_maki.cpp @@ -0,0 +1,12 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Fri Oct 01 02:49:40 1999] +// +// File : api_maki.cpp +// Class : api_maki +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#include +#include "api_maki.h" + + diff --git a/Src/Wasabi/api/script/api_maki.h b/Src/Wasabi/api/script/api_maki.h new file mode 100644 index 00000000..28eb7670 --- /dev/null +++ b/Src/Wasabi/api/script/api_maki.h @@ -0,0 +1,392 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Fri Oct 01 02:49:40 1999] +// +// File : api_maki.h +// Class : api_maki +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#ifndef __API_MAKI_H +#define __API_MAKI_H + +#include + +class ScriptObject; +class ScriptObjectController; + +#include +#include + +// ---------------------------------------------------------------------------- + +class NOVTABLE api_maki: public Dispatchable { + protected: + api_maki() {} + ~api_maki() {} + public: + void maki_pushObject(void *o); + void maki_pushInt(int i); + void maki_pushBoolean(int b); + void maki_pushFloat(float f); + void maki_pushDouble(double d); + void maki_pushString(const wchar_t *s); + void maki_pushVoid(); + void maki_pushAny(scriptVar v); + void *maki_popObject(); + int maki_popInt(); + bool maki_popBoolean(); + float maki_popFloat(); + double maki_popDouble(); + const wchar_t *maki_popString(); + scriptVar maki_popAny(); + void maki_popDiscard(); + const wchar_t *maki_getFunction(int dlfid, int *nparams, ScriptObjectController **p); + int maki_addDlfRef(ScriptObjectController *o, const wchar_t *function_name, void *host); + void maki_addDlfClassRef(ScriptObjectController *o, void *host); + void maki_remDlfRef(void *host); + scriptVar maki_callFunction(ScriptObject *o, int dlfid, scriptVar **params); + scriptVar maki_triggerEvent(ScriptObject *o, int dlfid, int np, int scriptid = -1); + int maki_getScriptInt(scriptVar v); + bool maki_getScriptBoolean(scriptVar v); + float maki_getScriptFloat(scriptVar v); + double maki_getScriptDouble(scriptVar v); + const wchar_t *maki_getScriptString(scriptVar v); + ScriptObject *maki_getScriptObject(scriptVar v); + scriptVar maki_updateDlf(maki_cmd *cmd, int *dlfid, int *linkcount); + ScriptObject *maki_instantiate(GUID classguid); + void maki_destroy(ScriptObject *o); + void *maki_encapsulate(GUID classguid, ScriptObject *o); + void maki_deencapsulate(GUID classguid, void *o); + ScriptObjectController *maki_getController(GUID scriptclass); + int maki_createOrphan(int type); + void maki_killOrphan(int id); + void maki_setObjectAtom(const wchar_t *atomname, ScriptObject *object); + ScriptObject *maki_getObjectAtom(const wchar_t *atomname); + #ifdef WASABI_COMPILE_WND + ScriptObject *maki_findObject(const wchar_t *name); + #endif + void vcpu_addScriptObject(ScriptObject *o); + void vcpu_removeScriptObject(ScriptObject *o); + int vcpu_getCacheCount(); + int vcpu_isValidScriptId(int id); + int vcpu_mapVarId(int varid, int scriptid); + int vcpu_getUserAncestorId(int varid, int scriptid); + int vcpu_getNumEvents(); + int vcpu_getEvent(int event, int *dlf, int *script, int *var); + int vcpu_getComplete(); + void vcpu_setComplete(); + void vcpu_resetComplete(); + const wchar_t *vcpu_getClassName(int vcpuid, int localclassid); + + protected: + enum { + API_MAKI_MAKI_PUSHOBJECT = 10, + API_MAKI_MAKI_PUSHINT = 20, + API_MAKI_MAKI_PUSHBOOLEAN = 30, + API_MAKI_MAKI_PUSHFLOAT = 40, + API_MAKI_MAKI_PUSHDOUBLE = 50, + API_MAKI_MAKI_PUSHSTRING = 60, + API_MAKI_MAKI_PUSHVOID = 70, + API_MAKI_MAKI_PUSHANY = 80, + API_MAKI_MAKI_POPOBJECT = 90, + API_MAKI_MAKI_POPINT = 100, + API_MAKI_MAKI_POPBOOLEAN = 110, + API_MAKI_MAKI_POPFLOAT = 120, + API_MAKI_MAKI_POPDOUBLE = 130, + API_MAKI_MAKI_POPSTRING = 140, + API_MAKI_MAKI_POPANY = 150, + API_MAKI_MAKI_POPDISCARD = 160, + API_MAKI_MAKI_GETFUNCTION = 170, + API_MAKI_MAKI_ADDDLFREF = 180, + API_MAKI_MAKI_ADDDLFCLASSREF = 190, + API_MAKI_MAKI_REMDLFREF = 200, + API_MAKI_MAKI_CALLFUNCTION = 210, + API_MAKI_MAKI_TRIGGEREVENT = 220, + API_MAKI_MAKI_GETSCRIPTINT = 230, + API_MAKI_MAKI_GETSCRIPTBOOLEAN = 240, + API_MAKI_MAKI_GETSCRIPTFLOAT = 250, + API_MAKI_MAKI_GETSCRIPTDOUBLE = 260, + API_MAKI_MAKI_GETSCRIPTSTRING = 270, + API_MAKI_MAKI_GETSCRIPTOBJECT = 280, + API_MAKI_MAKI_UPDATEDLF = 290, + API_MAKI_MAKI_INSTANTIATE = 300, + API_MAKI_MAKI_DESTROY = 310, + API_MAKI_MAKI_ENCAPSULATE = 320, + API_MAKI_MAKI_DEENCAPSULATE = 330, + API_MAKI_MAKI_GETCONTROLLER = 340, + API_MAKI_MAKI_CREATEORPHAN = 350, + API_MAKI_MAKI_KILLORPHAN = 360, + API_MAKI_MAKI_SETOBJECTATOM = 370, + API_MAKI_MAKI_GETOBJECTATOM = 380, + #ifdef WASABI_COMPILE_WND + API_MAKI_MAKI_FINDOBJECT = 390, + #endif + API_MAKI_VCPU_ADDSCRIPTOBJECT = 400, + API_MAKI_VCPU_REMOVESCRIPTOBJECT = 410, + API_MAKI_VCPU_GETCACHECOUNT = 420, + API_MAKI_VCPU_ISVALIDSCRIPTID = 430, + API_MAKI_VCPU_MAPVARID = 440, + API_MAKI_VCPU_GETUSERANCESTORID = 450, + API_MAKI_VCPU_GETNUMEVENTS = 460, + API_MAKI_VCPU_GETEVENT = 470, + API_MAKI_VCPU_GETCOMPLETE = 480, + API_MAKI_VCPU_SETCOMPLETE = 481, + API_MAKI_VCPU_RESETCOMPLETE = 482, + API_MAKI_VCPU_GETCLASSNAME = 490, + }; +}; + +// ---------------------------------------------------------------------------- + +inline void api_maki::maki_pushObject(void *o) { + _voidcall(API_MAKI_MAKI_PUSHOBJECT, o); +} + +inline void api_maki::maki_pushInt(int i) { + _voidcall(API_MAKI_MAKI_PUSHINT, i); +} + +inline void api_maki::maki_pushBoolean(int b) { + _voidcall(API_MAKI_MAKI_PUSHBOOLEAN, b); +} + +inline void api_maki::maki_pushFloat(float f) { + _voidcall(API_MAKI_MAKI_PUSHFLOAT, f); +} + +inline void api_maki::maki_pushDouble(double d) { + _voidcall(API_MAKI_MAKI_PUSHDOUBLE, d); +} + +inline void api_maki::maki_pushString(const wchar_t *s) { + _voidcall(API_MAKI_MAKI_PUSHSTRING, s); +} + +inline void api_maki::maki_pushVoid() { + _voidcall(API_MAKI_MAKI_PUSHVOID); +} + +inline void api_maki::maki_pushAny(scriptVar v) { + _voidcall(API_MAKI_MAKI_PUSHANY, v); +} + +inline void *api_maki::maki_popObject() { + void *__retval = _call(API_MAKI_MAKI_POPOBJECT, (void *)NULL); + return __retval; +} + +inline int api_maki::maki_popInt() { + int __retval = _call(API_MAKI_MAKI_POPINT, (int)0); + return __retval; +} + +inline bool api_maki::maki_popBoolean() { + bool __retval = _call(API_MAKI_MAKI_POPBOOLEAN, (bool)0); + return __retval; +} + +inline float api_maki::maki_popFloat() { + float __retval = _call(API_MAKI_MAKI_POPFLOAT, (float)0); + return __retval; +} + +inline double api_maki::maki_popDouble() { + double __retval = _call(API_MAKI_MAKI_POPDOUBLE, (double)0); + return __retval; +} + +inline const wchar_t *api_maki::maki_popString() { + return _call(API_MAKI_MAKI_POPSTRING, (const wchar_t *)0); + +} + +inline scriptVar api_maki::maki_popAny() +{ + scriptVar r; r.type = SCRIPT_VOID; r.data.idata = 0; + scriptVar __retval = _call(API_MAKI_MAKI_POPANY, (scriptVar)r); + return __retval; +} + +inline void api_maki::maki_popDiscard() { + _voidcall(API_MAKI_MAKI_POPDISCARD); +} + +inline const wchar_t *api_maki::maki_getFunction(int dlfid, int *nparams, ScriptObjectController **p) { + return _call(API_MAKI_MAKI_GETFUNCTION, (const wchar_t *)0, dlfid, nparams, p); + +} + +inline int api_maki::maki_addDlfRef(ScriptObjectController *o, const wchar_t *function_name, void *host) { + int __retval = _call(API_MAKI_MAKI_ADDDLFREF, (int)0, o, function_name, host); + return __retval; +} + +inline void api_maki::maki_addDlfClassRef(ScriptObjectController *o, void *host) { + _voidcall(API_MAKI_MAKI_ADDDLFCLASSREF, o, host); +} + +inline void api_maki::maki_remDlfRef(void *host) { + _voidcall(API_MAKI_MAKI_REMDLFREF, host); +} + +inline scriptVar api_maki::maki_callFunction(ScriptObject *o, int dlfid, scriptVar **params) { + scriptVar r; r.type = SCRIPT_VOID; r.data.idata = 0; + scriptVar __retval = _call(API_MAKI_MAKI_CALLFUNCTION, (scriptVar)r, o, dlfid, params); + return __retval; +} + +inline scriptVar api_maki::maki_triggerEvent(ScriptObject *o, int dlfid, int np, int scriptid) { + scriptVar r; r.type = SCRIPT_VOID; r.data.idata = 0; + scriptVar __retval = _call(API_MAKI_MAKI_TRIGGEREVENT, (scriptVar)r, o, dlfid, np, scriptid); + return __retval; +} + +inline int api_maki::maki_getScriptInt(scriptVar v) { + int __retval = _call(API_MAKI_MAKI_GETSCRIPTINT, (int)0, v); + return __retval; +} + +inline bool api_maki::maki_getScriptBoolean(scriptVar v) { + bool __retval = _call(API_MAKI_MAKI_GETSCRIPTBOOLEAN, (bool)0, v); + return __retval; +} + +inline float api_maki::maki_getScriptFloat(scriptVar v) { + float __retval = _call(API_MAKI_MAKI_GETSCRIPTFLOAT, (float)0, v); + return __retval; +} + +inline double api_maki::maki_getScriptDouble(scriptVar v) { + double __retval = _call(API_MAKI_MAKI_GETSCRIPTDOUBLE, (double)0, v); + return __retval; +} + +inline const wchar_t *api_maki::maki_getScriptString(scriptVar v) { + const wchar_t *__retval = _call(API_MAKI_MAKI_GETSCRIPTSTRING, (const wchar_t *)0, v); + return __retval; +} + +inline ScriptObject *api_maki::maki_getScriptObject(scriptVar v) { + ScriptObject *__retval = _call(API_MAKI_MAKI_GETSCRIPTOBJECT, (ScriptObject *)NULL, v); + return __retval; +} + +inline scriptVar api_maki::maki_updateDlf(maki_cmd *cmd, int *dlfid, int *linkcount) { + scriptVar r; r.type = SCRIPT_VOID; r.data.idata = 0; + scriptVar __retval = _call(API_MAKI_MAKI_UPDATEDLF, (scriptVar)r, cmd, dlfid, linkcount); + return __retval; +} + +inline ScriptObject *api_maki::maki_instantiate(GUID classguid) { + ScriptObject *__retval = _call(API_MAKI_MAKI_INSTANTIATE, (ScriptObject *)NULL, classguid); + return __retval; +} + +inline void api_maki::maki_destroy(ScriptObject *o) { + _voidcall(API_MAKI_MAKI_DESTROY, o); +} + +inline void *api_maki::maki_encapsulate(GUID classguid, ScriptObject *o) { + void *__retval = _call(API_MAKI_MAKI_ENCAPSULATE, (void *)NULL, classguid, o); + return __retval; +} + +inline void api_maki::maki_deencapsulate(GUID classguid, void *o) { + _voidcall(API_MAKI_MAKI_DEENCAPSULATE, classguid, o); +} + +inline ScriptObjectController *api_maki::maki_getController(GUID scriptclass) { + ScriptObjectController *__retval = _call(API_MAKI_MAKI_GETCONTROLLER, (ScriptObjectController *)NULL, scriptclass); + return __retval; +} + +inline int api_maki::maki_createOrphan(int type) { + int __retval = _call(API_MAKI_MAKI_CREATEORPHAN, (int)0, type); + return __retval; +} + +inline void api_maki::maki_killOrphan(int id) { + _voidcall(API_MAKI_MAKI_KILLORPHAN, id); +} + +inline void api_maki::maki_setObjectAtom(const wchar_t *atomname, ScriptObject *object) { + _voidcall(API_MAKI_MAKI_SETOBJECTATOM, atomname, object); +} + +inline ScriptObject *api_maki::maki_getObjectAtom(const wchar_t *atomname) { + ScriptObject *__retval = _call(API_MAKI_MAKI_GETOBJECTATOM, (ScriptObject *)NULL, atomname); + return __retval; +} + +#ifdef WASABI_COMPILE_WND +inline ScriptObject *api_maki::maki_findObject(const wchar_t *name) { + ScriptObject *__retval = _call(API_MAKI_MAKI_FINDOBJECT, (ScriptObject *)NULL, name); + return __retval; +} + +#endif +inline void api_maki::vcpu_addScriptObject(ScriptObject *o) { + _voidcall(API_MAKI_VCPU_ADDSCRIPTOBJECT, o); +} + +inline void api_maki::vcpu_removeScriptObject(ScriptObject *o) { + _voidcall(API_MAKI_VCPU_REMOVESCRIPTOBJECT, o); +} + +inline int api_maki::vcpu_getCacheCount() { + int __retval = _call(API_MAKI_VCPU_GETCACHECOUNT, (int)0); + return __retval; +} + +inline int api_maki::vcpu_isValidScriptId(int id) { + int __retval = _call(API_MAKI_VCPU_ISVALIDSCRIPTID, (int)0, id); + return __retval; +} + +inline int api_maki::vcpu_mapVarId(int varid, int scriptid) { + int __retval = _call(API_MAKI_VCPU_MAPVARID, (int)0, varid, scriptid); + return __retval; +} + +inline int api_maki::vcpu_getUserAncestorId(int varid, int scriptid) { + int __retval = _call(API_MAKI_VCPU_GETUSERANCESTORID, (int)0, varid, scriptid); + return __retval; +} + +inline int api_maki::vcpu_getNumEvents() { + int __retval = _call(API_MAKI_VCPU_GETNUMEVENTS, (int)0); + return __retval; +} + +inline int api_maki::vcpu_getEvent(int event, int *dlf, int *script, int *var) { + int __retval = _call(API_MAKI_VCPU_GETEVENT, (int)0, event, dlf, script, var); + return __retval; +} + +inline int api_maki::vcpu_getComplete() { + int __retval = _call(API_MAKI_VCPU_GETCOMPLETE, (int)0); + return __retval; +} + +inline void api_maki::vcpu_setComplete() { + _voidcall(API_MAKI_VCPU_SETCOMPLETE); +} + +inline void api_maki::vcpu_resetComplete() { + _voidcall(API_MAKI_VCPU_RESETCOMPLETE); +} + +inline const wchar_t *api_maki::vcpu_getClassName(int vcpuid, int localclassid) { + return _call(API_MAKI_VCPU_GETCLASSNAME, (const wchar_t *)0, vcpuid, localclassid); + +} + +// ---------------------------------------------------------------------------- + +// {87D2391B-C928-4a49-8E0B-D47C049E0711} +static const GUID makiApiServiceGuid = +{ 0x87d2391b, 0xc928, 0x4a49, { 0x8e, 0xb, 0xd4, 0x7c, 0x4, 0x9e, 0x7, 0x11 } }; + +extern api_maki *makiApi; + +#endif // __API_MAKI_H diff --git a/Src/Wasabi/api/script/api_makidebug.cpp b/Src/Wasabi/api/script/api_makidebug.cpp new file mode 100644 index 00000000..f356f1f1 --- /dev/null +++ b/Src/Wasabi/api/script/api_makidebug.cpp @@ -0,0 +1,20 @@ +#include "precomp.h" +#include "api_makidebug.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif +#define CBCLASS api_makiDebuggerI +START_DISPATCH; + VCB(API_MAKIDEBUGGER_DEBUGGER_TRACE, debugger_trace); + CB(API_MAKIDEBUGGER_DEBUGGER_ISACTIVE, debugger_isActive); + CB(API_MAKIDEBUGGER_DEBUGGER_GETVIP, debugger_getVIP); + CB(API_MAKIDEBUGGER_DEBUGGER_GETVSD, debugger_getVSD); + CB(API_MAKIDEBUGGER_DEBUGGER_GETVCC, debugger_getVCC); + CB(API_MAKIDEBUGGER_DEBUGGER_GETVSP, debugger_getVSP); + CB(API_MAKIDEBUGGER_DEBUGGER_FILTEREVENT, debugger_filterEvent); + VCB(API_MAKIDEBUGGER_DEBUGGER_EVENTCOMPLETE, debugger_eventComplete); + CB(API_MAKIDEBUGGER_DEBUGGER_CREATEJITD, debugger_createJITD); + CB(API_MAKIDEBUGGER_DEBUGGER_READSTACK, debugger_readStack); + CB(API_MAKIDEBUGGER_DEBUGGER_GETCODEBLOCK, debugger_getCodeBlock); +END_DISPATCH; diff --git a/Src/Wasabi/api/script/api_makidebug.h b/Src/Wasabi/api/script/api_makidebug.h new file mode 100644 index 00000000..c55d130e --- /dev/null +++ b/Src/Wasabi/api/script/api_makidebug.h @@ -0,0 +1,134 @@ +#ifndef __API_MAKIDEBUG_H +#define __API_MAKIDEBUG_H + +/*--------------------------------------------------------- +api_makiDebugger + void debugger_trace(); + int debugger_isActive(); + int debugger_getVIP(); + int debugger_getVSD(); + int debugger_getVCC(); + int debugger_getVSP(); + int debugger_filterEvent(int vcpuid, int eventid); + void debugger_eventComplete(); + MakiJITD *debugger_createJITD(int vcpuid, int bringitup=1); + int debugger_readStack(int n); + int debugger_getCodeBlock(int vcpuid); +---------------------------------------------------------*/ + +#include + +#ifndef WASABI_COMPILE_SCRIPT +#error "This module requires the script api" +#endif + +#ifndef WASABI_COMPILE_MAKIDEBUG +#error "This module requires the script debugger api" +#endif + +#include +#include + +class MakiJITD; + +class NOVTABLE api_makiDebugger : public Dispatchable { + public: + void debugger_trace(); + int debugger_isActive(); + int debugger_getVIP(); + int debugger_getVSD(); + int debugger_getVCC(); + int debugger_getVSP(); + int debugger_filterEvent(int vcpuid, int eventid); + void debugger_eventComplete(); + MakiJITD *debugger_createJITD(int vcpuid, int bringitup=1); + scriptVar debugger_readStack(int n); + const char *debugger_getCodeBlock(int vcpuid); + + enum { + API_MAKIDEBUGGER_DEBUGGER_TRACE = 0, + API_MAKIDEBUGGER_DEBUGGER_ISACTIVE = 10, + API_MAKIDEBUGGER_DEBUGGER_GETVIP = 20, + API_MAKIDEBUGGER_DEBUGGER_GETVSD = 30, + API_MAKIDEBUGGER_DEBUGGER_GETVCC = 40, + API_MAKIDEBUGGER_DEBUGGER_GETVSP = 50, + API_MAKIDEBUGGER_DEBUGGER_FILTEREVENT = 60, + API_MAKIDEBUGGER_DEBUGGER_EVENTCOMPLETE = 70, + API_MAKIDEBUGGER_DEBUGGER_CREATEJITD = 80, + API_MAKIDEBUGGER_DEBUGGER_READSTACK = 90, + API_MAKIDEBUGGER_DEBUGGER_GETCODEBLOCK = 100, + }; +}; + +inline void api_makiDebugger::debugger_trace() { + _voidcall(API_MAKIDEBUGGER_DEBUGGER_TRACE); +} + +inline int api_makiDebugger::debugger_isActive() { + return _call(API_MAKIDEBUGGER_DEBUGGER_ISACTIVE, (int)0); +} + +inline int api_makiDebugger::debugger_getVIP() { + return _call(API_MAKIDEBUGGER_DEBUGGER_GETVIP, (int)0); +} + +inline int api_makiDebugger::debugger_getVSD() { + return _call(API_MAKIDEBUGGER_DEBUGGER_GETVSD, (int)0); +} + +inline int api_makiDebugger::debugger_getVCC() { + return _call(API_MAKIDEBUGGER_DEBUGGER_GETVCC, (int)0); +} + +inline int api_makiDebugger::debugger_getVSP() { + return _call(API_MAKIDEBUGGER_DEBUGGER_GETVSP, (int)0); +} + +inline int api_makiDebugger::debugger_filterEvent(int vcpuid, int eventid) { + return _call(API_MAKIDEBUGGER_DEBUGGER_FILTEREVENT, (int)0, vcpuid, eventid); +} + +inline void api_makiDebugger::debugger_eventComplete() { + _voidcall(API_MAKIDEBUGGER_DEBUGGER_EVENTCOMPLETE); +} + +inline MakiJITD *api_makiDebugger::debugger_createJITD(int vcpuid, int bringitup) { + return _call(API_MAKIDEBUGGER_DEBUGGER_CREATEJITD, (MakiJITD *)NULL, vcpuid, bringitup); +} + +inline const char *api_makiDebugger::debugger_getCodeBlock(int vcpuid) { + return _call(API_MAKIDEBUGGER_DEBUGGER_GETCODEBLOCK, (const char *)NULL, vcpuid); +} + +inline scriptVar api_makiDebugger::debugger_readStack(int n) { + scriptVar v={0,0}; + return _call(API_MAKIDEBUGGER_DEBUGGER_READSTACK, v, n); +} + +class api_makiDebuggerI : public api_makiDebugger { + public: + virtual void debugger_trace()=0; + virtual int debugger_isActive()=0; + virtual int debugger_getVIP()=0; + virtual int debugger_getVSD()=0; + virtual int debugger_getVCC()=0; + virtual int debugger_getVSP()=0; + virtual int debugger_filterEvent(int vcpuid, int eventid)=0; + virtual void debugger_eventComplete()=0; + virtual MakiJITD *debugger_createJITD(int vcpuid, int bringitup=1)=0; + virtual scriptVar debugger_readStack(int n)=0; + virtual const char *debugger_getCodeBlock(int vcpuid)=0; + + protected: + RECVS_DISPATCH; +}; + +// {858E4B64-AF1E-4b64-8D27-EFFAD9F82BB4} +static const GUID makiDebugApiServiceGuid = +{ 0x858e4b64, 0xaf1e, 0x4b64, { 0x8d, 0x27, 0xef, 0xfa, 0xd9, 0xf8, 0x2b, 0xb4 } }; + +extern api_makiDebugger *debugApi; + +#endif + + diff --git a/Src/Wasabi/api/script/api_makii.cpp b/Src/Wasabi/api/script/api_makii.cpp new file mode 100644 index 00000000..37f885e7 --- /dev/null +++ b/Src/Wasabi/api/script/api_makii.cpp @@ -0,0 +1,264 @@ +#include +#include "api_makii.h" + +#include +#include +#include +#include +#include + +api_maki *makiApi = NULL; + +api_makiI::api_makiI() { + VCPU::scriptManager = new ScriptObjectManager(); +} + +api_makiI::~api_makiI() { + delete VCPU::scriptManager; + VCPU::scriptManager = NULL; + VCPU::shutdown(); + ObjectTable::unloadExternalClasses(); +} + +void api_makiI::init() { + ObjectTable::loadExternalClasses(); +} + +void api_makiI::maki_pushObject(void *o) { + VCPU::pushObject(o); +} + +void api_makiI::maki_pushInt(int i) { + VCPU::pushInt(i); +} + +void api_makiI::maki_pushBoolean(int b) { + VCPU::pushBoolean(b); +} + +void api_makiI::maki_pushFloat(float f) { + VCPU::pushFloat(f); +} + +void api_makiI::maki_pushDouble(double d) { + VCPU::pushDouble(d); +} + +void api_makiI::maki_pushString(const wchar_t *s) { + VCPU::pushString(s); +} + +void api_makiI::maki_pushVoid() { + VCPU::pushVoid(); +} + +void api_makiI::maki_pushAny(scriptVar v) { + VCPU::push(v); +} + +void *api_makiI::maki_popObject() { + return VCPU::popObject(); +} + +int api_makiI::maki_popInt() { + return VCPU::popInt(); +} + +bool api_makiI::maki_popBoolean() { + return VCPU::popBoolean(); +} + +float api_makiI::maki_popFloat() { + return VCPU::popFloat(); +} + +double api_makiI::maki_popDouble() { + return VCPU::popDouble(); +} + +const wchar_t *api_makiI::maki_popString() { + return VCPU::popString(); +} + +scriptVar api_makiI::maki_popAny() { + return VCPU::pop().v; +} + +void api_makiI::maki_popDiscard() { + VCPU::popDiscard(); +} + +const wchar_t *api_makiI::maki_getFunction(int dlfid, int *nparams, ScriptObjectController **p) { + return ObjectTable::getFunction(dlfid, nparams, p); +} + +int api_makiI::maki_addDlfRef(ScriptObjectController *o, const wchar_t *function_name, void *host) { + return ObjectTable::dlfAddRef(o, function_name, host); +} + +void api_makiI::maki_addDlfClassRef(ScriptObjectController *o, void *host) { + ObjectTable::dlfAddClassRef(o, host); +} + +void api_makiI::maki_remDlfRef(void *host) { + ObjectTable::dlfRemRef(host); +} + +scriptVar api_makiI::maki_callFunction(ScriptObject *o, int dlfid, scriptVar **params) { + return ObjectTable::callFunction(o, dlfid, params); +} + +scriptVar api_makiI::maki_triggerEvent(ScriptObject *o, int dlfid, int np, int scriptid) { + scriptVar v = MAKE_SCRIPT_OBJECT(o); + return VCPU::executeEvent(v, dlfid, np, scriptid); +} + +int api_makiI::maki_getScriptInt(scriptVar v) { + return SOM::makeInt(&v); +} + +bool api_makiI::maki_getScriptBoolean(scriptVar v) { + return SOM::makeBoolean(&v); +} + +float api_makiI::maki_getScriptFloat(scriptVar v) { + return SOM::makeFloat(&v); +} + +double api_makiI::maki_getScriptDouble(scriptVar v) { + return SOM::makeDouble(&v); +} + +const wchar_t *api_makiI::maki_getScriptString(scriptVar v) +{ + ASSERT(v.type == SCRIPT_STRING); + return v.data.sdata; +} + +ScriptObject *api_makiI::maki_getScriptObject(scriptVar v) { + ASSERT(!SOM::isNumeric(&v) && v.type != SCRIPT_STRING); + return v.data.odata; +} + +scriptVar api_makiI::maki_updateDlf(maki_cmd *cmd, int *dlfid, int *linkcount) { + switch (cmd->cmd) { + case MAKI_CMD_ADDREF: + (*linkcount)++; + break; + case MAKI_CMD_REMREF: + (*linkcount)--; + ASSERT(*linkcount >= 0); + if (*linkcount == 0) + *dlfid = -1; + break; + case MAKI_CMD_SETDLF: + ASSERT(*dlfid == -1); + *dlfid = cmd->id; + break; + case MAKI_CMD_GETDLF: + cmd->id = *dlfid; + break; + case MAKI_CMD_RESETDLF: + *dlfid = -1; + break; + } + RETURN_SCRIPT_VOID +} + +ScriptObject *api_makiI::maki_instantiate(GUID classguid) { + int classid = ObjectTable::getClassFromGuid(classguid); + if (classid == -1) return NULL; + return ObjectTable::instantiate(classid); +} + +void api_makiI::maki_destroy(ScriptObject *o) { + ObjectTable::destroy(o); +} + +void *api_makiI::maki_encapsulate(GUID classguid, ScriptObject *o) { + int classid = ObjectTable::getClassFromGuid(classguid); + if (classid == -1) return NULL; + return ObjectTable::encapsulate(classid, o); +} + +void api_makiI::maki_deencapsulate(GUID classguid, void *o) { + int classid = ObjectTable::getClassFromGuid(classguid); + if (classid == -1) return; + ObjectTable::deencapsulate(classid, o); +} + +ScriptObjectController *api_makiI::maki_getController(GUID scriptclass) { + return ObjectTable::getController(scriptclass); +} + +int api_makiI::maki_createOrphan(int type) { + return VCPU::createOrphan(type); +} + +void api_makiI::maki_killOrphan(int id) { + VCPU::killOrphan(id); +} + +void api_makiI::maki_setObjectAtom(const wchar_t *atomname, ScriptObject *object) { + VCPU::setAtom(atomname, object); +} + +ScriptObject *api_makiI::maki_getObjectAtom(const wchar_t *atomname) { + return VCPU::getAtom(atomname); +} + +#ifdef WASABI_COMPILE_WND +ScriptObject *api_makiI::maki_findObject(const wchar_t *name) +{ + return ScriptObjectManager::findObject(name); +} +#endif + +void api_makiI::vcpu_addScriptObject(ScriptObject *o) { + SystemObject::addScriptObject(o); +} + +void api_makiI::vcpu_removeScriptObject(ScriptObject *o) { + SystemObject::removeScriptObject(o); +} + +int api_makiI::vcpu_getCacheCount() { + return Script::getCacheCount(); +} + +int api_makiI::vcpu_isValidScriptId(int id) { + return Script::isValidScriptId(id); +} + +int api_makiI::vcpu_mapVarId(int varid, int scriptid) { + return Script::varIdToGlobal(varid, scriptid); +} + +int api_makiI::vcpu_getUserAncestorId(int varid, int scriptid) { + return Script::getUserAncestor(varid, scriptid); +} + +int api_makiI::vcpu_getNumEvents() { + return Script::getNumEventsLinked(); +} + +int api_makiI::vcpu_getEvent(int event, int *dlf, int *script, int *var) { + return Script::getLinkedEventParams(event, dlf, script, var); +} + +int api_makiI::vcpu_getComplete() { + return VCPU::getComplete(); +} + +void api_makiI::vcpu_setComplete() { + VCPU::setComplete(); +} + +void api_makiI::vcpu_resetComplete() { + VCPU::resetComplete(); +} + +const wchar_t *api_makiI::vcpu_getClassName(int vcpuid, int localclassid) { + return VCPU::getClassName(vcpuid, localclassid); +} + diff --git a/Src/Wasabi/api/script/api_makii.h b/Src/Wasabi/api/script/api_makii.h new file mode 100644 index 00000000..51fc1320 --- /dev/null +++ b/Src/Wasabi/api/script/api_makii.h @@ -0,0 +1,93 @@ +#ifndef _API_MAKII_H +#define _API_MAKII_H + +/*[interface.header.h] +#include "common/script/scriptvar.h" +#include "common/script/vcputypes.h" +#include "common/script/objcontroller.h" +*/ + +#include "api_maki.h" +#include "api_makix.h" + +class ScriptObject; +class ScriptObjectController; + +class api_makiI : public api_makiX { + public: + api_makiI(); + virtual ~api_makiI(); + DISPATCH(10) virtual void maki_pushObject(void *o); + DISPATCH(20) virtual void maki_pushInt(int i); + DISPATCH(30) virtual void maki_pushBoolean(int b); + DISPATCH(40) virtual void maki_pushFloat(float f); + DISPATCH(50) virtual void maki_pushDouble(double d); + DISPATCH(60) virtual void maki_pushString(const wchar_t *s); + DISPATCH(70) virtual void maki_pushVoid(); + DISPATCH(80) virtual void maki_pushAny(scriptVar v); + DISPATCH(90) virtual void *maki_popObject(); + DISPATCH(100) virtual int maki_popInt(); + DISPATCH(110) virtual bool maki_popBoolean(); + DISPATCH(120) virtual float maki_popFloat(); + DISPATCH(130) virtual double maki_popDouble(); + DISPATCH(140) virtual const wchar_t *maki_popString(); + DISPATCH(150) virtual scriptVar maki_popAny(); + DISPATCH(160) virtual void maki_popDiscard(); + DISPATCH(170) virtual const wchar_t *maki_getFunction(int dlfid, int *nparams, ScriptObjectController **p); + DISPATCH(180) virtual int maki_addDlfRef(ScriptObjectController *o, const wchar_t *function_name, void *host); + DISPATCH(190) virtual void maki_addDlfClassRef(ScriptObjectController *o, void *host); + DISPATCH(200) virtual void maki_remDlfRef(void *host); + DISPATCH(210) virtual scriptVar maki_callFunction(ScriptObject *o, int dlfid, scriptVar **params); + DISPATCH(220) virtual scriptVar maki_triggerEvent(ScriptObject *o, int dlfid, int np, int scriptid = -1); + DISPATCH(230) virtual int maki_getScriptInt(scriptVar v); + DISPATCH(240) virtual bool maki_getScriptBoolean(scriptVar v); + DISPATCH(250) virtual float maki_getScriptFloat(scriptVar v); + DISPATCH(260) virtual double maki_getScriptDouble(scriptVar v); + DISPATCH(270) virtual const wchar_t *maki_getScriptString(scriptVar v); + DISPATCH(280) virtual ScriptObject *maki_getScriptObject(scriptVar v); + DISPATCH(290) virtual scriptVar maki_updateDlf(maki_cmd *cmd, int *dlfid, int *linkcount); + DISPATCH(300) virtual ScriptObject *maki_instantiate(GUID classguid); + DISPATCH(310) virtual void maki_destroy(ScriptObject *o); + DISPATCH(320) virtual void *maki_encapsulate(GUID classguid, ScriptObject *o); + DISPATCH(330) virtual void maki_deencapsulate(GUID classguid, void *o); + DISPATCH(340) virtual ScriptObjectController *maki_getController(GUID scriptclass); + DISPATCH(350) virtual int maki_createOrphan(int type); + DISPATCH(360) virtual void maki_killOrphan(int id); + DISPATCH(370) virtual void maki_setObjectAtom(const wchar_t *atomname, ScriptObject *object); + DISPATCH(380) virtual ScriptObject *maki_getObjectAtom(const wchar_t *atomname); +/*[interface.maki_findObject.cpp]#ifdef WASABI_COMPILE_WND*/ +/*[interface.maki_findObject.h]#ifdef WASABI_COMPILE_WND*/ +/*[dispatchable.maki_findObject.enum]#ifdef WASABI_COMPILE_WND*/ +/*[dispatchable.maki_findObject.bridge]#ifdef WASABI_COMPILE_WND*/ +#ifdef WASABI_COMPILE_WND + DISPATCH(390) virtual ScriptObject *maki_findObject(const wchar_t *name); +#endif +/*[interface.vcpu_addScriptObject.cpp]#endif*/ +/*[interface.vcpu_addScriptObject.h]#endif*/ +/*[dispatchable.vcpu_addScriptObject.enum]#endif*/ +/*[dispatchable.vcpu_addScriptObject.bridge]#endif*/ + DISPATCH(400) virtual void vcpu_addScriptObject(ScriptObject *o); + DISPATCH(410) virtual void vcpu_removeScriptObject(ScriptObject *o); + DISPATCH(420) virtual int vcpu_getCacheCount(); + DISPATCH(430) virtual int vcpu_isValidScriptId(int id); + DISPATCH(440) virtual int vcpu_mapVarId(int varid, int scriptid); + DISPATCH(450) virtual int vcpu_getUserAncestorId(int varid, int scriptid); + DISPATCH(460) virtual int vcpu_getNumEvents(); + DISPATCH(470) virtual int vcpu_getEvent(int event, int *dlf, int *script, int *var); + DISPATCH(480) virtual int vcpu_getComplete(); + DISPATCH(481) virtual void vcpu_setComplete(); + DISPATCH(482) virtual void vcpu_resetComplete(); + DISPATCH(490) virtual const wchar_t *vcpu_getClassName(int vcpuid, int localclassid); + + NODISPATCH void init(); +}; + +/*[interface.footer.h] +// {F2398F09-63B0-4442-86C9-F8BC473F6DA7} +static const GUID makiApiServiceGuid = +{ 0xf2398f09, 0x63b0, 0x4442, { 0x86, 0xc9, 0xf8, 0xbc, 0x47, 0x3f, 0x6d, 0xa7 } }; + +extern api_maki *makiApi; +*/ + +#endif diff --git a/Src/Wasabi/api/script/api_makix.cpp b/Src/Wasabi/api/script/api_makix.cpp new file mode 100644 index 00000000..8d4efdd5 --- /dev/null +++ b/Src/Wasabi/api/script/api_makix.cpp @@ -0,0 +1,72 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Fri Oct 01 02:49:41 1999] +// +// File : api_makix.cpp +// Class : api_maki +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- +#include + +#include "api_makix.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif + +#define CBCLASS api_makiX +START_DISPATCH; + VCB(API_MAKI_MAKI_PUSHOBJECT, maki_pushObject); + VCB(API_MAKI_MAKI_PUSHINT, maki_pushInt); + VCB(API_MAKI_MAKI_PUSHBOOLEAN, maki_pushBoolean); + VCB(API_MAKI_MAKI_PUSHFLOAT, maki_pushFloat); + VCB(API_MAKI_MAKI_PUSHDOUBLE, maki_pushDouble); + VCB(API_MAKI_MAKI_PUSHSTRING, maki_pushString); + VCB(API_MAKI_MAKI_PUSHVOID, maki_pushVoid); + VCB(API_MAKI_MAKI_PUSHANY, maki_pushAny); + CB(API_MAKI_MAKI_POPOBJECT, maki_popObject); + CB(API_MAKI_MAKI_POPINT, maki_popInt); + CB(API_MAKI_MAKI_POPBOOLEAN, maki_popBoolean); + CB(API_MAKI_MAKI_POPFLOAT, maki_popFloat); + CB(API_MAKI_MAKI_POPDOUBLE, maki_popDouble); + CB(API_MAKI_MAKI_POPSTRING, maki_popString); + CB(API_MAKI_MAKI_POPANY, maki_popAny); + VCB(API_MAKI_MAKI_POPDISCARD, maki_popDiscard); + CB(API_MAKI_MAKI_GETFUNCTION, maki_getFunction); + CB(API_MAKI_MAKI_ADDDLFREF, maki_addDlfRef); + VCB(API_MAKI_MAKI_ADDDLFCLASSREF, maki_addDlfClassRef); + VCB(API_MAKI_MAKI_REMDLFREF, maki_remDlfRef); + CB(API_MAKI_MAKI_CALLFUNCTION, maki_callFunction); + CB(API_MAKI_MAKI_TRIGGEREVENT, maki_triggerEvent); + CB(API_MAKI_MAKI_GETSCRIPTINT, maki_getScriptInt); + CB(API_MAKI_MAKI_GETSCRIPTBOOLEAN, maki_getScriptBoolean); + CB(API_MAKI_MAKI_GETSCRIPTFLOAT, maki_getScriptFloat); + CB(API_MAKI_MAKI_GETSCRIPTDOUBLE, maki_getScriptDouble); + CB(API_MAKI_MAKI_GETSCRIPTSTRING, maki_getScriptString); + CB(API_MAKI_MAKI_GETSCRIPTOBJECT, maki_getScriptObject); + CB(API_MAKI_MAKI_UPDATEDLF, maki_updateDlf); + CB(API_MAKI_MAKI_INSTANTIATE, maki_instantiate); + VCB(API_MAKI_MAKI_DESTROY, maki_destroy); + CB(API_MAKI_MAKI_ENCAPSULATE, maki_encapsulate); + VCB(API_MAKI_MAKI_DEENCAPSULATE, maki_deencapsulate); + CB(API_MAKI_MAKI_GETCONTROLLER, maki_getController); + CB(API_MAKI_MAKI_CREATEORPHAN, maki_createOrphan); + VCB(API_MAKI_MAKI_KILLORPHAN, maki_killOrphan); + VCB(API_MAKI_MAKI_SETOBJECTATOM, maki_setObjectAtom); + CB(API_MAKI_MAKI_GETOBJECTATOM, maki_getObjectAtom); + #ifdef WASABI_COMPILE_WND + CB(API_MAKI_MAKI_FINDOBJECT, maki_findObject); + #endif + VCB(API_MAKI_VCPU_ADDSCRIPTOBJECT, vcpu_addScriptObject); + VCB(API_MAKI_VCPU_REMOVESCRIPTOBJECT, vcpu_removeScriptObject); + CB(API_MAKI_VCPU_GETCACHECOUNT, vcpu_getCacheCount); + CB(API_MAKI_VCPU_ISVALIDSCRIPTID, vcpu_isValidScriptId); + CB(API_MAKI_VCPU_MAPVARID, vcpu_mapVarId); + CB(API_MAKI_VCPU_GETUSERANCESTORID, vcpu_getUserAncestorId); + CB(API_MAKI_VCPU_GETNUMEVENTS, vcpu_getNumEvents); + CB(API_MAKI_VCPU_GETEVENT, vcpu_getEvent); + CB(API_MAKI_VCPU_GETCOMPLETE, vcpu_getComplete); + VCB(API_MAKI_VCPU_SETCOMPLETE, vcpu_setComplete); + VCB(API_MAKI_VCPU_RESETCOMPLETE, vcpu_resetComplete); + CB(API_MAKI_VCPU_GETCLASSNAME, vcpu_getClassName); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/script/api_makix.h b/Src/Wasabi/api/script/api_makix.h new file mode 100644 index 00000000..60cf532e --- /dev/null +++ b/Src/Wasabi/api/script/api_makix.h @@ -0,0 +1,81 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Fri Oct 01 02:49:40 1999] +// +// File : api_makix.h +// Class : api_maki +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- + +#ifndef __API_MAKIX_H +#define __API_MAKIX_H + +#include "api_maki.h" + +class ScriptObject; +class ScriptObjectController; + +// ---------------------------------------------------------------------------- + +class api_makiX : public api_maki { + protected: + api_makiX() {} + public: + virtual void maki_pushObject(void *o)=0; + virtual void maki_pushInt(int i)=0; + virtual void maki_pushBoolean(int b)=0; + virtual void maki_pushFloat(float f)=0; + virtual void maki_pushDouble(double d)=0; + virtual void maki_pushString(const wchar_t *s)=0; + virtual void maki_pushVoid()=0; + virtual void maki_pushAny(scriptVar v)=0; + virtual void *maki_popObject()=0; + virtual int maki_popInt()=0; + virtual bool maki_popBoolean()=false; + virtual float maki_popFloat()=0; + virtual double maki_popDouble()=0; + virtual const wchar_t *maki_popString()=0; + virtual scriptVar maki_popAny()=0; + virtual void maki_popDiscard()=0; + virtual const wchar_t *maki_getFunction(int dlfid, int *nparams, ScriptObjectController **p)=0; + virtual int maki_addDlfRef(ScriptObjectController *o, const wchar_t *function_name, void *host)=0; + virtual void maki_addDlfClassRef(ScriptObjectController *o, void *host)=0; + virtual void maki_remDlfRef(void *host)=0; + virtual scriptVar maki_callFunction(ScriptObject *o, int dlfid, scriptVar **params)=0; + virtual scriptVar maki_triggerEvent(ScriptObject *o, int dlfid, int np, int scriptid = -1)=0; + virtual int maki_getScriptInt(scriptVar v)=0; + virtual bool maki_getScriptBoolean(scriptVar v)=false; + virtual float maki_getScriptFloat(scriptVar v)=0; + virtual double maki_getScriptDouble(scriptVar v)=0; + virtual const wchar_t *maki_getScriptString(scriptVar v)=0; + virtual ScriptObject *maki_getScriptObject(scriptVar v)=0; + virtual scriptVar maki_updateDlf(maki_cmd *cmd, int *dlfid, int *linkcount)=0; + virtual ScriptObject *maki_instantiate(GUID classguid)=0; + virtual void maki_destroy(ScriptObject *o)=0; + virtual void *maki_encapsulate(GUID classguid, ScriptObject *o)=0; + virtual void maki_deencapsulate(GUID classguid, void *o)=0; + virtual ScriptObjectController *maki_getController(GUID scriptclass)=0; + virtual int maki_createOrphan(int type)=0; + virtual void maki_killOrphan(int id)=0; + virtual void maki_setObjectAtom(const wchar_t *atomname, ScriptObject *object)=0; + virtual ScriptObject *maki_getObjectAtom(const wchar_t *atomname)=0; + #ifdef WASABI_COMPILE_WND + virtual ScriptObject *maki_findObject(const wchar_t *name)=0; + #endif + virtual void vcpu_addScriptObject(ScriptObject *o)=0; + virtual void vcpu_removeScriptObject(ScriptObject *o)=0; + virtual int vcpu_getCacheCount()=0; + virtual int vcpu_isValidScriptId(int id)=0; + virtual int vcpu_mapVarId(int varid, int scriptid)=0; + virtual int vcpu_getUserAncestorId(int varid, int scriptid)=0; + virtual int vcpu_getNumEvents()=0; + virtual int vcpu_getEvent(int event, int *dlf, int *script, int *var)=0; + virtual int vcpu_getComplete()=0; + virtual void vcpu_setComplete()=0; + virtual void vcpu_resetComplete()=0; + virtual const wchar_t *vcpu_getClassName(int vcpuid, int localclassid)=0; + + protected: + RECVS_DISPATCH; +}; + +#endif // __API_MAKIX_H diff --git a/Src/Wasabi/api/script/debugger/api_makidebug.cpp b/Src/Wasabi/api/script/debugger/api_makidebug.cpp new file mode 100644 index 00000000..af819fd9 --- /dev/null +++ b/Src/Wasabi/api/script/debugger/api_makidebug.cpp @@ -0,0 +1,20 @@ +#include +#include "api_makidebug.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif +#define CBCLASS api_makiDebuggerI +START_DISPATCH; + VCB(API_MAKIDEBUGGER_DEBUGGER_TRACE, debugger_trace); + CB(API_MAKIDEBUGGER_DEBUGGER_ISACTIVE, debugger_isActive); + CB(API_MAKIDEBUGGER_DEBUGGER_GETVIP, debugger_getVIP); + CB(API_MAKIDEBUGGER_DEBUGGER_GETVSD, debugger_getVSD); + CB(API_MAKIDEBUGGER_DEBUGGER_GETVCC, debugger_getVCC); + CB(API_MAKIDEBUGGER_DEBUGGER_GETVSP, debugger_getVSP); + CB(API_MAKIDEBUGGER_DEBUGGER_FILTEREVENT, debugger_filterEvent); + VCB(API_MAKIDEBUGGER_DEBUGGER_EVENTCOMPLETE, debugger_eventComplete); + CB(API_MAKIDEBUGGER_DEBUGGER_CREATEJITD, debugger_createJITD); + CB(API_MAKIDEBUGGER_DEBUGGER_READSTACK, debugger_readStack); + CB(API_MAKIDEBUGGER_DEBUGGER_GETCODEBLOCK, debugger_getCodeBlock); +END_DISPATCH; diff --git a/Src/Wasabi/api/script/debugger/api_makidebug.h b/Src/Wasabi/api/script/debugger/api_makidebug.h new file mode 100644 index 00000000..c55d130e --- /dev/null +++ b/Src/Wasabi/api/script/debugger/api_makidebug.h @@ -0,0 +1,134 @@ +#ifndef __API_MAKIDEBUG_H +#define __API_MAKIDEBUG_H + +/*--------------------------------------------------------- +api_makiDebugger + void debugger_trace(); + int debugger_isActive(); + int debugger_getVIP(); + int debugger_getVSD(); + int debugger_getVCC(); + int debugger_getVSP(); + int debugger_filterEvent(int vcpuid, int eventid); + void debugger_eventComplete(); + MakiJITD *debugger_createJITD(int vcpuid, int bringitup=1); + int debugger_readStack(int n); + int debugger_getCodeBlock(int vcpuid); +---------------------------------------------------------*/ + +#include + +#ifndef WASABI_COMPILE_SCRIPT +#error "This module requires the script api" +#endif + +#ifndef WASABI_COMPILE_MAKIDEBUG +#error "This module requires the script debugger api" +#endif + +#include +#include + +class MakiJITD; + +class NOVTABLE api_makiDebugger : public Dispatchable { + public: + void debugger_trace(); + int debugger_isActive(); + int debugger_getVIP(); + int debugger_getVSD(); + int debugger_getVCC(); + int debugger_getVSP(); + int debugger_filterEvent(int vcpuid, int eventid); + void debugger_eventComplete(); + MakiJITD *debugger_createJITD(int vcpuid, int bringitup=1); + scriptVar debugger_readStack(int n); + const char *debugger_getCodeBlock(int vcpuid); + + enum { + API_MAKIDEBUGGER_DEBUGGER_TRACE = 0, + API_MAKIDEBUGGER_DEBUGGER_ISACTIVE = 10, + API_MAKIDEBUGGER_DEBUGGER_GETVIP = 20, + API_MAKIDEBUGGER_DEBUGGER_GETVSD = 30, + API_MAKIDEBUGGER_DEBUGGER_GETVCC = 40, + API_MAKIDEBUGGER_DEBUGGER_GETVSP = 50, + API_MAKIDEBUGGER_DEBUGGER_FILTEREVENT = 60, + API_MAKIDEBUGGER_DEBUGGER_EVENTCOMPLETE = 70, + API_MAKIDEBUGGER_DEBUGGER_CREATEJITD = 80, + API_MAKIDEBUGGER_DEBUGGER_READSTACK = 90, + API_MAKIDEBUGGER_DEBUGGER_GETCODEBLOCK = 100, + }; +}; + +inline void api_makiDebugger::debugger_trace() { + _voidcall(API_MAKIDEBUGGER_DEBUGGER_TRACE); +} + +inline int api_makiDebugger::debugger_isActive() { + return _call(API_MAKIDEBUGGER_DEBUGGER_ISACTIVE, (int)0); +} + +inline int api_makiDebugger::debugger_getVIP() { + return _call(API_MAKIDEBUGGER_DEBUGGER_GETVIP, (int)0); +} + +inline int api_makiDebugger::debugger_getVSD() { + return _call(API_MAKIDEBUGGER_DEBUGGER_GETVSD, (int)0); +} + +inline int api_makiDebugger::debugger_getVCC() { + return _call(API_MAKIDEBUGGER_DEBUGGER_GETVCC, (int)0); +} + +inline int api_makiDebugger::debugger_getVSP() { + return _call(API_MAKIDEBUGGER_DEBUGGER_GETVSP, (int)0); +} + +inline int api_makiDebugger::debugger_filterEvent(int vcpuid, int eventid) { + return _call(API_MAKIDEBUGGER_DEBUGGER_FILTEREVENT, (int)0, vcpuid, eventid); +} + +inline void api_makiDebugger::debugger_eventComplete() { + _voidcall(API_MAKIDEBUGGER_DEBUGGER_EVENTCOMPLETE); +} + +inline MakiJITD *api_makiDebugger::debugger_createJITD(int vcpuid, int bringitup) { + return _call(API_MAKIDEBUGGER_DEBUGGER_CREATEJITD, (MakiJITD *)NULL, vcpuid, bringitup); +} + +inline const char *api_makiDebugger::debugger_getCodeBlock(int vcpuid) { + return _call(API_MAKIDEBUGGER_DEBUGGER_GETCODEBLOCK, (const char *)NULL, vcpuid); +} + +inline scriptVar api_makiDebugger::debugger_readStack(int n) { + scriptVar v={0,0}; + return _call(API_MAKIDEBUGGER_DEBUGGER_READSTACK, v, n); +} + +class api_makiDebuggerI : public api_makiDebugger { + public: + virtual void debugger_trace()=0; + virtual int debugger_isActive()=0; + virtual int debugger_getVIP()=0; + virtual int debugger_getVSD()=0; + virtual int debugger_getVCC()=0; + virtual int debugger_getVSP()=0; + virtual int debugger_filterEvent(int vcpuid, int eventid)=0; + virtual void debugger_eventComplete()=0; + virtual MakiJITD *debugger_createJITD(int vcpuid, int bringitup=1)=0; + virtual scriptVar debugger_readStack(int n)=0; + virtual const char *debugger_getCodeBlock(int vcpuid)=0; + + protected: + RECVS_DISPATCH; +}; + +// {858E4B64-AF1E-4b64-8D27-EFFAD9F82BB4} +static const GUID makiDebugApiServiceGuid = +{ 0x858e4b64, 0xaf1e, 0x4b64, { 0x8d, 0x27, 0xef, 0xfa, 0xd9, 0xf8, 0x2b, 0xb4 } }; + +extern api_makiDebugger *debugApi; + +#endif + + diff --git a/Src/Wasabi/api/script/debugger/debugapi.cpp b/Src/Wasabi/api/script/debugger/debugapi.cpp new file mode 100644 index 00000000..31ffc9d9 --- /dev/null +++ b/Src/Wasabi/api/script/debugger/debugapi.cpp @@ -0,0 +1,62 @@ +#include +#include +#include +#include + +api_makiDebugger *debugApi = NULL; + +MakiDebuggerApi::MakiDebuggerApi() +{ +} + +MakiDebuggerApi::~MakiDebuggerApi() { + +} + +void MakiDebuggerApi::debugger_trace() { + debugger.trace(); +} + +int MakiDebuggerApi::debugger_isActive() { + return debugger.isActive(); +} + +int MakiDebuggerApi::debugger_getVIP() { + return VCPU::VIP; +} + +int MakiDebuggerApi::debugger_getVSD() { + return VCPU::VSD; +} + +int MakiDebuggerApi::debugger_getVCC() { + return VCPU::VCC; +} + +int MakiDebuggerApi::debugger_getVSP() { + return VCPU::VSP; +} + +int MakiDebuggerApi::debugger_filterEvent(int vcpuid, int eventid) { + return debugger.filterEvent(vcpuid, eventid); +} + +void MakiDebuggerApi::debugger_eventComplete() { + debugger.eventComplete(); +} + +MakiJITD *MakiDebuggerApi::debugger_createJITD(int vcpuid, int bringitup) { + MakiJITD *jitd = debugger.createJITD(vcpuid); + if (bringitup) + jitd->setGlobalBreakpoint(1); + return jitd; +} + +scriptVar MakiDebuggerApi::debugger_readStack(int n) { + VCPUscriptVar v = VCPU::peekAt(n); + return v.v; +} + +const char *MakiDebuggerApi::debugger_getCodeBlock(int vcpuid) { + return VCPU::getCodeBlock(vcpuid); +} diff --git a/Src/Wasabi/api/script/debugger/debugapi.h b/Src/Wasabi/api/script/debugger/debugapi.h new file mode 100644 index 00000000..2b44fa4f --- /dev/null +++ b/Src/Wasabi/api/script/debugger/debugapi.h @@ -0,0 +1,28 @@ +#ifndef __MAKIDEBUGAPI_H +#define __MAKIDEBUGAPI_H + +#include +#include + +class MakiDebuggerApi : public api_makiDebuggerI { + public: + MakiDebuggerApi(); + virtual ~MakiDebuggerApi(); + + virtual void debugger_trace(); + virtual int debugger_isActive(); + virtual int debugger_getVIP(); + virtual int debugger_getVSD(); + virtual int debugger_getVCC(); + virtual int debugger_getVSP(); + virtual int debugger_filterEvent(int vcpuid, int eventid); + virtual void debugger_eventComplete(); + virtual MakiJITD *debugger_createJITD(int vcpuid, int bringitup=1); + virtual scriptVar debugger_readStack(int n); + virtual const char *debugger_getCodeBlock(int vcpuid); + + private: + VCPUDebugger debugger; +}; + +#endif diff --git a/Src/Wasabi/api/script/debugger/debuggerui.cpp b/Src/Wasabi/api/script/debugger/debuggerui.cpp new file mode 100644 index 00000000..692fdeee --- /dev/null +++ b/Src/Wasabi/api/script/debugger/debuggerui.cpp @@ -0,0 +1,11 @@ +#include +#include "debuggerui.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif +#define CBCLASS DebuggerUII +START_DISPATCH; + CB(DEBUGGERUI_MESSAGELOOP, messageLoop); + VCB(DEBUGGERUI_SETJITD, setJITD); +END_DISPATCH; diff --git a/Src/Wasabi/api/script/debugger/debuggerui.h b/Src/Wasabi/api/script/debugger/debuggerui.h new file mode 100644 index 00000000..6138b417 --- /dev/null +++ b/Src/Wasabi/api/script/debugger/debuggerui.h @@ -0,0 +1,42 @@ +#ifndef __DEBUGGERUI_H +#define __DEBUGGERUI_H + +#include + +class MakiJITD; + +/*------------------------------------------- +DebuggerUI + int messageLoop(); + void setJITD(MakiJITD *jitd); +-------------------------------------------*/ + +class DebuggerUI : public Dispatchable { + public: + int messageLoop(); + void setJITD(MakiJITD *jitd); + + enum { + DEBUGGERUI_MESSAGELOOP = 0, + DEBUGGERUI_SETJITD = 10, + }; +}; + +inline int DebuggerUI::messageLoop() { + return _call(DEBUGGERUI_MESSAGELOOP, (int)0); +} + +inline void DebuggerUI::setJITD(MakiJITD *jitd) { + _voidcall(DEBUGGERUI_SETJITD, jitd); +} + +class DebuggerUII : public DebuggerUI { + public: + virtual int messageLoop()=0; + virtual void setJITD(MakiJITD *jitd)=0; + + protected: + RECVS_DISPATCH; +}; + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/script/debugger/debugsymbols.cpp b/Src/Wasabi/api/script/debugger/debugsymbols.cpp new file mode 100644 index 00000000..e3b85980 --- /dev/null +++ b/Src/Wasabi/api/script/debugger/debugsymbols.cpp @@ -0,0 +1,75 @@ +#include +#include "debugsymbols.h" +#include +#include +#include +#include + +DebugSymbols::DebugSymbols(int _vcpuid) : disasm(_vcpuid) +{ + gotsymbols = 0; + SystemObject *so = SOM::getSystemObjectByScriptId(_vcpuid); + if (so != NULL) + binaryfilename = so->getFilename(); + + VCPUcodeBlock *cb = VCPU::getCodeBlockEntry(_vcpuid); + if (cb->debugsize != 0) { + gotsymbols = 1; + char *p = cb->debugsymbols; + int n = *(int *)p; p += 4; + while (n--) { + int s = *(int *)p; p += 4; + wchar_t *m = WMALLOC(s+1); + MEMCPY(m, p, s*sizeof(wchar_t)); + m[s] = 0; + StringW *temp = new StringW; + temp->own(m); + //files.addItem(new String(m)); + files.addItem(temp); + //FREE(m); + p+=s; + } + n = *(int *)p; p += 4; + while (n--) { + SourceCodeLineI *l = new SourceCodeLineI(); + l->setPointer(*(int *)p); p += 4; + l->setSourceFile(files[*(int *)p]->getValue()); p += 4; + l->setSourceFileLine(*(int *)p); p += 4; + SourceCodeLineI *last = lines.getLast(); + if (last != NULL) last->setLength(l->getPointer()-last->getPointer()); + lines.addItem(l); + } + SourceCodeLineI *last = lines.getLast(); + if (last != NULL) last->setLength(cb->size - last->getPointer()); + } +} + +DebugSymbols::~DebugSymbols() +{ + files.deleteAll(); + lines.deleteAll(); +} + +int DebugSymbols::getNumLines() { + if (!gotsymbols) return disasm.getNumLines(); + return lines.getNumItems(); +} + +int DebugSymbols::findLine(int pointer) { + if (!gotsymbols) return disasm.findLine(pointer); + int i; + for (i=0;igetPointer(); + int il = l->getLength(); + if (pointer >= ip && pointer < ip+il) { + return i; + } + } + return -1; +} + +SourceCodeLine *DebugSymbols::enumLine(int n) { + if (!gotsymbols) return disasm.enumLine(n); + return lines.enumItem(n); +} diff --git a/Src/Wasabi/api/script/debugger/debugsymbols.h b/Src/Wasabi/api/script/debugger/debugsymbols.h new file mode 100644 index 00000000..26c23a9c --- /dev/null +++ b/Src/Wasabi/api/script/debugger/debugsymbols.h @@ -0,0 +1,38 @@ +#ifndef __DEBUGSYMBOLS_H +#define __DEBUGSYMBOLS_H + +#include +#include +#include "disasm.h" + +class SourceCodeLine; +class SourceCodeLineI; +class MakiDisassembler; + +class DebugSymbols { + + public: + + DebugSymbols(int vcpuid); + virtual ~DebugSymbols(); + + virtual int getNumLines(); + virtual int findLine(int pointer); + virtual SourceCodeLine *enumLine(int n); + + private: + + PtrList lines; + MakiDisassembler disasm; + StringW binaryfilename; + int gotsymbols; + PtrList files; + //PtrList vars; +}; + + + + + + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/script/debugger/disasm.cpp b/Src/Wasabi/api/script/debugger/disasm.cpp new file mode 100644 index 00000000..7b3c17ee --- /dev/null +++ b/Src/Wasabi/api/script/debugger/disasm.cpp @@ -0,0 +1,193 @@ +#include +#include +#include +#include +#include +// --------------------------------------------------------------------- + +typedef struct { + const wchar_t *opname; + unsigned __int8 opval; + int type; +} opentry; + +opentry _optable[] = { + {L"nop", OPCODE_NOP, OPCODE_TYPE_VOID}, + {L"push", OPCODE_PUSH, OPCODE_TYPE_VAR}, + {L"popi", OPCODE_POPI, OPCODE_TYPE_VOID}, + {L"pop", OPCODE_POP, OPCODE_TYPE_VAR}, + {L"set ", OPCODE_SET, OPCODE_TYPE_VOID}, + {L"retf", OPCODE_RETF, OPCODE_TYPE_VOID}, + {L"call", OPCODE_CALLC, OPCODE_TYPE_PTR}, + {L"call", OPCODE_CALLM, OPCODE_TYPE_DLF}, + {L"call", OPCODE_CALLM2, OPCODE_TYPE_NDLF}, + {L"umv", OPCODE_UMV, OPCODE_TYPE_DISCARD}, + {L"cmpeq", OPCODE_CMPEQ, OPCODE_TYPE_VOID}, + {L"cmpne", OPCODE_CMPNE, OPCODE_TYPE_VOID}, + {L"cmpa", OPCODE_CMPA, OPCODE_TYPE_VOID}, + {L"cmpae", OPCODE_CMPAE, OPCODE_TYPE_VOID}, + {L"cmpb", OPCODE_CMPB, OPCODE_TYPE_VOID}, + {L"cmpbe", OPCODE_CMPBE, OPCODE_TYPE_VOID}, + {L"jiz", OPCODE_JIZ, OPCODE_TYPE_PTR}, + {L"jnz", OPCODE_JNZ, OPCODE_TYPE_PTR}, + {L"jmp", OPCODE_JMP, OPCODE_TYPE_PTR}, + {L"incs", OPCODE_INCS, OPCODE_TYPE_VOID}, + {L"decs", OPCODE_DECS, OPCODE_TYPE_VOID}, + {L"incp", OPCODE_INCP, OPCODE_TYPE_VOID}, + {L"decp", OPCODE_DECP, OPCODE_TYPE_VOID}, + {L"add", OPCODE_ADD, OPCODE_TYPE_VOID}, + {L"sub", OPCODE_SUB, OPCODE_TYPE_VOID}, + {L"mul", OPCODE_MUL, OPCODE_TYPE_VOID}, + {L"div", OPCODE_DIV, OPCODE_TYPE_VOID}, + {L"mod", OPCODE_MOD, OPCODE_TYPE_VOID}, + {L"neg", OPCODE_NEG, OPCODE_TYPE_VOID}, + {L"shl", OPCODE_SHL, OPCODE_TYPE_VOID}, + {L"shr", OPCODE_SHR, OPCODE_TYPE_VOID}, + {L"bnot", OPCODE_BNOT, OPCODE_TYPE_VOID}, + {L"bxor", OPCODE_XOR, OPCODE_TYPE_VOID}, + {L"band", OPCODE_AND, OPCODE_TYPE_VOID}, + {L"bor", OPCODE_OR, OPCODE_TYPE_VOID}, + {L"not", OPCODE_NOT, OPCODE_TYPE_VOID}, + {L"and", OPCODE_LAND, OPCODE_TYPE_VOID}, + {L"or", OPCODE_LOR, OPCODE_TYPE_VOID}, + {L"del", OPCODE_DELETE, OPCODE_TYPE_VOID}, + {L"new", OPCODE_NEW, OPCODE_TYPE_CLASSID}, + {L"cmpl", OPCODE_CMPLT, OPCODE_TYPE_VOID}, +}; + +int MakiDisassembler::optable[256]; +int MakiDisassembler::optableready = 0; + + +MakiDisassembler::MakiDisassembler(int _vcpuid) { + if (!optableready) { + MEMSET(optable, 0, sizeof(optable)); + for (int i=0;igetPointer(); + int il = l->getLength(); + if (pointer >= ip && pointer < ip+il) { + return i; + } + } + return -1; +} + + +void MakiDisassembler::disassemble() { + int size; + const char *codeblock = VCPU::getCodeBlock(vcpuid, &size); + if (codeblock != NULL) { + + const char *p = codeblock; + + unsigned char opcode = OPCODE_NOP; + + while (p < codeblock+size) { + const char *start_of_instruction = p; + opcode = *p; + p+=sizeof(opcode); + + StringW inst; + int a = optable[opcode]; + int id; + int size = 0; + inst = _optable[a].opname; + switch (_optable[a].type) { + case OPCODE_TYPE_VOID: + size = 1; + break; + case OPCODE_TYPE_VAR: + id = *(int *)p; p+=sizeof(int); + inst += StringPrintfW(L" var %08X", id); + size = 5; + break; + case OPCODE_TYPE_PTR: + id = *(int *)p; p+=sizeof(int); + inst += StringPrintfW(L" %08X", id+(p-codeblock)); + size = 5; + break; + case OPCODE_TYPE_DLF: { + id = *(int *)p; p+=sizeof(int); + int np = *(int *)p; + if ((np & 0xFFFF0000) == 0xFFFF0000) { + p+=sizeof(int); + np &= 0xFFFF; + } else + np = -1; + int i = VCPU::dlfBase(vcpuid)+id; + if (i != -1) { + VCPUdlfEntry *e = VCPU::DLFentryTable.enumItem(i); + if (e != NULL) { + if (np != -1) inst += StringPrintfW(L"(%d)", np); + inst += L" "; + inst += e->functionName; + } + } + size = 5 + ((np == -1) ? 0 : 4); + break; + } + case OPCODE_TYPE_NDLF: { + id = *(int *)p; p+=sizeof(int); + int np = *p; p++; + int i = VCPU::dlfBase(vcpuid)+id; + if (i != -1) { + VCPUdlfEntry *e = VCPU::DLFentryTable.enumItem(i); + if (e != NULL) { + inst += StringPrintfW(L"(%d) ", np); + inst += e->functionName; + } + } + size = 6; + break; + } + case OPCODE_TYPE_CLASSID: { + id = *(int *)p; p+=sizeof(int); + const wchar_t *cn = WASABI_API_MAKI->vcpu_getClassName(vcpuid, id); + inst += L" "; + inst += cn; + size = 5; + break; + } + case OPCODE_TYPE_DISCARD: + id = *(int *)p; p+=sizeof(int); + size = 5; + break; + } + SourceCodeLineI *scl = new SourceCodeLineI(); + scl->setLine(inst), + scl->setPointer(start_of_instruction-codeblock); + scl->setLength(size); + lines.addItem(scl); + } + } +} + diff --git a/Src/Wasabi/api/script/debugger/disasm.h b/Src/Wasabi/api/script/debugger/disasm.h new file mode 100644 index 00000000..2d8d3c71 --- /dev/null +++ b/Src/Wasabi/api/script/debugger/disasm.h @@ -0,0 +1,38 @@ +#ifndef __MakiDisassembler_H +#define __MakiDisassembler_H + +#include + +class SourceCodeLine; +class SourceCodeLineI; + +enum { + OPCODE_TYPE_VOID = 0, + OPCODE_TYPE_VAR, + OPCODE_TYPE_PTR, + OPCODE_TYPE_DLF, + OPCODE_TYPE_NDLF, + OPCODE_TYPE_CLASSID, + OPCODE_TYPE_DISCARD, +}; + +class MakiDisassembler { + public: + MakiDisassembler(int vcpuid); + virtual ~MakiDisassembler(); + + int getVCPUId(); + int getNumLines(); + SourceCodeLine *enumLine(int n); + int findLine(int pointer); + + private: + void disassemble(); + PtrList lines; + int vcpuid; + static int optable[256]; + static int optableready; +}; + + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/script/debugger/jitd.cpp b/Src/Wasabi/api/script/debugger/jitd.cpp new file mode 100644 index 00000000..62bfa731 --- /dev/null +++ b/Src/Wasabi/api/script/debugger/jitd.cpp @@ -0,0 +1,176 @@ +#include +#include "jitd.h" +#include "jitdbreak.h" +#include +#include +#include +#include +#include +#include + +MakiJITD::MakiJITD(VCPUDebugger *_debugger, int _vcpuid) { + vip = vsp = vsd = vcc = -1; + globalbreakpoint = 1; // fucko!! + onhold = 0; + debugger = _debugger; + vcpuid = _vcpuid; + uisvc = NULL; + ui = NULL; + simpleui = NULL; + codeblock = _debugger->getCodeBlock(vcpuid); + sysbp = new JITDBreakpoint(this, 0); + breakpoints.addItem(sysbp); + sysbp->setEnabled(0); + symbols = new DebugSymbols(_vcpuid); +} + +MakiJITD::~MakiJITD() { + breakpoints.deleteAll(); + if (uisvc != NULL) { + uisvc->destroyUI(ui); + WASABI_API_SVC->service_release(uisvc); + } + delete simpleui; + delete symbols; +} + +int MakiJITD::getVIP() { + return vip; +} + +int MakiJITD::getVCC() { + return vcc; +} + +int MakiJITD::getVSD() { + return vsd; +} + +int MakiJITD::getVSP() { + return vsp; +} + +int MakiJITD::isGlobalBreakpointSet() { + return globalbreakpoint; +} + +void MakiJITD::setGlobalBreakpoint(int s) { + globalbreakpoint = s; +} + +int MakiJITD::getNumBreakpoints() { + return breakpoints.getNumItems(); +} + +JITDBreakpoint *MakiJITD::enumBreakpoint(int n) { + return breakpoints.enumItem(n); +} + +JITDBreakpoint *MakiJITD::findBreakpoint(int pointer) { + int i; + for (i=0;iisEnabled() && bp->getPointer() == pointer) + return bp; + } + return NULL; +} + +void MakiJITD::addBreakpoint(int pointer) { + breakpoints.addItem(new JITDBreakpoint(this, pointer)); +} + +void MakiJITD::removeBreakpoint(JITDBreakpoint *breakpoint) { + breakpoints.removeItem(breakpoint); + delete breakpoint; +} + +void MakiJITD::clearAllBreakpoints() { + breakpoints.deleteAll(); +} + +int MakiJITD::getVCPUId() { + return vcpuid; +} + +void MakiJITD::trace() { + vip = debugger->getVIP(); + vsp = debugger->getVSP(); + vsd = debugger->getVSD(); + vcc = debugger->getVCC(); + + if (globalbreakpoint || findBreakpoint(vip)) { + enterUi(); + } +} + +int MakiJITD::isActive() { + return 1; +} + +void MakiJITD::enterUi() { + createUi(); + sysbp->setEnabled(0); + globalbreakpoint = 0; + onhold = 1; + int next_command = ui->messageLoop(); + onhold = 0; + switch (next_command) { + case JITD_RETURN_STEPINTO: + globalbreakpoint = 1; + break; + case JITD_RETURN_STEPOUT: + // for now, continue + break; + case JITD_RETURN_TERMINATE: + // for now, continue + break; + case JITD_RETURN_CONTINUE: + // do nothing + default: + break; + } +} + +void MakiJITD::createUi() { + if (ui != NULL) return; + waServiceFactory *f = WASABI_API_SVC->service_getServiceByGuid(SERVICE_DEBUGGERUI); + if (f != NULL) { + uisvc = castService(f); + if (uisvc != NULL) { + ui = uisvc->createUI(); + ui->setJITD(this); + } + } else { + simpleui = new SimpleDebuggerUI(); + ui = simpleui; + ui->setJITD(this); + } +} + +int MakiJITD::isOnHold() { + return onhold; +} + +const char *MakiJITD::getCodeBlock() { + return codeblock; +} + +void MakiJITD::setSysBreakpoint(int pointer) { + sysbp->setPointer(pointer); + sysbp->setEnabled(1); +} + +int MakiJITD::getNumLines() { + return symbols->getNumLines(); +} + +SourceCodeLine *MakiJITD::enumLine(int n) { + return symbols->enumLine(n); +} + +int MakiJITD::findLine(int pointer) { + return symbols->findLine(pointer); +} + + diff --git a/Src/Wasabi/api/script/debugger/jitd.h b/Src/Wasabi/api/script/debugger/jitd.h new file mode 100644 index 00000000..6cb41f72 --- /dev/null +++ b/Src/Wasabi/api/script/debugger/jitd.h @@ -0,0 +1,71 @@ +#ifndef __MAKIJITD_H +#define __MAKIJITD_H + +#include + +class JITDBreakpoint; +class VCPUDebugger; +class svc_debuggerUI; +class SimpleDebuggerUI; +class DebuggerUI; +class DebugSymbols; +class SourceCodeLine; + +enum { + JITD_RETURN_STEPINTO = 0, + JITD_RETURN_STEPOVER = 1, + JITD_RETURN_STEPOUT = 2, + JITD_RETURN_TERMINATE = 3, + JITD_RETURN_CONTINUE = 4, +}; + +class MakiJITD { // dispatch me! + public: + MakiJITD(VCPUDebugger *debugger, int vcpuid); + virtual ~MakiJITD(); + + int getNumBreakpoints(); + JITDBreakpoint *enumBreakpoint(int n); + JITDBreakpoint *findBreakpoint(int pointer); + void addBreakpoint(int pointer); + void removeBreakpoint(JITDBreakpoint *breakpoint); + void clearAllBreakpoints(); + int isGlobalBreakpointSet(); + void setGlobalBreakpoint(int s); + void setSysBreakpoint(int pointer); // deactivates automatically next time the debugger is activated + int getVCPUId(); + void trace(); + int isActive(); + int isOnHold(); // 1 if running in the jitd's message loop + + int getVIP(); + int getVSD(); + int getVCC(); + int getVSP(); + + const char *getCodeBlock(); + + virtual int findLine(int pointer); + virtual int getNumLines(); + virtual SourceCodeLine *enumLine(int n); + + private: + void createUi(); + void enterUi(); + + int vcpuid; + int vip, vsd, vcc, vsp; + int globalbreakpoint; + + PtrList breakpoints; + VCPUDebugger *debugger; + svc_debuggerUI *uisvc; + DebuggerUI *ui; + SimpleDebuggerUI *simpleui; + int onhold; + const char *codeblock; + JITDBreakpoint *sysbp; + DebugSymbols *symbols; +}; + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/script/debugger/jitdbreak.cpp b/Src/Wasabi/api/script/debugger/jitdbreak.cpp new file mode 100644 index 00000000..4d12d3fe --- /dev/null +++ b/Src/Wasabi/api/script/debugger/jitdbreak.cpp @@ -0,0 +1,27 @@ +#include "precomp.h" +#include "jitdbreak.h" + +JITDBreakpoint::JITDBreakpoint(MakiJITD *_jitd, int _pointer) { + jitd = _jitd; + pointer = _pointer; + enabled = 1; +} + +JITDBreakpoint::~JITDBreakpoint() { +} + +int JITDBreakpoint::getPointer() { + return pointer; +} + +void JITDBreakpoint::setEnabled(int e) { + enabled = e; +} + +int JITDBreakpoint::isEnabled() { + return enabled; +} + +void JITDBreakpoint::setPointer(int _pointer) { + pointer = _pointer; +} \ No newline at end of file diff --git a/Src/Wasabi/api/script/debugger/jitdbreak.h b/Src/Wasabi/api/script/debugger/jitdbreak.h new file mode 100644 index 00000000..960e83b6 --- /dev/null +++ b/Src/Wasabi/api/script/debugger/jitdbreak.h @@ -0,0 +1,22 @@ +#ifndef __JITDBREAKPOINT_H +#define __JITDBREAKPOINT_H + +class MakiJITD; + +class JITDBreakpoint { + public: + JITDBreakpoint(MakiJITD *jitd, int pointer); + virtual ~JITDBreakpoint(); + + virtual int getPointer(); + virtual void setPointer(int pointer); + virtual void setEnabled(int e); + virtual int isEnabled(); + + private: + MakiJITD *jitd; + int pointer; + int enabled; +}; + +#endif diff --git a/Src/Wasabi/api/script/debugger/sdebuggerui.cpp b/Src/Wasabi/api/script/debugger/sdebuggerui.cpp new file mode 100644 index 00000000..c8349b05 --- /dev/null +++ b/Src/Wasabi/api/script/debugger/sdebuggerui.cpp @@ -0,0 +1,437 @@ +#include +#include "sdebuggerui.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../nu/AutoWide.h" + +#define LEFTCOLUMN 100 +#define RIGHTCOLUMN 200 +#define INPUTHEIGHT 21 +#define NCONSOLELINES 4 +#define LINEHEIGHT 14 +#define REGWIDTH 100 + +SimpleDebuggerUI::SimpleDebuggerUI() +{ + leave = 0; + jitd = NULL; + edit = NULL; + memset(cmdbuf, 0, sizeof(cmdbuf)); + retcode = JITD_RETURN_CONTINUE; +} + +SimpleDebuggerUI::~SimpleDebuggerUI() +{} + +void SimpleDebuggerUI::setJITD(MakiJITD *_jitd) +{ + jitd = _jitd; +} + +int SimpleDebuggerUI::messageLoop() +{ + leave = 0; + retcode = JITD_RETURN_STEPINTO; + + if (!isInited()) + { + setVirtual(0); + setStartHidden(1); + setParent(WASABI_API_WND->main_getRootWnd()); + init(WASABI_API_WND->main_getRootWnd(), 1); + + edit = new EditWnd; + edit->setParent(this); + edit->setBackgroundColor(RGB(0, 0, 0)); + edit->setTextColor(RGB(0, 255, 0)); + edit->setWantFocus(0); + + *cmdbuf = 0; + edit->setBuffer(cmdbuf, 256); + edit->init(this); + + RECT r; + POINT pt = {0, 0}; + Wasabi::Std::getViewport(&r, &pt); + resize(r.right - 656, r.top + 16, 640, 480); + bringToFront(); + } + + for (int s = 0;s < jitd->getVSP();s++) + { + scriptVar v = WASABI_API_MAKIDEBUG->debugger_readStack(s); + StringW str; + switch (v.type) + { + case SCRIPT_VOID: + str = L"NULL"; + break; + case SCRIPT_INT: + str = StringPrintfW(L"%d", GET_SCRIPT_INT(v)); + break; + case SCRIPT_BOOLEAN: + str = StringPrintfW(L"%s", GET_SCRIPT_BOOLEAN(v) ? L"true" : L"false"); + break; + case SCRIPT_FLOAT: + str = StringPrintfW(L"%f", GET_SCRIPT_FLOAT(v)); + break; + case SCRIPT_DOUBLE: + str = StringPrintfW(L"%f", (float)GET_SCRIPT_DOUBLE(v)); + break; + case SCRIPT_STRING: + str = GET_SCRIPT_STRING(v); + break; + default: + { + if (v.type == SCRIPT_OBJECT) + str = L"Object"; + else + str = ObjectTable::getClassName(v.type); +#ifdef WASABI_COMPILE_SKIN + ScriptObject *o = GET_SCRIPT_OBJECT(v); + if (o != NULL) + { + GuiObject *go = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (go != NULL) + { + str += L";"; + str.cat(go->guiobject_getId()); + } + } +#endif + break; + } + } + strstack.addItem(new StringW(str)); + } + + setVisible(1); + + //WASABI_API_WND->pushModalWnd(this); + +#ifdef WIN32 + MSG msg; + //DWORD leavetime = GetTickCount()+5; + while (!leave/* && !(GetTickCount() >leavetime)*/) + { + if (PeekMessage(&msg, /*(HWND)NULL*/ getOsWindowHandle(), 0, 0, PM_NOREMOVE)) + { + GetMessage(&msg, /*(HWND) NULL*/getOsWindowHandle(), 0, 0) && + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } +#endif + + //WASABI_API_WND->popModalWnd(this); + + setVisible(0); + strstack.deleteAll(); + + return retcode; +} + +int SimpleDebuggerUI::onPaint(Canvas *c) +{ + SimpleDebuggerUI_PARENT::onPaint(c); + Wasabi::FontInfo fontInfo; + RECT r; + getClientRect(&r); + c->fillRect(&r, RGB(0, 0, 0)); + c->drawRect(&r, 1, RGB(0, 255, 0)); + + fontInfo.color = RGB(0, 255, 0); + fontInfo.pointSize = 14; + fontInfo.face = L"Courier New"; + c->pushPen(PENSTYLE_SOLID, 1, RGB(0, 255, 0)); + c->textOut(r.right - REGWIDTH + 7, r.bottom - (INPUTHEIGHT + (NCONSOLELINES*LINEHEIGHT) + 2) + 8, StringPrintfW(L"VSD:%08X", jitd->getVSD()), &fontInfo); + c->textOut(r.right - REGWIDTH + 7, r.bottom - (INPUTHEIGHT + (NCONSOLELINES*LINEHEIGHT) + 2) + 8 + (LINEHEIGHT + 1), StringPrintfW(L"VIP:%08X", jitd->getVIP()), &fontInfo); + c->textOut(r.right - REGWIDTH + 7, r.bottom - (INPUTHEIGHT + (NCONSOLELINES*LINEHEIGHT) + 2) + 8 + (LINEHEIGHT + 1)*2, StringPrintfW(L"VSP:%08X", jitd->getVSP()), &fontInfo); + c->textOut(r.right - REGWIDTH + 7, r.bottom - (INPUTHEIGHT + (NCONSOLELINES*LINEHEIGHT) + 2) + 8 + (LINEHEIGHT + 1)*3, StringPrintfW(L"VCC:%08X", jitd->getVCC()), &fontInfo); + c->lineDraw(r.left, r.bottom - (INPUTHEIGHT + (NCONSOLELINES*LINEHEIGHT) + 2), r.right, r.bottom - (INPUTHEIGHT + (NCONSOLELINES*LINEHEIGHT) + 2)); + c->lineDraw(r.left, r.bottom - (INPUTHEIGHT + 2), r.right - REGWIDTH, r.bottom - (INPUTHEIGHT + 2)); + c->lineDraw(r.right - REGWIDTH, r.bottom - (INPUTHEIGHT + (NCONSOLELINES*LINEHEIGHT) + 2), r.right - REGWIDTH, r.bottom); + c->lineDraw(r.right - RIGHTCOLUMN, 0, r.right - RIGHTCOLUMN, r.bottom - (INPUTHEIGHT + (NCONSOLELINES*LINEHEIGHT) + 2)); + disassemble(c); + for (int s = 0;s < strstack.getNumItems();s++) + { + c->textOutEllipsed(r.right - RIGHTCOLUMN + 4, s*LINEHEIGHT + 4, RIGHTCOLUMN - 8, 16, strstack.enumItem(s)->getValue(), &fontInfo); + } + return 1; +} + +int SimpleDebuggerUI::onLeftButtonDown(int x, int y) +{ + SimpleDebuggerUI_PARENT::onLeftButtonDown(x, y); + if (edit) edit->onGetFocus(); +// leave = 1; + return 1; +} + +void SimpleDebuggerUI::disassemble(Canvas *c) +{ + RECT r; + getClientRect(&r); + int x = 4; + + int y = (r.bottom - r.top - 4) / 2 + 4; + + int ln = jitd->findLine(jitd->getVIP()); + if (ln != -1) + { + Wasabi::FontInfo fontInfo; + SourceCodeLine *l = jitd->enumLine(ln); + int sourcecode = l->getSourceFile() != NULL; + int g; + int j = 0; + for (g = y;g < r.bottom - (INPUTHEIGHT + 4 + (NCONSOLELINES*LINEHEIGHT)) - LINEHEIGHT;g += LINEHEIGHT) + { + if (!sourcecode || j == 0) + l = jitd->enumLine(ln + j); + if (!l) break; + + if (j == 0) + { + RECT br; + br.left = 4; + br.top = g; + br.right = r.right - (RIGHTCOLUMN + 4); + br.bottom = br.top + LINEHEIGHT; + c->fillRect(&br, RGB(0, 255, 0)); + fontInfo.color = RGB(0, 0, 0); + } + if (!sourcecode) + { + String str; + unsigned const char *d = (unsigned const char *)(l->getPointer() + jitd->getCodeBlock()); + for (int k = 0;k < l->getLength();k++) + { + if (!str.isempty()) str += " "; + str += StringPrintf("%02X", *d); + d++; + } + c->textOut(x, g, StringPrintfW(L"%08X", l->getPointer()), &fontInfo); + c->textOut(x + 70, g, AutoWide(str), &fontInfo); + c->textOut(x + 70 + 150, g, l->getLine(), &fontInfo); + } + else + { + c->textOutEllipsed(x, g, r.right - r.left - (RIGHTCOLUMN + 4 + x), 16, (getLine(l->getSourceFile(), l->getSourceFileLine() + j)), &fontInfo); + } + + j++; + } + j = 1; + for (g = y - LINEHEIGHT;g > 1;g -= LINEHEIGHT) + { + if (!sourcecode || j == 0) + l = jitd->enumLine(ln - j); + if (!l) break; + if (!sourcecode) + { + String str; + unsigned const char *d = (unsigned const char *)(l->getPointer() + jitd->getCodeBlock()); + for (int k = 0;k < l->getLength();k++) + { + if (!str.isempty()) str += " "; + str += StringPrintf("%02X", *d); + d++; + } + c->textOut(x, g, StringPrintfW(L"%08X", l->getPointer()), &fontInfo); + c->textOut(x + 70, g, AutoWide(str), &fontInfo); + c->textOut(x + 70 + 150, g, (l->getLine()), &fontInfo); + } + else + { + c->textOutEllipsed(x, g, r.right - r.left - (RIGHTCOLUMN + 4 + x), 16, (getLine(l->getSourceFile(), l->getSourceFileLine() - j)), &fontInfo); + } + j++; + } + } +} + +int SimpleDebuggerUI::onResize() +{ + SimpleDebuggerUI_PARENT::onResize(); + if (edit != NULL) + { + RECT r; + getClientRect(&r); + edit->resize(1, r.bottom - (INPUTHEIGHT + 1), r.right - r.left - (REGWIDTH + 1), INPUTHEIGHT); + } + return 1; +} + +int SimpleDebuggerUI::childNotify(ifc_window *child, int msg, intptr_t p1, intptr_t p2) +{ + if (child == edit) + { + if (msg == ChildNotify::EDITWND_ENTER_PRESSED) + { + onCommand(cmdbuf); + } + } + return SimpleDebuggerUI_PARENT::childNotify(child, msg, p1, p2); +} + +BEGIN_STRINGDICTIONARY(_debuggercommands) +SDI(L"b", DEBUG_CMD_BREAKPOINT); +SDI(L"break", DEBUG_CMD_BREAKPOINT); +SDI(L"x", DEBUG_CMD_CONTINUE); +SDI(L"continue", DEBUG_CMD_CONTINUE); +SDI(L"i", DEBUG_CMD_STEPINTO); +SDI(L"stepinto", DEBUG_CMD_STEPINTO); +SDI(L"o", DEBUG_CMD_STEPOVER); +SDI(L"stepover", DEBUG_CMD_STEPOVER); +SDI(L"p", DEBUG_CMD_STEPOUT); +SDI(L"stepout", DEBUG_CMD_STEPOUT); +SDI(L"k", DEBUG_CMD_KILL); +SDI(L"kill", DEBUG_CMD_KILL); +SDI(L"?", DEBUG_CMD_HELP); +SDI(L"help", DEBUG_CMD_HELP); +END_STRINGDICTIONARY(_debuggercommands, debuggercommands) + + +void SimpleDebuggerUI::onCommand(const wchar_t *cmd) +{ + if (*cmd == 0) + { + stepOver(); + return; + } + ParamParser pp(cmd, L" "); + int i = debuggercommands.getId(pp.enumItem(0)); + switch (i) + { + case DEBUG_CMD_BREAKPOINT: + addBreakPoint(pp.enumItem(1)); + break; + case DEBUG_CMD_CONTINUE: + continueExecution(); + break; + case DEBUG_CMD_STEPINTO: + stepInto(); + break; + case DEBUG_CMD_STEPOVER: + stepOver(); + break; + case DEBUG_CMD_KILL: + killScript(); + break; + case DEBUG_CMD_HELP: + showHelp(); + break; + } +} + +int SimpleDebuggerUI::evaluate(const wchar_t *ascii) +{ + if (!_wcsicmp(ascii, L"VSD")) return jitd->getVSD(); + if (!_wcsicmp(ascii, L"VIP")) return jitd->getVIP(); + if (!_wcsicmp(ascii, L"VSP")) return jitd->getVSP(); + if (!_wcsicmp(ascii, L"VCC")) return jitd->getVCC(); + wchar_t *end; + return wcstol(ascii, &end, 16); +} + +void SimpleDebuggerUI::addBreakPoint(const wchar_t *pointer_ascii) +{ + /*int i = */evaluate(pointer_ascii); +} + +void SimpleDebuggerUI::continueExecution() +{ + retcode = JITD_RETURN_CONTINUE; + leave = 1; +} + +void SimpleDebuggerUI::stepInto() +{ + retcode = JITD_RETURN_STEPINTO; + leave = 1; +} + +void SimpleDebuggerUI::stepOver() +{ + int ln = jitd->findLine(jitd->getVIP()); + ln++; + SourceCodeLine *l = jitd->enumLine(ln); + + if (l != NULL) // else ret as last opcode + jitd->setSysBreakpoint(l->getPointer()); + + retcode = JITD_RETURN_CONTINUE; + leave = 1; +} + +void SimpleDebuggerUI::killScript() +{ + retcode = JITD_RETURN_TERMINATE; + leave = 1; +} + +void SimpleDebuggerUI::showHelp() +{} + +int SimpleDebuggerUI::onGetFocus() +{ + SimpleDebuggerUI_PARENT::onGetFocus(); + if (edit) edit->onGetFocus(); + return 1; +} + +void SimpleDebuggerUI::onSetVisible(int show) +{ + SimpleDebuggerUI_PARENT::onSetVisible(show); + if (edit) edit->onGetFocus(); +} +#undef fgets +const wchar_t *SimpleDebuggerUI::getLine(const wchar_t *filename, int fileline) +{ + if (fileline <= 0) + return L""; + static StringW str; + FILE *f = _wfopen(filename, L"rt"); + if (!f) + { + str = L"couldn't load "; + str += filename; + return str; + } + + char t[256] = {0}; + char u[256] = {0}; + int n = fileline; + while (n--) + { + *u = 0; + char *p; + do + { + p = *u ? t : u; + fgets(p, 255, f); + t[255] = 0; + } + while (!feof(f) && p[STRLEN(p)-1] != '\n' && p[STRLEN(p)-1] != '\r'); + } + + char *p = u; + while (p && *p && p < u + 256) + { + if (*p < 0x21) *p = ' '; + p++; + } + + str = AutoWide(u, CP_UTF8); + fclose(f); + + return str; +} + diff --git a/Src/Wasabi/api/script/debugger/sdebuggerui.h b/Src/Wasabi/api/script/debugger/sdebuggerui.h new file mode 100644 index 00000000..39f73ee5 --- /dev/null +++ b/Src/Wasabi/api/script/debugger/sdebuggerui.h @@ -0,0 +1,65 @@ +#ifndef __SIMPLEDEBUGGERUI_H +#define __SIMPLEDEBUGGERUI_H + +#include "debuggerui.h" +#include + +class MakiDisassembler; +class EditWnd; +class String; +class SourceCodeLine; + +#define SimpleDebuggerUI_PARENT ClickWnd + +enum { + DEBUG_CMD_BREAKPOINT = 0, + DEBUG_CMD_CONTINUE, + DEBUG_CMD_STEPINTO, + DEBUG_CMD_STEPOVER, + DEBUG_CMD_STEPOUT, + DEBUG_CMD_KILL, + DEBUG_CMD_HELP, +}; + + +class MakiJITD; + +class SimpleDebuggerUI : public SimpleDebuggerUI_PARENT, public DebuggerUII { + public: + SimpleDebuggerUI(); + virtual ~SimpleDebuggerUI(); + + virtual int onPaint(Canvas *c); + virtual int onLeftButtonDown(int x, int y); + virtual int onResize(); + virtual int childNotify(ifc_window *child, int msg, intptr_t p1, intptr_t p2); + virtual void onSetVisible(int show); + + virtual int messageLoop(); + virtual void setJITD(MakiJITD *jitd); + + virtual void disassemble(Canvas *c); + virtual void onCommand(const wchar_t *cmd); + + virtual void addBreakPoint(const wchar_t *pointer_ascii); + virtual void continueExecution(); + virtual void stepInto(); + virtual void stepOver(); + virtual void killScript(); + virtual void showHelp(); + virtual int onGetFocus(); + + virtual int evaluate(const wchar_t *ascii); + virtual const wchar_t *getLine(const wchar_t *filename, int fileline); + + private: + + int leave; + MakiJITD *jitd; + EditWnd *edit; + wchar_t cmdbuf[256]; + int retcode; + PtrList strstack; +}; + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/script/debugger/sourcecodeline.cpp b/Src/Wasabi/api/script/debugger/sourcecodeline.cpp new file mode 100644 index 00000000..b6511c2b --- /dev/null +++ b/Src/Wasabi/api/script/debugger/sourcecodeline.cpp @@ -0,0 +1,69 @@ +#include +#include "sourcecodeline.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif +#define CBCLASS SourceCodeLineI +START_DISPATCH; + CB(SOURCECODELINE_GETLINE, getLine); + VCB(SOURCECODELINE_SETLINE, setLine); + CB(SOURCECODELINE_GETPOINTER, getPointer); + VCB(SOURCECODELINE_SETPOINTER, setPointer); + CB(SOURCECODELINE_GETLENGTH, getLength); + VCB(SOURCECODELINE_SETLENGTH, setLength); + VCB(SOURCECODELINE_SETSOURCEFILE, setSourceFile); + CB(SOURCECODELINE_GETSOURCEFILE, getSourceFile); + VCB(SOURCECODELINE_SETSOURCEFILELINE, setSourceFileLine); + CB(SOURCECODELINE_GETSOURCEFILELINE, getSourceFileLine); +END_DISPATCH; + +SourceCodeLineI::SourceCodeLineI() { + pointer = -1; + fileline = -1; + length = 0; +} + +SourceCodeLineI::~SourceCodeLineI() { +} + +const wchar_t *SourceCodeLineI::getLine() +{ + return line; +} + +void SourceCodeLineI::setLine(const wchar_t *_line) { + line = _line; +} + +int SourceCodeLineI::getPointer() { + return pointer; +} + +void SourceCodeLineI::setPointer(int _pointer) { + pointer = _pointer; +} + +int SourceCodeLineI::getLength() { + return length; +} + +void SourceCodeLineI::setLength(int _length) { + length = _length; +} + +void SourceCodeLineI::setSourceFile(const wchar_t *_file) { + file = _file; +} + +const wchar_t *SourceCodeLineI::getSourceFile() { + return file; +} + +void SourceCodeLineI::setSourceFileLine(int _linenumber) { + fileline = _linenumber; +} + +int SourceCodeLineI::getSourceFileLine() { + return fileline; +} \ No newline at end of file diff --git a/Src/Wasabi/api/script/debugger/sourcecodeline.h b/Src/Wasabi/api/script/debugger/sourcecodeline.h new file mode 100644 index 00000000..a3a341ac --- /dev/null +++ b/Src/Wasabi/api/script/debugger/sourcecodeline.h @@ -0,0 +1,100 @@ +#ifndef __SOURCECODELINE_H +#define __SOURCECODELINE_H + +#include +#include + + +class SourceCodeLine : public Dispatchable { + public: + const wchar_t *getLine(); + void setLine(const wchar_t *line); + int getPointer(); + void setPointer(int pointer); + int getLength(); + void setLength(int length); + void setSourceFile(const wchar_t *file); + const wchar_t *getSourceFile(); + void setSourceFileLine(int linenumber); + int getSourceFileLine(); + + enum { + SOURCECODELINE_GETLINE = 0, + SOURCECODELINE_SETLINE = 10, + SOURCECODELINE_GETPOINTER = 20, + SOURCECODELINE_SETPOINTER = 30, + SOURCECODELINE_GETLENGTH = 40, + SOURCECODELINE_SETLENGTH = 50, + SOURCECODELINE_SETSOURCEFILE = 60, + SOURCECODELINE_GETSOURCEFILE = 70, + SOURCECODELINE_SETSOURCEFILELINE = 80, + SOURCECODELINE_GETSOURCEFILELINE = 90, + }; +}; + +inline const wchar_t *SourceCodeLine::getLine() { + return _call(SOURCECODELINE_GETLINE, (const wchar_t*)NULL); +} + +inline void SourceCodeLine::setLine(const wchar_t *line) { + _voidcall(SOURCECODELINE_SETLINE, line); +} + +inline int SourceCodeLine::getPointer() { + return _call(SOURCECODELINE_GETPOINTER, (int)0); +} + +inline void SourceCodeLine::setPointer(int pointer) { + _voidcall(SOURCECODELINE_SETPOINTER, pointer); +} + +inline int SourceCodeLine::getLength() { + return _call(SOURCECODELINE_GETLENGTH, (int)0); +} + +inline void SourceCodeLine::setLength(int length) { + _voidcall(SOURCECODELINE_SETLENGTH, length); +} + +inline void SourceCodeLine::setSourceFile(const wchar_t *file) { + _voidcall(SOURCECODELINE_SETSOURCEFILE, file); +} + +inline const wchar_t *SourceCodeLine::getSourceFile() { + return _call(SOURCECODELINE_GETSOURCEFILE, (const wchar_t *)0); +} + +inline void SourceCodeLine::setSourceFileLine(int linenumber) { + _voidcall(SOURCECODELINE_SETSOURCEFILELINE, linenumber); +} + +inline int SourceCodeLine::getSourceFileLine() { + return _call(SOURCECODELINE_GETSOURCEFILELINE, (int)0); +} + +class SourceCodeLineI : public SourceCodeLine { + public: + SourceCodeLineI(); + virtual ~SourceCodeLineI(); + virtual const wchar_t *getLine(); + virtual void setLine(const wchar_t *line); + virtual int getPointer(); + virtual void setPointer(int pointer); + virtual int getLength(); + virtual void setLength(int length); + virtual void setSourceFile(const wchar_t *file); + virtual const wchar_t *getSourceFile(); + virtual void setSourceFileLine(int linenumber); + virtual int getSourceFileLine(); + + protected: + RECVS_DISPATCH; + + StringW line; + StringW file; + int fileline; + int pointer; + int length; +}; + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/script/debugger/vcpudebug.cpp b/Src/Wasabi/api/script/debugger/vcpudebug.cpp new file mode 100644 index 00000000..94087956 --- /dev/null +++ b/Src/Wasabi/api/script/debugger/vcpudebug.cpp @@ -0,0 +1,99 @@ +#include +#include +#include "vcpudebug.h" +#include + +VCPUDebugger::VCPUDebugger() { + filter.setFilterObject(&reentryfilter); +} + +VCPUDebugger::~VCPUDebugger() { +} + +// ------------------------------------------------------------------------ + +// instruction pointer +int VCPUDebugger::getVIP() { + return WASABI_API_MAKIDEBUG->debugger_getVIP(); +} + +// script descriptor (vcpuid) +int VCPUDebugger::getVSD() { + return WASABI_API_MAKIDEBUG->debugger_getVSD(); +} + +// variables stack pointer +int VCPUDebugger::getVSP() { + return WASABI_API_MAKIDEBUG->debugger_getVSP(); +} + +// call stack pointer +int VCPUDebugger::getVCC() { + return WASABI_API_MAKIDEBUG->debugger_getVCC(); +} + +// ------------------------------------------------------------------------ +void VCPUDebugger::trace() { + int i; + for (i=0;igetVCPUId() == getVSD()) { + jitd->trace(); + } + } +} + +MakiJITD *VCPUDebugger::getJITD(int vcpuid) { + int i; + for (i=0;igetVCPUId() == vcpuid) + return jitd; + } + return NULL; +} + +// if this returns 1, you should not call eventComplete! +int VCPUDebugger::filterEvent(int vcpuid, int eventid) { + MakiJITD *jitd = getJITD(vcpuid); + if (!jitd || !jitd->isOnHold()) { + WASABI_API_WND->pushModalWnd(); + scopestack.push(0); + return 0; + } + filter.enterScope((vcpuid<<16) + eventid); // (vcpuid<<16) + eventid + if (filter.mustLeave()) { + filter.leaveScope(); + return 1; + } + WASABI_API_WND->pushModalWnd(); + scopestack.push(1); + return 0; +} + +void VCPUDebugger::eventComplete() { + int n; + scopestack.pop(&n); + WASABI_API_WND->popModalWnd(); + if (n) { + filter.leaveScope(); + } +} + +int VCPUDebugger::isActive() { + foreach(jitds) + if (jitds.getfor()->isActive()) + return 1; + endfor; + return 0; +} + +MakiJITD *VCPUDebugger::createJITD(int vcpuid) { + MakiJITD *jitd = new MakiJITD(this, vcpuid); + jitds.addItem(jitd); + return jitd; +} + +const char *VCPUDebugger::getCodeBlock(int vcpuid) { + return WASABI_API_MAKIDEBUG->debugger_getCodeBlock(vcpuid); +} diff --git a/Src/Wasabi/api/script/debugger/vcpudebug.h b/Src/Wasabi/api/script/debugger/vcpudebug.h new file mode 100644 index 00000000..6bba084b --- /dev/null +++ b/Src/Wasabi/api/script/debugger/vcpudebug.h @@ -0,0 +1,39 @@ +#ifndef __VCPUDEBUG_H +#define __VCPUDEBUG_H + +#include +#include +#include + +class MakiJITD; + +class VCPUDebugger { + public: + VCPUDebugger(); + virtual ~VCPUDebugger(); + + void trace(); + + int getVIP(); // instruction pointer + int getVSD(); // script descriptor (id) + int getVSP(); // variables stack pointer + int getVCC(); // call stack pointer + + int filterEvent(int vcpuid, int eventid); // if this returns 1, you should return immediatly and not call eventComplete! + void eventComplete(); + + int isActive(); + + MakiJITD *createJITD(int vcpuid); + MakiJITD *getJITD(int vcpuid); + const char *getCodeBlock(int vcpuid); + + private: + + PtrList jitds; + ReentryFilterObject reentryfilter; + ReentryFilter filter; + Stack scopestack; +}; + +#endif diff --git a/Src/Wasabi/api/script/guru.cpp b/Src/Wasabi/api/script/guru.cpp new file mode 100644 index 00000000..b245dd50 --- /dev/null +++ b/Src/Wasabi/api/script/guru.cpp @@ -0,0 +1,216 @@ +#include +#include +#ifdef WASABI_COMPILE_WND +#include +#include +#endif +#include +#include +#include +#ifdef WASABI_COMPILE_SKIN +#include +#endif + +extern HINSTANCE hInstance; +#ifdef WASABI_COMPILE_WND +Guru::Guru() +{ + fcount = 0; + txt=NULL; + code=0; + intinfo=0; +} + +Guru::~Guru() { +} +#endif + +void Guru::spawn(SystemObject *_script, int code, const wchar_t *pub, int intinfo) { +#ifdef WASABI_COMPILE_WND + script = _script; + if (WASABI_API_PALETTE->getSkinPartIterator() > last_iterator) { + mustquit = 0; + last_iterator = WASABI_API_PALETTE->getSkinPartIterator(); + } + else + return; + +#ifdef WASABI_COMPILE_SKIN + int oldlock = WASABI_API_SKIN->skin_getLockUI(); + WASABI_API_SKIN->skin_setLockUI(0); +#endif + + Guru g; + g.setCode(code); + g.setPublicTxt(pub); + g.setIntInfo(intinfo); + g.setStartHidden(1); + g.init(hInstance, INVALIDOSWINDOWHANDLE, TRUE); + + RECT r; + Wasabi::Std::getViewport(&r, (POINT*)NULL); + + r.left = r.left + ((r.right-r.left-640)/2); + r.right = r.left + 640; + TextInfoCanvas c(&g); + Wasabi::FontInfo fontInfo; + fontInfo.pointSize = WASABI_API_APP->getScaleY(14); + +#ifdef WIN32 + fontInfo.face = L"Lucida Console"; +#else + fontInfo.face = L"Lucida"; +#endif + fontInfo.bold = true; + + r.bottom = r.top + c.getTextHeight(&fontInfo)* (script != NULL ? 9 : 7); + + g.resize(&r); + g.setVisible(1); + g.bringToFront(); + + MSG msg = {0}; + WASABI_API_WND->pushModalWnd(&g); +#ifdef WIN32 + HWND old = SetCapture(g.gethWnd()); +#endif + while (!mustquit) { + mustquit = !GetMessage(&msg, g.gethWnd(), 0, 0); +#ifdef WIN32 + if (!msg.hwnd || !TranslateAccelerator(msg.hwnd, NULL, &msg)) { +#endif + TranslateMessage(&msg); + DispatchMessage(&msg); +#ifdef WIN32 + } +#endif + } + + WASABI_API_WND->popModalWnd(&g); +#ifdef WIN32 + SetCapture(old); +#endif + +#else + StringPrintfW t(L"Guru Meditation #%04X.%04X%04X.%d%s%s", code, (intinfo & 0xFFFF), VCPU::VIP & 0xFFFF, VCPU::VSD, pub?" ":"", pub?pub:""); + Std::messageBox(t, L"Guru Meditiation", 16); +#endif + +#ifdef WASABI_COMPILE_SKIN + WASABI_API_SKIN->skin_setLockUI(oldlock); +#endif +} + +#ifdef WASABI_COMPILE_WND + +int Guru::onPaint(Canvas *canvas) { + + GURU_PARENT::onPaint(canvas); + + PaintBltCanvas paintcanvas; + if (canvas == NULL) { + paintcanvas.beginPaint(this); + canvas = &paintcanvas; + } + + RECT r; + getClientRect(&r); + + canvas->fillRect(&r, 0); + + if (fcount%2==0) + { + int w; + Wasabi::FontInfo fontInfo; + fontInfo.color = RGB(0xFF,0,0); + fontInfo.pointSize = WASABI_API_APP->getScaleY(14); + +#ifdef WIN32 + fontInfo.face = L"Lucida Console"; +#else + fontInfo.face = L"Lucida"; +#endif + fontInfo.bold = true; + fontInfo.opaque = false; + w = canvas->getTextHeight(&fontInfo); + RECT s = {40, w*2, 560, w*3}; + canvas->textOutCentered(&s, L"Winamp Script Failure. Press the left mouse button to continue.", &fontInfo); + StringPrintfW t(L"Guru Meditation #%04X.%04X%04X.%d%s%s", code, (intinfo & 0xFFFF), VCPU::VIP & 0xFFFF, VCPU::VSD, txt?L" ":L"", txt?txt:L""); + s.top=w*4; + s.bottom=s.top+w; + canvas->textOutCentered(&s, t, &fontInfo); + + if (script != NULL) { + s.top=w*6; + s.bottom=s.top+w; + canvas->textOutCentered(&s, script->getFilename(), &fontInfo); + } + + RECT z; + z.top = r.top + 5; + z.bottom = r.top + min(10, w-2); + z.left = r.left + 5; + z.right = r.right - 5; + canvas->fillRect(&z, RGB(0xFF,0,0)); + + z.top = r.top + 5; + z.bottom = r.bottom - 5;; + z.left = r.right - min(10, w-2); + z.right = r.right - 5; + canvas->fillRect(&z, RGB(0xFF,0,0)); + + z.top = r.bottom - min(10, w-2); + z.bottom = r.bottom - 5; + z.left = r.left + 5; + z.right = r.right - 5; + canvas->fillRect(&z, RGB(0xFF,0,0)); + + z.top = r.top + 5; + z.bottom = r.bottom - 5;; + z.left = r.left + 5; + z.right = r.left + min(10, w-2); + canvas->fillRect(&z, RGB(0xFF,0,0)); + } + + return 1; +} + +int Guru::onLeftButtonUp(int x, int y) { + mustquit=1; + return GURU_PARENT::onLeftButtonUp(x,y); +} + +int Guru::onInit() { + GURU_PARENT::onInit(); + setTimer(GURU_TIMERID, 400); + return 1; +} + +void Guru::setCode(int c) { + code = c; +} + +void Guru::setPublicTxt(const wchar_t *t) { + txt = t; +} + +void Guru::setIntInfo(int info) { + intinfo = info; +} + +void Guru::timerCallback(int id) { + if (id == GURU_TIMERID) { + fcount++; + if (fcount > 7) { + killTimer(GURU_TIMERID); + } + invalidate(); + return; + } + GURU_PARENT::timerCallback(id); +} + +int Guru::mustquit = 0; +int Guru::last_iterator = -1; +SystemObject * Guru::script = NULL; +#endif diff --git a/Src/Wasabi/api/script/guru.h b/Src/Wasabi/api/script/guru.h new file mode 100644 index 00000000..2af5e5b2 --- /dev/null +++ b/Src/Wasabi/api/script/guru.h @@ -0,0 +1,51 @@ +//PORTABLE +#ifndef _GURU_H +#define _GURU_H + +#include + +#ifdef WASABI_COMPILE_WND +#define GURU_PARENT BaseWnd +#else +class _Guru {}; +#define GURU_PARENT _Guru +#endif + +class SystemObject; + +#define GURU_TIMERID 2482 + +class Guru : public GURU_PARENT { +public: +#ifdef WASABI_COMPILE_WND + Guru(); + virtual ~Guru(); +#endif + + static void spawn(SystemObject *_script, int code, const wchar_t *pub = NULL, int intinfo = 0); + +#ifdef WASABI_COMPILE_WND + virtual int onPaint(Canvas *canvas); + virtual int onLeftButtonUp(int x, int y); + virtual int onInit(); + void setCode(int c); + void setPublicTxt(const wchar_t *t); + void setIntInfo(int info); +#endif + +#ifdef WASABI_COMPILE_WND +protected: + virtual void timerCallback(int id); + +private: + int code; + const wchar_t *txt; + int fcount; + int intinfo; + static int mustquit; + static int last_iterator; + static SystemObject * script; +#endif +}; + +#endif diff --git a/Src/Wasabi/api/script/makiapi.cpp b/Src/Wasabi/api/script/makiapi.cpp new file mode 100644 index 00000000..de3df611 --- /dev/null +++ b/Src/Wasabi/api/script/makiapi.cpp @@ -0,0 +1,248 @@ +#include "precomp.h" +#include "makiapi.h" +#include "../../studio/api.h" +#include "../../bfc/api/api_maki.h" +#include "../../studio/script/vcpu.h" +#include "../../studio/script/objecttable.h" +#include "../../studio/script/scriptmgr.h" +#include "../../studio/script/script.h" +#include "../../common/script/scriptobj.h" + +api_maki *makiApi = NULL; + +ScriptApi::ScriptApi() { + ObjectTable::loadExternalClasses(); + VCPU::scriptManager = new ScriptObjectManager(); +} + +ScriptApi::~ScriptApi() { + delete VCPU::scriptManager; + VCPU::scriptManager = NULL; + VCPU::shutdown(); + ObjectTable::unloadExternalClasses(); +} + +void ScriptApi::maki_pushObject(void *o) { + VCPU::pushObject(o); +} + +void ScriptApi::maki_pushInt(int i) { + VCPU::pushInt(i); +} + +void ScriptApi::maki_pushBoolean(int b) { + VCPU::pushBoolean(b); +} + +void ScriptApi::maki_pushFloat(float f) { + VCPU::pushFloat(f); +} + +void ScriptApi::maki_pushDouble(double d) { + VCPU::pushDouble(d); +} + +void ScriptApi::maki_pushString(const char *s) { + VCPU::pushString(s); +} + +void ScriptApi::maki_pushAny(scriptVar v) { + VCPU::push(v); +} + +void ScriptApi::maki_pushVoid() { + VCPU::pushVoid(); +} + +void *ScriptApi::maki_popObject() { + return VCPU::popObject(); +} + +int ScriptApi::maki_popInt() { + return VCPU::popInt(); +} + +bool ScriptApi::maki_popBoolean() { + return VCPU::popBoolean(); +} + +float ScriptApi::maki_popFloat() { + return VCPU::popFloat(); +} + +double ScriptApi::maki_popDouble() { + return VCPU::popDouble(); +} + +const char *ScriptApi::maki_popString() { + return VCPU::popString(); +} + +scriptVar ScriptApi::maki_popAny() { + return VCPU::pop().v; +} + +void ScriptApi::maki_popDiscard() { + VCPU::popDiscard(); +} + +const char *ScriptApi::maki_getFunction(int dlfid, int *nparams, ScriptObjectController **p) { + return ObjectTable::getFunction(dlfid, nparams, p); +} + +int ScriptApi::maki_addDlfRef(ScriptObjectController *o, const char *function_name, void *host) { + return ObjectTable::dlfAddRef(o, function_name, host); +} + +void ScriptApi::maki_remDlfRef(void *host) { + ObjectTable::dlfRemRef(host); +} + +void ScriptApi::maki_addDlfClassRef(ScriptObjectController *o, void *host) { + ObjectTable::dlfAddClassRef(o, host); +} + +scriptVar ScriptApi::maki_callFunction(ScriptObject *o, int dlfid, scriptVar **params) { + return ObjectTable::callFunction(o, dlfid, params); +} + +scriptVar ScriptApi::maki_triggerEvent(ScriptObject *o, int dlfid, int np, int scriptid) { + scriptVar v = MAKE_SCRIPT_OBJECT(o); + return VCPU::executeEvent(v, dlfid, np, scriptid); +} + +ScriptObject *ScriptApi::maki_instantiate(GUID classguid) { + int classid = ObjectTable::getClassFromGuid(classguid); + if (classid == -1) return NULL; + return ObjectTable::instantiate(classid); +} + +void ScriptApi::maki_destroy(ScriptObject *o) { + ObjectTable::destroy(o); +} + +void *ScriptApi::maki_encapsulate(GUID classguid, ScriptObject *o) { + int classid = ObjectTable::getClassFromGuid(classguid); + if (classid == -1) return NULL; + return ObjectTable::encapsulate(classid, o); +} + +void ScriptApi::maki_deencapsulate(GUID classguid, void *o) { + int classid = ObjectTable::getClassFromGuid(classguid); + if (classid == -1) return; + ObjectTable::deencapsulate(classid, o); +} + +ScriptObjectController *ScriptApi::maki_getController(GUID scriptclass) { + return ObjectTable::getController(scriptclass); +} +int ScriptApi::maki_createOrphan(int type) { + return VCPU::createOrphan(type); +} + +void ScriptApi::maki_killOrphan(int id) { + VCPU::killOrphan(id); +} + +int ScriptApi::maki_getScriptInt(scriptVar v) { + return SOM::makeInt(&v); +} + +bool ScriptApi::maki_getScriptBoolean(scriptVar v) { + return SOM::makeBoolean(&v); +} + +float ScriptApi::maki_getScriptFloat(scriptVar v) { + return SOM::makeFloat(&v); +} + +double ScriptApi::maki_getScriptDouble(scriptVar v) { + return SOM::makeDouble(&v); +} + +const char *ScriptApi::maki_getScriptString(scriptVar v) { + ASSERT(v.type == SCRIPT_STRING); + return v.data.sdata; +} + +ScriptObject *ScriptApi::maki_getScriptObject(scriptVar v) { + ASSERT(!SOM::isNumeric(&v) && v.type != SCRIPT_STRING); + return v.data.odata; +} + +scriptVar ScriptApi::maki_updateDlf(maki_cmd *cmd, int *dlfid, int *linkcount) { + switch (cmd->cmd) { + case MAKI_CMD_ADDREF: + (*linkcount)++; + break; + case MAKI_CMD_REMREF: + (*linkcount)--; + ASSERT(*linkcount >= 0); + if (*linkcount == 0) + *dlfid = -1; + break; + case MAKI_CMD_SETDLF: + ASSERT(*dlfid == -1); + *dlfid = cmd->id; + break; + case MAKI_CMD_GETDLF: + cmd->id = *dlfid; + break; + } + RETURN_SCRIPT_VOID +} + +void ScriptApi::maki_setObjectAtom(const char *atomname, ScriptObject *object) { + VCPU::setAtom(atomname, object); +} + +ScriptObject *ScriptApi::maki_getObjectAtom(const char *atomname) { + return VCPU::getAtom(atomname); +} + +#ifdef WASABI_COMPILE_WND +ScriptObject *ScriptApi::maki_findObject(const char *name) { + return ScriptObjectManager::findObject(name); +} +#endif + +void ScriptApi::vcpu_addScriptObject(ScriptObject *o) { + SystemObject::addScriptObject(o); +} + +void ScriptApi::vcpu_removeScriptObject(ScriptObject *o) { + SystemObject::removeScriptObject(o); +} + +int ScriptApi::vcpu_getCacheCount() { + return Script::getCacheCount(); +} + +int ScriptApi::vcpu_isValidScriptId(int id) { + return Script::isValidScriptId(id); +} + +int ScriptApi::vcpu_mapVarId(int varid, int scriptid) { + return Script::varIdToGlobal(varid, scriptid); +} + +int ScriptApi::vcpu_getUserAncestorId(int varid, int scriptid) { + return Script::getUserAncestor(varid, scriptid); +} + +int ScriptApi::vcpu_getNumEvents() { + return Script::getNumEventsLinked(); +} + +int ScriptApi::vcpu_getEvent(int event, int *dlf, int *script, int *var) { + return Script::getLinkedEventParams(event, dlf, script, var); +} + +int ScriptApi::vcpu_getComplete() { + return VCPU::getComplete(); +} + +const char * ScriptApi::vcpu_getClassName(int vcpuid, int localclassid) { + return VCPU::getClassName(vcpuid, localclassid); +} + diff --git a/Src/Wasabi/api/script/makiapi.h b/Src/Wasabi/api/script/makiapi.h new file mode 100644 index 00000000..e1d27aff --- /dev/null +++ b/Src/Wasabi/api/script/makiapi.h @@ -0,0 +1,66 @@ +#ifndef __SCRIPTAPI_H +#define __SCRIPTAPI_H + +#include + +class ScriptApi : public api_makiI { + public: + ScriptApi(); + virtual ~ScriptApi(); + + virtual void maki_pushObject(void *o); + virtual void maki_pushInt(int v); + virtual void maki_pushBoolean(int b); + virtual void maki_pushFloat(float f); + virtual void maki_pushDouble(double d); + virtual void maki_pushString(const wchar_t *s); + virtual void maki_pushVoid(); + virtual void maki_pushAny(scriptVar v); + virtual void *maki_popObject(); + virtual int maki_popInt(); + virtual bool maki_popBoolean(); + virtual float maki_popFloat(); + virtual double maki_popDouble(); + virtual const wchar_t *maki_popString(); + virtual scriptVar maki_popAny(); + virtual void maki_popDiscard(); + virtual const wchar_t *maki_getFunction(int dlfid, int *n, ScriptObjectController **p); + virtual int maki_addDlfRef(ScriptObjectController *o, const wchar_t *function_name, void *host); + virtual void maki_addDlfClassRef(ScriptObjectController *o, void *host); + virtual void maki_remDlfRef(void *host); + virtual scriptVar maki_callFunction(ScriptObject *o, int dlfid, scriptVar **params); + virtual scriptVar maki_triggerEvent(ScriptObject *o, int dlfid, int np, int scriptid0=-1); + virtual int maki_getScriptInt(scriptVar v); + virtual bool maki_getScriptBoolean(scriptVar v); + virtual float maki_getScriptFloat(scriptVar v); + virtual double maki_getScriptDouble(scriptVar v); + virtual const wchar_t *maki_getScriptString(scriptVar v); + virtual ScriptObject *maki_getScriptObject(scriptVar v); + virtual scriptVar maki_updateDlf(maki_cmd *cmd, int *dlfid, int *linkcount); + virtual ScriptObject *maki_instantiate(GUID classguid); + virtual void maki_destroy(ScriptObject *o); + virtual void *maki_encapsulate(GUID classguid, ScriptObject *o); + virtual void maki_deencapsulate(GUID classguid, void *o); + virtual ScriptObjectController *maki_getController(GUID scriptclass); + virtual int maki_createOrphan(int type); + virtual void maki_killOrphan(int id); + virtual void maki_setObjectAtom(const wchar_t *atomname, ScriptObject *object); + virtual ScriptObject *maki_getObjectAtom(const wchar_t *atomname); +#ifdef WASABI_COMPILE_WND + virtual ScriptObject *maki_findObject(const wchar_t *name); +#endif + virtual void vcpu_addScriptObject(ScriptObject *o); + virtual void vcpu_removeScriptObject(ScriptObject *o); + virtual int vcpu_getCacheCount(); + virtual int vcpu_isValidScriptId(int id); + virtual int vcpu_mapVarId(int varid, int scriptid); + virtual int vcpu_getUserAncestorId(int varid, int scriptid); + virtual int vcpu_getNumEvents(); + virtual int vcpu_getEvent(int event, int *dlf, int *script, int *var); + virtual int vcpu_getComplete(); + virtual const wchar_t *vcpu_getClassName(int vcpuid, int localclassid); +}; + +extern api_maki *makiApi; + +#endif diff --git a/Src/Wasabi/api/script/objcontroller.cpp b/Src/Wasabi/api/script/objcontroller.cpp new file mode 100644 index 00000000..0cae1ccc --- /dev/null +++ b/Src/Wasabi/api/script/objcontroller.cpp @@ -0,0 +1,156 @@ +#include +#include +#include +#include "api.h" + +#define CBCLASS ScriptObjectControllerI +START_DISPATCH; + CB(GETCLASSGUID, getClassGuid); + CB(GETCLASSNAME, getClassName); + CB(GETANCESTORCLASSNAME, getAncestorClassName); + CB(GETNUMFUNCTIONS, getNumFunctions); + CB(GETEXPORTEDFUNCTIONS, getExportedFunctions); + CB(INSTANTIATE, instantiate); + VCB(DESTROY, destroy); + CB(ENCAPSULATE, encapsulate); + VCB(DEENCAPSULATE, deencapsulate); + VCB(SETCLASSID, setClassId); + CB(GETCLASSID, getClassId); + VCB(SETANCESTORCLASSID, setAncestorClassId); + CB(GETANCESTORCLASSID, getAncestorClassId); + CB(GETINSTANTIABLE, getInstantiable); + CB(GETREFERENCEABLE, getReferenceable); + CB(GETANCESTORCONTROLLER, getAncestorController); + VCB(ADDCLASSHOOK, addClassHook); + VCB(ADDOBJHOOK, addObjectHook); + VCB(REMHOOKS, removeHooks); + VCB(ONREGISTERCLASS, onRegisterClass); + CB(CAST, cast); +END_DISPATCH; + +ScriptObjectControllerI::ScriptObjectControllerI() { + my_class_id = -1; + my_ancestor_class_id = -1; + rootController = NULL; + incast = 0; +} + +ScriptObjectControllerI::~ScriptObjectControllerI() { +} + +int ScriptObjectControllerI::processHooks(ScriptObject *o, int dlfid, scriptVar **table, int nparams) { + //CUT: int n=-1; + for (int j=0;jeventCallback(o, dlfid, table, nparams); + } + for (int i=0;iobject == o) { + s->hook->eventCallback(o, dlfid, table, nparams); + } + } + return 0; +} + +ScriptObject *ScriptObjectControllerI::cast(ScriptObject *o, GUID g) { + if (incast) return NULL; + incast = 1; + ASSERT(o != NULL); + ScriptObject *obj = NULL; + void *i = o->vcpu_getInterfaceObject(g, &obj); + incast = 0; + if (i != NULL) { + if (obj != NULL) return obj; + return o; + } + return NULL; +} + +void ScriptObjectControllerI::addClassHook(ScriptHook *h) { + classhooks.addItem(h); +} + +void ScriptObjectControllerI::addObjectHook(ScriptHook *h, ScriptObject *o) { + object_hook_struct *s = new object_hook_struct; + s->hook = h; + s->object = o; + objhooks.addItem(s); +/* if (getAncestorController()) + getAncestorController()->addObjectHook(h, o); + else + if (rootController && this != rootController) rootController->addObjectHook(h, o);*/ +} + +void ScriptObjectControllerI::removeHooks(ScriptHook *h) { + classhooks.removeItem(h); + for (int i=0;ihook == h) { + delete o; + objhooks.removeByPos(i); + i--; + } + } +/* if (getAncestorController()) + getAncestorController()->removeHooks(h); + else + if (rootController && this != rootController) rootController->removeHooks(h);*/ +} + +void ScriptObjectControllerI::onRegisterClass(ScriptObjectController *root) { + rootController = root; +} + + +scriptVar MAKE_SCRIPT_INT(int i) { + scriptVar r; + r.type = SCRIPT_INT; + r.data.idata = i; + return r; +} + +scriptVar MAKE_SCRIPT_VOID() { + scriptVar r; r.type = SCRIPT_VOID; + r.data.idata = 0; + return r; +} + +scriptVar MAKE_SCRIPT_FLOAT(float f) { + scriptVar r; r.type = SCRIPT_FLOAT; + r.data.fdata = f; + return r; +} + +scriptVar MAKE_SCRIPT_DOUBLE(double d) { + scriptVar r; r.type = SCRIPT_DOUBLE; + r.data.ddata = d; + return r; +} + +scriptVar MAKE_SCRIPT_BOOLEAN(int b) { + scriptVar r; r.type = SCRIPT_BOOLEAN; + r.data.idata = b; + return r; +} + +scriptVar MAKE_SCRIPT_OBJECT(ScriptObject *o) { + scriptVar r; + r.type = SCRIPT_OBJECT; + r.data.odata = o; + return r; +} + +scriptVar MAKE_SCRIPT_STRING(const wchar_t *s) +{ + scriptVar r; + r.type = SCRIPT_STRING; + r.data.sdata = s; + return r; +} + +void *GET_SCRIPT_OBJECT_AS(scriptVar v, GUID g) { + ScriptObject *o = GET_SCRIPT_OBJECT(v); + if (!o) return NULL; + return o->vcpu_getInterface(g); +} + diff --git a/Src/Wasabi/api/script/objcontroller.h b/Src/Wasabi/api/script/objcontroller.h new file mode 100644 index 00000000..15400853 --- /dev/null +++ b/Src/Wasabi/api/script/objcontroller.h @@ -0,0 +1,316 @@ +#ifndef __SCRIPTOBJECTCONTROLLER_H +#define __SCRIPTOBJECTCONTROLLER_H + +#include + +//#include + +#include +#include +#include +#include +#include + +#define SCRIPT_MAXARGS 10 // 10 args max per function + +#define MAKI_CMD_NONE 0 +#define MAKI_CMD_SETDLF 1 +#define MAKI_CMD_GETDLF 2 +#define MAKI_CMD_ADDREF 3 +#define MAKI_CMD_REMREF 4 +#define MAKI_CMD_RESETDLF 5 + +#define SCRIPT_FUNCTION_INIT static int __dlfid=-1, __linkcount=0; if (__cmd != NULL) return WASABI_API_MAKI->maki_updateDlf(__cmd, &__dlfid, &__linkcount); +#define SCRIPT_FUNCTION_CHECKABORTEVENT if (__dlfid==-1) RETURN_SCRIPT_VOID; +#define SCRIPT_FUNCTION_CHECKABORTEVENT_SYS(o) { SCRIPT_FUNCTION_CHECKABORTEVENT { SystemObject *so = static_cast(o->vcpu_getInterface(systemObjectGuid)); if (!so || !so->isLoaded()) RETURN_SCRIPT_VOID; } } +#define PROCESS_HOOKS0(object, controller) { controller->processHooks(static_cast(object), DLF_ID, NULL, 0); } +#define PROCESS_HOOKS1(object, controller, p1) { scriptVar *__table[1] = {&p1}; controller->processHooks(static_cast(object), DLF_ID, __table, 1); } +#define PROCESS_HOOKS2(object, controller, p1, p2) { scriptVar *__table[2] = {&p1, &p2}; controller->processHooks(static_cast(object), DLF_ID, __table, 2); } +#define PROCESS_HOOKS3(object, controller, p1, p2, p3) { scriptVar *__table[3] = {&p1, &p2, &p3}; controller->processHooks(static_cast(object), DLF_ID, __table, 3); } +#define PROCESS_HOOKS4(object, controller, p1, p2, p3, p4) { scriptVar *__table[4] = {&p1, &p2, &p3, &p4}; controller->processHooks(static_cast(object), DLF_ID, __table, 4); } +#define PROCESS_HOOKS5(object, controller, p1, p2, p3, p4, p5) { scriptVar *__table[5] = {&p1, &p2, &p3, &p4, &p5}; controller->processHooks(static_cast(object), DLF_ID, __table, 5); } +#define PROCESS_HOOKS6(object, controller, p1, p2, p3, p4, p5, p6) { scriptVar *__table[6] = {&p1, &p2, &p3, &p4, &p5, &p6}; controller->processHooks(static_cast(object), DLF_ID, __table, 6); } +#define PROCESS_HOOKS7(object, controller, p1, p2, p3, p4, p5, p6, p7) { scriptVar *__table[7] = {&p1, &p2, &p3, &p4, &p5, &p6, &p7}; controller->processHooks(static_cast(object), DLF_ID, __table, 7); } +#define PROCESS_HOOKS8(object, controller, p1, p2, p3, p4, p5, p6, p7, p8) { scriptVar *__table[8] = {&p1, &p2, &p3, &p4, &p5, &p6, &p7, &p8}; controller->processHooks(static_cast(object), DLF_ID, __table, 8); } +#define PROCESS_HOOKS9(object, controller, p1, p2, p3, p4, p5, p6, p7, p8, p9) { scriptVar *__table[9] = {&p1, &p2, &p3, &p4, &p5, &p6, &p7, &p8, &p9}; controller->processHooks(static_cast(object), DLF_ID, __table, 9); } +#define PROCESS_HOOKS10(object, controller, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) { scriptVar *__table[10] = {&p1, &p2, &p3, &p4, &p5, &p6, &p7, &p8, &p9, &p10}; controller->processHooks(static_cast(object), DLF_ID, __table, 10); } +#define SCRIPT_EXEC_EVENT0(object) { return WASABI_API_MAKI->maki_triggerEvent(object, DLF_ID, 0); } +#define SCRIPT_EXEC_EVENT1(object, p1) { WASABI_API_MAKI->maki_pushAny(p1); return WASABI_API_MAKI->maki_triggerEvent(object, DLF_ID, 1); } +#define SCRIPT_EXEC_EVENT2(object, p1, p2) { WASABI_API_MAKI->maki_pushAny(p1); WASABI_API_MAKI->maki_pushAny(p2); return WASABI_API_MAKI->maki_triggerEvent(object, DLF_ID, 2); } +#define SCRIPT_EXEC_EVENT3(object, p1, p2, p3) { WASABI_API_MAKI->maki_pushAny(p1); WASABI_API_MAKI->maki_pushAny(p2); WASABI_API_MAKI->maki_pushAny(p3); return WASABI_API_MAKI->maki_triggerEvent(object, DLF_ID, 3); } +#define SCRIPT_EXEC_EVENT4(object, p1, p2, p3, p4) { WASABI_API_MAKI->maki_pushAny(p1); WASABI_API_MAKI->maki_pushAny(p2); WASABI_API_MAKI->maki_pushAny(p3); WASABI_API_MAKI->maki_pushAny(p4); return WASABI_API_MAKI->maki_triggerEvent(object, DLF_ID, 4); } +#define SCRIPT_EXEC_EVENT5(object, p1, p2, p3, p4, p5) { WASABI_API_MAKI->maki_pushAny(p1); WASABI_API_MAKI->maki_pushAny(p2); WASABI_API_MAKI->maki_pushAny(p3); WASABI_API_MAKI->maki_pushAny(p4); WASABI_API_MAKI->maki_pushAny(p5); return WASABI_API_MAKI->maki_triggerEvent(object, DLF_ID, 5); } +#define SCRIPT_EXEC_EVENT6(object, p1, p2, p3, p4, p5, p6) { WASABI_API_MAKI->maki_pushAny(p1); WASABI_API_MAKI->maki_pushAny(p2); WASABI_API_MAKI->maki_pushAny(p3); WASABI_API_MAKI->maki_pushAny(p4); WASABI_API_MAKI->maki_pushAny(p5); WASABI_API_MAKI->maki_pushAny(p6); return WASABI_API_MAKI->maki_triggerEvent(object, DLF_ID, 6); } +#define SCRIPT_EXEC_EVENT7(object, p1, p2, p3, p4, p5, p6, p7) { WASABI_API_MAKI->maki_pushAny(p1); WASABI_API_MAKI->maki_pushAny(p2); WASABI_API_MAKI->maki_pushAny(p3); WASABI_API_MAKI->maki_pushAny(p4); WASABI_API_MAKI->maki_pushAny(p5); WASABI_API_MAKI->maki_pushAny(p6); WASABI_API_MAKI->maki_pushAny(p7); return WASABI_API_MAKI->maki_triggerEvent(object, DLF_ID, 7); } +#define SCRIPT_EXEC_EVENT8(object, p1, p2, p3, p4, p5, p6, p7, p8) { WASABI_API_MAKI->maki_pushAny(p1); WASABI_API_MAKI->maki_pushAny(p2); WASABI_API_MAKI->maki_pushAny(p3); WASABI_API_MAKI->maki_pushAny(p4); WASABI_API_MAKI->maki_pushAny(p5); WASABI_API_MAKI->maki_pushAny(p6); WASABI_API_MAKI->maki_pushAny(p7); WASABI_API_MAKI->maki_pushAny(p8); return WASABI_API_MAKI->maki_triggerEvent(object, DLF_ID, 8); } +#define SCRIPT_EXEC_EVENT9(object, p1, p2, p3, p4, p5, p6, p7, p8, p9) { WASABI_API_MAKI->maki_pushAny(p1); WASABI_API_MAKI->maki_pushAny(p2); WASABI_API_MAKI->maki_pushAny(p3); WASABI_API_MAKI->maki_pushAny(p4); WASABI_API_MAKI->maki_pushAny(p5); WASABI_API_MAKI->maki_pushAny(p6); WASABI_API_MAKI->maki_pushAny(p7); WASABI_API_MAKI->maki_pushAny(p8); WASABI_API_MAKI->maki_pushAny(p9); return WASABI_API_MAKI->maki_triggerEvent(object, DLF_ID, 9); } +#define SCRIPT_EXEC_EVENT10(object, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) { WASABI_API_MAKI->maki_pushAny(p1); WASABI_API_MAKI->maki_pushAny(p2); WASABI_API_MAKI->maki_pushAny(p3); WASABI_API_MAKI->maki_pushAny(p4); WASABI_API_MAKI->maki_pushAny(p5); WASABI_API_MAKI->maki_pushAny(p6); WASABI_API_MAKI->maki_pushAny(p7); WASABI_API_MAKI->maki_pushAny(p8); WASABI_API_MAKI->maki_pushAny(p9); WASABI_API_MAKI->maki_pushAny(p10); return WASABI_API_MAKI->maki_triggerEvent(object, DLF_ID, 10); } + +#define SCRIPT_FUNCTION_PARAMS maki_cmd *__cmd, int __vsd +#define SCRIPT_CALL NULL, -1 +#define GET_SCRIPT_INT(v) WASABI_API_MAKI->maki_getScriptInt(v) +//CUT#define GET_SCRIPT_INT(v) ((v).getAsInt()) +#define GET_SCRIPT_BOOLEAN(v) WASABI_API_MAKI->maki_getScriptBoolean(v) +#define GET_SCRIPT_FLOAT(v) WASABI_API_MAKI->maki_getScriptFloat(v) +#define GET_SCRIPT_DOUBLE(v) WASABI_API_MAKI->maki_getScriptDouble(v) +#define GET_SCRIPT_STRING(v) WASABI_API_MAKI->maki_getScriptString(v) +#define GET_SCRIPT_OBJECT(v) WASABI_API_MAKI->maki_getScriptObject(v) + +scriptVar COMEXP MAKE_SCRIPT_INT(int i); +scriptVar COMEXP MAKE_SCRIPT_VOID(); +scriptVar COMEXP MAKE_SCRIPT_FLOAT(float f); +scriptVar COMEXP MAKE_SCRIPT_DOUBLE(double d); +scriptVar COMEXP MAKE_SCRIPT_BOOLEAN(int b); +scriptVar COMEXP MAKE_SCRIPT_OBJECT(ScriptObject *o); +scriptVar COMEXP MAKE_SCRIPT_STRING(const wchar_t *s); +void COMEXP *GET_SCRIPT_OBJECT_AS(scriptVar v, GUID g); + +#define FIXUP_FUNCTION_DLF SCRIPT_FUNCTION_INIT +/*#define FIXUP_FUNCTION_DLF \ +static int fn_DLF=-1; \ +if (fn_DLF == -1 && DLFid == -1) { RETURN_SCRIPT_ZERO } \ +if (fn_DLF == -1 && DLFid != -1 && o == NULL) { \ + fn_DLF = DLFid; \ + RETURN_SCRIPT_VOID \ + } else if (DLFid != -1) { \ + ASSERTPR(0, "DLFId already set"); \ + RETURN_SCRIPT_VOID \ + }*/ + +#define DLF_ID __dlfid + +#define RETURN_SCRIPT_EVENT \ +{ scriptVar script_event_return={SCRIPT_EVENT,0}; \ +return script_event_return; } + +#define RETURN_SCRIPT_VOID \ +{ scriptVar script_event_return={SCRIPT_VOID,0}; \ +return script_event_return; } + +#define RETURN_SCRIPT_ZERO \ +{ scriptVar script_event_return={SCRIPT_INT,0}; \ +return script_event_return; } + +#define RETURN_SCRIPT_NULL \ +{ scriptVar script_event_return={SCRIPT_OBJECT,NULL}; \ +return script_event_return; } + +#define SCRIPT_FUNCTION_INT(_class, func, call) \ +scriptVar _class::func(int DLFid, ScriptObject *o) { \ + FIXUP_FUNCTION_DLF \ + ASSERT(o != NULL); \ + scriptVar s = SOM::makeVar(SCRIPT_INT); \ + SOM::assign(&s, ((_class *)o)->call()); \ + return s;\ +} + +#define DEC_SCRIPT_FUNCTION_INT(func1, func2) \ + static scriptVar func1(int DLFid, ScriptObject *o); \ + virtual int func2(); + + +#define EVENT_ID __dlfid + +typedef struct { + const wchar_t *function_name; + int nparams; + void *physical_ptr; +} function_descriptor_struct; + +typedef struct { + ScriptHook *hook; + ScriptObject *object; +} object_hook_struct; + +static const GUID ROOT_GUID = +{ 0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }; + + +class ScriptObjectController : public Dispatchable { + protected: + ScriptObjectController() {}; + + public: + + void onRegisterClass(ScriptObjectController *rootController); + GUID getClassGuid(); + const wchar_t *getClassName(); + const wchar_t *getAncestorClassName(); + ScriptObjectController *getAncestorController(); + int getNumFunctions(); + const function_descriptor_struct *getExportedFunctions(); + ScriptObject *instantiate(); + void destroy(ScriptObject *o); + void *encapsulate(ScriptObject *o); + void deencapsulate(void *o); + ScriptObject *cast(ScriptObject *o, GUID g); + void setClassId(int id); + int getClassId(); + void setAncestorClassId(int id); + int getAncestorClassId(); + int getInstantiable(); + int getReferenceable(); + int processHooks(ScriptObject *o, int dlfid, scriptVar **table, int nparams); + void addClassHook(ScriptHook *h); + void addObjectHook(ScriptHook *h, ScriptObject *o); + void removeHooks(ScriptHook *h); + + enum { + GETCLASSGUID = 100, + GETCLASSNAME = 200, + GETANCESTORCLASSNAME = 300, + GETNUMFUNCTIONS = 400, + GETEXPORTEDFUNCTIONS = 500, + INSTANTIATE = 600, + DESTROY = 700, + GETCLASSID = 800, + SETCLASSID = 900, + SETANCESTORCLASSID = 1000, + GETANCESTORCLASSID = 1100, + GETINSTANTIABLE = 1200, + GETREFERENCEABLE = 1300, + PROCESSHOOKS = 1400, + GETANCESTORCONTROLLER = 1500, + ADDCLASSHOOK = 1600, + ADDOBJHOOK = 1700, + REMHOOKS = 1800, + ONREGISTERCLASS = 1900, + ENCAPSULATE = 2000, + DEENCAPSULATE = 2100, + CAST = 2200, + }; +}; + +inline GUID ScriptObjectController::getClassGuid() { + return _call(GETCLASSGUID, ROOT_GUID); +} + +inline const wchar_t *ScriptObjectController::getClassName() +{ + return _call(GETCLASSNAME, (const wchar_t *)NULL); +} + +inline const wchar_t *ScriptObjectController::getAncestorClassName() { + return _call(GETANCESTORCLASSNAME, (const wchar_t *)NULL); +} + +inline int ScriptObjectController::getNumFunctions() { + return _call(GETNUMFUNCTIONS, 0); +} + +inline const function_descriptor_struct *ScriptObjectController::getExportedFunctions() { + return _call(GETEXPORTEDFUNCTIONS, (const function_descriptor_struct *)NULL); +} + +inline ScriptObject *ScriptObjectController::instantiate() { + return _call(INSTANTIATE, (ScriptObject *)NULL); +} + +inline void ScriptObjectController::destroy(ScriptObject *o) { + _voidcall(DESTROY, o); +} + +inline int ScriptObjectController::getClassId() { + return _call(GETCLASSID, 0); +} + +inline void ScriptObjectController::setClassId(int id) { + _voidcall(SETCLASSID, id); +} + +inline int ScriptObjectController::getAncestorClassId() { + return _call(GETANCESTORCLASSID, 0); +} + +inline void ScriptObjectController::setAncestorClassId(int id) { + _voidcall(SETANCESTORCLASSID, id); +} + +inline int ScriptObjectController::getInstantiable() { + return _call(GETINSTANTIABLE, 0); +} + +inline int ScriptObjectController::getReferenceable() { + return _call(GETREFERENCEABLE, 0); +} + +inline ScriptObjectController *ScriptObjectController::getAncestorController() { + return _call(GETANCESTORCONTROLLER, (ScriptObjectController *)NULL); +} + +inline int ScriptObjectController::processHooks(ScriptObject *o, int dlfid, scriptVar **table, int nparams) { + return _call(PROCESSHOOKS, 0, o, dlfid, table, nparams); +} + +inline void ScriptObjectController::addClassHook(ScriptHook *h) { + _voidcall(ADDCLASSHOOK, h); +} + +inline void ScriptObjectController::addObjectHook(ScriptHook *h, ScriptObject *o) { + _voidcall(ADDOBJHOOK, h, o); +} + +inline void ScriptObjectController::removeHooks(ScriptHook *h) { + _voidcall(REMHOOKS, h); +} + +inline void ScriptObjectController::onRegisterClass(ScriptObjectController *rootController) { + _voidcall(ONREGISTERCLASS, rootController); +} + +inline void *ScriptObjectController::encapsulate(ScriptObject *o) { + return _call(ENCAPSULATE, (void *) NULL, o); +} + +inline void ScriptObjectController::deencapsulate(void *o) { + _voidcall(DEENCAPSULATE, o); +} + +inline ScriptObject *ScriptObjectController::cast(ScriptObject *o, GUID g) { + return _call(CAST, (ScriptObject *)NULL, o, g); +} + +class ScriptObjectControllerI : public ScriptObjectController { + public: + + ScriptObjectControllerI(); + virtual ~ScriptObjectControllerI(); + + virtual void onRegisterClass(ScriptObjectController *rootController); + virtual GUID getClassGuid()=0; + virtual const wchar_t *getClassName()=0; + virtual const wchar_t *getAncestorClassName()=0; + virtual ScriptObjectController *getAncestorController()=0; + virtual int getNumFunctions()=0; + virtual const function_descriptor_struct *getExportedFunctions()=0; + virtual ScriptObject *instantiate()=0; + virtual void destroy(ScriptObject *o)=0; + virtual void *encapsulate(ScriptObject *o)=0; + virtual void deencapsulate(void *o)=0; + virtual ScriptObject *cast(ScriptObject *o, GUID g); + + virtual void setClassId(int id) { my_class_id = id; } + virtual int getClassId() { return my_class_id; } + virtual void setAncestorClassId(int id) { my_ancestor_class_id = id; } + virtual int getAncestorClassId() { return my_ancestor_class_id; } + virtual int getInstantiable() { return 1; }; + virtual int getReferenceable() { return 1; }; + virtual int processHooks(ScriptObject *o, int dlfid, scriptVar **table, int nparams); + virtual void addClassHook(ScriptHook *h); + virtual void addObjectHook(ScriptHook *h, ScriptObject *o); + virtual void removeHooks(ScriptHook *h); + + private: + int my_class_id; + int my_ancestor_class_id; + + PtrList objhooks; + PtrList classhooks; + ScriptObjectController *rootController; + int incast; + + protected: + RECVS_DISPATCH; +}; + +#endif diff --git a/Src/Wasabi/api/script/objcontrollert.cpp b/Src/Wasabi/api/script/objcontrollert.cpp new file mode 100644 index 00000000..ceeb0d64 --- /dev/null +++ b/Src/Wasabi/api/script/objcontrollert.cpp @@ -0,0 +1 @@ +#include "precomp.h" diff --git a/Src/Wasabi/api/script/objcontrollert.h b/Src/Wasabi/api/script/objcontrollert.h new file mode 100644 index 00000000..5d0e37ef --- /dev/null +++ b/Src/Wasabi/api/script/objcontrollert.h @@ -0,0 +1,67 @@ +#ifndef __SCRIPTOBJECTCONTROLLERT_H +#define __SCRIPTOBJECTCONTROLLERT_H + +#include "objcontroller.h" + +template +class ScriptObjectControllerT : public ScriptObjectControllerI { +public: + virtual const wchar_t *getClassName() { return T::scriptobject_getClassName(); } + virtual const wchar_t *getAncestorClassName() { return A::scriptobject_getClassName(); } + virtual ScriptObjectController *getAncestorController() { + return WASABI_API_MAKI->maki_getController(A::scriptobject_getClassGuid()); + } + virtual GUID getClassGuid() { return T::scriptobject_getClassGuid(); } + virtual ScriptObject *instantiate() { + return (new T)->getScriptObject(); + } + virtual void destroy(ScriptObject *o) { + T *t = static_cast(o->vcpu_getInterface(T::scriptobject_getClassGuid())); + delete t; + } + virtual void *encapsulate(ScriptObject *o) { return NULL; } + virtual void deencapsulate(void *o) { } + +#if 0 + virtual int getNumFunctions() { return fn_descs.getNumItems(); } + virtual const function_descriptor_struct *getExportedFunctions() { + return fn_descs.enumRef(0); + } +protected: + void addFn(const wchar_t *fnname, scriptcb *cb) { + function_descriptor_struct fds; + fds.function_name = fnname; + fds.nparams = cb->getNumParams(); + fds.physical_ptr = cb-> + } +private: + TList fn_descs; +#endif +}; + +#if 0 +class scriptcb { +public: + virtual void *getNumParams()=0; + virtual void *getfn()=0; +}; + +template +class scriptcb0v : public scriptcb { + typedef void (T::*fnPtrType)(); +public: + scriptcb0v(fnPtrType _fn) : fn(_fn) { } + static scriptVar call(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + T *t = static_cast(o->vcpu_getInterface(T::scriptobject_getClassGuid())); + if (t) (t->*fn)(); + RETURN_SCRIPT_VOID; + } + virtual void *getNumParams() { return 0; } + virtual void *getfn() { + return static_cast(call); + } +}; +#endif + +#endif diff --git a/Src/Wasabi/api/script/objects/PlaylistScriptObject.cpp b/Src/Wasabi/api/script/objects/PlaylistScriptObject.cpp new file mode 100644 index 00000000..aa177956 --- /dev/null +++ b/Src/Wasabi/api/script/objects/PlaylistScriptObject.cpp @@ -0,0 +1,438 @@ +// ----------------------------------------------------------------------------------------------------- +// Playlist Script Object +// +// functions for +// ----------------------------------------------------------------------------------------------------- + +#include +#include "main.h" + +#include "PlaylistScriptObject.h" + +#include +#include +#include +#include +#include + +#ifdef WASABI_COMPILE_MEDIACORE +#include +#include +#include +#include // safe to include even if core isn't there +#endif + +static PlaylistScriptController _playlistController; +ScriptObjectController *playlistController = &_playlistController; + + +#ifndef _WASABIRUNTIME + +BEGIN_SERVICES(PlaylistObject_Svc); +DECLARE_SERVICE(ScriptObjectCreator); +END_SERVICES(PlaylistObject_Svc, _PlaylistObject_Svc); + +#ifdef _X86_ +extern "C" { int _link_PlaylistObjectSvc; } +#else +extern "C" { int __link_PlaylistObjectSvc; } +#endif + +#endif + + +// ----------------------------------------------------------------------------------------------------- +// Functions Table +function_descriptor_struct PlaylistScriptController::exportedFunction[] = +{ + {L"showCurrentlyPlayingTrack", 0, (void*)SPlaylist::script_vcpu_showCurrentlyPlayingEntry}, + {L"showTrack", 1, (void*)SPlaylist::script_vcpu_showEntry}, + {L"getNumTracks", 0, (void*)SPlaylist::script_vcpu_getNumItems}, + {L"getCurrentIndex", 0, (void*)SPlaylist::script_vcpu_getCurrentIndex}, + {L"getRating", 1, (void*)SPlaylist::script_vcpu_getTrackRating}, + {L"setRating", 2, (void*)SPlaylist::script_vcpu_setTrackRating}, + {L"enqueueFile", 1, (void*)SPlaylist::script_vcpu_enqueueFile }, + {L"clear", 0, (void*)SPlaylist::script_vcpu_clear }, + {L"removeTrack", 1, (void*)SPlaylist::script_vcpu_removeTrack }, + {L"swapTracks", 2, (void*)SPlaylist::script_vcpu_swapTrack }, + {L"moveUp", 1, (void*)SPlaylist::script_vcpu_moveUp }, + {L"moveDown", 1, (void*)SPlaylist::script_vcpu_moveDown }, + {L"moveTo", 2, (void*)SPlaylist::script_vcpu_moveTo }, + {L"getTitle", 1, (void*)SPlaylist::script_vcpu_getTitle }, + {L"getLength", 1, (void*)SPlaylist::script_vcpu_getLength }, + {L"getMetaData", 2, (void*)SPlaylist::script_vcpu_getExtendedInfo }, + {L"getNumSelectedTracks", 0, (void*)SPlaylist::script_vcpu_getNumSelectedItems }, + {L"getNextSelectedTrack", 1, (void*)SPlaylist::script_vcpu_getNextSelectedItem }, + {L"getFileName", 1, (void*)SPlaylist::script_vcpu_getFileName }, + {L"playTrack", 1, (void*)SPlaylist::script_vcpu_playTrack }, + {L"onPleditModified", 0, (void*)SPlaylist::script_vcpu_onPleditModified }, +}; + +ScriptObjectController *PlaylistScriptObjectSvc::getController(int n) +{ + switch (n) { + case 0: + return playlistController; + } + return NULL; +} + +ScriptObject *PlaylistScriptController::instantiate() +{ + SPlaylist *c = new SPlaylist; + if (!c) return NULL; + return c->getScriptObject(); +} + +void PlaylistScriptController::destroy(ScriptObject *o) +{ + SPlaylist *obj = static_cast(o->vcpu_getInterface(playlistScriptObjectGUID)); + ASSERT(obj != NULL); + delete obj; +} + +void *PlaylistScriptController::encapsulate(ScriptObject *o) +{ + return NULL; +} + +void PlaylistScriptController::deencapsulate(void *o) +{ +} + +int PlaylistScriptController::getNumFunctions() +{ + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +SPlaylist::SPlaylist() +{ + getScriptObject()->vcpu_setInterface(playlistScriptObjectGUID, (void *)static_cast(this)); + getScriptObject()->vcpu_setClassName(L"PlEdit"); + getScriptObject()->vcpu_setController(playlistController); + + SOList.addItem(this); +} + +SPlaylist::~SPlaylist() +{ + SOList.removeItem(this); +} + +// Script helper functions + +void SPlaylist::onPleditModified () +{ + //This one is not working + for (int i=0; i < SOList.getNumItems(); i++) + { + //script_vcpu_onPleditModified(SCRIPT_CALL, getScriptObject()); + script_vcpu_onPleditModified(SCRIPT_CALL, SOList.enumItem(i)->getScriptObject()); + //Std::messageBox(SOList.enumItem(i)->getClassName(), t, 0); + } +} + +void SPlaylist::showEntry( int i) +{ + HWND hPeWindow = wa2.getWnd(IPC_GETWND_PE); + SendMessageW(hPeWindow, WM_USER, 666, i); +} + +void SPlaylist::swap(int track1, int track2) +{ + HWND hPeWindow = wa2.getWnd(IPC_GETWND_PE); + + int i = wa2.PE_getCurrentIndex(); + + int param = ((track1) << 16) | (track2); + SendMessageW(hPeWindow, WM_USER, IPC_PE_SWAPINDEX, param); + + //Swap our currently playing item as well + if (i == track1) + { + wa2.PE_setCurrentIndex(track2); + } + else if (i == track2) + { + wa2.PE_setCurrentIndex(track1); + } +} + +fileinfoW *SPlaylist::getFileInfoStructW1 (int item) +{ + static fileinfoW fi; + fi.index = item; + *(fi.file) = 0; + HWND hPeWindow = wa2.getWnd(IPC_GETWND_PE); + SendMessageW(hPeWindow, WM_USER, IPC_PE_GETINDEXINFOW_INPROC, (LPARAM)&fi); + return &fi; +} + +// Script Calls + +scriptVar SPlaylist::script_vcpu_showCurrentlyPlayingEntry(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT + + showEntry (wa2.PE_getCurrentIndex()); + + RETURN_SCRIPT_VOID; +} + + +scriptVar SPlaylist::script_vcpu_showEntry(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i) +{ + SCRIPT_FUNCTION_INIT + + showEntry (GET_SCRIPT_INT(i)); + + RETURN_SCRIPT_VOID; +} + +scriptVar SPlaylist::script_vcpu_getNumItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT + + int i = wa2.PE_getNumItems(); + + return MAKE_SCRIPT_INT(i); +} + +scriptVar SPlaylist::script_vcpu_getCurrentIndex(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT + + int i = wa2.PE_getCurrentIndex(); + + return MAKE_SCRIPT_INT(i); +} + +scriptVar SPlaylist::script_vcpu_setTrackRating(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i, scriptVar rating) +{ + SCRIPT_FUNCTION_INIT + + HWND hwnd_winamp = wa2.getMainWindow(); + + int cur_pos = wa2.PE_getCurrentIndex(); + wa2.PE_setCurrentIndex(GET_SCRIPT_INT(i)); + SendMessageW(hwnd_winamp, WM_WA_IPC, GET_SCRIPT_INT(rating), IPC_SETRATING); + wa2.PE_setCurrentIndex(cur_pos); + + RETURN_SCRIPT_VOID; +} + +scriptVar SPlaylist::script_vcpu_getTrackRating(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i) +{ + SCRIPT_FUNCTION_INIT + + HWND hwnd_winamp = wa2.getMainWindow(); + + int cur_pos = wa2.PE_getCurrentIndex(); + wa2.PE_setCurrentIndex(GET_SCRIPT_INT(i)); + int r = 0; + r = SendMessageW(hwnd_winamp, WM_WA_IPC, GET_SCRIPT_INT(i), IPC_GETRATING); + wa2.PE_setCurrentIndex(cur_pos); + + return MAKE_SCRIPT_INT(r); +} + +scriptVar SPlaylist::script_vcpu_enqueueFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar file) +{ + SCRIPT_FUNCTION_INIT; + + wa2.enqueueFile (GET_SCRIPT_STRING(file)); + + RETURN_SCRIPT_VOID; +} + +scriptVar SPlaylist::script_vcpu_clear(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + + wa2.clearPlaylist(); + + RETURN_SCRIPT_VOID; +} + +scriptVar SPlaylist::script_vcpu_removeTrack(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i) +{ + SCRIPT_FUNCTION_INIT; + + HWND hPeWindow = wa2.getWnd(IPC_GETWND_PE); + SendMessageW(hPeWindow, WM_USER, IPC_PE_DELETEINDEX, GET_SCRIPT_INT(i)); + + RETURN_SCRIPT_VOID; +} + +scriptVar SPlaylist::script_vcpu_swapTrack(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track1, scriptVar _track2) +{ + SCRIPT_FUNCTION_INIT; + + int track1 = GET_SCRIPT_INT(_track1); + int track2 = GET_SCRIPT_INT(_track2); + + if (track1 >= wa2.PE_getNumItems() || track1 < 0 || track2 >= wa2.PE_getNumItems() || track2 < 0) RETURN_SCRIPT_VOID; + swap ((track1), (track2)); + + RETURN_SCRIPT_VOID; +} + +scriptVar SPlaylist::script_vcpu_moveUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track) +{ + SCRIPT_FUNCTION_INIT; + + int track = GET_SCRIPT_INT(_track); + if (track < wa2.PE_getNumItems()-1) swap (track, track+1); + + RETURN_SCRIPT_VOID; +} + +scriptVar SPlaylist::script_vcpu_moveDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track) +{ + SCRIPT_FUNCTION_INIT; + + int track = GET_SCRIPT_INT(_track); + if (track > 0) swap (track, track-1); + + RETURN_SCRIPT_VOID; +} + +scriptVar SPlaylist::script_vcpu_moveTo(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track, scriptVar _pos) +{ + SCRIPT_FUNCTION_INIT; + + int track = GET_SCRIPT_INT(_track); + int pos = GET_SCRIPT_INT(_pos); + + if (track == pos || pos >= wa2.PE_getNumItems() || pos < 0 || track >= wa2.PE_getNumItems() || track < 0) + { + RETURN_SCRIPT_VOID; + } + + // Martin> This can be done much faster :P + /*if (track > pos) + { + for (int i = track; i > pos; i--) + { + swap (i, i-1); + } + } + else + { + for (int i = track; i < pos; i++) + { + swap (i, i+1); + } + }*/ + HWND hPeWindow = wa2.getWnd(IPC_GETWND_PE); + fileinfoW *fi = getFileInfoStructW1(track); + SendMessageW(hPeWindow, WM_USER, IPC_PE_DELETEINDEX, fi->index); + fi->index = pos; + static COPYDATASTRUCT cds; + cds.dwData = IPC_PE_INSERTFILENAMEW; + cds.lpData = fi; + SendMessageW(hPeWindow, WM_COPYDATA, NULL, (LPARAM)&cds); + + RETURN_SCRIPT_VOID; +} + +scriptVar SPlaylist::script_vcpu_getTitle(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track) +{ + SCRIPT_FUNCTION_INIT; + + int track = GET_SCRIPT_INT(_track); + + // Martin> There might be a better way to convert this;) + // benski> yes, there is :) see below. There's a unicode equivalent API for this, just wasn't enabled in wa2frontend object + // so I added it + fileinfo2W *fi = wa2.PE_getFileTitleW(track); + if (fi) + return MAKE_SCRIPT_STRING(fi->filetitle); + else + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar SPlaylist::script_vcpu_getLength(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track) +{ + SCRIPT_FUNCTION_INIT; + + int track = GET_SCRIPT_INT(_track); + + fileinfo2W *fi = wa2.PE_getFileTitleW(track); + if (fi) + return MAKE_SCRIPT_STRING((fi->filelength)); + else + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar SPlaylist::script_vcpu_getFileName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track) +{ + SCRIPT_FUNCTION_INIT; + + int track = GET_SCRIPT_INT(_track); + + fileinfoW *fi = getFileInfoStructW1(track); + + return MAKE_SCRIPT_STRING(fi->file); +} + + +scriptVar SPlaylist::script_vcpu_getExtendedInfo(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track, scriptVar _name) +{ + SCRIPT_FUNCTION_INIT; + + int track = GET_SCRIPT_INT(_track); + const wchar_t *name = GET_SCRIPT_STRING(_name); + + fileinfoW *fi = getFileInfoStructW1(track); + + wa2.getMetaData((fi->file), name, staticStr, 4096); + + return MAKE_SCRIPT_STRING(staticStr); +} + +scriptVar SPlaylist::script_vcpu_getNumSelectedItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + + HWND hPeWindow = wa2.getWnd(IPC_GETWND_PE); + int ret = SendMessageW(hPeWindow, WM_USER, IPC_PE_GETSELECTEDCOUNT, 0); + + return MAKE_SCRIPT_INT(ret); +} + +scriptVar SPlaylist::script_vcpu_getNextSelectedItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track) +{ + SCRIPT_FUNCTION_INIT; + + int track = GET_SCRIPT_INT(_track); + + track = SendMessageW(wa2.getMainWindow(), WM_USER, track, IPC_PLAYLIST_GET_NEXT_SELECTED); + + return MAKE_SCRIPT_INT(track); +} + +scriptVar SPlaylist::script_vcpu_playTrack(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + int track = GET_SCRIPT_INT(_track); + WASABI_API_MEDIACORE->core_userButton(0, UserButton::STOP); + wa2.PE_setCurrentIndex(track); + WASABI_API_MEDIACORE->core_userButton(0, UserButton::PLAY); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SPlaylist::script_vcpu_onPleditModified(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, playlistController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +wchar_t SPlaylist::staticStr[4096] = {0}; +PtrList < SPlaylist > SPlaylist::SOList; \ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/PlaylistScriptObject.h b/Src/Wasabi/api/script/objects/PlaylistScriptObject.h new file mode 100644 index 00000000..db21e54b --- /dev/null +++ b/Src/Wasabi/api/script/objects/PlaylistScriptObject.h @@ -0,0 +1,102 @@ +#ifndef NULLSOFT_GEN_FF_PLAYLISTSCRIPTOBJECT_H +#define NULLSOFT_GEN_FF_PLAYLISTSCRIPTOBJECT_H + +#include "wa2frontend.h" + +class SPlaylist; + +#include +#include +#include +#include + +#include + +// ----------------------------------------------------------------------------------------------------- +// ScriptObject Provider Service + +class PlaylistScriptObjectSvc : public svc_scriptObjectI { + +public: + PlaylistScriptObjectSvc() {}; + virtual ~PlaylistScriptObjectSvc() {}; + + static const char *getServiceName() { return "PlEdit maki object"; } + virtual ScriptObjectController *getController(int n); +}; + +// ----------------------------------------------------------------------------------------------------- +// PlaylistScriptObject GUID +// {345BEEBC-0229-4921-90BE-6CB6A49A79D9} +static const GUID playlistScriptObjectGUID = +{ 0x345beebc, 0x229, 0x4921, { 0x90, 0xbe, 0x6c, 0xb6, 0xa4, 0x9a, 0x79, 0xd9 } }; + +#define SPLAYLIST_SCRIPTPARENT RootObjectInstance + +// ----------------------------------------------------------------------------------------------------- +// ScriptObject Service + +class PlaylistScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName() { return L"PlEdit"; } + virtual const wchar_t *getAncestorClassName() { return L"Object"; } + virtual ScriptObjectController *getAncestorController() { return rootScriptObjectController; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions() { return exportedFunction; } + virtual GUID getClassGuid() { return playlistScriptObjectGUID; } + //virtual int getInstantiable() { return 0; } + //virtual int getReferenceable() { return 0; } + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern ScriptObjectController *playlistController; + +class SPlaylist : public SPLAYLIST_SCRIPTPARENT { +public: + SPlaylist(); + virtual ~SPlaylist(); + + static PtrList < SPlaylist > SOList; + + static void onPleditModified(); + static void showEntry (int i); + static void swap (int a, int b); + static fileinfoW * getFileInfoStructW1 (int index); + + // Maki functions table + static scriptVar script_vcpu_showCurrentlyPlayingEntry(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_showEntry(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i); + static scriptVar script_vcpu_getCurrentIndex(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getNumItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getTrackRating(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i); + static scriptVar script_vcpu_setTrackRating(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i, scriptVar rating); + static scriptVar script_vcpu_enqueueFile (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar file); + static scriptVar script_vcpu_clear(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_removeTrack(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i); + static scriptVar script_vcpu_swapTrack(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar track, scriptVar to); + static scriptVar script_vcpu_moveUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar track); + static scriptVar script_vcpu_moveDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar track); + static scriptVar script_vcpu_moveTo(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar track, scriptVar to); + static scriptVar script_vcpu_getTitle(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track); + static scriptVar script_vcpu_getLength(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track); + static scriptVar script_vcpu_getExtendedInfo(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track, scriptVar _name); + static scriptVar script_vcpu_getNumSelectedItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getNextSelectedItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _num); + static scriptVar script_vcpu_getFileName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _num); + static scriptVar script_vcpu_playTrack(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _num); + static scriptVar script_vcpu_onPleditModified(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + +private: + static wchar_t staticStr[4096]; +}; + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/c_script/c_browser.cpp b/Src/Wasabi/api/script/objects/c_script/c_browser.cpp new file mode 100644 index 00000000..fdb167b9 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_browser.cpp @@ -0,0 +1,127 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include "c_browser.h" +#include + +C_Browser::C_Browser(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + C_hook(object); +} + +C_Browser::C_Browser() { + inited = 0; + obj = NULL; +} + +void C_Browser::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, browserGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + navigateurl_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"navigateUrl", this); + back_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"back", this); + forward_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"forward", this); + stop_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"stop", this); + refresh_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"refresh", this); + home_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"home", this); + settargetname_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setTargetName", this); + onbeforenavigate_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onBeforeNavigate", this); + ondocumentcomplete_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onDocumentComplete", this); + onmedialink_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onMediaLink", this); + } + inited = 1; +} + +C_Browser::~C_Browser() { +} + +ScriptObject *C_Browser::getScriptObject() { + if (obj != NULL) return obj; + return C_BROWSER_PARENT::getScriptObject(); +} + +void C_Browser::navigateUrl(const wchar_t *url) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(url); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), navigateurl_id, params); +} + +void C_Browser::back() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), back_id, NULL); +} + +void C_Browser::forward() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), forward_id, NULL); +} + +void C_Browser::stop() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), stop_id, NULL); +} + +void C_Browser::refresh() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), refresh_id, NULL); +} + +void C_Browser::home() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), home_id, NULL); +} + +void C_Browser::setTargetName(const wchar_t *targetname) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(targetname); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), settargetname_id, params); +} + +int C_Browser::onBeforeNavigate(const wchar_t *url, int flags, const wchar_t *targetframename) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(url); + scriptVar b = MAKE_SCRIPT_INT(flags); + scriptVar c = MAKE_SCRIPT_STRING(targetframename); + scriptVar *params[3] = {&a, &b, &c}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onbeforenavigate_id, params)); +} + +void C_Browser::onDocumentComplete(const wchar_t *url) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(url); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ondocumentcomplete_id, params); +} + +void C_Browser::onMediaLink(const wchar_t *url) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(url); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onmedialink_id, params); +} + +int C_Browser::loaded=0; +int C_Browser::navigateurl_id=0; +int C_Browser::back_id=0; +int C_Browser::forward_id=0; +int C_Browser::stop_id=0; +int C_Browser::refresh_id=0; +int C_Browser::home_id=0; +int C_Browser::settargetname_id=0; +int C_Browser::onbeforenavigate_id=0; +int C_Browser::ondocumentcomplete_id=0; +int C_Browser::onmedialink_id=0; + diff --git a/Src/Wasabi/api/script/objects/c_script/c_browser.h b/Src/Wasabi/api/script/objects/c_script/c_browser.h new file mode 100644 index 00000000..63b12b25 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_browser.h @@ -0,0 +1,49 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_BROWSER_H +#define __C_BROWSER_H + +#include "c_guiobject.h" + +#define C_BROWSER_PARENT C_GuiObject + +class C_Browser : public C_BROWSER_PARENT { + public: + + C_Browser(ScriptObject *object); + C_Browser(); + virtual ~C_Browser(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void navigateUrl(const wchar_t *url); + virtual void back(); + virtual void forward(); + virtual void stop(); + virtual void refresh(); + virtual void home(); + virtual void setTargetName(const wchar_t *targetname); + virtual int onBeforeNavigate(const wchar_t *url, int flags, const wchar_t *targetframename); + virtual void onDocumentComplete(const wchar_t *url); + virtual void onMediaLink(const wchar_t *url); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int navigateurl_id; + static int back_id; + static int forward_id; + static int stop_id; + static int refresh_id; + static int home_id; + static int settargetname_id; + static int onbeforenavigate_id; + static int ondocumentcomplete_id; + static int onmedialink_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_button.cpp b/Src/Wasabi/api/script/objects/c_script/c_button.cpp new file mode 100644 index 00000000..f22c73b6 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_button.cpp @@ -0,0 +1,104 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include "c_button.h" +#include + +C_Button::C_Button(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + C_hook(object); +} + +C_Button::C_Button() { + inited = 0; + obj = NULL; +} + +void C_Button::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, buttonGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + onactivate_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onActivate", this); + onleftclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onLeftClick", this); + onrightclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onRightClick", this); + setactivated_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setActivated", this); + setactivatednocallback_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setActivatedNoCallback", this); + getactivated_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getActivated", this); + leftclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"leftClick", this); + rightclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"rightClick", this); + } + inited = 1; +} + +C_Button::~C_Button() { +} + +ScriptObject *C_Button::getScriptObject() { + if (obj != NULL) return obj; + return C_BUTTON_PARENT::getScriptObject(); +} + +void C_Button::onActivate(int activated) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(activated); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onactivate_id, params); +} + +void C_Button::onLeftClick() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onleftclick_id, NULL); +} + +void C_Button::onRightClick() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onrightclick_id, NULL); +} + +void C_Button::setActivated(int onoff) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(onoff); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setactivated_id, params); +} + +void C_Button::setActivatedNoCallback(int onoff) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(onoff); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setactivatednocallback_id, params); +} + +int C_Button::getActivated() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getactivated_id, NULL)); +} + +void C_Button::leftClick() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), leftclick_id, NULL); +} + +void C_Button::rightClick() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), rightclick_id, NULL); +} + +int C_Button::loaded=0; +int C_Button::onactivate_id=0; +int C_Button::onleftclick_id=0; +int C_Button::onrightclick_id=0; +int C_Button::setactivated_id=0; +int C_Button::setactivatednocallback_id=0; +int C_Button::getactivated_id=0; +int C_Button::leftclick_id=0; +int C_Button::rightclick_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_button.h b/Src/Wasabi/api/script/objects/c_script/c_button.h new file mode 100644 index 00000000..44af7579 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_button.h @@ -0,0 +1,45 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_BUTTON_H +#define __C_BUTTON_H + +#include "c_guiobject.h" + +#define C_BUTTON_PARENT C_GuiObject + +class C_Button : public C_BUTTON_PARENT { + public: + + C_Button(ScriptObject *object); + C_Button(); + virtual ~C_Button(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void onActivate(int activated); + virtual void onLeftClick(); + virtual void onRightClick(); + virtual void setActivated(int onoff); + virtual void setActivatedNoCallback(int onoff); + virtual int getActivated(); + virtual void leftClick(); + virtual void rightClick(); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onactivate_id; + static int onleftclick_id; + static int onrightclick_id; + static int setactivated_id; + static int setactivatednocallback_id; + static int getactivated_id; + static int leftclick_id; + static int rightclick_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_checkbox.cpp b/Src/Wasabi/api/script/objects/c_script/c_checkbox.cpp new file mode 100644 index 00000000..f5e82571 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_checkbox.cpp @@ -0,0 +1,84 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include "c_checkbox.h" +#include + +C_CheckBox::C_CheckBox(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + C_hook(object); +} + +C_CheckBox::C_CheckBox() { + inited = 0; + obj = NULL; +} + +void C_CheckBox::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, checkBoxGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + ontoggle_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onToggle", this); + setchecked_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setChecked", this); + ischecked_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isChecked", this); + settext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setText", this); + gettext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getText", this); + } + inited = 1; +} + +C_CheckBox::~C_CheckBox() { +} + +ScriptObject *C_CheckBox::getScriptObject() { + if (obj != NULL) return obj; + return C_CHECKBOX_PARENT::getScriptObject(); +} + +void C_CheckBox::onToggle(int newstate) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(newstate); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ontoggle_id, params); +} + +void C_CheckBox::setChecked(int checked) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(checked); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setchecked_id, params); +} + +int C_CheckBox::isChecked() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), ischecked_id, NULL)); +} + +void C_CheckBox::setText(const wchar_t *txt) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(txt); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), settext_id, params); +} + +const wchar_t *C_CheckBox::getText() { + ASSERT(inited); + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), gettext_id, NULL)); +} + +int C_CheckBox::loaded=0; +int C_CheckBox::ontoggle_id=0; +int C_CheckBox::setchecked_id=0; +int C_CheckBox::ischecked_id=0; +int C_CheckBox::settext_id=0; +int C_CheckBox::gettext_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_checkbox.h b/Src/Wasabi/api/script/objects/c_script/c_checkbox.h new file mode 100644 index 00000000..7a42a810 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_checkbox.h @@ -0,0 +1,39 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_CHECKBOX_H +#define __C_CHECKBOX_H + +#include "c_guiobject.h" + +#define C_CHECKBOX_PARENT C_GuiObject + +class C_CheckBox : public C_CHECKBOX_PARENT { + public: + + C_CheckBox(ScriptObject *object); + C_CheckBox(); + virtual ~C_CheckBox(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void onToggle(int newstate); + virtual void setChecked(int checked); + virtual int isChecked(); + virtual void setText(const wchar_t *txt); + virtual const wchar_t *getText(); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int ontoggle_id; + static int setchecked_id; + static int ischecked_id; + static int settext_id; + static int gettext_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_container.cpp b/Src/Wasabi/api/script/objects/c_script/c_container.cpp new file mode 100644 index 00000000..d9db7641 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_container.cpp @@ -0,0 +1,179 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include "c_container.h" +#include + +C_Container::C_Container(ScriptObject *object) : C_RootObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_Container::C_Container() { + inited = 0; + obj = NULL; +} + +void C_Container::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, containerGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + onswitchtolayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSwitchToLayout", this); + onbeforeswitchtolayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onBeforeSwitchToLayout", this); + setxmlparam_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setXmlParam", this); + onhidelayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onHideLayout", this); + onshowlayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onShowLayout", this); + getlayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getLayout", this); + getnumlayouts_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNumLayouts", this); + enumlayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"enumLayout", this); + switchtolayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"switchToLayout", this); + show_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"show", this); + hide_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"hide", this); + close_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"close", this); + toggle_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"toggle", this); + isdynamic_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isDynamic", this); + setname_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setName", this); + getcurlayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getCurLayout", this); + } + inited = 1; +} + +C_Container::~C_Container() { +} + +ScriptObject *C_Container::getScriptObject() { + if (obj != NULL) return obj; + return C_CONTAINER_PARENT::getScriptObject(); +} + +void C_Container::onSwitchToLayout(ScriptObject *newlayout) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(newlayout); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onswitchtolayout_id, params); +} + +void C_Container::onBeforeSwitchToLayout(ScriptObject *oldlayout, ScriptObject *newlayout) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(oldlayout); + scriptVar b = MAKE_SCRIPT_OBJECT(newlayout); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onbeforeswitchtolayout_id, params); +} + +void C_Container::setXmlParam(const wchar_t *param, const wchar_t *value) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(param); + scriptVar b = MAKE_SCRIPT_STRING(value); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setxmlparam_id, params); +} + +void C_Container::onHideLayout(ScriptObject *_layout) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(_layout); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onhidelayout_id, params); +} + +void C_Container::onShowLayout(ScriptObject *_layout) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(_layout); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onshowlayout_id, params); +} + +ScriptObject *C_Container::getLayout(const wchar_t *layout_id) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(layout_id); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getlayout_id, params)); +} + +int C_Container::getNumLayouts() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnumlayouts_id, NULL)); +} + +ScriptObject *C_Container::enumLayout(int num) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(num); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), enumlayout_id, params)); +} + +void C_Container::switchToLayout(const wchar_t *layout_id) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(layout_id); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), switchtolayout_id, params); +} + +void C_Container::show() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), show_id, NULL); +} + +void C_Container::hide() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), hide_id, NULL); +} + +void C_Container::close() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), close_id, NULL); +} + +void C_Container::toggle() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), toggle_id, NULL); +} + +int C_Container::isDynamic() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), isdynamic_id, NULL)); +} + +void C_Container::setName(const wchar_t *name) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(name); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setname_id, params); +} + +ScriptObject *C_Container::getCurLayout() { + ASSERT(inited); + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcurlayout_id, NULL)); +} + +int C_Container::loaded=0; +int C_Container::onswitchtolayout_id=0; +int C_Container::onbeforeswitchtolayout_id=0; +int C_Container::setxmlparam_id=0; +int C_Container::onhidelayout_id=0; +int C_Container::onshowlayout_id=0; +int C_Container::getlayout_id=0; +int C_Container::getnumlayouts_id=0; +int C_Container::enumlayout_id=0; +int C_Container::switchtolayout_id=0; +int C_Container::show_id=0; +int C_Container::hide_id=0; +int C_Container::close_id=0; +int C_Container::toggle_id=0; +int C_Container::isdynamic_id=0; +int C_Container::setname_id=0; +int C_Container::getcurlayout_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_container.h b/Src/Wasabi/api/script/objects/c_script/c_container.h new file mode 100644 index 00000000..f3fbe908 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_container.h @@ -0,0 +1,61 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_CONTAINER_H +#define __C_CONTAINER_H + +#include "c_rootobj.h" + +#define C_CONTAINER_PARENT C_RootObject + +class C_Container : public C_CONTAINER_PARENT { + public: + + C_Container(ScriptObject *object); + C_Container(); + virtual ~C_Container(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void onSwitchToLayout(ScriptObject *newlayout); + virtual void onBeforeSwitchToLayout(ScriptObject *oldlayout, ScriptObject *newlayout); + virtual void setXmlParam(const wchar_t *param, const wchar_t *value); + virtual void onHideLayout(ScriptObject *_layout); + virtual void onShowLayout(ScriptObject *_layout); + virtual ScriptObject *getLayout(const wchar_t *layout_id); + virtual int getNumLayouts(); + virtual ScriptObject *enumLayout(int num); + virtual void switchToLayout(const wchar_t *layout_id); + virtual void show(); + virtual void hide(); + virtual void close(); + virtual void toggle(); + virtual int isDynamic(); + virtual void setName(const wchar_t *name); + virtual ScriptObject *getCurLayout(); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onswitchtolayout_id; + static int onbeforeswitchtolayout_id; + static int setxmlparam_id; + static int onhidelayout_id; + static int onshowlayout_id; + static int getlayout_id; + static int getnumlayouts_id; + static int enumlayout_id; + static int switchtolayout_id; + static int show_id; + static int hide_id; + static int close_id; + static int toggle_id; + static int isdynamic_id; + static int setname_id; + static int getcurlayout_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_dropdownlist.cpp b/Src/Wasabi/api/script/objects/c_script/c_dropdownlist.cpp new file mode 100644 index 00000000..2dc719fb --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_dropdownlist.cpp @@ -0,0 +1,184 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include "c_dropdownlist.h" +#include + +C_DropDownList::C_DropDownList(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_DropDownList::C_DropDownList() { + inited = 0; + obj = NULL; +} + +void C_DropDownList::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, dropDownListGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + getitemselected_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getItemSelected", this); + onselect_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSelect", this); + setlistheight_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setListHeight", this); + openlist_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"openList", this); + closelist_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"closeList", this); + setitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setItems", this); + additem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"addItem", this); + delitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"delItem", this); + finditem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"findItem", this); + getnumitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNumItems", this); + selectitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"selectItem", this); + getitemtext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getItemText", this); + getselected_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSelected", this); + getselectedtext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSelectedText", this); + getcustomtext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getCustomText", this); + deleteallitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"deleteAllItems", this); + setnoitemtext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setNoItemText", this); + } + inited = 1; +} + +C_DropDownList::~C_DropDownList() { +} + +ScriptObject *C_DropDownList::getScriptObject() { + if (obj != NULL) return obj; + return C_DROPDOWNLIST_PARENT::getScriptObject(); +} + +const wchar_t *C_DropDownList::getItemSelected() +{ + ASSERT(inited); + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getitemselected_id, NULL)); +} + +void C_DropDownList::onSelect(int id, int hover) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(id); + scriptVar b = MAKE_SCRIPT_INT(hover); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onselect_id, params); +} + +void C_DropDownList::setListHeight(int h) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(h); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setlistheight_id, params); +} + +void C_DropDownList::openList() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), openlist_id, NULL); +} + +void C_DropDownList::closeList() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), closelist_id, NULL); +} + +void C_DropDownList::setItems(const wchar_t *lotsofitems) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(lotsofitems); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setitems_id, params); +} + +int C_DropDownList::addItem(const wchar_t *_text) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(_text); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), additem_id, params)); +} + +void C_DropDownList::delItem(int id) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(id); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), delitem_id, params); +} + +int C_DropDownList::findItem(const wchar_t *_text) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(_text); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), finditem_id, params)); +} + +int C_DropDownList::getNumItems() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnumitems_id, NULL)); +} + +void C_DropDownList::selectItem(int id, int hover) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(id); + scriptVar b = MAKE_SCRIPT_INT(hover); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), selectitem_id, params); +} + +const wchar_t *C_DropDownList::getItemText(int id) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(id); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getitemtext_id, params)); +} + +int C_DropDownList::getSelected() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getselected_id, NULL)); +} + +const wchar_t *C_DropDownList::getSelectedText() { + ASSERT(inited); + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getselectedtext_id, NULL)); +} + +const wchar_t *C_DropDownList::getCustomText() { + ASSERT(inited); + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcustomtext_id, NULL)); +} + +void C_DropDownList::deleteAllItems() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), deleteallitems_id, NULL); +} + +void C_DropDownList::setNoItemText(const wchar_t *txt) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(txt); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setnoitemtext_id, params); +} + +int C_DropDownList::loaded=0; +int C_DropDownList::getitemselected_id=0; +int C_DropDownList::onselect_id=0; +int C_DropDownList::setlistheight_id=0; +int C_DropDownList::openlist_id=0; +int C_DropDownList::closelist_id=0; +int C_DropDownList::setitems_id=0; +int C_DropDownList::additem_id=0; +int C_DropDownList::delitem_id=0; +int C_DropDownList::finditem_id=0; +int C_DropDownList::getnumitems_id=0; +int C_DropDownList::selectitem_id=0; +int C_DropDownList::getitemtext_id=0; +int C_DropDownList::getselected_id=0; +int C_DropDownList::getselectedtext_id=0; +int C_DropDownList::getcustomtext_id=0; +int C_DropDownList::deleteallitems_id=0; +int C_DropDownList::setnoitemtext_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_dropdownlist.h b/Src/Wasabi/api/script/objects/c_script/c_dropdownlist.h new file mode 100644 index 00000000..3beba99f --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_dropdownlist.h @@ -0,0 +1,63 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_DROPDOWNLIST_H +#define __C_DROPDOWNLIST_H + +#include "c_guiobject.h" + +#define C_DROPDOWNLIST_PARENT C_GuiObject + +class C_DropDownList : public C_DROPDOWNLIST_PARENT { + public: + + C_DropDownList(ScriptObject *object); + C_DropDownList(); + virtual ~C_DropDownList(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual const wchar_t *getItemSelected(); + virtual void onSelect(int id, int hover); + virtual void setListHeight(int h); + virtual void openList(); + virtual void closeList(); + virtual void setItems(const wchar_t *lotsofitems); + virtual int addItem(const wchar_t *_text); + virtual void delItem(int id); + virtual int findItem(const wchar_t *_text); + virtual int getNumItems(); + virtual void selectItem(int id, int hover); + virtual const wchar_t *getItemText(int id); + virtual int getSelected(); + virtual const wchar_t *getSelectedText(); + virtual const wchar_t *getCustomText(); + virtual void deleteAllItems(); + virtual void setNoItemText(const wchar_t *txt); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int getitemselected_id; + static int onselect_id; + static int setlistheight_id; + static int openlist_id; + static int closelist_id; + static int setitems_id; + static int additem_id; + static int delitem_id; + static int finditem_id; + static int getnumitems_id; + static int selectitem_id; + static int getitemtext_id; + static int getselected_id; + static int getselectedtext_id; + static int getcustomtext_id; + static int deleteallitems_id; + static int setnoitemtext_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_edit.cpp b/Src/Wasabi/api/script/objects/c_script/c_edit.cpp new file mode 100644 index 00000000..4ce40920 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_edit.cpp @@ -0,0 +1,135 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include "c_edit.h" +#include + +C_Edit::C_Edit(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_Edit::C_Edit() { + inited = 0; + obj = NULL; +} + +void C_Edit::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, editGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + onenter_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onEnter", this); + onabort_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onAbort", this); + onidleeditupdate_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onIdleEditUpdate", this); + oneditupdate_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onEditUpdate", this); + settext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setText", this); + setautoenter_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setAutoEnter", this); + getautoenter_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getAutoEnter", this); + gettext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getText", this); + selectall_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"selectAll", this); + enter_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"enter", this); + setidleenabled_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setIdleEnabled", this); + getidleenabled_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getIdleEnabled", this); + } + inited = 1; +} + +C_Edit::~C_Edit() { +} + +ScriptObject *C_Edit::getScriptObject() { + if (obj != NULL) return obj; + return C_EDIT_PARENT::getScriptObject(); +} + +void C_Edit::onEnter() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onenter_id, NULL); +} + +void C_Edit::onAbort() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onabort_id, NULL); +} + +void C_Edit::onIdleEditUpdate() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onidleeditupdate_id, NULL); +} + +void C_Edit::onEditUpdate() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), oneditupdate_id, NULL); +} + +void C_Edit::setText(const wchar_t *txt) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(txt); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), settext_id, params); +} + +void C_Edit::setAutoEnter(int onoff) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(onoff); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setautoenter_id, params); +} + +int C_Edit::getAutoEnter() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getautoenter_id, NULL)); +} + +const wchar_t *C_Edit::getText() +{ + ASSERT(inited); + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), gettext_id, NULL)); +} + +void C_Edit::selectAll() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), selectall_id, NULL); +} + +void C_Edit::enter() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), enter_id, NULL); +} + +void C_Edit::setIdleEnabled(int onoff) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(onoff); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setidleenabled_id, params); +} + +int C_Edit::getIdleEnabled() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getidleenabled_id, NULL)); +} + +int C_Edit::loaded=0; +int C_Edit::onenter_id=0; +int C_Edit::onabort_id=0; +int C_Edit::onidleeditupdate_id=0; +int C_Edit::oneditupdate_id=0; +int C_Edit::settext_id=0; +int C_Edit::setautoenter_id=0; +int C_Edit::getautoenter_id=0; +int C_Edit::gettext_id=0; +int C_Edit::selectall_id=0; +int C_Edit::enter_id=0; +int C_Edit::setidleenabled_id=0; +int C_Edit::getidleenabled_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_edit.h b/Src/Wasabi/api/script/objects/c_script/c_edit.h new file mode 100644 index 00000000..09f96b24 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_edit.h @@ -0,0 +1,53 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_EDIT_H +#define __C_EDIT_H + +#include "c_guiobject.h" + +#define C_EDIT_PARENT C_GuiObject + +class C_Edit : public C_EDIT_PARENT { + public: + + C_Edit(ScriptObject *object); + C_Edit(); + virtual ~C_Edit(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void onEnter(); + virtual void onAbort(); + virtual void onIdleEditUpdate(); + virtual void onEditUpdate(); + virtual void setText(const wchar_t *txt); + virtual void setAutoEnter(int onoff); + virtual int getAutoEnter(); + virtual const wchar_t *getText(); + virtual void selectAll(); + virtual void enter(); + virtual void setIdleEnabled(int onoff); + virtual int getIdleEnabled(); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onenter_id; + static int onabort_id; + static int onidleeditupdate_id; + static int oneditupdate_id; + static int settext_id; + static int setautoenter_id; + static int getautoenter_id; + static int gettext_id; + static int selectall_id; + static int enter_id; + static int setidleenabled_id; + static int getidleenabled_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_group.cpp b/Src/Wasabi/api/script/objects/c_script/c_group.cpp new file mode 100644 index 00000000..8d0cb037 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_group.cpp @@ -0,0 +1,99 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include "c_group.h" +#include + +C_Group::C_Group(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_Group::C_Group() { + inited = 0; + obj = NULL; +} + +void C_Group::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, groupGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + getobject_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getObject", this); + getnumobjects_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNumObjects", this); + enumobject_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"enumObject", this); + oncreateobject_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onCreateObject", this); + getmouseposx_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getMousePosX", this); + getmouseposy_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getMousePosY", this); + islayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isLayout", this); + } + inited = 1; +} + +C_Group::~C_Group() { +} + +ScriptObject *C_Group::getScriptObject() { + if (obj != NULL) return obj; + return C_GROUP_PARENT::getScriptObject(); +} + +ScriptObject *C_Group::getObject(const wchar_t *object_id) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(object_id); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getobject_id, params)); +} + +int C_Group::getNumObjects() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnumobjects_id, NULL)); +} + +ScriptObject *C_Group::enumObject(int num) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(num); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), enumobject_id, params)); +} + +void C_Group::onCreateObject(ScriptObject *newobj) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(newobj); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), oncreateobject_id, params); +} + +int C_Group::getMousePosX() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getmouseposx_id, NULL)); +} + +int C_Group::getMousePosY() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getmouseposy_id, NULL)); +} + +int C_Group::isLayout() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), islayout_id, NULL)); +} + +int C_Group::loaded=0; +int C_Group::getobject_id=0; +int C_Group::getnumobjects_id=0; +int C_Group::enumobject_id=0; +int C_Group::oncreateobject_id=0; +int C_Group::getmouseposx_id=0; +int C_Group::getmouseposy_id=0; +int C_Group::islayout_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_group.h b/Src/Wasabi/api/script/objects/c_script/c_group.h new file mode 100644 index 00000000..2204ec6f --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_group.h @@ -0,0 +1,43 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_GROUP_H +#define __C_GROUP_H + +#include "c_guiobject.h" + +#define C_GROUP_PARENT C_GuiObject + +class C_Group : public C_GROUP_PARENT { + public: + + C_Group(ScriptObject *object); + C_Group(); + virtual ~C_Group(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual ScriptObject *getObject(const wchar_t *object_id); + virtual int getNumObjects(); + virtual ScriptObject *enumObject(int num); + virtual void onCreateObject(ScriptObject *newobj); + virtual int getMousePosX(); + virtual int getMousePosY(); + virtual int isLayout(); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int getobject_id; + static int getnumobjects_id; + static int enumobject_id; + static int oncreateobject_id; + static int getmouseposx_id; + static int getmouseposy_id; + static int islayout_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_grouplist.cpp b/Src/Wasabi/api/script/objects/c_script/c_grouplist.cpp new file mode 100644 index 00000000..e5462602 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_grouplist.cpp @@ -0,0 +1,85 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include +#include +#include "c_grouplist.h" +#include + +C_GroupList::C_GroupList(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_GroupList::C_GroupList() { + inited = 0; + obj = NULL; +} + +void C_GroupList::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, groupListGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + instantiate_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"instantiate", this); + getnumitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNumItems", this); + enumitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"enumItem", this); + removeall_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"removeAll", this); + scrolltopercent_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"scrollToPercent", this); + } + inited = 1; +} + +C_GroupList::~C_GroupList() { +} + +ScriptObject *C_GroupList::getScriptObject() { + if (obj != NULL) return obj; + return C_GROUPLIST_PARENT::getScriptObject(); +} + +ScriptObject *C_GroupList::instantiate(const char *group_id, int num_groups) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(group_id); + scriptVar b = MAKE_SCRIPT_INT(num_groups); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), instantiate_id, params)); +} + +int C_GroupList::getNumItems() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnumitems_id, NULL)); +} + +ScriptObject *C_GroupList::enumItem(int num) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(num); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), enumitem_id, params)); +} + +void C_GroupList::removeAll() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), removeall_id, NULL); +} + +void C_GroupList::scrollToPercent(int percent) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(percent); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), scrolltopercent_id, params); +} + +int C_GroupList::loaded=0; +int C_GroupList::instantiate_id=0; +int C_GroupList::getnumitems_id=0; +int C_GroupList::enumitem_id=0; +int C_GroupList::removeall_id=0; +int C_GroupList::scrolltopercent_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_grouplist.h b/Src/Wasabi/api/script/objects/c_script/c_grouplist.h new file mode 100644 index 00000000..0977e0c4 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_grouplist.h @@ -0,0 +1,39 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_GROUPLIST_H +#define __C_GROUPLIST_H + +#include "c_guiobject.h" + +#define C_GROUPLIST_PARENT C_GuiObject + +class C_GroupList : public C_GROUPLIST_PARENT { + public: + + C_GroupList(ScriptObject *object); + C_GroupList(); + virtual ~C_GroupList(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual ScriptObject *instantiate(const char *group_id, int num_groups); + virtual int getNumItems(); + virtual ScriptObject *enumItem(int num); + virtual void removeAll(); + virtual void scrollToPercent(int percent); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int instantiate_id; + static int getnumitems_id; + static int enumitem_id; + static int removeall_id; + static int scrolltopercent_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_guilist.cpp b/Src/Wasabi/api/script/objects/c_script/c_guilist.cpp new file mode 100644 index 00000000..f28e168a --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_guilist.cpp @@ -0,0 +1,722 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include "c_guilist.h" +#include + +C_GuiList::C_GuiList(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_GuiList::C_GuiList() { + inited = 0; + obj = NULL; +} + +void C_GuiList::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, guiListGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + getnumitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNumItems", this); + getwantautodeselect_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getWantAutoDeselect", this); + setwantautodeselect_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setWantAutoDeselect", this); + onsetvisible_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSetVisible", this); + setautosort_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setAutoSort", this); + next_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"next", this); + selectcurrent_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"selectCurrent", this); + selectfirstentry_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"selectFirstEntry", this); + previous_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"previous", this); + pagedown_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"pagedown", this); + pageup_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"pageup", this); + home_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"home", this); + end_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"end", this); + reset_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"reset", this); + addcolumn_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"addColumn", this); + getnumcolumns_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNumColumns", this); + getcolumnwidth_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getColumnWidth", this); + setcolumnwidth_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setColumnWidth", this); + getcolumnlabel_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getColumnLabel", this); + setcolumnlabel_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setColumnLabel", this); + getcolumnnumeric_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getColumnNumeric", this); + setcolumndynamic_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setColumnDynamic", this); + iscolumndynamic_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isColumnDynamic", this); + setminimumsize_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setMinimumSize", this); + additem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"addItem", this); + insertitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"insertItem", this); + getlastaddeditempos_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getLastAddedItemPos", this); + setsubitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setSubItem", this); + deleteallitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"deleteAllItems", this); + deletebypos_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"deleteByPos", this); + getitemlabel_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getItemLabel", this); + setitemlabel_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setItemLabel", this); + getitemselected_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getItemSelected", this); + isitemfocused_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isItemFocused", this); + getitemfocused_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getItemFocused", this); + setitemfocused_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setItemFocused", this); + ensureitemvisible_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"ensureItemVisible", this); + invalidatecolumns_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"invalidateColumns", this); + scrollabsolute_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"scrollAbsolute", this); + scrollrelative_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"scrollRelative", this); + scrollleft_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"scrollLeft", this); + scrollright_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"scrollRight", this); + scrollup_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"scrollUp", this); + scrolldown_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"scrollDown", this); + getsubitemtext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSubitemText", this); + getfirstitemselected_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getFirstItemSelected", this); + getnextitemselected_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNextItemSelected", this); + selectall_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"selectAll", this); + deselectall_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"deselectAll", this); + invertselection_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"invertSelection", this); + invalidateitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"invalidateItem", this); + getfirstitemvisible_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getFirstItemVisible", this); + getlastitemvisible_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getLastItemVisible", this); + setfontsize_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setFontSize", this); + getfontsize_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getFontSize", this); + jumptonext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"jumpToNext", this); + scrolltoitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"scrollToItem", this); + resort_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"resort", this); + getsortdirection_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSortDirection", this); + getsortcolumn_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSortColumn", this); + setsortcolumn_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setSortColumn", this); + setsortdirection_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setSortDirection", this); + getitemcount_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getItemCount", this); + setselectionstart_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setSelectionStart", this); + setselectionend_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setSelectionEnd", this); + setselected_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setSelected", this); + toggleselection_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"toggleSelection", this); + getheaderheight_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getHeaderHeight", this); + getpreventmultipleselection_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getPreventMultipleSelection", this); + setpreventmultipleselection_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setPreventMultipleSelection", this); + moveitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"moveItem", this); + onselectall_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSelectAll", this); + ondelete_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onDelete", this); + ondoubleclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onDoubleClick", this); + onleftclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onLeftClick", this); + onsecondleftclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSecondLeftClick", this); + onrightclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onRightClick", this); + oncolumndblclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onColumnDblClick", this); + oncolumnlabelclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onColumnLabelClick", this); + onitemselection_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onItemSelection", this); + } + inited = 1; +} + +C_GuiList::~C_GuiList() { +} + +ScriptObject *C_GuiList::getScriptObject() { + if (obj != NULL) return obj; + return C_GUILIST_PARENT::getScriptObject(); +} + +int C_GuiList::getNumItems() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnumitems_id, NULL)); +} + +int C_GuiList::getWantAutoDeselect() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getwantautodeselect_id, NULL)); +} + +void C_GuiList::setWantAutoDeselect(int want) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(want); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setwantautodeselect_id, params); +} + +void C_GuiList::onSetVisible(int show) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(show); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onsetvisible_id, params); +} + +void C_GuiList::setAutoSort(int dosort) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(dosort); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setautosort_id, params); +} + +void C_GuiList::next() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), next_id, NULL); +} + +void C_GuiList::selectCurrent() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), selectcurrent_id, NULL); +} + +void C_GuiList::selectFirstEntry() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), selectfirstentry_id, NULL); +} + +void C_GuiList::previous() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), previous_id, NULL); +} + +void C_GuiList::pagedown() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), pagedown_id, NULL); +} + +void C_GuiList::pageup() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), pageup_id, NULL); +} + +void C_GuiList::home() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), home_id, NULL); +} + +void C_GuiList::end() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), end_id, NULL); +} + +void C_GuiList::reset() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), reset_id, NULL); +} + +int C_GuiList::addColumn(const wchar_t *name, int width, int numeric) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(name); + scriptVar b = MAKE_SCRIPT_INT(width); + scriptVar c = MAKE_SCRIPT_INT(numeric); + scriptVar *params[3] = {&a, &b, &c}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), addcolumn_id, params)); +} + +int C_GuiList::getNumColumns() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnumcolumns_id, NULL)); +} + +int C_GuiList::getColumnWidth(int column) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(column); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcolumnwidth_id, params)); +} + +void C_GuiList::setColumnWidth(int column, int newwidth) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(column); + scriptVar b = MAKE_SCRIPT_INT(newwidth); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setcolumnwidth_id, params); +} + +const wchar_t *C_GuiList::getColumnLabel(int column) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(column); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcolumnlabel_id, params)); +} + +void C_GuiList::setColumnLabel(int column, const wchar_t *newlabel) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(column); + scriptVar b = MAKE_SCRIPT_STRING(newlabel); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setcolumnlabel_id, params); +} + +int C_GuiList::getColumnNumeric(int column) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(column); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcolumnnumeric_id, params)); +} + +void C_GuiList::setColumnDynamic(int column, int isdynamic) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(column); + scriptVar b = MAKE_SCRIPT_INT(isdynamic); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setcolumndynamic_id, params); +} + +int C_GuiList::isColumnDynamic(int column) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(column); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), iscolumndynamic_id, params)); +} + +void C_GuiList::setMinimumSize(int size) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(size); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setminimumsize_id, params); +} + +int C_GuiList::addItem(const wchar_t *label) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(label); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), additem_id, params)); +} + +int C_GuiList::insertItem(int pos, const wchar_t *label) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar b = MAKE_SCRIPT_STRING(label); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), insertitem_id, params)); +} + +int C_GuiList::getLastAddedItemPos() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getlastaddeditempos_id, NULL)); +} + +void C_GuiList::setSubItem(int pos, int subpos, const wchar_t *txt) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar b = MAKE_SCRIPT_INT(subpos); + scriptVar c = MAKE_SCRIPT_STRING(txt); + scriptVar *params[3] = {&a, &b, &c}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setsubitem_id, params); +} + +void C_GuiList::deleteAllItems() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), deleteallitems_id, NULL); +} + +int C_GuiList::deleteByPos(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), deletebypos_id, params)); +} + +const wchar_t *C_GuiList::getItemLabel(int pos, int subpos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar b = MAKE_SCRIPT_INT(subpos); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getitemlabel_id, params)); +} + +void C_GuiList::setItemLabel(int pos, const wchar_t *_text) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar b = MAKE_SCRIPT_STRING(_text); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setitemlabel_id, params); +} + +int C_GuiList::getItemSelected(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getitemselected_id, params)); +} + +int C_GuiList::isItemFocused(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), isitemfocused_id, params)); +} + +int C_GuiList::getItemFocused() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getitemfocused_id, NULL)); +} + +void C_GuiList::setItemFocused(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setitemfocused_id, params); +} + +void C_GuiList::ensureItemVisible(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ensureitemvisible_id, params); +} + +void C_GuiList::invalidateColumns() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), invalidatecolumns_id, NULL); +} + +int C_GuiList::scrollAbsolute(int x) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), scrollabsolute_id, params)); +} + +int C_GuiList::scrollRelative(int x) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), scrollrelative_id, params)); +} + +void C_GuiList::scrollLeft(int lines) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(lines); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), scrollleft_id, params); +} + +void C_GuiList::scrollRight(int lines) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(lines); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), scrollright_id, params); +} + +void C_GuiList::scrollUp(int lines) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(lines); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), scrollup_id, params); +} + +void C_GuiList::scrollDown(int lines) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(lines); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), scrolldown_id, params); +} + +const wchar_t *C_GuiList::getSubitemText(int pos, int subpos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar b = MAKE_SCRIPT_INT(subpos); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getsubitemtext_id, params)); +} + +int C_GuiList::getFirstItemSelected() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getfirstitemselected_id, NULL)); +} + +int C_GuiList::getNextItemSelected(int lastpos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(lastpos); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnextitemselected_id, params)); +} + +int C_GuiList::selectAll() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), selectall_id, NULL)); +} + +int C_GuiList::deselectAll() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), deselectall_id, NULL)); +} + +int C_GuiList::invertSelection() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), invertselection_id, NULL)); +} + +int C_GuiList::invalidateItem(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), invalidateitem_id, params)); +} + +int C_GuiList::getFirstItemVisible() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getfirstitemvisible_id, NULL)); +} + +int C_GuiList::getLastItemVisible() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getlastitemvisible_id, NULL)); +} + +int C_GuiList::setFontSize(int size) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(size); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), setfontsize_id, params)); +} + +int C_GuiList::getFontSize() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getfontsize_id, NULL)); +} + +void C_GuiList::jumpToNext(int c) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(c); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), jumptonext_id, params); +} + +void C_GuiList::scrollToItem(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), scrolltoitem_id, params); +} + +void C_GuiList::resort() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), resort_id, NULL); +} + +int C_GuiList::getSortDirection() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getsortdirection_id, NULL)); +} + +int C_GuiList::getSortColumn() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getsortcolumn_id, NULL)); +} + +void C_GuiList::setSortColumn(int col) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(col); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setsortcolumn_id, params); +} + +void C_GuiList::setSortDirection(int dir) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(dir); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setsortdirection_id, params); +} + +int C_GuiList::getItemCount() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getitemcount_id, NULL)); +} + +void C_GuiList::setSelectionStart(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setselectionstart_id, params); +} + +void C_GuiList::setSelectionEnd(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setselectionend_id, params); +} + +void C_GuiList::setSelected(int pos, int selected) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar b = MAKE_SCRIPT_INT(selected); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setselected_id, params); +} + +void C_GuiList::toggleSelection(int pos, int setfocus) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar b = MAKE_SCRIPT_INT(setfocus); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), toggleselection_id, params); +} + +int C_GuiList::getHeaderHeight() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getheaderheight_id, NULL)); +} + +int C_GuiList::getPreventMultipleSelection() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getpreventmultipleselection_id, NULL)); +} + +int C_GuiList::setPreventMultipleSelection(int val) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(val); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), setpreventmultipleselection_id, params)); +} + +void C_GuiList::moveItem(int from, int to) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(from); + scriptVar b = MAKE_SCRIPT_INT(to); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), moveitem_id, params); +} + +void C_GuiList::onSelectAll() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onselectall_id, NULL); +} + +void C_GuiList::onDelete() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ondelete_id, NULL); +} + +void C_GuiList::onDoubleClick(int itemnum) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(itemnum); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ondoubleclick_id, params); +} + +void C_GuiList::onLeftClick(int itemnum) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(itemnum); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onleftclick_id, params); +} + +void C_GuiList::onSecondLeftClick(int itemnum) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(itemnum); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onsecondleftclick_id, params); +} + +int C_GuiList::onRightClick(int itemnum) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(itemnum); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onrightclick_id, params)); +} + +int C_GuiList::onColumnDblClick(int col, int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(col); + scriptVar b = MAKE_SCRIPT_INT(x); + scriptVar c = MAKE_SCRIPT_INT(y); + scriptVar *params[3] = {&a, &b, &c}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), oncolumndblclick_id, params)); +} + +int C_GuiList::onColumnLabelClick(int col, int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(col); + scriptVar b = MAKE_SCRIPT_INT(x); + scriptVar c = MAKE_SCRIPT_INT(y); + scriptVar *params[3] = {&a, &b, &c}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), oncolumnlabelclick_id, params)); +} + +void C_GuiList::onItemSelection(int itemnum, int selected) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(itemnum); + scriptVar b = MAKE_SCRIPT_INT(selected); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onitemselection_id, params); +} + +int C_GuiList::loaded=0; +int C_GuiList::getnumitems_id=0; +int C_GuiList::getwantautodeselect_id=0; +int C_GuiList::setwantautodeselect_id=0; +int C_GuiList::onsetvisible_id=0; +int C_GuiList::setautosort_id=0; +int C_GuiList::next_id=0; +int C_GuiList::selectcurrent_id=0; +int C_GuiList::selectfirstentry_id=0; +int C_GuiList::previous_id=0; +int C_GuiList::pagedown_id=0; +int C_GuiList::pageup_id=0; +int C_GuiList::home_id=0; +int C_GuiList::end_id=0; +int C_GuiList::reset_id=0; +int C_GuiList::addcolumn_id=0; +int C_GuiList::getnumcolumns_id=0; +int C_GuiList::getcolumnwidth_id=0; +int C_GuiList::setcolumnwidth_id=0; +int C_GuiList::getcolumnlabel_id=0; +int C_GuiList::setcolumnlabel_id=0; +int C_GuiList::getcolumnnumeric_id=0; +int C_GuiList::setcolumndynamic_id=0; +int C_GuiList::iscolumndynamic_id=0; +int C_GuiList::setminimumsize_id=0; +int C_GuiList::additem_id=0; +int C_GuiList::insertitem_id=0; +int C_GuiList::getlastaddeditempos_id=0; +int C_GuiList::setsubitem_id=0; +int C_GuiList::deleteallitems_id=0; +int C_GuiList::deletebypos_id=0; +int C_GuiList::getitemlabel_id=0; +int C_GuiList::setitemlabel_id=0; +int C_GuiList::getitemselected_id=0; +int C_GuiList::isitemfocused_id=0; +int C_GuiList::getitemfocused_id=0; +int C_GuiList::setitemfocused_id=0; +int C_GuiList::ensureitemvisible_id=0; +int C_GuiList::invalidatecolumns_id=0; +int C_GuiList::scrollabsolute_id=0; +int C_GuiList::scrollrelative_id=0; +int C_GuiList::scrollleft_id=0; +int C_GuiList::scrollright_id=0; +int C_GuiList::scrollup_id=0; +int C_GuiList::scrolldown_id=0; +int C_GuiList::getsubitemtext_id=0; +int C_GuiList::getfirstitemselected_id=0; +int C_GuiList::getnextitemselected_id=0; +int C_GuiList::selectall_id=0; +int C_GuiList::deselectall_id=0; +int C_GuiList::invertselection_id=0; +int C_GuiList::invalidateitem_id=0; +int C_GuiList::getfirstitemvisible_id=0; +int C_GuiList::getlastitemvisible_id=0; +int C_GuiList::setfontsize_id=0; +int C_GuiList::getfontsize_id=0; +int C_GuiList::jumptonext_id=0; +int C_GuiList::scrolltoitem_id=0; +int C_GuiList::resort_id=0; +int C_GuiList::getsortdirection_id=0; +int C_GuiList::getsortcolumn_id=0; +int C_GuiList::setsortcolumn_id=0; +int C_GuiList::setsortdirection_id=0; +int C_GuiList::getitemcount_id=0; +int C_GuiList::setselectionstart_id=0; +int C_GuiList::setselectionend_id=0; +int C_GuiList::setselected_id=0; +int C_GuiList::toggleselection_id=0; +int C_GuiList::getheaderheight_id=0; +int C_GuiList::getpreventmultipleselection_id=0; +int C_GuiList::setpreventmultipleselection_id=0; +int C_GuiList::moveitem_id=0; +int C_GuiList::onselectall_id=0; +int C_GuiList::ondelete_id=0; +int C_GuiList::ondoubleclick_id=0; +int C_GuiList::onleftclick_id=0; +int C_GuiList::onsecondleftclick_id=0; +int C_GuiList::onrightclick_id=0; +int C_GuiList::oncolumndblclick_id=0; +int C_GuiList::oncolumnlabelclick_id=0; +int C_GuiList::onitemselection_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_guilist.h b/Src/Wasabi/api/script/objects/c_script/c_guilist.h new file mode 100644 index 00000000..8fbc54d3 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_guilist.h @@ -0,0 +1,189 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_GUILIST_H +#define __C_GUILIST_H + +#include "c_guiobject.h" + +#define C_GUILIST_PARENT C_GuiObject + +class C_GuiList : public C_GUILIST_PARENT { + public: + + C_GuiList(ScriptObject *object); + C_GuiList(); + virtual ~C_GuiList(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual int getNumItems(); + virtual int getWantAutoDeselect(); + virtual void setWantAutoDeselect(int want); + virtual void onSetVisible(int show); + virtual void setAutoSort(int dosort); + virtual void next(); + virtual void selectCurrent(); + virtual void selectFirstEntry(); + virtual void previous(); + virtual void pagedown(); + virtual void pageup(); + virtual void home(); + virtual void end(); + virtual void reset(); + virtual int addColumn(const wchar_t *name, int width, int numeric); + virtual int getNumColumns(); + virtual int getColumnWidth(int column); + virtual void setColumnWidth(int column, int newwidth); + virtual const wchar_t *getColumnLabel(int column); + virtual void setColumnLabel(int column, const wchar_t *newlabel); + virtual int getColumnNumeric(int column); + virtual void setColumnDynamic(int column, int isdynamic); + virtual int isColumnDynamic(int column); + virtual void setMinimumSize(int size); + virtual int addItem(const wchar_t *label); + virtual int insertItem(int pos, const wchar_t *label); + virtual int getLastAddedItemPos(); + virtual void setSubItem(int pos, int subpos, const wchar_t *txt); + virtual void deleteAllItems(); + virtual int deleteByPos(int pos); + virtual const wchar_t *getItemLabel(int pos, int subpos); + virtual void setItemLabel(int pos, const wchar_t *_text); + virtual int getItemSelected(int pos); + virtual int isItemFocused(int pos); + virtual int getItemFocused(); + virtual void setItemFocused(int pos); + virtual void ensureItemVisible(int pos); + virtual void invalidateColumns(); + virtual int scrollAbsolute(int x); + virtual int scrollRelative(int x); + virtual void scrollLeft(int lines); + virtual void scrollRight(int lines); + virtual void scrollUp(int lines); + virtual void scrollDown(int lines); + virtual const wchar_t *getSubitemText(int pos, int subpos); + virtual int getFirstItemSelected(); + virtual int getNextItemSelected(int lastpos); + virtual int selectAll(); + virtual int deselectAll(); + virtual int invertSelection(); + virtual int invalidateItem(int pos); + virtual int getFirstItemVisible(); + virtual int getLastItemVisible(); + virtual int setFontSize(int size); + virtual int getFontSize(); + virtual void jumpToNext(int c); + virtual void scrollToItem(int pos); + virtual void resort(); + virtual int getSortDirection(); + virtual int getSortColumn(); + virtual void setSortColumn(int col); + virtual void setSortDirection(int dir); + virtual int getItemCount(); + virtual void setSelectionStart(int pos); + virtual void setSelectionEnd(int pos); + virtual void setSelected(int pos, int selected); + virtual void toggleSelection(int pos, int setfocus); + virtual int getHeaderHeight(); + virtual int getPreventMultipleSelection(); + virtual int setPreventMultipleSelection(int val); + virtual void moveItem(int from, int to); + virtual void onSelectAll(); + virtual void onDelete(); + virtual void onDoubleClick(int itemnum); + virtual void onLeftClick(int itemnum); + virtual void onSecondLeftClick(int itemnum); + virtual int onRightClick(int itemnum); + virtual int onColumnDblClick(int col, int x, int y); + virtual int onColumnLabelClick(int col, int x, int y); + virtual void onItemSelection(int itemnum, int selected); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int getnumitems_id; + static int getwantautodeselect_id; + static int setwantautodeselect_id; + static int onsetvisible_id; + static int setautosort_id; + static int next_id; + static int selectcurrent_id; + static int selectfirstentry_id; + static int previous_id; + static int pagedown_id; + static int pageup_id; + static int home_id; + static int end_id; + static int reset_id; + static int addcolumn_id; + static int getnumcolumns_id; + static int getcolumnwidth_id; + static int setcolumnwidth_id; + static int getcolumnlabel_id; + static int setcolumnlabel_id; + static int getcolumnnumeric_id; + static int setcolumndynamic_id; + static int iscolumndynamic_id; + static int setminimumsize_id; + static int additem_id; + static int insertitem_id; + static int getlastaddeditempos_id; + static int setsubitem_id; + static int deleteallitems_id; + static int deletebypos_id; + static int getitemlabel_id; + static int setitemlabel_id; + static int getitemselected_id; + static int isitemfocused_id; + static int getitemfocused_id; + static int setitemfocused_id; + static int ensureitemvisible_id; + static int invalidatecolumns_id; + static int scrollabsolute_id; + static int scrollrelative_id; + static int scrollleft_id; + static int scrollright_id; + static int scrollup_id; + static int scrolldown_id; + static int getsubitemtext_id; + static int getfirstitemselected_id; + static int getnextitemselected_id; + static int selectall_id; + static int deselectall_id; + static int invertselection_id; + static int invalidateitem_id; + static int getfirstitemvisible_id; + static int getlastitemvisible_id; + static int setfontsize_id; + static int getfontsize_id; + static int jumptonext_id; + static int scrolltoitem_id; + static int resort_id; + static int getsortdirection_id; + static int getsortcolumn_id; + static int setsortcolumn_id; + static int setsortdirection_id; + static int getitemcount_id; + static int setselectionstart_id; + static int setselectionend_id; + static int setselected_id; + static int toggleselection_id; + static int getheaderheight_id; + static int getpreventmultipleselection_id; + static int setpreventmultipleselection_id; + static int moveitem_id; + static int onselectall_id; + static int ondelete_id; + static int ondoubleclick_id; + static int onleftclick_id; + static int onsecondleftclick_id; + static int onrightclick_id; + static int oncolumndblclick_id; + static int oncolumnlabelclick_id; + static int onitemselection_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_guiobject.cpp b/Src/Wasabi/api/script/objects/c_script/c_guiobject.cpp new file mode 100644 index 00000000..0b7add98 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_guiobject.cpp @@ -0,0 +1,739 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include "c_guiobject.h" +#include + +C_GuiObject::C_GuiObject(ScriptObject *object) : C_RootObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_GuiObject::C_GuiObject() { + inited = 0; + obj = NULL; +} + +void C_GuiObject::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, guiObjectGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + show_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"show", this); + hide_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"hide", this); + isvisible_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isVisible", this); + onsetvisible_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSetVisible", this); + setalpha_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setAlpha", this); + getalpha_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getAlpha", this); + onleftbuttonup_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onLeftButtonUp", this); + onleftbuttondown_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onLeftButtonDown", this); + onrightbuttonup_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onRightButtonUp", this); + onrightbuttondown_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onRightButtonDown", this); + onrightbuttondblclk_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onRightButtonDblClk", this); + onleftbuttondblclk_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onLeftButtonDblClk", this); + onmousemove_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onMouseMove", this); + onenterarea_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onEnterArea", this); + onleavearea_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onLeaveArea", this); + setenabled_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setEnabled", this); + getenabled_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getEnabled", this); + onenable_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onEnable", this); + resize_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"resize", this); + onresize_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onResize", this); + ismouseover_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isMouseOver", this); + getleft_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getLeft", this); + gettop_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getTop", this); + getwidth_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getWidth", this); + getheight_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getHeight", this); + settargetx_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setTargetX", this); + settargety_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setTargetY", this); + settargetw_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setTargetW", this); + settargeth_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setTargetH", this); + settargeta_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setTargetA", this); + settargetspeed_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setTargetSpeed", this); + gototarget_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"gotoTarget", this); + ontargetreached_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onTargetReached", this); + canceltarget_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"cancelTarget", this); + reversetarget_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"reverseTarget", this); + onstartup_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onStartup", this); + isgoingtotarget_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isGoingToTarget", this); + setxmlparam_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setXmlParam", this); + getxmlparam_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getXmlParam", this); + init_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"init", this); + bringtofront_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"bringToFront", this); + bringtoback_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"bringToBack", this); + bringabove_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"bringAbove", this); + bringbelow_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"bringBelow", this); + getguix_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getGuiX", this); + getguiy_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getGuiY", this); + getguiw_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getGuiW", this); + getguih_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getGuiH", this); + getguirelatx_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getGuiRelatX", this); + getguirelaty_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getGuiRelatY", this); + getguirelatw_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getGuiRelatW", this); + getguirelath_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getGuiRelatH", this); + isactive_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isActive", this); + getparent_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getParent", this); + getparentlayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getParentLayout", this); + gettopparent_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getTopParent", this); + runmodal_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"runModal", this); + endmodal_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"endModal", this); + findobject_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"findObject", this); + findobjectxy_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"findObjectXY", this); + getname_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getName", this); + clienttoscreenx_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"clientToScreenX", this); + clienttoscreeny_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"clientToScreenY", this); + clienttoscreenw_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"clientToScreenW", this); + clienttoscreenh_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"clientToScreenH", this); + screentoclientx_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"screenToClientX", this); + screentoclienty_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"screenToClientY", this); + screentoclientw_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"screenToClientW", this); + screentoclienth_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"screenToClientH", this); + getautowidth_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getAutoWidth", this); + getautoheight_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getAutoHeight", this); + setfocus_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setFocus", this); + onchar_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onChar", this); + onaccelerator_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onAccelerator", this); + ismouseoverrect_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isMouseOverRect", this); + getinterface_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getInterface", this); + onkeydown_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onKeyDown", this); + onkeyup_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onKeyUp", this); + ongetfocus_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onGetFocus", this); + onkillfocus_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onKillFocus", this); + sendaction_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"sendAction", this); + onaction_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onAction", this); + } + inited = 1; +} + +C_GuiObject::~C_GuiObject() { +} + +ScriptObject *C_GuiObject::getScriptObject() { + if (obj != NULL) return obj; + return C_GUIOBJECT_PARENT::getScriptObject(); +} + +void C_GuiObject::show() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), show_id, NULL); +} + +void C_GuiObject::hide() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), hide_id, NULL); +} + +int C_GuiObject::isVisible() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), isvisible_id, NULL)); +} + +void C_GuiObject::onSetVisible(int onoff) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(onoff); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onsetvisible_id, params); +} + +void C_GuiObject::setAlpha(int alpha) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(alpha); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setalpha_id, params); +} + +int C_GuiObject::getAlpha() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getalpha_id, NULL)); +} + +void C_GuiObject::onLeftButtonUp(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onleftbuttonup_id, params); +} + +void C_GuiObject::onLeftButtonDown(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onleftbuttondown_id, params); +} + +void C_GuiObject::onRightButtonUp(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onrightbuttonup_id, params); +} + +void C_GuiObject::onRightButtonDown(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onrightbuttondown_id, params); +} + +void C_GuiObject::onRightButtonDblClk(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onrightbuttondblclk_id, params); +} + +void C_GuiObject::onLeftButtonDblClk(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onleftbuttondblclk_id, params); +} + +void C_GuiObject::onMouseMove(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onmousemove_id, params); +} + +void C_GuiObject::onEnterArea() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onenterarea_id, NULL); +} + +void C_GuiObject::onLeaveArea() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onleavearea_id, NULL); +} + +void C_GuiObject::setEnabled(int onoff) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(onoff); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setenabled_id, params); +} + +int C_GuiObject::getEnabled() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getenabled_id, NULL)); +} + +void C_GuiObject::onEnable(int onoff) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(onoff); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onenable_id, params); +} + +void C_GuiObject::resize(int x, int y, int w, int h) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar c = MAKE_SCRIPT_INT(w); + scriptVar d = MAKE_SCRIPT_INT(h); + scriptVar *params[4] = {&a, &b, &c, &d}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), resize_id, params); +} + +void C_GuiObject::onResize(int x, int y, int w, int h) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar c = MAKE_SCRIPT_INT(w); + scriptVar d = MAKE_SCRIPT_INT(h); + scriptVar *params[4] = {&a, &b, &c, &d}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onresize_id, params); +} + +int C_GuiObject::isMouseOver(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), ismouseover_id, params)); +} + +int C_GuiObject::getLeft() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getleft_id, NULL)); +} + +int C_GuiObject::getTop() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), gettop_id, NULL)); +} + +int C_GuiObject::getWidth() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getwidth_id, NULL)); +} + +int C_GuiObject::getHeight() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getheight_id, NULL)); +} + +void C_GuiObject::setTargetX(int x) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), settargetx_id, params); +} + +void C_GuiObject::setTargetY(int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(y); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), settargety_id, params); +} + +void C_GuiObject::setTargetW(int w) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(w); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), settargetw_id, params); +} + +void C_GuiObject::setTargetH(int r) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(r); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), settargeth_id, params); +} + +void C_GuiObject::setTargetA(int alpha) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(alpha); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), settargeta_id, params); +} + +void C_GuiObject::setTargetSpeed(float insecond) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_FLOAT(insecond); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), settargetspeed_id, params); +} + +void C_GuiObject::gotoTarget() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), gototarget_id, NULL); +} + +void C_GuiObject::onTargetReached() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ontargetreached_id, NULL); +} + +void C_GuiObject::cancelTarget() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), canceltarget_id, NULL); +} + +void C_GuiObject::reverseTarget(int reverse) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(reverse); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), reversetarget_id, params); +} + +void C_GuiObject::onStartup() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onstartup_id, NULL); +} + +int C_GuiObject::isGoingToTarget() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), isgoingtotarget_id, NULL)); +} + +void C_GuiObject::setXmlParam(const wchar_t *param, const wchar_t *value) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(param); + scriptVar b = MAKE_SCRIPT_STRING(value); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setxmlparam_id, params); +} + +const wchar_t *C_GuiObject::getXmlParam(const wchar_t *param) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(param); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getxmlparam_id, params)); +} + +void C_GuiObject::init(ScriptObject *parent) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(parent); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), init_id, params); +} + +void C_GuiObject::bringToFront() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), bringtofront_id, NULL); +} + +void C_GuiObject::bringToBack() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), bringtoback_id, NULL); +} + +void C_GuiObject::bringAbove(ScriptObject *guiobj) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(guiobj); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), bringabove_id, params); +} + +void C_GuiObject::bringBelow(ScriptObject *guiobj) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(guiobj); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), bringbelow_id, params); +} + +int C_GuiObject::getGuiX() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getguix_id, NULL)); +} + +int C_GuiObject::getGuiY() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getguiy_id, NULL)); +} + +int C_GuiObject::getGuiW() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getguiw_id, NULL)); +} + +int C_GuiObject::getGuiH() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getguih_id, NULL)); +} + +int C_GuiObject::getGuiRelatX() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getguirelatx_id, NULL)); +} + +int C_GuiObject::getGuiRelatY() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getguirelaty_id, NULL)); +} + +int C_GuiObject::getGuiRelatW() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getguirelatw_id, NULL)); +} + +int C_GuiObject::getGuiRelatH() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getguirelath_id, NULL)); +} + +int C_GuiObject::isActive() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), isactive_id, NULL)); +} + +ScriptObject *C_GuiObject::getParent() { + ASSERT(inited); + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getparent_id, NULL)); +} + +ScriptObject *C_GuiObject::getParentLayout() { + ASSERT(inited); + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getparentlayout_id, NULL)); +} + +ScriptObject *C_GuiObject::getTopParent() { + ASSERT(inited); + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), gettopparent_id, NULL)); +} + +int C_GuiObject::runModal() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), runmodal_id, NULL)); +} + +void C_GuiObject::endModal(int retcode) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(retcode); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), endmodal_id, params); +} + +ScriptObject *C_GuiObject::findObject(const wchar_t *id) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(id); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), findobject_id, params)); +} + +ScriptObject *C_GuiObject::findObjectXY(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), findobjectxy_id, params)); +} + +const wchar_t *C_GuiObject::getName() +{ + ASSERT(inited); + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getname_id, NULL)); +} + +int C_GuiObject::clientToScreenX(int x) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), clienttoscreenx_id, params)); +} + +int C_GuiObject::clientToScreenY(int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(y); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), clienttoscreeny_id, params)); +} + +int C_GuiObject::clientToScreenW(int w) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(w); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), clienttoscreenw_id, params)); +} + +int C_GuiObject::clientToScreenH(int h) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(h); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), clienttoscreenh_id, params)); +} + +int C_GuiObject::screenToClientX(int x) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), screentoclientx_id, params)); +} + +int C_GuiObject::screenToClientY(int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(y); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), screentoclienty_id, params)); +} + +int C_GuiObject::screenToClientW(int w) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(w); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), screentoclientw_id, params)); +} + +int C_GuiObject::screenToClientH(int h) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(h); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), screentoclienth_id, params)); +} + +int C_GuiObject::getAutoWidth() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getautowidth_id, NULL)); +} + +int C_GuiObject::getAutoHeight() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getautoheight_id, NULL)); +} + +void C_GuiObject::setFocus() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setfocus_id, NULL); +} + +void C_GuiObject::onChar(const wchar_t *c) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(c); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onchar_id, params); +} + +void C_GuiObject::onAccelerator(const wchar_t *accel) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(accel); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onaccelerator_id, params); +} + +int C_GuiObject::isMouseOverRect() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), ismouseoverrect_id, NULL)); +} + +ScriptObject *C_GuiObject::getInterface(const wchar_t *interface_guid) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(interface_guid); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getinterface_id, params)); +} + +void C_GuiObject::onKeyDown(int vk_code) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(vk_code); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onkeydown_id, params); +} + +void C_GuiObject::onKeyUp(int vk_code) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(vk_code); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onkeyup_id, params); +} + +void C_GuiObject::onGetFocus() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ongetfocus_id, NULL); +} + +void C_GuiObject::onKillFocus() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onkillfocus_id, NULL); +} + +int C_GuiObject::sendAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(action); + scriptVar b = MAKE_SCRIPT_STRING(param); + scriptVar c = MAKE_SCRIPT_INT(x); + scriptVar d = MAKE_SCRIPT_INT(y); + scriptVar e = MAKE_SCRIPT_INT((int)p1); + scriptVar f = MAKE_SCRIPT_INT((int)p2); + scriptVar *params[6] = {&a, &b, &c, &d, &e, &f}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), sendaction_id, params)); +} + +int C_GuiObject::onAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2, ScriptObject *source) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(action); + scriptVar b = MAKE_SCRIPT_STRING(param); + scriptVar c = MAKE_SCRIPT_INT(x); + scriptVar d = MAKE_SCRIPT_INT(y); + scriptVar e = MAKE_SCRIPT_INT((int)p1); + scriptVar f = MAKE_SCRIPT_INT((int)p2); + scriptVar g = MAKE_SCRIPT_OBJECT(source); + scriptVar *params[7] = {&a, &b, &c, &d, &e, &f, &g}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onaction_id, params)); +} + +int C_GuiObject::loaded=0; +int C_GuiObject::show_id=0; +int C_GuiObject::hide_id=0; +int C_GuiObject::isvisible_id=0; +int C_GuiObject::onsetvisible_id=0; +int C_GuiObject::setalpha_id=0; +int C_GuiObject::getalpha_id=0; +int C_GuiObject::onleftbuttonup_id=0; +int C_GuiObject::onleftbuttondown_id=0; +int C_GuiObject::onrightbuttonup_id=0; +int C_GuiObject::onrightbuttondown_id=0; +int C_GuiObject::onrightbuttondblclk_id=0; +int C_GuiObject::onleftbuttondblclk_id=0; +int C_GuiObject::onmousemove_id=0; +int C_GuiObject::onenterarea_id=0; +int C_GuiObject::onleavearea_id=0; +int C_GuiObject::setenabled_id=0; +int C_GuiObject::getenabled_id=0; +int C_GuiObject::onenable_id=0; +int C_GuiObject::resize_id=0; +int C_GuiObject::onresize_id=0; +int C_GuiObject::ismouseover_id=0; +int C_GuiObject::getleft_id=0; +int C_GuiObject::gettop_id=0; +int C_GuiObject::getwidth_id=0; +int C_GuiObject::getheight_id=0; +int C_GuiObject::settargetx_id=0; +int C_GuiObject::settargety_id=0; +int C_GuiObject::settargetw_id=0; +int C_GuiObject::settargeth_id=0; +int C_GuiObject::settargeta_id=0; +int C_GuiObject::settargetspeed_id=0; +int C_GuiObject::gototarget_id=0; +int C_GuiObject::ontargetreached_id=0; +int C_GuiObject::canceltarget_id=0; +int C_GuiObject::reversetarget_id=0; +int C_GuiObject::onstartup_id=0; +int C_GuiObject::isgoingtotarget_id=0; +int C_GuiObject::setxmlparam_id=0; +int C_GuiObject::getxmlparam_id=0; +int C_GuiObject::init_id=0; +int C_GuiObject::bringtofront_id=0; +int C_GuiObject::bringtoback_id=0; +int C_GuiObject::bringabove_id=0; +int C_GuiObject::bringbelow_id=0; +int C_GuiObject::getguix_id=0; +int C_GuiObject::getguiy_id=0; +int C_GuiObject::getguiw_id=0; +int C_GuiObject::getguih_id=0; +int C_GuiObject::getguirelatx_id=0; +int C_GuiObject::getguirelaty_id=0; +int C_GuiObject::getguirelatw_id=0; +int C_GuiObject::getguirelath_id=0; +int C_GuiObject::isactive_id=0; +int C_GuiObject::getparent_id=0; +int C_GuiObject::getparentlayout_id=0; +int C_GuiObject::gettopparent_id=0; +int C_GuiObject::runmodal_id=0; +int C_GuiObject::endmodal_id=0; +int C_GuiObject::findobject_id=0; +int C_GuiObject::findobjectxy_id=0; +int C_GuiObject::getname_id=0; +int C_GuiObject::clienttoscreenx_id=0; +int C_GuiObject::clienttoscreeny_id=0; +int C_GuiObject::clienttoscreenw_id=0; +int C_GuiObject::clienttoscreenh_id=0; +int C_GuiObject::screentoclientx_id=0; +int C_GuiObject::screentoclienty_id=0; +int C_GuiObject::screentoclientw_id=0; +int C_GuiObject::screentoclienth_id=0; +int C_GuiObject::getautowidth_id=0; +int C_GuiObject::getautoheight_id=0; +int C_GuiObject::setfocus_id=0; +int C_GuiObject::onchar_id=0; +int C_GuiObject::onaccelerator_id=0; +int C_GuiObject::ismouseoverrect_id=0; +int C_GuiObject::getinterface_id=0; +int C_GuiObject::onkeydown_id=0; +int C_GuiObject::onkeyup_id=0; +int C_GuiObject::ongetfocus_id=0; +int C_GuiObject::onkillfocus_id=0; +int C_GuiObject::sendaction_id=0; +int C_GuiObject::onaction_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_guiobject.h b/Src/Wasabi/api/script/objects/c_script/c_guiobject.h new file mode 100644 index 00000000..3922dd20 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_guiobject.h @@ -0,0 +1,193 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_GUIOBJECT_H +#define __C_GUIOBJECT_H + +#include "c_rootobj.h" + +#define C_GUIOBJECT_PARENT C_RootObject + +class C_GuiObject : public C_GUIOBJECT_PARENT { + public: + + C_GuiObject(ScriptObject *object); + C_GuiObject(); + virtual ~C_GuiObject(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void show(); + virtual void hide(); + virtual int isVisible(); + virtual void onSetVisible(int onoff); + virtual void setAlpha(int alpha); + virtual int getAlpha(); + virtual void onLeftButtonUp(int x, int y); + virtual void onLeftButtonDown(int x, int y); + virtual void onRightButtonUp(int x, int y); + virtual void onRightButtonDown(int x, int y); + virtual void onRightButtonDblClk(int x, int y); + virtual void onLeftButtonDblClk(int x, int y); + virtual void onMouseMove(int x, int y); + virtual void onEnterArea(); + virtual void onLeaveArea(); + virtual void setEnabled(int onoff); + virtual int getEnabled(); + virtual void onEnable(int onoff); + virtual void resize(int x, int y, int w, int h); + virtual void onResize(int x, int y, int w, int h); + virtual int isMouseOver(int x, int y); + virtual int getLeft(); + virtual int getTop(); + virtual int getWidth(); + virtual int getHeight(); + virtual void setTargetX(int x); + virtual void setTargetY(int y); + virtual void setTargetW(int w); + virtual void setTargetH(int r); + virtual void setTargetA(int alpha); + virtual void setTargetSpeed(float insecond); + virtual void gotoTarget(); + virtual void onTargetReached(); + virtual void cancelTarget(); + virtual void reverseTarget(int reverse); + virtual void onStartup(); + virtual int isGoingToTarget(); + virtual void setXmlParam(const wchar_t *param, const wchar_t *value); + virtual const wchar_t *getXmlParam(const wchar_t *param); + virtual void init(ScriptObject *parent); + virtual void bringToFront(); + virtual void bringToBack(); + virtual void bringAbove(ScriptObject *guiobj); + virtual void bringBelow(ScriptObject *guiobj); + virtual int getGuiX(); + virtual int getGuiY(); + virtual int getGuiW(); + virtual int getGuiH(); + virtual int getGuiRelatX(); + virtual int getGuiRelatY(); + virtual int getGuiRelatW(); + virtual int getGuiRelatH(); + virtual int isActive(); + virtual ScriptObject *getParent(); + virtual ScriptObject *getParentLayout(); + virtual ScriptObject *getTopParent(); + virtual int runModal(); + virtual void endModal(int retcode); + virtual ScriptObject *findObject(const wchar_t *id); + virtual ScriptObject *findObjectXY(int x, int y); + virtual const wchar_t *getName(); + virtual int clientToScreenX(int x); + virtual int clientToScreenY(int y); + virtual int clientToScreenW(int w); + virtual int clientToScreenH(int h); + virtual int screenToClientX(int x); + virtual int screenToClientY(int y); + virtual int screenToClientW(int w); + virtual int screenToClientH(int h); + virtual int getAutoWidth(); + virtual int getAutoHeight(); + virtual void setFocus(); + virtual void onChar(const wchar_t *c); + virtual void onAccelerator(const wchar_t *accel); + virtual int isMouseOverRect(); + virtual ScriptObject *getInterface(const wchar_t *interface_guid); + virtual void onKeyDown(int vk_code); + virtual void onKeyUp(int vk_code); + virtual void onGetFocus(); + virtual void onKillFocus(); + virtual int sendAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2); + virtual int onAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2, ScriptObject *source); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int show_id; + static int hide_id; + static int isvisible_id; + static int onsetvisible_id; + static int setalpha_id; + static int getalpha_id; + static int onleftbuttonup_id; + static int onleftbuttondown_id; + static int onrightbuttonup_id; + static int onrightbuttondown_id; + static int onrightbuttondblclk_id; + static int onleftbuttondblclk_id; + static int onmousemove_id; + static int onenterarea_id; + static int onleavearea_id; + static int setenabled_id; + static int getenabled_id; + static int onenable_id; + static int resize_id; + static int onresize_id; + static int ismouseover_id; + static int getleft_id; + static int gettop_id; + static int getwidth_id; + static int getheight_id; + static int settargetx_id; + static int settargety_id; + static int settargetw_id; + static int settargeth_id; + static int settargeta_id; + static int settargetspeed_id; + static int gototarget_id; + static int ontargetreached_id; + static int canceltarget_id; + static int reversetarget_id; + static int onstartup_id; + static int isgoingtotarget_id; + static int setxmlparam_id; + static int getxmlparam_id; + static int init_id; + static int bringtofront_id; + static int bringtoback_id; + static int bringabove_id; + static int bringbelow_id; + static int getguix_id; + static int getguiy_id; + static int getguiw_id; + static int getguih_id; + static int getguirelatx_id; + static int getguirelaty_id; + static int getguirelatw_id; + static int getguirelath_id; + static int isactive_id; + static int getparent_id; + static int getparentlayout_id; + static int gettopparent_id; + static int runmodal_id; + static int endmodal_id; + static int findobject_id; + static int findobjectxy_id; + static int getname_id; + static int clienttoscreenx_id; + static int clienttoscreeny_id; + static int clienttoscreenw_id; + static int clienttoscreenh_id; + static int screentoclientx_id; + static int screentoclienty_id; + static int screentoclientw_id; + static int screentoclienth_id; + static int getautowidth_id; + static int getautoheight_id; + static int setfocus_id; + static int onchar_id; + static int onaccelerator_id; + static int ismouseoverrect_id; + static int getinterface_id; + static int onkeydown_id; + static int onkeyup_id; + static int ongetfocus_id; + static int onkillfocus_id; + static int sendaction_id; + static int onaction_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_guitree.cpp b/Src/Wasabi/api/script/objects/c_script/c_guitree.cpp new file mode 100644 index 00000000..aa97f3ee --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_guitree.cpp @@ -0,0 +1,491 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include "c_guitree.h" +#include + +C_GuiTree::C_GuiTree(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_GuiTree::C_GuiTree() { + inited = 0; + obj = NULL; +} + +void C_GuiTree::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, guiTreeGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + onwantautocontextmenu_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onWantAutoContextMenu", this); + onmousewheelup_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onMouseWheelUp", this); + onmousewheeldown_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onMouseWheelDown", this); + oncontextmenu_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onContextMenu", this); + onchar_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onChar", this); + onitemrecvdrop_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onItemRecvDrop", this); + onlabelchange_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onLabelChange", this); + onitemselected_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onItemSelected", this); + onitemdeselected_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onItemDeselected", this); + getnumrootitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNumRootItems", this); + enumrootitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"enumRootItem", this); + jumptonext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"jumpToNext", this); + ensureitemvisible_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"ensureItemVisible", this); + getcontentswidth_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getContentsWidth", this); + getcontentsheight_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getContentsHeight", this); + addtreeitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"addTreeItem", this); + removetreeitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"removeTreeItem", this); + movetreeitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"moveTreeItem", this); + deleteallitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"deleteAllItems", this); + expanditem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"expandItem", this); + expanditemdeferred_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"expandItemDeferred", this); + collapseitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"collapseItem", this); + collapseitemdeferred_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"collapseItemDeferred", this); + selectitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"selectItem", this); + selectitemdeferred_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"selectItemDeferred", this); + delitemdeferred_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"delItemDeferred", this); + hiliteitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"hiliteItem", this); + unhiliteitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"unhiliteItem", this); + getcuritem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getCurItem", this); + hittest_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"hitTest", this); + edititemlabel_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"editItemLabel", this); + canceleditlabel_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"cancelEditLabel", this); + setautoedit_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setAutoEdit", this); + getautoedit_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getAutoEdit", this); + getbylabel_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getByLabel", this); + setsorted_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setSorted", this); + getsorted_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSorted", this); + sorttreeitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"sortTreeItems", this); + getsibling_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSibling", this); + setautocollapse_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setAutoCollapse", this); + setfontsize_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setFontSize", this); + getfontsize_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getFontSize", this); + getnumvisiblechilditems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNumVisibleChildItems", this); + getnumvisibleitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNumVisibleItems", this); + enumvisibleitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"enumVisibleItems", this); + enumvisiblechilditems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"enumVisibleChildItems", this); + enumallitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"enumAllItems", this); + getitemrectx_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getItemRectX", this); + getitemrecty_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getItemRectY", this); + getitemrectw_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getItemRectW", this); + getitemrecth_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getItemRectH", this); + } + inited = 1; +} + +C_GuiTree::~C_GuiTree() { +} + +ScriptObject *C_GuiTree::getScriptObject() { + if (obj != NULL) return obj; + return C_GUITREE_PARENT::getScriptObject(); +} + +int C_GuiTree::onWantAutoContextMenu() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onwantautocontextmenu_id, NULL)); +} + +int C_GuiTree::onMouseWheelUp(int clicked, int lines) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(clicked); + scriptVar b = MAKE_SCRIPT_INT(lines); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onmousewheelup_id, params)); +} + +int C_GuiTree::onMouseWheelDown(int clicked, int lines) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(clicked); + scriptVar b = MAKE_SCRIPT_INT(lines); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onmousewheeldown_id, params)); +} + +int C_GuiTree::onContextMenu(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), oncontextmenu_id, params)); +} + +int C_GuiTree::onChar(int c) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(c); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onchar_id, params)); +} + +void C_GuiTree::onItemRecvDrop(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onitemrecvdrop_id, params); +} + +void C_GuiTree::onLabelChange(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onlabelchange_id, params); +} + +void C_GuiTree::onItemSelected(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onitemselected_id, params); +} + +void C_GuiTree::onItemDeselected(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onitemdeselected_id, params); +} + +int C_GuiTree::getNumRootItems() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnumrootitems_id, NULL)); +} + +ScriptObject *C_GuiTree::enumRootItem(int which) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(which); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), enumrootitem_id, params)); +} + +void C_GuiTree::jumpToNext(int c) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(c); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), jumptonext_id, params); +} + +void C_GuiTree::ensureItemVisible(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ensureitemvisible_id, params); +} + +int C_GuiTree::getContentsWidth() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcontentswidth_id, NULL)); +} + +int C_GuiTree::getContentsHeight() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcontentsheight_id, NULL)); +} + +ScriptObject *C_GuiTree::addTreeItem(ScriptObject *item, ScriptObject *par, int sorted, int haschildtab) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar b = MAKE_SCRIPT_OBJECT(par); + scriptVar c = MAKE_SCRIPT_INT(sorted); + scriptVar d = MAKE_SCRIPT_INT(haschildtab); + scriptVar *params[4] = {&a, &b, &c, &d}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), addtreeitem_id, params)); +} + +int C_GuiTree::removeTreeItem(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), removetreeitem_id, params)); +} + +void C_GuiTree::moveTreeItem(ScriptObject *item, ScriptObject *newparent) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar b = MAKE_SCRIPT_OBJECT(newparent); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), movetreeitem_id, params); +} + +void C_GuiTree::deleteAllItems() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), deleteallitems_id, NULL); +} + +int C_GuiTree::expandItem(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), expanditem_id, params)); +} + +void C_GuiTree::expandItemDeferred(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), expanditemdeferred_id, params); +} + +int C_GuiTree::collapseItem(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), collapseitem_id, params)); +} + +void C_GuiTree::collapseItemDeferred(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), collapseitemdeferred_id, params); +} + +void C_GuiTree::selectItem(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), selectitem_id, params); +} + +void C_GuiTree::selectItemDeferred(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), selectitemdeferred_id, params); +} + +void C_GuiTree::delItemDeferred(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), delitemdeferred_id, params); +} + +void C_GuiTree::hiliteItem(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), hiliteitem_id, params); +} + +void C_GuiTree::unhiliteItem(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), unhiliteitem_id, params); +} + +ScriptObject *C_GuiTree::getCurItem() { + ASSERT(inited); + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcuritem_id, NULL)); +} + +ScriptObject *C_GuiTree::hitTest(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), hittest_id, params)); +} + +void C_GuiTree::editItemLabel(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), edititemlabel_id, params); +} + +void C_GuiTree::cancelEditLabel(int destroyit) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(destroyit); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), canceleditlabel_id, params); +} + +void C_GuiTree::setAutoEdit(int ae) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(ae); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setautoedit_id, params); +} + +int C_GuiTree::getAutoEdit() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getautoedit_id, NULL)); +} + +ScriptObject *C_GuiTree::getByLabel(ScriptObject *item, const wchar_t *name) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar b = MAKE_SCRIPT_STRING(name); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getbylabel_id, params)); +} + +void C_GuiTree::setSorted(int dosort) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(dosort); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setsorted_id, params); +} + +int C_GuiTree::getSorted() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getsorted_id, NULL)); +} + +void C_GuiTree::sortTreeItems() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), sorttreeitems_id, NULL); +} + +ScriptObject *C_GuiTree::getSibling(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getsibling_id, params)); +} + +void C_GuiTree::setAutoCollapse(int doautocollapse) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(doautocollapse); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setautocollapse_id, params); +} + +int C_GuiTree::setFontSize(int newsize) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(newsize); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), setfontsize_id, params)); +} + +int C_GuiTree::getFontSize() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getfontsize_id, NULL)); +} + +int C_GuiTree::getNumVisibleChildItems(ScriptObject *c) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(c); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnumvisiblechilditems_id, params)); +} + +int C_GuiTree::getNumVisibleItems() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnumvisibleitems_id, NULL)); +} + +ScriptObject *C_GuiTree::enumVisibleItems(int n) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(n); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), enumvisibleitems_id, params)); +} + +ScriptObject *C_GuiTree::enumVisibleChildItems(ScriptObject *c, int n) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(c); + scriptVar b = MAKE_SCRIPT_INT(n); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), enumvisiblechilditems_id, params)); +} + +ScriptObject *C_GuiTree::enumAllItems(int n) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(n); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), enumallitems_id, params)); +} + +int C_GuiTree::getItemRectX(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getitemrectx_id, params)); +} + +int C_GuiTree::getItemRectY(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getitemrecty_id, params)); +} + +int C_GuiTree::getItemRectW(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getitemrectw_id, params)); +} + +int C_GuiTree::getItemRectH(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getitemrecth_id, params)); +} + +int C_GuiTree::loaded=0; +int C_GuiTree::onwantautocontextmenu_id=0; +int C_GuiTree::onmousewheelup_id=0; +int C_GuiTree::onmousewheeldown_id=0; +int C_GuiTree::oncontextmenu_id=0; +int C_GuiTree::onchar_id=0; +int C_GuiTree::onitemrecvdrop_id=0; +int C_GuiTree::onlabelchange_id=0; +int C_GuiTree::onitemselected_id=0; +int C_GuiTree::onitemdeselected_id=0; +int C_GuiTree::getnumrootitems_id=0; +int C_GuiTree::enumrootitem_id=0; +int C_GuiTree::jumptonext_id=0; +int C_GuiTree::ensureitemvisible_id=0; +int C_GuiTree::getcontentswidth_id=0; +int C_GuiTree::getcontentsheight_id=0; +int C_GuiTree::addtreeitem_id=0; +int C_GuiTree::removetreeitem_id=0; +int C_GuiTree::movetreeitem_id=0; +int C_GuiTree::deleteallitems_id=0; +int C_GuiTree::expanditem_id=0; +int C_GuiTree::expanditemdeferred_id=0; +int C_GuiTree::collapseitem_id=0; +int C_GuiTree::collapseitemdeferred_id=0; +int C_GuiTree::selectitem_id=0; +int C_GuiTree::selectitemdeferred_id=0; +int C_GuiTree::delitemdeferred_id=0; +int C_GuiTree::hiliteitem_id=0; +int C_GuiTree::unhiliteitem_id=0; +int C_GuiTree::getcuritem_id=0; +int C_GuiTree::hittest_id=0; +int C_GuiTree::edititemlabel_id=0; +int C_GuiTree::canceleditlabel_id=0; +int C_GuiTree::setautoedit_id=0; +int C_GuiTree::getautoedit_id=0; +int C_GuiTree::getbylabel_id=0; +int C_GuiTree::setsorted_id=0; +int C_GuiTree::getsorted_id=0; +int C_GuiTree::sorttreeitems_id=0; +int C_GuiTree::getsibling_id=0; +int C_GuiTree::setautocollapse_id=0; +int C_GuiTree::setfontsize_id=0; +int C_GuiTree::getfontsize_id=0; +int C_GuiTree::getnumvisiblechilditems_id=0; +int C_GuiTree::getnumvisibleitems_id=0; +int C_GuiTree::enumvisibleitems_id=0; +int C_GuiTree::enumvisiblechilditems_id=0; +int C_GuiTree::enumallitems_id=0; +int C_GuiTree::getitemrectx_id=0; +int C_GuiTree::getitemrecty_id=0; +int C_GuiTree::getitemrectw_id=0; +int C_GuiTree::getitemrecth_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_guitree.h b/Src/Wasabi/api/script/objects/c_script/c_guitree.h new file mode 100644 index 00000000..296e0043 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_guitree.h @@ -0,0 +1,131 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_GUITREE_H +#define __C_GUITREE_H + +#include "c_guiobject.h" + +#define C_GUITREE_PARENT C_GuiObject + +class C_GuiTree : public C_GUITREE_PARENT { + public: + + C_GuiTree(ScriptObject *object); + C_GuiTree(); + virtual ~C_GuiTree(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual int onWantAutoContextMenu(); + virtual int onMouseWheelUp(int clicked, int lines); + virtual int onMouseWheelDown(int clicked, int lines); + virtual int onContextMenu(int x, int y); + virtual int onChar(int c); + virtual void onItemRecvDrop(ScriptObject *item); + virtual void onLabelChange(ScriptObject *item); + virtual void onItemSelected(ScriptObject *item); + virtual void onItemDeselected(ScriptObject *item); + virtual int getNumRootItems(); + virtual ScriptObject *enumRootItem(int which); + virtual void jumpToNext(int c); + virtual void ensureItemVisible(ScriptObject *item); + virtual int getContentsWidth(); + virtual int getContentsHeight(); + virtual ScriptObject *addTreeItem(ScriptObject *item, ScriptObject *par, int sorted, int haschildtab); + virtual int removeTreeItem(ScriptObject *item); + virtual void moveTreeItem(ScriptObject *item, ScriptObject *newparent); + virtual void deleteAllItems(); + virtual int expandItem(ScriptObject *item); + virtual void expandItemDeferred(ScriptObject *item); + virtual int collapseItem(ScriptObject *item); + virtual void collapseItemDeferred(ScriptObject *item); + virtual void selectItem(ScriptObject *item); + virtual void selectItemDeferred(ScriptObject *item); + virtual void delItemDeferred(ScriptObject *item); + virtual void hiliteItem(ScriptObject *item); + virtual void unhiliteItem(ScriptObject *item); + virtual ScriptObject *getCurItem(); + virtual ScriptObject *hitTest(int x, int y); + virtual void editItemLabel(ScriptObject *item); + virtual void cancelEditLabel(int destroyit); + virtual void setAutoEdit(int ae); + virtual int getAutoEdit(); + virtual ScriptObject *getByLabel(ScriptObject *item, const wchar_t *name); + virtual void setSorted(int dosort); + virtual int getSorted(); + virtual void sortTreeItems(); + virtual ScriptObject *getSibling(ScriptObject *item); + virtual void setAutoCollapse(int doautocollapse); + virtual int setFontSize(int newsize); + virtual int getFontSize(); + virtual int getNumVisibleChildItems(ScriptObject *c); + virtual int getNumVisibleItems(); + virtual ScriptObject *enumVisibleItems(int n); + virtual ScriptObject *enumVisibleChildItems(ScriptObject *c, int n); + virtual ScriptObject *enumAllItems(int n); + virtual int getItemRectX(ScriptObject *item); + virtual int getItemRectY(ScriptObject *item); + virtual int getItemRectW(ScriptObject *item); + virtual int getItemRectH(ScriptObject *item); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onwantautocontextmenu_id; + static int onmousewheelup_id; + static int onmousewheeldown_id; + static int oncontextmenu_id; + static int onchar_id; + static int onitemrecvdrop_id; + static int onlabelchange_id; + static int onitemselected_id; + static int onitemdeselected_id; + static int getnumrootitems_id; + static int enumrootitem_id; + static int jumptonext_id; + static int ensureitemvisible_id; + static int getcontentswidth_id; + static int getcontentsheight_id; + static int addtreeitem_id; + static int removetreeitem_id; + static int movetreeitem_id; + static int deleteallitems_id; + static int expanditem_id; + static int expanditemdeferred_id; + static int collapseitem_id; + static int collapseitemdeferred_id; + static int selectitem_id; + static int selectitemdeferred_id; + static int delitemdeferred_id; + static int hiliteitem_id; + static int unhiliteitem_id; + static int getcuritem_id; + static int hittest_id; + static int edititemlabel_id; + static int canceleditlabel_id; + static int setautoedit_id; + static int getautoedit_id; + static int getbylabel_id; + static int setsorted_id; + static int getsorted_id; + static int sorttreeitems_id; + static int getsibling_id; + static int setautocollapse_id; + static int setfontsize_id; + static int getfontsize_id; + static int getnumvisiblechilditems_id; + static int getnumvisibleitems_id; + static int enumvisibleitems_id; + static int enumvisiblechilditems_id; + static int enumallitems_id; + static int getitemrectx_id; + static int getitemrecty_id; + static int getitemrectw_id; + static int getitemrecth_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_layout.cpp b/Src/Wasabi/api/script/objects/c_script/c_layout.cpp new file mode 100644 index 00000000..cc87042f --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_layout.cpp @@ -0,0 +1,236 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include "c_layout.h" +#include + +C_Layout::C_Layout(ScriptObject *object) : C_Group(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_Layout::C_Layout() { + inited = 0; + obj = NULL; +} + +void C_Layout::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, layoutGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + ondock_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onDock", this); + onundock_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onUndock", this); + onscale_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onScale", this); + getscale_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getScale", this); + setscale_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setScale", this); + setdesktopalpha_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setDesktopAlpha", this); + getdesktopalpha_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getDesktopAlpha", this); + getcontainer_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getContainer", this); + center_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"center", this); + onmove_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onMove", this); + onendmove_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onEndMove", this); + onuserresize_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onUserResize", this); + snapadjust_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"snapAdjust", this); + getsnapadjusttop_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSnapAdjustTop", this); + getsnapadjustright_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSnapAdjustRight", this); + getsnapadjustleft_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSnapAdjustLeft", this); + getsnapadjustbottom_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSnapAdjustBottom", this); + setredrawonresize_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setRedrawOnResize", this); + beforeredock_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"beforeRedock", this); + redock_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"redock", this); + istransparencysafe_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isTransparencySafe", this); + islayoutanimationsafe_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isLayoutAnimationSafe", this); + onmouseenterlayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onMouseEnterLayout", this); + onmouseleavelayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onMouseLeaveLayout", this); + onsnapadjustchanged_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSnapAdjustChanged", this); + } + inited = 1; +} + +C_Layout::~C_Layout() { +} + +ScriptObject *C_Layout::getScriptObject() { + if (obj != NULL) return obj; + return C_LAYOUT_PARENT::getScriptObject(); +} + +void C_Layout::onDock() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ondock_id, NULL); +} + +void C_Layout::onUndock() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onundock_id, NULL); +} + +void C_Layout::onScale(double newscalevalue) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_DOUBLE(newscalevalue); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onscale_id, params); +} + +double C_Layout::getScale() { + ASSERT(inited); + return GET_SCRIPT_DOUBLE(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getscale_id, NULL)); +} + +void C_Layout::setScale(double scalevalue) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_DOUBLE(scalevalue); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setscale_id, params); +} + +void C_Layout::setDesktopAlpha(int onoff) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(onoff); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setdesktopalpha_id, params); +} + +int C_Layout::getDesktopAlpha() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getdesktopalpha_id, NULL)); +} + +ScriptObject *C_Layout::getContainer() { + ASSERT(inited); + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcontainer_id, NULL)); +} + +void C_Layout::center() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), center_id, NULL); +} + +void C_Layout::onMove() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onmove_id, NULL); +} + +void C_Layout::onEndMove() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onendmove_id, NULL); +} + +void C_Layout::onUserResize(int x, int y, int w, int h) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar c = MAKE_SCRIPT_INT(w); + scriptVar d = MAKE_SCRIPT_INT(h); + scriptVar *params[4] = {&a, &b, &c, &d}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onuserresize_id, params); +} + +void C_Layout::snapAdjust(int left, int top, int right, int bottom) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(left); + scriptVar b = MAKE_SCRIPT_INT(top); + scriptVar c = MAKE_SCRIPT_INT(right); + scriptVar d = MAKE_SCRIPT_INT(bottom); + scriptVar *params[4] = {&a, &b, &c, &d}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), snapadjust_id, params); +} + +int C_Layout::getSnapAdjustTop() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getsnapadjusttop_id, NULL)); +} + +int C_Layout::getSnapAdjustRight() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getsnapadjustright_id, NULL)); +} + +int C_Layout::getSnapAdjustLeft() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getsnapadjustleft_id, NULL)); +} + +int C_Layout::getSnapAdjustBottom() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getsnapadjustbottom_id, NULL)); +} + +void C_Layout::setRedrawOnResize(int wantredrawonresize) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(wantredrawonresize); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setredrawonresize_id, params); +} + +void C_Layout::beforeRedock() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), beforeredock_id, NULL); +} + +void C_Layout::redock() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), redock_id, NULL); +} + +int C_Layout::isTransparencySafe() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), istransparencysafe_id, NULL)); +} + +int C_Layout::isLayoutAnimationSafe() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), islayoutanimationsafe_id, NULL)); +} + +void C_Layout::onMouseEnterLayout() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onmouseenterlayout_id, NULL); +} + +void C_Layout::onMouseLeaveLayout() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onmouseleavelayout_id, NULL); +} + +void C_Layout::onSnapAdjustChanged() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onsnapadjustchanged_id, NULL); +} + +int C_Layout::loaded=0; +int C_Layout::ondock_id=0; +int C_Layout::onundock_id=0; +int C_Layout::onscale_id=0; +int C_Layout::getscale_id=0; +int C_Layout::setscale_id=0; +int C_Layout::setdesktopalpha_id=0; +int C_Layout::getdesktopalpha_id=0; +int C_Layout::getcontainer_id=0; +int C_Layout::center_id=0; +int C_Layout::onmove_id=0; +int C_Layout::onendmove_id=0; +int C_Layout::onuserresize_id=0; +int C_Layout::snapadjust_id=0; +int C_Layout::getsnapadjusttop_id=0; +int C_Layout::getsnapadjustright_id=0; +int C_Layout::getsnapadjustleft_id=0; +int C_Layout::getsnapadjustbottom_id=0; +int C_Layout::setredrawonresize_id=0; +int C_Layout::beforeredock_id=0; +int C_Layout::redock_id=0; +int C_Layout::istransparencysafe_id=0; +int C_Layout::islayoutanimationsafe_id=0; +int C_Layout::onmouseenterlayout_id=0; +int C_Layout::onmouseleavelayout_id=0; +int C_Layout::onsnapadjustchanged_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_layout.h b/Src/Wasabi/api/script/objects/c_script/c_layout.h new file mode 100644 index 00000000..158a0545 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_layout.h @@ -0,0 +1,79 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_LAYOUT_H +#define __C_LAYOUT_H + +#include "c_group.h" + +#define C_LAYOUT_PARENT C_Group + +class C_Layout : public C_LAYOUT_PARENT { + public: + + C_Layout(ScriptObject *object); + C_Layout(); + virtual ~C_Layout(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void onDock(); + virtual void onUndock(); + virtual void onScale(double newscalevalue); + virtual double getScale(); + virtual void setScale(double scalevalue); + virtual void setDesktopAlpha(int onoff); + virtual int getDesktopAlpha(); + virtual ScriptObject *getContainer(); + virtual void center(); + virtual void onMove(); + virtual void onEndMove(); + virtual void onUserResize(int x, int y, int w, int h); + virtual void snapAdjust(int left, int top, int right, int bottom); + virtual int getSnapAdjustTop(); + virtual int getSnapAdjustRight(); + virtual int getSnapAdjustLeft(); + virtual int getSnapAdjustBottom(); + virtual void setRedrawOnResize(int wantredrawonresize); + virtual void beforeRedock(); + virtual void redock(); + virtual int isTransparencySafe(); + virtual int isLayoutAnimationSafe(); + virtual void onMouseEnterLayout(); + virtual void onMouseLeaveLayout(); + virtual void onSnapAdjustChanged(); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int ondock_id; + static int onundock_id; + static int onscale_id; + static int getscale_id; + static int setscale_id; + static int setdesktopalpha_id; + static int getdesktopalpha_id; + static int getcontainer_id; + static int center_id; + static int onmove_id; + static int onendmove_id; + static int onuserresize_id; + static int snapadjust_id; + static int getsnapadjusttop_id; + static int getsnapadjustright_id; + static int getsnapadjustleft_id; + static int getsnapadjustbottom_id; + static int setredrawonresize_id; + static int beforeredock_id; + static int redock_id; + static int istransparencysafe_id; + static int islayoutanimationsafe_id; + static int onmouseenterlayout_id; + static int onmouseleavelayout_id; + static int onsnapadjustchanged_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_menubutton.cpp b/Src/Wasabi/api/script/objects/c_script/c_menubutton.cpp new file mode 100644 index 00000000..a79909e1 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_menubutton.cpp @@ -0,0 +1,80 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include "c_menubutton.h" +#include + +C_MenuButton::C_MenuButton(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_MenuButton::C_MenuButton() { + inited = 0; + obj = NULL; +} + +void C_MenuButton::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, menuButtonGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + onopenmenu_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onOpenMenu", this); + onclosemenu_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onCloseMenu", this); + onselectitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSelectItem", this); + openmenu_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"openMenu", this); + closemenu_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"closeMenu", this); + } + inited = 1; +} + +C_MenuButton::~C_MenuButton() { +} + +ScriptObject *C_MenuButton::getScriptObject() { + if (obj != NULL) return obj; + return C_MENUBUTTON_PARENT::getScriptObject(); +} + +void C_MenuButton::onOpenMenu() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onopenmenu_id, NULL); +} + +void C_MenuButton::onCloseMenu() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onclosemenu_id, NULL); +} + +void C_MenuButton::onSelectItem(const wchar_t *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onselectitem_id, params); +} + +void C_MenuButton::openMenu() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), openmenu_id, NULL); +} + +void C_MenuButton::closeMenu() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), closemenu_id, NULL); +} + +int C_MenuButton::loaded=0; +int C_MenuButton::onopenmenu_id=0; +int C_MenuButton::onclosemenu_id=0; +int C_MenuButton::onselectitem_id=0; +int C_MenuButton::openmenu_id=0; +int C_MenuButton::closemenu_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_menubutton.h b/Src/Wasabi/api/script/objects/c_script/c_menubutton.h new file mode 100644 index 00000000..2da559ba --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_menubutton.h @@ -0,0 +1,39 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_MENUBUTTON_H +#define __C_MENUBUTTON_H + +#include "c_guiobject.h" + +#define C_MENUBUTTON_PARENT C_GuiObject + +class C_MenuButton : public C_MENUBUTTON_PARENT { + public: + + C_MenuButton(ScriptObject *object); + C_MenuButton(); + virtual ~C_MenuButton(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void onOpenMenu(); + virtual void onCloseMenu(); + virtual void onSelectItem(const wchar_t *item); + virtual void openMenu(); + virtual void closeMenu(); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onopenmenu_id; + static int onclosemenu_id; + static int onselectitem_id; + static int openmenu_id; + static int closemenu_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_querylist.cpp b/Src/Wasabi/api/script/objects/c_script/c_querylist.cpp new file mode 100644 index 00000000..8535bcf5 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_querylist.cpp @@ -0,0 +1,49 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include "c_querylist.h" +#include + +C_QueryList::C_QueryList(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_QueryList::C_QueryList() { + inited = 0; + obj = NULL; +} + +void C_QueryList::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, queryListGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + if (!loaded) { + loaded = 1; + onresetquery_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onResetQuery", this); + } + inited = 1; +} + +C_QueryList::~C_QueryList() { +} + +ScriptObject *C_QueryList::getScriptObject() { + if (obj != NULL) return obj; + return C_QUERYLIST_PARENT::getScriptObject(); +} + +void C_QueryList::onResetQuery() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onresetquery_id, NULL); +} + +int C_QueryList::loaded=0; +int C_QueryList::onresetquery_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_querylist.h b/Src/Wasabi/api/script/objects/c_script/c_querylist.h new file mode 100644 index 00000000..51c18a77 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_querylist.h @@ -0,0 +1,31 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_QUERYLIST_H +#define __C_QUERYLIST_H + +#include "c_guiobject.h" + +#define C_QUERYLIST_PARENT C_GuiObject + +class C_QueryList : public C_QUERYLIST_PARENT { + public: + + C_QueryList(ScriptObject *object); + C_QueryList(); + virtual ~C_QueryList(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void onResetQuery(); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onresetquery_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_rootobj.cpp b/Src/Wasabi/api/script/objects/c_script/c_rootobj.cpp new file mode 100644 index 00000000..304d1715 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_rootobj.cpp @@ -0,0 +1,64 @@ +#include + +#include +#include +#include "c_rootobj.h" + +C_RootObject::C_RootObject(ScriptObject *o) +{ + inited = 0; + obj = NULL; + C_hook(o); +} + +C_RootObject::C_RootObject() +{ + inited = 0; + obj = NULL; +} + +void C_RootObject::C_hook(ScriptObject *o) +{ + ASSERT(!inited); + obj = o; + if (count++ == 0) { + getclassname_id = WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"getClassName", this); + notify_id = WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"notify", this); + } + inited=1; +} + +C_RootObject::~C_RootObject() +{ + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); + //count--; +} + +ScriptObject *C_RootObject::getScriptObject() +{ + ASSERT(inited); + return obj; +} + +const wchar_t *C_RootObject::getClassName() +{ + ASSERT(inited); + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(obj, getclassname_id, NULL)); +} + +void C_RootObject::notify(const wchar_t *a, const wchar_t *b, int c, int d) +{ + ASSERT(inited); + scriptVar _a = MAKE_SCRIPT_STRING(a); + scriptVar _b = MAKE_SCRIPT_STRING(b); + scriptVar _c = MAKE_SCRIPT_INT(c); + scriptVar _d = MAKE_SCRIPT_INT(d); + scriptVar *params[4]={&_a, &_b, &_c, &_d}; + WASABI_API_MAKI->maki_callFunction(obj, notify_id, params); +} + +int C_RootObject::getclassname_id=0; +int C_RootObject::notify_id=0; +int C_RootObject::inited=0; +int C_RootObject::count=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_rootobj.h b/Src/Wasabi/api/script/objects/c_script/c_rootobj.h new file mode 100644 index 00000000..780b83b1 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_rootobj.h @@ -0,0 +1,33 @@ +#ifndef __C_SCRIPTOBJ_H +#define __C_SCRIPTOBJ_H + +#include + +class C_RootObject{ + + public: + + C_RootObject(ScriptObject *o); + C_RootObject(); + virtual ~C_RootObject(); + + virtual void C_hook(ScriptObject *o); + + virtual const wchar_t *getClassName(); + virtual void notify(const wchar_t *a, const wchar_t *b, int c, int d); + virtual ScriptObject *getScriptObject(); + + operator ScriptObject *() { return getScriptObject(); } + + private: + + ScriptObject *obj; + static int getclassname_id; + static int notify_id; + static int inited; + static int count; +}; + + + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_slider.cpp b/Src/Wasabi/api/script/objects/c_script/c_slider.cpp new file mode 100644 index 00000000..0aaaa4b1 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_slider.cpp @@ -0,0 +1,100 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include "c_slider.h" +#include + +C_Slider::C_Slider(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_Slider::C_Slider() { + inited = 0; + obj = NULL; +} + +void C_Slider::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, sliderGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + onsetposition_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSetPosition", this); + onpostedposition_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onPostedPosition", this); + onsetfinalposition_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSetFinalPosition", this); + setposition_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setPosition", this); + getposition_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getPosition", this); + lock_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"lock", this); + unlock_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"unlock", this); + } + inited = 1; +} + +C_Slider::~C_Slider() { +} + +ScriptObject *C_Slider::getScriptObject() { + if (obj != NULL) return obj; + return C_SLIDER_PARENT::getScriptObject(); +} + +void C_Slider::onSetPosition(int newpos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(newpos); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onsetposition_id, params); +} + +void C_Slider::onPostedPosition(int newpos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(newpos); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onpostedposition_id, params); +} + +void C_Slider::onSetFinalPosition(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onsetfinalposition_id, params); +} + +void C_Slider::setPosition(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setposition_id, params); +} + +int C_Slider::getPosition() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getposition_id, NULL)); +} + +void C_Slider::lock() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), lock_id, NULL); +} + +void C_Slider::unlock() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), unlock_id, NULL); +} + +int C_Slider::loaded=0; +int C_Slider::onsetposition_id=0; +int C_Slider::onpostedposition_id=0; +int C_Slider::onsetfinalposition_id=0; +int C_Slider::setposition_id=0; +int C_Slider::getposition_id=0; +int C_Slider::lock_id=0; +int C_Slider::unlock_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_slider.h b/Src/Wasabi/api/script/objects/c_script/c_slider.h new file mode 100644 index 00000000..a7d96fc0 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_slider.h @@ -0,0 +1,43 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_SLIDER_H +#define __C_SLIDER_H + +#include "c_guiobject.h" + +#define C_SLIDER_PARENT C_GuiObject + +class C_Slider : public C_SLIDER_PARENT { + public: + + C_Slider(ScriptObject *object); + C_Slider(); + virtual ~C_Slider(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void onSetPosition(int newpos); + virtual void onPostedPosition(int newpos); + virtual void onSetFinalPosition(int pos); + virtual void setPosition(int pos); + virtual int getPosition(); + virtual void lock(); + virtual void unlock(); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onsetposition_id; + static int onpostedposition_id; + static int onsetfinalposition_id; + static int setposition_id; + static int getposition_id; + static int lock_id; + static int unlock_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_tabsheet.cpp b/Src/Wasabi/api/script/objects/c_script/c_tabsheet.cpp new file mode 100644 index 00000000..b7455187 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_tabsheet.cpp @@ -0,0 +1,59 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include +#include +#include "c_tabsheet.h" +#include + +C_TabSheet::C_TabSheet(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_TabSheet::C_TabSheet() { + inited = 0; + obj = NULL; +} + +void C_TabSheet::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, tabSheetGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + getcurpage_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getCurPage", this); + setcurpage_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setCurPage", this); + } + inited = 1; +} + +C_TabSheet::~C_TabSheet() { +} + +ScriptObject *C_TabSheet::getScriptObject() { + if (obj != NULL) return obj; + return C_TABSHEET_PARENT::getScriptObject(); +} + +int C_TabSheet::getCurPage() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcurpage_id, NULL)); +} + +void C_TabSheet::setCurPage(int a) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(a); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setcurpage_id, params); +} + +int C_TabSheet::loaded=0; +int C_TabSheet::getcurpage_id=0; +int C_TabSheet::setcurpage_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_tabsheet.h b/Src/Wasabi/api/script/objects/c_script/c_tabsheet.h new file mode 100644 index 00000000..5d2323d7 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_tabsheet.h @@ -0,0 +1,33 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_TABSHEET_H +#define __C_TABSHEET_H + +#include "c_guiobject.h" + +#define C_TABSHEET_PARENT C_GuiObject + +class C_TabSheet : public C_TABSHEET_PARENT { + public: + + C_TabSheet(ScriptObject *object); + C_TabSheet(); + virtual ~C_TabSheet(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual int getCurPage(); + virtual void setCurPage(int a); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int getcurpage_id; + static int setcurpage_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_text.cpp b/Src/Wasabi/api/script/objects/c_script/c_text.cpp new file mode 100644 index 00000000..0d178d01 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_text.cpp @@ -0,0 +1,89 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include "c_text.h" +#include + +C_Text::C_Text(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_Text::C_Text() { + inited = 0; + obj = NULL; +} + +void C_Text::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, textGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + settext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setText", this); + setalternatetext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setAlternateText", this); + gettext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getText", this); + gettextwidth_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getTextWidth", this); + ontextchanged_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onTextChanged", this); + } + inited = 1; +} + +C_Text::~C_Text() { +} + +ScriptObject *C_Text::getScriptObject() { + if (obj != NULL) return obj; + return C_TEXT_PARENT::getScriptObject(); +} + +void C_Text::setText(const wchar_t *txt) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(txt); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), settext_id, params); +} + +void C_Text::setAlternateText(const wchar_t *txt) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(txt); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setalternatetext_id, params); +} + +const wchar_t *C_Text::getText() +{ + ASSERT(inited); + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), gettext_id, NULL)); +} + +int C_Text::getTextWidth() +{ + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), gettextwidth_id, NULL)); +} + +void C_Text::onTextChanged(const wchar_t *newtxt) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(newtxt); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ontextchanged_id, params); +} + +int C_Text::loaded=0; +int C_Text::settext_id=0; +int C_Text::setalternatetext_id=0; +int C_Text::gettext_id=0; +int C_Text::gettextwidth_id=0; +int C_Text::ontextchanged_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_text.h b/Src/Wasabi/api/script/objects/c_script/c_text.h new file mode 100644 index 00000000..5a997c47 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_text.h @@ -0,0 +1,40 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_TEXT_H +#define __C_TEXT_H + +#include "c_guiobject.h" + +#define C_TEXT_PARENT C_GuiObject + +class C_Text : public C_TEXT_PARENT +{ + public: + + C_Text(ScriptObject *object); + C_Text(); + virtual ~C_Text(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void setText(const wchar_t *txt); + virtual void setAlternateText(const wchar_t *txt); + virtual const wchar_t *getText(); + virtual int getTextWidth(); + virtual void onTextChanged(const wchar_t *newtxt); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int settext_id; + static int setalternatetext_id; + static int gettext_id; + static int gettextwidth_id; + static int ontextchanged_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_togglebutton.cpp b/Src/Wasabi/api/script/objects/c_script/c_togglebutton.cpp new file mode 100644 index 00000000..93a8e0a0 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_togglebutton.cpp @@ -0,0 +1,59 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include "c_togglebutton.h" +#include + +C_ToggleButton::C_ToggleButton(ScriptObject *object) : C_Button(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_ToggleButton::C_ToggleButton() { + inited = 0; + obj = NULL; +} + +void C_ToggleButton::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, toggleButtonGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + ontoggle_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onToggle", this); + getcurcfgval_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getCurCfgVal", this); + } + inited = 1; +} + +C_ToggleButton::~C_ToggleButton() { +} + +ScriptObject *C_ToggleButton::getScriptObject() { + if (obj != NULL) return obj; + return C_TOGGLEBUTTON_PARENT::getScriptObject(); +} + +void C_ToggleButton::onToggle(int (null)) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT((null)); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ontoggle_id, params); +} + +int C_ToggleButton::getCurCfgVal() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcurcfgval_id, NULL)); +} + +int C_ToggleButton::loaded=0; +int C_ToggleButton::ontoggle_id=0; +int C_ToggleButton::getcurcfgval_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_togglebutton.h b/Src/Wasabi/api/script/objects/c_script/c_togglebutton.h new file mode 100644 index 00000000..0abcb656 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_togglebutton.h @@ -0,0 +1,33 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_TOGGLEBUTTON_H +#define __C_TOGGLEBUTTON_H + +#include "c_button.h" + +#define C_TOGGLEBUTTON_PARENT C_Button + +class C_ToggleButton : public C_TOGGLEBUTTON_PARENT { + public: + + C_ToggleButton(ScriptObject *object); + C_ToggleButton(); + virtual ~C_ToggleButton(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void onToggle(int (null)); + virtual int getCurCfgVal(); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int ontoggle_id; + static int getcurcfgval_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_treeitem.cpp b/Src/Wasabi/api/script/objects/c_script/c_treeitem.cpp new file mode 100644 index 00000000..337c441b --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_treeitem.cpp @@ -0,0 +1,310 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include "c_treeitem.h" +#include + +C_TreeItem::C_TreeItem(ScriptObject *object) : C_RootObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_TreeItem::C_TreeItem() { + inited = 0; + obj = NULL; +} + +void C_TreeItem::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, treeItemGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + getnumchildren_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNumChildren", this); + setlabel_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setLabel", this); + getlabel_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getLabel", this); + ensurevisible_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"ensureVisible", this); + getnthchild_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNthChild", this); + getchild_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getChild", this); + getchildsibling_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getChildSibling", this); + getsibling_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSibling", this); + getparent_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getParent", this); + editlabel_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"editLabel", this); + hassubitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"hasSubItems", this); + setsorted_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setSorted", this); + setchildtab_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setChildTab", this); + issorted_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isSorted", this); + iscollapsed_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isCollapsed", this); + isexpanded_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isExpanded", this); + invalidate_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"invalidate", this); + isselected_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isSelected", this); + ishilited_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isHilited", this); + sethilited_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setHilited", this); + collapse_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"collapse", this); + expand_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"expand", this); + gettree_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getTree", this); + ontreeadd_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onTreeAdd", this); + ontreeremove_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onTreeRemove", this); + onselect_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSelect", this); + ondeselect_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onDeselect", this); + onleftdoubleclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onLeftDoubleClick", this); + onrightdoubleclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onRightDoubleClick", this); + onchar_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onChar", this); + onexpand_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onExpand", this); + oncollapse_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onCollapse", this); + onbeginlabeledit_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onBeginLabelEdit", this); + onendlabeledit_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onEndLabelEdit", this); + oncontextmenu_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onContextMenu", this); + } + inited = 1; +} + +C_TreeItem::~C_TreeItem() { +} + +ScriptObject *C_TreeItem::getScriptObject() { + if (obj != NULL) return obj; + return C_TREEITEM_PARENT::getScriptObject(); +} + +int C_TreeItem::getNumChildren() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnumchildren_id, NULL)); +} + +void C_TreeItem::setLabel(const wchar_t *label) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(label); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setlabel_id, params); +} + +const wchar_t *C_TreeItem::getLabel() +{ + ASSERT(inited); + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getlabel_id, NULL)); +} + +void C_TreeItem::ensureVisible() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ensurevisible_id, NULL); +} + +ScriptObject *C_TreeItem::getNthChild(int nth) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(nth); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnthchild_id, params)); +} + +ScriptObject *C_TreeItem::getChild() { + ASSERT(inited); + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getchild_id, NULL)); +} + +ScriptObject *C_TreeItem::getChildSibling(ScriptObject *_item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(_item); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getchildsibling_id, params)); +} + +ScriptObject *C_TreeItem::getSibling() { + ASSERT(inited); + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getsibling_id, NULL)); +} + +ScriptObject *C_TreeItem::getParent() { + ASSERT(inited); + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getparent_id, NULL)); +} + +void C_TreeItem::editLabel() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), editlabel_id, NULL); +} + +int C_TreeItem::hasSubItems() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), hassubitems_id, NULL)); +} + +void C_TreeItem::setSorted(int issorted) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(issorted); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setsorted_id, params); +} + +void C_TreeItem::setChildTab(int haschildtab) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(haschildtab); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setchildtab_id, params); +} + +int C_TreeItem::isSorted() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), issorted_id, NULL)); +} + +int C_TreeItem::isCollapsed() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), iscollapsed_id, NULL)); +} + +int C_TreeItem::isExpanded() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), isexpanded_id, NULL)); +} + +void C_TreeItem::invalidate() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), invalidate_id, NULL); +} + +int C_TreeItem::isSelected() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), isselected_id, NULL)); +} + +int C_TreeItem::isHilited() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), ishilited_id, NULL)); +} + +void C_TreeItem::setHilited(int ishilited) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(ishilited); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), sethilited_id, params); +} + +int C_TreeItem::collapse() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), collapse_id, NULL)); +} + +int C_TreeItem::expand() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), expand_id, NULL)); +} + +ScriptObject *C_TreeItem::getTree() { + ASSERT(inited); + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), gettree_id, NULL)); +} + +void C_TreeItem::onTreeAdd() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ontreeadd_id, NULL); +} + +void C_TreeItem::onTreeRemove() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ontreeremove_id, NULL); +} + +void C_TreeItem::onSelect() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onselect_id, NULL); +} + +void C_TreeItem::onDeselect() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ondeselect_id, NULL); +} + +int C_TreeItem::onLeftDoubleClick() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onleftdoubleclick_id, NULL)); +} + +int C_TreeItem::onRightDoubleClick() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onrightdoubleclick_id, NULL)); +} + +int C_TreeItem::onChar(int key) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(key); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onchar_id, params)); +} + +void C_TreeItem::onExpand() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onexpand_id, NULL); +} + +void C_TreeItem::onCollapse() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), oncollapse_id, NULL); +} + +int C_TreeItem::onBeginLabelEdit() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onbeginlabeledit_id, NULL)); +} + +int C_TreeItem::onEndLabelEdit(const wchar_t *newlabel) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(newlabel); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onendlabeledit_id, params)); +} + +int C_TreeItem::onContextMenu(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), oncontextmenu_id, params)); +} + +int C_TreeItem::loaded=0; +int C_TreeItem::getnumchildren_id=0; +int C_TreeItem::setlabel_id=0; +int C_TreeItem::getlabel_id=0; +int C_TreeItem::ensurevisible_id=0; +int C_TreeItem::getnthchild_id=0; +int C_TreeItem::getchild_id=0; +int C_TreeItem::getchildsibling_id=0; +int C_TreeItem::getsibling_id=0; +int C_TreeItem::getparent_id=0; +int C_TreeItem::editlabel_id=0; +int C_TreeItem::hassubitems_id=0; +int C_TreeItem::setsorted_id=0; +int C_TreeItem::setchildtab_id=0; +int C_TreeItem::issorted_id=0; +int C_TreeItem::iscollapsed_id=0; +int C_TreeItem::isexpanded_id=0; +int C_TreeItem::invalidate_id=0; +int C_TreeItem::isselected_id=0; +int C_TreeItem::ishilited_id=0; +int C_TreeItem::sethilited_id=0; +int C_TreeItem::collapse_id=0; +int C_TreeItem::expand_id=0; +int C_TreeItem::gettree_id=0; +int C_TreeItem::ontreeadd_id=0; +int C_TreeItem::ontreeremove_id=0; +int C_TreeItem::onselect_id=0; +int C_TreeItem::ondeselect_id=0; +int C_TreeItem::onleftdoubleclick_id=0; +int C_TreeItem::onrightdoubleclick_id=0; +int C_TreeItem::onchar_id=0; +int C_TreeItem::onexpand_id=0; +int C_TreeItem::oncollapse_id=0; +int C_TreeItem::onbeginlabeledit_id=0; +int C_TreeItem::onendlabeledit_id=0; +int C_TreeItem::oncontextmenu_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_treeitem.h b/Src/Wasabi/api/script/objects/c_script/c_treeitem.h new file mode 100644 index 00000000..7ff3c78d --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_treeitem.h @@ -0,0 +1,99 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_TREEITEM_H +#define __C_TREEITEM_H + +#include "c_rootobj.h" + +#define C_TREEITEM_PARENT C_RootObject + +class C_TreeItem : public C_TREEITEM_PARENT { + public: + + C_TreeItem(ScriptObject *object); + C_TreeItem(); + virtual ~C_TreeItem(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual int getNumChildren(); + virtual void setLabel(const wchar_t *label); + virtual const wchar_t *getLabel(); + virtual void ensureVisible(); + virtual ScriptObject *getNthChild(int nth); + virtual ScriptObject *getChild(); + virtual ScriptObject *getChildSibling(ScriptObject *_item); + virtual ScriptObject *getSibling(); + virtual ScriptObject *getParent(); + virtual void editLabel(); + virtual int hasSubItems(); + virtual void setSorted(int issorted); + virtual void setChildTab(int haschildtab); + virtual int isSorted(); + virtual int isCollapsed(); + virtual int isExpanded(); + virtual void invalidate(); + virtual int isSelected(); + virtual int isHilited(); + virtual void setHilited(int ishilited); + virtual int collapse(); + virtual int expand(); + virtual ScriptObject *getTree(); + virtual void onTreeAdd(); + virtual void onTreeRemove(); + virtual void onSelect(); + virtual void onDeselect(); + virtual int onLeftDoubleClick(); + virtual int onRightDoubleClick(); + virtual int onChar(int key); + virtual void onExpand(); + virtual void onCollapse(); + virtual int onBeginLabelEdit(); + virtual int onEndLabelEdit(const wchar_t *newlabel); + virtual int onContextMenu(int x, int y); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int getnumchildren_id; + static int setlabel_id; + static int getlabel_id; + static int ensurevisible_id; + static int getnthchild_id; + static int getchild_id; + static int getchildsibling_id; + static int getsibling_id; + static int getparent_id; + static int editlabel_id; + static int hassubitems_id; + static int setsorted_id; + static int setchildtab_id; + static int issorted_id; + static int iscollapsed_id; + static int isexpanded_id; + static int invalidate_id; + static int isselected_id; + static int ishilited_id; + static int sethilited_id; + static int collapse_id; + static int expand_id; + static int gettree_id; + static int ontreeadd_id; + static int ontreeremove_id; + static int onselect_id; + static int ondeselect_id; + static int onleftdoubleclick_id; + static int onrightdoubleclick_id; + static int onchar_id; + static int onexpand_id; + static int oncollapse_id; + static int onbeginlabeledit_id; + static int onendlabeledit_id; + static int oncontextmenu_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/gen.m b/Src/Wasabi/api/script/objects/c_script/gen.m new file mode 100644 index 00000000..e3f89a27 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/gen.m @@ -0,0 +1,22 @@ +#include + +#export_cclass GuiObject +#export_cclass Browser +#export_cclass Button +#export_cclass Container +#export_cclass DropDownList +#export_cclass Edit +#export_cclass Group +#export_cclass GuiList +#export_cclass GuiTree +#export_cclass Layout +#export_cclass MenuButton +#export_cclass Slider +#export_cclass Text +#export_cclass ToggleButton +#export_cclass TreeItem +#export_cclass CheckBox +#export_cclass GroupList +#export_cclass TabSheet + +#abort "All done." diff --git a/Src/Wasabi/api/script/objects/c_script/h_browser.cpp b/Src/Wasabi/api/script/objects/c_script/h_browser.cpp new file mode 100644 index 00000000..9eb6eaa2 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_browser.cpp @@ -0,0 +1,85 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include +#include "h_browser.h" + +H_Browser::H_Browser(ScriptObject *o) : H_GuiObject(o) +{ + inited = 0; + obj = NULL; + H_hook(o); +} + +H_Browser::H_Browser() +{ + inited = 0; + obj = NULL; +} + +void H_Browser::H_hook(ScriptObject *o) +{ + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, browserGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &browserGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) + { + onbeforenavigate_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onBeforeNavigate", this); + ondocumentcomplete_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onDocumentComplete", this); + onmedialink_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onMediaLink", this); + loaded = 1; + } + inited=1; +} + +H_Browser::~H_Browser() +{ + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_Browser::getHookedObject() +{ + if (obj != NULL) return obj; + return H_BROWSER_PARENT::getHookedObject(); +} + +int H_Browser::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) +{ + if (object != getHookedObject()) return 0; + if (H_BROWSER_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + + if (dlfid == onbeforenavigate_id) + { + hook_onBeforeNavigate(GET_SCRIPT_STRING(*params[0]), GET_SCRIPT_INT(*params[1]), GET_SCRIPT_STRING(*params[2])); + return 1; + } + else if (dlfid == ondocumentcomplete_id) + { + hook_onDocumentComplete(GET_SCRIPT_STRING(*params[0])); + return 1; + } + else if (dlfid == onmedialink_id) + { + + hook_onMediaLink(GET_SCRIPT_STRING(*params[0])); + return 1; + } + + return 0; + +} + +int H_Browser::onbeforenavigate_id=0; +int H_Browser::ondocumentcomplete_id=0; +int H_Browser::onmedialink_id=0; +int H_Browser::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_browser.h b/Src/Wasabi/api/script/objects/c_script/h_browser.h new file mode 100644 index 00000000..1c958f10 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_browser.h @@ -0,0 +1,35 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_BROWSER_H +#define __HOOK_BROWSER_H + +#include "h_guiobject.h" + +#define H_BROWSER_PARENT H_GuiObject + +class H_Browser : public H_BROWSER_PARENT { + +public: + + H_Browser(ScriptObject *o); + H_Browser(); + virtual ~H_Browser(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onBeforeNavigate(const wchar_t *url, int flags, const wchar_t *targetframename) { } + virtual void hook_onDocumentComplete(const wchar_t *url) { } + virtual void hook_onMediaLink(const wchar_t *url) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onbeforenavigate_id; + static int ondocumentcomplete_id; + static int onmedialink_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_button.cpp b/Src/Wasabi/api/script/objects/c_script/h_button.cpp new file mode 100644 index 00000000..5477e4fa --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_button.cpp @@ -0,0 +1,62 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include +#include "h_button.h" + +H_Button::H_Button(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_Button::H_Button() { + inited = 0; + obj = NULL; +} + +void H_Button::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, buttonGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &buttonGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + onactivate_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onActivate", this); + onleftclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLeftClick", this); + onrightclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onRightClick", this); + loaded = 1; + } + inited=1; +} + +H_Button::~H_Button() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_Button::getHookedObject() { + if (obj != NULL) return obj; + return H_BUTTON_PARENT::getHookedObject(); +} + +int H_Button::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_BUTTON_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == onactivate_id) { hook_onActivate(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onleftclick_id) { hook_onLeftClick(); return 1; } + if (dlfid == onrightclick_id) { hook_onRightClick(); return 1; } + return 0; +} + +int H_Button::onactivate_id=0; +int H_Button::onleftclick_id=0; +int H_Button::onrightclick_id=0; +int H_Button::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_button.h b/Src/Wasabi/api/script/objects/c_script/h_button.h new file mode 100644 index 00000000..32cc15e2 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_button.h @@ -0,0 +1,35 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_BUTTON_H +#define __HOOK_BUTTON_H + +#include "h_guiobject.h" + +#define H_BUTTON_PARENT H_GuiObject + +class H_Button : public H_BUTTON_PARENT { + +public: + + H_Button(ScriptObject *o); + H_Button(); + virtual ~H_Button(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onActivate(int activated) { } + virtual void hook_onLeftClick() { } + virtual void hook_onRightClick() { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onactivate_id; + static int onleftclick_id; + static int onrightclick_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_checkbox.cpp b/Src/Wasabi/api/script/objects/c_script/h_checkbox.cpp new file mode 100644 index 00000000..4c5a0d97 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_checkbox.cpp @@ -0,0 +1,56 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include +#include "h_checkbox.h" + +H_CheckBox::H_CheckBox(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_CheckBox::H_CheckBox() { + inited = 0; + obj = NULL; +} + +void H_CheckBox::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, checkBoxGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &checkBoxGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + ontoggle_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onToggle", this); + loaded = 1; + } + inited=1; +} + +H_CheckBox::~H_CheckBox() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_CheckBox::getHookedObject() { + if (obj != NULL) return obj; + return H_CHECKBOX_PARENT::getHookedObject(); +} + +int H_CheckBox::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_CHECKBOX_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == ontoggle_id) { hook_onToggle(GET_SCRIPT_INT(*params[0])); return 1; } + return 0; +} + +int H_CheckBox::ontoggle_id=0; +int H_CheckBox::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_checkbox.h b/Src/Wasabi/api/script/objects/c_script/h_checkbox.h new file mode 100644 index 00000000..e1725073 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_checkbox.h @@ -0,0 +1,31 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_CHECKBOX_H +#define __HOOK_CHECKBOX_H + +#include "h_guiobject.h" + +#define H_CHECKBOX_PARENT H_GuiObject + +class H_CheckBox : public H_CHECKBOX_PARENT { + +public: + + H_CheckBox(ScriptObject *o); + H_CheckBox(); + virtual ~H_CheckBox(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onToggle(int newstate) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int ontoggle_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_container.cpp b/Src/Wasabi/api/script/objects/c_script/h_container.cpp new file mode 100644 index 00000000..b665af5c --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_container.cpp @@ -0,0 +1,65 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include +#include "h_container.h" + +H_Container::H_Container(ScriptObject *o) : H_RootObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_Container::H_Container() { + inited = 0; + obj = NULL; +} + +void H_Container::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, containerGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &containerGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + onswitchtolayout_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSwitchToLayout", this); + onbeforeswitchtolayout_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onBeforeSwitchToLayout", this); + onhidelayout_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onHideLayout", this); + onshowlayout_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onShowLayout", this); + loaded = 1; + } + inited=1; +} + +H_Container::~H_Container() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_Container::getHookedObject() { + if (obj != NULL) return obj; + return H_CONTAINER_PARENT::getHookedObject(); +} + +int H_Container::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_CONTAINER_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == onswitchtolayout_id) { hook_onSwitchToLayout(GET_SCRIPT_OBJECT(*params[0])); return 1; } + if (dlfid == onbeforeswitchtolayout_id) { hook_onBeforeSwitchToLayout(GET_SCRIPT_OBJECT(*params[0]), GET_SCRIPT_OBJECT(*params[1])); return 1; } + if (dlfid == onhidelayout_id) { hook_onHideLayout(GET_SCRIPT_OBJECT(*params[0])); return 1; } + if (dlfid == onshowlayout_id) { hook_onShowLayout(GET_SCRIPT_OBJECT(*params[0])); return 1; } + return 0; +} + +int H_Container::onswitchtolayout_id=0; +int H_Container::onbeforeswitchtolayout_id=0; +int H_Container::onhidelayout_id=0; +int H_Container::onshowlayout_id=0; +int H_Container::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_container.h b/Src/Wasabi/api/script/objects/c_script/h_container.h new file mode 100644 index 00000000..eae5069d --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_container.h @@ -0,0 +1,37 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_CONTAINER_H +#define __HOOK_CONTAINER_H + +#include "h_rootobj.h" + +#define H_CONTAINER_PARENT H_RootObject + +class H_Container : public H_CONTAINER_PARENT { + +public: + + H_Container(ScriptObject *o); + H_Container(); + virtual ~H_Container(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onSwitchToLayout(ScriptObject *newlayout) { } + virtual void hook_onBeforeSwitchToLayout(ScriptObject *oldlayout, ScriptObject *newlayout) { } + virtual void hook_onHideLayout(ScriptObject *_layout) { } + virtual void hook_onShowLayout(ScriptObject *_layout) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onswitchtolayout_id; + static int onbeforeswitchtolayout_id; + static int onhidelayout_id; + static int onshowlayout_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_dropdownlist.cpp b/Src/Wasabi/api/script/objects/c_script/h_dropdownlist.cpp new file mode 100644 index 00000000..a6d14f7a --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_dropdownlist.cpp @@ -0,0 +1,56 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include +#include "h_dropdownlist.h" + +H_DropDownList::H_DropDownList(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_DropDownList::H_DropDownList() { + inited = 0; + obj = NULL; +} + +void H_DropDownList::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, dropDownListGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &dropDownListGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + onselect_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSelect", this); + loaded = 1; + } + inited=1; +} + +H_DropDownList::~H_DropDownList() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_DropDownList::getHookedObject() { + if (obj != NULL) return obj; + return H_DROPDOWNLIST_PARENT::getHookedObject(); +} + +int H_DropDownList::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_DROPDOWNLIST_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == onselect_id) { hook_onSelect(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + return 0; +} + +int H_DropDownList::onselect_id=0; +int H_DropDownList::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_dropdownlist.h b/Src/Wasabi/api/script/objects/c_script/h_dropdownlist.h new file mode 100644 index 00000000..a044cf8c --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_dropdownlist.h @@ -0,0 +1,31 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_DROPDOWNLIST_H +#define __HOOK_DROPDOWNLIST_H + +#include "h_guiobject.h" + +#define H_DROPDOWNLIST_PARENT H_GuiObject + +class H_DropDownList : public H_DROPDOWNLIST_PARENT { + +public: + + H_DropDownList(ScriptObject *o); + H_DropDownList(); + virtual ~H_DropDownList(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onSelect(int id, int hover) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onselect_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_edit.cpp b/Src/Wasabi/api/script/objects/c_script/h_edit.cpp new file mode 100644 index 00000000..2bb72698 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_edit.cpp @@ -0,0 +1,65 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include +#include "h_edit.h" + +H_Edit::H_Edit(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_Edit::H_Edit() { + inited = 0; + obj = NULL; +} + +void H_Edit::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, editGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &editGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + onenter_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onEnter", this); + onabort_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onAbort", this); + onidleeditupdate_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onIdleEditUpdate", this); + oneditupdate_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onEditUpdate", this); + loaded = 1; + } + inited=1; +} + +H_Edit::~H_Edit() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_Edit::getHookedObject() { + if (obj != NULL) return obj; + return H_EDIT_PARENT::getHookedObject(); +} + +int H_Edit::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_EDIT_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == onenter_id) { hook_onEnter(); return 1; } + if (dlfid == onabort_id) { hook_onAbort(); return 1; } + if (dlfid == onidleeditupdate_id) { hook_onIdleEditUpdate(); return 1; } + if (dlfid == oneditupdate_id) { hook_onEditUpdate(); return 1; } + return 0; +} + +int H_Edit::onenter_id=0; +int H_Edit::onabort_id=0; +int H_Edit::onidleeditupdate_id=0; +int H_Edit::oneditupdate_id=0; +int H_Edit::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_edit.h b/Src/Wasabi/api/script/objects/c_script/h_edit.h new file mode 100644 index 00000000..d267cd89 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_edit.h @@ -0,0 +1,37 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_EDIT_H +#define __HOOK_EDIT_H + +#include "h_guiobject.h" + +#define H_EDIT_PARENT H_GuiObject + +class H_Edit : public H_EDIT_PARENT { + +public: + + H_Edit(ScriptObject *o); + H_Edit(); + virtual ~H_Edit(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onEnter() { } + virtual void hook_onAbort() { } + virtual void hook_onIdleEditUpdate() { } + virtual void hook_onEditUpdate() { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onenter_id; + static int onabort_id; + static int onidleeditupdate_id; + static int oneditupdate_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_group.cpp b/Src/Wasabi/api/script/objects/c_script/h_group.cpp new file mode 100644 index 00000000..36aaadda --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_group.cpp @@ -0,0 +1,56 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include +#include "h_group.h" + +H_Group::H_Group(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_Group::H_Group() { + inited = 0; + obj = NULL; +} + +void H_Group::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, groupGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &groupGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + oncreateobject_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onCreateObject", this); + loaded = 1; + } + inited=1; +} + +H_Group::~H_Group() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_Group::getHookedObject() { + if (obj != NULL) return obj; + return H_GROUP_PARENT::getHookedObject(); +} + +int H_Group::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_GROUP_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == oncreateobject_id) { hook_onCreateObject(GET_SCRIPT_OBJECT(*params[0])); return 1; } + return 0; +} + +int H_Group::oncreateobject_id=0; +int H_Group::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_group.h b/Src/Wasabi/api/script/objects/c_script/h_group.h new file mode 100644 index 00000000..06dbefb0 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_group.h @@ -0,0 +1,31 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_GROUP_H +#define __HOOK_GROUP_H + +#include "h_guiobject.h" + +#define H_GROUP_PARENT H_GuiObject + +class H_Group : public H_GROUP_PARENT { + +public: + + H_Group(ScriptObject *o); + H_Group(); + virtual ~H_Group(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onCreateObject(ScriptObject *newobj) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int oncreateobject_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_grouplist.cpp b/Src/Wasabi/api/script/objects/c_script/h_grouplist.cpp new file mode 100644 index 00000000..4a9aecaa --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_grouplist.cpp @@ -0,0 +1,53 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include +#include +#include +#include "h_grouplist.h" + +H_GroupList::H_GroupList(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_GroupList::H_GroupList() { + inited = 0; + obj = NULL; +} + +void H_GroupList::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, groupListGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &groupListGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = 1; + } + inited=1; +} + +H_GroupList::~H_GroupList() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_GroupList::getHookedObject() { + if (obj != NULL) return obj; + return H_GROUPLIST_PARENT::getHookedObject(); +} + +int H_GroupList::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_GROUPLIST_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + return 0; +} + +int H_GroupList::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_grouplist.h b/Src/Wasabi/api/script/objects/c_script/h_grouplist.h new file mode 100644 index 00000000..460b94ab --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_grouplist.h @@ -0,0 +1,29 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_GROUPLIST_H +#define __HOOK_GROUPLIST_H + +#include "h_guiobject.h" + +#define H_GROUPLIST_PARENT H_GuiObject + +class H_GroupList : public H_GROUPLIST_PARENT { + +public: + + H_GroupList(ScriptObject *o); + H_GroupList(); + virtual ~H_GroupList(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + + private: + + ScriptObject *obj; + int inited; + static int loaded; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_guilist.cpp b/Src/Wasabi/api/script/objects/c_script/h_guilist.cpp new file mode 100644 index 00000000..e108c898 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_guilist.cpp @@ -0,0 +1,83 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include +#include "h_guilist.h" + +H_GuiList::H_GuiList(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_GuiList::H_GuiList() { + inited = 0; + obj = NULL; +} + +void H_GuiList::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, guiListGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &guiListGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + onsetvisible_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSetVisible", this); + onselectall_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSelectAll", this); + ondelete_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onDelete", this); + ondoubleclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onDoubleClick", this); + onleftclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLeftClick", this); + onsecondleftclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSecondLeftClick", this); + onrightclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onRightClick", this); + oncolumndblclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onColumnDblClick", this); + oncolumnlabelclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onColumnLabelClick", this); + onitemselection_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onItemSelection", this); + loaded = 1; + } + inited=1; +} + +H_GuiList::~H_GuiList() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_GuiList::getHookedObject() { + if (obj != NULL) return obj; + return H_GUILIST_PARENT::getHookedObject(); +} + +int H_GuiList::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_GUILIST_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == onsetvisible_id) { hook_onSetVisible(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onselectall_id) { hook_onSelectAll(); return 1; } + if (dlfid == ondelete_id) { hook_onDelete(); return 1; } + if (dlfid == ondoubleclick_id) { hook_onDoubleClick(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onleftclick_id) { hook_onLeftClick(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onsecondleftclick_id) { hook_onSecondLeftClick(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onrightclick_id) { hook_onRightClick(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == oncolumndblclick_id) { hook_onColumnDblClick(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1]), GET_SCRIPT_INT(*params[2])); return 1; } + if (dlfid == oncolumnlabelclick_id) { hook_onColumnLabelClick(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1]), GET_SCRIPT_INT(*params[2])); return 1; } + if (dlfid == onitemselection_id) { hook_onItemSelection(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + return 0; +} + +int H_GuiList::onsetvisible_id=0; +int H_GuiList::onselectall_id=0; +int H_GuiList::ondelete_id=0; +int H_GuiList::ondoubleclick_id=0; +int H_GuiList::onleftclick_id=0; +int H_GuiList::onsecondleftclick_id=0; +int H_GuiList::onrightclick_id=0; +int H_GuiList::oncolumndblclick_id=0; +int H_GuiList::oncolumnlabelclick_id=0; +int H_GuiList::onitemselection_id=0; +int H_GuiList::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_guilist.h b/Src/Wasabi/api/script/objects/c_script/h_guilist.h new file mode 100644 index 00000000..d762abb3 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_guilist.h @@ -0,0 +1,49 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_GUILIST_H +#define __HOOK_GUILIST_H + +#include "h_guiobject.h" + +#define H_GUILIST_PARENT H_GuiObject + +class H_GuiList : public H_GUILIST_PARENT { + +public: + + H_GuiList(ScriptObject *o); + H_GuiList(); + virtual ~H_GuiList(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onSetVisible(int show) { } + virtual void hook_onSelectAll() { } + virtual void hook_onDelete() { } + virtual void hook_onDoubleClick(int itemnum) { } + virtual void hook_onLeftClick(int itemnum) { } + virtual void hook_onSecondLeftClick(int itemnum) { } + virtual void hook_onRightClick(int itemnum) { } + virtual void hook_onColumnDblClick(int col, int x, int y) { } + virtual void hook_onColumnLabelClick(int col, int x, int y) { } + virtual void hook_onItemSelection(int itemnum, int selected) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onsetvisible_id; + static int onselectall_id; + static int ondelete_id; + static int ondoubleclick_id; + static int onleftclick_id; + static int onsecondleftclick_id; + static int onrightclick_id; + static int oncolumndblclick_id; + static int oncolumnlabelclick_id; + static int onitemselection_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_guiobject.cpp b/Src/Wasabi/api/script/objects/c_script/h_guiobject.cpp new file mode 100644 index 00000000..b4867dd8 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_guiobject.cpp @@ -0,0 +1,117 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include +#include "h_guiobject.h" +#include "../nu/AUtoChar.h" + +H_GuiObject::H_GuiObject(ScriptObject *o) : H_RootObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_GuiObject::H_GuiObject() { + inited = 0; + obj = NULL; +} + +void H_GuiObject::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, guiObjectGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &guiObjectGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + onsetvisible_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSetVisible", this); + onleftbuttonup_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLeftButtonUp", this); + onleftbuttondown_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLeftButtonDown", this); + onrightbuttonup_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onRightButtonUp", this); + onrightbuttondown_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onRightButtonDown", this); + onrightbuttondblclk_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onRightButtonDblClk", this); + onleftbuttondblclk_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLeftButtonDblClk", this); + onmousemove_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onMouseMove", this); + onenterarea_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onEnterArea", this); + onleavearea_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLeaveArea", this); + onenable_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onEnable", this); + onresize_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onResize", this); + ontargetreached_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onTargetReached", this); + onstartup_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onStartup", this); + onchar_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onChar", this); + onaccelerator_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onAccelerator", this); + onkeydown_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onKeyDown", this); + onkeyup_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onKeyUp", this); + ongetfocus_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onGetFocus", this); + onkillfocus_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onKillFocus", this); + onaction_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onAction", this); + loaded = 1; + } + inited=1; +} + +H_GuiObject::~H_GuiObject() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_GuiObject::getHookedObject() { + if (obj != NULL) return obj; + return H_GUIOBJECT_PARENT::getHookedObject(); +} + +int H_GuiObject::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_GUIOBJECT_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == onsetvisible_id) { hook_onSetVisible(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onleftbuttonup_id) { hook_onLeftButtonUp(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + if (dlfid == onleftbuttondown_id) { hook_onLeftButtonDown(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + if (dlfid == onrightbuttonup_id) { hook_onRightButtonUp(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + if (dlfid == onrightbuttondown_id) { hook_onRightButtonDown(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + if (dlfid == onrightbuttondblclk_id) { hook_onRightButtonDblClk(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + if (dlfid == onleftbuttondblclk_id) { hook_onLeftButtonDblClk(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + if (dlfid == onmousemove_id) { hook_onMouseMove(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + if (dlfid == onenterarea_id) { hook_onEnterArea(); return 1; } + if (dlfid == onleavearea_id) { hook_onLeaveArea(); return 1; } + if (dlfid == onenable_id) { hook_onEnable(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onresize_id) { hook_onResize(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1]), GET_SCRIPT_INT(*params[2]), GET_SCRIPT_INT(*params[3])); return 1; } + if (dlfid == ontargetreached_id) { hook_onTargetReached(); return 1; } + if (dlfid == onstartup_id) { hook_onStartup(); return 1; } + if (dlfid == onchar_id) { hook_onChar(GET_SCRIPT_STRING(*params[0])); return 1; } + if (dlfid == onaccelerator_id) { hook_onAccelerator(GET_SCRIPT_STRING(*params[0])); return 1; } + if (dlfid == onkeydown_id) { hook_onKeyDown(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onkeyup_id) { hook_onKeyUp(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == ongetfocus_id) { hook_onGetFocus(); return 1; } + if (dlfid == onkillfocus_id) { hook_onKillFocus(); return 1; } + if (dlfid == onaction_id) { hook_onAction(GET_SCRIPT_STRING(*params[0]), GET_SCRIPT_STRING(*params[1]), GET_SCRIPT_INT(*params[2]), GET_SCRIPT_INT(*params[3]), GET_SCRIPT_INT(*params[4]), GET_SCRIPT_INT(*params[5]), GET_SCRIPT_OBJECT(*params[6])); return 1; } + return 0; +} + +int H_GuiObject::onsetvisible_id=0; +int H_GuiObject::onleftbuttonup_id=0; +int H_GuiObject::onleftbuttondown_id=0; +int H_GuiObject::onrightbuttonup_id=0; +int H_GuiObject::onrightbuttondown_id=0; +int H_GuiObject::onrightbuttondblclk_id=0; +int H_GuiObject::onleftbuttondblclk_id=0; +int H_GuiObject::onmousemove_id=0; +int H_GuiObject::onenterarea_id=0; +int H_GuiObject::onleavearea_id=0; +int H_GuiObject::onenable_id=0; +int H_GuiObject::onresize_id=0; +int H_GuiObject::ontargetreached_id=0; +int H_GuiObject::onstartup_id=0; +int H_GuiObject::onchar_id=0; +int H_GuiObject::onaccelerator_id=0; +int H_GuiObject::onkeydown_id=0; +int H_GuiObject::onkeyup_id=0; +int H_GuiObject::ongetfocus_id=0; +int H_GuiObject::onkillfocus_id=0; +int H_GuiObject::onaction_id=0; +int H_GuiObject::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_guiobject.h b/Src/Wasabi/api/script/objects/c_script/h_guiobject.h new file mode 100644 index 00000000..d73900bf --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_guiobject.h @@ -0,0 +1,71 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_GUIOBJECT_H +#define __HOOK_GUIOBJECT_H + +#include "h_rootobj.h" + +#define H_GUIOBJECT_PARENT H_RootObject + +class H_GuiObject : public H_GUIOBJECT_PARENT { + +public: + + H_GuiObject(ScriptObject *o); + H_GuiObject(); + virtual ~H_GuiObject(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onSetVisible(int onoff) { } + virtual void hook_onLeftButtonUp(int x, int y) { } + virtual void hook_onLeftButtonDown(int x, int y) { } + virtual void hook_onRightButtonUp(int x, int y) { } + virtual void hook_onRightButtonDown(int x, int y) { } + virtual void hook_onRightButtonDblClk(int x, int y) { } + virtual void hook_onLeftButtonDblClk(int x, int y) { } + virtual void hook_onMouseMove(int x, int y) { } + virtual void hook_onEnterArea() { } + virtual void hook_onLeaveArea() { } + virtual void hook_onEnable(int onoff) { } + virtual void hook_onResize(int x, int y, int w, int h) { } + virtual void hook_onTargetReached() { } + virtual void hook_onStartup() { } + virtual void hook_onChar(const wchar_t *c) { } + virtual void hook_onAccelerator(const wchar_t *accel) { } + virtual void hook_onKeyDown(int vk_code) { } + virtual void hook_onKeyUp(int vk_code) { } + virtual void hook_onGetFocus() { } + virtual void hook_onKillFocus() { } + virtual void hook_onAction(const wchar_t *action, const wchar_t *param, int x, int y, int p1, int p2, ScriptObject *source) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onsetvisible_id; + static int onleftbuttonup_id; + static int onleftbuttondown_id; + static int onrightbuttonup_id; + static int onrightbuttondown_id; + static int onrightbuttondblclk_id; + static int onleftbuttondblclk_id; + static int onmousemove_id; + static int onenterarea_id; + static int onleavearea_id; + static int onenable_id; + static int onresize_id; + static int ontargetreached_id; + static int onstartup_id; + static int onchar_id; + static int onaccelerator_id; + static int onkeydown_id; + static int onkeyup_id; + static int ongetfocus_id; + static int onkillfocus_id; + static int onaction_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_guitree.cpp b/Src/Wasabi/api/script/objects/c_script/h_guitree.cpp new file mode 100644 index 00000000..28363b06 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_guitree.cpp @@ -0,0 +1,80 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include +#include "h_guitree.h" + +H_GuiTree::H_GuiTree(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_GuiTree::H_GuiTree() { + inited = 0; + obj = NULL; +} + +void H_GuiTree::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, guiTreeGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &guiTreeGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + onwantautocontextmenu_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onWantAutoContextMenu", this); + onmousewheelup_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onMouseWheelUp", this); + onmousewheeldown_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onMouseWheelDown", this); + oncontextmenu_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onContextMenu", this); + onchar_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onChar", this); + onitemrecvdrop_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onItemRecvDrop", this); + onlabelchange_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLabelChange", this); + onitemselected_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onItemSelected", this); + onitemdeselected_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onItemDeselected", this); + loaded = 1; + } + inited=1; +} + +H_GuiTree::~H_GuiTree() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_GuiTree::getHookedObject() { + if (obj != NULL) return obj; + return H_GUITREE_PARENT::getHookedObject(); +} + +int H_GuiTree::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_GUITREE_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == onwantautocontextmenu_id) { hook_onWantAutoContextMenu(); return 1; } + if (dlfid == onmousewheelup_id) { hook_onMouseWheelUp(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + if (dlfid == onmousewheeldown_id) { hook_onMouseWheelDown(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + if (dlfid == oncontextmenu_id) { hook_onContextMenu(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + if (dlfid == onchar_id) { hook_onChar(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onitemrecvdrop_id) { hook_onItemRecvDrop(GET_SCRIPT_OBJECT(*params[0])); return 1; } + if (dlfid == onlabelchange_id) { hook_onLabelChange(GET_SCRIPT_OBJECT(*params[0])); return 1; } + if (dlfid == onitemselected_id) { hook_onItemSelected(GET_SCRIPT_OBJECT(*params[0])); return 1; } + if (dlfid == onitemdeselected_id) { hook_onItemDeselected(GET_SCRIPT_OBJECT(*params[0])); return 1; } + return 0; +} + +int H_GuiTree::onwantautocontextmenu_id=0; +int H_GuiTree::onmousewheelup_id=0; +int H_GuiTree::onmousewheeldown_id=0; +int H_GuiTree::oncontextmenu_id=0; +int H_GuiTree::onchar_id=0; +int H_GuiTree::onitemrecvdrop_id=0; +int H_GuiTree::onlabelchange_id=0; +int H_GuiTree::onitemselected_id=0; +int H_GuiTree::onitemdeselected_id=0; +int H_GuiTree::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_guitree.h b/Src/Wasabi/api/script/objects/c_script/h_guitree.h new file mode 100644 index 00000000..c56c28b7 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_guitree.h @@ -0,0 +1,47 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_GUITREE_H +#define __HOOK_GUITREE_H + +#include "h_guiobject.h" + +#define H_GUITREE_PARENT H_GuiObject + +class H_GuiTree : public H_GUITREE_PARENT { + +public: + + H_GuiTree(ScriptObject *o); + H_GuiTree(); + virtual ~H_GuiTree(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onWantAutoContextMenu() { } + virtual void hook_onMouseWheelUp(int clicked, int lines) { } + virtual void hook_onMouseWheelDown(int clicked, int lines) { } + virtual void hook_onContextMenu(int x, int y) { } + virtual void hook_onChar(wchar_t c) { } + virtual void hook_onItemRecvDrop(ScriptObject *item) { } + virtual void hook_onLabelChange(ScriptObject *item) { } + virtual void hook_onItemSelected(ScriptObject *item) { } + virtual void hook_onItemDeselected(ScriptObject *item) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onwantautocontextmenu_id; + static int onmousewheelup_id; + static int onmousewheeldown_id; + static int oncontextmenu_id; + static int onchar_id; + static int onitemrecvdrop_id; + static int onlabelchange_id; + static int onitemselected_id; + static int onitemdeselected_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_layout.cpp b/Src/Wasabi/api/script/objects/c_script/h_layout.cpp new file mode 100644 index 00000000..385cc852 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_layout.cpp @@ -0,0 +1,80 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include +#include "h_layout.h" + +H_Layout::H_Layout(ScriptObject *o) : H_Group(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_Layout::H_Layout() { + inited = 0; + obj = NULL; +} + +void H_Layout::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, layoutGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &layoutGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + ondock_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onDock", this); + onundock_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onUndock", this); + onscale_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onScale", this); + onmove_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onMove", this); + onendmove_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onEndMove", this); + onuserresize_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onUserResize", this); + onmouseenterlayout_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onMouseEnterLayout", this); + onmouseleavelayout_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onMouseLeaveLayout", this); + onsnapadjustchanged_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSnapAdjustChanged", this); + loaded = 1; + } + inited=1; +} + +H_Layout::~H_Layout() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_Layout::getHookedObject() { + if (obj != NULL) return obj; + return H_LAYOUT_PARENT::getHookedObject(); +} + +int H_Layout::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_LAYOUT_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == ondock_id) { hook_onDock(); return 1; } + if (dlfid == onundock_id) { hook_onUndock(); return 1; } + if (dlfid == onscale_id) { hook_onScale(GET_SCRIPT_DOUBLE(*params[0])); return 1; } + if (dlfid == onmove_id) { hook_onMove(); return 1; } + if (dlfid == onendmove_id) { hook_onEndMove(); return 1; } + if (dlfid == onuserresize_id) { hook_onUserResize(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1]), GET_SCRIPT_INT(*params[2]), GET_SCRIPT_INT(*params[3])); return 1; } + if (dlfid == onmouseenterlayout_id) { hook_onMouseEnterLayout(); return 1; } + if (dlfid == onmouseleavelayout_id) { hook_onMouseLeaveLayout(); return 1; } + if (dlfid == onsnapadjustchanged_id) { hook_onSnapAdjustChanged(); return 1; } + return 0; +} + +int H_Layout::ondock_id=0; +int H_Layout::onundock_id=0; +int H_Layout::onscale_id=0; +int H_Layout::onmove_id=0; +int H_Layout::onendmove_id=0; +int H_Layout::onuserresize_id=0; +int H_Layout::onmouseenterlayout_id=0; +int H_Layout::onmouseleavelayout_id=0; +int H_Layout::onsnapadjustchanged_id=0; +int H_Layout::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_layout.h b/Src/Wasabi/api/script/objects/c_script/h_layout.h new file mode 100644 index 00000000..1b19c3e7 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_layout.h @@ -0,0 +1,47 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_LAYOUT_H +#define __HOOK_LAYOUT_H + +#include "h_group.h" + +#define H_LAYOUT_PARENT H_Group + +class H_Layout : public H_LAYOUT_PARENT { + +public: + + H_Layout(ScriptObject *o); + H_Layout(); + virtual ~H_Layout(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onDock() { } + virtual void hook_onUndock() { } + virtual void hook_onScale(double newscalevalue) { } + virtual void hook_onMove() { } + virtual void hook_onEndMove() { } + virtual void hook_onUserResize(int x, int y, int w, int h) { } + virtual void hook_onMouseEnterLayout() { } + virtual void hook_onMouseLeaveLayout() { } + virtual void hook_onSnapAdjustChanged() { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int ondock_id; + static int onundock_id; + static int onscale_id; + static int onmove_id; + static int onendmove_id; + static int onuserresize_id; + static int onmouseenterlayout_id; + static int onmouseleavelayout_id; + static int onsnapadjustchanged_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_menubutton.cpp b/Src/Wasabi/api/script/objects/c_script/h_menubutton.cpp new file mode 100644 index 00000000..bce0f405 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_menubutton.cpp @@ -0,0 +1,62 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include +#include "h_menubutton.h" + +H_MenuButton::H_MenuButton(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_MenuButton::H_MenuButton() { + inited = 0; + obj = NULL; +} + +void H_MenuButton::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, menuButtonGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &menuButtonGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + onopenmenu_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onOpenMenu", this); + onclosemenu_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onCloseMenu", this); + onselectitem_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSelectItem", this); + loaded = 1; + } + inited=1; +} + +H_MenuButton::~H_MenuButton() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_MenuButton::getHookedObject() { + if (obj != NULL) return obj; + return H_MENUBUTTON_PARENT::getHookedObject(); +} + +int H_MenuButton::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_MENUBUTTON_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == onopenmenu_id) { hook_onOpenMenu(); return 1; } + if (dlfid == onclosemenu_id) { hook_onCloseMenu(); return 1; } + if (dlfid == onselectitem_id) { hook_onSelectItem(GET_SCRIPT_STRING(*params[0])); return 1; } + return 0; +} + +int H_MenuButton::onopenmenu_id=0; +int H_MenuButton::onclosemenu_id=0; +int H_MenuButton::onselectitem_id=0; +int H_MenuButton::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_menubutton.h b/Src/Wasabi/api/script/objects/c_script/h_menubutton.h new file mode 100644 index 00000000..c55b4791 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_menubutton.h @@ -0,0 +1,35 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_MENUBUTTON_H +#define __HOOK_MENUBUTTON_H + +#include "h_guiobject.h" + +#define H_MENUBUTTON_PARENT H_GuiObject + +class H_MenuButton : public H_MENUBUTTON_PARENT { + +public: + + H_MenuButton(ScriptObject *o); + H_MenuButton(); + virtual ~H_MenuButton(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onOpenMenu() { } + virtual void hook_onCloseMenu() { } + virtual void hook_onSelectItem(const wchar_t *item) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onopenmenu_id; + static int onclosemenu_id; + static int onselectitem_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_querylist.cpp b/Src/Wasabi/api/script/objects/c_script/h_querylist.cpp new file mode 100644 index 00000000..061f298e --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_querylist.cpp @@ -0,0 +1,54 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include +#include "h_querylist.h" + +H_QueryList::H_QueryList(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_QueryList::H_QueryList() { + inited = 0; + obj = NULL; +} + +void H_QueryList::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, queryListGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &queryListGuid); + if (loaded == 0) { + onresetquery_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onResetQuery", this); + loaded = 1; + } + inited=1; +} + +H_QueryList::~H_QueryList() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_QueryList::getHookedObject() { + if (obj != NULL) return obj; + return H_QUERYLIST_PARENT::getHookedObject(); +} + +int H_QueryList::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_QUERYLIST_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == onresetquery_id) { hook_onResetQuery(); return 1; } + return 0; +} + +int H_QueryList::onresetquery_id=0; +int H_QueryList::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_querylist.h b/Src/Wasabi/api/script/objects/c_script/h_querylist.h new file mode 100644 index 00000000..e95b3015 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_querylist.h @@ -0,0 +1,31 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_QUERYLIST_H +#define __HOOK_QUERYLIST_H + +#include "h_guiobject.h" + +#define H_QUERYLIST_PARENT H_GuiObject + +class H_QueryList : public H_QUERYLIST_PARENT { + +public: + + H_QueryList(ScriptObject *o); + H_QueryList(); + virtual ~H_QueryList(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onResetQuery() { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onresetquery_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_rootobj.cpp b/Src/Wasabi/api/script/objects/c_script/h_rootobj.cpp new file mode 100644 index 00000000..72ccc990 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_rootobj.cpp @@ -0,0 +1,41 @@ +#include + +#include +#include "h_rootobj.h" + +H_RootObject::H_RootObject(ScriptObject *o) { + inited = 0; + me = NULL; + H_hook(o); +} + +H_RootObject::H_RootObject() { + inited = 0; + me = NULL; +} + +void H_RootObject::H_hook(ScriptObject *o) { + ASSERT(!inited); + me = o; + addMonitorObject(o, &rootObjectGuid); + if (count++ == 0) { + onnotify_id = WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onNotify", this); + } + inited=1; +} + +H_RootObject::~H_RootObject() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); + //count--; +} + +int H_RootObject::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (dlfid == onnotify_id) { hook_onNotify(GET_SCRIPT_STRING(*params[0]), GET_SCRIPT_STRING(*params[1]), GET_SCRIPT_INT(*params[2]), GET_SCRIPT_INT(*params[3])); return 1; } + return 0; +} + +int H_RootObject::onnotify_id=0; +int H_RootObject::inited=0; +int H_RootObject::count=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_rootobj.h b/Src/Wasabi/api/script/objects/c_script/h_rootobj.h new file mode 100644 index 00000000..8488f7c7 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_rootobj.h @@ -0,0 +1,30 @@ +#ifndef __HOOK_SCRIPTOBJECT_H +#define __HOOK_SCRIPTOBJECT_H + +#include + +class H_RootObject : public ScriptHookI { + + public: + + H_RootObject(ScriptObject *o); + H_RootObject(); + virtual ~H_RootObject(); + + virtual void H_hook(ScriptObject *o); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + + virtual void hook_onNotify(const wchar_t *s, const wchar_t *t, int u, int v) {} + + virtual ScriptObject *getHookedObject() { return me; } + + private: + + ScriptObject *me; + static int onnotify_id; + static int inited; + static int count; +}; + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/c_script/h_slider.cpp b/Src/Wasabi/api/script/objects/c_script/h_slider.cpp new file mode 100644 index 00000000..bca6dc96 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_slider.cpp @@ -0,0 +1,62 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include +#include "h_slider.h" + +H_Slider::H_Slider(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_Slider::H_Slider() { + inited = 0; + obj = NULL; +} + +void H_Slider::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, sliderGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &sliderGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + onsetposition_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSetPosition", this); + onpostedposition_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onPostedPosition", this); + onsetfinalposition_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSetFinalPosition", this); + loaded = 1; + } + inited=1; +} + +H_Slider::~H_Slider() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_Slider::getHookedObject() { + if (obj != NULL) return obj; + return H_SLIDER_PARENT::getHookedObject(); +} + +int H_Slider::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_SLIDER_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == onsetposition_id) { hook_onSetPosition(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onpostedposition_id) { hook_onPostedPosition(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onsetfinalposition_id) { hook_onSetFinalPosition(GET_SCRIPT_INT(*params[0])); return 1; } + return 0; +} + +int H_Slider::onsetposition_id=0; +int H_Slider::onpostedposition_id=0; +int H_Slider::onsetfinalposition_id=0; +int H_Slider::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_slider.h b/Src/Wasabi/api/script/objects/c_script/h_slider.h new file mode 100644 index 00000000..c7539746 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_slider.h @@ -0,0 +1,35 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_SLIDER_H +#define __HOOK_SLIDER_H + +#include "h_guiobject.h" + +#define H_SLIDER_PARENT H_GuiObject + +class H_Slider : public H_SLIDER_PARENT { + +public: + + H_Slider(ScriptObject *o); + H_Slider(); + virtual ~H_Slider(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onSetPosition(int newpos) { } + virtual void hook_onPostedPosition(int newpos) { } + virtual void hook_onSetFinalPosition(int pos) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onsetposition_id; + static int onpostedposition_id; + static int onsetfinalposition_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_tabsheet.cpp b/Src/Wasabi/api/script/objects/c_script/h_tabsheet.cpp new file mode 100644 index 00000000..7c66f043 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_tabsheet.cpp @@ -0,0 +1,53 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include +#include +#include +#include "h_tabsheet.h" + +H_TabSheet::H_TabSheet(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_TabSheet::H_TabSheet() { + inited = 0; + obj = NULL; +} + +void H_TabSheet::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, tabSheetGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &tabSheetGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = 1; + } + inited=1; +} + +H_TabSheet::~H_TabSheet() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_TabSheet::getHookedObject() { + if (obj != NULL) return obj; + return H_TABSHEET_PARENT::getHookedObject(); +} + +int H_TabSheet::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_TABSHEET_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + return 0; +} + +int H_TabSheet::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_tabsheet.h b/Src/Wasabi/api/script/objects/c_script/h_tabsheet.h new file mode 100644 index 00000000..d68714d5 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_tabsheet.h @@ -0,0 +1,29 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_TABSHEET_H +#define __HOOK_TABSHEET_H + +#include "h_guiobject.h" + +#define H_TABSHEET_PARENT H_GuiObject + +class H_TabSheet : public H_TABSHEET_PARENT { + +public: + + H_TabSheet(ScriptObject *o); + H_TabSheet(); + virtual ~H_TabSheet(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + + private: + + ScriptObject *obj; + int inited; + static int loaded; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_text.cpp b/Src/Wasabi/api/script/objects/c_script/h_text.cpp new file mode 100644 index 00000000..37afc9bf --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_text.cpp @@ -0,0 +1,56 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include +#include "h_text.h" + +H_Text::H_Text(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_Text::H_Text() { + inited = 0; + obj = NULL; +} + +void H_Text::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, textGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &textGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + ontextchanged_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onTextChanged", this); + loaded = 1; + } + inited=1; +} + +H_Text::~H_Text() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_Text::getHookedObject() { + if (obj != NULL) return obj; + return H_TEXT_PARENT::getHookedObject(); +} + +int H_Text::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_TEXT_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == ontextchanged_id) { hook_onTextChanged(GET_SCRIPT_STRING(*params[0])); return 1; } + return 0; +} + +int H_Text::ontextchanged_id=0; +int H_Text::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_text.h b/Src/Wasabi/api/script/objects/c_script/h_text.h new file mode 100644 index 00000000..f91285eb --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_text.h @@ -0,0 +1,31 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_TEXT_H +#define __HOOK_TEXT_H + +#include "h_guiobject.h" + +#define H_TEXT_PARENT H_GuiObject + +class H_Text : public H_TEXT_PARENT { + +public: + + H_Text(ScriptObject *o); + H_Text(); + virtual ~H_Text(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onTextChanged(const wchar_t *newtxt) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int ontextchanged_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_togglebutton.cpp b/Src/Wasabi/api/script/objects/c_script/h_togglebutton.cpp new file mode 100644 index 00000000..a3e64678 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_togglebutton.cpp @@ -0,0 +1,56 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include +#include "h_togglebutton.h" + +H_ToggleButton::H_ToggleButton(ScriptObject *o) : H_Button(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_ToggleButton::H_ToggleButton() { + inited = 0; + obj = NULL; +} + +void H_ToggleButton::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, toggleButtonGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &toggleButtonGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + ontoggle_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onToggle", this); + loaded = 1; + } + inited=1; +} + +H_ToggleButton::~H_ToggleButton() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_ToggleButton::getHookedObject() { + if (obj != NULL) return obj; + return H_TOGGLEBUTTON_PARENT::getHookedObject(); +} + +int H_ToggleButton::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_TOGGLEBUTTON_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == ontoggle_id) { hook_onToggle(GET_SCRIPT_INT(*params[0])); return 1; } + return 0; +} + +int H_ToggleButton::ontoggle_id=0; +int H_ToggleButton::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_togglebutton.h b/Src/Wasabi/api/script/objects/c_script/h_togglebutton.h new file mode 100644 index 00000000..ce76fa35 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_togglebutton.h @@ -0,0 +1,31 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_TOGGLEBUTTON_H +#define __HOOK_TOGGLEBUTTON_H + +#include "h_button.h" + +#define H_TOGGLEBUTTON_PARENT H_Button + +class H_ToggleButton : public H_TOGGLEBUTTON_PARENT { + +public: + + H_ToggleButton(ScriptObject *o); + H_ToggleButton(); + virtual ~H_ToggleButton(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onToggle(int (null)) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int ontoggle_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_treeitem.cpp b/Src/Wasabi/api/script/objects/c_script/h_treeitem.cpp new file mode 100644 index 00000000..1191d0bf --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_treeitem.cpp @@ -0,0 +1,89 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include + +#include +#include "h_treeitem.h" + +H_TreeItem::H_TreeItem(ScriptObject *o) : H_RootObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_TreeItem::H_TreeItem() { + inited = 0; + obj = NULL; +} + +void H_TreeItem::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, treeItemGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &treeItemGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + ontreeadd_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onTreeAdd", this); + ontreeremove_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onTreeRemove", this); + onselect_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSelect", this); + ondeselect_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onDeselect", this); + onleftdoubleclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLeftDoubleClick", this); + onrightdoubleclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onRightDoubleClick", this); + onchar_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onChar", this); + onexpand_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onExpand", this); + oncollapse_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onCollapse", this); + onbeginlabeledit_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onBeginLabelEdit", this); + onendlabeledit_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onEndLabelEdit", this); + oncontextmenu_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onContextMenu", this); + loaded = 1; + } + inited=1; +} + +H_TreeItem::~H_TreeItem() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_TreeItem::getHookedObject() { + if (obj != NULL) return obj; + return H_TREEITEM_PARENT::getHookedObject(); +} + +int H_TreeItem::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_TREEITEM_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == ontreeadd_id) { hook_onTreeAdd(); return 1; } + if (dlfid == ontreeremove_id) { hook_onTreeRemove(); return 1; } + if (dlfid == onselect_id) { hook_onSelect(); return 1; } + if (dlfid == ondeselect_id) { hook_onDeselect(); return 1; } + if (dlfid == onleftdoubleclick_id) { hook_onLeftDoubleClick(); return 1; } + if (dlfid == onrightdoubleclick_id) { hook_onRightDoubleClick(); return 1; } + if (dlfid == onchar_id) { hook_onChar(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onexpand_id) { hook_onExpand(); return 1; } + if (dlfid == oncollapse_id) { hook_onCollapse(); return 1; } + if (dlfid == onbeginlabeledit_id) { hook_onBeginLabelEdit(); return 1; } + if (dlfid == onendlabeledit_id) { hook_onEndLabelEdit(GET_SCRIPT_STRING(*params[0])); return 1; } + if (dlfid == oncontextmenu_id) { hook_onContextMenu(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + return 0; +} + +int H_TreeItem::ontreeadd_id=0; +int H_TreeItem::ontreeremove_id=0; +int H_TreeItem::onselect_id=0; +int H_TreeItem::ondeselect_id=0; +int H_TreeItem::onleftdoubleclick_id=0; +int H_TreeItem::onrightdoubleclick_id=0; +int H_TreeItem::onchar_id=0; +int H_TreeItem::onexpand_id=0; +int H_TreeItem::oncollapse_id=0; +int H_TreeItem::onbeginlabeledit_id=0; +int H_TreeItem::onendlabeledit_id=0; +int H_TreeItem::oncontextmenu_id=0; +int H_TreeItem::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_treeitem.h b/Src/Wasabi/api/script/objects/c_script/h_treeitem.h new file mode 100644 index 00000000..173ce1a0 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_treeitem.h @@ -0,0 +1,53 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_TREEITEM_H +#define __HOOK_TREEITEM_H + +#include "h_rootobj.h" + +#define H_TREEITEM_PARENT H_RootObject + +class H_TreeItem : public H_TREEITEM_PARENT { + +public: + + H_TreeItem(ScriptObject *o); + H_TreeItem(); + virtual ~H_TreeItem(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onTreeAdd() { } + virtual void hook_onTreeRemove() { } + virtual void hook_onSelect() { } + virtual void hook_onDeselect() { } + virtual void hook_onLeftDoubleClick() { } + virtual void hook_onRightDoubleClick() { } + virtual void hook_onChar(wchar_t key) { } + virtual void hook_onExpand() { } + virtual void hook_onCollapse() { } + virtual void hook_onBeginLabelEdit() { } + virtual void hook_onEndLabelEdit(const wchar_t *newlabel) { } + virtual void hook_onContextMenu(int x, int y) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int ontreeadd_id; + static int ontreeremove_id; + static int onselect_id; + static int ondeselect_id; + static int onleftdoubleclick_id; + static int onrightdoubleclick_id; + static int onchar_id; + static int onexpand_id; + static int oncollapse_id; + static int onbeginlabeledit_id; + static int onendlabeledit_id; + static int oncontextmenu_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/scripthook.cpp b/Src/Wasabi/api/script/objects/c_script/scripthook.cpp new file mode 100644 index 00000000..a57ced19 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/scripthook.cpp @@ -0,0 +1,47 @@ +#include + +#include +#include +#include "scripthook.h" + +#define CBCLASS ScriptHookI +START_DISPATCH; + CB(EVENTCALLBACK, eventCallback); +END_DISPATCH; + +ScriptHookI::ScriptHookI() { +} + +ScriptHookI::~ScriptHookI() { + WASABI_API_MAKI->maki_remDlfRef(this); + foreach(controllers) + controllers.getfor()->removeHooks(this); + endfor + +} + + +void ScriptHookI::addMonitorObject(ScriptObject *o, const GUID *hookedclass) { + WASABI_API_MAKI->maki_addDlfClassRef(o->vcpu_getController(), this); + ScriptObjectController *cont = o->vcpu_getController(); + if (hookedclass == NULL) { + cont->addObjectHook(this, o); + } else { + while (cont) { + if (cont->getClassGuid() == *hookedclass) { + cont->addObjectHook(this, o); + break; + } + cont = cont->getAncestorController(); + } + } + if (cont == NULL) // guid not found + return; + controllers.addItem(cont); +} + +void ScriptHookI::addMonitorClass(ScriptObject *o) { + WASABI_API_MAKI->maki_addDlfClassRef(o->vcpu_getController(), this); + o->vcpu_getController()->addClassHook(this); + controllers.addItem(o->vcpu_getController()); +} diff --git a/Src/Wasabi/api/script/objects/c_script/scripthook.h b/Src/Wasabi/api/script/objects/c_script/scripthook.h new file mode 100644 index 00000000..f529ee6f --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/scripthook.h @@ -0,0 +1,49 @@ +#ifndef __SCRIPTHOOK_H +#define __SCRIPTHOOK_H + +#include +#include +#include + + +class ScriptObject; +class ScriptObjectController; + +// ---------------------------------------------------------------------------------------------------------- + +class ScriptHook : public Dispatchable { + protected: + ScriptHook() {}; + + public: + int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + + enum { + EVENTCALLBACK = 100, + }; + +}; + +inline int ScriptHook::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + return _call(EVENTCALLBACK, 0, object, dlfid, params, nparams); +} + +class ScriptHookI : public ScriptHook { + +public: + + ScriptHookI(); + virtual ~ScriptHookI(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams)=0; + + void addMonitorObject(ScriptObject *o, const GUID *hookedclass=NULL); // NULL = all classes of object o + void addMonitorClass(ScriptObject *o); + +protected: + RECVS_DISPATCH; + + PtrList controllers; +}; + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/compoobj.cpp b/Src/Wasabi/api/script/objects/compoobj.cpp new file mode 100644 index 00000000..7b7ba8bb --- /dev/null +++ b/Src/Wasabi/api/script/objects/compoobj.cpp @@ -0,0 +1,361 @@ +#include "precomp.h" +#ifndef _NOSTUDIO + +#include "../../common/std.h" +#include "script.h" +#include "scriptmgr.h" +#include "../../common/script/scriptobj.h" +#include "compoobj.h" +#include "../api.h" +#include "vcpu.h" +#include "../smap.h" +#include "sregion.h" +#include "../skinparse.h" +#include "../compon.h" +#include "../compwnd.h" +#include "../cbmgr.h" +#include "../smap.h" +#include "../../common/wndcb.h" + +#else +#include "compoobj.h" +#endif + +CompoObjScriptController _compoController; +CompoObjScriptController *compoController=&_compoController; + +// -- Functions table ------------------------------------- +function_descriptor_struct CompoObjScriptController::exportedFunction[] = { + {"getGUID", 1, (void*)ComponentObject::script_vcpu_getGUID }, + {"getWac", 0, (void*)ComponentObject::script_vcpu_getWac }, + {"setRegionFromMap", 3, (void*)ComponentObject::script_vcpu_setRegionFromMap }, + {"setRegion", 1, (void*)ComponentObject::script_vcpu_setRegion }, + {"onGetWac", 1, (void*)ComponentObject::script_vcpu_onGetWac }, + {"onGiveUpWac", 1, (void*)ComponentObject::script_vcpu_onGiveUpWac }, + {"setAcceptWac", 1, (void*)ComponentObject::script_vcpu_setAcceptWac }, +}; +// -------------------------------------------------------- + +const char *CompoObjScriptController::getClassName() { + return "Component"; +} + +const wchar_t *CompoObjScriptController::getAncestorClassName() { + return "GuiObject"; +} + +int CompoObjScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *CompoObjScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID CompoObjScriptController::getClassGuid() { + return componentObjectGuid; +} + +ScriptObject *CompoObjScriptController::instantiate() { + ComponentObject *obj = new ComponentObject(); + return obj->getScriptObject(); +} + +void CompoObjScriptController::destroy(ScriptObject *o) { + ComponentObject *obj = static_cast(o->vcpu_getInterface(componentObjectGuid)); + ASSERT(obj != NULL); + delete obj; +} + +void *CompoObjScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for componentobject yet +} + +void CompoObjScriptController::deencapsulate(void *) { +} + + +ComponentObject::ComponentObject() { + getScriptObject()->vcpu_setInterface(componentObjectGuid, (void *)static_cast(this)); + getScriptObject()->vcpu_setClassName("Component"); + getScriptObject()->vcpu_setController(compoController); + deleting = 0; + compwnd = NULL; + noshowcmdbar = 0; + noshowbtnbar = 0; + MEMCPY(&myGUID, &INVALID_GUID, sizeof(GUID)); + MEMCPY(&myCompGuid, &INVALID_GUID, sizeof(GUID)); + my_region_clone = NULL; + ComponentManager::registerComponentObject(this); + autoopen = 0; + autoclose = 0; + accept = 1; + denyDesktopAlpha = 0; + denyTransparency = 0; + noanimrects = 0; +} + +int ComponentObject::setXmlParam(const char *name, const char *value) { + if (COMPONENTOBJECT_PARENT::setXmlParam(name, value)) return 1; + else if (STRCASEEQL(name, "param")) { + GUID *g; + g = SkinParser::getComponentGuid(value); + if (g) + setGUID(*g); + } else if (STRCASEEQL(name, "noshowcmdbar")) { + noshowcmdbar = WTOI(value); + } else if (STRCASEEQL(name, "autoopen")) { + autoopen = WTOI(value); + } else if (STRCASEEQL(name, "autoclose")) { + autoclose = WTOI(value); + } else if (STRCASEEQL(name, "disableanimatedrects")) { + noanimrects = WTOI(value); + } else return 0; + return 1; +} + +ComponentObject::~ComponentObject() { + deleting = 1; + ComponentManager::unregisterComponentObject(this, 1); + delete my_region_clone; +} + +int ComponentObject::onResize() { + COMPONENTOBJECT_PARENT::onResize(); + RECT r = clientRect(); + if (compwnd) { + compwnd->resize(&r); + } + return 1; +} + +int ComponentObject::handleRatio() { + return compwnd ? compwnd->handleRatio() : 0; +} + +void ComponentObject::setGUID(GUID g) { + myGUID = g; +} + +void ComponentObject::setCompGUID(GUID g) { + myCompGuid = g; +} + +GUID ComponentObject::getGUID(void) { + if (!MEMCMP(&myCompGuid, &INVALID_GUID, sizeof(GUID))) + return myGUID; + else + return myCompGuid; +} + +void ComponentObject::script_resetRegion() { + HWND h = ComponentManager::getComponentHWnd(myGUID); + if (h) SetWindowRgn(h, NULL, TRUE); + delete my_region_clone; + my_region_clone = NULL; +} + +void ComponentObject::script_setRegionFromMap(SMap *map, int byte, int inv) { + RECT r={map->getBitmap()->getX(), map->getBitmap()->getY(), map->getBitmap()->getWidth(), map->getBitmap()->getHeight()}; + api_region *reg = new api_region(map->getBitmap(), &r, 0, 0, FALSE, 1, (unsigned char)byte, inv); + if (!reg) { script_resetRegion(); return; } + delete my_region_clone; + my_region_clone = new api_region(); + my_region_clone->add(reg); + delete reg; + HWND h = ComponentManager::getComponentHWnd(myGUID); + if (h) { + api_region *clone = my_region_clone->clone(); + clone->scale(getRenderRatio()); + SetWindowRgn(h, clone->makeWindowRegion(), TRUE); + my_region_clone->disposeClone(clone); + } +} + +void ComponentObject::script_setRegion(SRegion *r) { + api_region *reg = r->getRegion(); + if (!reg) { script_resetRegion(); return; } + delete my_region_clone; + my_region_clone = new api_region(); + my_region_clone->add(reg); + HWND h = ComponentManager::getComponentHWnd(myGUID); + if (h) { + api_region *clone = my_region_clone->clone(); + clone->scale(getRenderRatio()); + SetWindowRgn(h, clone->makeWindowRegion(), TRUE); + my_region_clone->disposeClone(clone); + } +} + +void ComponentObject::onSetVisible(int s) { + COMPONENTOBJECT_PARENT::onSetVisible(s); + if (compwnd) { + compwnd->setVisible(s); + onResize(); + } else { + if (s && autoopen && myGUID != INVALID_GUID && myGUID != GENERIC_GUID) + api->setComponentVisible(myGUID, 1); + } +} + +void ComponentObject::deniedComponentCompWnd(CompWnd *c, GUID g) { + if (!deleting) { + Container *_c = getGuiObject()->guiobject_getParentGroup()->getParentContainer(); + if (_c) _c->resetGUID(); + } + compwnd = c; + compwnd->suppressStatusBar(noshowcmdbar); + + CallbackManager::issueCallback(SysCallback::WINDOW, WndCallback::HIDEWINDOW, reinterpret_cast((int *)&g)); + + onReleaseComponent(); + compwnd = NULL; + denyDesktopAlpha = 0; + denyTransparency = 0; + if (!deleting) getGuiObject()->guiobject_getParentLayout()->onGuiObjectSetVisible(getGuiObject(), 0); +} + +void ComponentObject::grantedComponentCompWnd(CompWnd *c, GUID g) { + Container *_c = getGuiObject()->guiobject_getParentGroup()->getParentContainer(); + if (_c) _c->setGUID(g); // tells the container to change its script_id to id:{guid} + compwnd = c; + compwnd->suppressStatusBar(noshowcmdbar); + + onResize(); + + if (isVisible()) + c->setVisible(1); + + CallbackManager::issueCallback(SysCallback::WINDOW, WndCallback::SHOWWINDOW, reinterpret_cast((int *)&g)); + + onGetComponent(g); +} + +void ComponentObject::onReleaseComponent() { + HWND h = ComponentManager::getComponentHWnd(myGUID); + SetWindowRgn(h, NULL, FALSE); +} + +void ComponentObject::onGetComponent(GUID g) { + HWND h = ComponentManager::getComponentHWnd(myGUID); + if (h) { + if (my_region_clone) { + api_region *clone = my_region_clone->clone(); + clone->scale(getRenderRatio()); + SetWindowRgn(h, clone->makeWindowRegion(), TRUE); + my_region_clone->disposeClone(clone); + } else + SetWindowRgn(h, NULL, FALSE); + } +} + +int ComponentObject::wantGUID(GUID *g) { + if (!accept || !getGuiObject()->guiobject_getParentGroup()) return 0; + Container *_c = getGuiObject()->guiobject_getParentGroup()->getParentContainer(); + if (_c && _c->isDynamic() && compwnd) return 0; + if (!MEMCMP(&myGUID, &GENERIC_GUID, sizeof(GUID))) return 1; + return !MEMCMP(&myGUID, g, sizeof(GUID)); +} + +void ComponentObject::onBeforeGetWac(GUID g, CompWnd *c) { +// if (!Std::isXPOrGreater()) + if (!c->handleDesktopAlpha()) + denyDesktopAlpha = 1; + if (!c->handleTransparency()) + denyTransparency = 1; + getGuiObject()->guiobject_getParentLayout()->onGuiObjectSetVisible(getGuiObject(), 1); + WACObject *wo = SOM::getWACObject(g); + script_vcpu_onGetWac(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_OBJECT(wo ? wo->getScriptObject() : NULL)); +} + +void ComponentObject::onBeforeGiveUpWac(GUID g, CompWnd *c) { + WACObject *wo = SOM::getWACObject(g); + script_vcpu_onGiveUpWac(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_OBJECT(wo ? wo->getScriptObject() : NULL)); +} + +int ComponentObject::getAutoClose() { + return autoclose; +} + +void ComponentObject::setAcceptWac(int a) { + accept = a; +} + +int ComponentObject::handleDesktopAlpha() { + if (denyDesktopAlpha) return 0; + if (!compwnd) return 1; + return 0; +} + +int ComponentObject::handleTransparency() { + if (denyTransparency) return 0; + if (!compwnd) return 1; + return compwnd->handleTransparency(); +} + +int ComponentObject::getPreferences(int what) { + if (compwnd) return compwnd->getPreferences(what); + return COMPONENTOBJECT_PARENT::getPreferences(what); +} + +scriptVar ComponentObject::script_vcpu_getGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + + OLECHAR oguid[256] = {0}; // NONPORTABLE + ComponentObject *co = static_cast(o->vcpu_getInterface(componentObjectGuid)); + if (co) { + static char guid[256]; + StringFromGUID2(((ComponentObject *)o)->myGUID, oguid, 256); + wsprintf(guid, "%$", oguid); + return MAKE_SCRIPT_STRING(guid); + } + return MAKE_SCRIPT_STRING(""); +} + +scriptVar ComponentObject::script_vcpu_getWac(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; ; + ComponentObject *co = static_cast(o->vcpu_getInterface(componentObjectGuid)); + return MAKE_SCRIPT_OBJECT(co ? SOM::getWACObject(co->getGUID())->getScriptObject() : NULL); +} + +scriptVar ComponentObject::script_vcpu_setRegionFromMap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar map, scriptVar byte, scriptVar inv) { + SCRIPT_FUNCTION_INIT; ; + ASSERT(SOM::isNumeric(&byte)); + ASSERT(SOM::isNumeric(&inv)); + ComponentObject *co = static_cast(o->vcpu_getInterface(componentObjectGuid)); + SMap *sm = static_cast(GET_SCRIPT_OBJECT_AS(map, mapGuid)); + co->script_setRegionFromMap(sm, SOM::makeInt(&byte), SOM::makeBoolean(&inv)); + RETURN_SCRIPT_VOID; +} + +scriptVar ComponentObject::script_vcpu_setRegion(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r) { + SCRIPT_FUNCTION_INIT; ; + ComponentObject *co = static_cast(o->vcpu_getInterface(componentObjectGuid)); + SRegion *reg = static_cast(GET_SCRIPT_OBJECT_AS(r, regionGuid)); + if (co) co->script_setRegion(reg); + RETURN_SCRIPT_VOID; +} + +scriptVar ComponentObject::script_vcpu_onGetWac(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar wac) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1(o, compoController, wac); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, wac); +} + +scriptVar ComponentObject::script_vcpu_onGiveUpWac(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar wac) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1(o, compoController, wac); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, wac); +} + +scriptVar ComponentObject::script_vcpu_setAcceptWac(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar on) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&on)); + ComponentObject *co = static_cast(o->vcpu_getInterface(componentObjectGuid)); + if (co) co->setAcceptWac(GET_SCRIPT_BOOLEAN(on)); + RETURN_SCRIPT_VOID; +} + + diff --git a/Src/Wasabi/api/script/objects/compoobj.h b/Src/Wasabi/api/script/objects/compoobj.h new file mode 100644 index 00000000..6e18f84b --- /dev/null +++ b/Src/Wasabi/api/script/objects/compoobj.h @@ -0,0 +1,119 @@ +#ifndef _COMPONENTOBJ_H +#define _COMPONENTOBJ_H + +#include +#include +#include +#include + +class SMap; +class SRegion; +class Container; +class Layout; +class CompWnd; + +// {403ABCC0-6F22-4bd6-8BA4-10C829932547} +static const GUID componentObjectGuid = +{ 0x403abcc0, 0x6f22, 0x4bd6, { 0x8b, 0xa4, 0x10, 0xc8, 0x29, 0x93, 0x25, 0x47 } }; + +#define COMPONENTOBJECT_PARENT GuiObjectWnd + +class CompoObjScriptController : public GuiObjectScriptController { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController() { return guiController; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern CompoObjScriptController *compoController; + + +#ifndef _NOSTUDIO + +#include + +class ComponentObject : public COMPONENTOBJECT_PARENT { +public: + ComponentObject(); + virtual ~ComponentObject(); + + virtual int setXmlParam(const wchar_t *name, const wchar_t *value); + + virtual int onResize(); + virtual void onSetVisible(int s); + virtual int handleRatio(); + + void deniedComponentCompWnd(CompWnd *c, GUID g); + void grantedComponentCompWnd(CompWnd *c, GUID g); + int wantGUID(GUID *g); + + void onReleaseComponent(); + void onGetComponent(GUID g); + + void onBeforeGetWac(GUID g, CompWnd *c); + void onBeforeGiveUpWac(GUID g, CompWnd *c); + + void setGUID(GUID g); + void setCompGUID(GUID g); + GUID getGUID(void); + int getAutoClose(); + void setAcceptWac(int a); + int getAnimatedRects() { return !noanimrects; } + virtual int getPreferences(int what); + + virtual void script_resetRegion(); + virtual void script_setRegionFromMap(SMap *map, int byte, int inv); + virtual void script_setRegion(SRegion *r); + virtual int handleDesktopAlpha(); + virtual int handleTransparency(); + + // VCPU + static scriptVar script_vcpu_getGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getWac(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_onShow(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_onHide(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_onGetWac(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar wac); + static scriptVar script_vcpu_onGiveUpWac(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar wac); + static scriptVar script_vcpu_setRegionFromMap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar map, scriptVar byte, scriptVar inv); + static scriptVar script_vcpu_setRegion(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r); + static scriptVar script_vcpu_setAcceptWac(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar on); + // End VCPU + +private: + GUID myGUID; + GUID myCompGuid; + + int deleting; + + CompWnd *compwnd; + int noshowcmdbar; + int noshowbtnbar; + + api_region *my_region_clone; + int autoopen, autoclose; + int accept; + int denyDesktopAlpha; + int denyTransparency; + int noanimrects; + +#else +class ComponentObject : public COMPONENTOBJECT_SCRIPTPARENT { +#endif + +}; + + +#endif diff --git a/Src/Wasabi/api/script/objects/core/coreadminobj.cpp b/Src/Wasabi/api/script/objects/core/coreadminobj.cpp new file mode 100644 index 00000000..505fa2e8 --- /dev/null +++ b/Src/Wasabi/api/script/objects/core/coreadminobj.cpp @@ -0,0 +1,184 @@ +#include + +#include +#include +#include + +static CoreAdminScriptObjectController _coreAdminController; +ScriptObjectController *coreAdminController = &_coreAdminController; + +// Table of exported functions and events +// "function name", n. params, function_pointer +function_descriptor_struct CoreAdminScriptObjectController::exportedFunction[] = { + {L"getNamedCore", 1, (void*)coreadmin_getNamedCore}, + {L"newNamedCore", 1, (void*)coreadmin_newNamedCore}, + {L"freeCore", 1, (void*)coreadmin_freeCore}, + {L"freeCoreByName", 1, (void*)coreadmin_freeCoreByName}, +}; + +int CoreAdminScriptObjectController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +ScriptObject *CoreAdminScriptObjectController::instantiate() { + ScriptCoreAdminObject *scao = new ScriptCoreAdminObject; + ASSERT(scao != NULL); + return scao->getScriptObject(); +} + +void CoreAdminScriptObjectController::destroy(ScriptObject *o) { + ScriptCoreAdminObject *scao = static_cast(o->vcpu_getInterface(COREADMIN_SCRIPTOBJECT_GUID)); + ASSERT(scao != NULL); + delete scao; +} + +void *CoreAdminScriptObjectController::encapsulate(ScriptObject *o) { + return NULL; +} + +void CoreAdminScriptObjectController::deencapsulate(void *o) { +} + +scriptVar CoreAdminScriptObjectController::coreadmin_getNamedCore(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name) +{ + SCRIPT_FUNCTION_INIT + ScriptCoreAdminObject *scao = static_cast(o->vcpu_getInterface(COREADMIN_SCRIPTOBJECT_GUID)); + if (scao) { + const wchar_t *cname = GET_SCRIPT_STRING(name); + if (cname) { +#ifndef FAKE_SCRIPTCORE + // Get the token for the requested core. + CoreToken core = scao->getNamedCore(cname); + if (core == -1) { + RETURN_SCRIPT_VOID; + } +#endif + // Make a new Core scriptobj to point to the requested core. + CoreScriptObjectController *controller = static_cast(coreController); +#ifndef FAKE_SCRIPTCORE + ScriptObject *coreobj = controller->instantiate(core); +#else + ScriptObject *coreobj = controller->instantiate(NULL); +#endif + return MAKE_SCRIPT_OBJECT(coreobj); + } + } + RETURN_SCRIPT_NULL; +} + +scriptVar CoreAdminScriptObjectController::coreadmin_newNamedCore(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name) { + SCRIPT_FUNCTION_INIT + ScriptCoreAdminObject *scao = static_cast(o->vcpu_getInterface(COREADMIN_SCRIPTOBJECT_GUID)); + if (scao) { + const wchar_t *cname = GET_SCRIPT_STRING(name); + if (cname) { + // Get the token for the created core. + /*CoreToken core = */scao->newNamedCore(cname); + // Make a new Core scriptobj to point to the created core. + CoreScriptObjectController *controller = static_cast(coreController); +#ifndef FAKE_SCRIPTCORE + ScriptObject *coreobj = controller->instantiate(core); + // Then get the object back and bind a sequencer and stuff to it. Like we just said "new Core" + ScriptCoreObject *sco = static_cast(coreobj->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + sco->initAsCreated(); + } +#else + ScriptObject *coreobj = controller->instantiate(NULL); +#endif + return MAKE_SCRIPT_OBJECT(coreobj); + } + } + RETURN_SCRIPT_VOID; +} + +scriptVar CoreAdminScriptObjectController::coreadmin_freeCore(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar core) { + SCRIPT_FUNCTION_INIT + ScriptCoreAdminObject *scao = static_cast(o->vcpu_getInterface(COREADMIN_SCRIPTOBJECT_GUID)); + if (scao) { + // Pull the ScriptCoreObject from the scriptVar + ScriptObject *coreobj = GET_SCRIPT_OBJECT(core); + if (coreobj) { + ScriptCoreObject *sco = static_cast(coreobj->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { +#ifndef FAKE_SCRIPTCORE + scao->freeCore(sco->core_handle); +#endif + return MAKE_SCRIPT_INT(1); + } + } + } + return MAKE_SCRIPT_INT(0); +} + +scriptVar CoreAdminScriptObjectController::coreadmin_freeCoreByName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name) { + SCRIPT_FUNCTION_INIT + ScriptCoreAdminObject *scao = static_cast(o->vcpu_getInterface(COREADMIN_SCRIPTOBJECT_GUID)); + if (scao) { + const wchar_t *cname = GET_SCRIPT_STRING(name); + if (cname) { + // Try to remove it. + int retval = scao->freeCoreByName(cname); + return MAKE_SCRIPT_INT(retval); + } + } + return MAKE_SCRIPT_INT(0); +} + + +// ----------------------------------------------------------------------------------------------------- + +ScriptCoreAdminObject::ScriptCoreAdminObject() { + getScriptObject()->vcpu_setClassName(L"CoreAdmin"); + getScriptObject()->vcpu_setController(coreAdminController); + getScriptObject()->vcpu_setInterface(COREADMIN_SCRIPTOBJECT_GUID, static_cast(this)); + +#ifndef FAKE_SCRIPTCORE + waServiceFactory *s = api->service_enumService(WaSvc::COREADMIN,0); + ASSERTPR(s,"Core Admin must be present to use ScriptCore!"); + admin = castService(s); +#endif +} + +ScriptCoreAdminObject::~ScriptCoreAdminObject() { +#ifndef FAKE_SCRIPTCORE + api->service_release(admin); + admin = NULL; +#endif +} + +CoreToken ScriptCoreAdminObject::getNamedCore(const wchar_t *name) { +#ifndef FAKE_SCRIPTCORE + return admin->nameToToken(name); +#else + return 0; +#endif +} + +CoreToken ScriptCoreAdminObject::newNamedCore(const wchar_t *name) { +#ifndef FAKE_SCRIPTCORE + return admin->createCore(name); +#else + return 0; +#endif +} + +int ScriptCoreAdminObject::freeCore(CoreToken core) { +#ifndef FAKE_SCRIPTCORE + if (core == 0) return 0; // don't touch the main core. + return admin->freeCoreByToken(core); +#else + return 0; +#endif +} + +int ScriptCoreAdminObject::freeCoreByName(const wchar_t *name) { +#ifndef FAKE_SCRIPTCORE + CoreToken core = admin->nameToToken(name); + if (core == 0) return 0; // don't touch the main core. + return admin->freeCoreByToken(core); +#else + return 0; +#endif +} + diff --git a/Src/Wasabi/api/script/objects/core/coreadminobj.h b/Src/Wasabi/api/script/objects/core/coreadminobj.h new file mode 100644 index 00000000..c0322edf --- /dev/null +++ b/Src/Wasabi/api/script/objects/core/coreadminobj.h @@ -0,0 +1,67 @@ +#ifndef __COREADMINOBJ_H +#define __COREADMINOBJ_H + +#include +#include +#include +#include + +#ifdef GEN_FF +#ifndef FAKE_SCRIPTCORE +#define FAKE_SCRIPTCORE +#endif +#endif + +class svc_coreAdmin; + +// {F857BECA-8E19-41f1-973E-097E39649F03} +static const GUID COREADMIN_SCRIPTOBJECT_GUID = + { 0xf857beca, 0x8e19, 0x41f1, { 0x97, 0x3e, 0x9, 0x7e, 0x39, 0x64, 0x9f, 0x3 } }; + +extern ScriptObjectController *coreAdminController; + +// ----------------------------------------------------------------------------------------------------- +class ScriptCoreAdminObject : public RootObjectInstance +{ +public: + ScriptCoreAdminObject(); + virtual ~ScriptCoreAdminObject(); + + CoreToken getNamedCore(const wchar_t *name); + CoreToken newNamedCore(const wchar_t *name); + int freeCore(CoreToken core); + int freeCoreByName(const wchar_t *name); + +private: +#ifndef FAKE_SCRIPTCORE + svc_coreAdmin *admin; +#endif +}; + +// ----------------------------------------------------------------------------------------------------- +class CoreAdminScriptObjectController : public ScriptObjectControllerI +{ +public: + virtual const wchar_t *getClassName() { return L"CoreAdmin"; } + virtual const wchar_t *getAncestorClassName() { return L"Object"; } + virtual ScriptObjectController *getAncestorController() { return WASABI_API_MAKI->maki_getController(rootObjectGuid); } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions() { return exportedFunction; } + virtual GUID getClassGuid() { return COREADMIN_SCRIPTOBJECT_GUID; } + virtual int getInstantiable() { return 0; } + virtual int getReferenceable() { return 0; } + virtual ScriptObject *instantiate(); + virtual void *encapsulate(ScriptObject *o); + virtual void destroy(ScriptObject *o); + virtual void deencapsulate(void *o); + + static scriptVar coreadmin_getNamedCore(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name); + static scriptVar coreadmin_newNamedCore(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name); + static scriptVar coreadmin_freeCore(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar core); + static scriptVar coreadmin_freeCoreByName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name); + +private: + static function_descriptor_struct exportedFunction[]; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/core/coreobj.cpp b/Src/Wasabi/api/script/objects/core/coreobj.cpp new file mode 100644 index 00000000..a3b47bc6 --- /dev/null +++ b/Src/Wasabi/api/script/objects/core/coreobj.cpp @@ -0,0 +1,1151 @@ +#include + +#include +#include +#include + +static CoreScriptObjectController _coreController; +ScriptObjectController *coreController = &_coreController; + +#define TRICK_VOLUME 0 + +// Table of exported functions and events +// "function name", n. params, function_pointer +function_descriptor_struct CoreScriptObjectController::exportedFunction[] = { + {L"playFile", 1, (void*)ScriptCoreObject::maki_playFile}, + {L"stop", 0, (void*)ScriptCoreObject::maki_stop}, + {L"setVolume", 1, (void*)ScriptCoreObject::maki_setVolume}, +// {L"onStop", 0, (void*)ScriptCoreObject::maki_onStop}, + {L"getStatus", 0, (void*)ScriptCoreObject::maki_getStatus}, +// {L"getStuff", 0, (void*)ScriptCoreObject::maki_getStuff}, + + // Here come the new ones + {L"onStarted", 0, (void*)ScriptCoreObject::maki_onStarted}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + {L"onStopped", 0, (void*)ScriptCoreObject::maki_onStopped}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + {L"onPaused", 0, (void*)ScriptCoreObject::maki_onPaused}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + {L"onUnpaused", 0, (void*)ScriptCoreObject::maki_onUnpaused}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + {L"onSeeked", 1, (void*)ScriptCoreObject::maki_onSeeked}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newpos); + {L"onVolumeChange", 1, (void*)ScriptCoreObject::maki_onVolumeChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newvol); + {L"onPanChange", 1, (void*)ScriptCoreObject::maki_onPanChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newpan); + {L"onEQStatusChange", 1, (void*)ScriptCoreObject::maki_onEQStatusChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval); + {L"onEQPreampChange", 1, (void*)ScriptCoreObject::maki_onEQPreampChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval); + {L"onEQBandChange", 2, (void*)ScriptCoreObject::maki_onEQBandChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ band, scriptVar /*int*/ newval); + {L"onEQFreqChange", 1, (void*)ScriptCoreObject::maki_onEQFreqChange}, + {L"onEQAutoChange", 1, (void*)ScriptCoreObject::maki_onEQAutoChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval); + {L"onCoreStatusMsg", 1, (void*)ScriptCoreObject::maki_onStatusMsg}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text); + {L"onWarningMsg", 1, (void*)ScriptCoreObject::maki_onWarningMsg}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text); + {L"onErrorMsg", 1, (void*)ScriptCoreObject::maki_onErrorMsg}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text); + {L"onTitleChange", 1, (void*)ScriptCoreObject::maki_onTitleChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ title); + {L"onTitle2Change", 1, (void*)ScriptCoreObject::maki_onTitle2Change}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ title2); + {L"onInfoChange", 1, (void*)ScriptCoreObject::maki_onInfoChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ info); + {L"onUrlChange", 1, (void*)ScriptCoreObject::maki_onUrlChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ url); + {L"onLengthChange", 1, (void*)ScriptCoreObject::maki_onLengthChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newlength); + {L"onNextFile", 0, (void*)ScriptCoreObject::maki_onNextFile}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + {L"onNeedNextFile", 1, (void*)ScriptCoreObject::maki_onNeedNextFile}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ fileid); + {L"onSetNextFile", 1, (void*)ScriptCoreObject::maki_onSetNextFile}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ playstring); + {L"onErrorOccured", 2, (void*)ScriptCoreObject::maki_onErrorOccured}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ severity, scriptVar /*String*/ text); + {L"onAbortCurrentSong", 0, (void*)ScriptCoreObject::maki_onAbortCurrentSong}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + {L"onEndOfDecode", 0, (void*)ScriptCoreObject::maki_onEndOfDecode}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + {L"onFileComplete", 1, (void*)ScriptCoreObject::maki_onFileComplete}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ playstring); + {L"onConvertersChainRebuilt", 0, (void*)ScriptCoreObject::maki_onConvertersChainRebuilt}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + {L"onMediaFamilyChange", 1, (void*)ScriptCoreObject::maki_onMediaFamilyChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ newfamily); + + {L"setNextFile", 1, (void*)ScriptCoreObject::maki_setNextFile}, // (scriptVar /*String*/ playstr); +// {L"getStatus", 0, (void*)ScriptCoreObject::maki_getStatus}, // (); + {L"getCurrent", 0, (void*)ScriptCoreObject::maki_getCurrent}, // (); + {L"getCurPlaybackNumber", 0, (void*)ScriptCoreObject::maki_getCurPlaybackNumber}, // (); + {L"getNumTracks", 0, (void*)ScriptCoreObject::maki_getNumTracks}, // (); + {L"getPosition", 0, (void*)ScriptCoreObject::maki_getPosition}, // (); + {L"getWritePosition", 0, (void*)ScriptCoreObject::maki_getWritePosition}, // (); + {L"setPosition", 1, (void*)ScriptCoreObject::maki_setPosition}, // (scriptVar /*int*/ ms); + {L"getLength", 0, (void*)ScriptCoreObject::maki_getLength}, // (); + {L"getVolume", 0, (void*)ScriptCoreObject::maki_getVolume}, // (); +// {L"setVolume", 1, (void*)ScriptCoreObject::maki_setVolume}, // (scriptVar /*int*/ vol); + {L"getPan", 0, (void*)ScriptCoreObject::maki_getPan}, // (); + {L"setPan", 1, (void*)ScriptCoreObject::maki_setPan}, // (scriptVar /*int*/ bal); + {L"setMute", 1, (void*)ScriptCoreObject::maki_setMute}, // (scriptVar /*int*/ mute); + {L"getMute", 0, (void*)ScriptCoreObject::maki_getMute}, // (); + {L"getLeftVuMeter", 0, (void*)ScriptCoreObject::maki_getLeftVuMeter}, // (); + {L"getRightVuMeter", 0, (void*)ScriptCoreObject::maki_getRightVuMeter}, // (); + {L"userButton", 1, (void*)ScriptCoreObject::maki_userButton}, // (scriptVar /*int*/ button); + {L"getEqStatus", 0, (void*)ScriptCoreObject::maki_getEqStatus}, // (); + {L"setEqStatus", 1, (void*)ScriptCoreObject::maki_setEqStatus}, // (scriptVar /*int*/ enable); + {L"getEqPreamp", 0, (void*)ScriptCoreObject::maki_getEqPreamp}, // (); + {L"setEqPreamp", 1, (void*)ScriptCoreObject::maki_setEqPreamp}, // (scriptVar /*int*/ pre); + {L"getEqBand", 1, (void*)ScriptCoreObject::maki_getEqBand}, // (scriptVar /*int*/ band); + {L"setEqBand", 2, (void*)ScriptCoreObject::maki_setEqBand}, // (scriptVar /*int*/ band, scriptVar /*int*/ val); + {L"getEqAuto", 0, (void*)ScriptCoreObject::maki_getEqAuto}, // (); + {L"setEqAuto", 1, (void*)ScriptCoreObject::maki_setEqAuto}, // (scriptVar /*int*/ enable); + {L"setCustomMsg", 1, (void*)ScriptCoreObject::maki_setCustomMsg}, // (scriptVar /*String*/ text); + {L"setPriority", 1, (void*)ScriptCoreObject::maki_setPriority}, // (scriptVar /*int*/ priority); + {L"getPriority", 0, (void*)ScriptCoreObject::maki_getPriority}, // (); + {L"rebuildConvertersChain", 0, (void*)ScriptCoreObject::maki_rebuildConvertersChain}, // (); + +}; + +int CoreScriptObjectController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +// Only called by us and our friend the admin. +ScriptObject *CoreScriptObjectController::instantiate(CoreToken token) { + ScriptCoreObject *gvo = new ScriptCoreObject(token); + ASSERT(gvo != NULL); + ScriptCoreObject::objects.addItem(gvo); + return gvo->getScriptObject(); +} + +ScriptObject *CoreScriptObjectController::instantiate() { + // magic value to make a new one. + return instantiate(0x80000000); +} + +void CoreScriptObjectController::destroy(ScriptObject *o) { + ScriptCoreObject *gvo = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + ASSERT(gvo != NULL); + ScriptCoreObject::objects.removeItem(gvo); + delete gvo; +} + +void *CoreScriptObjectController::encapsulate(ScriptObject *o) { + return NULL; +} + +void CoreScriptObjectController::deencapsulate(void *o) { +} + +// ----------------------------------------------------------------------------------------------------- + +ScriptCoreObject::ScriptCoreObject(CoreToken token) { + getScriptObject()->vcpu_setClassName(L"Core"); + getScriptObject()->vcpu_setController(coreController); + getScriptObject()->vcpu_setInterface(CORE_SCRIPTOBJECT_GUID, static_cast(this)); +#ifndef FAKE_SCRIPTCORE + curvol = -1; + if (token == 0x80000000) { + // If we create it new for the script, bind a sequencer and set the volume + core_handle = api->core_create(); + initAsCreated(); + } else { + // If the ScriptCoreAdminObject caused this object to be created, + // it will worry about calling initAsCreated() -- otherwise we don't + // bind ourselves as a sequencer to the core. + core_handle = token; + registered_sequencer = 0; + } + + waServiceFactory *s = api->service_enumService(WaSvc::COREADMIN,0); + ASSERTPR(s,"Core Admin must be present to use ScriptCore!"); + svc = castService(s); + if (svc) { + svc->addCallback(core_handle, this); + } +#endif +} + +ScriptCoreObject::~ScriptCoreObject() { +#ifndef FAKE_SCRIPTCORE + if (registered_sequencer) { + // don't remove a sequencer if we didn't add one + api->core_deregisterSequencer(core_handle, this); + } + api->core_delCallback(0, this); +#endif +} + +#ifndef FAKE_SCRIPTCORE +void ScriptCoreObject::initAsCreated() { + api->core_registerSequencer(core_handle, this); +#if TRICK_VOLUME + api->core_setVolume(core_handle, api->core_getVolume(0)); + setVolume(255); +#endif + registered_sequencer = 1; +} +#endif + +/*int ScriptCoreObject::corecb_onStopped() { + maki_onStop(SCRIPT_CALL, getScriptObject()); + return 0; +} + +int ScriptCoreObject::corecb_onEndOfDecode() { + maki_onStop(SCRIPT_CALL, getScriptObject()); + return 0; +}*/ + +int ScriptCoreObject::getStatus() { +#ifndef FAKE_SCRIPTCORE + return api->core_getStatus(core_handle); +#else + return 0; +#endif +} + +void ScriptCoreObject::playFile(const wchar_t *file) { +#ifndef FAKE_SCRIPTCORE + if (registered_sequencer) { + filetoplay = file; + } else { + String playstring = "FILE:"; + playstring += file; + api->core_setNextFile(core_handle, playstring); + } + api->core_userButton(core_handle, UserButton::PLAY); +#endif +} + +#ifndef FAKE_SCRIPTCORE +const char *ScriptCoreObject::enumItem(int pos) { + return filetoplay; +} +#endif + +void ScriptCoreObject::stop() { +#ifndef FAKE_SCRIPTCORE + filetoplay = ""; + api->core_userButton(core_handle, UserButton::STOP); +#endif +} + +void ScriptCoreObject::setVolume(int v) { +#ifndef FAKE_SCRIPTCORE +#if TRICK_VOLUME + // if we're not the main core.... + if (core_handle) { + // set this core's volume as a percentage of the main core volume. + if (v == -1) v = curvol; + curvol = v; + int mainvolume = api->core_getVolume(0); + v = (int)( ((float)mainvolume * (float)v) / 256.0 ); + if ((unsigned)v == api->core_getVolume(core_handle)) return; + api->core_setVolume(core_handle, MIN(MAX(0, v), 255)); + } else { + // if we are the main core, don't cause recursion. + if ((v > 0) && (v != curvol)) { + curvol = v; + api->core_setVolume(core_handle, v); + } + } +#else + api->core_setVolume(core_handle, v); +#endif +#endif +} + +/* + Moved to be with all his friends. + +int ScriptCoreObject::corecb_onVolumeChange(int newvol) { + foreach(objects) + objects.getfor()->setVolume(-1); + endfor; + return 0; +} +*/ + +/*scriptVar ScriptCoreObject::maki_onStop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS0(o, coreController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +}*/ + +scriptVar ScriptCoreObject::maki_playFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar f) { + SCRIPT_FUNCTION_INIT + ScriptCoreObject *gvo = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (gvo) + gvo->playFile(GET_SCRIPT_STRING(f)); + RETURN_SCRIPT_VOID; +} + +scriptVar ScriptCoreObject::maki_stop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + ScriptCoreObject *gvo = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (gvo) + gvo->stop(); + RETURN_SCRIPT_VOID; +} + +/* +scriptVar ScriptCoreObject::maki_setVolume(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) { + SCRIPT_FUNCTION_INIT + ScriptCoreObject *gvo = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (gvo) gvo->setVolume(GET_SCRIPT_INT(v)); + RETURN_SCRIPT_VOID; +} + +scriptVar ScriptCoreObject::maki_getStatus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + ScriptCoreObject *gvo = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (gvo) return MAKE_SCRIPT_INT(gvo->getStatus()); + RETURN_SCRIPT_ZERO; +} +*/ + +PtrList ScriptCoreObject::objects; + + +int ScriptCoreObject::corecb_onStarted() { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onStarted(SCRIPT_CALL, getScriptObject()); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onStopped() { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onStopped(SCRIPT_CALL, getScriptObject()); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onPaused() { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onPaused(SCRIPT_CALL, getScriptObject()); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onUnpaused() { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onUnpaused(SCRIPT_CALL, getScriptObject()); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onSeeked(int newpos) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onSeeked(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(newpos)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onVolumeChange(int newvol) { +#ifndef FAKE_SCRIPTCORE +#if TRICK_VOLUME + foreach(objects) + objects.getfor()->setVolume(-1); + endfor; +#endif + scriptVar svInt = maki_onVolumeChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(newvol)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onPanChange(int newpan) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onPanChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(newpan)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onEQStatusChange(int newval) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onEQStatusChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(newval)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onEQPreampChange(int newval) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onEQPreampChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(newval)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onEQBandChange(int band, int newval) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onEQBandChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(band), MAKE_SCRIPT_INT(newval)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onEQFreqChange(int newval) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onEQFreqChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(newval)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onEQAutoChange(int newval) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onEQAutoChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(newval)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onStatusMsg(const wchar_t *text) +{ +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onStatusMsg(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(text)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onWarningMsg(const wchar_t *text) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onWarningMsg(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(text)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onErrorMsg(const wchar_t *text) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onErrorMsg(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(text)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onTitleChange(const wchar_t *title) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onTitleChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(title)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onTitle2Change(const wchar_t *title2) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onTitle2Change(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(title2)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onInfoChange(const wchar_t *info) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onInfoChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(info)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onUrlChange(const wchar_t *url) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onUrlChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(url)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onLengthChange(int newlength) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onLengthChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(newlength)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onNextFile() { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onNextFile(SCRIPT_CALL, getScriptObject()); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onNeedNextFile(int fileid) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onNeedNextFile(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(fileid)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onSetNextFile(const wchar_t *playstring) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onSetNextFile(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(playstring)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onErrorOccured(int severity, const wchar_t *text) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onErrorOccured(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(severity), MAKE_SCRIPT_STRING(text)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onAbortCurrentSong() { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onAbortCurrentSong(SCRIPT_CALL, getScriptObject()); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onEndOfDecode() { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onEndOfDecode(SCRIPT_CALL, getScriptObject()); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onFileComplete(const wchar_t *playstring) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onFileComplete(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(playstring)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onConvertersChainRebuilt() { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onConvertersChainRebuilt(SCRIPT_CALL, getScriptObject()); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onMediaFamilyChange(const wchar_t *newfamily) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onMediaFamilyChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(newfamily)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + + +scriptVar /*int*/ ScriptCoreObject::maki_onStarted(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS0(o, coreController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onStopped(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS0(o, coreController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onPaused(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS0(o, coreController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onUnpaused(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS0(o, coreController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onSeeked(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newpos) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, newpos); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, newpos); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onVolumeChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newvol) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, newvol); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, newvol); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onPanChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newpan) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, newpan); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, newpan); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onEQStatusChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, newval); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, newval); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onEQPreampChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, newval); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, newval); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onEQBandChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ band, scriptVar /*int*/ newval) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS2(o, coreController, band, newval); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, band, newval); +} + + +scriptVar /*int*/ ScriptCoreObject::maki_onEQFreqChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval) +{ + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, newval); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, newval); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onEQAutoChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, newval); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, newval); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onStatusMsg(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, text); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, text); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onWarningMsg(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, text); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, text); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onErrorMsg(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, text); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, text); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onTitleChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ title) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, title); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, title); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onTitle2Change(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ title2) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, title2); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, title2); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onInfoChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ info) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, info); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, info); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onUrlChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ url) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, url); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, url); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onLengthChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newlength) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, newlength); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, newlength); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onNextFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS0(o, coreController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onNeedNextFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ fileid) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, fileid); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, fileid); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onSetNextFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ playstring) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, playstring); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, playstring); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onErrorOccured(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ severity, scriptVar /*String*/ text) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS2(o, coreController, severity, text); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, severity, text); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onAbortCurrentSong(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS0(o, coreController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onEndOfDecode(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS0(o, coreController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onFileComplete(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ playstring) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, playstring); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, playstring); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onConvertersChainRebuilt(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS0(o, coreController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onMediaFamilyChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ newfamily) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, newfamily); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, newfamily); +} + + +scriptVar /*int*/ ScriptCoreObject::maki_setNextFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ playstr) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->setNextFile(sco->core_handle, GET_SCRIPT_STRING(playstr))); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getStatus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getStatus(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*String*/ ScriptCoreObject::maki_getCurrent(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_STRING(sco->svc->getCurrent(sco->core_handle)); + } +#endif + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar /*int*/ ScriptCoreObject::maki_getCurPlaybackNumber(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getCurPlaybackNumber(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getNumTracks(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getNumTracks(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getPosition(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getPosition(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getWritePosition(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getWritePosition(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*int*/ ScriptCoreObject::maki_setPosition(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ ms) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->setPosition(sco->core_handle, GET_SCRIPT_INT(ms))); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getLength(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getLength(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getVolume(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getVolume(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*void*/ ScriptCoreObject::maki_setVolume(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ vol) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->setVolume(sco->core_handle, GET_SCRIPT_INT(vol)); + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getPan(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getPan(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*void*/ ScriptCoreObject::maki_setPan(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ bal) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->setPan(sco->core_handle, GET_SCRIPT_INT(bal)); + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar /*void*/ ScriptCoreObject::maki_setMute(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ mute) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->setMute(sco->core_handle, GET_SCRIPT_INT(mute)); + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getMute(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getMute(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getLeftVuMeter(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getLeftVuMeter(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getRightVuMeter(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getRightVuMeter(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*void*/ ScriptCoreObject::maki_userButton(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ button) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->userButton(sco->core_handle, GET_SCRIPT_INT(button)); + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getEqStatus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getEqStatus(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*void*/ ScriptCoreObject::maki_setEqStatus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ enable) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->setEqStatus(sco->core_handle, GET_SCRIPT_INT(enable)); + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getEqPreamp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getEqPreamp(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*void*/ ScriptCoreObject::maki_setEqPreamp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ pre) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->setEqPreamp(sco->core_handle, GET_SCRIPT_INT(pre)); + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getEqBand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ band) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getEqBand(sco->core_handle, GET_SCRIPT_INT(band))); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*void*/ ScriptCoreObject::maki_setEqBand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ band, scriptVar /*int*/ val) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->setEqBand(sco->core_handle, GET_SCRIPT_INT(band), GET_SCRIPT_INT(val)); + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getEqAuto(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getEqAuto(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*void*/ ScriptCoreObject::maki_setEqAuto(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ enable) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->setEqAuto(sco->core_handle, GET_SCRIPT_INT(enable)); + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar /*void*/ ScriptCoreObject::maki_setCustomMsg(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->setCustomMsg(sco->core_handle, GET_SCRIPT_STRING(text)); + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar /*void*/ ScriptCoreObject::maki_setPriority(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ priority) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->setPriority(sco->core_handle, GET_SCRIPT_INT(priority)); + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getPriority(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getPriority(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*void*/ ScriptCoreObject::maki_rebuildConvertersChain(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->rebuildConvertersChain(sco->core_handle); + } +#endif + RETURN_SCRIPT_VOID; +} + diff --git a/Src/Wasabi/api/script/objects/core/coreobj.h b/Src/Wasabi/api/script/objects/core/coreobj.h new file mode 100644 index 00000000..75b77346 --- /dev/null +++ b/Src/Wasabi/api/script/objects/core/coreobj.h @@ -0,0 +1,192 @@ +#ifndef __CONOBJ_H +#define __CONOBJ_H + +#include +#include +#include +#include +#include +#ifdef GEN_FF +#ifndef FAKE_SCRIPTCORE +#define FAKE_SCRIPTCORE +#endif +#endif + +// {2825A91B-D488-4245-AAF1-7059CF88437B} +static const GUID CORE_SCRIPTOBJECT_GUID = +{ 0x2825a91b, 0xd488, 0x4245, { 0xaa, 0xf1, 0x70, 0x59, 0xcf, 0x88, 0x43, 0x7b } }; + +extern ScriptObjectController *coreController; +class PlayItem; +class CoreAdminScriptObjectController; +class svc_coreAdmin; + +// ----------------------------------------------------------------------------------------------------- +class ScriptCoreObject : public RootObjectInstance +#ifndef FAKE_SCRIPTCORE +, public ListSequencer, public CoreCallbackI/*, public CoreCallbackI*/ +#endif +{ + friend class CoreAdminScriptObjectController; + public: + + ScriptCoreObject(CoreToken token = 0x80000000); + virtual ~ScriptCoreObject(); + + void playFile(const wchar_t *file); + void stop(); + void setVolume(int v); + int getStatus(); + +/* virtual int corecb_onStopped(); + virtual int corecb_onEndOfDecode();*/ + + static scriptVar maki_playFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar file); + static scriptVar maki_stop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +// static scriptVar maki_onStop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +// static scriptVar maki_setVolume(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v); +// static scriptVar maki_getStatus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + + // Callback Methods in Maki. + static scriptVar /*int*/ maki_onStarted(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_onStopped(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_onPaused(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_onUnpaused(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_onSeeked(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newpos); + static scriptVar /*int*/ maki_onVolumeChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newvol); + static scriptVar /*int*/ maki_onPanChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newpan); + static scriptVar /*int*/ maki_onEQStatusChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval); + static scriptVar /*int*/ maki_onEQPreampChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval); + static scriptVar /*int*/ maki_onEQBandChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ band, scriptVar /*int*/ newval); + static scriptVar /*int*/ maki_onEQFreqChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval); + static scriptVar /*int*/ maki_onEQAutoChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval); + static scriptVar /*int*/ maki_onStatusMsg(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text); + static scriptVar /*int*/ maki_onWarningMsg(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text); + static scriptVar /*int*/ maki_onErrorMsg(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text); + static scriptVar /*int*/ maki_onTitleChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ title); + static scriptVar /*int*/ maki_onTitle2Change(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ title2); + static scriptVar /*int*/ maki_onInfoChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ info); + static scriptVar /*int*/ maki_onUrlChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ url); + static scriptVar /*int*/ maki_onLengthChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newlength); + static scriptVar /*int*/ maki_onNextFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_onNeedNextFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ fileid); + static scriptVar /*int*/ maki_onSetNextFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ playstring); + static scriptVar /*int*/ maki_onErrorOccured(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ severity, scriptVar /*String*/ text); + static scriptVar /*int*/ maki_onAbortCurrentSong(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_onEndOfDecode(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_onFileComplete(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ playstring); + static scriptVar /*int*/ maki_onConvertersChainRebuilt(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_onMediaFamilyChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ newfamily); + + static scriptVar /*int*/ maki_setNextFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ playstr); + static scriptVar /*int*/ maki_getStatus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*String*/ maki_getCurrent(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_getCurPlaybackNumber(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_getNumTracks(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_getPosition(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_getWritePosition(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_setPosition(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ ms); + static scriptVar /*int*/ maki_getLength(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_getVolume(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*void*/ maki_setVolume(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ vol); + static scriptVar /*int*/ maki_getPan(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*void*/ maki_setPan(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ bal); + static scriptVar /*void*/ maki_setMute(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ mute); + static scriptVar /*int*/ maki_getMute(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_getLeftVuMeter(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_getRightVuMeter(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*void*/ maki_userButton(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ button); + static scriptVar /*int*/ maki_getEqStatus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*void*/ maki_setEqStatus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ enable); + static scriptVar /*int*/ maki_getEqPreamp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*void*/ maki_setEqPreamp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ pre); + static scriptVar /*int*/ maki_getEqBand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ band); + static scriptVar /*void*/ maki_setEqBand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ band, scriptVar /*int*/ val); + static scriptVar /*int*/ maki_getEqAuto(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*void*/ maki_setEqAuto(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ enable); + static scriptVar /*void*/ maki_setCustomMsg(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text); + static scriptVar /*void*/ maki_setPriority(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ priority); + static scriptVar /*int*/ maki_getPriority(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*void*/ maki_rebuildConvertersChain(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + + static PtrList objects; + + protected: +#ifndef FAKE_SCRIPTCORE + virtual int getNumEntries() { return 1; } + virtual const char *enumItem(int pos); + virtual int getCurrent() { return 0; } + virtual int setCurrent(int cur) { return 0; } +#endif + + // Callback Methods forwarded to Maki. + virtual int corecb_onStarted(); + virtual int corecb_onStopped(); + virtual int corecb_onPaused(); + virtual int corecb_onUnpaused(); + virtual int corecb_onSeeked(int newpos); + virtual int corecb_onVolumeChange(int newvol); + virtual int corecb_onPanChange(int newpan); + virtual int corecb_onEQStatusChange(int newval); + virtual int corecb_onEQPreampChange(int newval); + virtual int corecb_onEQBandChange(int band, int newval); + virtual int corecb_onEQFreqChange(int newval); + virtual int corecb_onEQAutoChange(int newval); + virtual int corecb_onStatusMsg(const wchar_t *text); + virtual int corecb_onWarningMsg(const wchar_t *text); + virtual int corecb_onErrorMsg(const wchar_t *text); + virtual int corecb_onTitleChange(const wchar_t *title); + virtual int corecb_onTitle2Change(const wchar_t *title2); + virtual int corecb_onInfoChange(const wchar_t *info); + virtual int corecb_onUrlChange(const wchar_t *url); + virtual int corecb_onLengthChange(int newlength); + virtual int corecb_onNextFile(); + virtual int corecb_onNeedNextFile(int fileid); + virtual int corecb_onSetNextFile(const wchar_t *playstring); + virtual int corecb_onErrorOccured(int severity, const wchar_t *text); + virtual int corecb_onAbortCurrentSong(); + virtual int corecb_onEndOfDecode(); + virtual int corecb_onFileComplete(const wchar_t *playstring); + virtual int corecb_onConvertersChainRebuilt(); + virtual int corecb_onMediaFamilyChange(const wchar_t *newfamily); + + private: + // Only called by us and our friend the admin. +#ifndef FAKE_SCRIPTCORE + virtual void initAsCreated(); + + svc_coreAdmin *svc; + CoreToken core_handle; + String filetoplay; + int curvol; + int registered_sequencer; +#endif +}; + +// ----------------------------------------------------------------------------------------------------- +class CoreScriptObjectController : public ScriptObjectControllerI { + friend CoreAdminScriptObjectController; + public: + virtual const wchar_t *getClassName() { return L"Core"; } + virtual const wchar_t *getAncestorClassName() { return L"Object"; } + virtual ScriptObjectController *getAncestorController() { return WASABI_API_MAKI->maki_getController(rootObjectGuid); } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions() { return exportedFunction; } + virtual GUID getClassGuid() { return CORE_SCRIPTOBJECT_GUID; } + virtual int getInstantiable() { return 1; } + virtual int getReferenceable() { return 1; } + virtual ScriptObject *instantiate(); + virtual void *encapsulate(ScriptObject *o); + virtual void destroy(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + static function_descriptor_struct exportedFunction[]; + + // Only called by us and our friend the admin. + virtual ScriptObject *instantiate(CoreToken token = 0x80000000); +}; + +// ----------------------------------------------------------------------- + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/core/svc_scriptcore.cpp b/Src/Wasabi/api/script/objects/core/svc_scriptcore.cpp new file mode 100644 index 00000000..a4c3ed1c --- /dev/null +++ b/Src/Wasabi/api/script/objects/core/svc_scriptcore.cpp @@ -0,0 +1,38 @@ +#include +#include "svc_scriptcore.h" +#include +#include + +#ifndef _WASABIRUNTIME + +BEGIN_SERVICES(ScriptCore_Svc); +DECLARE_SERVICETSINGLE(svc_scriptObject, CoreScriptObjectSvc); +END_SERVICES(ScriptCore_Svc, _ScriptCore_Svc); + +#ifdef _X86_ +extern "C" { int _link_ScriptCore_Svc; } +#else +extern "C" { int __link_ScriptCore_Svc; } +#endif + +#endif + +// ----------------------------------------------------------------------------------------------------- +// Service + +ScriptObjectController *CoreScriptObjectSvc::getController(int n) { + switch (n) { + case 0: + return coreController; + } + return NULL; +} + +ScriptObjectController *CoreAdminScriptObjectSvc::getController(int n) { + switch (n) { + case 0: + return coreAdminController; + } + return NULL; +} + diff --git a/Src/Wasabi/api/script/objects/core/svc_scriptcore.h b/Src/Wasabi/api/script/objects/core/svc_scriptcore.h new file mode 100644 index 00000000..c6530aa5 --- /dev/null +++ b/Src/Wasabi/api/script/objects/core/svc_scriptcore.h @@ -0,0 +1,27 @@ +#ifndef __GUIVIDEOSVC_H +#define __GUIVIDEOSVC_H + +#include + +class CoreScriptObjectSvc : public svc_scriptObjectI { + +public: + CoreScriptObjectSvc() {}; + virtual ~CoreScriptObjectSvc() {}; + + static const char *getServiceName() { return "MediaCore maki object"; } + virtual ScriptObjectController *getController(int n); +}; + +class CoreAdminScriptObjectSvc : public svc_scriptObjectI { + +public: + CoreAdminScriptObjectSvc() {}; + virtual ~CoreAdminScriptObjectSvc() {}; + + static const char *getServiceName() { return "MediaCoreAdmin maki object"; } + virtual ScriptObjectController *getController(int n); +}; + +#endif + diff --git a/Src/Wasabi/api/script/objects/guiobj.cpp b/Src/Wasabi/api/script/objects/guiobj.cpp new file mode 100644 index 00000000..dd7b5903 --- /dev/null +++ b/Src/Wasabi/api/script/objects/guiobj.cpp @@ -0,0 +1,2880 @@ +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef PI +#define PI 3.1415926536F +#endif + +#include + +const wchar_t guiobjectXuiStr[] = L"GuiObject"; // This is the xml tag +char guiobjectXuiSvcName[] = "GuiObject xui object"; // this is the name of the xuiservice + +#ifdef USEAPPBAR +extern _bool cfg_options_appbarondrag; +#endif + +static wchar_t txt[4096]; + +GuiObjectI::GuiObjectI(ScriptObject *o) { + translate = 1; + my_script_object = o; + my_root_wnd = NULL; + + redock.l = NULL; + MEMSET(&redock.original_rect, 0, sizeof(RECT)); + targetstatus = TARGET_FROZEN; + targetspeed = 4; + start_time = 0; + reversetarget = 0; + dodragcheck = 0; + gui_rx = 0; + gui_ry = 0; + gui_rw = 0; + gui_rh = 0; + gui_x = 0; + gui_y = 0; + gui_w = AUTOWH; + gui_h = AUTOWH; + p_group = NULL; + targetx = AUTOWH; + targety = AUTOWH; + targetw = AUTOWH; + targeth = AUTOWH; + targeta = AUTOWH; + in_area = 0; + clickthrough = 0; + autosysmetricsx = 0; + autosysmetricsy = 0; + autosysmetricsw = 0; + autosysmetricsh = 0; + xuisvc = NULL; + xuifac = NULL; + mover = 0; + moving = 0; + droptarget = 0; +#ifdef WASABI_COMPILE_CONFIG + cfgitem = NULL; +#endif + timer.setGuiObjectI(this); + wantfocus = 0; + anchorage = ANCHOR_NONE; + anchor_x1 = anchor_x2 = anchor_y1 = anchor_y2 = 0; + anchorage_invalidated = 0; + anchorage = ANCHOR_LEFT|ANCHOR_TOP; + cursor = NULL; +#ifdef USEAPPBAR + m_dock_side = APPBAR_NOTDOCKED; +#endif + m_lastnondocked_x = -0xFFFF; + m_lastnondocked_y = -0xFFFF; +} + +GuiObjectI::~GuiObjectI() { + notifylist.deleteAll(); + delete cursor; + if (guiobject_getParentGroup()) + guiobject_getParentGroup()->removeObject(this); + if (targetstatus == TARGET_RUNNING) + stopTargetTimer(); +#ifdef WASABI_COMPILE_CONFIG + if (cfgitem) viewer_delViewItem(cfgitem); +#endif +} + +ScriptObject *GuiObjectI::guiobject_getScriptObject() +{ + return my_script_object; +} + +// Used by us when parsing xml to assign the object's ID, shouldn't be used elsewhere +void GuiObjectI::guiobject_setId(const wchar_t *id) +{ + guiobject_id = id; +} + +const wchar_t *GuiObjectI::guiobject_getId() +{ + if (guiobject_id.isempty()) return L""; + return guiobject_id; //FG> avoid returning NULL +} + +int GuiObjectI::guiobject_setXmlParam(const wchar_t *paramname, const wchar_t *strvalue) +{ + int r = 0; + //ifc_window *w = guiobject_getRootWnd(); + XmlObject *xo = static_cast(guiobject_getScriptObject()->vcpu_getInterface(xmlObjectGuid)); + if (xo != NULL) { + r = xo->setXmlParam(paramname, strvalue); + } + return r; +} + +const wchar_t *GuiObjectI::guiobject_getXmlParam(const wchar_t *paramname) { + const wchar_t *rt = NULL; + //ifc_window *w = guiobject_getRootWnd(); + XmlObject *xo = static_cast(guiobject_getScriptObject()->vcpu_getInterface(xmlObjectGuid)); + if (xo != NULL) { + int r = xo->getXmlParam(paramname); + rt = xo->getXmlParamValue(r); + } + return rt; +} + +int GuiObjectI::guiobject_setXmlParamById(int id, const wchar_t *strvalue) +{ + int a; + switch (id) { + case GuiObjectWnd::GUIOBJECT_ID: + guiobject_setId(strvalue); + break; + case GuiObjectWnd::GUIOBJECT_ALPHA: + if (wcschr(strvalue, ',')) // erroneous value, this is probably a color, or something + guiobject_setAlpha(255); + else + guiobject_setAlpha(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_ACTIVEALPHA: + if (wcschr(strvalue, ',')) // erroneous value, this is probably a color, or something + guiobject_setActiveAlpha(255); + else + guiobject_setActiveAlpha(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_INACTIVEALPHA: + if (wcschr(strvalue, ',')) // erroneous value, this is probably a color, or something + guiobject_setInactiveAlpha(255); + else + guiobject_setInactiveAlpha(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_SYSREGION: + guiobject_setRegionOp(WASABI_API_SKIN->parse(strvalue, L"regionop")); + break; + case GuiObjectWnd::GUIOBJECT_RECTRGN: + guiobject_setRectRgn(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_TOOLTIP: + guiobject_getRootWnd()->setTip(strvalue); + break; + case GuiObjectWnd::GUIOBJECT_SYSMETRICSX: + guiobject_setAutoSysMetricsX(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_SYSMETRICSY: + guiobject_setAutoSysMetricsY(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_SYSMETRICSW: + guiobject_setAutoSysMetricsW(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_SYSMETRICSH: + guiobject_setAutoSysMetricsH(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_MOVE: + guiobject_setMover(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_RENDERBASETEXTURE: + guiobject_getRootWnd()->setRenderBaseTexture(WTOI(strvalue)); + break; +#ifdef WASABI_COMPILE_CONFIG + case GuiObjectWnd::GUIOBJECT_CFGATTR: + setCfgAttr(strvalue); + break; +#endif + case GuiObjectWnd::GUIOBJECT_TABORDER: + guiobject_setTabOrder(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_X: { + a = WTOI(strvalue); + guiobject_setGuiPosition(&a, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; } + case GuiObjectWnd::GUIOBJECT_Y: { + a = WTOI(strvalue); + guiobject_setGuiPosition(NULL, &a, NULL, NULL, NULL, NULL, NULL, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; } + case GuiObjectWnd::GUIOBJECT_W: { + a = WTOI(strvalue); + guiobject_setGuiPosition(NULL, NULL, &a, NULL, NULL, NULL, NULL, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; } + case GuiObjectWnd::GUIOBJECT_H: { + a = WTOI(strvalue); + guiobject_setGuiPosition(NULL, NULL, NULL, &a, NULL, NULL, NULL, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; } + case GuiObjectWnd::GUIOBJECT_FITTOPARENT: { + int v = WTOI(strvalue); + if (v) { + int one = 1; + int x = 0, y = 0, w = 0, h = 0; + if (v < 0) { + v = -v; + x += v; + y += v; + w -= v * 2; + h -= v * 2; + } + guiobject_setGuiPosition(&x, &y, &w, &h, NULL, NULL, &one, &one); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + } + break; } + case GuiObjectWnd::GUIOBJECT_WANTFOCUS: + wantfocus = WTOI(strvalue); + if (guiobject_getRootWnd()->isPostOnInit()) { + if (wantfocus) { + if (guiobject_getRootWnd()->getTabOrder() == -1) + guiobject_getRootWnd()->setAutoTabOrder(); + } else { + if (guiobject_getRootWnd()->getTabOrder() != -1) + guiobject_getRootWnd()->setTabOrder(-1); + } + } + break; + case GuiObjectWnd::GUIOBJECT_VISIBLE: { + a = WTOI(strvalue); + ifc_window *w = guiobject_getRootWnd(); + if (w->isPostOnInit()) + w->setVisible(a); + else + w->setStartHidden(!a); + break; } + case GuiObjectWnd::GUIOBJECT_RELATX: { + if (strvalue && *strvalue == '%') + a = 2; + else + a = WTOI(strvalue); + guiobject_setGuiPosition(NULL, NULL, NULL, NULL, &a, NULL, NULL, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; } + case GuiObjectWnd::GUIOBJECT_RELATY: { + if (strvalue && *strvalue == '%') + a = 2; + else + a = WTOI(strvalue); + guiobject_setGuiPosition(NULL, NULL, NULL, NULL, NULL, &a, NULL, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; } + case GuiObjectWnd::GUIOBJECT_RELATW: { + if (strvalue && *strvalue == '%') + a = 2; + else + a = WTOI(strvalue); + guiobject_setGuiPosition(NULL, NULL, NULL, NULL, NULL, NULL, &a, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; } + case GuiObjectWnd::GUIOBJECT_RELATH: { + if (strvalue && *strvalue == '%') + a = 2; + else + a = WTOI(strvalue); + guiobject_setGuiPosition(NULL, NULL, NULL, NULL, NULL, NULL, NULL, &a); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; } + case GuiObjectWnd::GUIOBJECT_DROPTARGET: + guiobject_setDropTarget(strvalue); + break; + case GuiObjectWnd::GUIOBJECT_GHOST: + guiobject_setClickThrough(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_SETNODBLCLICK: + guiobject_setNoDoubleClick(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_SETNOLEFTCLICK: + guiobject_setNoLeftClick(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_SETNORIGHTCLICK: + guiobject_setNoRightClick(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_SETNOMOUSEMOVE: + guiobject_setNoMouseMove(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_SETNOCONTEXTMENU: + guiobject_setNoContextMenu(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_SETX1: { + a = WTOI(strvalue); + guiobject_setAnchoragePosition(&a, NULL, NULL, NULL, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; + } + case GuiObjectWnd::GUIOBJECT_SETY1:{ + a = WTOI(strvalue); + guiobject_setAnchoragePosition(NULL, &a, NULL, NULL, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; + } + case GuiObjectWnd::GUIOBJECT_SETX2:{ + a = WTOI(strvalue); + guiobject_setAnchoragePosition(NULL, NULL, &a, NULL, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; + } + case GuiObjectWnd::GUIOBJECT_SETY2:{ + a = WTOI(strvalue); + guiobject_setAnchoragePosition(NULL, NULL, NULL, &a, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; + } + case GuiObjectWnd::GUIOBJECT_SETANCHOR: { + int anchorage=ANCHOR_NONE; + ParamParser pp(strvalue, L"|"); + for (int m=0;misPostOnInit()) + g->updatePos(this); + } + break; + case GuiObjectWnd::GUIOBJECT_SETCURSOR: + guiobject_setCursor(strvalue); + break; + case GuiObjectWnd::GUIOBJECT_NOTIFY: + notifylist.addItem(new StringW(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_USERDATA: + // nothing to do, param goes in xmlobject + break; +#ifdef USEAPPBAR + case GuiObjectWnd::GUIOBJECT_APPBAR: + setAppBar(strvalue); + break; +#endif + case GuiObjectWnd::GUIOBJECT_TRANSLATE: + translate = WTOI(strvalue); + break; + default: + return 0; + } + return 1; +} + +void GuiObjectI::guiobject_getGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh) { + if (x) *x = gui_x; + if (y) *y = gui_y; + if (w) *w = gui_w; + if (h) *h = gui_h; + if (rx) *rx = gui_rx; + if (ry) *ry = gui_ry; + if (rw) *rw = gui_rw; + if (rh) *rh = gui_rh; +} + +void GuiObjectI::guiobject_setGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh) { + if (x && *x != NOCHANGE && *x != AUTOWH) gui_x = *x; + if (y && *y != NOCHANGE && *y != AUTOWH) gui_y = *y; + if (w && *w != NOCHANGE && *w != AUTOWH) gui_w = *w; + if (h && *h != NOCHANGE && *h != AUTOWH) gui_h = *h; + if (rx && *rx != NOCHANGE && *rx != AUTOWH) gui_rx = *rx; + if (ry && *ry != NOCHANGE && *ry != AUTOWH) gui_ry = *ry; + if (rw && *rw != NOCHANGE && *rw != AUTOWH) gui_rw = *rw; + if (rh && *rh != NOCHANGE && *rh != AUTOWH) gui_rh = *rh; + if (guiobject_getRootWnd()->isInited() && guiobject_getParentGroup()) + guiobject_getParentGroup()->updatePos(this); + else { + if (!guiobject_getRootWnd()->isVirtual()) + guiobject_getRootWnd()->resize(gui_x, gui_y, gui_w, gui_h); + } +} + +int GuiObjectI::guiobject_getAnchoragePosition(int *x1, int *y1, int *x2, int *y2, int *anchor) { + if (x1) *x1 = anchor_x1; + if (y1) *y1 = anchor_y1; + if (x2) *x2 = anchor_x2; + if (y2) *y2 = anchor_y2; + if (anchor) *anchor = anchorage; + return anchorage_invalidated; +} + +void GuiObjectI::guiobject_setAnchoragePosition(int *x1, int *y1, int *x2, int *y2, int *anchor) { + anchorage_invalidated = 1; + if (x1) anchor_x1 = *x1; + if (x2) anchor_x2 = *x2; + if (y1) anchor_y1 = *y1; + if (y2) anchor_y2 = *y2; + if (anchor) anchorage = *anchor; + if (guiobject_getRootWnd()->isInited() && guiobject_getParentGroup()) { + guiobject_getParentGroup()->updatePos(this); + } +} + +void GuiObjectI::guiobject_validateAnchorage() { + anchorage_invalidated = 0; +} + +void GuiObjectI::guiobject_setClickThrough(int c) { + guiobject_getRootWnd()->setClickThrough(c); +} + +void GuiObjectI::guiobject_setRegionOp(int op) { + guiobject_getRootWnd()->setRegionOp(op); +} + +int GuiObjectI::guiobject_getRegionOp() { + return guiobject_getRootWnd()->getRegionOp(); +} + +void GuiObjectI::guiobject_setRectRgn(int rrgn) { + guiobject_getRootWnd()->setRectRgn(rrgn); +} + +void GuiObjectI::guiobject_setMover(int n) { + mover = n; +} + +int GuiObjectI::guiobject_getMover() { + return mover; +} + +FOURCC GuiObjectI::guiobject_getDropTarget() { + return droptarget; +} + +void GuiObjectI::guiobject_setDropTarget(const wchar_t *strval) +{ + if (strval == NULL) + droptarget = 0; + else + { + uint8_t *temp = (uint8_t *)&droptarget; + temp[3]=(uint8_t)strval[0]; + temp[2]=(uint8_t)strval[1]; + temp[1]=(uint8_t)strval[2]; + temp[0]=(uint8_t)strval[3]; + } +} + +int GuiObjectI::guiobject_isRectRgn() { + return guiobject_getRootWnd()->isRectRgn(); +} + +int GuiObjectI::guiobject_isClickThrough() { + return guiobject_getRootWnd()->isClickThrough(); +} + +void GuiObjectI::guiobject_setParentGroup(Group *l) { + if (!l) { p_group = NULL; return; } + p_group = l; +} + +Group *GuiObjectI::guiobject_getParentGroup() { + if (!p_group) return NULL; + return p_group; +} + +GuiObject *GuiObjectI::guiobject_getParent() { + ifc_window *grw = guiobject_getRootWnd(); + if (!grw) return NULL; + ifc_window *w = grw->getParent(); + if (!w) return NULL; + return static_cast(w->getInterface(guiObjectGuid)); +} + +#ifdef WASABI_COMPILE_WNDMGR +Layout *GuiObjectI::guiobject_getParentLayout() { + Group *m = p_group; + Layout *l = NULL; + while (m) { + if (m->isLayout()) { + l = static_cast(m); + break; + } + m = m->getGuiObject()->guiobject_getParentGroup(); + } + if (!l) { + ifc_window *w = guiobject_getRootWnd()->getDesktopParent(); + if (w) + l = static_cast(w->getInterface(layoutGuid)); + } + if (l && l->isDeleting()) return NULL; + return l; +} +#endif + +GuiObject *GuiObjectI::guiobject_getTopParent() { + ifc_window *m = guiobject_getRootWnd(); + GuiObject *top = this; + + while (m != NULL) { + m = m->getParent(); + if (m != NULL) { + GuiObject *g = m->getGuiObject(); + if (g != NULL) + top = g; + } + } + + return top; +} + +/*void GuiObjectI::parseNotify(const char *s) { + scriptNotify(s, "", 0, 0); +}*/ + +void GuiObjectI::guiobject_bringToFront() { + ifc_window *b = guiobject_getRootWnd(); + if (b) { + if (b->getParent()) + b->getParent()->bringVirtualToFront(b); + } +} + +void GuiObjectI::guiobject_bringToBack() { + ifc_window *b = guiobject_getRootWnd(); + if (b) { + if (b->getParent()) + b->getParent()->bringVirtualToBack(b); + } +} + +void GuiObjectI::guiobject_bringAbove(GuiObject *o) { + ASSERT(o != NULL); + ifc_window *b = guiobject_getRootWnd(); + ifc_window *c = o->guiobject_getRootWnd(); + if (b && c) { + if (b->getParent()) + b->getParent()->bringVirtualAbove(b, c); + } +} + +void GuiObjectI::guiobject_bringBelow(GuiObject *o) { + ASSERT(o != NULL); + ifc_window *b = guiobject_getRootWnd(); + ifc_window *c = o->guiobject_getRootWnd(); + if (b && c) { + if (b->getParent()) + b->getParent()->bringVirtualBelow(b, c); + } +} + +void GuiObjectI::guiobject_setTargetSpeed(float s) { // s == n of seconds + if (targetspeed == (int)(s * 4.0)) return; + targetspeed = (int)(s * 4.0); // units of 250ms + if (targetstatus == TARGET_RUNNING) { + stopTargetTimer(); + startTargetTimer(); + } +} + +void GuiObjectTimer::timerclient_timerCallback(int id) { + if (id == TARGETTIMER_ID && obj) + obj->onTargetTimer(); +} + +void GuiObjectI::guiobject_setTargetX(int x) { + targetx = x; +} + +void GuiObjectI::guiobject_setTargetY(int y) { + targety = y; +} + +void GuiObjectI::guiobject_setTargetW(int w) { + targetw = w; +} + +void GuiObjectI::guiobject_setTargetH(int h) { + targeth = h; +} + +void GuiObjectI::guiobject_setTargetA(int a) { + targeta = a; +} + +void GuiObjectI::guiobject_gotoTarget() { + if (!guiobject_getRootWnd()) return; + start_time=0; + guiobject_getGuiPosition(&startx, &starty, &startw, &starth, NULL, NULL, NULL, NULL); + starta = guiobject_getAlpha(); + if (targetx == AUTOWH || targetx == NOCHANGE) + targetx = startx; + if (targety == AUTOWH || targety == NOCHANGE) + targety = starty; + if (targetw == AUTOWH || targetw == NOCHANGE) + targetw = startw; + if (targeth == AUTOWH || targeth == NOCHANGE) + targeth = starth; + if (targeta == AUTOWH || targeta == NOCHANGE) + targeta = starta; + startTargetTimer(); + Layout *l = static_cast(guiobject_getScriptObject()->vcpu_getInterface(layoutGuid)); + if (targetx != startx || + targety != starty || + targetw != startw || + targeth != starth) { + if (l) windowTracker->beforeRedock(l, &redock); + } +} + +void GuiObjectI::startTargetTimer() { + timer.timerclient_setTimer(TARGETTIMER_ID, 20); + targetstatus = TARGET_RUNNING; +} + +void GuiObjectI::stopTargetTimer() { + timer.timerclient_killTimer(TARGETTIMER_ID); + targetstatus = TARGET_FROZEN; +} + +void GuiObjectI::onTargetTimer() { + + if (targetstatus != TARGET_RUNNING) return; + if (!guiobject_getRootWnd()) return; + + RECT r; + guiobject_getRootWnd()->getClientRect(&r); + RECT wr; + guiobject_getRootWnd()->getWindowRect(&wr); + + int ttime=250*targetspeed; + if (ttime < 0) ttime = 0; + + int n; + if (!start_time) + { + n=0; + start_time = Wasabi::Std::getTickCount(); + } + else + { + n=MulDiv(Wasabi::Std::getTickCount()-start_time,256,ttime); + } + + if (ttime == 0) n = 255; + + if (n >= 255) n=255; + + float sintrans = (float)(sin(((float)n/255)*PI-PI/2)/2+0.5); // used for smoothing transitions + + float nw = ((float)(targetw - startw) * sintrans) + startw; + float nh = ((float)(targeth - starth) * sintrans) + starth; + float na = ((float)(targeta - starta) * sintrans) + starta; + + Layout *l = static_cast(guiobject_getScriptObject()->vcpu_getInterface(layoutGuid)); + int islayout = l != NULL && static_cast(l) == guiobject_getRootWnd(); + + float rat = 1.0f; + if (islayout) rat = (float)l->getRenderRatio(); + + float nx; + float ny; + if (!reversetarget) { + nx = ((float)(targetx - startx) * sintrans) + startx; + ny = ((float)(targety - starty) * sintrans) + starty; + } else { + nx = startx - ((float)(targetw - startw) * sintrans) * rat; + ny = starty - ((float)(targeth - starth) * sintrans) * rat; + } + + int zx=(int)nx; + int zy=(int)ny; + int zw=(int)nw; + int zh=(int)nh; + + if (reversetarget) { + while (zy + zh * rat < wr.bottom) zy++; + while (zx + zw * rat < wr.right) zx++; + } + + int oldredraw = -1; + if (reversetarget && islayout) { + oldredraw = l->wantRedrawOnResize(); + l->setWantRedrawOnResize(0); + + int paddtop = wr.top - (int)ny; + int paddleft = wr.left - (int)nx; + +#ifdef _WIN32 + if (paddtop > 0 || paddleft > 0) { + RegionI r; + GetWindowRgn(l->gethWnd(), r.getOSHandle()); + r.offset(MAX(0, paddleft), MAX(0, paddtop)); + SetWindowRgn(l->gethWnd(), r.makeWindowRegion(), FALSE); + } +#else +#warning port me +#endif + } + guiobject_setGuiPosition(&zx, &zy, &zw, &zh, NULL, NULL, NULL, NULL); + guiobject_getRootWnd()->cascadeRepaint(0); + guiobject_setAlpha((int)na); + if (n==255) { + stopTargetTimer(); + guiobject_onTargetReached(); + } + if (l != NULL) l->savePosition(); + if (oldredraw != -1 && l) { + l->setWantRedrawOnResize(oldredraw); + } +} + +void GuiObjectI::guiobject_cancelTarget() { + stopTargetTimer(); + Layout *l = static_cast(guiobject_getScriptObject()->vcpu_getInterface(layoutGuid)); + if (l && redock.l) windowTracker->afterRedock(l, &redock); +} + +void GuiObjectI::guiobject_reverseTarget(int reverse) { + reversetarget = reverse; +} + +#ifdef WASABI_COMPILE_WNDMGR +void GuiObjectI::guiobject_popParentLayout() { + Layout *l = guiobject_getParentLayout(); + if (l && l->getParentContainer()) { + SkinParser::showContainer(l->getParentContainer()->getId(), TRUE); +#ifdef WIN32 + SetForegroundWindow(l->gethWnd()); +#else + l->bringToFront(); +#endif + } +} +#endif + +int GuiObjectI::guiobject_movingToTarget() { + return targetstatus == TARGET_RUNNING; +} + +void GuiObjectI::guiobject_onLeftButtonDown(int x, int y) { + if (!VCPU::getComplete()) { + scriptVar _x = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_x, x); + scriptVar _y = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_y, y); + GuiObject_ScriptMethods::onLeftButtonDown(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y); + if (mover && !VCPU::getComplete()) { + #ifdef WASABI_COMPILE_WNDMGR + Layout *l = guiobject_getParentLayout(); + if (l) { + // Martin> (9/9/8) added l->getGuiObject()->guiobject_getMover() so setting move="0" to layouts will disable moving it around + if (!l->isLocked() && l->getGuiObject()->guiobject_getMover()) { +#ifdef USEAPPBAR + if (cfg_options_appbarondrag) { + m_initial_dock_side = m_dock_side = l->appbar_getSide(); + if (m_dock_side != APPBAR_NOTDOCKED) { + dodragcheck = 1; + goto skipit; + } + } +#endif + l->maximize(0); + skipit: + l->beginMove(); + if (l->getParentContainer() && l->getParentContainer()->isMainContainer() || Std::keyModifier(STDKEY_ALT)) + WASABI_API_WNDMGR->wndTrackStartCooperative(l); + moving = 1; + anchor.x = (int)((float)x * guiobject_getRootWnd()->getRenderRatio()); + anchor.y = (int)((float)y * guiobject_getRootWnd()->getRenderRatio()); + } + } + #endif //WASABI_COMPILE_WNDMGR + } + } +} + +void GuiObjectI::guiobject_onLeftButtonUp(int x, int y) { + scriptVar _x = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_x, x); + scriptVar _y = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_y, y); + GuiObject_ScriptMethods::onLeftButtonUp(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y); + if (moving) { + int sendendmove = 0; +#ifdef WASABI_COMPILE_WNDMGR + Group *l = guiobject_getParentLayout(); + if (l) { + if (WASABI_API_WNDMGR->wndTrackWasCooperative()) + WASABI_API_WNDMGR->wndTrackEndCooperative(); + moving = 0; + sendendmove = 1; + } +#ifdef USEAPPBAR + if (cfg_options_appbarondrag) { + if (m_dock_side != m_initial_dock_side) { + ifc_window *dw = guiobject_getRootWnd()->getDesktopParent(); + if (dw) { + AppBar *ab = reinterpret_cast(dw->getInterface(appBarGuid)); + if (ab) { + if (m_dock_side == APPBAR_NOTDOCKED) ab->appbar_setNoRestore(1); + ab->appbar_dock(m_dock_side); + if (m_dock_side == APPBAR_NOTDOCKED) ab->appbar_setNoRestore(0); + } + } + } + if (m_dock_side == APPBAR_NOTDOCKED) { + ifc_window *dp = guiobject_getRootWnd()->getDesktopParent(); + if (dp) dp->restore(0); + } + } else { + ifc_window *dp = guiobject_getRootWnd()->getDesktopParent(); + if (dp) dp->restore(0); + } +#else + ifc_window *dp = guiobject_getRootWnd()->getDesktopParent(); + if (dp) dp->restore(0); +#endif // USEAPPBAR + if (sendendmove && l) l->endMove(); +#endif //WASABI_COMPILE_WNDMGR + } +} + +void GuiObjectI::guiobject_onRightButtonDown(int x, int y) { + scriptVar _x = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_x, x); + scriptVar _y = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_y, y); + GuiObject_ScriptMethods::onRightButtonDown(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y); +} + +#ifdef WASABI_CUSTOM_CONTEXTMENUS +extern void appContextMenu(ifc_window *wnd); +extern void appControlMenu(ifc_window *wnd); +#endif + +void GuiObjectI::guiobject_onRightButtonUp(int x, int y) { + scriptVar _x = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_x, x); + scriptVar _y = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_y, y); + GuiObject_ScriptMethods::onRightButtonUp(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y); + ifc_window *w = guiobject_getRootWnd(); + if (Std::keyModifier(STDKEY_CONTROL) && + Std::keyModifier(STDKEY_SHIFT)) { + GuiObjectI::infoMenu(this, x, y); + } else { + if (w && w->wantAutoContextMenu() && !VCPU::getComplete() && WASABI_API_WNDMGR->getModalWnd() == NULL) { + ifc_window *par = w->getParent(); + if (par && guiobject_getParentLayout()) { + if (!Std::keyModifier(STDKEY_CONTROL)) { +#if defined(WA3COMPATIBILITY) + Main::appContextMenu(par, TRUE, guiobject_getParentLayout()->isTransparencySafe()); +#elif defined(WASABI_CUSTOM_CONTEXTMENUS) + appContextMenu(par); +#endif + } else { + Layout *l = guiobject_getParentLayout(); + if (l->getParent() == NULL) { +#if defined(WA3COMPATIBILITY) + l->controlMenu(); +#elif defined(WASABI_CUSTOM_CONTEXTMENUS) + appControlMenu(l); +#endif + } + } + } else { + Layout *l = static_cast(w->getInterface(layoutGuid)); + if (l != NULL) { + if (!Std::keyModifier(STDKEY_CONTROL)) { +#if defined(WA3COMPATIBILITY) + Main::appContextMenu(w, TRUE, l->isTransparencySafe()); +#elif defined(WASABI_CUSTOM_CONTEXTMENUS) + appContextMenu(w); +#endif + } else { +#if defined(WA3COMPATIBILITY) + l->controlMenu(); +#elif defined(WASABI_CUSTOM_CONTEXTMENUS) + appControlMenu(l); +#endif + } + } + } + } + } +} + +void GuiObjectI::guiobject_onRightButtonDblClk(int x, int y) { + scriptVar _x = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_x, x); + scriptVar _y = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_y, y); + GuiObject_ScriptMethods::onRightButtonDblClk(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y); +} + +void GuiObjectI::guiobject_onLeftButtonDblClk(int x, int y) { + scriptVar _x = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_x, x/* - wr.left*/); + scriptVar _y = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_y, y/* - wr.top*/); + GuiObject_ScriptMethods::onLeftButtonDblClk(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y); +} + +int GuiObjectI::guiobject_onMouseWheelUp(int clicked, int lines) +{ + scriptVar retval; + retval = GuiObject_ScriptMethods::onMouseWheelUp(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_INT(clicked), MAKE_SCRIPT_INT(lines) ); + int retv; + + if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING)) + retv = 0; + else + retv = GET_SCRIPT_INT(retval); + + return retv; +} + +int GuiObjectI::guiobject_onMouseWheelDown(int clicked, int lines) +{ + scriptVar retval; + retval = GuiObject_ScriptMethods::onMouseWheelDown(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_INT(clicked), MAKE_SCRIPT_INT(lines) ); + int retv; + + if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING)) + retv = 0; + else + retv = GET_SCRIPT_INT(retval); + + return retv; +} + +void GuiObjectI::guiobject_onMouseMove(int x, int y) { + scriptVar _x = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_x, x); + scriptVar _y = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_y, y); + GuiObject_ScriptMethods::onMouseMove(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y); + POINT pos={x,y}; + guiobject_getRootWnd()->clientToScreen((int *)&pos.x, (int *)&pos.y); +#ifdef WASABI_COMPILE_WNDMGR + if (moving) { +#ifdef _WIN32 + if (!Std::keyDown(MK_LBUTTON)) { +#else +#warning port me + if (0) { +#endif + moving = 0; + } else { +#ifdef WIN32 + int drag_x = GetSystemMetrics(SM_CXDRAG); + int drag_y = GetSystemMetrics(SM_CYDRAG); +#else +#warning port me + int drag_x = 5; + int drag_y = 5; +#endif + POINT relatpos; + relatpos.x = (int)((float)x*guiobject_getRootWnd()->getRenderRatio()) - anchor.x; + relatpos.y = (int)((float)y*guiobject_getRootWnd()->getRenderRatio()) - anchor.y; + if (!dodragcheck || (ABS(relatpos.x) >= drag_x || ABS(relatpos.y) >= drag_y)) { + dodragcheck = 0; + ifc_window *p = guiobject_getRootWnd()->getDesktopParent(); + if (p) { + RECT r, cr; + p->getWindowRect(&r); + p->getClientRect(&cr); + RECT nr=r; + int w,h; + + #ifdef USEAPPBAR + int side = APPBAR_NOTDOCKED; + if (cfg_options_appbarondrag) { + AppBar *ab = reinterpret_cast(p->getInterface(appBarGuid)); + if (ab) { + int _x=x, _y=y; + p->clientToScreen(&_x, &_y); + side = ab->appbar_testDock(_x, _y, &nr); + if (ABS(p->getRenderRatio() - 1.0) > 0.01f) { + int _w = nr.right-nr.left; + int _h = nr.bottom-nr.top; + double rr = p->getRenderRatio(); + _w = (int)((double)(_w) / rr + 0.5); + _h = (int)((double)(_h) / rr + 0.5); + nr.right = nr.left + _w; + nr.bottom = nr.top + _h; + } + } + } + #endif + w = cr.right-cr.left; + h = cr.bottom-cr.top; + int resize=0; +#ifdef USEAPPBAR + if (cfg_options_appbarondrag) { + if (side != m_dock_side) { + if (side != APPBAR_NOTDOCKED) { + m_lastnondocked_x = r.left; + m_lastnondocked_y = r.top; + resize=1; + } else { + RECT rr; + p->getRestoredRect(&rr); + w = (rr.right-rr.left); + h = (rr.bottom-rr.top); + if (m_lastnondocked_x != -0xFFFF) { + r.left = m_lastnondocked_x; + r.top = m_lastnondocked_y; + } + r.right = r.left + w; + r.bottom = r.top + h; + snapAdjust(p, &r, -1); + nr=r; + resize=1; + } + } + } +#endif + + // use the scaling to adjust the overall size so docking will be correct + double rr = p->getRenderRatio(); + r.left += relatpos.x; + r.top += relatpos.y; + r.right = r.left + (int)((double)w * rr); + r.bottom = r.top + (int)((double)h * rr); + +#ifdef USEAPPBAR + + if (side == APPBAR_NOTDOCKED && m_dock_side == APPBAR_NOTDOCKED) + WASABI_API_WNDMGR->wndTrackDock(p, &r, &nr, LEFT|TOP|RIGHT|BOTTOM|KEEPSIZE); + + if (side != APPBAR_NOTDOCKED || resize) { + Layout *l = (Layout *)p->getInterface(layoutGuid); + if (l) l->pushForceUnlink(); + { + RECT adj = nr; + snapAdjust(p, &adj, 1); + int _w = adj.right-adj.left; + int _h = adj.bottom-adj.top; + if (ABS(p->getRenderRatio() - 1.0) > 0.01f) { + double rr = p->getRenderRatio(); + if ((int)((double)(_w) * rr) == (int)((double)(w) * rr)) _w = w; + if ((int)((double)(_h) * rr) == (int)((double)(h) * rr)) _h = h; + } + p->resize(adj.left, adj.top, _w, _h); + } + if (l) l->popForceUnlink(); + } else { + p->move(r.left, r.top); + } + + m_dock_side = side; + guiobject_getParentLayout()->onMove(); + if (GetCapture() != guiobject_getRootWnd()->getRootParent()->gethWnd()) { + DebugStringW(L"not mine anymore :(\n"); + } +#endif + } + } + } + } +#endif +} + +// ----------------------------------------------------------------------- +void GuiObjectI::snapAdjust(ifc_window *rw, RECT *r, int way) { + RECT s; + Layout *l = static_cast(rw->getInterface(layoutGuid)); + if (!l) return; + l->getSnapAdjust(&s); + int h = r->bottom - r->top; + int w = r->right - r->left; + if (way == 1) { + h += s.top + s.bottom; + w += s.left + s.right; + r->left -= s.left; + r->top -= s.top; + r->bottom = r->top + h; + r->right = r->left + w; + } else if (way == -1) { + h -= s.top + s.bottom; + w -= s.left + s.right; + r->left += s.left; + r->top += s.top; + r->bottom = r->top + h; + r->right = r->left + w; + } +} + +#ifdef USEAPPBAR +int GuiObjectI::guiobject_getAppBar() { + AppBar *ab = reinterpret_cast(guiobject_getRootWnd()->getInterface(appBarGuid)); + if (ab) return ab->appbar_getEnabledSides(); + return 0; +} + +BEGIN_STRINGDICTIONARY(_appbarvalues) +SDI(L"top", APPBAR_TOP_ENABLED); +SDI(L"left", APPBAR_LEFT_ENABLED); +SDI(L"right", APPBAR_RIGHT_ENABLED); +SDI(L"bottom", APPBAR_BOTTOM_ENABLED); +END_STRINGDICTIONARY(_appbarvalues, appbarvalues) + +void GuiObjectI::guiobject_setAppBar(int en) { + AppBar *ab = reinterpret_cast(guiobject_getRootWnd()->getInterface(appBarGuid)); + if (ab) ab->appbar_setEnabledSides(en); +} + +void GuiObjectI::setAppBar(const wchar_t *en) +{ + AppBar *ab = reinterpret_cast(guiobject_getRootWnd()->getInterface(appBarGuid)); + if (ab) { + int e = 0; + ParamParser pp(en, L"|;"); + for (int i=0;iappbar_setEnabledSides(e); + } +} +#endif + +const wchar_t *GuiObjectI::guiobject_getName() +{ + const wchar_t *ret = NULL; + ifc_window *w = guiobject_getRootWnd(); + if (w != NULL) + ret = w->getRootWndName(); + return ret; +} + +void GuiObjectI::guiobject_onEnable(int en) { + scriptVar _is = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_is, en); + GuiObject_ScriptMethods::onEnable(SCRIPT_CALL, guiobject_getScriptObject(), _is); +} + +void GuiObjectI::guiobject_onStartup() { + GuiObject_ScriptMethods::onStartup(SCRIPT_CALL, guiobject_getScriptObject()); + if (guiobject_getRootObject()) { + foreach (notifylist) + guiobject_getRootObject()->rootobject_notify(notifylist.getfor()->getValue(), L"", 0, 0); + endfor; + } +} + +void GuiObjectI::guiobject_onEnterArea() { + if (in_area) return; + GuiObject_ScriptMethods::onEnterArea(SCRIPT_CALL, guiobject_getScriptObject()); + in_area = 1; +} + +void GuiObjectI::guiobject_onLeaveArea() { + if (!in_area) return; + GuiObject_ScriptMethods::onLeaveArea(SCRIPT_CALL, guiobject_getScriptObject()); + in_area = 0; +} + +void GuiObjectI::guiobject_onCancelCapture() { + moving = 0; +} + +ifc_window *GuiObjectI::guiobject_getRootWnd(void) { + return my_root_wnd; +} + +void GuiObjectI::guiobject_setRootWnd(ifc_window *r) { + my_root_wnd = r; +} + +RootObject *GuiObjectI::guiobject_getRootObject() { + ScriptObject *o = guiobject_getScriptObject(); + if (!o) return NULL; + return static_cast(o->vcpu_getInterface(rootObjectGuid)); +} + +void GuiObjectI::guiobject_onResize(int x, int y, int w, int h) { + scriptVar _x = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_x, x); + scriptVar _y = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_y, y); + scriptVar _w = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_w, w); + scriptVar _h = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_h, h); + GuiObject_ScriptMethods::onResize(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y, _w, _h); +} + +void GuiObjectI::guiobject_onSetVisible(int v) { +#ifdef WASABI_COMPILE_WNDMGR + if (guiobject_getParentLayout()) + guiobject_getParentLayout()->onGuiObjectSetVisible(this, v); +#endif + scriptVar _v = SOM::makeVar(SCRIPT_BOOLEAN); + SOM::assign(&_v, v); + GuiObject_ScriptMethods::onSetVisible(SCRIPT_CALL, guiobject_getScriptObject(), _v); +#ifdef WASABI_COMPILE_WNDMGR + if (moving) { + if (WASABI_API_WNDMGR->wndTrackWasCooperative()) + WASABI_API_WNDMGR->wndTrackEndCooperative(); + moving = 0; + ifc_window *dp = guiobject_getRootWnd()->getDesktopParent(); + if (dp) dp->restore(0); + guiobject_getParentGroup()->endMove(); + } +#endif //WASABI_COMPILE_WNDMGR +} + +void GuiObjectI::guiobject_setAlpha(int a) { + if (!my_root_wnd) return; + Layout *l = static_cast(my_root_wnd->getInterface(layoutGuid)); + if (l) l->setAlpha(a); + else my_root_wnd->setAlpha(a); +} + +int GuiObjectI::guiobject_getAlpha() { + if (!my_root_wnd) return 255; + Layout *l = static_cast(my_root_wnd->getInterface(layoutGuid)); + if (l) return l->getAlpha(); + return my_root_wnd->getPaintingAlpha(); +} + +void GuiObjectI::guiobject_setActiveAlpha(int a) { + if (my_root_wnd) { + int i; + my_root_wnd->getAlpha(NULL, &i); + my_root_wnd->setAlpha(a, i); + } +} + +int GuiObjectI::guiobject_getActiveAlpha() { + int a = 255; + if (my_root_wnd) my_root_wnd->getAlpha(&a); + return a; +} + +void GuiObjectI::guiobject_setInactiveAlpha(int a) { + if (my_root_wnd) { + int _a; + my_root_wnd->getAlpha(&_a); + my_root_wnd->setAlpha(_a, a); + } +} + +int GuiObjectI::guiobject_getInactiveAlpha() { + if (my_root_wnd) { + int i; + my_root_wnd->getAlpha(NULL, &i); + return i; + } + return 255; +} + +void GuiObjectI::guiobject_onTargetReached() { + GuiObject_ScriptMethods::onTargetReached(SCRIPT_CALL, guiobject_getScriptObject()); + Layout *l = static_cast(guiobject_getScriptObject()->vcpu_getInterface(layoutGuid)); + if (l && redock.l) windowTracker->afterRedock(l, &redock); +} + +void GuiObjectI::guiobject_setAutoSysMetricsX(int a) { + if (a == autosysmetricsx) return; + autosysmetricsx = a; + if (guiobject_getRootWnd() && guiobject_getRootWnd()->isInited()) + if (guiobject_getParentGroup()) guiobject_getParentGroup()->updatePos(this); +} + +void GuiObjectI::guiobject_setAutoSysMetricsY(int a) { + if (a == autosysmetricsy) return; + autosysmetricsy = a; + if (guiobject_getRootWnd() && guiobject_getRootWnd()->isInited()) + if (guiobject_getParentGroup()) guiobject_getParentGroup()->updatePos(this); +} + +void GuiObjectI::guiobject_setAutoSysMetricsW(int a) { + if (a == autosysmetricsw) return; + autosysmetricsw = a; + if (guiobject_getRootWnd() && guiobject_getRootWnd()->isInited()) + if (guiobject_getParentGroup()) guiobject_getParentGroup()->updatePos(this); +} + +void GuiObjectI::guiobject_setAutoSysMetricsH(int a) { + if (a == autosysmetricsh) return; + autosysmetricsh = a; + if (guiobject_getRootWnd() && guiobject_getRootWnd()->isInited()) + if (guiobject_getParentGroup()) guiobject_getParentGroup()->updatePos(this); +} + +int GuiObjectI::guiobject_getAutoSysMetricsX() { + return autosysmetricsx; +} + +int GuiObjectI::guiobject_getAutoSysMetricsY() { + return autosysmetricsy; +} + +int GuiObjectI::guiobject_getAutoSysMetricsW() { + return autosysmetricsw; +} + +int GuiObjectI::guiobject_getAutoSysMetricsH() { + return autosysmetricsh; +} + +int GuiObjectI::guiobject_getAutoWidth() { + if (!guiobject_getRootWnd()) return AUTOWH; + return guiobject_getRootWnd()->getPreferences(SUGGESTED_W); +} + +int GuiObjectI::guiobject_getAutoHeight() { + if (!guiobject_getRootWnd()) return AUTOWH; + return guiobject_getRootWnd()->getPreferences(SUGGESTED_H); +} + +#ifdef WASABI_COMPILE_WNDMGR +int GuiObjectI::guiobject_runModal() { + if (!guiobject_getRootWnd()) return 0; + ifc_window *w = guiobject_getRootWnd()->getDesktopParent(); + #ifdef WASABI_MODAL_PUSH + WASABI_MODAL_PUSH + #endif + int r = w->runModal(); + #ifdef WASABI_MODAL_POP + WASABI_MODAL_POP + #endif + return r; +} + +void GuiObjectI::guiobject_endModal(int retcode) { + if (!guiobject_getRootWnd()) return; + ifc_window *w = guiobject_getRootWnd()->getDesktopParent(); + w->endModal(retcode); +} +#endif + +int GuiObjectI::guiobject_isActive() { + if (!guiobject_getRootWnd()) return 0; + return guiobject_getRootWnd()->isActive(); +} + +svc_xuiObject *GuiObjectI::guiobject_getXuiService() { + return xuisvc; +} + +void GuiObjectI::guiobject_setXuiService(svc_xuiObject *svc) { + xuisvc = svc; +} + +waServiceFactory *GuiObjectI::guiobject_getXuiServiceFactory() { + return xuifac; +} +void GuiObjectI::guiobject_setXuiServiceFactory(waServiceFactory *fac) { + xuifac = fac; +} + +#ifdef WASABI_COMPILE_WNDMGR +void GuiObjectI::guiobject_setStatusText(const wchar_t *text, int overlay) +{ + Layout *l = guiobject_getParentLayout(); + if (l) + l->setStatusText(text, overlay); +} + +void GuiObjectI::guiobject_registerStatusCB(GuiStatusCallback *cb) { + Layout *l = guiobject_getParentLayout(); + if (l) l->registerStatusCallback(cb); +} + +void GuiObjectI::guiobject_addAppCmds(AppCmds *commands){ + Layout *l = guiobject_getParentLayout(); + if (l) l->addAppCmds(commands); +} + +void GuiObjectI::guiobject_removeAppCmds(AppCmds *commands){ + Layout *l = guiobject_getParentLayout(); + if (l) l->removeAppCmds(commands); +} + +void GuiObjectI::guiobject_pushCompleted(int max) { + Layout *l = guiobject_getParentLayout(); + if (l) l->pushCompleted(max); +} +void GuiObjectI::guiobject_incCompleted(int add) { + Layout *l = guiobject_getParentLayout(); + if (l) l->incCompleted(add); +} +void GuiObjectI::guiobject_setCompleted(int pos) { + Layout *l = guiobject_getParentLayout(); + if (l) l->setCompleted(pos); +} +void GuiObjectI::guiobject_popCompleted() { + Layout *l = guiobject_getParentLayout(); + if (l) l->popCompleted(); +} +#endif //WASABI_COMPILE_WNDMGR + +void GuiObjectI::infoMenu(GuiObject *o, int x, int y) +{ + PopupMenu pop; + pop.addCommand(StringPrintfW(L"Class : %s", o->guiobject_getScriptObject()->vcpu_getClassName()), 0, 0, 1); + pop.addCommand(StringPrintfW(L"Id : %s", o->guiobject_getId()), 0, 0, 1); + RECT r; + guiobject_getRootWnd()->getNonClientRect(&r); + pop.addCommand(StringPrintfW(L"Coordinates : %d,%d (%d x %d)", r.left, r.top, r.right-r.left, r.bottom-r.top), 0, 0, 1); + int _x, _y, _w, _h, _rx, _ry, _rw, _rh; + guiobject_getGuiPosition(&_x, &_y, &_w, &_h, &_rx, &_ry, &_rw, &_rh); + pop.addCommand(StringPrintfW(L"GuiPos : x=%d relatx=%d, y=%d relaty=%d, w=%d relatw=%d, h=%d relath=%d", _x, _rx, _y, _ry, _w, _rw, _h, _rh), 0, 0, 1); + + if (guiobject_wantTranslation() == 2) + { + if (!_wcsicmp(o->guiobject_getScriptObject()->vcpu_getClassName(), L"Text")) + { + pop.addCommand(StringPrintfW(L"StringEntry : %s", guiobject_getXmlParam(L"text")), 0, 0, 1); + } + else if (!_wcsicmp(o->guiobject_getScriptObject()->vcpu_getClassName(), L"TitleBar")) + { + pop.addCommand(StringPrintfW(L"StringEntry : %s", guiobject_getXmlParam(L"title")), 0, 0, 1); + } + } + guiobject_getRootWnd()->clientToScreen(&x, &y); + pop.popAtXY(x, y, 1); +} + +#ifdef WASABI_COMPILE_CONFIG + +void GuiObjectI::guiobject_setCfgAttrib(CfgItem *item, const wchar_t *name) +{ + if (cfgitem) viewer_delViewItem(cfgitem); + cfgitem = item; + cfgattrname = name; + if (cfgitem) { + viewer_addViewItem(cfgitem); + } + ifc_window *mw = guiobject_getRootWnd(); + if (mw != NULL) { + if (mw->isPostOnInit()) + dataChanged(); + } +} + +int GuiObjectI::viewer_onEvent(CfgItem *item, int event, intptr_t param, void *ptr, size_t ptrlen) { + if (item == cfgitem) + dataChanged(); + return 1; +} + +void GuiObjectI::dataChanged() { + ifc_window *w = guiobject_getRootWnd(); + if (w != NULL) { + w->onAction(L"reload_config", NULL, -1, -1, 0, 0, NULL, 0, w); + } + GuiObject_ScriptMethods::onCfgChanged(SCRIPT_CALL, guiobject_getScriptObject()); +} + + +CfgItem *GuiObjectI::guiobject_getCfgItem() { + return cfgitem; +} + +const wchar_t *GuiObjectI::guiobject_getCfgAttrib() +{ + return cfgattrname; +} +#endif //WASABI_COMPILE_CONFIG + +void GuiObjectI::guiobject_onChar(wchar_t c) +{ + wchar_t _c[2]=L"X"; + _c[0]=c; + GuiObject_ScriptMethods::onChar(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_STRING(_c)); +} + +void GuiObjectI::guiobject_onKeyDown(int vkcode) { + GuiObject_ScriptMethods::onKeyDown(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_INT(vkcode)); +} + +void GuiObjectI::guiobject_onKeyUp(int vkcode) { + GuiObject_ScriptMethods::onKeyUp(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_INT(vkcode)); +} + +void GuiObjectI::guiobject_setCursor(const wchar_t *c) +{ + ifc_window *w = guiobject_getRootWnd(); +#ifdef _WIN32 + if (w != NULL) { + delete cursor; + cursor = new SkinCursor(c); + w->setDefaultCursor(cursor); + } +#else +#warning port me +#endif +} + +void GuiObjectI::guiobject_setEnabled(int en) { + ifc_window *w = guiobject_getRootWnd(); + if (w != NULL) w->setEnabled(en); +} + +int GuiObjectI::guiobject_wantTranslation() +{ + return translate; +} +int GuiObjectI::guiobject_dragEnter(ifc_window *sourceWnd) +{ + GuiObject_ScriptMethods::onDragEnter(SCRIPT_CALL, guiobject_getScriptObject()); + return 1; +} + +int GuiObjectI::guiobject_dragOver(int x, int y, ifc_window *sourceWnd) +{ + GuiObject_ScriptMethods::onDragOver(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_INT(x), MAKE_SCRIPT_INT(y) ); + return 1; +} + +int GuiObjectI::guiobject_dragLeave(ifc_window *sourceWnd) +{ + GuiObject_ScriptMethods::onDragLeave(SCRIPT_CALL, guiobject_getScriptObject()); + return 1; +} + +GuiObjectScriptController _guiController; +GuiObjectScriptController *guiController = &_guiController; + +// -- Functions table ------------------------------------- +function_descriptor_struct GuiObjectScriptController::exportedFunction[] = { + {L"getId", 0, (void*)GuiObject_ScriptMethods::getId }, + {L"show", 0, (void*)GuiObject_ScriptMethods::show }, + {L"hide", 0, (void*)GuiObject_ScriptMethods::hide }, + {L"onSetVisible", 1, (void*)GuiObject_ScriptMethods::onSetVisible}, + {L"isVisible", 0, (void*)GuiObject_ScriptMethods::isvisible }, + {L"setAlpha", 1, (void*)GuiObject_ScriptMethods::setAlpha }, + {L"getAlpha", 0, (void*)GuiObject_ScriptMethods::getAlpha }, + {L"setActiveAlpha", 1, (void*)GuiObject_ScriptMethods::setActiveAlpha }, + {L"getActiveAlpha", 0, (void*)GuiObject_ScriptMethods::getActiveAlpha }, + {L"setInactiveAlpha", 1, (void*)GuiObject_ScriptMethods::setInactiveAlpha }, + {L"getInactiveAlpha", 0, (void*)GuiObject_ScriptMethods::getInactiveAlpha }, + {L"onLeftButtonDown", 2, (void*)GuiObject_ScriptMethods::onLeftButtonDown }, + {L"onLeftButtonUp", 2, (void*)GuiObject_ScriptMethods::onLeftButtonUp }, + {L"onRightButtonDown", 2, (void*)GuiObject_ScriptMethods::onRightButtonDown }, + {L"onRightButtonUp", 2, (void*)GuiObject_ScriptMethods::onRightButtonUp }, + {L"onRightButtonDblClk", 2, (void*)GuiObject_ScriptMethods::onRightButtonDblClk }, + {L"onLeftButtonDblClk", 2, (void*)GuiObject_ScriptMethods::onLeftButtonDblClk }, + {L"onMouseWheelUp", 2, (void*)GuiObject_ScriptMethods::onMouseWheelUp }, + {L"onMouseWheelDown", 2, (void*)GuiObject_ScriptMethods::onMouseWheelDown }, + {L"onMouseMove", 2, (void*)GuiObject_ScriptMethods::onMouseMove }, + {L"onEnterArea", 0, (void*)GuiObject_ScriptMethods::onEnterArea }, + {L"onLeaveArea", 0, (void*)GuiObject_ScriptMethods::onLeaveArea }, + {L"isMouseOverRect", 0, (void*)GuiObject_ScriptMethods::isMouseOverRect}, + {L"onStartup", 0, (void*)GuiObject_ScriptMethods::onStartup }, + {L"onChar", 1, (void*)GuiObject_ScriptMethods::onChar }, + {L"onKeyDown", 1, (void*)GuiObject_ScriptMethods::onKeyDown}, + {L"onKeyUp", 1, (void*)GuiObject_ScriptMethods::onKeyUp}, + {L"setEnabled", 1, (void*)GuiObject_ScriptMethods::setEnabled }, + {L"getEnabled", 0, (void*)GuiObject_ScriptMethods::getEnabled }, + {L"onEnable", 1, (void*)GuiObject_ScriptMethods::onEnable }, + {L"resize", 4, (void*)GuiObject_ScriptMethods::resize }, + {L"onResize", 4, (void*)GuiObject_ScriptMethods::onResize }, + {L"isMouseOver", 2, (void*)GuiObject_ScriptMethods::isMouseOver }, + {L"getLeft", 0, (void*)GuiObject_ScriptMethods::getLeft }, + {L"getTop", 0, (void*)GuiObject_ScriptMethods::getTop }, + {L"getWidth", 0, (void*)GuiObject_ScriptMethods::getWidth }, + {L"getHeight", 0, (void*)GuiObject_ScriptMethods::getHeight }, + {L"getGuiX", 0, (void*)GuiObject_ScriptMethods::getGuiX }, + {L"getGuiY", 0, (void*)GuiObject_ScriptMethods::getGuiY }, + {L"getGuiW", 0, (void*)GuiObject_ScriptMethods::getGuiW }, + {L"getGuiH", 0, (void*)GuiObject_ScriptMethods::getGuiH }, + {L"getGuiRelatX", 0, (void*)GuiObject_ScriptMethods::getGuiRelatX }, + {L"getGuiRelatY", 0, (void*)GuiObject_ScriptMethods::getGuiRelatX }, + {L"getGuiRelatW", 0, (void*)GuiObject_ScriptMethods::getGuiRelatX }, + {L"getGuiRelatH", 0, (void*)GuiObject_ScriptMethods::getGuiRelatX }, + {L"clientToScreenX", 1, (void*)GuiObject_ScriptMethods::clientToScreenX }, + {L"clientToScreenY", 1, (void*)GuiObject_ScriptMethods::clientToScreenY }, + {L"clientToScreenW", 1, (void*)GuiObject_ScriptMethods::clientToScreenW }, + {L"clientToScreenH", 1, (void*)GuiObject_ScriptMethods::clientToScreenH }, + {L"screenToClientX", 1, (void*)GuiObject_ScriptMethods::screenToClientX }, + {L"screenToClientY", 1, (void*)GuiObject_ScriptMethods::screenToClientY }, + {L"screenToClientW", 1, (void*)GuiObject_ScriptMethods::screenToClientW }, + {L"screenToClientH", 1, (void*)GuiObject_ScriptMethods::screenToClientH }, + {L"setTargetX", 1, (void*)GuiObject_ScriptMethods::setTargetX }, + {L"setTargetY", 1, (void*)GuiObject_ScriptMethods::setTargetY }, + {L"setTargetW", 1, (void*)GuiObject_ScriptMethods::setTargetW }, + {L"setTargetH", 1, (void*)GuiObject_ScriptMethods::setTargetH }, + {L"setTargetA", 1, (void*)GuiObject_ScriptMethods::setTargetA }, + {L"setTargetSpeed", 1, (void*)GuiObject_ScriptMethods::setTargetSpeed }, + {L"gotoTarget", 0, (void*)GuiObject_ScriptMethods::gotoTarget }, + {L"onTargetReached", 0, (void*)GuiObject_ScriptMethods::onTargetReached }, + {L"cancelTarget", 0, (void*)GuiObject_ScriptMethods::cancelTarget }, + {L"reverseTarget", 1, (void*)GuiObject_ScriptMethods::reverseTarget }, + {L"isGoingToTarget", 0, (void*)GuiObject_ScriptMethods::movingToTarget }, + {L"setXmlParam", 2, (void*)GuiObject_ScriptMethods::setXmlParam }, + {L"getXmlParam", 1, (void*)GuiObject_ScriptMethods::getXmlParam }, + {L"init", 1, (void*)GuiObject_ScriptMethods::init }, + {L"bringToFront", 0, (void*)GuiObject_ScriptMethods::bringToFront }, + {L"bringToBack", 0, (void*)GuiObject_ScriptMethods::bringToBack }, + {L"bringAbove", 1, (void*)GuiObject_ScriptMethods::bringAbove }, + {L"bringBelow", 1, (void*)GuiObject_ScriptMethods::bringBelow }, + {L"isActive", 0, (void*)GuiObject_ScriptMethods::isActive}, + {L"getParent", 0, (void*)GuiObject_ScriptMethods::getParent}, + {L"getTopParent", 0, (void*)GuiObject_ScriptMethods::getTopParent}, + {L"getInterface", 1, (void*)GuiObject_ScriptMethods::getInterface}, + {L"onAction", 7, (void*)GuiObject_ScriptMethods::onAction}, +#ifdef WASABI_COMPILE_WNDMGR + {L"getParentLayout", 0, (void*)GuiObject_ScriptMethods::getParentLayout}, + {L"runModal", 0, (void*)GuiObject_ScriptMethods::runModal}, + {L"endModal", 1, (void*)GuiObject_ScriptMethods::endModal}, + {L"popParentLayout", 0, (void*)GuiObject_ScriptMethods::popParentLayout}, + {L"setStatusText", 2, (void*)GuiObject_ScriptMethods::setStatusText}, +#endif + {L"findObject", 1, (void*)GuiObject_ScriptMethods::findObject}, + {L"findObjectXY", 2, (void*)GuiObject_ScriptMethods::findObjectXY}, + {L"getName", 0, (void*)GuiObject_ScriptMethods::getName}, + {L"getAutoWidth", 0, (void*)GuiObject_ScriptMethods::getAutoWidth }, + {L"getAutoHeight", 0, (void*)GuiObject_ScriptMethods::getAutoHeight }, + {L"setFocus", 0, (void*)GuiObject_ScriptMethods::setFocus}, + {L"onGetFocus", 0, (void*)GuiObject_ScriptMethods::onGetFocus}, + {L"onKillFocus", 0, (void*)GuiObject_ScriptMethods::onKillFocus}, + {L"sendAction", 6, (void*)GuiObject_ScriptMethods::sendAction}, + {L"onAccelerator", 1, (void*)GuiObject_ScriptMethods::onAccelerator}, +#ifdef WASABI_COMPILE_CONFIG + {L"cfg_getInt", 0, (void*)GuiObject_ScriptMethods::cfgGetInt }, + {L"cfg_setInt", 1, (void*)GuiObject_ScriptMethods::cfgSetInt }, + {L"cfg_getFloat", 0, (void*)GuiObject_ScriptMethods::cfgGetFloat }, + {L"cfg_setFloat", 1, (void*)GuiObject_ScriptMethods::cfgSetFloat }, + {L"cfg_getString", 0, (void*)GuiObject_ScriptMethods::cfgGetString }, + {L"cfg_setString", 1, (void*)GuiObject_ScriptMethods::cfgSetString }, + {L"cfg_onDataChanged", 0, (void*)GuiObject_ScriptMethods::onCfgChanged }, + {L"cfg_getItemGuid", 0, (void*)GuiObject_ScriptMethods::cfgGetGuid}, + {L"cfg_getAttributeName", 0, (void*)GuiObject_ScriptMethods::cfgGetAttributeName}, +#endif + {L"onDragEnter", 0, (void*)GuiObject_ScriptMethods::onDragEnter }, + {L"onDragOver", 2, (void*)GuiObject_ScriptMethods::onDragOver}, + {L"onDragLeave", 0, (void*)GuiObject_ScriptMethods::onDragLeave}, +}; + +const wchar_t *GuiObjectScriptController::getClassName() { + return L"GuiObject"; +} + +const wchar_t *GuiObjectScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObjectController *GuiObjectScriptController::getAncestorController() { + return rootScriptObjectController;} + +int GuiObjectScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *GuiObjectScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID GuiObjectScriptController::getClassGuid() { + return guiObjectGuid; +} + +int GuiObjectScriptController::getInstantiable() { + return 1; +} + +ScriptObject *GuiObjectScriptController::instantiate() { + GuiObjectWnd *w = new GuiObjectWnd; + ASSERT(w != NULL); + return w->getScriptObject(); +} + +void GuiObjectScriptController::destroy(ScriptObject *o) { + GuiObjectWnd *w = static_cast(o->vcpu_getInterface(guiObjectWndGuid)); + ASSERT(w != NULL); + delete w; +} + +void *GuiObjectScriptController::encapsulate(ScriptObject *o) { + return static_cast(new GuiObjectI(o)); +} + +void GuiObjectScriptController::deencapsulate(void *o) { + delete static_cast(o); +} + +// ---------------------------------------------------------------------------------------------------------------------------------- + +// returns a new ScriptString object containing the xml id of this object +scriptVar GuiObject_ScriptMethods::getId(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + + if (g) + return MAKE_SCRIPT_STRING(g->guiobject_getId()); + + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar GuiObject_ScriptMethods::hide(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = g->guiobject_getRootWnd(); + if (w) + w->setVisible(0); + } + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::show(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = g->guiobject_getRootWnd(); + if (w) + w->setVisible(1); + } + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::isvisible(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = g->guiobject_getRootWnd(); + if (w) return MAKE_SCRIPT_BOOLEAN(w->isVisible()); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar GuiObject_ScriptMethods::getAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) return MAKE_SCRIPT_INT(g->guiobject_getAlpha()); + return MAKE_SCRIPT_INT(255); +} + +scriptVar GuiObject_ScriptMethods::setAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_setAlpha(GET_SCRIPT_INT(a)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::getActiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) return MAKE_SCRIPT_INT(g->guiobject_getActiveAlpha()); + return MAKE_SCRIPT_INT(255); +} + +scriptVar GuiObject_ScriptMethods::setActiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_setActiveAlpha(GET_SCRIPT_INT(a)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::getInactiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) return MAKE_SCRIPT_INT(g->guiobject_getInactiveAlpha()); + return MAKE_SCRIPT_INT(255); +} + +scriptVar GuiObject_ScriptMethods::setInactiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_setInactiveAlpha(GET_SCRIPT_INT(a)); + RETURN_SCRIPT_VOID; +} + + +scriptVar GuiObject_ScriptMethods::onMouseMove(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2(o, guiController, x, y); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, x, y); +} + +scriptVar GuiObject_ScriptMethods::onLeftButtonDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2(o, guiController, x, y); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, x, y); +} + +scriptVar GuiObject_ScriptMethods::onLeftButtonUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2(o, guiController, x, y); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, x, y); +} + +scriptVar GuiObject_ScriptMethods::onRightButtonDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2(o, guiController, x, y); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, x, y); +} + +scriptVar GuiObject_ScriptMethods::onRightButtonUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2(o, guiController, x, y); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, x, y); +} + +scriptVar GuiObject_ScriptMethods::onLeftButtonDblClk(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2(o, guiController, x, y); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, x, y); +} + +scriptVar GuiObject_ScriptMethods::onRightButtonDblClk(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2(o, guiController, x, y); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, x, y); +} + +scriptVar GuiObject_ScriptMethods::onMouseWheelUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar clicked, scriptVar lines) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2(o, guiController, clicked, lines); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, clicked, lines); +} + +scriptVar GuiObject_ScriptMethods::onMouseWheelDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar clicked, scriptVar lines) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2(o, guiController, clicked, lines); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, clicked, lines); +} + +scriptVar GuiObject_ScriptMethods::onEnterArea(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, guiController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar GuiObject_ScriptMethods::onLeaveArea(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, guiController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar GuiObject_ScriptMethods::setEnabled(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&v)); + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *b = g->guiobject_getRootWnd(); + if (b) b->setEnabled(GET_SCRIPT_BOOLEAN(v)); + } + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::getEnabled(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *b = g->guiobject_getRootWnd(); + if (b) return MAKE_SCRIPT_BOOLEAN(b->isEnabled()); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar GuiObject_ScriptMethods::onEnable(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1(o, guiController, v); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, v); +} + +scriptVar GuiObject_ScriptMethods::onSetVisible(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1(o, guiController, v); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, v); +} + +scriptVar GuiObject_ScriptMethods::onResize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y, scriptVar w, scriptVar h) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS4(o, guiController, x, y, w, h); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT4(o, x, y, w, h); +} + +scriptVar GuiObject_ScriptMethods::resize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y, scriptVar w, scriptVar h) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&x)); + ASSERT(SOM::isNumeric(&y)); + ASSERT(SOM::isNumeric(&w)); + ASSERT(SOM::isNumeric(&h)); + GuiObject *go = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (go) { + int _x = SOM::makeInt(&x); + int _y = SOM::makeInt(&y); + int _w = SOM::makeInt(&w); + int _h = SOM::makeInt(&h); + ifc_window *b = go->guiobject_getRootWnd(); + if (b) b->resize(_x, _y, _w, _h); + go->guiobject_setGuiPosition(_x == NOCHANGE ? &_x : NULL, _y == NOCHANGE ? &_y : NULL, _w == NOCHANGE ? &_w : NULL, _h == NOCHANGE ? &_h : NULL, NULL, NULL, NULL, NULL); + if (b && b->getInterface(layoutGuid)) { + b->cascadeRepaint(); + ((Layout *)b->getInterface(layoutGuid))->savePosition(); + } + } + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::isMouseOver(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&x)); + ASSERT(SOM::isNumeric(&y)); + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *b = g->guiobject_getRootWnd(); + POINT pt={GET_SCRIPT_INT(x), GET_SCRIPT_INT(y)}; + b->clientToScreen((int *)&pt.x, (int *)&pt.y); + return MAKE_SCRIPT_BOOLEAN(WASABI_API_WND->rootWndFromPoint(&pt) == b); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar GuiObject_ScriptMethods::getLeft(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *go = static_cast(o->vcpu_getInterface(guiObjectGuid)); + ifc_window *b = go->guiobject_getRootWnd(); + int r=0; + if (b && b->isInited()) { + POINT pt; + b->getPosition(&pt); + r = pt.x; + } else if (b && !b->isInited()) { + go->guiobject_getGuiPosition(&r, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + } + return MAKE_SCRIPT_INT(r); +} + +scriptVar GuiObject_ScriptMethods::movingToTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) return MAKE_SCRIPT_BOOLEAN(g->guiobject_movingToTarget()); + RETURN_SCRIPT_ZERO; +} + +scriptVar GuiObject_ScriptMethods::cancelTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g && g->guiobject_movingToTarget()) g->guiobject_cancelTarget(); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::reverseTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_reverseTarget(GET_SCRIPT_INT(r)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::getTop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *go = static_cast(o->vcpu_getInterface(guiObjectGuid)); + ifc_window *b = go->guiobject_getRootWnd(); + int r=0; + if (b && b->isInited()) { + POINT pt; + b->getPosition(&pt); + r = pt.y; + } else if (b && !b->isInited()) { + go->guiobject_getGuiPosition(NULL, &r, NULL, NULL, NULL, NULL, NULL, NULL); + } + return MAKE_SCRIPT_INT(r); +} + +scriptVar GuiObject_ScriptMethods::getWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *go = static_cast(o->vcpu_getInterface(guiObjectGuid)); + ifc_window *b = go->guiobject_getRootWnd(); + int r=0; + if (b && b->isInited()) { + RECT rc; + b->getClientRect(&rc); + r = rc.right-rc.left; + } else if (b && !b->isInited()) { + go->guiobject_getGuiPosition(NULL, NULL, &r, NULL, NULL, NULL, NULL, NULL); + } + return MAKE_SCRIPT_INT(r); +} + +scriptVar GuiObject_ScriptMethods::getHeight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *go = static_cast(o->vcpu_getInterface(guiObjectGuid)); + ifc_window *b = go->guiobject_getRootWnd(); + int r=0; + if (b && b->isInited()) { + RECT rc; + b->getClientRect(&rc); + r = rc.bottom-rc.top; + } else if (b && !b->isInited()) { + go->guiobject_getGuiPosition(NULL, NULL, NULL, &r, NULL, NULL, NULL, NULL); + } + return MAKE_SCRIPT_INT(r); +} + +scriptVar GuiObject_ScriptMethods::setTargetX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&x)); + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_setTargetX(GET_SCRIPT_INT(x)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::setTargetY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar y) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&y)); + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_setTargetY(GET_SCRIPT_INT(y)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::setTargetW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar w) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&w)); + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_setTargetW(GET_SCRIPT_INT(w)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::setTargetH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar h) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&h)); + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_setTargetH(GET_SCRIPT_INT(h)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::setTargetA(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&a)); + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_setTargetA(GET_SCRIPT_INT(a)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::setTargetSpeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&s)); + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_setTargetSpeed(GET_SCRIPT_FLOAT(s)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::gotoTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_gotoTarget(); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::bringToFront(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_bringToFront(); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::bringToBack(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_bringToBack(); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::bringAbove(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj) { + SCRIPT_FUNCTION_INIT; + ASSERT(obj.data.odata != NULL); + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_bringAbove((static_cast(GET_SCRIPT_OBJECT_AS(obj, guiObjectGuid)))); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::bringBelow(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj) { + SCRIPT_FUNCTION_INIT; + ASSERT(obj.data.odata != NULL); + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_bringBelow((static_cast(GET_SCRIPT_OBJECT_AS(obj, guiObjectGuid)))); + RETURN_SCRIPT_VOID; +} + + +scriptVar GuiObject_ScriptMethods::onTargetReached(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, guiController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar GuiObject_ScriptMethods::setXmlParam(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar param, scriptVar value) +{ + SCRIPT_FUNCTION_INIT; + XmlObject *x = static_cast(o->vcpu_getInterface(xmlObjectGuid)); + if (x) + x->setXmlParam(GET_SCRIPT_STRING(param), GET_SCRIPT_STRING(value)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::getXmlParam(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar param) { + SCRIPT_FUNCTION_INIT; + const wchar_t *rt = NULL; + XmlObject *x = static_cast(o->vcpu_getInterface(xmlObjectGuid)); + if (x) { + int r = x->getXmlParam(GET_SCRIPT_STRING(param)); + if (r != -1) + rt = x->getXmlParamValue(r); + } + if (rt == NULL) + rt = L""; // returning null in a string is kinda bad, y'know? + + return MAKE_SCRIPT_STRING(rt); +} + +scriptVar GuiObject_ScriptMethods::onStartup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, guiController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar GuiObject_ScriptMethods::getGuiX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_getGuiPosition(&v, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::getGuiY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_getGuiPosition(NULL, &v, NULL, NULL, NULL, NULL, NULL, NULL); + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::getGuiW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_getGuiPosition(NULL, NULL, &v, NULL, NULL, NULL, NULL, NULL); + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::getGuiH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_getGuiPosition(NULL, NULL, NULL, &v, NULL, NULL, NULL, NULL); + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::getGuiRelatX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_getGuiPosition(NULL, NULL, NULL, NULL, &v, NULL, NULL, NULL); + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::getGuiRelatY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_getGuiPosition(NULL, NULL, NULL, NULL, NULL, &v, NULL, NULL); + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::getGuiRelatW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_getGuiPosition(NULL, NULL, NULL, NULL, NULL, NULL, &v, NULL); + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::getGuiRelatH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_getGuiPosition(NULL, NULL, NULL, NULL, NULL, NULL, NULL, &v); + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::clientToScreenX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = g->guiobject_getRootWnd(); + if (w != NULL) { + v = GET_SCRIPT_INT(x); + w->clientToScreen(&v, NULL); + } + } + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::clientToScreenY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar y) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = g->guiobject_getRootWnd(); + if (w != NULL) { + v = GET_SCRIPT_INT(y); + w->clientToScreen(NULL, &v); + } + } + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::clientToScreenW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar w) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *wn = g->guiobject_getRootWnd(); + if (wn != NULL) { + v = GET_SCRIPT_INT(w); + double rr = wn->getRenderRatio(); + v = (int)((double)(v) * rr); + } + } + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::clientToScreenH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar h) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = g->guiobject_getRootWnd(); + if (w != NULL) { + v = GET_SCRIPT_INT(h); + double rr = w->getRenderRatio(); + v = (int)((double)(v) * rr); + } + } + return MAKE_SCRIPT_INT(v); +} + + +scriptVar GuiObject_ScriptMethods::screenToClientX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = g->guiobject_getRootWnd(); + if (w != NULL) { + v = GET_SCRIPT_INT(x); + w->screenToClient(&v, NULL); + } + } + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::screenToClientY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar y) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = g->guiobject_getRootWnd(); + if (w != NULL) { + v = GET_SCRIPT_INT(y); + w->screenToClient(NULL, &v); + } + } + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::screenToClientW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar w) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *wn = g->guiobject_getRootWnd(); + if (wn != NULL) { + v = GET_SCRIPT_INT(w); + double rr = wn->getRenderRatio(); + v = (int)((double)(v) / rr); + } + } + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::screenToClientH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar h) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = g->guiobject_getRootWnd(); + if (w != NULL) { + v = GET_SCRIPT_INT(h); + double rr = w->getRenderRatio(); + v = (int)((double)(v) / rr); + } + } + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::isActive(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = (static_cast(o->vcpu_getInterface(guiObjectGuid)))->guiobject_getRootWnd(); + if (w) return MAKE_SCRIPT_INT(w->isActive()); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar GuiObject_ScriptMethods::getParent(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *go = (static_cast(o->vcpu_getInterface(guiObjectGuid))); + if (go) { + GuiObject *g = go->guiobject_getParent(); + ScriptObject *so = NULL; + if (g != NULL) + so = g->guiobject_getScriptObject(); + return MAKE_SCRIPT_OBJECT(so); + } + RETURN_SCRIPT_VOID; +} + +#ifdef WASABI_COMPILE_WNDMGR +scriptVar GuiObject_ScriptMethods::getParentLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *go = (static_cast(o->vcpu_getInterface(guiObjectGuid))); + if (go) { + Layout *l = go->guiobject_getParentLayout(); + return MAKE_SCRIPT_OBJECT(l ? l->getGuiObject()->guiobject_getScriptObject() : NULL); + } + RETURN_SCRIPT_VOID; +} +#endif + +scriptVar GuiObject_ScriptMethods::getTopParent(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *go = (static_cast(o->vcpu_getInterface(guiObjectGuid))); + if (go) { + GuiObject *l = go->guiobject_getTopParent(); + return MAKE_SCRIPT_OBJECT(l ? l->guiobject_getScriptObject() : NULL); + } + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::getAutoWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *go = (static_cast(o->vcpu_getInterface(guiObjectGuid))); + int v = 0; + if (go) { v = go->guiobject_getRootWnd()->getPreferences(SUGGESTED_W); if (v == AUTOWH) v = go->guiobject_getAutoWidth(); } + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::getAutoHeight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *go = (static_cast(o->vcpu_getInterface(guiObjectGuid))); + int v = 0; + if (go) { v = go->guiobject_getRootWnd()->getPreferences(SUGGESTED_H); if (v == AUTOWH) v = go->guiobject_getAutoHeight(); } + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::init(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar parentGroup) { + SCRIPT_FUNCTION_INIT; + ASSERT(parentGroup.data.odata != NULL); + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + Group *pg = static_cast(GET_SCRIPT_OBJECT_AS(parentGroup, groupGuid)); + pg->addChild(g); + if (!g->guiobject_getRootWnd()->isInited()) + g->guiobject_getRootWnd()->init(pg); + } + RETURN_SCRIPT_VOID; +} + +#ifdef WASABI_COMPILE_WNDMGR +scriptVar GuiObject_ScriptMethods::runModal(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int r=0; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) r = g->guiobject_runModal(); + return MAKE_SCRIPT_INT(r); +} + +scriptVar GuiObject_ScriptMethods::endModal(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar retcode) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_endModal(GET_SCRIPT_INT(retcode)); + RETURN_SCRIPT_VOID; +} +#endif + +scriptVar GuiObject_ScriptMethods::setFocus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = g->guiobject_getRootWnd(); + if (w != NULL) { + w->setFocus(); + } + } + RETURN_SCRIPT_VOID; +} + +#ifdef WASABI_COMPILE_WNDMGR +scriptVar GuiObject_ScriptMethods::popParentLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_popParentLayout(); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::setStatusText(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar text, scriptVar overlay) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) + g->guiobject_setStatusText(GET_SCRIPT_STRING(text), GET_SCRIPT_INT(overlay)); + RETURN_SCRIPT_VOID; +} +#endif + +scriptVar GuiObject_ScriptMethods::findObject(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar id) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + ScriptObject *s = NULL; + if (g) { + GuiObject *o = g->guiobject_findObject(GET_SCRIPT_STRING(id)); + if (o != NULL) s = o->guiobject_getScriptObject(); + } + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar GuiObject_ScriptMethods::findObjectXY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + ScriptObject *s = NULL; + if (g) { + GuiObject *o = g->guiobject_findObjectXY(GET_SCRIPT_INT(x), GET_SCRIPT_INT(y)); + if (o != NULL) s = o->guiobject_getScriptObject(); + } + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar GuiObject_ScriptMethods::getName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) + return MAKE_SCRIPT_STRING(g->guiobject_getName()); + + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar GuiObject_ScriptMethods::getMover(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int r = 0; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) r = g->guiobject_getMover(); + return MAKE_SCRIPT_INT(r); +} + +scriptVar GuiObject_ScriptMethods::setMover(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_setMover(GET_SCRIPT_INT(i)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::setDropTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar targ) { + GuiObject *g = static_cast(o->vcpu_getInterface(guiObjectGuid)); + const wchar_t *s = GET_SCRIPT_STRING(targ); + if (g) + g->guiobject_setDropTarget(s); + RETURN_SCRIPT_VOID; +} + +#ifdef WASABI_COMPILE_CONFIG +scriptVar GuiObject_ScriptMethods::cfgGetInt(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + GuiObject *go = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (go) return MAKE_SCRIPT_INT(go->guiobject_getCfgInt()); + return MAKE_SCRIPT_INT(0); +} + +scriptVar GuiObject_ScriptMethods::cfgSetInt(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) { + SCRIPT_FUNCTION_INIT + ASSERT(SOM::isNumeric(&v)); + GuiObject *go = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (go) go->guiobject_setCfgInt(GET_SCRIPT_INT(v)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::cfgGetString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + GuiObject *go = static_cast(o->vcpu_getInterface(guiObjectGuid)); + + if (go) + return MAKE_SCRIPT_STRING(go->guiobject_getCfgString()); + + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar GuiObject_ScriptMethods::cfgSetString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) { + SCRIPT_FUNCTION_INIT + GuiObject *go = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (go) go->guiobject_setCfgString(GET_SCRIPT_STRING(v)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::cfgGetFloat(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + GuiObject *go = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (go) return MAKE_SCRIPT_FLOAT(go->guiobject_getCfgFloat()); + return MAKE_SCRIPT_FLOAT(0); +} + +scriptVar GuiObject_ScriptMethods::cfgSetFloat(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) { + SCRIPT_FUNCTION_INIT + GuiObject *go = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (go) go->guiobject_setCfgFloat(GET_SCRIPT_FLOAT(v)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::cfgGetGuid(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + GuiObject *go = static_cast(o->vcpu_getInterface(guiObjectGuid)); + if (go) { + CfgItem *i = go->guiobject_getCfgItem(); + if (i != NULL) + { + GUID guid = i->getGuid(); + nsGUID::toCharW(guid, txt); + return MAKE_SCRIPT_STRING(txt); + } + } + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar GuiObject_ScriptMethods::cfgGetAttributeName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + GuiObject *go = static_cast(o->vcpu_getInterface(guiObjectGuid)); + + if (go) + return MAKE_SCRIPT_STRING(go->guiobject_getCfgAttrib()); + + return MAKE_SCRIPT_STRING(L""); +} +#endif + +scriptVar GuiObject_ScriptMethods::isMouseOverRect(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + GuiObject *go = static_cast(o->vcpu_getInterface(guiObjectGuid)); + int r = 0; + if (go) { + ifc_window *w = go->guiobject_getRootWnd(); + if (w != NULL) { + RECT rc; + int x, y; + w->getWindowRect(&rc); + Wasabi::Std::getMousePos(&x, &y); + if (x >= rc.left && x <= rc.right && y >= rc.top && y <= rc.bottom) r = 1; + } + } + return MAKE_SCRIPT_BOOLEAN(r); +} + +#ifdef WASABI_COMPILE_CONFIG +scriptVar GuiObject_ScriptMethods::onCfgChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, guiController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} +#endif + +scriptVar GuiObject_ScriptMethods::onChar(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar c) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1(o, guiController, c); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, c); +} + +scriptVar GuiObject_ScriptMethods::onKeyDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar c) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1(o, guiController, c); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, c); +} + +scriptVar GuiObject_ScriptMethods::onKeyUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar c) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1(o, guiController, c); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, c); +} + +scriptVar GuiObject_ScriptMethods::onGetFocus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, guiController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar GuiObject_ScriptMethods::onKillFocus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, guiController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar GuiObject_ScriptMethods::sendAction(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar action, scriptVar param, scriptVar x, scriptVar y, scriptVar p1, scriptVar p2) { + SCRIPT_FUNCTION_INIT + GuiObject *go = static_cast(o->vcpu_getInterface(guiObjectGuid)); + int a = 0; + if (go) { + ifc_window *w = go->guiobject_getRootWnd(); + if (w!=NULL) { + a = w->onAction(GET_SCRIPT_STRING(action), GET_SCRIPT_STRING(param), GET_SCRIPT_INT(x), GET_SCRIPT_INT(y), GET_SCRIPT_INT(p1), GET_SCRIPT_INT(p2)); + } + } + return MAKE_SCRIPT_INT(a); +} + +scriptVar GuiObject_ScriptMethods::onAccelerator(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar accel) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1(o, guiController, accel); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, accel); +} + +scriptVar GuiObject_ScriptMethods::onAction(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar action, scriptVar param, scriptVar x, scriptVar y, scriptVar p1, scriptVar p2, scriptVar source) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS7(o, guiController, action, param, x, y, p1, p2, source); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT7(o, action, param, x, y, p1, p2, source); +} + +#ifdef WASABI_COMPILE_CONFIG +int GuiObjectI::guiobject_getCfgInt() +{ + if (!cfgitem) + return 0; + return + cfgitem->getDataAsInt(cfgattrname); +} + +void GuiObjectI::guiobject_setCfgInt(int i) { + if (!cfgitem) return; + cfgitem->setDataAsInt(cfgattrname, i); +} + +float GuiObjectI::guiobject_getCfgFloat() { + if (!cfgitem) return 0; + return (float)cfgitem->getDataAsFloat(cfgattrname); +} + +void GuiObjectI::guiobject_setCfgFloat(float f) { + if (!cfgitem) return; + cfgitem->setDataAsFloat(cfgattrname, f); +} + +const wchar_t *GuiObjectI::guiobject_getCfgString() +{ + static StringW blah; + if (!cfgitem) return 0; + cfgitem->getData(cfgattrname, txt, 4096); + return txt; +} + +void GuiObjectI::guiobject_setCfgString(const wchar_t *s) +{ + if (!cfgitem) + return; + cfgitem->setData(cfgattrname, s); +} + +void GuiObjectI::setCfgAttr(const wchar_t *strvalue) +{ + ParamParser pp(strvalue); + if (pp.getNumItems() < 2) return; + + GUID g = nsGUID::fromCharW(pp.enumItem(0)); + if (g == INVALID_GUID) return; + CfgItem *i = WASABI_API_CONFIG->config_getCfgItemByGuid(g); + if (i == NULL) return; + cfgattrname = pp.enumItem(1); + guiobject_setCfgAttrib(i, cfgattrname); +} + +int GuiObjectI::guiobject_hasCfgAttrib() { + return (guiobject_getCfgItem() && guiobject_getCfgAttrib()); +} +#endif + +GuiObject *GuiObjectI::guiobject_findObject(const wchar_t *id) +{ + ifc_window *me = guiobject_getRootWnd(); + ifc_window *w = me->findWindow(id); + if (w != NULL) return w->getGuiObject(); + return NULL; +} + +GuiObject *GuiObjectI::guiobject_findObjectXY(int x, int y) { + ifc_window *me = guiobject_getRootWnd(); + POINT pt={x,y}; + me->clientToScreen((int *)&pt.x, (int *)&pt.y); + ifc_window *w = WASABI_API_WND->rootWndFromPoint(&pt); + if (w != NULL) return w->getGuiObject(); + return NULL; +} + +GuiObject *GuiObjectI::guiobject_findObjectByInterface(GUID interface_guid) { + ifc_window *me = guiobject_getRootWnd(); + ifc_window *w = me->findWindowByInterface(interface_guid); + if (w != NULL) return w->getGuiObject(); + return NULL; +} + +GuiObject *GuiObjectI::guiobject_findObjectByCallback(FindObjectCallback *cb) { + ifc_window *me = guiobject_getRootWnd(); + ifc_window *w = me->findWindowByCallback(cb); + if (w != NULL) return w->getGuiObject(); + return NULL; +} + +void GuiObjectI::guiobject_onAccelerator(const wchar_t *accel) +{ + GuiObject_ScriptMethods::onAccelerator(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_STRING(accel)); +} + +int GuiObjectI::guiobject_onAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2, void *data, size_t datalen, ifc_window *source) +{ + GuiObject *gsourceobj = (source == NULL) ? NULL : source->getGuiObject(); + ScriptObject *sourceobj = (gsourceobj == NULL) ? NULL : gsourceobj->guiobject_getScriptObject(); + GuiObject_ScriptMethods::onAction(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_STRING(action), MAKE_SCRIPT_STRING(param), MAKE_SCRIPT_INT(x), MAKE_SCRIPT_INT(y), MAKE_SCRIPT_INT(p1), MAKE_SCRIPT_INT(p2), MAKE_SCRIPT_OBJECT(sourceobj)); + return 1; +} + +void GuiObjectI::guiobject_setTabOrder(int a) { + ifc_window *me = guiobject_getRootWnd(); + me->setTabOrder(a); +} + +void GuiObjectI::guiobject_onInit() { + // api_window *me = guiobject_getRootWnd(); + // nothing to do here anymore, for now + return; +} + +int GuiObjectI::guiobject_wantFocus() { + return wantfocus; +} + +void GuiObjectI::guiobject_setNoDoubleClick(int no) { + ifc_window *w = guiobject_getRootWnd(); + if (w != NULL) + w->setNoDoubleClicks(no); +} + +void GuiObjectI::guiobject_setNoLeftClick(int no) { + ifc_window *w = guiobject_getRootWnd(); + if (w != NULL) + w->setNoLeftClicks(no); +} + +void GuiObjectI::guiobject_setNoRightClick(int no) { + ifc_window *w = guiobject_getRootWnd(); + if (w != NULL) + w->setNoRightClicks(no); +} + +void GuiObjectI::guiobject_setNoMouseMove(int no) { + ifc_window *w = guiobject_getRootWnd(); + if (w != NULL) + w->setNoMouseMoves(no); +} + +void GuiObjectI::guiobject_setNoContextMenu(int no) { + ifc_window *w = guiobject_getRootWnd(); + if (w != NULL) + w->setNoContextMenus(no); +} + +scriptVar GuiObject_ScriptMethods::getInterface(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar guid) { + SCRIPT_FUNCTION_INIT; + int type=-1; + GUID _g = nsGUID::fromCharW(GET_SCRIPT_STRING(guid)); + void *i = o->vcpu_getInterface(_g, &type); + if (i != NULL && type == INTERFACE_SCRIPTOBJECT) { + return MAKE_SCRIPT_OBJECT(reinterpret_cast(i)); + } + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::onDragEnter(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, guiController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar GuiObject_ScriptMethods::onDragOver(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2(o, guiController, x, y); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, x, y); +} + +scriptVar GuiObject_ScriptMethods::onDragLeave(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, guiController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} diff --git a/Src/Wasabi/api/script/objects/guiobj.h b/Src/Wasabi/api/script/objects/guiobj.h new file mode 100644 index 00000000..7997299d --- /dev/null +++ b/Src/Wasabi/api/script/objects/guiobj.h @@ -0,0 +1,423 @@ +#ifndef __GUIOBJ_H +#define __GUIOBJ_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class Layout; +class FindObjectCallback; +class ScriptObject; +class SkinCursor; + +#ifndef _REDOCK_STRUCT_DEFINED +#define _REDOCK_STRUCT_DEFINED +typedef struct +{ + Layout *l; + RECT original_rect; +} +redock_struct; +#endif + +class GuiObjectScriptController : public ScriptObjectControllerI +{ +public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + virtual int getInstantiable(); + +private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern GuiObjectScriptController *guiController; + +#define GUIOBJECT_SCRIPTPARENT RootObject + +#define TARGET_FROZEN 0 +#define TARGET_RUNNING 1 +#define TARGETTIMER_ID 0x1879 + +#define ANCHOR_NONE 0 +#define ANCHOR_LEFT 1 +#define ANCHOR_TOP 2 +#define ANCHOR_RIGHT 4 +#define ANCHOR_BOTTOM 8 + +class GuiObjectI; + +class GuiObjectTimer : public TimerClientDI +{ +public: + GuiObjectTimer() { obj = NULL; } + virtual ~GuiObjectTimer() { } + +public: + virtual void timerclient_timerCallback(int id); + virtual void setGuiObjectI(GuiObjectI *o) { obj = o; } + +private: + GuiObjectI *obj; +}; + +class GuiObjectI : public GuiObjectX, public DependentViewerTPtr +{ +public: + GuiObjectI(ScriptObject *o); + virtual ~GuiObjectI(); + + virtual ifc_window *guiobject_getRootWnd(); + virtual void guiobject_setRootWnd(ifc_window *w); + virtual void guiobject_onInit(); + + virtual void guiobject_getGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh); + virtual void guiobject_setGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh); + virtual int guiobject_getAnchoragePosition(int *x1, int *y1, int *x2, int *y2, int *anchor); + virtual void guiobject_setAnchoragePosition(int *x1, int *y1, int *x2, int *y2, int *anchor); + virtual void guiobject_validateAnchorage(); + + virtual void guiobject_setParentGroup(Group *g); + virtual ScriptObject *guiobject_getScriptObject(); + virtual RootObject *guiobject_getRootObject(); + virtual Group *guiobject_getParentGroup(); + virtual GuiObject *guiobject_getParent(); + virtual void guiobject_setTabOrder(int a); + + virtual void guiobject_setId(const wchar_t *id); + virtual const wchar_t *guiobject_getId(); + + virtual void guiobject_setTargetX(int tx); + virtual void guiobject_setTargetY(int ty); + virtual void guiobject_setTargetW(int tw); + virtual void guiobject_setTargetH(int th); + virtual void guiobject_setTargetA(int th); + virtual void guiobject_setTargetSpeed(float s); + virtual void guiobject_gotoTarget(void); + virtual void guiobject_cancelTarget(); + virtual void guiobject_reverseTarget(int reverse); + + virtual int guiobject_getAutoWidth(); + virtual int guiobject_getAutoHeight(); + virtual int guiobject_movingToTarget(); + + virtual void guiobject_bringToFront(); + virtual void guiobject_bringToBack(); + virtual void guiobject_bringAbove(GuiObject *o); + virtual void guiobject_bringBelow(GuiObject *o); + + virtual void guiobject_setClickThrough(int ct); + virtual int guiobject_isClickThrough(); + + virtual void guiobject_setAutoSysMetricsX(int a); + virtual void guiobject_setAutoSysMetricsY(int a); + virtual void guiobject_setAutoSysMetricsW(int a); + virtual void guiobject_setAutoSysMetricsH(int a); + virtual int guiobject_getAutoSysMetricsX(); + virtual int guiobject_getAutoSysMetricsY(); + virtual int guiobject_getAutoSysMetricsW(); + virtual int guiobject_getAutoSysMetricsH(); + + virtual int guiobject_getRegionOp(); + virtual void guiobject_setRegionOp(int op); + virtual int guiobject_isRectRgn(); + virtual void guiobject_setRectRgn(int rrgn); + + virtual void guiobject_onLeftButtonDown(int x, int y); + virtual void guiobject_onLeftButtonUp(int x, int y); + virtual void guiobject_onRightButtonDown(int x, int y); + virtual void guiobject_onRightButtonUp(int x, int y); + virtual void guiobject_onLeftButtonDblClk(int x, int y); + virtual void guiobject_onRightButtonDblClk(int x, int y); + virtual int guiobject_onMouseWheelUp(int click, int lines); + virtual int guiobject_onMouseWheelDown(int click, int lines); + virtual void guiobject_onMouseMove(int x, int y); + virtual void guiobject_onEnterArea(); + virtual void guiobject_onLeaveArea(); + virtual void guiobject_onEnable(int en); + virtual void guiobject_setEnabled(int en); + virtual void guiobject_onResize(int x, int y, int w, int h); + virtual void guiobject_onSetVisible(int v); + virtual void guiobject_onTargetReached(); + virtual void guiobject_setAlpha(int a); + virtual void guiobject_setActiveAlpha(int a); + virtual void guiobject_setInactiveAlpha(int a); + virtual int guiobject_getAlpha(); + virtual int guiobject_getActiveAlpha(); + virtual int guiobject_getInactiveAlpha(); + virtual int guiobject_isActive(); + virtual void guiobject_onStartup(); + virtual int guiobject_setXmlParam(const wchar_t *param, const wchar_t *value); + virtual const wchar_t *guiobject_getXmlParam(const wchar_t *param); + virtual int guiobject_setXmlParamById(int id, const wchar_t *value); + virtual svc_xuiObject *guiobject_getXuiService(); + virtual void guiobject_setXuiService(svc_xuiObject *svc); + virtual waServiceFactory *guiobject_getXuiServiceFactory(); + virtual void guiobject_setXuiServiceFactory(waServiceFactory *fac); + virtual GuiObject *guiobject_getTopParent(); + virtual Layout *guiobject_getParentLayout(); + virtual int guiobject_runModal(); + virtual void guiobject_endModal(int retcode); + virtual void guiobject_popParentLayout(); + virtual void guiobject_registerStatusCB(GuiStatusCallback *cb); + virtual void guiobject_setStatusText(const wchar_t *txt, int overlay = FALSE); + virtual void guiobject_addAppCmds(AppCmds *commands); + virtual void guiobject_removeAppCmds(AppCmds *commands); + virtual void guiobject_pushCompleted(int max = 100); + virtual void guiobject_incCompleted(int add = 1); + virtual void guiobject_setCompleted(int pos); + virtual void guiobject_popCompleted(); + virtual GuiObject *guiobject_findObject(const wchar_t *id); + virtual GuiObject *guiobject_findObjectXY(int x, int y); // in client coordinates relative to this object + virtual GuiObject *guiobject_findObjectByInterface(GUID interface_guid); + virtual GuiObject *guiobject_findObjectByCallback(FindObjectCallback *cb); + virtual void guiobject_setMover(int m); + virtual int guiobject_getMover(); + virtual void guiobject_onCancelCapture(); + virtual void guiobject_onChar(wchar_t c); + virtual void guiobject_onKeyDown(int vkcode); + virtual void guiobject_onKeyUp(int vkcode); + + virtual FOURCC guiobject_getDropTarget(); + virtual void guiobject_setDropTarget(const wchar_t *strval); + + virtual void onTargetTimer(); +#ifdef USEAPPBAR + virtual int guiobject_getAppBar(); + virtual void guiobject_setAppBar(int en); + virtual void setAppBar(const wchar_t *en); +#endif + + virtual void guiobject_setCfgAttrib(CfgItem *item, const wchar_t *name); + + virtual int viewer_onEvent(CfgItem *item, int event, intptr_t param, void *ptr, size_t ptrlen); + virtual CfgItem *guiobject_getCfgItem(); + const wchar_t *guiobject_getCfgAttrib(); + + virtual int guiobject_getCfgInt(); + virtual void guiobject_setCfgInt(int i); + virtual float guiobject_getCfgFloat(); + virtual void guiobject_setCfgFloat(float f); + virtual const wchar_t *guiobject_getCfgString(); + virtual void guiobject_setCfgString(const wchar_t *s); + virtual int guiobject_hasCfgAttrib(); + + virtual const wchar_t *guiobject_getName(); + virtual void guiobject_onAccelerator(const wchar_t *accel); + virtual int guiobject_onAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2, void *data, size_t datalen, ifc_window *source); + + virtual int guiobject_wantFocus(); + virtual void guiobject_setNoDoubleClick(int no); + virtual void guiobject_setNoLeftClick(int no); + virtual void guiobject_setNoRightClick(int no); + virtual void guiobject_setNoMouseMove(int no); + virtual void guiobject_setNoContextMenu(int no); + + virtual void guiobject_setCursor(const wchar_t *c); + + virtual int guiobject_wantTranslation(); + + virtual int guiobject_dragEnter(ifc_window *sourceWnd); + virtual int guiobject_dragOver(int x, int y, ifc_window *sourceWnd); + virtual int guiobject_dragLeave(ifc_window *sourceWnd); + +private: + void setCfgAttr(const wchar_t *strvalue); + virtual void dataChanged(); + + void snapAdjust(ifc_window *w, RECT *r, int way); + void infoMenu(GuiObject *o, int x, int y); + + int targetx, targety, targetw, targeth, targeta, targetspeed; + int start_time; + int targetstatus; + + void startTargetTimer(); + void stopTargetTimer(); + void ensureTimerOk(); + + int autosysmetricsx, autosysmetricsy, autosysmetricsw, autosysmetricsh; + + int startx, starty, startw, starth, starta; + + int in_area; + StringW guiobject_id; + int clickthrough; + StringW autonotify; + ifc_window *my_root_wnd; + ScriptObject *my_script_object; + GuiObjectTimer timer; + + int gui_x; + int gui_y; + int gui_w; + int gui_h; + int gui_rx; + int gui_ry; + int gui_rw; + int gui_rh; + int mover, moving; + FOURCC droptarget; + Group *p_group; + POINT anchor; + svc_xuiObject *xuisvc; + waServiceFactory *xuifac; + PtrList notifylist; + int wantfocus; + int anchor_x1, anchor_y1, anchor_x2, anchor_y2, anchorage, anchorage_invalidated; + int reversetarget; + SkinCursor *cursor; + redock_struct redock; + int dodragcheck; + int m_lastnondocked_x, m_lastnondocked_y; +#ifdef USEAPPBAR + int m_dock_side; + int m_initial_dock_side; +#endif + StringW cfgattrname; + StringW cfgguid; + CfgItem *cfgitem; + int translate; +}; + + + + +class GuiObject_ScriptMethods +{ +public: + + static scriptVar getId(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar show(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar hide(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar isvisible(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar setAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar getActiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar setActiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar getInactiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar setInactiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar resize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y, scriptVar w, scriptVar h); + static scriptVar onResize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y, scriptVar w, scriptVar h); + static scriptVar init(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar parentGroup); + static scriptVar bringToFront(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar bringToBack(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar bringAbove(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj); + static scriptVar bringBelow(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj); + static scriptVar getIdVar(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar onLeftButtonDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar onLeftButtonUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar onRightButtonDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar onRightButtonUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar onRightButtonDblClk(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar onLeftButtonDblClk(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar onMouseWheelUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar clicked, scriptVar lines); + static scriptVar onMouseWheelDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar clicked, scriptVar lines); + static scriptVar onMouseMove(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar onEnterArea(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar onLeaveArea(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar onChar(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar c); + static scriptVar onKeyDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar c); + static scriptVar onKeyUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar c); + static scriptVar setEnabled(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar getEnabled(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar onEnable(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v); + static scriptVar isMouseOver(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar getLeft(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getTop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getHeight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar setTargetX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar setTargetY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar setTargetW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar setTargetH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar setTargetA(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar setTargetSpeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar gotoTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar onTargetReached(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar cancelTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar reverseTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r); + static scriptVar movingToTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar setXmlParam(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar param, scriptVar value); + static scriptVar getXmlParam(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar param); + static scriptVar onSetVisible(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v); + static scriptVar onStartup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getGuiX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getGuiY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getGuiW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getGuiH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getGuiRelatX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getGuiRelatY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getGuiRelatW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getGuiRelatH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar isActive(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getParent(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getTopParent(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getParentLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar runModal(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar endModal(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar retcode); + static scriptVar popParentLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar setStatusText(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar text, scriptVar overlay); + static scriptVar findObject(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar id); + static scriptVar findObjectXY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar getName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getMover(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar setMover(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar is); + static scriptVar setDropTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar targ); + + static scriptVar onCfgChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar cfgGetInt(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar cfgSetInt(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v); + static scriptVar cfgGetString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar cfgSetString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v); + static scriptVar cfgGetFloat(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar cfgSetFloat(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v); + static scriptVar cfgGetGuid(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar cfgGetAttributeName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + + static scriptVar clientToScreenX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x); + static scriptVar clientToScreenY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar y); + static scriptVar clientToScreenW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x); + static scriptVar clientToScreenH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar y); + static scriptVar screenToClientX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x); + static scriptVar screenToClientY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar y); + static scriptVar screenToClientW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x); + static scriptVar screenToClientH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar y); + static scriptVar getAutoWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getAutoHeight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar setFocus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar onGetFocus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar onKillFocus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar onAccelerator(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar accel); + static scriptVar sendAction(SCRIPT_FUNCTION_PARAMS, ScriptObject *obj, scriptVar action, scriptVar param, scriptVar x, scriptVar y, scriptVar p1, scriptVar p2); + static scriptVar onAction(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar action, scriptVar param, scriptVar x, scriptVar y, scriptVar p1, scriptVar p2, scriptVar source); + static scriptVar isMouseOverRect(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getInterface(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar interfaceguid); + static scriptVar onDragEnter(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar onDragOver(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar onDragLeave(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +}; + +extern const wchar_t guiobjectXuiStr[]; +extern char guiobjectXuiSvcName[]; +class GuiObjectXuiSvc : public XuiObjectSvc {}; + + +#endif diff --git a/Src/Wasabi/api/script/objects/guiobject.h b/Src/Wasabi/api/script/objects/guiobject.h new file mode 100644 index 00000000..f4cccfa2 --- /dev/null +++ b/Src/Wasabi/api/script/objects/guiobject.h @@ -0,0 +1,855 @@ +#ifndef __GUIOBJECT_H +#define __GUIOBJECT_H + +#include +#include +#include + +class ifc_window; +class ScriptObject; // scriptobj.h +class GuiObject; // this file +class RootObject; // rootobj.h +class svc_xuiObject; // studio/services/svc_xuiobject.h +class GuiStatusCallback; +class AppCmds; +class CfgItem; +class FindObjectCallback; + +class Group; +class Layout; + +class GuiObject : public Dispatchable +{ +public: + + ifc_window *guiobject_getRootWnd(); + void guiobject_setRootWnd(ifc_window *w); + void guiobject_onInit(); + + void guiobject_getGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh); + void guiobject_setGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh); + int guiobject_getAnchoragePosition(int *x1, int *x2, int *y1, int *y2, int *anchor); // returns anchor invalidation flag + void guiobject_setAnchoragePosition(int *x1, int *x2, int *y1, int *y2, int *anchor); + void guiobject_validateAnchorage(); // clears up anchor invalidation flag + void guiobject_setParentGroup(Group *l); + ScriptObject *guiobject_getScriptObject(); + RootObject *guiobject_getRootObject(); + Group *guiobject_getParentGroup(); + GuiObject *guiobject_getParent(); + Layout *guiobject_getParentLayout(); + + int guiobject_wantAutoContextMenu(); + + void guiobject_setId(const wchar_t *id); + const wchar_t *guiobject_getId(); + + void guiobject_setTargetX(int tx); + void guiobject_setTargetY(int ty); + void guiobject_setTargetW(int tw); + void guiobject_setTargetH(int th); + void guiobject_setTargetA(int th); + void guiobject_setTargetSpeed(float s); + void guiobject_gotoTarget(void); + void guiobject_cancelTarget(); + void guiobject_reverseTarget(int reverse); + + int guiobject_getAutoWidth(); + int guiobject_getAutoHeight(); + int guiobject_movingToTarget(); + + void guiobject_bringToFront(); + void guiobject_bringToBack(); + void guiobject_bringAbove(GuiObject *o); + void guiobject_bringBelow(GuiObject *o); + + void guiobject_setClickThrough(int ct); + int guiobject_isClickThrough(); + + void guiobject_setAutoSysMetricsX(int a); + void guiobject_setAutoSysMetricsY(int a); + void guiobject_setAutoSysMetricsW(int a); + void guiobject_setAutoSysMetricsH(int a); + int guiobject_getAutoSysMetricsX(); + int guiobject_getAutoSysMetricsY(); + int guiobject_getAutoSysMetricsW(); + int guiobject_getAutoSysMetricsH(); + + void guiobject_setRegionOp(int op); + int guiobject_getRegionOp(); + void guiobject_setRectRgn(int rrgn); + int guiobject_isRectRgn(); + + void guiobject_setMover(int mover); + int guiobject_getMover(); + + FOURCC guiobject_getDropTarget(); + void guiobject_setDropTarget(const wchar_t *target); + + void guiobject_onLeftButtonDown(int x, int y); + void guiobject_onLeftButtonUp(int x, int y); + void guiobject_onRightButtonDown(int x, int y); + void guiobject_onRightButtonUp(int x, int y); + void guiobject_onLeftButtonDblClk(int x, int y); + void guiobject_onRightButtonDblClk(int x, int y); + void guiobject_onMouseMove(int x, int y); + int guiobject_onMouseWheelUp(int click, int lines); // Need to return 1 if handled + int guiobject_onMouseWheelDown(int click, int lines); // Need to return 1 if handled + void guiobject_onEnterArea(); + void guiobject_onLeaveArea(); + void guiobject_onCancelCapture(); + void guiobject_setEnabled(int en); + void guiobject_onEnable(int en); + void guiobject_onResize(int x, int y, int w, int h); + void guiobject_onSetVisible(int v); + void guiobject_onTargetReached(); + void guiobject_setAlpha(int a); + int guiobject_getAlpha(); + void guiobject_setActiveAlpha(int a); + int guiobject_getActiveAlpha(); + void guiobject_setInactiveAlpha(int a); + int guiobject_getInactiveAlpha(); + void guiobject_onStartup(); + const wchar_t *guiobject_getXmlParam(const wchar_t *param); + int guiobject_setXmlParam(const wchar_t *param, const wchar_t *value); + int guiobject_setXmlParamById(int id, const wchar_t *value); + GuiObject *guiobject_getTopParent(); +#ifdef WASABI_COMPILE_WNDMGR + int guiobject_runModal(); + void guiobject_endModal(int retcode); + void guiobject_popParentLayout(); + void guiobject_registerStatusCB(GuiStatusCallback *cb); + void guiobject_setStatusText(const wchar_t *text, int overlay=FALSE); + void guiobject_addAppCmds(AppCmds *commands); + void guiobject_removeAppCmds(AppCmds *commands); + void guiobject_pushCompleted(int max=100); + void guiobject_incCompleted(int add=1); + void guiobject_setCompleted(int pos); + void guiobject_popCompleted(); +#endif + + void guiobject_onChar(wchar_t c); + void guiobject_onKeyDown(int vkcode); + void guiobject_onKeyUp(int vkcode); + + svc_xuiObject *guiobject_getXuiService(); + void guiobject_setXuiService(svc_xuiObject *svc); + waServiceFactory *guiobject_getXuiServiceFactory(); + void guiobject_setXuiServiceFactory(waServiceFactory *fac); + GuiObject *guiobject_findObject(const wchar_t *id); + GuiObject *guiobject_findObjectXY(int x, int y); + GuiObject *guiobject_findObjectByInterface(GUID interface_guid); + GuiObject *guiobject_findObjectByCallback(FindObjectCallback *cb); + GuiObject *guiobject_findObjectChain(FindObjectCallback *cb, GuiObject *caller=NULL); + const wchar_t *guiobject_getName(); + +#ifdef WASABI_COMPILE_CONFIG + void guiobject_setCfgAttrib(CfgItem *i, const wchar_t *attrib); + CfgItem *guiobject_getCfgItem(); + const wchar_t *guiobject_getCfgAttrib(); + + int guiobject_getCfgInt(); + void guiobject_setCfgInt(int i); + float guiobject_getCfgFloat(); + void guiobject_setCfgFloat(float v); + const wchar_t *guiobject_getCfgString(); + void guiobject_setCfgString(const wchar_t *s); + int guiobject_hasCfgAttrib(); +#endif + + void guiobject_onGetFocus(); + void guiobject_onKillFocus(); + void guiobject_onAccelerator(const wchar_t *accel); + int guiobject_onAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2, void *data, size_t datalen, ifc_window *source); + + int guiobject_wantFocus(); + + void guiobject_setNoDoubleClick(int no); + void guiobject_setNoLeftClick(int no); + void guiobject_setNoRightClick(int no); + void guiobject_setNoMouseMove(int no); + void guiobject_setNoContextMenu(int no); + + void guiobject_setCursor(const wchar_t *c); + + void guiobject_setAppBar(int enabled); + int guiobject_getAppBar(); + + int guiobject_wantTranslation(); + + int guiobject_dragEnter(ifc_window *sourceWnd); + int guiobject_dragOver(int x, int y, ifc_window *sourceWnd); + int guiobject_dragLeave(ifc_window *sourceWnd); + + enum { + GUI_GETGUIPOSITION=10, + GUI_GETANCHORAGEPOSITION=11, + GUI_SETGUIPOSITION=20, + GUI_SETANCHORAGEPOSITION=21, + GUI_VALIDATEANCHORAGE=22, + GUI_SETPARENTGROUP=30, + GUI_GETPARENTGROUP=40, + GUI_GETPARENT=45, + GUI_GETPARENTLAYOUT=50, + GUI_GETTOPPARENT=55, + GUI_GETROOTWND=60, + GUI_WANTAUTOCTXMENU=70, + GUI_SETID=80, + GUI_GETID=90, + GUI_SETTARGETX=100, + GUI_SETTARGETY=110, + GUI_SETTARGETW=120, + GUI_SETTARGETH=130, + GUI_SETTARGETA=140, + GUI_SETTARGETSPEED=150, + GUI_GOTOTARGET=160, + GUI_CANCELTARGET=161, + GUI_REVERSETARGET=162, + GUI_MOVINGTOTARGET=170, + GUI_GETAUTOWIDTH=180, + GUI_GETAUTOHEIGHT=190, + GUI_BRINGTOFRONT=200, + GUI_BRINGTOBACK=210, + GUI_BRINGBELOW=220, + GUI_BRINGABOVE=230, + GUI_SETCLICKTHROUGH=240, + GUI_ISCLICKTHROUGH=250, + GUI_SETAUTOSMX=260, + GUI_SETAUTOSMY=270, + GUI_SETAUTOSMW=280, + GUI_SETAUTOSMH=290, + GUI_GETAUTOSMX=300, + GUI_GETAUTOSMY=310, + GUI_GETAUTOSMW=320, + GUI_GETAUTOSMH=330, + GUI_ONLEFTBUTTONDOWN=340, + GUI_ONLEFTBUTTONUP=350, + GUI_ONRIGHTBUTTONDOWN=360, + GUI_ONRIGHTBUTTONUP=370, + GUI_ONLEFTBUTTONDBLCLK=380, + GUI_ONRIGHTBUTTONDBLCLK=390, + GUI_ONMOUSEWHEELUP=394, + GUI_ONMOUSEWHEELDOWN=396, + GUI_ONMOUSEMOVE=400, + GUI_ONENTERAREA=410, + GUI_ONLEAVEAREA=420, + GUI_ONENABLE=430, + GUI_SETENABLED=431, + GUI_ONRESIZE=440, + GUI_ONSETVISIBLE=450, + GUI_ONTARGETREACHED=460, + GUI_SETALPHA=470, + GUI_GETALPHA=480, + GUI_SETACTIVEALPHA=490, + GUI_GETACTIVEALPHA=500, + GUI_SETINACTIVEALPHA=510, + GUI_GETINACTIVEALPHA=520, + GUI_ONSTARTUP=530, + GUI_SETXMLPARAM=540, + GUI_SETXMLPARAMBYID=541, + GUI_GETXMLPARAM=542, +// GUI_ONUNKNOWNXMLPARAM=545, retired + GUI_SETROOTWND=550, + GUI_GETSCRIPTOBJECT=560, + GUI_GETROOTOBJECT=570, + GUI_RUNMODAL=580, + GUI_ENDMODAL=590, + GUI_SETXUISVC=600, + GUI_GETXUISVC=610, + GUI_POPPARENTLAYOUT=620, + GUI_SETREGIONOP=630, + GUI_GETREGIONOP=640, + GUI_SETRECTRGN=650, + GUI_ISRECTRGN=660, + GUI_REGISTERSTATUSCB=670, + GUI_SETSTATUSTXT=680, + GUI_ADDCTXTCMDS=690, + GUI_REMCTXTCMDS=700, + GUI_FINDOBJECT=800, + GUI_FINDOBJECTBYGUID=801, + GUI_FINDOBJECTBYCB=802, + GUI_FINDOBJECTCHAIN=803, + GUI_FINDOBJECTXY=804, + GUI_GETNAME=805, + GUI_GETMOVER=810, + GUI_SETMOVER=820, + GUI_GETDROPTARGET=830, + GUI_SETDROPTARGET=840, + GUI_ONCANCELCAPTURE=850, + GUI_SETCFGATTRIB=860, + GUI_GETCFGITEM=870, + GUI_GETCFGATTRIB=880, + GUI_SETCFGINT=890, + GUI_GETCFGINT=900, + GUI_GETCFGFLOAT=910, + GUI_SETCFGFLOAT=920, + GUI_SETCFGSTRING=930, + GUI_GETCFGSTRING=940, + GUI_HASATTRIB=950, + GUI_PUSHCOMPLETED=1000, + GUI_INCCOMPLETED=1010, + GUI_SETCOMPLETED=1020, + GUI_POPCOMPLETED=1030, + GUI_ONCHAR=1100, + GUI_ONKEYDOWN=1110, + GUI_ONKEYUP=1120, + GUI_ONGETFOCUS=1200, + GUI_ONKILLFOCUS=1210, + GUI_ONACCELERATOR=1300, + GUI_ONACTION=1400, + GUI_ONINIT=1500, + GUI_WANTFOCUS=1600, + GUI_SETNOMOUSEMOVE=1700, + GUI_SETNOLEFTCLICK=1800, + GUI_SETNORIGHTCLICK=1900, + GUI_SETNODOUBLECLICK=2000, + GUI_SETNOCONTEXTMENU=2100, + GUI_SETCURSOR=2200, + GUI_SETXUIFAC=2300, + GUI_GETXUIFAC=2310, + GUI_SETAPPBAR=2400, + GUI_GETAPPBAR=2410, + GUI_WANTTRANSLATION=2420, + GUI_DRAGENTER = 2430, + GUI_DRAGOVER = 2440, + GUI_DRAGLEAVE = 2450, + }; + + operator ScriptObject *() { return (this == NULL) ? NULL : guiobject_getScriptObject(); } + operator ifc_window *() { return (this == NULL) ? NULL : guiobject_getRootWnd(); } +}; + +inline void GuiObject::guiobject_getGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh) { + _voidcall(GUI_GETGUIPOSITION, x, y, w, h, rx, ry, rw, rh); +} + +inline void GuiObject::guiobject_setGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh) { + _voidcall(GUI_SETGUIPOSITION, x, y, w, h, rx, ry, rw, rh); +} + +inline int GuiObject::guiobject_getAnchoragePosition(int *x1, int *y1, int *x2, int *y2, int *anchor) { + return _call(GUI_GETANCHORAGEPOSITION, 0, x1, y1, x2, y2, anchor); +} + +inline void GuiObject::guiobject_setAnchoragePosition(int *x1, int *y1, int *x2, int *y2, int *anchor) { + _voidcall(GUI_SETANCHORAGEPOSITION, x1, y1, x2, y2, anchor); +} + +inline void GuiObject::guiobject_validateAnchorage() { + _voidcall(GUI_VALIDATEANCHORAGE); +} + +inline void GuiObject::guiobject_setParentGroup(Group *g) { + _voidcall(GUI_SETPARENTGROUP, g); +} + +inline Group *GuiObject::guiobject_getParentGroup() { + return _call(GUI_GETPARENTGROUP, (Group *)NULL); +} + +inline GuiObject *GuiObject::guiobject_getParent() { + return _call(GUI_GETPARENT, (GuiObject *)NULL); +} + +inline Layout *GuiObject::guiobject_getParentLayout() { + return _call(GUI_GETPARENTLAYOUT, (Layout*)NULL); +} + +inline GuiObject *GuiObject::guiobject_getTopParent() { + return _call(GUI_GETTOPPARENT, (GuiObject *)NULL); +} + +inline ifc_window *GuiObject::guiobject_getRootWnd() { + return _call(GUI_GETROOTWND, (ifc_window *)NULL); +} + +inline void GuiObject::guiobject_setRootWnd(ifc_window *r) { + _voidcall(GUI_SETROOTWND, r); +} + +inline int GuiObject::guiobject_wantAutoContextMenu() { + return _call(GUI_WANTAUTOCTXMENU, 0); +} + +inline void GuiObject::guiobject_setId(const wchar_t *id) { + _voidcall(GUI_SETID, id); +} + +inline const wchar_t *GuiObject::guiobject_getId() { + return _call(GUI_GETID, (const wchar_t *)NULL); +} + +inline void GuiObject::guiobject_setTargetX(int tx) { + _voidcall(GUI_SETTARGETX, tx); +} + +inline void GuiObject::guiobject_setTargetY(int ty) { + _voidcall(GUI_SETTARGETY, ty); +} + +inline void GuiObject::guiobject_setTargetW(int tw) { + _voidcall(GUI_SETTARGETW, tw); +} + +inline void GuiObject::guiobject_setTargetH(int th) { + _voidcall(GUI_SETTARGETH, th); +} + +inline void GuiObject::guiobject_setTargetA(int ta) { + _voidcall(GUI_SETTARGETA, ta); +} + +inline void GuiObject::guiobject_setTargetSpeed(float s) { + _voidcall(GUI_SETTARGETSPEED, s); +} + +inline void GuiObject::guiobject_gotoTarget(void) { + _voidcall(GUI_GOTOTARGET); +} + +inline void GuiObject::guiobject_cancelTarget() { + _voidcall(GUI_CANCELTARGET); +} + +inline int GuiObject::guiobject_getAutoWidth() { + return _call(GUI_GETAUTOWIDTH, 0); +} + +inline int GuiObject::guiobject_getAutoHeight() { + return _call(GUI_GETAUTOHEIGHT, 0); +} + +inline int GuiObject::guiobject_movingToTarget() { + return _call(GUI_MOVINGTOTARGET, 0); +} + +inline void GuiObject::guiobject_bringToFront() { + _voidcall(GUI_BRINGTOFRONT); +} + +inline void GuiObject::guiobject_bringToBack() { + _voidcall(GUI_BRINGTOBACK); +} + +inline void GuiObject::guiobject_bringAbove(GuiObject *o) { + _voidcall(GUI_BRINGABOVE, o); +} + +inline void GuiObject::guiobject_bringBelow(GuiObject *o) { + _voidcall(GUI_BRINGBELOW, o); +} + +inline void GuiObject::guiobject_setClickThrough(int ct) { + _voidcall(GUI_SETCLICKTHROUGH, ct); +} + +inline void GuiObject::guiobject_setRegionOp(int op) { + _voidcall(GUI_SETREGIONOP, op); +} + +inline int GuiObject::guiobject_getRegionOp() { + return _call(GUI_GETREGIONOP, 0); +} + +inline void GuiObject::guiobject_setRectRgn(int rrgn) { + _voidcall(GUI_SETRECTRGN, rrgn); +} + +inline int GuiObject::guiobject_isRectRgn() { + return _call(GUI_ISRECTRGN, 0); +} + +inline int GuiObject::guiobject_isClickThrough() { + return _call(GUI_ISCLICKTHROUGH, 0); +} + +inline void GuiObject::guiobject_setAutoSysMetricsX(int a) { + _voidcall(GUI_SETAUTOSMX, a); +} + +inline void GuiObject::guiobject_setAutoSysMetricsY(int a) { + _voidcall(GUI_SETAUTOSMY, a); +} + +inline void GuiObject::guiobject_setAutoSysMetricsW(int a) { + _voidcall(GUI_SETAUTOSMW, a); +} + +inline void GuiObject::guiobject_setAutoSysMetricsH(int a) { + _voidcall(GUI_SETAUTOSMH, a); +} + +inline int GuiObject::guiobject_getAutoSysMetricsX() { + return _call(GUI_GETAUTOSMX, 0); +} + +inline int GuiObject::guiobject_getAutoSysMetricsY() { + return _call(GUI_GETAUTOSMY, 0); +} + +inline int GuiObject::guiobject_getAutoSysMetricsW() { + return _call(GUI_GETAUTOSMW, 0); +} + +inline int GuiObject::guiobject_getAutoSysMetricsH() { + return _call(GUI_GETAUTOSMH, 0); +} + +inline void GuiObject::guiobject_onLeftButtonDown(int x, int y) { + _voidcall(GUI_ONLEFTBUTTONDOWN, x, y); +} + +inline void GuiObject::guiobject_onLeftButtonUp(int x, int y) { + _voidcall(GUI_ONLEFTBUTTONUP, x, y); +} + +inline void GuiObject::guiobject_onRightButtonDown(int x, int y) { + _voidcall(GUI_ONRIGHTBUTTONDOWN, x, y); +} + +inline void GuiObject::guiobject_onRightButtonUp(int x, int y) { + _voidcall(GUI_ONRIGHTBUTTONUP, x, y); +} + +inline void GuiObject::guiobject_onLeftButtonDblClk(int x, int y) { + _voidcall(GUI_ONLEFTBUTTONDBLCLK, x, y); +} + +inline void GuiObject::guiobject_onRightButtonDblClk(int x, int y) { + _voidcall(GUI_ONRIGHTBUTTONDBLCLK, x, y); +} + +inline int GuiObject::guiobject_onMouseWheelUp(int click, int lines) +{ + return _call(GUI_ONMOUSEWHEELUP, 0, click, lines); +} + +inline int GuiObject::guiobject_onMouseWheelDown(int click, int lines) +{ + return _call(GUI_ONMOUSEWHEELDOWN, 0, click, lines); +} + +inline void GuiObject::guiobject_onMouseMove(int x, int y) { + _voidcall(GUI_ONMOUSEMOVE, x, y); +} + +inline void GuiObject::guiobject_onEnterArea() { + _voidcall(GUI_ONENTERAREA); +} + +inline void GuiObject::guiobject_onLeaveArea() { + _voidcall(GUI_ONLEAVEAREA); +} + +inline void GuiObject::guiobject_onEnable(int en) { + _voidcall(GUI_ONENABLE, en); +} + +inline void GuiObject::guiobject_setEnabled(int en) { + _voidcall(GUI_SETENABLED, en); +} + +inline void GuiObject::guiobject_onResize(int x, int y, int w, int h) { + _voidcall(GUI_ONRESIZE, x, y, w, h); +} + +inline void GuiObject::guiobject_onSetVisible(int v) { + _voidcall(GUI_ONSETVISIBLE, v); +} + +inline void GuiObject::guiobject_onTargetReached() { + _voidcall(GUI_ONTARGETREACHED); +} + +inline void GuiObject::guiobject_setAlpha(int a) { + _voidcall(GUI_SETALPHA, a); +} + +inline int GuiObject::guiobject_getAlpha() { + return _call(GUI_GETALPHA, 255); +} + +inline void GuiObject::guiobject_setActiveAlpha(int a) { + _voidcall(GUI_SETACTIVEALPHA, a); +} + +inline int GuiObject::guiobject_getActiveAlpha() { + return _call(GUI_GETACTIVEALPHA, 255); +} + +inline void GuiObject::guiobject_setInactiveAlpha(int a) { + _voidcall(GUI_SETINACTIVEALPHA, a); +} + +inline int GuiObject::guiobject_getInactiveAlpha() { + return _call(GUI_GETINACTIVEALPHA, 255); +} + +inline void GuiObject::guiobject_onStartup() { + _voidcall(GUI_ONSTARTUP); +} + +inline int GuiObject::guiobject_setXmlParam(const wchar_t *param, const wchar_t *value) { + return _call(GUI_SETXMLPARAM, 0, param, value); +} + +inline int GuiObject::guiobject_setXmlParamById(int id, const wchar_t *value) { + return _call(GUI_SETXMLPARAMBYID, 0, id, value); +} + +inline const wchar_t *GuiObject::guiobject_getXmlParam(const wchar_t *param) { + return _call(GUI_GETXMLPARAM, (const wchar_t *)NULL, param); +} + +inline ScriptObject *GuiObject::guiobject_getScriptObject() { + return _call(GUI_GETSCRIPTOBJECT, (ScriptObject *)NULL); +} + +inline RootObject *GuiObject::guiobject_getRootObject() { + return _call(GUI_GETROOTOBJECT, (RootObject *)NULL); +} + +#ifdef WASABI_COMPILE_WNDMGR +inline int GuiObject::guiobject_runModal() { + return _call(GUI_RUNMODAL, 0); +} + +inline void GuiObject::guiobject_endModal(int retcode) { + _voidcall(GUI_ENDMODAL, retcode); +} +#endif + +inline svc_xuiObject *GuiObject::guiobject_getXuiService() { + return _call(GUI_GETXUISVC, (svc_xuiObject *)NULL); +} + +inline void GuiObject::guiobject_setXuiService(svc_xuiObject *svc) { + _voidcall(GUI_SETXUISVC, svc); +} + +inline waServiceFactory *GuiObject::guiobject_getXuiServiceFactory() { + return _call(GUI_GETXUIFAC, (waServiceFactory*)NULL); +} + +inline void GuiObject::guiobject_setXuiServiceFactory(waServiceFactory *fac) { + _voidcall(GUI_SETXUIFAC, fac); +} + +#ifdef WASABI_COMPILE_WNDMGR +inline void GuiObject::guiobject_popParentLayout() { + _voidcall(GUI_POPPARENTLAYOUT); +} + +inline void GuiObject::guiobject_setStatusText(const wchar_t *txt, int overlay) { + _voidcall(GUI_SETSTATUSTXT, txt, overlay); +} + +inline void GuiObject::guiobject_addAppCmds(AppCmds *commands) { + _voidcall(GUI_ADDCTXTCMDS, commands); +} + +inline void GuiObject::guiobject_removeAppCmds(AppCmds *commands) { + _voidcall(GUI_REMCTXTCMDS, commands); +} + +inline +void GuiObject::guiobject_pushCompleted(int max) { + _voidcall(GUI_PUSHCOMPLETED, max); +} +inline +void GuiObject::guiobject_incCompleted(int add) { + _voidcall(GUI_INCCOMPLETED, add); +} +inline +void GuiObject::guiobject_setCompleted(int pos) { + _voidcall(GUI_SETCOMPLETED, pos); +} + +inline +void GuiObject::guiobject_popCompleted() { + _voidcall(GUI_POPCOMPLETED); +} + +inline void GuiObject::guiobject_registerStatusCB(GuiStatusCallback *callback) { + _voidcall(GUI_REGISTERSTATUSCB, callback); +} +#endif + +inline GuiObject *GuiObject::guiobject_findObject(const wchar_t *id) { + return _call(GUI_FINDOBJECT, (GuiObject *)NULL, id); +} + +inline GuiObject *GuiObject::guiobject_findObjectXY(int x, int y) { + return _call(GUI_FINDOBJECTXY, (GuiObject *)NULL, x, y); +} + +inline GuiObject *GuiObject::guiobject_findObjectByInterface(GUID interface_guid) { + return _call(GUI_FINDOBJECTBYGUID, (GuiObject *)NULL, interface_guid); +} + +inline GuiObject *GuiObject::guiobject_findObjectByCallback(FindObjectCallback *cb) { + return _call(GUI_FINDOBJECTBYCB, (GuiObject *)NULL, cb); +} + +inline GuiObject *GuiObject::guiobject_findObjectChain(FindObjectCallback *cb, GuiObject *caller) { + return _call(GUI_FINDOBJECTCHAIN, (GuiObject *)NULL, cb, caller); +} + +inline const wchar_t *GuiObject::guiobject_getName() { + return _call(GUI_GETNAME, (const wchar_t *)NULL); +} + +inline int GuiObject::guiobject_getMover() { + return _call(GUI_GETMOVER, 0); +} + +inline void GuiObject::guiobject_setMover(int s) { + _voidcall(GUI_SETMOVER, s); +} + +inline FOURCC GuiObject::guiobject_getDropTarget() { + return _call(GUI_GETDROPTARGET, (FOURCC)0); +} + +inline void GuiObject::guiobject_setDropTarget(const wchar_t *target) { + _voidcall(GUI_SETDROPTARGET, target); +} + +inline void GuiObject::guiobject_onCancelCapture() { + _voidcall(GUI_ONCANCELCAPTURE); +} + +#ifdef WASABI_COMPILE_CONFIG +inline void GuiObject::guiobject_setCfgAttrib(CfgItem *item, const wchar_t *attr) { + _voidcall(GUI_SETCFGATTRIB, item, attr); +} + +inline CfgItem *GuiObject::guiobject_getCfgItem() { + return _call(GUI_GETCFGITEM, (CfgItem *)NULL); +} + +inline const wchar_t *GuiObject::guiobject_getCfgAttrib() { + return _call(GUI_GETCFGATTRIB, (const wchar_t *)NULL); +} + +inline int GuiObject::guiobject_getCfgInt() { + return _call(GUI_GETCFGINT, 0); +} + +inline void GuiObject::guiobject_setCfgInt(int i) { + _voidcall(GUI_SETCFGINT, i); +} + +inline float GuiObject::guiobject_getCfgFloat() { + return _call(GUI_GETCFGFLOAT, (float)0); +} + +inline void GuiObject::guiobject_setCfgFloat(float v) { + _voidcall(GUI_SETCFGFLOAT, v); +} + +inline const wchar_t *GuiObject::guiobject_getCfgString() { + return _call(GUI_GETCFGSTRING, (const wchar_t *)NULL); +} + +inline void GuiObject::guiobject_setCfgString(const wchar_t *s) { + _voidcall(GUI_SETCFGSTRING, s); +} + +inline int GuiObject::guiobject_hasCfgAttrib() { + return _call(GUI_HASATTRIB, 0); +} +#endif + +inline void GuiObject::guiobject_onChar(wchar_t c) { + _voidcall(GUI_ONCHAR, c); +} + +inline void GuiObject::guiobject_onKeyDown(int k) { + _voidcall(GUI_ONKEYDOWN, k); +} + +inline void GuiObject::guiobject_onKeyUp(int k) { + _voidcall(GUI_ONKEYUP, k); +} + +inline void GuiObject::guiobject_onGetFocus() { + _voidcall(GUI_ONGETFOCUS); +} + +inline void GuiObject::guiobject_onKillFocus() { + _voidcall(GUI_ONKILLFOCUS); +} + +inline void GuiObject::guiobject_onAccelerator(const wchar_t *accel) { + _voidcall(GUI_ONACCELERATOR, accel); +} + +inline int GuiObject::guiobject_onAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2, void *data, size_t datalen, ifc_window *source) { + return _call(GUI_ONACTION, 0, action, param, x, y, p1, p2, data, datalen, source); +} + +inline void GuiObject::guiobject_onInit() { + _voidcall(GUI_ONINIT); +} + +inline int GuiObject::guiobject_wantFocus() { + return _call(GUI_WANTFOCUS, 0); +} + +inline void GuiObject::guiobject_setNoDoubleClick(int no) { + _voidcall(GUI_SETNODOUBLECLICK, no); +} + +inline void GuiObject::guiobject_setNoLeftClick(int no) { + _voidcall(GUI_SETNOLEFTCLICK, no); +} + +inline void GuiObject::guiobject_setNoRightClick(int no) { + _voidcall(GUI_SETNORIGHTCLICK, no); +} + +inline void GuiObject::guiobject_setNoMouseMove(int no) { + _voidcall(GUI_SETNOMOUSEMOVE, no); +} + +inline void GuiObject::guiobject_setNoContextMenu(int no) { + _voidcall(GUI_SETNOCONTEXTMENU, no); +} + +inline void GuiObject::guiobject_setCursor(const wchar_t *c) { + _voidcall(GUI_SETCURSOR, c); +} + +inline void GuiObject::guiobject_reverseTarget(int reverse) { + _voidcall(GUI_REVERSETARGET, reverse); +} + +inline void GuiObject::guiobject_setAppBar(int enabled) { + _voidcall(GUI_SETAPPBAR, enabled); +} + +inline int GuiObject::guiobject_getAppBar() { + return _call(GUI_GETAPPBAR, 0); +} + +inline int GuiObject::guiobject_wantTranslation() +{ + return _call(GUI_WANTTRANSLATION, (int)1); +} + +inline int GuiObject::guiobject_dragEnter(ifc_window *sourceWnd) +{ + return _call(GUI_DRAGENTER, (int)1, sourceWnd); +} + +inline int GuiObject::guiobject_dragOver(int x, int y, ifc_window *sourceWnd) +{ + return _call(GUI_DRAGOVER, (int)1, sourceWnd, x, y); +} + +inline int GuiObject::guiobject_dragLeave(ifc_window *sourceWnd) +{ + return _call(GUI_DRAGLEAVE, (int)1, sourceWnd); +} + +#endif diff --git a/Src/Wasabi/api/script/objects/guiobjectx.cpp b/Src/Wasabi/api/script/objects/guiobjectx.cpp new file mode 100644 index 00000000..44d0ca83 --- /dev/null +++ b/Src/Wasabi/api/script/objects/guiobjectx.cpp @@ -0,0 +1,131 @@ +#include +#include "guiobjectx.h" + +#define CBCLASS GuiObjectX +START_DISPATCH; + CB(GUI_GETSCRIPTOBJECT, guiobject_getScriptObject); + CB(GUI_GETROOTWND, guiobject_getRootWnd); + CB(GUI_GETROOTOBJECT, guiobject_getRootObject); + VCB(GUI_SETROOTWND, guiobject_setRootWnd); + CB(GUI_SETXMLPARAM, guiobject_setXmlParam); + CB(GUI_SETXMLPARAMBYID, guiobject_setXmlParamById); + CB(GUI_GETXMLPARAM, guiobject_getXmlParam); + VCB(GUI_SETPARENTGROUP, guiobject_setParentGroup); + CB(GUI_GETPARENTGROUP, guiobject_getParentGroup); + CB(GUI_GETPARENT, guiobject_getParent); + CB(GUI_GETPARENTLAYOUT, guiobject_getParentLayout); + CB(GUI_GETTOPPARENT, guiobject_getTopParent); + VCB(GUI_GETGUIPOSITION, guiobject_getGuiPosition); + VCB(GUI_SETGUIPOSITION, guiobject_setGuiPosition); + CB(GUI_GETANCHORAGEPOSITION, guiobject_getAnchoragePosition); + VCB(GUI_SETANCHORAGEPOSITION, guiobject_setAnchoragePosition); + VCB(GUI_VALIDATEANCHORAGE, guiobject_validateAnchorage); + VCB(GUI_SETID, guiobject_setId); + CB(GUI_GETID, guiobject_getId); + VCB(GUI_SETTARGETX, guiobject_setTargetX); + VCB(GUI_SETTARGETY, guiobject_setTargetY); + VCB(GUI_SETTARGETW, guiobject_setTargetW); + VCB(GUI_SETTARGETH, guiobject_setTargetH); + VCB(GUI_SETTARGETA, guiobject_setTargetA); + VCB(GUI_SETTARGETSPEED, guiobject_setTargetSpeed); + VCB(GUI_GOTOTARGET, guiobject_gotoTarget); + VCB(GUI_CANCELTARGET, guiobject_cancelTarget); + VCB(GUI_REVERSETARGET, guiobject_reverseTarget); + CB(GUI_GETAUTOWIDTH, guiobject_getAutoWidth); + CB(GUI_GETAUTOHEIGHT, guiobject_getAutoHeight); + CB(GUI_MOVINGTOTARGET, guiobject_movingToTarget); + VCB(GUI_BRINGTOFRONT, guiobject_bringToFront); + VCB(GUI_BRINGTOBACK, guiobject_bringToBack); + VCB(GUI_BRINGABOVE, guiobject_bringAbove); + VCB(GUI_BRINGBELOW, guiobject_bringBelow); + VCB(GUI_SETCLICKTHROUGH, guiobject_setClickThrough); + CB(GUI_ISCLICKTHROUGH, guiobject_isClickThrough); + VCB(GUI_SETAUTOSMX, guiobject_setAutoSysMetricsX); + VCB(GUI_SETAUTOSMY, guiobject_setAutoSysMetricsY); + VCB(GUI_SETAUTOSMW, guiobject_setAutoSysMetricsW); + VCB(GUI_SETAUTOSMH, guiobject_setAutoSysMetricsH); + CB(GUI_GETAUTOSMX, guiobject_getAutoSysMetricsX); + CB(GUI_GETAUTOSMY, guiobject_getAutoSysMetricsY); + CB(GUI_GETAUTOSMW, guiobject_getAutoSysMetricsW); + CB(GUI_GETAUTOSMH, guiobject_getAutoSysMetricsH); + VCB(GUI_ONLEFTBUTTONDOWN, guiobject_onLeftButtonDown); + VCB(GUI_ONLEFTBUTTONUP, guiobject_onLeftButtonUp); + VCB(GUI_ONRIGHTBUTTONDOWN, guiobject_onRightButtonDown); + VCB(GUI_ONRIGHTBUTTONUP, guiobject_onRightButtonUp); + VCB(GUI_ONLEFTBUTTONDBLCLK, guiobject_onLeftButtonDblClk); + VCB(GUI_ONRIGHTBUTTONDBLCLK, guiobject_onRightButtonDblClk); + CB(GUI_ONMOUSEWHEELUP, guiobject_onMouseWheelUp); + CB(GUI_ONMOUSEWHEELDOWN, guiobject_onMouseWheelDown); + VCB(GUI_ONMOUSEMOVE, guiobject_onMouseMove); + VCB(GUI_ONENTERAREA, guiobject_onEnterArea); + VCB(GUI_ONLEAVEAREA, guiobject_onLeaveArea); + VCB(GUI_ONENABLE, guiobject_onEnable); + VCB(GUI_SETENABLED, guiobject_setEnabled); + VCB(GUI_ONRESIZE, guiobject_onResize); + VCB(GUI_ONSETVISIBLE, guiobject_onSetVisible); + VCB(GUI_ONTARGETREACHED, guiobject_onTargetReached); + VCB(GUI_SETALPHA, guiobject_setAlpha); + CB(GUI_GETALPHA, guiobject_getAlpha); + VCB(GUI_ONSTARTUP, guiobject_onStartup); + CB(GUI_GETXUISVC, guiobject_getXuiService); + VCB(GUI_SETXUISVC, guiobject_setXuiService); + CB(GUI_GETXUIFAC, guiobject_getXuiServiceFactory); + VCB(GUI_SETXUIFAC, guiobject_setXuiServiceFactory); + VCB(GUI_SETREGIONOP, guiobject_setRegionOp); + CB(GUI_GETREGIONOP, guiobject_getRegionOp); + VCB(GUI_SETRECTRGN, guiobject_setRectRgn); + CB(GUI_ISRECTRGN, guiobject_isRectRgn); + VCB(GUI_SETMOVER, guiobject_setMover); + CB(GUI_GETMOVER, guiobject_getMover); + CB(GUI_GETDROPTARGET, guiobject_getDropTarget); + VCB(GUI_ONCANCELCAPTURE, guiobject_onCancelCapture); + CB(GUI_ONACTION, guiobject_onAction); +#ifdef WASABI_COMPILE_CONFIG + CB(GUI_GETCFGITEM, guiobject_getCfgItem); + CB(GUI_GETCFGATTRIB, guiobject_getCfgAttrib); + VCB(GUI_SETCFGATTRIB, guiobject_setCfgAttrib); + VCB(GUI_SETCFGINT, guiobject_setCfgInt); + CB(GUI_GETCFGINT, guiobject_getCfgInt); + CB(GUI_GETCFGFLOAT, guiobject_getCfgFloat); + VCB(GUI_SETCFGFLOAT, guiobject_setCfgFloat); + VCB(GUI_SETCFGSTRING, guiobject_setCfgString); + CB(GUI_GETCFGSTRING, guiobject_getCfgString); + CB(GUI_HASATTRIB, guiobject_hasCfgAttrib); +#endif + VCB(GUI_ONCHAR, guiobject_onChar); + VCB(GUI_ONKEYDOWN, guiobject_onKeyDown); + VCB(GUI_ONKEYUP, guiobject_onKeyUp); + CB(GUI_FINDOBJECT, guiobject_findObject); + CB(GUI_FINDOBJECTBYGUID, guiobject_findObjectByInterface); + CB(GUI_FINDOBJECTBYCB, guiobject_findObjectByCallback); + CB(GUI_FINDOBJECTXY, guiobject_findObjectXY); + VCB(GUI_ONACCELERATOR, guiobject_onAccelerator); + VCB(GUI_ONINIT, guiobject_onInit); + CB(GUI_WANTFOCUS, guiobject_wantFocus); + VCB(GUI_SETNODOUBLECLICK, guiobject_setNoDoubleClick); + VCB(GUI_SETNOLEFTCLICK, guiobject_setNoLeftClick); + VCB(GUI_SETNORIGHTCLICK, guiobject_setNoRightClick); + VCB(GUI_SETNOMOUSEMOVE, guiobject_setNoMouseMove); + VCB(GUI_SETNOCONTEXTMENU, guiobject_setNoContextMenu); + VCB(GUI_SETCURSOR, guiobject_setCursor); +#ifdef WASABI_COMPILE_WNDMGR + CB(GUI_RUNMODAL, guiobject_runModal); + VCB(GUI_ENDMODAL, guiobject_endModal); + VCB(GUI_SETDROPTARGET, guiobject_setDropTarget); + VCB(GUI_SETSTATUSTXT, guiobject_setStatusText); + VCB(GUI_ADDCTXTCMDS, guiobject_addAppCmds); + VCB(GUI_REMCTXTCMDS, guiobject_removeAppCmds); + VCB(GUI_PUSHCOMPLETED, guiobject_pushCompleted); + VCB(GUI_INCCOMPLETED, guiobject_incCompleted); + VCB(GUI_SETCOMPLETED, guiobject_setCompleted); + VCB(GUI_POPCOMPLETED, guiobject_popCompleted); + VCB(GUI_REGISTERSTATUSCB, guiobject_registerStatusCB); + VCB(GUI_POPPARENTLAYOUT, guiobject_popParentLayout); +#endif + VCB(GUI_SETAPPBAR, guiobject_setAppBar); + CB(GUI_GETAPPBAR, guiobject_getAppBar); + CB(GUI_WANTTRANSLATION, guiobject_wantTranslation); + CB(GUI_DRAGENTER, guiobject_dragEnter); + CB(GUI_DRAGOVER, guiobject_dragOver); + CB(GUI_DRAGLEAVE, guiobject_dragLeave); +END_DISPATCH; diff --git a/Src/Wasabi/api/script/objects/guiobjectx.h b/Src/Wasabi/api/script/objects/guiobjectx.h new file mode 100644 index 00000000..c840476c --- /dev/null +++ b/Src/Wasabi/api/script/objects/guiobjectx.h @@ -0,0 +1,177 @@ +#ifndef NULLSOFT_WASABI_GUIOBJECTX_H +#define NULLSOFT_WASABI_GUIOBJECTX_H + +#include +#include + +class GuiObjectX : public GuiObject +{ +public: + virtual ~GuiObjectX() {} + + virtual ifc_window *guiobject_getRootWnd()=0; + virtual void guiobject_setRootWnd(ifc_window *w)=0; + virtual void guiobject_onInit()=0; + + virtual void guiobject_getGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh)=0; + virtual void guiobject_setGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh)=0; + virtual int guiobject_getAnchoragePosition(int *x1, int *y1, int *x2, int *y2, int *anchor)=0; + virtual void guiobject_setAnchoragePosition(int *x1, int *y1, int *x2, int *y2, int *anchor)=0; + virtual void guiobject_validateAnchorage()=0; + + virtual void guiobject_setParentGroup(Group *g)=0; + virtual ScriptObject *guiobject_getScriptObject()=0; + virtual RootObject *guiobject_getRootObject()=0; + virtual Group *guiobject_getParentGroup()=0; + virtual GuiObject *guiobject_getParent()=0; + virtual void guiobject_setTabOrder(int a)=0; + + virtual void guiobject_setId(const wchar_t *id)=0; + virtual const wchar_t *guiobject_getId()=0; + + virtual void guiobject_setTargetX(int tx)=0; + virtual void guiobject_setTargetY(int ty)=0; + virtual void guiobject_setTargetW(int tw)=0; + virtual void guiobject_setTargetH(int th)=0; + virtual void guiobject_setTargetA(int th)=0; + virtual void guiobject_setTargetSpeed(float s)=0; + virtual void guiobject_gotoTarget(void)=0; + virtual void guiobject_cancelTarget()=0; + virtual void guiobject_reverseTarget(int reverse)=0; + + virtual int guiobject_getAutoWidth()=0; + virtual int guiobject_getAutoHeight()=0; + virtual int guiobject_movingToTarget()=0; + + virtual void guiobject_bringToFront()=0; + virtual void guiobject_bringToBack()=0; + virtual void guiobject_bringAbove(GuiObject *o)=0; + virtual void guiobject_bringBelow(GuiObject *o)=0; + + virtual void guiobject_setClickThrough(int ct)=0; + virtual int guiobject_isClickThrough()=0; + + virtual void guiobject_setAutoSysMetricsX(int a)=0; + virtual void guiobject_setAutoSysMetricsY(int a)=0; + virtual void guiobject_setAutoSysMetricsW(int a)=0; + virtual void guiobject_setAutoSysMetricsH(int a)=0; + virtual int guiobject_getAutoSysMetricsX()=0; + virtual int guiobject_getAutoSysMetricsY()=0; + virtual int guiobject_getAutoSysMetricsW()=0; + virtual int guiobject_getAutoSysMetricsH()=0; + + virtual int guiobject_getRegionOp()=0; + virtual void guiobject_setRegionOp(int op)=0; + virtual int guiobject_isRectRgn()=0; + virtual void guiobject_setRectRgn(int rrgn)=0; + + virtual void guiobject_onLeftButtonDown(int x, int y)=0; + virtual void guiobject_onLeftButtonUp(int x, int y)=0; + virtual void guiobject_onRightButtonDown(int x, int y)=0; + virtual void guiobject_onRightButtonUp(int x, int y)=0; + virtual void guiobject_onLeftButtonDblClk(int x, int y)=0; + virtual void guiobject_onRightButtonDblClk(int x, int y)=0; + virtual int guiobject_onMouseWheelUp(int click, int lines)=0; + virtual int guiobject_onMouseWheelDown(int click, int lines)=0; + virtual void guiobject_onMouseMove(int x, int y)=0; + virtual void guiobject_onEnterArea()=0; + virtual void guiobject_onLeaveArea()=0; + virtual void guiobject_onEnable(int en)=0; + virtual void guiobject_setEnabled(int en)=0; + virtual void guiobject_onResize(int x, int y, int w, int h)=0; + virtual void guiobject_onSetVisible(int v)=0; + virtual void guiobject_onTargetReached()=0; + virtual void guiobject_setAlpha(int a)=0; + virtual void guiobject_setActiveAlpha(int a)=0; + virtual void guiobject_setInactiveAlpha(int a)=0; + virtual int guiobject_getAlpha()=0; + virtual int guiobject_getActiveAlpha()=0; + virtual int guiobject_getInactiveAlpha()=0; + virtual int guiobject_isActive()=0; + virtual void guiobject_onStartup()=0; + virtual int guiobject_setXmlParam(const wchar_t *param, const wchar_t *value)=0; + virtual const wchar_t *guiobject_getXmlParam(const wchar_t *param)=0; + virtual int guiobject_setXmlParamById(int id, const wchar_t *value)=0; + virtual svc_xuiObject *guiobject_getXuiService()=0; + virtual void guiobject_setXuiService(svc_xuiObject *svc)=0; + virtual waServiceFactory *guiobject_getXuiServiceFactory()=0; + virtual void guiobject_setXuiServiceFactory(waServiceFactory *fac)=0; + virtual GuiObject *guiobject_getTopParent()=0; +#ifdef WASABI_COMPILE_WNDMGR + virtual Layout *guiobject_getParentLayout()=0; + virtual int guiobject_runModal()=0; + virtual void guiobject_endModal(int retcode)=0; + virtual void guiobject_popParentLayout()=0; + virtual void guiobject_registerStatusCB(GuiStatusCallback *cb)=0; + virtual void guiobject_setStatusText(const wchar_t *txt, int overlay = FALSE)=0; + virtual void guiobject_addAppCmds(AppCmds *commands)=0; + virtual void guiobject_removeAppCmds(AppCmds *commands)=0; + virtual void guiobject_pushCompleted(int max = 100)=0; + virtual void guiobject_incCompleted(int add = 1)=0; + virtual void guiobject_setCompleted(int pos)=0; + virtual void guiobject_popCompleted()=0; +#endif + virtual GuiObject *guiobject_findObject(const wchar_t *id)=0; + virtual GuiObject *guiobject_findObjectXY(int x, int y)=0; // in client coordinates relative to this object + virtual GuiObject *guiobject_findObjectByInterface(GUID interface_guid)=0; + virtual GuiObject *guiobject_findObjectByCallback(FindObjectCallback *cb)=0; + virtual void guiobject_setMover(int m)=0; + virtual int guiobject_getMover()=0; + virtual void guiobject_onCancelCapture()=0; + virtual void guiobject_onChar(wchar_t c)=0; + virtual void guiobject_onKeyDown(int vkcode)=0; + virtual void guiobject_onKeyUp(int vkcode)=0; + + virtual FOURCC guiobject_getDropTarget()=0; + virtual void guiobject_setDropTarget(const wchar_t *strval)=0; + + virtual void onTargetTimer()=0; +#ifdef USEAPPBAR + virtual int guiobject_getAppBar()=0; + virtual void guiobject_setAppBar(int en)=0; + virtual void setAppBar(const wchar_t *en)=0; +#endif + +#ifdef WASABI_COMPILE_CONFIG + virtual void guiobject_setCfgAttrib(CfgItem *item, const wchar_t *name)=0; + + virtual CfgItem *guiobject_getCfgItem()=0; + virtual const wchar_t *guiobject_getCfgAttrib()=0; + + virtual int guiobject_getCfgInt()=0; + virtual void guiobject_setCfgInt(int i)=0; + virtual float guiobject_getCfgFloat()=0; + virtual void guiobject_setCfgFloat(float f)=0; + virtual const wchar_t *guiobject_getCfgString()=0; + virtual void guiobject_setCfgString(const wchar_t *s)=0; + virtual int guiobject_hasCfgAttrib()=0; +#endif + + virtual const wchar_t *guiobject_getName()=0; + virtual void guiobject_onAccelerator(const wchar_t *accel)=0; + virtual int guiobject_onAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2, void *data, size_t datalen, ifc_window *source)=0; + + virtual int guiobject_wantFocus()=0; + virtual void guiobject_setNoDoubleClick(int no)=0; + virtual void guiobject_setNoLeftClick(int no)=0; + virtual void guiobject_setNoRightClick(int no)=0; + virtual void guiobject_setNoMouseMove(int no)=0; + virtual void guiobject_setNoContextMenu(int no)=0; + + virtual void guiobject_setCursor(const wchar_t *c)=0; + virtual int guiobject_wantTranslation()=0; + + virtual int guiobject_dragEnter(ifc_window *sourceWnd)=0; + virtual int guiobject_dragOver(int x, int y, ifc_window *sourceWnd)=0; + virtual int guiobject_dragLeave(ifc_window *sourceWnd)=0; + +protected: + RECVS_DISPATCH; + +}; + + + + + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/rootobj.cpp b/Src/Wasabi/api/script/objects/rootobj.cpp new file mode 100644 index 00000000..8791f430 --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobj.cpp @@ -0,0 +1,42 @@ +#include +#include "rootobj.h" +#include +#include "api.h" +#include + +RootObjectInstance::RootObjectInstance() +{ + ASSERT(WASABI_API_MAKI != 0); + rootobject_init(); +} + +RootObjectInstance::~RootObjectInstance() +{ + WASABI_API_MAKI->maki_deencapsulate(rootObjectGuid, my_root_object); +} + +RootObject *RootObjectInstance::getRootObject() { + return my_root_object; +} + +ScriptObject *RootObjectInstance::getScriptObject() { + return &my_script_object; +} + +const wchar_t *RootObjectInstance::getClassName() +{ + return my_root_object->rootobject_getClassName(); +} + +void RootObjectInstance::notify(const wchar_t *s, const wchar_t *t, int u, int v) { + my_root_object->rootobject_notify(s, t, u, v); +} + +void RootObjectInstance::rootobject_init() +{ + my_root_object = static_cast(WASABI_API_MAKI->maki_encapsulate(rootObjectGuid, &my_script_object)); // creates an encapsulated RootObject + my_script_object.vcpu_setInterface(rootObjectInstanceGuid, static_cast(this)); + my_script_object.vcpu_setClassName(L"Object"); + my_script_object.vcpu_setController(WASABI_API_MAKI->maki_getController(rootObjectGuid)); +} + diff --git a/Src/Wasabi/api/script/objects/rootobj.h b/Src/Wasabi/api/script/objects/rootobj.h new file mode 100644 index 00000000..4a44f8c2 --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobj.h @@ -0,0 +1,40 @@ +#ifndef __ROOTOBJ_H +#define __ROOTOBJ_H + +#include +#include +#include + +class ScriptObject; +class ScriptObjectI; +class RootObject; + +// RootObjectInstance::this == RootObjectInstance::getScriptObject()->vcpu_getInterface(rootObjectInstanceGuid); +// {F6D49468-4036-41a1-9683-C372416AD31B} +static const GUID rootObjectInstanceGuid = +{ 0xf6d49468, 0x4036, 0x41a1, { 0x96, 0x83, 0xc3, 0x72, 0x41, 0x6a, 0xd3, 0x1b } }; + +// Instantiate this class to create an object from which you can trap notify events, or inherit from +// it if you want to implement your own descendant of script class 'Object' (see GuiObjectWnd) +class RootObjectInstance : public RootObjectCallbackI +{ +public: + + RootObjectInstance(); + virtual ~RootObjectInstance(); + + virtual RootObject *getRootObject(); + virtual ScriptObject *getScriptObject(); + + virtual void rootobjectcb_onNotify(const wchar_t *a, const wchar_t *b, int c, int d) {}; + virtual const wchar_t *getClassName(); + virtual void notify(const wchar_t *s, const wchar_t *t, int u, int v); + + private: + void rootobject_init(); + ScriptObjectI my_script_object; + RootObject * my_root_object; +}; + + +#endif diff --git a/Src/Wasabi/api/script/objects/rootobjcb.cpp b/Src/Wasabi/api/script/objects/rootobjcb.cpp new file mode 100644 index 00000000..212a943e --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjcb.cpp @@ -0,0 +1,12 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Thu May 15 21:06:33 2003] +// +// File : rootobjcb.cpp +// Class : RootObjectCallback +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#include +#include "rootobjcb.h" + + diff --git a/Src/Wasabi/api/script/objects/rootobjcb.h b/Src/Wasabi/api/script/objects/rootobjcb.h new file mode 100644 index 00000000..9e3f1e3c --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjcb.h @@ -0,0 +1,40 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Thu May 15 21:06:33 2003] +// +// File : rootobjcb.h +// Class : RootObjectCallback +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#ifndef __ROOTOBJECTCALLBACK_H +#define __ROOTOBJECTCALLBACK_H + +#include +#include + + + +// ---------------------------------------------------------------------------- + +class RootObjectCallback: public Dispatchable { + protected: + RootObjectCallback() {} + ~RootObjectCallback() {} + public: + void rootobjectcb_onNotify(const wchar_t *a, const wchar_t *b, int c, int d); + + protected: + enum { + ROOTOBJECTCALLBACK_ROOTOBJECTCB_ONNOTIFY = 10, + }; +}; + +// ---------------------------------------------------------------------------- + +inline void RootObjectCallback::rootobjectcb_onNotify(const wchar_t *a, const wchar_t *b, int c, int d) { + _voidcall(ROOTOBJECTCALLBACK_ROOTOBJECTCB_ONNOTIFY, a, b, c, d); +} + +// ---------------------------------------------------------------------------- + +#endif // __ROOTOBJECTCALLBACK_H diff --git a/Src/Wasabi/api/script/objects/rootobjcbi.cpp b/Src/Wasabi/api/script/objects/rootobjcbi.cpp new file mode 100644 index 00000000..9545e59e --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjcbi.cpp @@ -0,0 +1,3 @@ +#include +#include "rootobjcb.h" + diff --git a/Src/Wasabi/api/script/objects/rootobjcbi.h b/Src/Wasabi/api/script/objects/rootobjcbi.h new file mode 100644 index 00000000..14dd63ad --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjcbi.h @@ -0,0 +1,15 @@ +#ifndef __ROOTOBJCB_H +#define __ROOTOBJCB_H + +// +#include "rootobjcb.h" +#include "rootobjcbx.h" + +//?> + +class NOVTABLE RootObjectCallbackI : public RootObjectCallbackX { + public: + DISPATCH(10) virtual void rootobjectcb_onNotify(const wchar_t *a, const wchar_t *b, int c, int d)=0; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/rootobjcbx.cpp b/Src/Wasabi/api/script/objects/rootobjcbx.cpp new file mode 100644 index 00000000..84ce169c --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjcbx.cpp @@ -0,0 +1,20 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Thu May 15 21:06:33 2003] +// +// File : rootobjcbx.cpp +// Class : RootObjectCallback +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- +#include "rootobjcbx.h" +#include "rootobjcbi.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif + +#define CBCLASS RootObjectCallbackX +START_DISPATCH; + VCB(ROOTOBJECTCALLBACK_ROOTOBJECTCB_ONNOTIFY, rootobjectcb_onNotify); +END_DISPATCH; +#undef CBCLASS + diff --git a/Src/Wasabi/api/script/objects/rootobjcbx.h b/Src/Wasabi/api/script/objects/rootobjcbx.h new file mode 100644 index 00000000..eb07530c --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjcbx.h @@ -0,0 +1,29 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Thu May 15 21:06:33 2003] +// +// File : rootobjcbx.h +// Class : RootObjectCallback +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- + +#ifndef __ROOTOBJECTCALLBACKX_H +#define __ROOTOBJECTCALLBACKX_H + +#include "rootobjcb.h" + + + + +// ---------------------------------------------------------------------------- + +class RootObjectCallbackX : public RootObjectCallback { + protected: + RootObjectCallbackX() {} + public: + virtual void rootobjectcb_onNotify(const wchar_t *a, const wchar_t *b, int c, int d)=0; + + protected: + RECVS_DISPATCH; +}; + +#endif // __ROOTOBJECTCALLBACKX_H diff --git a/Src/Wasabi/api/script/objects/rootobjcontroller.cpp b/Src/Wasabi/api/script/objects/rootobjcontroller.cpp new file mode 100644 index 00000000..94a6f396 --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjcontroller.cpp @@ -0,0 +1,81 @@ +#include "precomp.h" +//" +#include "rootobjcontroller.h" +//?> + +#include +#include + +RootScriptObjectController _rootScriptObjectController; +RootScriptObjectController *rootScriptObjectController = &_rootScriptObjectController; + +// -- Functions table ------------------------------------- +function_descriptor_struct RootScriptObjectController::exportedFunction[] = { + {L"getClassName", 0, (void*)RootObject_ScriptMethods::getClassName }, + {L"notify", 4, (void*)RootObject_ScriptMethods::notify }, + {L"onNotify", 4, (void*)RootObject_ScriptMethods::onNotify }, +}; + +const wchar_t *RootScriptObjectController::getClassName() { + return L"Object"; +} + +const wchar_t *RootScriptObjectController::getAncestorClassName() { + return NULL; +} + +int RootScriptObjectController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *RootScriptObjectController::getExportedFunctions() { + return exportedFunction; +} + +GUID RootScriptObjectController::getClassGuid() { + return rootObjectGuid; +} + +ScriptObject *RootScriptObjectController::instantiate() { + RootObjectInstance *o = new RootObjectInstance; + ASSERT(o != NULL); + return o->getScriptObject(); +} + +void RootScriptObjectController::destroy(ScriptObject *o) { + RootObjectInstance *obj = static_cast(o->vcpu_getInterface(rootObjectGuid)); + ASSERT(obj != NULL); + delete obj; +} + +void RootScriptObjectController::deencapsulate(void *o) { + RootObjectI *obj = static_cast(o); + delete obj; +} + +void *RootScriptObjectController::encapsulate(ScriptObject *o) { + return new RootObjectI(o); +} + +// ------------------------------------------------------------------------------------------------------------------------------------- +// Script Methods and Events for RootObject (Object) +// ------------------------------------------------------------------------------------------------------------------------------------- + +scriptVar RootObject_ScriptMethods::getClassName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_STRING(o->vcpu_getClassName()); +} + +scriptVar RootObject_ScriptMethods::onNotify(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s, scriptVar s2, scriptVar i1, scriptVar i2) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS4(o, rootScriptObjectController, s, s2, i1, i2); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT4(o, s, s2, i1, i2); +} + +scriptVar RootObject_ScriptMethods::notify(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s, scriptVar s2, scriptVar i1, scriptVar i2) { + SCRIPT_FUNCTION_INIT + RootObject *ro = static_cast(o->vcpu_getInterface(rootObjectGuid)); + if (ro) ro->rootobject_notify(GET_SCRIPT_STRING(s), GET_SCRIPT_STRING(s2), GET_SCRIPT_INT(i1), GET_SCRIPT_INT(i2)); + RETURN_SCRIPT_VOID; +} diff --git a/Src/Wasabi/api/script/objects/rootobjcontroller.h b/Src/Wasabi/api/script/objects/rootobjcontroller.h new file mode 100644 index 00000000..4dbb81fb --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjcontroller.h @@ -0,0 +1,36 @@ +#ifndef __ROOTSCRIPTOBJECTCONTROLLER_IMPL_H +#define __ROOTSCRIPTOBJECTCONTROLLER_IMPL_H + +#include +/**/ +class ScriptObject; +class ScriptObjectController; +/*?>*/ + +class RootScriptObjectController : public ScriptObjectControllerI +{ + public: + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController() { return NULL; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void deencapsulate(void *o); + virtual void *encapsulate(ScriptObject *o); + private: + static function_descriptor_struct exportedFunction[]; +}; + +class RootObject_ScriptMethods { + public: + static scriptVar getClassName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar onNotify(SCRIPT_FUNCTION_PARAMS, ScriptObject *on, scriptVar s, scriptVar s2, scriptVar i1, scriptVar i2); + static scriptVar notify(SCRIPT_FUNCTION_PARAMS, ScriptObject *on, scriptVar s, scriptVar s2, scriptVar i1, scriptVar i2); +}; + +extern RootScriptObjectController *rootScriptObjectController; + +#endif // __ROOTSCRIPTOBJECTCONTROLLER_IMPL_H diff --git a/Src/Wasabi/api/script/objects/rootobject.cpp b/Src/Wasabi/api/script/objects/rootobject.cpp new file mode 100644 index 00000000..1ebc36f1 --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobject.cpp @@ -0,0 +1,12 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Fri May 16 23:15:13 2003] +// +// File : rootobject.cpp +// Class : RootObject +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#include +#include "rootobject.h" + + diff --git a/Src/Wasabi/api/script/objects/rootobject.h b/Src/Wasabi/api/script/objects/rootobject.h new file mode 100644 index 00000000..c18fd1f9 --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobject.h @@ -0,0 +1,71 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Fri May 16 23:15:13 2003] +// +// File : rootobject.h +// Class : RootObject +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#ifndef __ROOTOBJECT_H +#define __ROOTOBJECT_H + +#include +#include + +class RootObjectCallback; +class ScriptObject; + + + +#include + +// ---------------------------------------------------------------------------- + +class RootObject: public Dispatchable { + protected: + RootObject() {} + ~RootObject() {} + public: + const wchar_t *rootobject_getClassName(); + void rootobject_notify(const wchar_t *s, const wchar_t *t, int u, int v); + ScriptObject *rootobject_getScriptObject(); + void rootobject_setScriptObject(ScriptObject *obj); + void rootobject_addCB(RootObjectCallback *cb); + + protected: + enum { + ROOTOBJECT_ROOTOBJECT_GETCLASSNAME = 10, + ROOTOBJECT_ROOTOBJECT_NOTIFY = 20, + ROOTOBJECT_ROOTOBJECT_GETSCRIPTOBJECT = 30, + ROOTOBJECT_ROOTOBJECT_SETSCRIPTOBJECT = 40, + ROOTOBJECT_ROOTOBJECT_ADDCB = 50, + }; +}; + +// ---------------------------------------------------------------------------- + +inline const wchar_t *RootObject::rootobject_getClassName() { + const wchar_t *__retval = _call(ROOTOBJECT_ROOTOBJECT_GETCLASSNAME, (const wchar_t *)0); + return __retval; +} + +inline void RootObject::rootobject_notify(const wchar_t *s, const wchar_t *t, int u, int v) { + _voidcall(ROOTOBJECT_ROOTOBJECT_NOTIFY, s, t, u, v); +} + +inline ScriptObject *RootObject::rootobject_getScriptObject() { + ScriptObject *__retval = _call(ROOTOBJECT_ROOTOBJECT_GETSCRIPTOBJECT, (ScriptObject *)NULL); + return __retval; +} + +inline void RootObject::rootobject_setScriptObject(ScriptObject *obj) { + _voidcall(ROOTOBJECT_ROOTOBJECT_SETSCRIPTOBJECT, obj); +} + +inline void RootObject::rootobject_addCB(RootObjectCallback *cb) { + _voidcall(ROOTOBJECT_ROOTOBJECT_ADDCB, cb); +} + +// ---------------------------------------------------------------------------- + +#endif // __ROOTOBJECT_H diff --git a/Src/Wasabi/api/script/objects/rootobjecti.cpp b/Src/Wasabi/api/script/objects/rootobjecti.cpp new file mode 100644 index 00000000..cb6e2f3b --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjecti.cpp @@ -0,0 +1,46 @@ +#include + +//" +#include "rootobjecti.h" +//?> + +#include +#include +#include +#include + + +// -------------------------------------------------------------------------------------------- + +RootObjectI::RootObjectI(ScriptObject *o) { + my_script_object = o; +} + +RootObjectI::~RootObjectI() { +} + +const wchar_t *RootObjectI::rootobject_getClassName() +{ + if (!my_script_object) return NULL; + return my_script_object->vcpu_getClassName(); +} + +void RootObjectI::rootobject_notify(const wchar_t *s, const wchar_t *t, int u, int v) { + foreach(cbs) + cbs.getfor()->rootobjectcb_onNotify(s, t, u, v); + endfor; + RootObject_ScriptMethods::onNotify(SCRIPT_CALL, rootobject_getScriptObject(), MAKE_SCRIPT_STRING(s), MAKE_SCRIPT_STRING(t), MAKE_SCRIPT_INT(u), MAKE_SCRIPT_INT(v)); +} + +ScriptObject *RootObjectI::rootobject_getScriptObject() { + return my_script_object; +} + +void RootObjectI::rootobject_setScriptObject(ScriptObject *obj) { + my_script_object = obj; +} + +void RootObjectI::rootobject_addCB(RootObjectCallback *cb) { + cbs.addItem(cb); +} + diff --git a/Src/Wasabi/api/script/objects/rootobjecti.h b/Src/Wasabi/api/script/objects/rootobjecti.h new file mode 100644 index 00000000..a76361e2 --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjecti.h @@ -0,0 +1,32 @@ +#ifndef __ROOTOBJECTI_IMPL_H +#define __ROOTOBJECTI_IMPL_H + +/**/ +#include "rootobject.h" +#include "rootobjectx.h" + +class RootObjectCallback; +class ScriptObject; +/*?>*/ + +/*[interface.header.h] +#include "common/script/rootobjcontroller.h" +*/ + +extern RootScriptObjectController *rootScriptObjectController; + +class RootObjectI : public RootObjectX { +public: + RootObjectI(ScriptObject *o); + virtual ~RootObjectI(); + DISPATCH(10) virtual const wchar_t *rootobject_getClassName(); + DISPATCH(20) virtual void rootobject_notify(const wchar_t *s, const wchar_t *t, int u, int v); + DISPATCH(30) virtual ScriptObject *rootobject_getScriptObject(); + DISPATCH(40) virtual void rootobject_setScriptObject(ScriptObject *obj); + DISPATCH(50) virtual void rootobject_addCB(RootObjectCallback *cb); + PtrList < RootObjectCallback > cbs; + ScriptObject * my_script_object; +}; + + +#endif // __ROOTOBJECTI_IMPL_H diff --git a/Src/Wasabi/api/script/objects/rootobjectx.cpp b/Src/Wasabi/api/script/objects/rootobjectx.cpp new file mode 100644 index 00000000..824a6825 --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjectx.cpp @@ -0,0 +1,22 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Fri May 16 23:15:13 2003] +// +// File : rootobjectx.cpp +// Class : RootObject +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- +#include "precomp.h" + +#include "rootobjectx.h" +#include "rootobjecti.h" + +#define CBCLASS RootObjectX +START_DISPATCH; + CB(ROOTOBJECT_ROOTOBJECT_GETCLASSNAME, rootobject_getClassName); + VCB(ROOTOBJECT_ROOTOBJECT_NOTIFY, rootobject_notify); + CB(ROOTOBJECT_ROOTOBJECT_GETSCRIPTOBJECT, rootobject_getScriptObject); + VCB(ROOTOBJECT_ROOTOBJECT_SETSCRIPTOBJECT, rootobject_setScriptObject); + VCB(ROOTOBJECT_ROOTOBJECT_ADDCB, rootobject_addCB); +END_DISPATCH; +#undef CBCLASS + diff --git a/Src/Wasabi/api/script/objects/rootobjectx.h b/Src/Wasabi/api/script/objects/rootobjectx.h new file mode 100644 index 00000000..687293a7 --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjectx.h @@ -0,0 +1,35 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Fri May 16 23:15:13 2003] +// +// File : rootobjectx.h +// Class : RootObject +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- + +#ifndef __ROOTOBJECTX_H +#define __ROOTOBJECTX_H + +#include "rootobject.h" + +class RootObjectCallback; +class ScriptObject; + + + +// ---------------------------------------------------------------------------- + +class RootObjectX : public RootObject { + protected: + RootObjectX() {} + public: + virtual const wchar_t *rootobject_getClassName()=0; + virtual void rootobject_notify(const wchar_t *s, const wchar_t *t, int u, int v)=0; + virtual ScriptObject *rootobject_getScriptObject()=0; + virtual void rootobject_setScriptObject(ScriptObject *obj)=0; + virtual void rootobject_addCB(RootObjectCallback *cb)=0; + + protected: + RECVS_DISPATCH; +}; + +#endif // __ROOTOBJECTX_H diff --git a/Src/Wasabi/api/script/objects/sapplication.cpp b/Src/Wasabi/api/script/objects/sapplication.cpp new file mode 100644 index 00000000..d1dca910 --- /dev/null +++ b/Src/Wasabi/api/script/objects/sapplication.cpp @@ -0,0 +1,213 @@ +#include "sapplication.h" +#include +#include + +// {B8E867B0-2715-4da7-A5BA-53DBA1FCFEAC} +static const GUID application_script_object_guid = +{ 0xb8e867b0, 0x2715, 0x4da7, { 0xa5, 0xba, 0x53, 0xdb, 0xa1, 0xfc, 0xfe, 0xac } }; + +static ApplicationScriptObjectController _applicationController; +ScriptObjectController *applicationController=&_applicationController; + +// -- Functions table ------------------------------------- +function_descriptor_struct ApplicationScriptObjectController::exportedFunction[] = +{ + {L"GetApplicationName", 0, (void*)SApplication::GetApplicationName }, + {L"GetVersionString", 0, (void*)SApplication::GetVersionString }, + {L"GetVersionNumberString", 0, (void*)SApplication::GetVersionNumberString }, + {L"GetBuildNumber",0, (void*)SApplication::GetBuildNumber }, + {L"GetGUID",0, (void*)SApplication::GetGUID }, + {L"GetCommandLine",0, (void*)SApplication::GetCommandLine }, + {L"Shutdown",0, (void*)SApplication::Shutdown }, + {L"CancelShutdown",0, (void*)SApplication::CancelShutdown }, + {L"IsShuttingDown",0, (void*)SApplication::IsShuttingDown }, + {L"GetApplicationPath",0, (void*)SApplication::GetApplicationPath }, + {L"GetSettingsPath",0, (void*)SApplication::GetSettingsPath }, + {L"GetWorkingPath",0, (void*)SApplication::GetWorkingPath }, + {L"SetWorkingPath",1, (void*)SApplication::SetWorkingPath }, + {L"GetMachineGUID",0, (void*)SApplication::GetMachineGUID }, + {L"GetUserGUID",0, (void*)SApplication::GetUserGUID }, + {L"GetSessionGUID",0, (void*)SApplication::GetSessionGUID }, +}; +// -------------------------------------------------------- + +const wchar_t *ApplicationScriptObjectController::getClassName() +{ + return L"Application"; +} + +const wchar_t *ApplicationScriptObjectController::getAncestorClassName() +{ + return L"Object"; +} + +ScriptObjectController *ApplicationScriptObjectController::getAncestorController() +{ + return NULL; +} + +ScriptObject *ApplicationScriptObjectController::instantiate() +{ + SApplication *c = new SApplication; + if (!c) return NULL; + return c->getScriptObject(); +} + +int ApplicationScriptObjectController::getInstantiable() +{ + return 0; +} + +void ApplicationScriptObjectController::destroy(ScriptObject *o) +{ + SApplication *obj = static_cast(o->vcpu_getInterface(application_script_object_guid)); + ASSERT(obj != NULL); + delete obj; +} + +void *ApplicationScriptObjectController::encapsulate(ScriptObject *o) +{ + return NULL; +} + +void ApplicationScriptObjectController::deencapsulate(void *o) +{ +} + +int ApplicationScriptObjectController::getNumFunctions() +{ + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *ApplicationScriptObjectController::getExportedFunctions() +{ + return exportedFunction; +} + +GUID ApplicationScriptObjectController::getClassGuid() +{ + return application_script_object_guid; +} + + +SApplication::SApplication() +{ + getScriptObject()->vcpu_setInterface(application_script_object_guid, static_cast(this)); + getScriptObject()->vcpu_setClassName(L"Application"); + getScriptObject()->vcpu_setController(applicationController); +} +SApplication::~SApplication() +{ +} + +static wchar_t guid_scratchpad[40]; + +scriptVar SApplication::GetApplicationName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_STRING(WASABI_API_APP->main_getAppName()); +} + +scriptVar SApplication::GetVersionString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_STRING(WASABI_API_APP->main_getVersionString()); +} + +scriptVar SApplication::GetVersionNumberString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_STRING(WASABI_API_APP->main_getVersionNumString()); +} + +scriptVar SApplication::GetBuildNumber(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT(WASABI_API_APP->main_getBuildNumber()); +} + +scriptVar SApplication::GetGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + GUID g = WASABI_API_APP->main_getGUID(); + nsGUID::toCharW(g, guid_scratchpad); + return MAKE_SCRIPT_STRING(guid_scratchpad); +} + +scriptVar SApplication::GetCommandLine(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_STRING(WASABI_API_APP->main_getCommandLine()); +} + +scriptVar SApplication::Shutdown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + WASABI_API_APP->main_shutdown(); + return MAKE_SCRIPT_VOID(); +} + +scriptVar SApplication::CancelShutdown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + WASABI_API_APP->main_cancelShutdown(); + return MAKE_SCRIPT_VOID(); +} + +scriptVar SApplication::IsShuttingDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_BOOLEAN(WASABI_API_APP->main_isShuttingDown()); +} + +scriptVar SApplication::GetApplicationPath(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_STRING(WASABI_API_APP->path_getAppPath()); +} + +scriptVar SApplication::GetSettingsPath(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_STRING(WASABI_API_APP->path_getUserSettingsPath()); +} + +scriptVar SApplication::GetWorkingPath(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_STRING(WASABI_API_APP->path_getWorkingPath()); +} + +scriptVar SApplication::SetWorkingPath(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar string_path) +{ + SCRIPT_FUNCTION_INIT; + WASABI_API_APP->path_setWorkingPath(GET_SCRIPT_STRING(string_path)); + return MAKE_SCRIPT_VOID(); +} + +scriptVar SApplication::GetMachineGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + GUID g; + WASABI_API_APP->GetMachineID(&g); + nsGUID::toCharW(g, guid_scratchpad); + return MAKE_SCRIPT_STRING(guid_scratchpad); +} + +scriptVar SApplication::GetUserGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + GUID g; + WASABI_API_APP->GetUserID(&g); + nsGUID::toCharW(g, guid_scratchpad); + return MAKE_SCRIPT_STRING(guid_scratchpad); +} + +scriptVar SApplication::GetSessionGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + GUID g; + WASABI_API_APP->GetSessionID(&g); + nsGUID::toCharW(g, guid_scratchpad); + return MAKE_SCRIPT_STRING(guid_scratchpad); +} diff --git a/Src/Wasabi/api/script/objects/sapplication.h b/Src/Wasabi/api/script/objects/sapplication.h new file mode 100644 index 00000000..f6ec099f --- /dev/null +++ b/Src/Wasabi/api/script/objects/sapplication.h @@ -0,0 +1,57 @@ +#pragma once +#include +#include +#include +#include +#include + +#define SApplication_SCRIPTPARENT RootObjectInstance + +class ApplicationScriptObjectController : public ScriptObjectControllerI +{ + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual int getInstantiable(); + virtual int getReferenceable() {return 0;} + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + static function_descriptor_struct exportedFunction[]; + +}; + +extern ScriptObjectController *applicationController; + +class SApplication : public SApplication_SCRIPTPARENT +{ +public: + SApplication(); + virtual ~SApplication(); + +public: + static scriptVar GetApplicationName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar GetVersionString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar GetVersionNumberString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar GetBuildNumber(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar GetGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar GetCommandLine(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar Shutdown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar CancelShutdown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar IsShuttingDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar GetApplicationPath(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar GetSettingsPath(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar GetWorkingPath(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar SetWorkingPath(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar string_path); + static scriptVar GetMachineGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar GetUserGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar GetSessionGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +}; diff --git a/Src/Wasabi/api/script/objects/sbitlist.cpp b/Src/Wasabi/api/script/objects/sbitlist.cpp new file mode 100644 index 00000000..d41afa47 --- /dev/null +++ b/Src/Wasabi/api/script/objects/sbitlist.cpp @@ -0,0 +1,118 @@ +#include +#include "sbitlist.h" +#include + +#include +#include + +// {87C65778-E743-49fe-85F9-09CC532AFD56} +static const GUID bitlistGuid = +{ 0x87c65778, 0xe743, 0x49fe, { 0x85, 0xf9, 0x9, 0xcc, 0x53, 0x2a, 0xfd, 0x56 } }; + +BitlistScriptController _bitlistController; +BitlistScriptController *bitlistController = &_bitlistController; + +// -- Functions table ------------------------------------- +function_descriptor_struct BitlistScriptController::exportedFunction[] = { + {L"getItem", 1, (void*)SBitlist::script_vcpu_getitem }, + {L"setItem", 2, (void*)SBitlist::script_vcpu_setitem }, + {L"setSize", 1, (void*)SBitlist::script_vcpu_setsize }, + {L"getSize", 0, (void*)SBitlist::script_vcpu_getsize }, +}; +// -------------------------------------------------------- + +const wchar_t *BitlistScriptController::getClassName() { + return L"BitList"; +} + +const wchar_t *BitlistScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObject *BitlistScriptController::instantiate() { + SBitlist *bl = new SBitlist; + ASSERT(bl != NULL); + return bl->getScriptObject(); +} + +void BitlistScriptController::destroy(ScriptObject *o) +{ + // TODO? + SBitlist *bl = static_cast(o->vcpu_getInterface(bitlistGuid)); +} + +void *BitlistScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for bitlist yet +} + +void BitlistScriptController::deencapsulate(void *o) { +} + +int BitlistScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *BitlistScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID BitlistScriptController::getClassGuid() { + return bitlistGuid; +} + +//------------------------------------------------------------------------------------------------------------- + + +SBitlist::SBitlist() { + list = new BitList; + getScriptObject()->vcpu_setInterface(bitlistGuid, (void *)static_cast(this)); + getScriptObject()->vcpu_setClassName(L"BitList"); + getScriptObject()->vcpu_setController(bitlistController); +} + +SBitlist::~SBitlist() { + delete list; +} + +BitList *SBitlist::getBitList() { + return list; +} + +scriptVar SBitlist::script_vcpu_getitem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&n)); // Compiler shouldn't do this + scriptVar r; + r = SOM::makeVar(SCRIPT_INT); + SBitlist *bl = static_cast(o->vcpu_getInterface(bitlistGuid)); + if (bl) SOM::assign(&r, bl->getBitList()->getitem(SOM::makeInt(&n))); + return r; +} + +scriptVar SBitlist::script_vcpu_setitem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n, scriptVar v) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&n)); // Compiler shouldn't do this + ASSERT(SOM::isNumeric(&v)); // Compiler shouldn't do this + SBitlist *bl = static_cast(o->vcpu_getInterface(bitlistGuid)); + if (bl) bl->getBitList()->setitem(SOM::makeInt(&n), SOM::makeBoolean(&v)); + RETURN_SCRIPT_VOID; +} + +scriptVar SBitlist::script_vcpu_setsize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar newsize) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&newsize)); // Compiler shouldn't do this + SBitlist *bl = static_cast(o->vcpu_getInterface(bitlistGuid)); + if (bl) bl->getBitList()->setSize(SOM::makeInt(&newsize)); + RETURN_SCRIPT_VOID; +} + +scriptVar SBitlist::script_vcpu_getsize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + scriptVar r; + r = SOM::makeVar(SCRIPT_INT); + SBitlist *bl = static_cast(o->vcpu_getInterface(bitlistGuid)); + if (bl) SOM::assign(&r, bl->getBitList()->getsize()); + return r; +} + + + diff --git a/Src/Wasabi/api/script/objects/sbitlist.h b/Src/Wasabi/api/script/objects/sbitlist.h new file mode 100644 index 00000000..9c6f023a --- /dev/null +++ b/Src/Wasabi/api/script/objects/sbitlist.h @@ -0,0 +1,56 @@ +#ifndef __SBITLIST_H +#define __SBITLIST_H + +#include + +#include +#include + +class BitList; + +#define SBITLIST_SCRIPTPARENT RootObjectInstance + +class BitlistScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController() { return rootScriptObjectController; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern BitlistScriptController *bitlistController; + + +class SBitlist : public SBITLIST_SCRIPTPARENT { + +public: + SBitlist(); + virtual ~SBitlist(); + + BitList *getBitList(); + +private: + + BitList *list; + +public: + static scriptVar script_vcpu_getitem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n); + static scriptVar script_vcpu_setitem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n, scriptVar v); + static scriptVar script_vcpu_setsize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar newsize); + static scriptVar script_vcpu_getsize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/scolor.cpp b/Src/Wasabi/api/script/objects/scolor.cpp new file mode 100644 index 00000000..cd00642d --- /dev/null +++ b/Src/Wasabi/api/script/objects/scolor.cpp @@ -0,0 +1,236 @@ +#include +#include "SColor.h" +#include +#include +#include +#include +#include + + +// {95DDB221-00E3-4e2b-8EA5-833548C13C10} +static const GUID colorSoGuid = +{ 0x95ddb221, 0xe3, 0x4e2b, { 0x8e, 0xa5, 0x83, 0x35, 0x48, 0xc1, 0x3c, 0x10 } }; + + +colorScriptController _colorController; +colorScriptController *colorController=&_colorController; + +// -- Functions table ------------------------------------- +function_descriptor_struct colorScriptController::exportedFunction[] = { + {L"getID", 0, (void*)SColor::script_vcpu_getColorID }, + {L"getRed", 0, (void*)SColor::script_vcpu_getRed }, + {L"getGreen", 0, (void*)SColor::script_vcpu_getGreen }, + {L"getBlue", 0, (void*)SColor::script_vcpu_getBlue }, + {L"getAlpha", 0, (void*)SColor::script_vcpu_getAlpha }, + {L"getGreenWithGamma", 0, (void*)SColor::script_vcpu_getGreenWithGamma }, + {L"getBlueWithGamma", 0, (void*)SColor::script_vcpu_getBlueWithGamma }, + {L"getRedWithGamma", 0, (void*)SColor::script_vcpu_getRedWithGamma }, + {L"getGammagroup", 0, (void*)SColor::script_vcpu_getGammagroup }, +}; +// -------------------------------------------------------- + +const wchar_t *colorScriptController::getClassName() { + return L"Color"; +} + +const wchar_t *colorScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObjectController *colorScriptController::getAncestorController() { return rootScriptObjectController; } + +ScriptObject *colorScriptController::instantiate() { + SColor *xd = new SColor; + ASSERT(xd != NULL); + return xd->getScriptObject(); +} + +void colorScriptController::destroy(ScriptObject *o) { + SColor *xd = static_cast(o->vcpu_getInterface(colorSoGuid)); + ASSERT(xd != NULL); + delete xd; +} + +void *colorScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for now +} + +void colorScriptController::deencapsulate(void *o) { +} + +int colorScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *colorScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID colorScriptController::getClassGuid() { + return colorSoGuid; +} + +void SColor::__construct() +{ + getScriptObject()->vcpu_setInterface(colorSoGuid, (void *)static_cast(this)); + getScriptObject()->vcpu_setClassName(L"Color"); + getScriptObject()->vcpu_setController(colorController); + gammagroup = NULL; + colorID = NULL; + color = 0; +} + +SColor::SColor() +{ + SColor::__construct(); +} + +SColor::SColor(const wchar_t* colorID) +{ + __construct(); + this->colorID = colorID; + color = WASABI_API_PALETTE->getColorElement(colorID, &gammagroup); +} + +SColor::SColor(int n) +{ + __construct(); + colorID = WASABI_API_PALETTE->enumColorElement(n); + color = WASABI_API_PALETTE->getColorElement(colorID, &gammagroup); +} + +SColor::~SColor() +{ +} + +int SColor::getARGBValue(int whichCol) +{ + + whichCol %= 4; + + /** + whichCol + 0: red + 1: green + 2: blue + 3: alpha + */ + + ARGB32 c = this->color; + + c = c >> (whichCol * 8); + c &= 0x000000FF; + + return (int)c; +} + +int SColor::getARGBValueWithGamma(int whichCol) +{ + ARGB32 c = imageLoader::filterSkinColor(this->color, this->colorID, NULL); + whichCol %= 4; + + /** + whichCol + 0: red + 1: green + 2: blue + 3: alpha + */ + + c = c >> (whichCol * 8); + c &= 0x000000FF; + + return (int)c; +} + +// VCPU + +scriptVar SColor::script_vcpu_getBlue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SColor *m = static_cast(o->vcpu_getInterface(colorSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->getARGBValue(2)); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SColor::script_vcpu_getGreen(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SColor *m = static_cast(o->vcpu_getInterface(colorSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->getARGBValue(1)); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SColor::script_vcpu_getRed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SColor *m = static_cast(o->vcpu_getInterface(colorSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->getARGBValue(0)); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SColor::script_vcpu_getBlueWithGamma(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SColor *m = static_cast(o->vcpu_getInterface(colorSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->getARGBValueWithGamma(2)); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SColor::script_vcpu_getGreenWithGamma(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SColor *m = static_cast(o->vcpu_getInterface(colorSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->getARGBValueWithGamma(1)); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SColor::script_vcpu_getRedWithGamma(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SColor *m = static_cast(o->vcpu_getInterface(colorSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->getARGBValueWithGamma(0)); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SColor::script_vcpu_getAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SColor *m = static_cast(o->vcpu_getInterface(colorSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->getARGBValue(3)); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SColor::script_vcpu_getColorID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SColor *m = static_cast(o->vcpu_getInterface(colorSoGuid)); + if (m) + { + return MAKE_SCRIPT_STRING(m->colorID); + } + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar SColor::script_vcpu_getGammagroup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SColor *m = static_cast(o->vcpu_getInterface(colorSoGuid)); + if (m) + { + return MAKE_SCRIPT_STRING(m->gammagroup?m->gammagroup:L""); + } + return MAKE_SCRIPT_STRING(L""); +} \ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/scolor.h b/Src/Wasabi/api/script/objects/scolor.h new file mode 100644 index 00000000..94f03671 --- /dev/null +++ b/Src/Wasabi/api/script/objects/scolor.h @@ -0,0 +1,66 @@ +#ifndef __SColor_H +#define __SColor_H + +class SColor; + +#include +#include +#include +#include +#include +#include +#define SCOLOR_SCRIPTPARENT RootObjectInstance + +class colorScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern colorScriptController *colorController; + +class SColor : public SCOLOR_SCRIPTPARENT { +public: + SColor(); + SColor(const wchar_t*); + SColor(int i); + virtual ~SColor(); + void enumColor(int n); + int getARGBValue(int whichCol); + int getARGBValueWithGamma(int whichCol); + +protected: + const wchar_t *gammagroup; + const wchar_t *colorID; + ARGB32 color; + +private: + void __construct(); + +public: + static scriptVar script_vcpu_getRed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getGreen(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getBlue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getRedWithGamma(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getGreenWithGamma(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getBlueWithGamma(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getGammagroup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getColorID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/scolormgr.cpp b/Src/Wasabi/api/script/objects/scolormgr.cpp new file mode 100644 index 00000000..fb135bdf --- /dev/null +++ b/Src/Wasabi/api/script/objects/scolormgr.cpp @@ -0,0 +1,235 @@ +#include +#include "SColorMgr.h" +#include +#include +#include +#include + + +// {AEE235FF-EBD1-498f-96AF-D7E0DAD4541A} +static const GUID colorMgrSoGuid = +{ 0xaee235ff, 0xebd1, 0x498f, { 0x96, 0xaf, 0xd7, 0xe0, 0xda, 0xd4, 0x54, 0x1a } }; + +ColorMgrScriptController _colorMgrController; +ColorMgrScriptController *colorMgrController=&_colorMgrController; + +// -- Functions table ------------------------------------- +function_descriptor_struct ColorMgrScriptController::exportedFunction[] = { + {L"getColor", 1, (void*)SColorMgr::script_vcpu_getColor }, + {L"enumColor", 1, (void*)SColorMgr::script_vcpu_enumColor }, + {L"getNumColors", 0, (void*)SColorMgr::script_vcpu_getNumColors }, + {L"getGammaSet", 1, (void*)SColorMgr::script_vcpu_getGammaSet }, + {L"getCurrentGammaSet", 0, (void*)SColorMgr::script_vcpu_getCurrentGammaSet }, + {L"enumGammaSet", 1, (void*)SColorMgr::script_vcpu_enumGammaSet }, + {L"getNumGammaSets", 0, (void*)SColorMgr::script_vcpu_getNumGammaSets }, + {L"onGuiLoaded", 0, (void*)SColorMgr::script_vcpu_onGuiLoaded }, + {L"onLoaded", 0, (void*)SColorMgr::script_vcpu_onLoaded }, + {L"newGammaSet", 1, (void*)SColorMgr::script_vcpu_newGammaSet }, + {L"onBeforeLoadingElements", 0, (void*)SColorMgr::script_vcpu_onBeforeLoadingElements }, + {L"onColorThemeChanged", 1, (void*)SColorMgr::script_vcpu_onColorThemeChanged }, + {L"onColorThemesListChanged", 0, (void*)SColorMgr::script_vcpu_onColorThemesListChanged }, +}; +// -------------------------------------------------------- + +const wchar_t *ColorMgrScriptController::getClassName() { + return L"ColorMgr"; +} + +const wchar_t *ColorMgrScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObjectController *ColorMgrScriptController::getAncestorController() { return rootScriptObjectController; } + +ScriptObject *ColorMgrScriptController::instantiate() { + SColorMgr *xd = new SColorMgr; + ASSERT(xd != NULL); + return xd->getScriptObject(); +} + +void ColorMgrScriptController::destroy(ScriptObject *o) { + SColorMgr *xd = static_cast(o->vcpu_getInterface(colorMgrSoGuid)); + ASSERT(xd != NULL); + delete xd; +} + +void *ColorMgrScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for now +} + +void ColorMgrScriptController::deencapsulate(void *o) { +} + +int ColorMgrScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *ColorMgrScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID ColorMgrScriptController::getClassGuid() { + return colorMgrSoGuid; +} + +SColorMgr::SColorMgr() +{ + getScriptObject()->vcpu_setInterface(colorMgrSoGuid, (void *)static_cast(this)); + getScriptObject()->vcpu_setClassName(L"ColorMgr"); + getScriptObject()->vcpu_setController(colorMgrController); + WASABI_API_SYSCB->syscb_registerCallback(static_cast(this)); +} + +SColorMgr::~SColorMgr() +{ + WASABI_API_SYSCB->syscb_deregisterCallback(static_cast(this)); +} + +int SColorMgr::skincb_onGuiLoaded () +{ + script_vcpu_onGuiLoaded(SCRIPT_CALL, this->getScriptObject()); + return 0; +} + +int SColorMgr::skincb_onLoaded () +{ + script_vcpu_onLoaded(SCRIPT_CALL, this->getScriptObject()); + return 0; +} + +int SColorMgr::skincb_onBeforeLoadingElements () +{ + script_vcpu_onBeforeLoadingElements(SCRIPT_CALL, this->getScriptObject()); + return 0; +} + +int SColorMgr::skincb_onColorThemeChanged (const wchar_t* newcolortheme) +{ + script_vcpu_onColorThemeChanged(SCRIPT_CALL, this->getScriptObject(), MAKE_SCRIPT_STRING(newcolortheme)); + return 0; +} + + +int SColorMgr::skincb_onColorThemesListChanged() +{ + script_vcpu_onColorThemesListChanged(SCRIPT_CALL, this->getScriptObject()); + return 0; +} + + +// VCPU + +scriptVar SColorMgr::script_vcpu_getColor(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar colorID) +{ + SCRIPT_FUNCTION_INIT; + ASSERT(colorID.type == SCRIPT_STRING); + ScriptObject *s = NULL; + SColor *sc = new SColor(colorID.data.sdata); + if (sc != NULL) s = sc->getScriptObject(); + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar SColorMgr::script_vcpu_enumColor(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n) +{ + SCRIPT_FUNCTION_INIT; + ASSERT(n.type == SCRIPT_INT); + ScriptObject *s = NULL; + SColor *sc = new SColor(n.data.idata); + if (sc != NULL) s = sc->getScriptObject(); + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar SColorMgr::script_vcpu_getNumColors(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT(WASABI_API_PALETTE->getNumColorElements()); +} + +scriptVar SColorMgr::script_vcpu_getGammaSet(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar colorID) +{ + SCRIPT_FUNCTION_INIT; + ASSERT(colorID.type == SCRIPT_STRING); + ScriptObject *s = NULL; + SGammaset *gs = new SGammaset(colorID.data.sdata); + if (gs != NULL) s = gs->getScriptObject(); + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar SColorMgr::script_vcpu_newGammaSet(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar colorID) +{ + SCRIPT_FUNCTION_INIT; + ASSERT(colorID.type == SCRIPT_STRING); + WASABI_API_COLORTHEMES->newGammaSet(colorID.data.sdata); + ScriptObject *s = NULL; + SGammaset *gs = new SGammaset(colorID.data.sdata); + if (gs != NULL) s = gs->getScriptObject(); + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar SColorMgr::script_vcpu_enumGammaSet(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n) +{ + SCRIPT_FUNCTION_INIT; + ASSERT(n.type == SCRIPT_INT); + ScriptObject *s = NULL; + SGammaset *gs = new SGammaset(n.data.idata); + if (gs != NULL) s = gs->getScriptObject(); + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar SColorMgr::script_vcpu_getCurrentGammaSet(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + ScriptObject *s = NULL; + const wchar_t * cur = WASABI_API_COLORTHEMES->getGammaSet(); + SGammaset *gs = NULL; + if (cur != NULL) new SGammaset(cur); + if (gs != NULL) s = gs->getScriptObject(); + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar SColorMgr::script_vcpu_getNumGammaSets(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT(WASABI_API_COLORTHEMES->getNumGammaSets()); +} + +scriptVar SColorMgr::script_vcpu_onGuiLoaded(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, colorMgrController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar SColorMgr::script_vcpu_onLoaded(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, colorMgrController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + + +scriptVar SColorMgr::script_vcpu_onBeforeLoadingElements(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, colorMgrController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar SColorMgr::script_vcpu_onColorThemesListChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, colorMgrController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar SColorMgr::script_vcpu_onColorThemeChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar newTheme) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1(o, colorMgrController, newTheme); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, newTheme); +} \ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/scolormgr.h b/Src/Wasabi/api/script/objects/scolormgr.h new file mode 100644 index 00000000..35258e2d --- /dev/null +++ b/Src/Wasabi/api/script/objects/scolormgr.h @@ -0,0 +1,66 @@ +#ifndef __SColorMgr_H +#define __SColorMgr_H + +class SColorMgr; + +#include +#include +#include +#include +#include +#include +#include "scolor.h" +#include "sgammaset.h" +#define SCOLORMGR_SCRIPTPARENT RootObjectInstance + +class ColorMgrScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern ColorMgrScriptController *colorMgrController; + +class SColorMgr : public SCOLORMGR_SCRIPTPARENT, public SkinCallbackI { +public: + SColorMgr(); + virtual ~SColorMgr(); + + virtual int skincb_onBeforeLoadingElements(); + virtual int skincb_onGuiLoaded(); + virtual int skincb_onLoaded(); + virtual int skincb_onColorThemeChanged(const wchar_t *newcolortheme); + virtual int skincb_onColorThemesListChanged(); + +public: + static scriptVar script_vcpu_getColor(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar colorID); + static scriptVar script_vcpu_enumColor(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n); + static scriptVar script_vcpu_getNumColors(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getCurrentGammaSet(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getGammaSet(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar colorID); + static scriptVar script_vcpu_enumGammaSet(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n); + static scriptVar script_vcpu_getNumGammaSets(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_newGammaSet(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar colorID); + + static scriptVar script_vcpu_onBeforeLoadingElements(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_onGuiLoaded(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_onColorThemeChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar newcolortheme); + static scriptVar script_vcpu_onColorThemesListChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_onLoaded(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/sfile.cpp b/Src/Wasabi/api/script/objects/sfile.cpp new file mode 100644 index 00000000..e7feaaac --- /dev/null +++ b/Src/Wasabi/api/script/objects/sfile.cpp @@ -0,0 +1,119 @@ +#include +#include "SFile.h" + +#include +#include +#include + + +// {836F8B2E-E0D1-4db4-937F-0D0A04C8DCD1} +static const GUID fileGuid = +{ 0x836f8b2e, 0xe0d1, 0x4db4, { 0x93, 0x7f, 0xd, 0xa, 0x4, 0xc8, 0xdc, 0xd1 } }; + + +fileScriptController _fileController; +fileScriptController *fileController=&_fileController; + +// -- Functions table ------------------------------------- +function_descriptor_struct fileScriptController::exportedFunction[] = { + {L"load", 1, (void*)SFile::script_vcpu_load }, + {L"getSize", 0, (void*)SFile::script_vcpu_getSize }, + {L"exists", 0, (void*)SFile::script_vcpu_exists }, +}; +// -------------------------------------------------------- + +const wchar_t *fileScriptController::getClassName() { + return L"File"; +} + +const wchar_t *fileScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObjectController *fileScriptController::getAncestorController() { return rootScriptObjectController; } + +ScriptObject *fileScriptController::instantiate() { + SFile *xd = new SFile; + ASSERT(xd != NULL); + return xd->getScriptObject(); +} + +void fileScriptController::destroy(ScriptObject *o) { + SFile *xd = static_cast(o->vcpu_getInterface(fileGuid)); + ASSERT(xd != NULL); + delete xd; +} + +void *fileScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for files for now +} + +void fileScriptController::deencapsulate(void *o) { +} + +int fileScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *fileScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID fileScriptController::getClassGuid() { + return fileGuid; +} + + + +SFile::SFile() { + getScriptObject()->vcpu_setInterface(fileGuid, (void *)static_cast(this)); + getScriptObject()->vcpu_setClassName(L"File"); + getScriptObject()->vcpu_setController(fileController); + filename = NULL; +} + +SFile::~SFile() { + //if (bmp) delete bmp; +} + +void SFile::loadfile(const wchar_t *b) +{ + filename = b; +} + +// VCPU + +scriptVar SFile::script_vcpu_load(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar fn) { + SCRIPT_FUNCTION_INIT; + ASSERT(fn.type == SCRIPT_STRING); + SFile *m = static_cast(o->vcpu_getInterface(fileGuid)); + if (m) m->loadfile(fn.data.sdata); + RETURN_SCRIPT_VOID; +} + +scriptVar SFile::script_vcpu_getSize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SFile *m = static_cast(o->vcpu_getInterface(fileGuid)); + if (m) + { + OSFILETYPE in = WFOPEN(m->filename, WF_READONLY_BINARY); + if (in == OPEN_FAILED) RETURN_SCRIPT_ZERO; + int size = (int)FGETSIZE(in); + FCLOSE(in); + return MAKE_SCRIPT_INT(size); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SFile::script_vcpu_exists(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SFile *m = static_cast(o->vcpu_getInterface(fileGuid)); + if (m) + { + OSFILETYPE in = WFOPEN(m->filename, WF_READONLY_BINARY); + if (in == OPEN_FAILED) return MAKE_SCRIPT_BOOLEAN(0); + FCLOSE(in); + return MAKE_SCRIPT_BOOLEAN(1); + } + return MAKE_SCRIPT_BOOLEAN(0); +} \ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/sfile.h b/Src/Wasabi/api/script/objects/sfile.h new file mode 100644 index 00000000..91a0ee9c --- /dev/null +++ b/Src/Wasabi/api/script/objects/sfile.h @@ -0,0 +1,53 @@ +#ifndef __SFile_H +#define __SFile_H + +class SFile; + +#include +#include +#include +#include + +#define SFile_SCRIPTPARENT RootObjectInstance + +class fileScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern fileScriptController *fileController; + +class SFile : public SFile_SCRIPTPARENT { +public: + SFile(); + virtual ~SFile(); + + + void loadfile(const wchar_t *b); + + +protected: + const wchar_t *filename; + +public: + static scriptVar script_vcpu_load(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar fn); + static scriptVar script_vcpu_getSize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_exists(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/sgammagroup.cpp b/Src/Wasabi/api/script/objects/sgammagroup.cpp new file mode 100644 index 00000000..55c1b872 --- /dev/null +++ b/Src/Wasabi/api/script/objects/sgammagroup.cpp @@ -0,0 +1,235 @@ +#include +#include "SGammagroup.h" + +#include +#include +#include + +// {B81F004D-ACBA-453d-A06B-30192A1DA17D} +static const GUID gammagroupSoGuid = +{ 0xb81f004d, 0xacba, 0x453d, { 0xa0, 0x6b, 0x30, 0x19, 0x2a, 0x1d, 0xa1, 0x7d } }; + + +GammagroupScriptController _gammagroupController; +GammagroupScriptController *gammagroupController=&_gammagroupController; + +// -- Functions table ------------------------------------- +function_descriptor_struct GammagroupScriptController::exportedFunction[] = { + {L"getRed", 0, (void*)SGammagroup::script_vcpu_getRed }, + {L"getGreen", 0, (void*)SGammagroup::script_vcpu_getGreen }, + {L"getBlue", 0, (void*)SGammagroup::script_vcpu_getBlue }, + {L"getBoost", 0, (void*)SGammagroup::script_vcpu_getBoost }, + {L"getGray", 0, (void*)SGammagroup::script_vcpu_getGray }, + {L"setRed", 1, (void*)SGammagroup::script_vcpu_setRed }, + {L"setGreen", 1, (void*)SGammagroup::script_vcpu_setGreen }, + {L"setBlue", 1, (void*)SGammagroup::script_vcpu_setBlue }, + {L"setBoost", 1, (void*)SGammagroup::script_vcpu_setBoost }, + {L"setGray", 1, (void*)SGammagroup::script_vcpu_setGray }, + {L"getID", 0, (void*)SGammagroup::script_vcpu_getID }, + {L"setID", 1, (void*)SGammagroup::script_vcpu_setID }, +}; +// -------------------------------------------------------- + +const wchar_t *GammagroupScriptController::getClassName() { + return L"Gammagroup"; +} + +const wchar_t *GammagroupScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObjectController *GammagroupScriptController::getAncestorController() { return rootScriptObjectController; } + +ScriptObject *GammagroupScriptController::instantiate() { + SGammagroup *xd = new SGammagroup; + ASSERT(xd != NULL); + return xd->getScriptObject(); +} + +void GammagroupScriptController::destroy(ScriptObject *o) { + SGammagroup *xd = static_cast(o->vcpu_getInterface(gammagroupSoGuid)); + ASSERT(xd != NULL); + delete xd; +} + +void *GammagroupScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for now +} + +void GammagroupScriptController::deencapsulate(void *o) { +} + +int GammagroupScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *GammagroupScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID GammagroupScriptController::getClassGuid() { + return gammagroupSoGuid; +} + +void SGammagroup::__construct() +{ + getScriptObject()->vcpu_setInterface(gammagroupSoGuid, (void *)static_cast(this)); + getScriptObject()->vcpu_setClassName(L"Gammagroup"); + getScriptObject()->vcpu_setController(gammagroupController); + this->grp = NULL; +} + +SGammagroup::SGammagroup() +{ + this->__construct(); +} + +SGammagroup::SGammagroup(const wchar_t * parentSet, const wchar_t * grp) +{ + this->__construct(); + this->parentSet = parentSet; + this->grp = WASABI_API_COLORTHEMES->getColorThemeGroup(parentSet, grp); +} + +SGammagroup::SGammagroup(const wchar_t * parentSet, int n) +{ + this->__construct(); + this->parentSet = parentSet; + for (int i = 0; i < (int)WASABI_API_COLORTHEMES->getNumGammaSets(); i++) + { + if(WCSICMPSAFE(parentSet, WASABI_API_COLORTHEMES->enumGammaSet(i))) + { + continue; + } + + this->grp = WASABI_API_COLORTHEMES->enumColorThemeGroup(i, n); + break; + } +} + +SGammagroup::~SGammagroup() +{ +} + +// VCPU + + +scriptVar SGammagroup::script_vcpu_getID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + return MAKE_SCRIPT_STRING(m->grp->getName()); + } + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar SGammagroup::script_vcpu_getBlue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->grp->getBlue()); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SGammagroup::script_vcpu_getGreen(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->grp->getGreen()); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SGammagroup::script_vcpu_getRed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->grp->getRed()); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SGammagroup::script_vcpu_getBoost(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->grp->getBoost()); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SGammagroup::script_vcpu_getGray(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->grp->getGray()); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SGammagroup::script_vcpu_setID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + (m->grp->setName(color.data.sdata)); + } + RETURN_SCRIPT_VOID; +} + +scriptVar SGammagroup::script_vcpu_setBlue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + (m->grp->setBlue(color.data.idata)); + } + RETURN_SCRIPT_VOID; +} + +scriptVar SGammagroup::script_vcpu_setGreen(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + (m->grp->setGreen(color.data.idata)); + } + RETURN_SCRIPT_VOID; +} + +scriptVar SGammagroup::script_vcpu_setRed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + (m->grp->setRed(color.data.idata)); + } + RETURN_SCRIPT_VOID; +} + +scriptVar SGammagroup::script_vcpu_setBoost(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + (m->grp->setBoost(color.data.idata)); + } + RETURN_SCRIPT_VOID; +} + +scriptVar SGammagroup::script_vcpu_setGray(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + (m->grp->setGray(color.data.idata)); + } + RETURN_SCRIPT_VOID; +} \ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/sgammagroup.h b/Src/Wasabi/api/script/objects/sgammagroup.h new file mode 100644 index 00000000..01113039 --- /dev/null +++ b/Src/Wasabi/api/script/objects/sgammagroup.h @@ -0,0 +1,66 @@ +#ifndef __SGammagroup_H +#define __SGammagroup_H + +class SGamma; + +#include +#include +#include +#include +#include +#include +#define SGAMMAGROUP_SCRIPTPARENT RootObjectInstance + +class GammagroupScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern GammagroupScriptController *gammagroupController; + +class SGammagroup : public SGAMMAGROUP_SCRIPTPARENT { +public: + SGammagroup(); + SGammagroup(const wchar_t * parentSet, const wchar_t * grpName); + SGammagroup(const wchar_t * parentSet, int i); + virtual ~SGammagroup(); + +//protected: + ColorThemeGroup * grp; + const wchar_t * parentSet; + +private: + void __construct(); + +public: + static scriptVar script_vcpu_setRed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color); + static scriptVar script_vcpu_setGreen(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color); + static scriptVar script_vcpu_setBlue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color); + static scriptVar script_vcpu_setBoost(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color); + static scriptVar script_vcpu_setGray(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color); + static scriptVar script_vcpu_setID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color); + + static scriptVar script_vcpu_getRed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getGreen(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getBlue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getBoost(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getGray(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/sgammaset.cpp b/Src/Wasabi/api/script/objects/sgammaset.cpp new file mode 100644 index 00000000..e1913e43 --- /dev/null +++ b/Src/Wasabi/api/script/objects/sgammaset.cpp @@ -0,0 +1,201 @@ +#include +#include "SGammaset.h" + +#include +#include +#include +#include + +// {0D024DB9-9574-42d0-B8C7-26B553F1F987} +static const GUID gammasetSoGuid = +{ 0xd024db9, 0x9574, 0x42d0, { 0xb8, 0xc7, 0x26, 0xb5, 0x53, 0xf1, 0xf9, 0x87 } }; + +GammasetScriptController _gammasetController; +GammasetScriptController *gammasetController=&_gammasetController; + +// -- Functions table ------------------------------------- +function_descriptor_struct GammasetScriptController::exportedFunction[] = { + {L"apply", 0, (void*)SGammaset::script_vcpu_apply }, + {L"getID", 0, (void*)SGammaset::script_vcpu_getID }, + {L"rename", 1, (void*)SGammaset::script_vcpu_rename }, + {L"remove", 0, (void*)SGammaset::script_vcpu_update }, + {L"delete", 0, (void*)SGammaset::script_vcpu_delete }, + {L"getGeneralGroup", 0, (void*)SGammaset::script_vcpu_getDefaultGammaGroup }, + {L"getGammaGroup", 1, (void*)SGammaset::script_vcpu_getGammaGroup }, + {L"getNumGammaGroups", 0, (void*)SGammaset::script_vcpu_getNumGammaGroups }, + {L"enumGammaGroup", 0, (void*)SGammaset::script_vcpu_enumGammaGroup }, +}; +// -------------------------------------------------------- + +const wchar_t *GammasetScriptController::getClassName() { + return L"Gammaset"; +} + +const wchar_t *GammasetScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObjectController *GammasetScriptController::getAncestorController() { return rootScriptObjectController; } + +ScriptObject *GammasetScriptController::instantiate() { + SGammaset *xd = new SGammaset; + ASSERT(xd != NULL); + return xd->getScriptObject(); +} + +void GammasetScriptController::destroy(ScriptObject *o) { + SGammaset *xd = static_cast(o->vcpu_getInterface(gammasetSoGuid)); + ASSERT(xd != NULL); + delete xd; +} + +void *GammasetScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for now +} + +void GammasetScriptController::deencapsulate(void *o) { +} + +int GammasetScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *GammasetScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID GammasetScriptController::getClassGuid() { + return gammasetSoGuid; +} + +void SGammaset::__construct() +{ + getScriptObject()->vcpu_setInterface(gammasetSoGuid, (void *)static_cast(this)); + getScriptObject()->vcpu_setClassName(L"Gammaset"); + getScriptObject()->vcpu_setController(gammasetController); + this->gammasetID = NULL; +} + +SGammaset::SGammaset() +{ + this->__construct(); +} + +SGammaset::SGammaset(const wchar_t * gammaSetID) +{ + this->__construct(); + this->gammasetID = gammaSetID; +} + +SGammaset::SGammaset(int n) +{ + this->__construct(); + this->gammasetID = WASABI_API_COLORTHEMES->enumGammaSet(n); +} + +SGammaset::~SGammaset() +{ +} + +// VCPU + +scriptVar SGammaset::script_vcpu_apply(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SGammaset *m = static_cast(o->vcpu_getInterface(gammasetSoGuid)); + if (m) + { + WASABI_API_SKIN->colortheme_setColorSet(m->gammasetID); + //WASABI_API_COLORTHEMES->setGammaSet(m->gammasetID); + } + RETURN_SCRIPT_VOID; +} + +scriptVar SGammaset::script_vcpu_update(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SGammaset *m = static_cast(o->vcpu_getInterface(gammasetSoGuid)); + if (m) + { + WASABI_API_COLORTHEMES->updateGammaSet(m->gammasetID); + } + RETURN_SCRIPT_VOID; +} + +scriptVar SGammaset::script_vcpu_delete(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SGammaset *m = static_cast(o->vcpu_getInterface(gammasetSoGuid)); + if (m) + { + WASABI_API_COLORTHEMES->deleteGammaSet(m->gammasetID); + } + RETURN_SCRIPT_VOID; +} + +scriptVar SGammaset::script_vcpu_rename(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name) { + SCRIPT_FUNCTION_INIT; + ASSERT(name.type == SCRIPT_STRING); + SGammaset *m = static_cast(o->vcpu_getInterface(gammasetSoGuid)); + if (m) + { + WASABI_API_COLORTHEMES->renameGammaSet(m->gammasetID, name.data.sdata); + } + RETURN_SCRIPT_VOID; +} + +scriptVar SGammaset::script_vcpu_getID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SGammaset *m = static_cast(o->vcpu_getInterface(gammasetSoGuid)); + if (m) + { + return MAKE_SCRIPT_STRING(m->gammasetID); + } + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar SGammaset::script_vcpu_getDefaultGammaGroup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + ScriptObject *s = NULL; + SGammaset *m = static_cast(o->vcpu_getInterface(gammasetSoGuid)); + if (m) + { + SGammagroup *gg = new SGammagroup(m->gammasetID, -1); + if (gg != NULL && gg->grp != NULL) s = gg->getScriptObject(); + } + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar SGammaset::script_vcpu_getGammaGroup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name) { + SCRIPT_FUNCTION_INIT; + ASSERT(name.type == SCRIPT_STRING); + ScriptObject *s = NULL; + SGammaset *m = static_cast(o->vcpu_getInterface(gammasetSoGuid)); + if (m) + { + SGammagroup *gg = new SGammagroup(m->gammasetID, GET_SCRIPT_STRING(name)); + if (gg != NULL) s = gg->getScriptObject(); + } + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar SGammaset::script_vcpu_enumGammaGroup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n) { + SCRIPT_FUNCTION_INIT; + ASSERT(n.type == SCRIPT_INT); + ScriptObject *s = NULL; + SGammaset *m = static_cast(o->vcpu_getInterface(gammasetSoGuid)); + if (m) + { + SGammagroup *gg = new SGammagroup(m->gammasetID, GET_SCRIPT_INT(n)); + if (gg != NULL) s = gg->getScriptObject(); + } + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar SGammaset::script_vcpu_getNumGammaGroups(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int n = 0; + SGammaset *m = static_cast(o->vcpu_getInterface(gammasetSoGuid)); + if (m) + { + n = WASABI_API_COLORTHEMES->getNumGammaGroups(m->gammasetID); + } + return MAKE_SCRIPT_INT(n); +} \ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/sgammaset.h b/Src/Wasabi/api/script/objects/sgammaset.h new file mode 100644 index 00000000..ea4343d4 --- /dev/null +++ b/Src/Wasabi/api/script/objects/sgammaset.h @@ -0,0 +1,62 @@ +#ifndef __SGammaset_H +#define __SGammaset_H + +class SGamma; + +#include +#include +#include +#include +#include +#include +#include "sgammagroup.h" +#define SGAMMASET_SCRIPTPARENT RootObjectInstance + +class GammasetScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern GammasetScriptController *gammasetController; + +class SGammaset : public SGAMMASET_SCRIPTPARENT { +public: + SGammaset(); + SGammaset(const wchar_t *); + SGammaset(int i); + virtual ~SGammaset(); + +protected: + const wchar_t *gammasetID; + +private: + void __construct(); + +public: + static scriptVar script_vcpu_apply(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_rename(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name); + static scriptVar script_vcpu_update(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_delete(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getDefaultGammaGroup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getGammaGroup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name); + static scriptVar script_vcpu_getNumGammaGroups(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_enumGammaGroup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n); +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/slist.cpp b/Src/Wasabi/api/script/objects/slist.cpp new file mode 100644 index 00000000..1bfe53bf --- /dev/null +++ b/Src/Wasabi/api/script/objects/slist.cpp @@ -0,0 +1,172 @@ +#include +#include "slist.h" + +#include +#include + +ListScriptController _listController; +ListScriptController *listController=&_listController; + +// -- Functions table ------------------------------------- +function_descriptor_struct ListScriptController::exportedFunction[] = { + {L"addItem", 1, (void*)SList::script_vcpu_addItem }, + {L"removeItem", 1, (void*)SList::script_vcpu_removeItem }, + {L"enumItem", 1, (void*)SList::script_vcpu_enumItem }, + {L"findItem2", 2, (void*)SList::script_vcpu_findItem2 }, + {L"findItem", 1, (void*)SList::script_vcpu_findItem }, + {L"getNumItems", 0, (void*)SList::script_vcpu_getNumItems }, + {L"removeAll", 0, (void*)SList::script_vcpu_removeAll }, +}; +// -------------------------------------------------------- + +const wchar_t *ListScriptController::getClassName() { + return L"List"; +} + +const wchar_t *ListScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObject *ListScriptController::instantiate() { + SList *l = new SList; + ASSERT(l != NULL); + return l->getScriptObject(); +} + +void ListScriptController::destroy(ScriptObject *o) { + SList *obj = static_cast(o->vcpu_getInterface(slistGuid)); + ASSERT(obj != NULL); + delete obj; +} + +void *ListScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for list yet +} + +void ListScriptController::deencapsulate(void *o) { +} + +int ListScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *ListScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID ListScriptController::getClassGuid() { + return slistGuid; +} + +//------------------------------------------------------------------------ + +SList::SList() { + getScriptObject()->vcpu_setInterface(slistGuid, (void *)static_cast(this)); + getScriptObject()->vcpu_setClassName(L"List"); + getScriptObject()->vcpu_setController(listController); +} + +SList::~SList() { +} + +TList *SList::getTList() { + return &list; +} + +scriptVar SList::script_vcpu_enumItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&i)); + SList *l = static_cast(o->vcpu_getInterface(slistGuid)); + if (l) return l->getTList()->enumItem(SOM::makeInt(&i)); + RETURN_SCRIPT_ZERO; +} + +scriptVar SList::script_vcpu_addItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj) { + SCRIPT_FUNCTION_INIT; + scriptVar dup; + dup = SOM::makeVar(obj.type); + SOM::assignPersistent(&dup, &obj); + SList *l = static_cast(o->vcpu_getInterface(slistGuid)); + if (l) l->getTList()->addItem(dup); + RETURN_SCRIPT_VOID; +} + +scriptVar SList::script_vcpu_removeItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&i)); + SList *l = static_cast(o->vcpu_getInterface(slistGuid)); + if (l) { + scriptVar dup = l->getTList()->enumItem(SOM::makeInt(&i)); + if (dup.type == SCRIPT_STRING) { + if (dup.data.odata) FREE(dup.data.odata); + } + l->getTList()->delByPos(SOM::makeInt(&i)); + } + RETURN_SCRIPT_VOID; +} + +scriptVar SList::script_vcpu_getNumItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SList *l = static_cast(o->vcpu_getInterface(slistGuid)); + if (l) return MAKE_SCRIPT_INT(l->getTList()->getNumItems()); + return MAKE_SCRIPT_INT(0); +} + +scriptVar SList::script_vcpu_findItem2(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj, scriptVar start) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&start)); + SList *l = static_cast(o->vcpu_getInterface(slistGuid)); + if (l) { + if (obj.type != SCRIPT_STRING) { + for (int i=SOM::makeInt(&start);igetTList()->getNumItems();i++) { + if (!MEMCMP(&l->getTList()->enumItem(i), &obj, sizeof(scriptVar))) { + return MAKE_SCRIPT_INT(i); + } + } + } else { + for (int i=SOM::makeInt(&start);igetTList()->getNumItems();i++) { + if (!wcscmp(l->getTList()->enumItem(i).data.sdata, obj.data.sdata)) { + return MAKE_SCRIPT_INT(i); + } + } + } + } + return MAKE_SCRIPT_INT(-1); +} + +scriptVar SList::script_vcpu_findItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj) { + SCRIPT_FUNCTION_INIT; + SList *l = static_cast(o->vcpu_getInterface(slistGuid)); + if (l) { + if (obj.type != SCRIPT_STRING) { + for (int i=0;igetTList()->getNumItems();i++) { + if (!MEMCMP(&l->getTList()->enumItem(i), &obj, sizeof(scriptVar))) { + return MAKE_SCRIPT_INT(i); + } + } + } else { + for (int i=0;igetTList()->getNumItems();i++) { + if (!wcscmp(l->getTList()->enumItem(i).data.sdata, obj.data.sdata)) { + return MAKE_SCRIPT_INT(i); + } + } + } + } + return MAKE_SCRIPT_INT(-1); +} + +scriptVar SList::script_vcpu_removeAll(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SList *l = static_cast(o->vcpu_getInterface(slistGuid)); + if (l) { + for (int i=0;igetTList()->getNumItems();i++) { + scriptVar v = l->getTList()->enumItem(i); + if (v.type == SCRIPT_STRING) + FREE((wchar_t *)v.data.sdata); + } + l->getTList()->removeAll(); + } + RETURN_SCRIPT_VOID; +} + + diff --git a/Src/Wasabi/api/script/objects/slist.h b/Src/Wasabi/api/script/objects/slist.h new file mode 100644 index 00000000..c81c2dd6 --- /dev/null +++ b/Src/Wasabi/api/script/objects/slist.h @@ -0,0 +1,62 @@ +#ifndef __SLIST_H +#define __SLIST_H + +#include +#include +#include +#include +class ScriptObject; + +// {B2023AB5-434D-4ba1-BEAE-59637503F3C6} +static const GUID slistGuid = +{ 0xb2023ab5, 0x434d, 0x4ba1, { 0xbe, 0xae, 0x59, 0x63, 0x75, 0x3, 0xf3, 0xc6 } }; + +#define SLIST_SCRIPTPARENT RootObjectInstance + +class ListScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController() { return rootScriptObjectController; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern ListScriptController *listController; + + +class SList : public SLIST_SCRIPTPARENT { + +public: + SList(); + virtual ~SList(); + + TList *getTList(); + +private: + TList list; + +// -- SCRIPT ----------------------------------------------------- +public: +// INSERT_SCRIPT_OBJECT_CONTROL + static scriptVar script_vcpu_enumItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i); + static scriptVar script_vcpu_addItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj); + static scriptVar script_vcpu_removeItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj); + static scriptVar script_vcpu_getNumItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_findItem2(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj, scriptVar start); + static scriptVar script_vcpu_findItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj); + static scriptVar script_vcpu_removeAll(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/smap.cpp b/Src/Wasabi/api/script/objects/smap.cpp new file mode 100644 index 00000000..6c829628 --- /dev/null +++ b/Src/Wasabi/api/script/objects/smap.cpp @@ -0,0 +1,205 @@ +#include +#include "smap.h" + +#include +#include +#include +#include + +MapScriptController _mapController; +MapScriptController *mapController=&_mapController; + +// -- Functions table ------------------------------------- +function_descriptor_struct MapScriptController::exportedFunction[] = { + {L"getValue", 2, (void*)SMap::script_vcpu_getValue }, + {L"getARGBValue", 3, (void*)SMap::script_vcpu_getARGBValue }, + {L"inRegion", 2, (void*)SMap::script_vcpu_inRegion }, + {L"loadMap", 1, (void*)SMap::script_vcpu_loadMap }, + {L"getWidth", 0, (void*)SMap::script_vcpu_getWidth }, + {L"getHeight", 0, (void*)SMap::script_vcpu_getHeight }, + {L"getRegion", 0, (void*)SMap::script_vcpu_getRegion }, + // todo: stretch +}; +// -------------------------------------------------------- + +const wchar_t *MapScriptController::getClassName() { + return L"Map"; +} + +const wchar_t *MapScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObjectController *MapScriptController::getAncestorController() { return rootScriptObjectController; } + +ScriptObject *MapScriptController::instantiate() { + SMap *m = new SMap; + ASSERT(m != NULL); + return m->getScriptObject(); +} + +void MapScriptController::destroy(ScriptObject *o) { + SMap *m = static_cast(o->vcpu_getInterface(mapGuid)); + ASSERT(m != NULL); + delete m; +} + +void *MapScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for maps for now +} + +void MapScriptController::deencapsulate(void *o) { +} + +int MapScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *MapScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID MapScriptController::getClassGuid() { + return mapGuid; +} + + + +SMap::SMap() { + getScriptObject()->vcpu_setInterface(mapGuid, (void *)static_cast(this)); + getScriptObject()->vcpu_setClassName(L"Map"); + getScriptObject()->vcpu_setController(mapController); + bmp = NULL; + region_so = ObjectTable::instantiate(ObjectTable::getClassFromName(L"Region")); + reg = static_cast(region_so->vcpu_getInterface(regionGuid)); +} + +SMap::~SMap() { + if (bmp) delete bmp; + ObjectTable::destroy(region_so); +} + +int SMap::getValue(int x, int y) { + if (!bmp) return 0; + ARGB32 c = bmp->getPixel(x, y); +// if ((c & 0xFF000000) >> 24 != 0xFF) return -1; + int v = MAX(MAX((c & 0xFF0000) >> 16, (c & 0xFF00) >> 8), c & 0xFF); + return v; +} + +int SMap::getARGBValue(int x, int y, int whichCol) { + if (!bmp) return 0; + ARGB32 c = bmp->getPixel(x, y); + + whichCol %= 4; + + /** + whichCol + 0: blue + 1: green + 2: red + 3: alpha + */ + + ARGB32 a = c >> 24; + a &= 0x000000FF; //just to be sure + + if (whichCol == 3) return a; + + c = c >> (whichCol * 8); + c &= 0x000000FF; + + if (0 == a || 255 == a) return c; + + double d = c*255/a; // Correction for bitmaps w/ alpha channel, otherwise a lesser rgb value is returned + d = ceil(d); + + return (int)d; +} + +void SMap::loadMap(const wchar_t *b) +{ + bmp = new SkinBitmap(b, 0); + reg->loadFromBitmap(b); +} + +int SMap::getWidth() { + if (!bmp) return 0; + return bmp->getWidth(); +} + +int SMap::getHeight() { + if (!bmp) return 0; + return bmp->getHeight(); +} + +int SMap::inRegion(int x, int y) { + POINT pt={x,y}; + return reg->getRegion()->ptInRegion(&pt); +} + +SRegion *SMap::getSRegion() { + return reg; +} + +// VCPU + +scriptVar SMap::script_vcpu_loadMap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar bmp) { + SCRIPT_FUNCTION_INIT; + ASSERT(bmp.type == SCRIPT_STRING); + SMap *m = static_cast(o->vcpu_getInterface(mapGuid)); + if (m) m->loadMap(bmp.data.sdata); + RETURN_SCRIPT_VOID; +} + +scriptVar SMap::script_vcpu_getValue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&x)); + ASSERT(SOM::isNumeric(&y)); + SMap *m = static_cast(o->vcpu_getInterface(mapGuid)); + if (m) return MAKE_SCRIPT_INT(m->getValue(SOM::makeInt(&x), SOM::makeInt(&y))); + RETURN_SCRIPT_ZERO; +} + +scriptVar SMap::script_vcpu_getARGBValue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y, scriptVar wichCol) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&x)); + ASSERT(SOM::isNumeric(&y)); + ASSERT(SOM::isNumeric(&wichCol)); + SMap *m = static_cast(o->vcpu_getInterface(mapGuid)); + if (m) return MAKE_SCRIPT_INT(m->getARGBValue(SOM::makeInt(&x), SOM::makeInt(&y), SOM::makeInt(&wichCol))); + RETURN_SCRIPT_ZERO; +} + +scriptVar SMap::script_vcpu_getWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SMap *m = static_cast(o->vcpu_getInterface(mapGuid)); + if (m) return MAKE_SCRIPT_INT(m->getWidth()); + RETURN_SCRIPT_ZERO; +} + +scriptVar SMap::script_vcpu_getHeight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SMap *m = static_cast(o->vcpu_getInterface(mapGuid)); + if (m) return MAKE_SCRIPT_INT(m->getHeight()); + RETURN_SCRIPT_ZERO; +} + +scriptVar SMap::script_vcpu_inRegion(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&x)); + ASSERT(SOM::isNumeric(&y)); + SMap *m = static_cast(o->vcpu_getInterface(mapGuid)); + if (m) return MAKE_SCRIPT_BOOLEAN(m->inRegion(SOM::makeInt(&x), SOM::makeInt(&y))); + RETURN_SCRIPT_ZERO; +} + +scriptVar SMap::script_vcpu_getRegion(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SMap *m = static_cast(o->vcpu_getInterface(mapGuid)); + if (m) { + SRegion *s = m->getSRegion(); + if (s) return MAKE_SCRIPT_OBJECT(s->getScriptObject()); + } + RETURN_SCRIPT_ZERO; +} \ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/smap.h b/Src/Wasabi/api/script/objects/smap.h new file mode 100644 index 00000000..7cd04b41 --- /dev/null +++ b/Src/Wasabi/api/script/objects/smap.h @@ -0,0 +1,74 @@ +#ifndef __SMAP_H +#define __SMAP_H + +class SMap; +class SRegion; + +#include +#include +#ifdef WASABI_WIDGETS_GUIOBJECT +#include +#endif +#include +#include + +// {38603665-461B-42a7-AA75-D83F6667BF73} +static const GUID mapGuid = +{ 0x38603665, 0x461b, 0x42a7, { 0xaa, 0x75, 0xd8, 0x3f, 0x66, 0x67, 0xbf, 0x73 } }; + +#define SMAP_SCRIPTPARENT RootObjectInstance + +class MapScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern MapScriptController *mapController; + +class SMap : public SMAP_SCRIPTPARENT { +public: + SMap(); + virtual ~SMap(); + + int getValue(int x, int y); + int getARGBValue(int x, int y, int whichCol); + int inRegion(int x, int y); + int getWidth(); + int getHeight(); + void loadMap(const wchar_t *b); + static void instantiate(SMap *s); + virtual SkinBitmap *getBitmap() { return bmp; }; + SRegion *getSRegion(); + +private: + SkinBitmap *bmp; + SRegion *reg; + ScriptObject *region_so; + +public: + static scriptVar script_vcpu_loadMap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar bitmap); + static scriptVar script_vcpu_getValue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar script_vcpu_getARGBValue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y, scriptVar whichCol); + static scriptVar script_vcpu_getWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getHeight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_inRegion(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar script_vcpu_getRegion(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/spopup.cpp b/Src/Wasabi/api/script/objects/spopup.cpp new file mode 100644 index 00000000..84cc6254 --- /dev/null +++ b/Src/Wasabi/api/script/objects/spopup.cpp @@ -0,0 +1,140 @@ +#include +#include +#include + +SPopup::SPopup() { + getScriptObject()->vcpu_setInterface(popupGuid, (void *)static_cast(this)); + getScriptObject()->vcpu_setClassName(L"Popup"); + getScriptObject()->vcpu_setController(popupController); +} + +SPopup::~SPopup() { +} + +PopupScriptController _popupController; +PopupScriptController *popupController = &_popupController; + +// -- Functions table ------------------------------------- +function_descriptor_struct PopupScriptController::exportedFunction[] = { + {L"addSubMenu", 2, (void*)SPopup::script_vcpu_addSubMenu }, + {L"addCommand", 4, (void*)SPopup::script_vcpu_addCommand }, + {L"addSeparator", 0, (void*)SPopup::script_vcpu_addSeparator }, + {L"popAtXY", 2, (void*)SPopup::script_vcpu_popAtXY }, + {L"popAtMouse", 0, (void*)SPopup::script_vcpu_popAtMouse }, + {L"getNumCommands", 0, (void*)SPopup::script_vcpu_getNumCommands }, + {L"checkCommand", 2, (void*)SPopup::script_vcpu_checkCommand }, + {L"disableCommand", 2, (void*)SPopup::script_vcpu_disableCommand }, + +//todo: events +}; + +// -------------------------------------------------------- +const wchar_t *PopupScriptController::getClassName() { + return L"Popup"; +} + +const wchar_t *PopupScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObject *PopupScriptController::instantiate() { + SPopup *p = new SPopup; + ASSERT(p != NULL); + return p->getScriptObject(); +} + +void PopupScriptController::destroy(ScriptObject *o) { + SPopup *p = static_cast(o->vcpu_getInterface(popupGuid)); + ASSERT(p != NULL); + delete p; +} + +void *PopupScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for popups yet +} + +void PopupScriptController::deencapsulate(void *o) { +} + +int PopupScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *PopupScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID PopupScriptController::getClassGuid() { + return popupGuid; +} + +// ----------------------------------------------------------------------- +scriptVar SPopup::script_vcpu_addSubMenu(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar popup, scriptVar str) +{ + SCRIPT_FUNCTION_INIT; + ASSERT(str.type == SCRIPT_STRING); // compiler discarded + SPopup *p = static_cast(o->vcpu_getInterface(popupGuid)); + SPopup *p2 = static_cast(GET_SCRIPT_OBJECT_AS(popup, popupGuid)); + if (p) p->addSubMenu(p2, GET_SCRIPT_STRING(str)); + RETURN_SCRIPT_VOID; +} + +scriptVar SPopup::script_vcpu_addCommand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar str, scriptVar cmd, scriptVar checked, scriptVar disabled) { + SCRIPT_FUNCTION_INIT; + ASSERT(str.type == SCRIPT_STRING); // compiler discarded + ASSERT(SOM::isNumeric(&cmd)); // compiler discarded + ASSERT(SOM::isNumeric(&checked)); // compiler discarded + ASSERT(SOM::isNumeric(&disabled)); // compiler discarded + SPopup *p = static_cast(o->vcpu_getInterface(popupGuid)); + if (p) + p->addCommand(str.data.sdata, SOM::makeInt(&cmd), SOM::makeBoolean(&checked), SOM::makeBoolean(&disabled)); + RETURN_SCRIPT_VOID; +} + +scriptVar SPopup::script_vcpu_addSeparator(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SPopup *p = static_cast(o->vcpu_getInterface(popupGuid)); + if (p) p->addSeparator(); + RETURN_SCRIPT_VOID; +} + +scriptVar SPopup::script_vcpu_checkCommand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i, scriptVar check) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&i)); + ASSERT(SOM::isNumeric(&check)); + SPopup *p = static_cast(o->vcpu_getInterface(popupGuid)); + if (p) p->checkCommand(SOM::makeInt(&i), SOM::makeBoolean(&check)); + RETURN_SCRIPT_VOID; +} + +scriptVar SPopup::script_vcpu_disableCommand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i, scriptVar disable) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&i)); + ASSERT(SOM::isNumeric(&disable)); + SPopup *p = static_cast(o->vcpu_getInterface(popupGuid)); + if (p) p->disableCommand(SOM::makeInt(&i), SOM::makeBoolean(&disable)); + RETURN_SCRIPT_VOID; +} + +scriptVar SPopup::script_vcpu_popAtXY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&x)); + ASSERT(SOM::isNumeric(&y)); + SPopup *p = static_cast(o->vcpu_getInterface(popupGuid)); + if (p) return MAKE_SCRIPT_INT(p->popAtXY(SOM::makeInt(&x), SOM::makeInt(&y))); + RETURN_SCRIPT_ZERO; +} + +scriptVar SPopup::script_vcpu_popAtMouse(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SPopup *p = static_cast(o->vcpu_getInterface(popupGuid)); + if (p) return MAKE_SCRIPT_INT(p->popAtMouse()); + RETURN_SCRIPT_ZERO; +} + +scriptVar SPopup::script_vcpu_getNumCommands(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SPopup *p = static_cast(o->vcpu_getInterface(popupGuid)); + if (p) return MAKE_SCRIPT_INT(p->getNumCommands()); + RETURN_SCRIPT_ZERO; +} diff --git a/Src/Wasabi/api/script/objects/spopup.h b/Src/Wasabi/api/script/objects/spopup.h new file mode 100644 index 00000000..07bd82df --- /dev/null +++ b/Src/Wasabi/api/script/objects/spopup.h @@ -0,0 +1,60 @@ +//PORTABLE +#ifndef _SPOPUP_H +#define _SPOPUP_H + +#include +#include + +// {F4787AF4-B2BB-4ef7-9CFB-E74BA9BEA88D} +static const GUID popupGuid = +{ 0xf4787af4, 0xb2bb, 0x4ef7, { 0x9c, 0xfb, 0xe7, 0x4b, 0xa9, 0xbe, 0xa8, 0x8d } }; + +#define SPOPUP_PARENT PopupMenu + +class PopupScriptController: public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController() { return rootScriptObjectController; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern PopupScriptController *popupController; + + +#ifndef WANT_NEW_POPUPMENU +class SPopup : public SPOPUP_PARENT, public RootObjectInstance { +#else +class SPopup : public SPOPUP_PARENT { +#endif +public: + SPopup(); + virtual ~SPopup(); + +private: + +public: + + static scriptVar script_vcpu_addSubMenu(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar popup, scriptVar str); + static scriptVar script_vcpu_addCommand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar str, scriptVar cmd, scriptVar checked, scriptVar disabled); + static scriptVar script_vcpu_addSeparator(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_popAtXY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar script_vcpu_popAtMouse(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getNumCommands(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_disableCommand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar cmd, scriptVar disable); + static scriptVar script_vcpu_checkCommand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar cmd, scriptVar check); +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/sprivate.cpp b/Src/Wasabi/api/script/objects/sprivate.cpp new file mode 100644 index 00000000..515fbb08 --- /dev/null +++ b/Src/Wasabi/api/script/objects/sprivate.cpp @@ -0,0 +1,258 @@ +#include +#include "sprivate.h" +#include "main.h" +#include +#include "wa2frontend.h" +#include +#include "../Agave/Language/api_language.h" +#include "../../../../Components/wac_network/wac_network_http_receiver_api.h" +#include "../nu/AutoWide.h" +#include "../nu/AutoChar.h" +#include "../nu/ns_wc.h" +#include "../Winamp/buildtype.h" +#include "../nu/refcount.h" +#include +#include + +// {78BD6ED9-0DBC-4fa5-B5CD-5977E3A912F8} +static const GUID SPrivate_script_object_guid = +{ 0x78bd6ed9, 0xdbc, 0x4fa5, { 0xb5, 0xcd, 0x59, 0x77, 0xe3, 0xa9, 0x12, 0xf8 } }; + + +static SPrivateScriptObjectController _SPrivateController; +ScriptObjectController *SPrivateController=&_SPrivateController; + +// -- Functions table ------------------------------------- +function_descriptor_struct SPrivateScriptObjectController::exportedFunction[] = +{ + {L"updateLinks", 2, (void*)SPrivate::vcpu_updateLinks }, + {L"onLinksUpdated", 1, (void*)SPrivate::vcpu_onLinksUpdated }, +}; +// -------------------------------------------------------- + +const wchar_t *SPrivateScriptObjectController::getClassName() +{ + return L"Private"; +} + +const wchar_t *SPrivateScriptObjectController::getAncestorClassName() +{ + return L"Object"; +} + +ScriptObjectController *SPrivateScriptObjectController::getAncestorController() +{ + return NULL; +} + +ScriptObject *SPrivateScriptObjectController::instantiate() +{ + SPrivate *c = new SPrivate; + if (!c) return NULL; + return c->getScriptObject(); +} + +int SPrivateScriptObjectController::getInstantiable() +{ + return 1; +} + +void SPrivateScriptObjectController::destroy(ScriptObject *o) +{ + SPrivate *obj = static_cast(o->vcpu_getInterface(SPrivate_script_object_guid)); + ASSERT(obj != NULL); + obj->dlcb = false; + delete obj; +} + +void *SPrivateScriptObjectController::encapsulate(ScriptObject *o) +{ + return NULL; +} + +void SPrivateScriptObjectController::deencapsulate(void *o) +{ +} + +int SPrivateScriptObjectController::getNumFunctions() +{ + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *SPrivateScriptObjectController::getExportedFunctions() +{ + return exportedFunction; +} + +GUID SPrivateScriptObjectController::getClassGuid() +{ + return SPrivate_script_object_guid; +} + +/*-----------------------------------*/ + +static void DoAPC(PAPCFUNC apc, ULONG_PTR data) +{ + HANDLE hMainThread = WASABI_API_APP->main_getMainThreadHandle(); + if (hMainThread) + { + QueueUserAPC(apc, hMainThread, data); + CloseHandle(hMainThread); + } +} + +static void CALLBACK LinksUpdatedAPC(ULONG_PTR data) +{ + ScriptObject* scriptCallback = (ScriptObject *)data; + SPrivate::vcpu_onLinksUpdated(SCRIPT_CALL, scriptCallback); +} + +class PDownloadCallback : public Countable +{ +public: + PDownloadCallback (const char *url, ScriptObject* scriptCallback) + { + this->scriptCallback = scriptCallback; + validSO = true; + } + + ~PDownloadCallback () + { + } + + + void OnFinish (DownloadToken token) + { + if (!validSO) + { + DeleteFileW(WAC_API_DOWNLOADMANAGER->GetLocation(token)); + delete this; + return; + } + + api_httpreceiver *http = WAC_API_DOWNLOADMANAGER->GetReceiver(token); + if (http) + { + int replyCode; + replyCode = http->getreplycode(); + if (204 != replyCode) + { + BOOL succeeded; + HANDLE hDest; + const wchar_t *downloadDest; + wchar_t finalFileName[MAX_PATH] = {0}; + + downloadDest = WAC_API_DOWNLOADMANAGER->GetLocation(token); + succeeded = FALSE; + + hDest = CreateFileW(downloadDest, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_EXISTING, 0, NULL); + if (INVALID_HANDLE_VALUE != hDest) + { + LARGE_INTEGER fileSize; + if (FALSE != GetFileSizeEx(hDest, &fileSize) && + 0 != fileSize.QuadPart) + { + succeeded = TRUE; + } + + CloseHandle(hDest); + + if (FALSE == succeeded) + { + DeleteFileW(downloadDest); + downloadDest = NULL; + } + } + + if (FALSE != succeeded && + NULL != (PathCombineW(finalFileName, WASABI_API_APP->path_getUserSettingsPath(), L"links.xml"))) + { + // then move the file there + succeeded = MoveFileW(downloadDest, finalFileName); + if (FALSE == succeeded) + { + succeeded = CopyFileW(downloadDest, finalFileName, FALSE); + DeleteFileW(downloadDest); + } + if (FALSE != succeeded) + { + // hop back on the main thread for the callback + DoAPC(LinksUpdatedAPC, (ULONG_PTR)scriptCallback); + } + } + } + } + Release(); + } + + void OnError (DownloadToken token, int error) + { + Release(); + } + void OnCancel (DownloadToken token) + { + Release(); + } + + void OnTick (DownloadToken token) {} + + ScriptObject* scriptCallback; + bool validSO; + REFERENCE_COUNT_IMPLEMENTATION; + +protected: + RECVS_DISPATCH; +}; + + +SPrivate::SPrivate() +{ + getScriptObject()->vcpu_setInterface(SPrivate_script_object_guid, static_cast(this)); + getScriptObject()->vcpu_setClassName(L"Private"); + getScriptObject()->vcpu_setController(SPrivateController); + dlcb = false; +} +SPrivate::~SPrivate() +{ +} + +scriptVar SPrivate::vcpu_updateLinks(SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar version, scriptVar bversion) +{ + SCRIPT_FUNCTION_INIT; + + String url; + + //if defined(BETA) || defined(INTERNAL) + const wchar_t *langIdentifier = WASABI_API_LNG?(WASABI_API_LNG->GetLanguageIdentifier(LANG_IDENT_STR)):0; + if (!langIdentifier) + langIdentifier = L"en-US"; + + url = StringPrintf("http://client.winamp.com/data/skins?o=links&sid=bento&version=%s&waversion=%s&build=%i&browserversion=%s&lang=%s", AutoChar(version.data.sdata), WASABI_API_APP->main_getVersionNumString(), WASABI_API_APP->main_getBuildNumber(),AutoChar(bversion.data.sdata), AutoChar(langIdentifier)); + //url = StringPrintf("http://martin.skinconsortium.com/links.php?o=links&sid=bento&version=%s&waversion=%s&build=%i&browserversion=%s", AutoChar(version.data.sdata), WASABI_API_APP->main_getVersionNumString(), WASABI_API_APP->main_getBuildNumber(),AutoChar(bversion.data.sdata)); + + SPrivate *sp = static_cast(object->vcpu_getInterface(SPrivate_script_object_guid)); + sp->dlcb = new PDownloadCallback(url, object); + WAC_API_DOWNLOADMANAGER->Download(url, sp->dlcb); + + RETURN_SCRIPT_VOID; +} + +scriptVar SPrivate::vcpu_onLinksUpdated(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, SPrivateController); + SCRIPT_FUNCTION_CHECKABORTEVENT(o); + SCRIPT_EXEC_EVENT0(o); +} + + +#define CBCLASS PDownloadCallback +START_DISPATCH; +REFERENCE_COUNTED; +VCB(IFC_DOWNLOADMANAGERCALLBACK_ONFINISH, OnFinish) +VCB(IFC_DOWNLOADMANAGERCALLBACK_ONTICK, OnTick) +VCB(IFC_DOWNLOADMANAGERCALLBACK_ONERROR, OnError) +VCB(IFC_DOWNLOADMANAGERCALLBACK_ONCANCEL, OnCancel) +END_DISPATCH; +#undef CBCLASS \ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/sprivate.h b/Src/Wasabi/api/script/objects/sprivate.h new file mode 100644 index 00000000..503fbb1a --- /dev/null +++ b/Src/Wasabi/api/script/objects/sprivate.h @@ -0,0 +1,47 @@ +#pragma once +#include +#include +#include +#include +#include + +class PDownloadCallback; + +#define SPRIVATE_SCRIPTPARENT RootObjectInstance + +class SPrivateScriptObjectController : public ScriptObjectControllerI +{ + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual int getInstantiable(); + virtual int getReferenceable() {return 0;} + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + static function_descriptor_struct exportedFunction[]; + +}; + +extern ScriptObjectController *SPrivateController; + +class SPrivate : public SPRIVATE_SCRIPTPARENT +{ +public: + SPrivate(); + virtual ~SPrivate(); + + PDownloadCallback * dlcb; + +public: + static scriptVar vcpu_updateLinks(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar version, scriptVar bversion); + static scriptVar vcpu_onLinksUpdated(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +}; diff --git a/Src/Wasabi/api/script/objects/sregion.cpp b/Src/Wasabi/api/script/objects/sregion.cpp new file mode 100644 index 00000000..0a966f8a --- /dev/null +++ b/Src/Wasabi/api/script/objects/sregion.cpp @@ -0,0 +1,256 @@ +#include +#include "sregion.h" + +#include +#include + +RegionScriptController _regionController; +RegionScriptController *regionController=&_regionController; + +// -- Functions table ------------------------------------- +function_descriptor_struct RegionScriptController::exportedFunction[] = { + {L"add", 1, (void*)SRegion::script_vcpu_add }, + {L"sub", 1, (void*)SRegion::script_vcpu_sub }, + {L"offset", 2, (void*)SRegion::script_vcpu_offset }, + {L"stretch", 1, (void*)SRegion::script_vcpu_stretch }, + {L"copy", 1, (void*)SRegion::script_vcpu_copy }, + {L"loadFromMap", 3, (void*)SRegion::script_vcpu_loadFromMap }, + {L"loadFromBitmap", 1, (void*)SRegion::script_vcpu_loadFromBitmap }, + {L"getBoundingBoxX", 0, (void*)SRegion::script_vcpu_getBoundX }, + {L"getBoundingBoxY", 0, (void*)SRegion::script_vcpu_getBoundY }, + {L"getBoundingBoxW", 0, (void*)SRegion::script_vcpu_getBoundW }, + {L"getBoundingBoxH", 0, (void*)SRegion::script_vcpu_getBoundH }, +}; +// -------------------------------------------------------- + +const wchar_t *RegionScriptController::getClassName() { + return L"Region"; +} + +const wchar_t *RegionScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObjectController *RegionScriptController::getAncestorController() { return rootScriptObjectController; } + +ScriptObject *RegionScriptController::instantiate() { + SRegion *r = new SRegion; + ASSERT(r != NULL); + return r->getScriptObject(); +} + +void RegionScriptController::destroy(ScriptObject *o) { + SRegion *r = static_cast(o->vcpu_getInterface(regionGuid)); + ASSERT(r != NULL); + delete r; +} + +void *RegionScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for regions yet +} + +void RegionScriptController::deencapsulate(void *o) { +} + +int RegionScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *RegionScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID RegionScriptController::getClassGuid() { + return regionGuid; +} + +SRegion::SRegion() { + getScriptObject()->vcpu_setInterface(regionGuid, (void *)static_cast(this)); + getScriptObject()->vcpu_setClassName(L"Region"); + getScriptObject()->vcpu_setController(regionController); + reg = new RegionI; +} + +SRegion::~SRegion() { + delete reg; +} + +int SRegion::inRegion(int x, int y) { + if (!reg) return 0; + POINT pt={x,y}; + return reg->ptInRegion(&pt); +} + +int SRegion::getBoundX() { + if (!reg) return 0; + RECT r; + reg->getBox(&r); + return r.left; +} + +int SRegion::getBoundY() { + if (!reg) return 0; + RECT r; + reg->getBox(&r); + return r.top; +} + +int SRegion::getBoundW() { + if (!reg) return 0; + RECT r; + reg->getBox(&r); + return r.right-r.left; +} + +int SRegion::getBoundH() { + if (!reg) return 0; + RECT r; + reg->getBox(&r); + return r.bottom-r.top; +} + +api_region *SRegion::getRegion() { + return reg; +} + +void SRegion::addRegion(SRegion *s) { + if (!reg) reg = new RegionI; + reg->addRegion(s->getRegion()); +} + +void SRegion::subRegion(SRegion *s) { + if (!reg) return; + reg->subtractRgn(s->getRegion()); +} + +void SRegion::offset(int x, int y) { + if (!reg) return; + reg->offset(x, y); +} + +void SRegion::stretch(double s) { + if (!reg) return; + reg->scale(s, s); +} + +void SRegion::copy(SRegion *s) { + if (!reg) reg = new RegionI; + else reg->empty(); + reg->addRegion(s->getRegion()); +} + +void SRegion::loadFromMap(SMap *m, int byte, int inverted) { + delete reg; + RECT r={m->getBitmap()->getX(), m->getBitmap()->getY(), m->getBitmap()->getWidth(), m->getBitmap()->getHeight()}; + reg = new RegionI(m->getBitmap(), &r, 0, 0, FALSE, 1, byte, inverted); +} + +void SRegion::loadFromBitmap(const wchar_t *p) +{ + delete reg; + SkinBitmap *b = new SkinBitmap(p); + ASSERT(b); // TODO: should be guru + reg = new RegionI(b); + delete b; +} + +// ----------------------------------------------------------------------- + +scriptVar SRegion::script_vcpu_loadFromMap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar map, scriptVar byte, scriptVar inv) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&byte)); + ASSERT(SOM::isNumeric(&inv)); + SRegion *r = static_cast(o->vcpu_getInterface(regionGuid)); + SMap *m = static_cast(GET_SCRIPT_OBJECT_AS(map, mapGuid)); + if (r) r->loadFromMap(m, GET_SCRIPT_INT(byte), GET_SCRIPT_BOOLEAN(inv)); + RETURN_SCRIPT_VOID; +} + +scriptVar SRegion::script_vcpu_loadFromBitmap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar b) +{ + SCRIPT_FUNCTION_INIT; + ASSERT(b.type == SCRIPT_STRING); + SRegion *r = static_cast(o->vcpu_getInterface(regionGuid)); + if (r) r->loadFromBitmap(GET_SCRIPT_STRING(b)); + RETURN_SCRIPT_VOID; +} + +scriptVar SRegion::script_vcpu_inRegion(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&x)); + ASSERT(SOM::isNumeric(&y)); + SRegion *r = static_cast(o->vcpu_getInterface(regionGuid)); + if (r) return MAKE_SCRIPT_INT(r->inRegion(GET_SCRIPT_INT(x), GET_SCRIPT_INT(y))); + RETURN_SCRIPT_ZERO; +} + +scriptVar SRegion::script_vcpu_add(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r) { + SCRIPT_FUNCTION_INIT; + SRegion *r1 = static_cast(o->vcpu_getInterface(regionGuid)); + SRegion *r2 = static_cast(GET_SCRIPT_OBJECT_AS(r, regionGuid)); + if (r1) r1->addRegion(r2); + RETURN_SCRIPT_VOID; +} + +scriptVar SRegion::script_vcpu_sub(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r) { + SCRIPT_FUNCTION_INIT; + SRegion *r1 = static_cast(o->vcpu_getInterface(regionGuid)); + SRegion *r2 = static_cast(GET_SCRIPT_OBJECT_AS(r, regionGuid)); + if (r1) r1->subRegion(r2); + RETURN_SCRIPT_VOID; +} + +scriptVar SRegion::script_vcpu_offset(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&x)); + ASSERT(SOM::isNumeric(&y)); + SRegion *r = static_cast(o->vcpu_getInterface(regionGuid)); + if (r) r->offset(GET_SCRIPT_INT(x), GET_SCRIPT_INT(y)); + RETURN_SCRIPT_VOID; +} + +scriptVar SRegion::script_vcpu_stretch(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&s)); + SRegion *r = static_cast(o->vcpu_getInterface(regionGuid)); + if (r) r->stretch(SOM::makeDouble(&s)); + RETURN_SCRIPT_VOID; +} + +scriptVar SRegion::script_vcpu_getBoundX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SRegion *r = static_cast(o->vcpu_getInterface(regionGuid)); + if (r) return MAKE_SCRIPT_INT(r->getBoundX()); + RETURN_SCRIPT_ZERO; +} + +scriptVar SRegion::script_vcpu_getBoundY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SRegion *r = static_cast(o->vcpu_getInterface(regionGuid)); + if (r) return MAKE_SCRIPT_INT(r->getBoundY()); + RETURN_SCRIPT_ZERO; +} + +scriptVar SRegion::script_vcpu_getBoundW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SRegion *r = static_cast(o->vcpu_getInterface(regionGuid)); + if (r) return MAKE_SCRIPT_INT(r->getBoundW()); + RETURN_SCRIPT_ZERO; +} + +scriptVar SRegion::script_vcpu_getBoundH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SRegion *r = static_cast(o->vcpu_getInterface(regionGuid)); + if (r) return MAKE_SCRIPT_INT(r->getBoundH()); + RETURN_SCRIPT_ZERO; +} + +scriptVar SRegion::script_vcpu_copy(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r) { + SCRIPT_FUNCTION_INIT; + SRegion *r1 = static_cast(o->vcpu_getInterface(regionGuid)); + SRegion *r2 = static_cast(GET_SCRIPT_OBJECT_AS(r, regionGuid)); + if (r1) r1->copy(r2); + RETURN_SCRIPT_VOID; +} + + diff --git a/Src/Wasabi/api/script/objects/sregion.h b/Src/Wasabi/api/script/objects/sregion.h new file mode 100644 index 00000000..00d0e607 --- /dev/null +++ b/Src/Wasabi/api/script/objects/sregion.h @@ -0,0 +1,92 @@ +#ifndef __SREGION_H +#define __SREGION_H + +class SRegion; + +#ifndef _NOSTUDIO + +#include +#include + +#endif + +#include +#include + +// {3A370C02-3CBF-439f-84F1-86885BCF1E36} +static const GUID regionGuid = +{ 0x3a370c02, 0x3cbf, 0x439f, { 0x84, 0xf1, 0x86, 0x88, 0x5b, 0xcf, 0x1e, 0x36 } }; + +#define SREGION_SCRIPTPARENT RootObjectInstance + +class RegionScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern RegionScriptController *regionController; + + +#ifndef _NOSTUDIO + +class SRegion : public SREGION_SCRIPTPARENT { +public: + SRegion(); + virtual ~SRegion(); + + int inRegion(int x, int y); + void loadFromMap(SMap *map, int byte, int inv); + void loadFromBitmap(const wchar_t *p); + int getBoundX(); + int getBoundY(); + int getBoundW(); + int getBoundH(); + api_region *getRegion(); + void addRegion(SRegion *s); + void subRegion(SRegion *s); + void offset(int x, int y); + void stretch(double s); + void copy(SRegion *s); + + +private: + RegionI *reg; + +#else +class SRegion : SREGION_SCRIPTPARENT { +#endif + +// FG> +// -- SCRIPT ----------------------------------------------------- +public: + static scriptVar script_vcpu_loadFromMap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar map, scriptVar byte, scriptVar inv); + static scriptVar script_vcpu_loadFromBitmap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar map); + static scriptVar script_vcpu_inRegion(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar script_vcpu_add(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r); + static scriptVar script_vcpu_sub(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r); + static scriptVar script_vcpu_offset(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar script_vcpu_stretch(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s); + static scriptVar script_vcpu_copy(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r); + static scriptVar script_vcpu_getBoundX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getBoundY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getBoundW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getBoundH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/svcwnd.cpp b/Src/Wasabi/api/script/objects/svcwnd.cpp new file mode 100644 index 00000000..2ab301e9 --- /dev/null +++ b/Src/Wasabi/api/script/objects/svcwnd.cpp @@ -0,0 +1,239 @@ +#include "precomp.h" +#include "../../bfc/std.h" +#include "script.h" +#include "scriptmgr.h" +#include "../../bfc/notifmsg.h" +#include "../../common/script/scriptobj.h" +#include "compoobj.h" +#include "../api.h" +#include "vcpu.h" +#include "../smap.h" +#include "../skinparse.h" +#include "svcwnd.h" +#include "../services/services.h" +#include "../services/servicei.h" +#include "../svcmgr.h" +#include "../services/svc_wndcreate.h" + +char svcWndXuiObjectStr[] = "SvcWnd"; // This is the xml tag +char svcWndXuiSvcName[] = "SvcWnd xui object"; // this is the name of the xuiservice + + +SvcWndScriptController _svcWndController; +SvcWndScriptController *svcWndController = &_svcWndController; + +// -- Functions table ------------------------------------- +function_descriptor_struct SvcWndScriptController::exportedFunction[] = { + {"getGUID", 1, (void*)SvcWnd::script_vcpu_getGUID }, + {"getWac", 0, (void*)SvcWnd::script_vcpu_getWac }, +}; +// -------------------------------------------------------- + +const wchar_t *SvcWndScriptController::getClassName() { + return L"SvcGuiObject"; +} + +const wchar_t *SvcWndScriptController::getAncestorClassName() { + return "GuiObject"; +} + +int SvcWndScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *SvcWndScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID SvcWndScriptController::getClassGuid() { + return svcWndGuid; +} + +ScriptObject *SvcWndScriptController::instantiate() { + SvcWnd *sv = new SvcWnd(); + ASSERT(sv != NULL); + return sv->getScriptObject(); +} + +void SvcWndScriptController::destroy(ScriptObject *o) { + SvcWnd *obj = static_cast(o->vcpu_getInterface(svcWndGuid)); + ASSERT(obj != NULL); + delete obj; +} + +void *SvcWndScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for svcwnd yet +} + +void SvcWndScriptController::deencapsulate(void *o) { +} + +char SvcWndParams[][] = +{ + "DBLCLICKACTION", //SVCWND_DBLCLKACTION + "GUID" // SVCWND_GUID +}; +SvcWnd::SvcWnd() { + getScriptObject()->vcpu_setInterface(svcWndGuid, (void *)static_cast(this)); + getScriptObject()->vcpu_setClassName("SvcGuiObject"); + getScriptObject()->vcpu_setController(svcWndController); + myGUID = INVALID_GUID; + svcwnd = NULL; + svc = NULL; + forwarded = 0; + xuihandle = newXuiHandle(); + + addParam(xuihandle, SvcWndParams[0], SVCWND_DBLCLKACTION, XUI_ATTRIBUTE_IMPLIED); + addParam(xuihandle, SvcWndParams[1], SVCWND_GUID, XUI_ATTRIBUTE_IMPLIED); + +} + +// servicewnd to svcwnd + +int SvcWnd::childNotify(api_window *child, int msg, intptr_t param1, intptr_t param2) { + if (child == svcwnd) { + switch (msg) { + case ChildNotify::SVCWND_LBUTTONDOWN: + onLeftButtonDown(param1, param2); + break; + case ChildNotify::SVCWND_RBUTTONDOWN: + onRightButtonDown(param1, param2); + break; + case ChildNotify::SVCWND_LBUTTONUP: + onLeftButtonUp(param1, param2); + break; + case ChildNotify::SVCWND_RBUTTONUP: + onRightButtonUp(param1, param2); + break; + case ChildNotify::SVCWND_LBUTTONDBLCLK: + onLeftButtonDblClk(param1, param2); + break; + case ChildNotify::SVCWND_RBUTTONDBLCLK: + onRightButtonDblClk(param1, param2); + break; + case ChildNotify::SVCWND_MOUSEMOVE: + onMouseMove(param1, param2); + break; + } + forwarded = 0; + } else + return SVCWND_PARENT::childNotify(child, msg, param1, param2); + return 1; +} + +// virtualwnd to guiobject bridging + +int SvcWnd::onLeftButtonDblClk(int x, int y) { + if(!dblClickAction.isempty()) { + const char *toCheck="SWITCH;"; + if(!STRNINCMP(dblClickAction,toCheck)) { + onLeftButtonUp(x,y); + getGuiObject()->guiobject_getParentGroup()->getParentContainer()->switchToLayout(dblClickAction.getValue()+STRLEN(toCheck)); + } + } + return SVCWND_PARENT::onLeftButtonDblClk(x, y); +} + +int SvcWnd::onResize() { + SVCWND_PARENT::onResize(); + RECT r = clientRect(); + if (svcwnd) + svcwnd->resize(r.left, r.top, r.right-r.left, r.bottom-r.top); + return 1; +} + +void SvcWnd::onSetVisible(int v) { + if (svcwnd) svcwnd->setVisible(v); + SVCWND_PARENT::onSetVisible(v); +} + +int SvcWnd::setXuiParam(int _xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *value) { + if (_xuihandle == xuihandle) { + switch (xmlattributeid) { + case SVCWND_GUID: { + GUID *g; + g = SkinParser::getComponentGuid(value); + if (g) + setGUID(*g); + return 1; + } + case SVCWND_DBLCLKACTION: + dblClickAction = value; + return 1; + } + } + return SVCWND_PARENT::setXuiParam(_xuihandle,xmlattributeid,xmlattributename,value); +} + +int SvcWnd::onUnknownXuiParam(const wchar_t *param, const wchar_t *value) { + params.addItem(new String(param)); + params.addItem(new String(value)); + return 0; +} + +int SvcWnd::onInit() { + int r = SVCWND_PARENT::onInit(); + WindowCreateByGuidEnum wce(getGUID()); + for (;;) { + if (!svc) + svc = wce.getNext(); + if (!svc) return 0; + svcwnd = svc->createWindowByGuid(getGUID(), this); + if (svcwnd != NULL) break; + SvcEnum::release(svc); svc = NULL; + } + if (svcwnd != NULL) + { + svcwnd->setStartHidden(1); + if (!svcwnd->isInited()) + r &= svcwnd->init(this); + if (params.getNumItems() > 0) { + for (int i=0;igetGuiObject()->guiobject_setXmlParam(params[i]->getValue(), params[i+1]->getValue()); + } + } + } + params.deleteAll(); + return r; +} + +SvcWnd::~SvcWnd() { + if (svc) { + svc->destroyWindow(svcwnd); + ServiceManager::release(svc); + } +} + +int SvcWnd::handleRatio() { + return 1; // todo: ask window +} + +void SvcWnd::setGUID(GUID g) { + myGUID = g; +} + +GUID SvcWnd::getGUID(void) { + return myGUID; +} + +int SvcWnd::getPreferences(int what) { + if (svcwnd) return svcwnd->getPreferences(what); + return SVCWND_PARENT::getPreferences(what); +} + +scriptVar SvcWnd::script_vcpu_getGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SvcWnd *s = static_cast(o->vcpu_getInterface(svcWndGuid)); + if (s) + return MAKE_SCRIPT_STRING(StringPrintf(s->myGUID)); + else + return MAKE_SCRIPT_STRING(""); +} + +scriptVar SvcWnd::script_vcpu_getWac(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SvcWnd *s = static_cast(o->vcpu_getInterface(svcWndGuid)); + if (s) return MAKE_SCRIPT_OBJECT(SOM::getWACObject(s->getGUID())->getScriptObject()); + RETURN_SCRIPT_VOID; +} + diff --git a/Src/Wasabi/api/script/objects/svcwnd.h b/Src/Wasabi/api/script/objects/svcwnd.h new file mode 100644 index 00000000..41f83f28 --- /dev/null +++ b/Src/Wasabi/api/script/objects/svcwnd.h @@ -0,0 +1,89 @@ +#ifndef _SVCWND_H +#define _SVCWND_H + +#include "script.h" +#include "../../common/script/scriptobj.h" +#include "guiobj.h" +#include "../../bfc/svc_enum.h" + +class SMap; +class SRegion; +class Container; +class Layout; + +// {8776F715-503A-41f9-BD63-FB148AD05765} +static const GUID svcWndGuid = +{ 0x8776f715, 0x503a, 0x41f9, { 0xbd, 0x63, 0xfb, 0x14, 0x8a, 0xd0, 0x57, 0x65 } }; + +#define SVCWND_PARENT GuiObjectWnd + +class SvcWndScriptController : public GuiObjectScriptController { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController() { return guiController; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern SvcWndScriptController *svcWndController; + +class SvcWnd : public SVCWND_PARENT { +public: + SvcWnd(); + virtual ~SvcWnd(); + + virtual int onLeftButtonDblClk(int x, int y); + virtual int onResize(); + virtual void onSetVisible(int v); + virtual int onInit(); + + virtual int getPreferences(int what); + virtual int handleRatio(); + + void setGUID(GUID g); + GUID getGUID(void); + + virtual int childNotify(ifc_window *child, int msg, intptr_t param1, intptr_t param2); + virtual int setXuiParam(int _xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *value); + virtual int onUnknownXuiParam(const wchar_t *param, const wchar_t *value); + + // VCPU + static scriptVar script_vcpu_getGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getWac(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + PtrList params; + // End VCPU + +protected: + + enum { + SVCWND_GUID=0, + SVCWND_DBLCLKACTION, + }; + +private: + GUID myGUID; + ifc_window *svcwnd; + svc_windowCreate *svc; + int forwarded; + StringW dblClickAction; + int xuihandle; +}; + +extern char svcWndXuiObjectStr[]; +extern char svcWndXuiSvcName[]; +class SvcWndXuiSvc : public XuiObjectSvc {}; + + +#endif diff --git a/Src/Wasabi/api/script/objects/sxmldoc.cpp b/Src/Wasabi/api/script/objects/sxmldoc.cpp new file mode 100644 index 00000000..f5954c20 --- /dev/null +++ b/Src/Wasabi/api/script/objects/sxmldoc.cpp @@ -0,0 +1,231 @@ +#include +#include "sxmldoc.h" + +#include "slist.h" + +#include +#include +#include + + +// {417FFB69-987F-4be8-8D87-D9965EEEC868} +static const GUID xmlDocGuid = +{ 0x417ffb69, 0x987f, 0x4be8, { 0x8d, 0x87, 0xd9, 0x96, 0x5e, 0xee, 0xc8, 0x68 } }; + + +XmlDocScriptController _xmlDocController; +XmlDocScriptController *xmlDocController=&_xmlDocController; + +// -- Functions table ------------------------------------- +function_descriptor_struct XmlDocScriptController::exportedFunction[] = { + {L"parser_addCallback", 1, (void*)SXmlDoc::script_vcpu_addParserCallback }, + {L"parser_start", 0, (void*)SXmlDoc::script_vcpu_parse }, + {L"parser_destroy", 0, (void*)SXmlDoc::script_vcpu_destroyParser }, + {L"parser_onCallback", 4, (void*)SXmlDoc::script_vcpu_onXmlParserCallback}, + {L"parser_onCloseCallback", 2, (void*)SXmlDoc::script_vcpu_onXmlParserEndCallback}, + {L"parser_onError", 5, (void*)SXmlDoc::script_vcpu_onXmlParserError}, +}; +// -------------------------------------------------------- + +const wchar_t *XmlDocScriptController::getClassName() { + return L"XmlDoc"; +} + +const wchar_t *XmlDocScriptController::getAncestorClassName() { + return L"File"; +} + +ScriptObjectController *XmlDocScriptController::getAncestorController() { return rootScriptObjectController; } + +ScriptObject *XmlDocScriptController::instantiate() { + SXmlDoc *xd = new SXmlDoc; + ASSERT(xd != NULL); + return xd->getScriptObject(); +} + +void XmlDocScriptController::destroy(ScriptObject *o) { + SXmlDoc *xd = static_cast(o->vcpu_getInterface(xmlDocGuid)); + ASSERT(xd != NULL); + delete xd; +} + +void *XmlDocScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for XmlDocs for now +} + +void XmlDocScriptController::deencapsulate(void *o) { +} + +int XmlDocScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *XmlDocScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID XmlDocScriptController::getClassGuid() { + return xmlDocGuid; +} + + +SXmlDoc::SXmlDoc() { + getScriptObject()->vcpu_setInterface(xmlDocGuid, (void *)static_cast(this)); + getScriptObject()->vcpu_setClassName(L"XmlDoc"); + getScriptObject()->vcpu_setController(xmlDocController); + filename = NULL; + myXmlParser = NULL; +} + +SXmlDoc::~SXmlDoc() { + destroyParser(); +} + +void SXmlDoc::addParserCallback(const wchar_t *name) +{ + createParser(); + StringW sw_name = name; + sw_name.replace(L"/", L"\f"); // We call subsections in Maki with a single /. in Wasabi \f is used + //debug: Std::messageBox(sw_name,name,0); + myXmlParser->xmlreader_registerCallback(sw_name, &myXmlParserCallback); + //debug: myXmlParser->xmlreader_registerCallback(L"WasabiXML\fbla", &myXmlParserCallback); +} + +void LoadXmlFile(obj_xml *parser, const wchar_t *filename); + +void SXmlDoc::startParsing() +{ +/* debug: createParser(); +myXmlParser->xmlreader_registerCallback(L"WasabiXML\fbla", &myXmlParserCallback); +myXmlParser->xmlreader_registerCallback(L"WasabiXML\fbrowserQuickLinks", &myXmlParserCallback);*/ + + if (!myXmlParser) return; + myXmlParser->xmlreader_open(); + LoadXmlFile(myXmlParser, filename); +} + +void SXmlDoc::createParser() +{ + if (myXmlParser != NULL) return; + + myXmlParserCallback.parent = this; + + myXmlParserFactory = WASABI_API_SVC->service_getServiceByGuid(obj_xmlGUID); + if (myXmlParserFactory) + { + myXmlParser = (obj_xml *)myXmlParserFactory->getInterface(); + + if (myXmlParser) + { + const wchar_t *file = Wasabi::Std::filename(filename); + int fnlen = wcslen(file); + StringW path = filename; + path.trunc( -fnlen); + XMLAutoInclude include(myXmlParser, path); + } + } +} + +void SXmlDoc::destroyParser() +{ + if (!myXmlParser) return; + myXmlParser->xmlreader_unregisterCallback(&myXmlParserCallback); + myXmlParser->xmlreader_close(); + myXmlParserFactory->releaseInterface(myXmlParser); + myXmlParser = NULL; +} + +// ParserCallbacks + +void SXmlDocParserCallback::xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params) +{ + //debug: Std::messageBox(xmlpath,xmltag,0); + StringW sw_xmlpath = xmlpath; + sw_xmlpath.replace(L"\f", L"/"); + + // Store the params and paramvalues in a SList + SList param; + SList paramvalue; + + for (size_t i = 0; i != params->getNbItems(); i++) + { + SList::script_vcpu_addItem(SCRIPT_CALL, param.getScriptObject(), MAKE_SCRIPT_STRING(params->getItemName(i))); + SList::script_vcpu_addItem(SCRIPT_CALL, paramvalue.getScriptObject(), MAKE_SCRIPT_STRING(params->getItemValue(i))); + } + + // and now the monster call ;) + SXmlDoc::script_vcpu_onXmlParserCallback( + SCRIPT_CALL, parent->getScriptObject(), + MAKE_SCRIPT_STRING(sw_xmlpath), + MAKE_SCRIPT_STRING(xmltag), + MAKE_SCRIPT_OBJECT(param.getScriptObject()), + MAKE_SCRIPT_OBJECT(paramvalue.getScriptObject()) ); +} + +void SXmlDocParserCallback::xmlReaderOnEndElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag) +{ + StringW sw_xmlpath = xmlpath; + sw_xmlpath.replace(L"\f", L"/"); + + SXmlDoc::script_vcpu_onXmlParserEndCallback(SCRIPT_CALL, parent->getScriptObject(), MAKE_SCRIPT_STRING(sw_xmlpath), MAKE_SCRIPT_STRING(xmltag)); +} + +void SXmlDocParserCallback::xmlReaderOnError(int linenum, int errcode, const wchar_t *errstr) +{ + SXmlDoc::script_vcpu_onXmlParserError( + SCRIPT_CALL, parent->getScriptObject(), + MAKE_SCRIPT_STRING(L""), // xml api changed, but we should keep the same maki function! + MAKE_SCRIPT_INT(linenum), + MAKE_SCRIPT_STRING(L""), // xml api changed, but we should keep the same maki function! + MAKE_SCRIPT_INT(errcode), + MAKE_SCRIPT_STRING(errstr) ); +} + +// VCPU + +scriptVar SXmlDoc::script_vcpu_addParserCallback(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar fn) { + SCRIPT_FUNCTION_INIT; + ASSERT(fn.type == SCRIPT_STRING); + SXmlDoc *m = static_cast(o->vcpu_getInterface(xmlDocGuid)); + if (m) m->addParserCallback(fn.data.sdata); + + RETURN_SCRIPT_VOID; +} + +scriptVar SXmlDoc::script_vcpu_parse(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SXmlDoc *m = static_cast(o->vcpu_getInterface(xmlDocGuid)); + if (m) m->startParsing(); + + RETURN_SCRIPT_VOID; +} + +scriptVar SXmlDoc::script_vcpu_destroyParser(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SXmlDoc *m = static_cast(o->vcpu_getInterface(xmlDocGuid)); + if (m) m->destroyParser(); + + RETURN_SCRIPT_VOID; +} + +scriptVar SXmlDoc::script_vcpu_onXmlParserCallback(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar xmlpath, scriptVar xmltag, scriptVar param, scriptVar paramvalue) +{ + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS4(o, xmlDocController, xmlpath, xmltag, param, paramvalue); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT4(o, xmlpath, xmltag, param, paramvalue); +} +scriptVar SXmlDoc::script_vcpu_onXmlParserEndCallback(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar xmlpath, scriptVar xmltag) +{ + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS2(o, xmlDocController, xmlpath, xmltag); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, xmlpath, xmltag); +} +scriptVar SXmlDoc::script_vcpu_onXmlParserError(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar filename, scriptVar linenum, scriptVar incpath, scriptVar errcode, scriptVar errstr) +{ + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS5(o, xmlDocController, filename, linenum, incpath, errcode, errstr); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT5(o, filename, linenum, incpath, errcode, errstr); +} \ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/sxmldoc.h b/Src/Wasabi/api/script/objects/sxmldoc.h new file mode 100644 index 00000000..cfee2551 --- /dev/null +++ b/Src/Wasabi/api/script/objects/sxmldoc.h @@ -0,0 +1,76 @@ +#ifndef __SXMLDOC_H +#define __SXMLDOC_H + +class SXmlDoc; + +#include + +#include +#include +#include +#include + +#include + +#define SXMLDOC_SCRIPTPARENT SFile + +class XmlDocScriptController : public fileScriptController { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +class SXmlDocParserCallback : public ifc_xmlreadercallbackI +{ + void xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params); + void xmlReaderOnEndElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag); + void xmlReaderOnError(int linenum, int errcode, const wchar_t *errstr); + +public: SXmlDoc *parent; // reference to the xmldoc that triggered this callback +}; + +extern XmlDocScriptController *xmlDocController; + +class SXmlDoc : public SXMLDOC_SCRIPTPARENT +{ +public: + SXmlDoc(); + virtual ~SXmlDoc(); + + void addParserCallback(const wchar_t *b); + void startParsing(); + void destroyParser(); + void elementCallback(const wchar_t *xmltag); + +private: + obj_xml *myXmlParser; + SXmlDocParserCallback myXmlParserCallback; + waServiceFactory *myXmlParserFactory; + + void createParser(); + +public: + static scriptVar script_vcpu_addParserCallback(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar fn); + static scriptVar script_vcpu_parse(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_destroyParser(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_onXmlParserCallback(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar xmlpath, scriptVar xmltag, scriptVar param, scriptVar paramvalue); + static scriptVar script_vcpu_onXmlParserError(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar filename, scriptVar linenum, scriptVar incpath, scriptVar errcode, scriptVar errstr); + static scriptVar script_vcpu_onXmlParserEndCallback(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar xmlpath, scriptVar xmltag); + +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/systemobj.cpp b/Src/Wasabi/api/script/objects/systemobj.cpp new file mode 100644 index 00000000..fb13ee2b --- /dev/null +++ b/Src/Wasabi/api/script/objects/systemobj.cpp @@ -0,0 +1,3500 @@ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // for getAtom, CUT + +#ifdef WASABI_COMPILE_WNDMGR +#include +#include +#endif + +#include +#include +#include + +#ifdef WASABI_COMPILE_SKIN +#include +#include +#endif +#include +#include + +#include +#include +#include +#ifdef WASABI_COMPILE_WNDMGR +#include +#endif + +#include +#include +#include + +#ifdef WA3COMPATIBILITY +#include +#include +#include +#include //CUT!! +#endif + +#ifdef WASABI_COMPILE_MEDIACORE +#include +#include +#include +#include // safe to include even if core isn't there +#endif + +#ifdef WASABI_COMPILE_CONFIG +#include +#endif + +#include +#include "../Agave/Language/api_language.h" +#include +#include "../nu/AutoChar.h" +#include "../nu/AutoUrl.h" +#include "../nu/AutoWide.h" +#ifdef _WIN32 +#include +extern HINSTANCE hInstance; +#endif + +#ifdef GEN_FF +#include "../../../../Plugins/General/gen_ff/wa2frontend.h" +#endif + +SystemScriptObjectController _systemController; +SystemScriptObjectController *systemController = &_systemController; + +#define MAKI_RUNTIME_VERSION 2 + +// -- Functions table ------------------------------------- +function_descriptor_struct SystemScriptObjectController::exportedFunction[] = +{ + {L"getRuntimeVersion", 0, (void*)SystemObject::vcpu_getVersion}, + {L"onScriptLoaded", 0, (void*)SystemObject::vcpu_onScriptLoaded}, + {L"onScriptUnloading", 0, (void*)SystemObject::vcpu_onScriptUnloading}, + {L"onQuit", 0, (void*)SystemObject::vcpu_onQuit}, + {L"onKeyDown", 1, (void*)SystemObject::vcpu_onKeyDown}, + {L"onKeyUp", 1, (void*)SystemObject::vcpu_onKeyUp}, + {L"onAccelerator", 3, (void*)SystemObject::vcpu_onAccelerator}, + {L"getMousePosX", 0, (void*)SystemObject::vcpu_getMousePosX}, + {L"getMousePosY", 0, (void*)SystemObject::vcpu_getMousePosY}, + {L"isMinimized", 0, (void*)SystemObject::vcpu_isMinimized}, + {L"restoreApplication", 0, (void*)SystemObject::vcpu_restoreApplication}, + {L"activateApplication", 0, (void*)SystemObject::vcpu_activateApplication}, + {L"minimizeApplication", 0, (void*)SystemObject::vcpu_minimizeApplication}, + {L"isDesktopAlphaAvailable", 0, (void*)SystemObject::vcpu_isDesktopAlphaAvailable}, + {L"isTransparencyAvailable", 0, (void*)SystemObject::vcpu_isTransparencyAvailable}, +//----- + {L"integerToString", 1, (void*)SystemObject::vcpu_integerToString}, + {L"stringToInteger", 1, (void*)SystemObject::vcpu_stringToInteger}, + {L"floatToString", 2, (void*)SystemObject::vcpu_floatToString}, + {L"stringToFloat", 1, (void*)SystemObject::vcpu_stringToFloat}, + {L"integerToTime", 1, (void*)SystemObject::vcpu_integerToTime}, + {L"integerToLongTime", 1, (void*)SystemObject::vcpu_integerToLongTime}, + {L"dateToTime", 1, (void*)SystemObject::vcpu_dateToTime}, + {L"dateToLongTime", 1, (void*)SystemObject::vcpu_dateToLongTime}, + {L"formatDate", 1, (void*)SystemObject::vcpu_formatDate}, + {L"formatLongDate", 1, (void*)SystemObject::vcpu_formatLongDate}, + {L"getDateYear", 1, (void*)SystemObject::vcpu_getDateYear}, + {L"getDateMonth", 1, (void*)SystemObject::vcpu_getDateMonth}, + {L"getDateDay", 1, (void*)SystemObject::vcpu_getDateDay}, + {L"getDateDow", 1, (void*)SystemObject::vcpu_getDateDow}, + {L"getDateDoy", 1, (void*)SystemObject::vcpu_getDateDoy}, + {L"getDateHour", 1, (void*)SystemObject::vcpu_getDateHour}, + {L"getDateMin", 1, (void*)SystemObject::vcpu_getDateMin}, + {L"getDateSec", 1, (void*)SystemObject::vcpu_getDateSec}, + {L"getDateDst", 1, (void*)SystemObject::vcpu_getDateDst}, + {L"getDate", 0, (void*)SystemObject::vcpu_getDate}, + {L"StrMid", 3, (void*)SystemObject::vcpu_strmid}, + {L"StrLeft", 2, (void*)SystemObject::vcpu_strleft}, + {L"StrRight", 2, (void*)SystemObject::vcpu_strright}, + {L"StrSearch", 2, (void*)SystemObject::vcpu_strsearch}, + {L"StrLen", 1, (void*)SystemObject::vcpu_strlen}, + {L"StrUpper", 1, (void*)SystemObject::vcpu_strupper}, + {L"StrLower", 1, (void*)SystemObject::vcpu_strlower}, + {L"UrlEncode", 1, (void*)SystemObject::vcpu_urlencode}, + {L"UrlDecode", 1, (void*)SystemObject::vcpu_urldecode}, + {L"RemovePath", 1, (void*)SystemObject::vcpu_removepath}, + {L"GetPath", 1, (void*)SystemObject::vcpu_getpath}, + {L"GetExtension", 1, (void*)SystemObject::vcpu_getextension}, + {L"getToken", 3, (void*)SystemObject::vcpu_gettoken}, +//----- + {L"sin", 1, (void*)SystemObject::vcpu_sin}, + {L"cos", 1, (void*)SystemObject::vcpu_cos}, + {L"tan", 1, (void*)SystemObject::vcpu_tan}, + {L"asin", 1, (void*)SystemObject::vcpu_asin}, + {L"acos", 1, (void*)SystemObject::vcpu_acos}, + {L"atan", 1, (void*)SystemObject::vcpu_atan}, + {L"atan2", 2, (void*)SystemObject::vcpu_atan2}, + {L"pow", 2, (void*)SystemObject::vcpu_pow}, + {L"sqr", 1, (void*)SystemObject::vcpu_sqr}, + {L"sqrt", 1, (void*)SystemObject::vcpu_sqrt}, + {L"random", 1, (void*)SystemObject::vcpu_random}, + {L"integer", 1, (void*)SystemObject::vcpu_integer}, + {L"frac", 1, (void*)SystemObject::vcpu_frac}, + {L"ln", 1, (void*)SystemObject::vcpu_log}, + {L"log10", 1, (void*)SystemObject::vcpu_log10}, +//----- + {L"getParam", 0, (void*)SystemObject::vcpu_getParam}, + {L"getViewportWidth", 0, (void*)SystemObject::vcpu_getViewportWidth}, + {L"getViewportHeight", 0, (void*)SystemObject::vcpu_getViewportHeight}, + {L"getViewportLeft", 0, (void*)SystemObject::vcpu_getViewportLeft}, + {L"getViewportTop", 0, (void*)SystemObject::vcpu_getViewportTop}, + {L"getViewportWidthFromPoint", 2, (void*)SystemObject::vcpu_getViewportWidthFP}, + {L"getViewportHeightFromPoint",2, (void*)SystemObject::vcpu_getViewportHeightFP}, + {L"getViewportLeftFromPoint", 2, (void*)SystemObject::vcpu_getViewportLeftFP}, + {L"getViewportTopFromPoint", 2, (void*)SystemObject::vcpu_getViewportTopFP}, + {L"getViewportWidthFromGuiObject", 1, (void*)SystemObject::vcpu_getViewportWidthGO}, + {L"getViewportHeightFromGuiObject", 1, (void*)SystemObject::vcpu_getViewportHeightGO}, + {L"getViewportLeftFromGuiObject", 1, (void*)SystemObject::vcpu_getViewportLeftGO}, + {L"getViewportTopFromGuiObject", 1, (void*)SystemObject::vcpu_getViewportTopGO}, + {L"onViewPortChanged", 2, (void*)SystemObject::vcpu_onViewPortChanged}, + {L"debugString", 2, (void*)SystemObject::vcpu_debugString}, + {L"isObjectValid", 1, (void*)SystemObject::vcpu_isObjectValid}, + {L"getTimeOfDay", 0, (void*)SystemObject::vcpu_getTimeOfDay}, + {L"navigateUrl", 1, (void*)SystemObject::vcpu_navigateUrl}, + {L"navigateUrlBrowser", 1, (void*)SystemObject::vcpu_navigateUrlBrowser}, + {L"isKeyDown", 1, (void*)SystemObject::vcpu_isKeyDown}, + {L"setClipboardText", 1, (void*)SystemObject::vcpu_setClipboard}, + {L"Chr", 1, (void*)SystemObject::vcpu_chr}, + {L"triggerAction", 3, (void*)SystemObject::vcpu_triggerAction}, + {L"messageBox", 4, (void*)SystemObject::vcpu_messageBox}, + {L"setAtom", 2, (void*)SystemObject::vcpu_setAtom}, + {L"getAtom", 1, (void*)SystemObject::vcpu_getAtom}, +#ifdef WASABI_COMPILE_MAKIDEBUG + {L"invokeDebugger", 0, (void*)SystemObject::vcpu_invokeDebugger}, +#endif +#ifdef WASABI_COMPILE_SKIN + {L"newGroup", 1, (void*)SystemObject::vcpu_newGroup}, + {L"onSetXuiParam", 2, (void*)SystemObject::vcpu_onSetXuiParam}, + {L"getScriptGroup", 0, (void*)SystemObject::vcpu_getScriptGroup}, + {L"getSkinName", 0, (void*)SystemObject::vcpu_getSkinName}, + {L"newGroupAsLayout", 1, (void*)SystemObject::vcpu_newGroupAsLayout}, + {L"getNumContainers", 0, (void*)SystemObject::vcpu_getNumContainers}, + {L"enumContainer", 1, (void*)SystemObject::vcpu_enumContainer}, + {L"onCreateLayout", 1, (void*)SystemObject::vcpu_onCreateLayout}, + {L"onShowLayout", 1, (void*)SystemObject::vcpu_onShowLayout}, + {L"onHideLayout", 1, (void*)SystemObject::vcpu_onHideLayout}, + {L"switchSkin", 1, (void*)SystemObject::vcpu_switchSkin}, + {L"isLoadingSkin", 0, (void*)SystemObject::vcpu_isLoadingSkin}, + {L"lockUI", 0, (void*)SystemObject::vcpu_lockUI}, + {L"unlockUI", 0, (void*)SystemObject::vcpu_unlockUI}, +#endif +#if defined(WASABI_COMPILE_WNDMGR) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + { + L"getContainer", 1, (void*)SystemObject::vcpu_getContainer + }, + {L"newDynamicContainer", 1, (void*)SystemObject::vcpu_newDynamicContainer}, + {L"onGetCancelComponent", 2, (void*)SystemObject::vcpu_onGetCancelComponent}, + {L"onLookForComponent", 1, (void*)SystemObject::vcpu_onLookForComponent}, + {L"isAppActive", 0, (void*)SystemObject::vcpu_isAppActive}, + {L"showWindow", 3, (void*)SystemObject::vcpu_showWindow}, + {L"hideWindow", 1, (void*)SystemObject::vcpu_hideWindow}, + {L"hideNamedWindow", 1, (void*)SystemObject::vcpu_hideNamedWindow}, + {L"isNamedWindowVisible", 1, (void*)SystemObject::vcpu_isNamedWindowVisible}, + {L"getCurAppLeft", 0, (void*)SystemObject::vcpu_getCurAppLeft}, + {L"getCurAppTop", 0, (void*)SystemObject::vcpu_getCurAppTop}, + {L"getCurAppWidth", 0, (void*)SystemObject::vcpu_getCurAppWidth}, + {L"getCurAppHeight", 0, (void*)SystemObject::vcpu_getCurAppHeight}, +#endif +#if defined (WASABI_COMPILE_CONFIG) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + { + L"setPrivateString", 3, (void*)SystemObject::vcpu_setPrivateString + }, + {L"setPrivateInt", 3, (void*)SystemObject::vcpu_setPrivateInt}, + {L"getPrivateString", 3, (void*)SystemObject::vcpu_getPrivateString}, + {L"getPrivateInt", 3, (void*)SystemObject::vcpu_getPrivateInt}, + {L"setPublicString", 2, (void*)SystemObject::vcpu_setPublicString}, + {L"setPublicInt", 2, (void*)SystemObject::vcpu_setPublicInt}, + {L"getPublicString", 2, (void*)SystemObject::vcpu_getPublicString}, + {L"getPublicInt", 2, (void*)SystemObject::vcpu_getPublicInt}, +#endif +#if defined (WASABI_COMPILE_MEDIACORE) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + { + L"getPlayItemString", 0, (void*)SystemObject::vcpu_getPlayItemString + }, + {L"getPlayItemLength", 0, (void*)SystemObject::vcpu_getPlayItemLength}, + {L"getPlayItemMetadataString", 1, (void*)SystemObject::vcpu_getPlayItemMetadataString}, + {L"getMetadataString", 2, (void*)SystemObject::vcpu_getMetadataString}, + {L"getPlayItemDisplayTitle", 0, (void*)SystemObject::vcpu_getPlayItemDisplayTitle}, + {L"getExtFamily", 1, (void*)SystemObject::vcpu_getExtFamily}, + {L"getDecoderName", 1, (void*)SystemObject::vcpu_getDecoderName}, + {L"playFile", 1, (void*)SystemObject::vcpu_playFile}, + {L"enqueueFile", 1, (void*)SystemObject::vcpu_enqueueFile}, + {L"clearPlaylist", 0, (void*)SystemObject::vcpu_clearPlaylist}, + {L"onStop", 0, (void*)SystemObject::vcpu_onStop}, + {L"onPlay", 0, (void*)SystemObject::vcpu_onPlay}, + {L"onPause", 0, (void*)SystemObject::vcpu_onPause}, + {L"onResume", 0, (void*)SystemObject::vcpu_onResume}, + {L"onTitleChange", 1, (void*)SystemObject::vcpu_onTitleChange}, + {L"onTitle2Change", 1, (void*)SystemObject::vcpu_onTitle2Change}, + {L"onUrlChange", 1, (void*)SystemObject::vcpu_onUrlChange}, + {L"onInfoChange", 1, (void*)SystemObject::vcpu_onInfoChange}, + {L"onStatusMsg", 1, (void*)SystemObject::vcpu_onStatusMsg}, + {L"getLeftVuMeter", 0, (void*)SystemObject::vcpu_getLeftVuMeter}, + {L"getRightVuMeter", 0, (void*)SystemObject::vcpu_getRightVuMeter}, + {L"getVisBand", 2, (void*)SystemObject::vcpu_getVisBand}, + {L"getVolume", 0, (void*)SystemObject::vcpu_getVolume}, + {L"setVolume", 1, (void*)SystemObject::vcpu_setVolume}, + {L"play", 0, (void*)SystemObject::vcpu_play}, + {L"stop", 0, (void*)SystemObject::vcpu_stop}, + {L"pause", 0, (void*)SystemObject::vcpu_pause}, + {L"next", 0, (void*)SystemObject::vcpu_next}, + {L"previous", 0, (void*)SystemObject::vcpu_previous}, + {L"eject", 0, (void*)SystemObject::vcpu_eject}, + {L"seekTo", 1, (void*)SystemObject::vcpu_seekTo}, + {L"getPosition", 0, (void*)SystemObject::vcpu_getPosition}, + {L"setEqBand", 2, (void*)SystemObject::vcpu_setEqBand}, + {L"setEqPreAmp", 1, (void*)SystemObject::vcpu_setEqPreAmp}, + {L"setEq", 1, (void*)SystemObject::vcpu_setEq}, + {L"getEqBand", 1, (void*)SystemObject::vcpu_getEqBand}, + {L"getEqPreAmp", 0, (void*)SystemObject::vcpu_getEqPreAmp}, + {L"getEq", 0, (void*)SystemObject::vcpu_getEq}, + {L"onEqBandChanged", 2, (void*)SystemObject::vcpu_onEqBandChanged}, + {L"onEqFreqChanged", 1, (void*)SystemObject::vcpu_onEqFreqChanged}, + {L"onEqPreAmpChanged", 1, (void*)SystemObject::vcpu_onEqPreAmpChanged}, + {L"onEqChanged", 1, (void*)SystemObject::vcpu_onEqChanged}, + {L"onVolumeChanged", 1, (void*)SystemObject::vcpu_onVolumeChanged}, + {L"onSeek", 1, (void*)SystemObject::vcpu_onSeeked}, + {L"getStatus", 0, (void*)SystemObject::vcpu_getStatus}, + {L"getStatus", 0, (void*)SystemObject::vcpu_getStatus}, + {L"getSongInfoText", 0, (void*)SystemObject::vcpu_getSongInfoText}, + {L"getSongInfoTextTranslated", 0, (void*)SystemObject::vcpu_getSongInfoTextTranslated}, + {L"hasVideoSupport", 0, (void*)SystemObject::vcpu_hasVideoSupport}, + {L"isVideo", 0, (void*)SystemObject::vcpu_isVideo}, + {L"isVideoFullscreen", 0, (void*)SystemObject::vcpu_isVideoFullscreen}, + {L"setVideoFullscreen", 1, (void*)SystemObject::vcpu_setVideoFullscreen}, + {L"getIdealVideoWidth", 0, (void*)SystemObject::vcpu_getIdealVideoWidth}, + {L"getIdealVideoHeight", 0, (void*)SystemObject::vcpu_getIdealVideoHeight}, + {L"getPlaylistIndex", 0, (void*)SystemObject::vcpu_getPlaylistIndex}, + {L"onShowNotification", 0, (void*)SystemObject::vcpu_onShowNotification}, + {L"getPlaylistLength", 0, (void*)SystemObject::vcpu_getPlaylistLength}, + {L"getCurrentTrackRating", 0, (void *)SystemObject::vcpu_getRating}, + {L"setCurrentTrackRating", 1, (void *)SystemObject::vcpu_setRating}, +#endif +#if defined(WASABI_COMPILE_COMPONENTS) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + { + L"getWac", 1, (void*)SystemObject::vcpu_getWac + }, +#endif +#if defined(WA3COMPATIBILITY) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + { + L"ddesend", 3, (void*)SystemObject::vcpu_ddeSend + }, + {L"setMenuTransparency", 1, (void*)SystemObject::vcpu_setMenuTransparency}, + {L"popMainBrowser", 0, (void*)SystemObject::vcpu_popMb}, + {L"getMainBrowser", 0, (void*)SystemObject::vcpu_getMainMB}, + {L"windowMenu", 0, (void*)SystemObject::vcpu_windowMenu}, + {L"systemMenu", 0, (void*)SystemObject::vcpu_systemMenu}, +#endif +#if defined (WA3COMPATIBILITY) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + { + L"selectFile", 3, (void*)SystemObject::vcpu_selectFile + }, +#endif + {L"selectFolder", 3, (void*)SystemObject::vcpu_selectFolder}, + {L"onOpenURL", 1, (void*)SystemObject::vcpu_onOpenURL}, + {L"getMonitorLeft", 0, (void*)SystemObject::vcpu_getMonitorLeftGO}, + {L"getMonitorTop", 0, (void*)SystemObject::vcpu_getMonitorTopGO}, + {L"getMonitorLeftFromPoint", 2, (void*)SystemObject::vcpu_getMonitorLeftFP}, + {L"getMonitorTopFromPoint", 2, (void*)SystemObject::vcpu_getMonitorTopFP}, + {L"getMonitorLeftFromGuiObject", 1, (void*)SystemObject::vcpu_getMonitorLeftGO}, + {L"getMonitorTopFromGuiObject", 1, (void*)SystemObject::vcpu_getMonitorTopGO}, + {L"getMonitorWidth", 0, (void*)SystemObject::vcpu_getMonitorWidth}, + {L"getMonitorHeight", 0, (void*)SystemObject::vcpu_getMonitorHeight}, + {L"getMonitorWidthFromPoint", 2, (void*)SystemObject::vcpu_getMonitorWidthFP}, + {L"getMonitorHeightFromPoint",2, (void*)SystemObject::vcpu_getMonitorHeightFP}, + {L"getMonitorWidthFromGuiObject", 1, (void*)SystemObject::vcpu_getMonitorWidthGO}, + {L"getMonitorHeightFromGuiObject", 1, (void*)SystemObject::vcpu_getMonitorHeightGO}, + {L"downloadURL", 3, (void*)SystemObject::vcpu_downloadURL}, + {L"downloadMedia", 4, (void*)SystemObject::vcpu_downloadMedia}, + {L"onDownloadFinished", 3, (void*)SystemObject::vcpu_onDownloadFinished}, + {L"getDownloadPath", 0, (void*)SystemObject::vcpu_getDownloadPath}, + {L"setDownloadPath", 1, (void*)SystemObject::vcpu_setDownloadPath}, + {L"getAlbumArt", 1, (void*)SystemObject::vcpu_getAlbumArt}, + {L"isProVersion", 0, (void*)SystemObject::vcpu_isWinampPro}, // ugh, i hate putting this here but ohh well + {L"enumEmbedGUID", 1, (void*)SystemObject::vcpu_enumEmbedGUID}, // ugh, i hate putting this here but ohh well + {L"getWinampVersion",0, (void*)SystemObject::vcpu_getWinampVersion}, + {L"getBuildNumber",0, (void*)SystemObject::vcpu_getBuildNumber}, + {L"getFileSize",1, (void*)SystemObject::vcpu_getFileSize}, + {L"getString", 2, (void*)SystemObject::vcpu_getString}, + {L"translate", 1, (void*)SystemObject::vcpu_translate}, + {L"getLanguageId", 0, (void*)SystemObject::vcpu_getLanguageId} +}; +// -------------------------------------------------------- + + +const wchar_t *SystemScriptObjectController::getClassName() +{ + return L"SystemObject"; +} + +const wchar_t *SystemScriptObjectController::getAncestorClassName() +{ + return L"Object"; +} + +ScriptObject *SystemScriptObjectController::instantiate() +{ + return NULL; +} + +void SystemScriptObjectController::destroy(ScriptObject *o) +{ + ASSERTALWAYS("don't delete systemobject!"); +} + +void *SystemScriptObjectController::encapsulate(ScriptObject *o) +{ + return NULL; +} + +void SystemScriptObjectController::deencapsulate(void *o) +{ +} + +int SystemScriptObjectController::getNumFunctions() +{ + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *SystemScriptObjectController::getExportedFunctions() +{ + return exportedFunction; +} + +GUID SystemScriptObjectController::getClassGuid() +{ + return systemObjectGuid; +} + +int SystemScriptObjectController::getReferenceable() +{ + return 0; +} + +int SystemScriptObjectController::getInstantiable() +{ + return 0; +} + +#ifndef _NOSTUDIO + +SystemObject::SystemObject() +{ + getScriptObject()->vcpu_setInterface( systemObjectGuid, ( void * )static_cast( this ) ); + getScriptObject()->vcpu_setClassName( L"System" ); + getScriptObject()->vcpu_setController( systemController ); + + loaded = 0; + started_up = 0; + scriptVCPUId = -1; + isoldformat = 0; + parentGroup = NULL; + +#ifdef WASABI_COMPILE_SKIN + skinpartid = WASABI_API_PALETTE->getSkinPartIterator(); +#else + skinpartid = -1; +#endif + + SOM::registerSystemObject( this ); + +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_addCallback( 0, this ); +#endif + + WASABI_API_SYSCB->syscb_registerCallback( this ); +} + +SystemObject::~SystemObject() +{ + SOM::unregisterSystemObject( this ); +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_delCallback( 0, this ); +#endif + WASABI_API_SYSCB->syscb_deregisterCallback( this ); +} + +void SystemObject::setScriptId( int id ) +{ + scriptVCPUId = id; +} + +int SystemObject::getScriptId() +{ + return scriptVCPUId; +} + +void SystemObject::setParam( const wchar_t *p ) +{ +#ifdef WASABI_COMPILE_WNDMGR + StringW *s = PublicVarManager::translate_nocontext( p ); + if ( s ) + param.swap( s ); + else + param = p; + delete s; +#else + param = p; +#endif +} + +void SystemObject::setParentGroup( Group *g ) +{ + parentGroup = g; +} + +Group *SystemObject::getParentGroup() +{ + return parentGroup; +} + +const wchar_t *SystemObject::getParam() +{ + return param; +} + +void SystemObject::onLoad() +{ + loaded = 1; + vcpu_onScriptLoaded( SCRIPT_CALL, getScriptObject() ); + started_up = 1; +} + +void SystemObject::onUnload() +{ + if ( loaded && started_up ) + vcpu_onScriptUnloading( SCRIPT_CALL, getScriptObject() ); + + // that was the script's last chance to delete its stuff, now we need to garbageCollect whatever is left + garbageCollect(); +} + +#ifdef WASABI_COMPILE_WNDMGR +WindowHolder *SystemObject::getSuitableWindowHolderByGuid( GUID g ) +{ + wchar_t guidstr[ 256 ] = { 0 }; + nsGUID::toCharW( g, guidstr ); + scriptVar v = vcpu_onLookForComponent( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( guidstr ) ); + + if ( v.type == SCRIPT_OBJECT ) + { + ScriptObject *ret = GET_SCRIPT_OBJECT( v ); + if ( ret ) + { + WindowHolder *co = static_cast( ret->vcpu_getInterface( windowHolderGuid ) ); + return co; + } + } + return NULL; +} + +int SystemObject::onGetCancelComponent( GUID g, int i ) +{ + wchar_t guidstr[ 256 ] = { 0 }; + nsGUID::toCharW( g, guidstr ); + scriptVar v = vcpu_onGetCancelComponent( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( guidstr ), MAKE_SCRIPT_BOOLEAN( i ) ); + + if ( v.type != SCRIPT_VOID ) + return GET_SCRIPT_INT( v ); + + return 0; +} + +void SystemObject::onViewPortChanged( int width, int height ) +{ + for ( int i = SOM::getNumSystemObjects() - 1; i >= 0; i-- ) + vcpu_onViewPortChanged( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_INT( width ), MAKE_SCRIPT_INT( height ) ); +} + +int SystemObject::onShowNotification() +{ + WASABI_API_MAKI->vcpu_resetComplete(); +#if defined(WASABI_COMPILE_MEDIACORE) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + for ( int i = SOM::getNumSystemObjects() - 1; i >= 0 && !WASABI_API_MAKI->vcpu_getComplete(); i-- ) + { + scriptVar v = vcpu_onShowNotification( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject() ); + if ( v.type != SCRIPT_VOID ) + return GET_SCRIPT_INT( v ); + } +#endif + return 0; +} + +void SystemObject::onCreateLayout( Layout *l ) +{ + for ( int i = SOM::getNumSystemObjects() - 1; i >= 0; i-- ) + vcpu_onCreateLayout( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_OBJECT( l->getGuiObject()->guiobject_getScriptObject() ) ); +} + +void SystemObject::onShowLayout( Layout *l ) +{ + for ( int i = SOM::getNumSystemObjects() - 1; i >= 0; i-- ) + vcpu_onShowLayout( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_OBJECT( l->getGuiObject()->guiobject_getScriptObject() ) ); +} + +void SystemObject::onHideLayout( Layout *l ) +{ + for ( int i = SOM::getNumSystemObjects() - 1; i >= 0; i-- ) + vcpu_onHideLayout( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_OBJECT( l->getGuiObject()->guiobject_getScriptObject() ) ); +} + +int SystemObject::getCurAppRect( RECT *r ) +{ + ASSERT( r ); +#ifdef WIN32 + HWND w = GetForegroundWindow(); + if ( !IsWindowVisible( w ) ) return 0; + GetWindowRect( w, r ); +#else + DebugString( "portme SystemObject::getCurAppRect\n" ); +#endif + return 1; +} + +void SystemObject::onQuit() +{ + for ( int i = SOM::getNumSystemObjects() - 1; i >= 0; i-- ) + vcpu_onQuit( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject() ); +} + +#endif // wndmgr + +static bool FilterBrowserUrl( const wchar_t *url ) +{ + const wchar_t filterNowPlaying[] = L"http://client.winamp.com/nowplaying"; + size_t urlLength, filterLength; + + if ( NULL == url ) + return false; + + urlLength = wcslen( url ); + filterLength = sizeof( filterNowPlaying ) / sizeof( filterNowPlaying[ 0 ] ) - 1; + if ( urlLength >= filterLength && + 0 == _wcsnicmp( url, filterNowPlaying, filterLength ) ) + { + return true; + } + + return false; +} + +void SystemObject::browsercb_onOpenURL( wchar_t *url, bool *override ) +{ + if ( !*override && false == FilterBrowserUrl( url ) ) // ignore if someone else already overrode + { + scriptVar v = vcpu_onOpenURL( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( url ) ); + if ( v.type == SCRIPT_INT ) + { + if ( v.data.idata == 1 ) + *override = true; + } + } +} + +scriptVar SystemObject::vcpu_onOpenURL( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar url ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, url ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, url ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +void SystemObject::onKeyDown( const wchar_t *s ) +{ + WASABI_API_MAKI->vcpu_resetComplete(); + for ( int i = SOM::getNumSystemObjects() - 1; i >= 0 && !WASABI_API_MAKI->vcpu_getComplete(); i-- ) + vcpu_onKeyDown( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_STRING( s ) ); +} + +void SystemObject::onKeyUp( const wchar_t *s ) +{ + WASABI_API_MAKI->vcpu_resetComplete(); + for ( int i = SOM::getNumSystemObjects() - 1; i >= 0 && !WASABI_API_MAKI->vcpu_getComplete(); i-- ) + vcpu_onKeyUp( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_STRING( s ) ); +} + +int SystemObject::onAccelerator( const wchar_t *action, const wchar_t *section, const wchar_t *key ) +{ + int r = 0; + WASABI_API_MAKI->vcpu_resetComplete(); + for ( int i = SOM::getNumSystemObjects() - 1; i >= 0 && !WASABI_API_MAKI->vcpu_getComplete(); i-- ) + { + scriptVar v = vcpu_onAccelerator( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_STRING( action ), MAKE_SCRIPT_STRING( section ), MAKE_SCRIPT_STRING( key ) ); + if ( SOM::isNumeric( &v ) ) + r |= GET_SCRIPT_INT( v ); + } + return r; +} + +void SystemObject::onDownloadFinished( const wchar_t *url, boolean success, const wchar_t *filename ) +{ + for ( int i = SOM::getNumSystemObjects() - 1; i >= 0; i-- ) + vcpu_onDownloadFinished( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_STRING( url ), MAKE_SCRIPT_BOOLEAN( success ), MAKE_SCRIPT_STRING( filename ) ); +} + +TList < int > *SystemObject::getTypesList() +{ + return &typeslist; +} + +void SystemObject::setIsOldFormat( int is ) +{ + isoldformat = is; +} + +int SystemObject::isOldFormat() +{ + return isoldformat; +} +#endif + +#ifdef WASABI_COMPILE_WND +int SystemObject::isAppActive() +{ +#ifdef WIN32 + HWND w = GetForegroundWindow(); + wchar_t classname[ 256 ] = L""; + GetClassNameW( w, classname, 256 ); + return ( w == WASABI_API_WND->main_getRootWnd()->gethWnd() || !wcscmp( classname, BASEWNDCLASSNAME ) ); +#else + DebugString( "portme SystemObject::isAppActive\n" ); + return 1; +#endif +} +#endif + +void SystemObject::setSkinPartId( int _skinpartid ) +{ + skinpartid = _skinpartid; +} + +int SystemObject::getSkinPartId() +{ + return skinpartid; +} + +void SystemObject::addInstantiatedObject( ScriptObject *obj ) +{ + ASSERT( !instantiated.haveItem( obj ) ); + instantiated.addItem( obj ); +} + +void SystemObject::removeInstantiatedObject( ScriptObject *obj ) +{ + int n = instantiated.searchItem( obj ); + if ( n < 0 ) return; //ASSERT(n >= 0); + instantiated.removeByPos( n ); +} + +void SystemObject::garbageCollect() +{ + foreach( instantiated ) + ObjectTable::destroy( instantiated.getfor() ); + endfor + instantiated.removeAll(); +} + +int SystemObject::isObjectValid( ScriptObject *o ) +{ + static ScriptObject *cached = NULL; + static int cachedn = -1; + if ( o == cached && scriptobjects.enumItem( cachedn ) == o ) return 1; + int is = scriptobjects.searchItem( o ); + if ( is >= 0 ) + { + cached = o; + cachedn = is; + } + return ( is > -1 ); +} + +void SystemObject::addScriptObject( ScriptObject *o ) +{ + ASSERT( !scriptobjects.haveItem( o ) ); + scriptobjects.addItem( o ); +} + +void SystemObject::removeScriptObject( ScriptObject *o ) +{ + int pos = scriptobjects.searchItem( o ); + if ( pos < 0 ) return; + scriptobjects.removeByPos( pos ); +} + +#ifdef WASABI_COMPILE_SKIN +void SystemObject::onSetXuiParam( const wchar_t *param, const wchar_t *value ) +{ + vcpu_onSetXuiParam( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( param ), MAKE_SCRIPT_STRING( value ) ); +} +#endif + +void SystemObject::navigateUrl( const wchar_t *url ) +{ +#ifdef WA3COMPATIBILITY + if ( MainMiniBrowser::getScriptObject() ) + { + MainMiniBrowser::navigateUrl( url ); + MainMiniBrowser::popMb(); + } + else // no minibrowser container -> launch IE + { + Std::shellExec( url ); + } +#else + Wasabi::Std::shellExec( url ); +#endif +} + +void SystemObject::navigateUrlBrowser( const wchar_t *url ) +{ + wa2.openUrl( url ); +} + +scriptVar SystemObject::vcpu_getVersion( SCRIPT_FUNCTION_PARAMS, ScriptObject *o ) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0( o, systemController ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + return MAKE_SCRIPT_DOUBLE( MAKI_RUNTIME_VERSION ); +} + +scriptVar SystemObject::vcpu_onScriptLoaded( SCRIPT_FUNCTION_PARAMS, ScriptObject *o ) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0( o, systemController ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SystemObject *so = static_cast( o->vcpu_getInterface( systemObjectGuid ) ); + ASSERT( so != NULL ); + return WASABI_API_MAKI->maki_triggerEvent( o, DLF_ID, 0, so->scriptVCPUId ); +} + +scriptVar SystemObject::vcpu_onScriptUnloading( SCRIPT_FUNCTION_PARAMS, ScriptObject *o ) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0( o, systemController ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SystemObject *so = static_cast( o->vcpu_getInterface( systemObjectGuid ) ); + ASSERT( so != NULL ); + return WASABI_API_MAKI->maki_triggerEvent( o, DLF_ID, 0, so->scriptVCPUId ); +} + +scriptVar SystemObject::vcpu_onQuit( SCRIPT_FUNCTION_PARAMS, ScriptObject *o ) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0( o, systemController ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT0( o ); +} + +#ifdef WASABI_COMPILE_SKIN +scriptVar SystemObject::vcpu_onSetXuiParam( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar param, scriptVar value ) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2( o, systemController, param, value ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT2( o, param, value ); +} + +scriptVar SystemObject::vcpu_getSkinName( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_STRING( WASABI_API_SKIN->getSkinName() ); +} + +scriptVar SystemObject::vcpu_switchSkin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar skinname ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef SWITCH_SKIN + SWITCH_SKIN( GET_SCRIPT_STRING( skinname ) ); +#else + WASABI_API_SKIN->skin_switchSkin( GET_SCRIPT_STRING( skinname ) ); +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar SystemObject::vcpu_isLoadingSkin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + int l = 0; +#ifdef IS_SKIN_STILL_LOADING + IS_SKIN_STILL_LOADING( l ); +#endif + if ( !l ) return MAKE_SCRIPT_INT( Skin::isLoading() ); + return MAKE_SCRIPT_INT( l ); +} + +scriptVar SystemObject::vcpu_lockUI( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + WASABI_API_SKIN->skin_setLockUI( 1 ); + RETURN_SCRIPT_NULL; +} + +scriptVar SystemObject::vcpu_unlockUI( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + WASABI_API_SKIN->skin_setLockUI( 0 ); + RETURN_SCRIPT_NULL; +} + +#endif + +scriptVar SystemObject::vcpu_isObjectValid( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar o ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_BOOLEAN( SystemObject::isObjectValid( GET_SCRIPT_OBJECT( o ) ) ); +} + +scriptVar SystemObject::vcpu_getTimeOfDay( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + time_t ts = Wasabi::Std::getTimeStamp(); + struct tm *tm_now; + tm_now = localtime( (const time_t *)&ts ); + uint32_t tcnow = Wasabi::Std::getTickCount(); + static uint32_t lasttc = 0; + + int v = tm_now->tm_hour * 3600000 + tm_now->tm_min * 60000 + tm_now->tm_sec * 1000; + + // yay milliseconds! + + static int lastv = 0; + static int total = 0; + int tv = v; + if ( v == lastv ) + { + total += tcnow - lasttc; + v += total; + } + else total = 0; + lasttc = tcnow; + lastv = tv; + + return MAKE_SCRIPT_INT( v ); +} + +scriptVar SystemObject::vcpu_navigateUrl( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url ) +{ + SCRIPT_FUNCTION_INIT; + SystemObject::navigateUrl( GET_SCRIPT_STRING( url ) ); + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_navigateUrlBrowser( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url ) +{ + SCRIPT_FUNCTION_INIT; + SystemObject::navigateUrlBrowser( GET_SCRIPT_STRING( url ) ); + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_isKeyDown( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar vk_code ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT( Std::keyDown( GET_SCRIPT_INT( vk_code ) ) ); +} + +scriptVar SystemObject::vcpu_setClipboard( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar text ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef _WIN32 + const wchar_t *source = GET_SCRIPT_STRING( text ); + DebugStringW( L"%s\n", source ); + OpenClipboard( 0 ); + EmptyClipboard(); + int len = ( wcslen( source ) + 1 ); + HGLOBAL clipbuffer = GlobalAlloc( GMEM_DDESHARE, sizeof( wchar_t ) * len ); + wchar_t *buffer = (wchar_t *)GlobalLock( clipbuffer ); + wcsncpy( buffer, source, len - 1 ); + GlobalUnlock( clipbuffer ); + SetClipboardData( CF_UNICODETEXT, clipbuffer ); + CloseClipboard(); +#else + DebugString( "portme SystemObject::vcpu_setClipboard\n" ); +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_chr( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar n ) +{ + SCRIPT_FUNCTION_INIT; + WCSCPYN( staticStr, StringPrintfW( L"%c", GET_SCRIPT_INT( n ) ), 4096 ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_onAccelerator( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar action, scriptVar section, scriptVar key ) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS3( o, systemController, action, section, key ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT3( o, action, section, key ); +} + +scriptVar SystemObject::vcpu_triggerAction( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar guiobj, scriptVar actionstr, scriptVar paramstr ) +{ + SCRIPT_FUNCTION_INIT; + ASSERT( actionstr.type == SCRIPT_STRING ); + ASSERT( paramstr.type == SCRIPT_STRING ); + const wchar_t *astr = GET_SCRIPT_STRING( actionstr ); + const wchar_t *pstr = GET_SCRIPT_STRING( paramstr ); +#ifdef WASABI_COMPILE_WNDMGR + ScriptObject *context = guiobj.data.odata; + if ( context != NULL ) + { + GuiObject *go = static_cast( context->vcpu_getInterface( guiObjectGuid ) ); + if ( go != NULL ) + { + ifc_window *wc = go->guiobject_getRootWnd(); + if ( wc != NULL ) + { + ifc_window *lr = wc->getDesktopParent(); + if ( lr != NULL ) + { + Layout *lay = static_cast( lr->getInterface( layoutGuid ) ); + if ( lay != NULL ) + { + int ia = WASABI_API_SKIN->parse( astr, L"internal_action" ); + if ( ia == ACTION_NONE ) + { + ActionEnum ae( astr ); + svc_action *act = ae.getFirst(); + if ( act ) + { + act->onAction( astr, pstr, 0, 0, NULL, 0, wc ); + SvcEnum::release( act ); + } + } + else + lay->runAction( ia, pstr ); + } + } + } + } + } + else + { + ActionEnum ae( astr ); + svc_action *act = ae.getFirst(); + if ( act ) + { + act->onAction( astr, pstr ); + SvcEnum::release( act ); + } + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_getParam( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + SystemObject *o = static_cast( object->vcpu_getInterface( systemObjectGuid ) ); + if ( o ) return MAKE_SCRIPT_STRING( o->getParam() ); + return MAKE_SCRIPT_STRING( L"" ); +} + +#ifdef WASABI_COMPILE_SKIN +scriptVar SystemObject::vcpu_getScriptGroup( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + SystemObject *o = static_cast( object->vcpu_getInterface( systemObjectGuid ) ); + if ( o ) + { + Group *g = o->getParentGroup(); + return MAKE_SCRIPT_OBJECT( g ? g->getScriptObject() : NULL ); + } + return MAKE_SCRIPT_OBJECT( NULL ); +} + +scriptVar SystemObject::vcpu_newGroup( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar groupname ) +{ + SCRIPT_FUNCTION_INIT; + GuiObject *g = SkinParser::newDynamicGroup( GET_SCRIPT_STRING( groupname ), GROUP_GROUP ); + if ( g != NULL ) + { + SystemObject *so = static_cast( object->vcpu_getInterface( systemObjectGuid ) ); + so->addInstantiatedObject( g->guiobject_getScriptObject() ); + } + return MAKE_SCRIPT_OBJECT( g ? g->guiobject_getScriptObject() : NULL ); +} +#endif + +scriptVar SystemObject::vcpu_getMousePosX( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt; + Wasabi::Std::getMousePos( &pt ); + return MAKE_SCRIPT_INT( pt.x ); +} + +scriptVar SystemObject::vcpu_getMousePosY( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt; + Wasabi::Std::getMousePos( &pt ); + return MAKE_SCRIPT_INT( pt.y ); +} + +scriptVar SystemObject::vcpu_minimizeApplication( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef _WIN32 + ShowWindow( WASABI_API_WND->main_getRootWnd()->gethWnd(), SW_MINIMIZE ); +#else + #warning port me +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_activateApplication( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef _WIN32 + SetForegroundWindow( WASABI_API_WND->main_getRootWnd()->gethWnd() ); +#else + #warning port me +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_restoreApplication( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef _WIN32 + ShowWindow( WASABI_API_WND->main_getRootWnd()->gethWnd(), SW_RESTORE ); +#else + #warning port me +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_isDesktopAlphaAvailable( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_CONFIG + extern _bool cfg_uioptions_desktopalpha; + return MAKE_SCRIPT_INT( Wasabi::Std::Wnd::isDesktopAlphaAvailable() && cfg_uioptions_desktopalpha.getValueAsInt() ); +#else + return MAKE_SCRIPT_INT( Wasabi::Std::Wnd::isDesktopAlphaAvailable() ); +#endif +} + +scriptVar SystemObject::vcpu_isTransparencyAvailable( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT( Wasabi::Std::Wnd::isTransparencyAvailable() ); +} + +scriptVar SystemObject::vcpu_isMinimized( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef _WIN32 + return MAKE_SCRIPT_INT( IsIconic( WASABI_API_WND->main_getRootWnd()->gethWnd() ) ); +#else + #warning port me + RETURN_SCRIPT_ZERO; +#endif +} + +// extern String System.translate(String str); +scriptVar SystemObject::vcpu_translate( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str ) +{ + SCRIPT_FUNCTION_INIT; + WCSCPYN( translateStr, _( GET_SCRIPT_STRING( str ) ), ( sizeof( translateStr ) / sizeof( *translateStr ) ) ); + return MAKE_SCRIPT_STRING( translateStr ); +} + +// extern String System.getString(String table, Int id); +scriptVar SystemObject::vcpu_getString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar table, scriptVar id ) +{ + SCRIPT_FUNCTION_INIT; + const wchar_t *xlat = LocalesManager::GetString( GET_SCRIPT_STRING( table ), GET_SCRIPT_INT( id ) ); + if ( xlat ) + return MAKE_SCRIPT_STRING( xlat ); + else + return MAKE_SCRIPT_STRING( L"" ); +} + +// extern String System.getString(String table, Int id); +scriptVar SystemObject::vcpu_getLanguageId( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + const wchar_t *langId = WASABI_API_LNG->GetLanguageIdentifier( LANG_IDENT_STR ); + if ( langId ) + return MAKE_SCRIPT_STRING( langId ); + else + return MAKE_SCRIPT_STRING( L"" ); +} + +scriptVar SystemObject::vcpu_integerToString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar i ) +{ + SCRIPT_FUNCTION_INIT; + WCSNPRINTF( staticStr, 4096, L"%d", GET_SCRIPT_INT( i ) ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_stringToInteger( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar s ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT( WTOI( GET_SCRIPT_STRING( s ) ) ); +} + +scriptVar SystemObject::vcpu_floatToString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar f, scriptVar digits ) +{ + SCRIPT_FUNCTION_INIT; + // to whoever made this use StringPrintf, you left out the digits param, GRRRRRR!! + double v = GET_SCRIPT_DOUBLE( f ); + StringPrintfW tmp( v ); + WCSCPYN( staticStr, tmp, ( sizeof( staticStr ) / sizeof( *staticStr ) ) ); + wchar_t *p = wcschr( staticStr, '.' ); + if ( p ) + { + int numdigits = GET_SCRIPT_INT( digits ); + if ( numdigits > 0 ) + { + int n = numdigits; + int curnumdigits = staticStr + wcslen( staticStr ) - ( p + 1 ); + n -= curnumdigits; + if ( n > 0 ) + { + for ( int i = 0; i < n && i < ( sizeof( staticStr ) / sizeof( *staticStr ) ) - 128; i++ ) + wcscat( staticStr, L"0" ); + } + else if ( n < 0 ) + { + *( p + 1 + numdigits ) = 0; + } + } + else + { + *p = 0; + } + } + else + { + int n = GET_SCRIPT_INT( digits ); + if ( n > 0 ) + { + wcscat( staticStr, L"." ); + for ( int i = 0; i < n && i < ( sizeof( staticStr ) / sizeof( *staticStr ) ) - 128; i++ ) + wcscat( staticStr, L"0" ); + } + } + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_stringToFloat( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar s ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_FLOAT( (float)WTOF( GET_SCRIPT_STRING( s ) ) ); +} + +scriptVar SystemObject::vcpu_integerToTime( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + int i = GET_SCRIPT_INT( _i ); + WCSNPRINTF( staticStr, 4096, L"%d:%02d", i / 60000, i % 60000 / 1000 ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_integerToLongTime( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + int i = GET_SCRIPT_INT( _i ); + WCSNPRINTF( staticStr, 4096, L"%d:%02d:%02d", i / 3600000, ( i % 3600000 ) / 60000, i % 60000 / 1000 ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_dateToTime( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + WCSNPRINTF( staticStr, 4096, L"%d:%02d", t->tm_hour, t->tm_min ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_dateToLongTime( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + WCSNPRINTF( staticStr, 4096, L"%d:%02d:%02d", t->tm_hour, t->tm_min, t->tm_sec ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_formatDate( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + wcsftime( staticStr, 4096, L"%c", t ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_formatLongDate( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + wcsftime( staticStr, 4096, L"%#c", t ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_getDateYear( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + return MAKE_SCRIPT_INT( t->tm_year ); +} + +scriptVar SystemObject::vcpu_getDateMonth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + return MAKE_SCRIPT_INT( t->tm_mon ); +} + +scriptVar SystemObject::vcpu_getDateDay( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + return MAKE_SCRIPT_INT( t->tm_mday ); +} + +scriptVar SystemObject::vcpu_getDateDow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + return MAKE_SCRIPT_INT( t->tm_wday ); +} + +scriptVar SystemObject::vcpu_getDateDoy( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + return MAKE_SCRIPT_INT( t->tm_yday ); +} + +scriptVar SystemObject::vcpu_getDateHour( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + return MAKE_SCRIPT_INT( t->tm_hour ); +} + +scriptVar SystemObject::vcpu_getDateMin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + return MAKE_SCRIPT_INT( t->tm_min ); +} + +scriptVar SystemObject::vcpu_getDateSec( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + return MAKE_SCRIPT_INT( t->tm_sec ); +} + +scriptVar SystemObject::vcpu_getDateDst( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + return MAKE_SCRIPT_INT( t->tm_isdst ); +} + +scriptVar SystemObject::vcpu_getDate( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + time_t t; + time( &t ); + return MAKE_SCRIPT_INT( (int)t ); +} + +scriptVar SystemObject::vcpu_strmid( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str, scriptVar start, scriptVar len ) +{ + SCRIPT_FUNCTION_INIT; + SOM::mid( staticStr, GET_SCRIPT_STRING( str ), MIN( GET_SCRIPT_INT( start ), 4096 ), MIN( GET_SCRIPT_INT( len ), 4096 ) ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_strleft( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str, scriptVar len ) +{ + SCRIPT_FUNCTION_INIT; + SOM::mid( staticStr, GET_SCRIPT_STRING( str ), 0, MIN( GET_SCRIPT_INT( len ), 4096 ) ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_strright( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str, scriptVar _len ) +{ + SCRIPT_FUNCTION_INIT; + const wchar_t *str = GET_SCRIPT_STRING( _str ); + int len = GET_SCRIPT_INT( _len ); + SOM::mid( staticStr, str, MIN( (int)( wcslen( str ) - len ), 4096 ), MIN( len, 4096 ) ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_strsearch( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str, scriptVar substr ) +{ + SCRIPT_FUNCTION_INIT; + const wchar_t *str = GET_SCRIPT_STRING( _str ); + const wchar_t *p = wcsstr( str, GET_SCRIPT_STRING( substr ) ); + return MAKE_SCRIPT_INT( p ? p - str : -1 ); +} + +scriptVar SystemObject::vcpu_strlen( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT( wcslen( GET_SCRIPT_STRING( str ) ) ); +} + +scriptVar SystemObject::vcpu_strupper( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str ) +{ + SCRIPT_FUNCTION_INIT; + WCSCPYN( staticStr, GET_SCRIPT_STRING( _str ), ( sizeof( staticStr ) / sizeof( *staticStr ) ) ); + WCSTOUPPER( staticStr ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_strlower( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str ) +{ + SCRIPT_FUNCTION_INIT; + WCSCPYN( staticStr, GET_SCRIPT_STRING( _str ), ( sizeof( staticStr ) / sizeof( *staticStr ) ) ); + WCSTOLOWER( staticStr ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_urlencode( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str ) +{ + SCRIPT_FUNCTION_INIT; + StringW str( GET_SCRIPT_STRING( _str ) ); + str = AutoWide( AutoUrl( str ) ); + *staticStr = 0; + if ( !str.isempty() ) WCSCPYN( staticStr, str, ( sizeof( staticStr ) / sizeof( *staticStr ) ) ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_urldecode( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str ) +{ + SCRIPT_FUNCTION_INIT; + StringW str( GET_SCRIPT_STRING( _str ) ); + Url::decode( str ); // Martin> I know there might be something nicer than this, but this does at least work + *staticStr = 0; + if ( !str.isempty() ) WCSCPYN( staticStr, str, ( sizeof( staticStr ) / sizeof( *staticStr ) ) ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_removepath( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str ) +{ + SCRIPT_FUNCTION_INIT; + PathParserW pp( GET_SCRIPT_STRING( _str ) ); +// ASSERT(pp.getNumStrings() >= 1); // shouldn't happen ever + wchar_t *lastString = pp.getLastString(); + if ( lastString ) + { + WCSCPYN( staticStr, lastString, ( sizeof( staticStr ) / sizeof( *staticStr ) ) ); + } + else + { + staticStr[ 0 ] = 0; + } + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_getpath( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str ) +{ + SCRIPT_FUNCTION_INIT; + WCSCPYN( staticStr, GET_SCRIPT_STRING( _str ), ( sizeof( staticStr ) / sizeof( *staticStr ) ) ); +#ifdef _WIN32 + PathRemoveFileSpecW( staticStr ); + PathRemoveBackslashW( staticStr ); +#else + #warning port me +#endif + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_getextension( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str ) +{ + SCRIPT_FUNCTION_INIT; + const wchar_t *pt = Wasabi::Std::extension( GET_SCRIPT_STRING( _str ) ); + if ( pt != NULL ) WCSCPYN( staticStr, pt, ( sizeof( staticStr ) / sizeof( *staticStr ) ) ); + else *staticStr = '\0'; + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_gettoken( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar tok, scriptVar sep, scriptVar num ) +{ + SCRIPT_FUNCTION_INIT; + wchar_t *p = const_cast( GET_SCRIPT_STRING( tok ) ); + wchar_t *d = const_cast( GET_SCRIPT_STRING( sep ) ); + int i = GET_SCRIPT_INT( num ); + if ( !d ) return MAKE_SCRIPT_STRING( L"" ); + if ( !p ) return MAKE_SCRIPT_STRING( L"" ); + wchar_t c = *d; + d = staticStr; + int n = 0, ct = 0; + while ( p && *p && ct < 4096 ) + { + if ( *p == c ) + { + n++; p++; continue; + } + if ( n > i ) break; + if ( n == i ) + *d++ = *p; + p++; + ct++; + } + *d = 0; + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_sin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::sin( GET_SCRIPT_DOUBLE( d ) ) ); +} + +scriptVar SystemObject::vcpu_cos( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::cos( GET_SCRIPT_DOUBLE( d ) ) ); +} + +scriptVar SystemObject::vcpu_tan( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::tan( GET_SCRIPT_DOUBLE( d ) ) ); +} + +scriptVar SystemObject::vcpu_asin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::asin( GET_SCRIPT_DOUBLE( d ) ) ); +} + +scriptVar SystemObject::vcpu_acos( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::acos( GET_SCRIPT_DOUBLE( d ) ) ); +} + +scriptVar SystemObject::vcpu_atan( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::atan( GET_SCRIPT_DOUBLE( d ) ) ); +} + +scriptVar SystemObject::vcpu_atan2( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar y, scriptVar x ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::atan2( GET_SCRIPT_DOUBLE( y ), GET_SCRIPT_DOUBLE( x ) ) ); +} + +scriptVar SystemObject::vcpu_pow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::pow( GET_SCRIPT_DOUBLE( x ), GET_SCRIPT_DOUBLE( y ) ) ); +} + +scriptVar SystemObject::vcpu_sqr( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _d ) +{ + SCRIPT_FUNCTION_INIT; + double d = GET_SCRIPT_DOUBLE( _d ); + return MAKE_SCRIPT_DOUBLE( d * d ); +} + +scriptVar SystemObject::vcpu_sqrt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::sqrt( GET_SCRIPT_DOUBLE( d ) ) ); +} + +scriptVar SystemObject::vcpu_log10( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::log10( GET_SCRIPT_DOUBLE( d ) ) ); +} + +scriptVar SystemObject::vcpu_log( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::log( GET_SCRIPT_DOUBLE( d ) ) ); +} + + +scriptVar SystemObject::vcpu_random( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar m ) +{ + SCRIPT_FUNCTION_INIT; + int m_ = GET_SCRIPT_INT( m ); + return MAKE_SCRIPT_INT( m_ <= 0 ? 0 : ::rand() % m_ ); +} + +scriptVar SystemObject::vcpu_integer( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v ) +{ + SCRIPT_FUNCTION_INIT; + // precision will get lost automatically + int _v = GET_SCRIPT_INT( v ); + return MAKE_SCRIPT_INT( _v ); +} + +scriptVar SystemObject::vcpu_frac( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v ) +{ + SCRIPT_FUNCTION_INIT; + double _v = GET_SCRIPT_DOUBLE( v ) - GET_SCRIPT_INT( v ); + return MAKE_SCRIPT_DOUBLE( _v ); +} + +scriptVar SystemObject::vcpu_onViewPortChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar width, scriptVar height ) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2( o, systemController, width, height ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT2( o, width, height ); +} + +scriptVar SystemObject::vcpu_getViewportWidth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { 0 }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.right - r.left ); +} + +scriptVar SystemObject::vcpu_getViewportHeight( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { 0 }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.bottom - r.top ); +} + +scriptVar SystemObject::vcpu_getViewportWidthGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj ) +{ + SCRIPT_FUNCTION_INIT; + RECT r = { 0 }; + GuiObject *o = static_cast( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) ); + if ( o ) + { + Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle() ); + return MAKE_SCRIPT_INT( r.right - r.left ); + } + else + { + POINT pt = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.right - r.left ); + } + return MAKE_SCRIPT_INT( 0 ); +} + +scriptVar SystemObject::vcpu_getViewportHeightGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj ) +{ + SCRIPT_FUNCTION_INIT; + RECT r = { 0 }; + GuiObject *o = static_cast( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) ); + if ( o ) + { + Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle() ); + + // benski> this prevents the window from going "fullscreen" but adds a one-line space at the bottom + RECT full = { 0 }; + Wasabi::Std::getViewport( &full, o->guiobject_getRootWnd()->getOsWindowHandle(), true ); + if (Wasabi::Std::rectEqual( &full, &r ) ) + r.bottom--; + + return MAKE_SCRIPT_INT( r.bottom - r.top ); + } + else + { + POINT pt = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.bottom - r.top ); + } + return MAKE_SCRIPT_INT( 0 ); +} + +scriptVar SystemObject::vcpu_getMonitorLeft( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { 0 }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.left ); +} + +scriptVar SystemObject::vcpu_getMonitorLeftFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.left ); +} + +scriptVar SystemObject::vcpu_getMonitorLeftGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj ) +{ + SCRIPT_FUNCTION_INIT; + RECT r = { 0 }; + GuiObject *o = static_cast( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) ); + if ( o ) + { + Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle(), 1 ); + return MAKE_SCRIPT_INT( r.left ); + } + else + { + POINT pt = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.left ); + } + return MAKE_SCRIPT_INT( 0 ); +} + +scriptVar SystemObject::vcpu_getMonitorTop( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { 0 }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.top ); +} + +scriptVar SystemObject::vcpu_getMonitorTopFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.top ); +} + +scriptVar SystemObject::vcpu_getMonitorTopGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj ) +{ + SCRIPT_FUNCTION_INIT; + RECT r = { 0 }; + GuiObject *o = static_cast( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) ); + if ( o ) + { + Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle(), 1 ); + return MAKE_SCRIPT_INT( r.top ); + } + else + { + POINT pt = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.top ); + } + return MAKE_SCRIPT_INT( 0 ); +} + +scriptVar SystemObject::vcpu_getMonitorWidth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { 0 }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.right - r.left ); +} + +scriptVar SystemObject::vcpu_getMonitorHeight( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { 0 }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.bottom - r.top ); +} + +scriptVar SystemObject::vcpu_getMonitorWidthGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj ) +{ + SCRIPT_FUNCTION_INIT; + RECT r = { 0 }; + GuiObject *o = static_cast( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) ); + if ( o ) + { + Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle(), 1 ); + return MAKE_SCRIPT_INT( r.right - r.left ); + } + else + { + POINT pt = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.right - r.left ); + } + return MAKE_SCRIPT_INT( 0 ); +} + +scriptVar SystemObject::vcpu_getMonitorHeightGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj ) +{ + SCRIPT_FUNCTION_INIT; + RECT r = { 0 }; + GuiObject *o = static_cast( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) ); + if ( o ) + { + Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle(), true ); + return MAKE_SCRIPT_INT( r.bottom - r.top ); + } + else + { + POINT pt = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.bottom - r.top ); + } + return MAKE_SCRIPT_INT( 0 ); +} + +scriptVar SystemObject::vcpu_getViewportLeft( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { 0 }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.left ); +} + +scriptVar SystemObject::vcpu_getViewportTop( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { 0 }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.top ); +} + +scriptVar SystemObject::vcpu_getViewportLeftGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj ) +{ + SCRIPT_FUNCTION_INIT; + RECT r = { 0 }; + GuiObject *o = static_cast( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) ); + if ( o ) + { + Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle() ); + return MAKE_SCRIPT_INT( r.left ); + } + else + { + POINT pt = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.left ); + } + return MAKE_SCRIPT_INT( 0 ); +} + +scriptVar SystemObject::vcpu_getViewportTopGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj ) +{ + SCRIPT_FUNCTION_INIT; + RECT r = { 0 }; + GuiObject *o = static_cast( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) ); + if ( o ) + { + Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle() ); + return MAKE_SCRIPT_INT( r.top ); + } + else + { + POINT pt = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.top ); + } + return MAKE_SCRIPT_INT( 0 ); +} + +scriptVar SystemObject::vcpu_getViewportWidthFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.right - r.left ); +} + +scriptVar SystemObject::vcpu_getMonitorHeightFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.bottom - r.top ); +} + +scriptVar SystemObject::vcpu_getMonitorWidthFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.right - r.left ); +} + +scriptVar SystemObject::vcpu_getViewportHeightFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.bottom - r.top ); +} + +scriptVar SystemObject::vcpu_getViewportLeftFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.left ); +} + +scriptVar SystemObject::vcpu_getViewportTopFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.top ); +} + +scriptVar SystemObject::vcpu_getTickCount( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT(Wasabi::Std::getTickCount() ); +} + +scriptVar SystemObject::vcpu_onKeyDown( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v ) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1( o, systemController, v ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, v ); +} + +scriptVar SystemObject::vcpu_onKeyUp( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v ) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1( o, systemController, v ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, v ); +} + +scriptVar SystemObject::vcpu_debugString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str, scriptVar severity ) +{ + SCRIPT_FUNCTION_INIT; + DebugStringW( L"%s", GET_SCRIPT_STRING( str ) ); + WASABI_API_SYSCB->syscb_issueCallback( SysCallback::CONSOLE, ConsoleCallback::DEBUGMESSAGE, GET_SCRIPT_INT( severity ), reinterpret_cast( GET_SCRIPT_STRING( str ) ) ); + return MAKE_SCRIPT_VOID(); +} + +scriptVar SystemObject::vcpu_messageBox( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar msg, scriptVar title, scriptVar flags, scriptVar nam ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + return MAKE_SCRIPT_INT( WASABI_API_WNDMGR->messageBox( GET_SCRIPT_STRING( msg ), GET_SCRIPT_STRING( title ), GET_SCRIPT_INT( flags ), GET_SCRIPT_STRING( nam ), NULL ) ); +#else + return MAKE_SCRIPT_INT( MessageBox( NULL, GET_SCRIPT_STRING( msg ), GET_SCRIPT_STRING( title ), GET_SCRIPT_INT( flags ) ) ); +#endif +} + +scriptVar SystemObject::vcpu_getAtom( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar atomname ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_OBJECT( VCPU::getAtom( GET_SCRIPT_STRING( atomname ) ) ); +} + +scriptVar SystemObject::vcpu_setAtom( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar atomname, scriptVar obj ) +{ + SCRIPT_FUNCTION_INIT; + VCPU::setAtom( GET_SCRIPT_STRING( atomname ), GET_SCRIPT_OBJECT( obj ) ); + RETURN_SCRIPT_VOID; +} + +#ifdef WASABI_COMPILE_MAKIDEBUG +scriptVar SystemObject::vcpu_invokeDebugger( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + WASABI_API_MAKIDEBUG->debugger_createJITD( object->vcpu_getScriptId(), 1 ); + RETURN_SCRIPT_VOID; +} +#endif + +#if defined (WASABI_COMPILE_WNDMGR) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + +scriptVar SystemObject::vcpu_onCreateLayout( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar l ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + PROCESS_HOOKS1( o, systemController, l ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, l ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onShowLayout( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar l ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + PROCESS_HOOKS1( o, systemController, l ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, l ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onHideLayout( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar l ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + PROCESS_HOOKS1( o, systemController, l ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, l ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_getContainer( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar contname ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + Container *c = SkinParser::script_getContainer( GET_SCRIPT_STRING( contname ) ); + return MAKE_SCRIPT_OBJECT( c ? c->getScriptObject() : NULL ); +#else + RETURN_SCRIPT_NULL; +#endif +} + +scriptVar SystemObject::vcpu_newDynamicContainer( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar contname ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + Container *c = SkinParser::newDynamicContainer( GET_SCRIPT_STRING( contname ) ); + return MAKE_SCRIPT_OBJECT( c ? c->getScriptObject() : NULL ); +#else + RETURN_SCRIPT_NULL; +#endif +} + +scriptVar SystemObject::vcpu_newGroupAsLayout( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar groupname ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + Group *g = GroupMgr::instantiate( GET_SCRIPT_STRING( groupname ), GROUP_LAYOUTGROUP ); + if ( g ) + { + Layout *l = static_cast( g ); + ifc_window *par = l->getCustomOwner(); + if ( !par ) par = WASABI_API_WND->main_getRootWnd(); + g->setAutoResizeAfterInit( 0 ); + g->setStartHidden( 1 ); + g->setParent( par ); + +#ifdef _WIN32 + g->init( hInstance, par->gethWnd(), TRUE ); +#else + #warning port me + g->init( 0, par->gethWnd(), TRUE ); +#endif + SystemObject *so = SOM::getSystemObjectByScriptId( __vsd ); + if ( so != NULL ) so->addInstantiatedObject( g->getScriptObject() ); + } + return MAKE_SCRIPT_OBJECT( g ? g->getScriptObject() : NULL ); +#else + RETURN_SCRIPT_NULL; +#endif +} + +scriptVar SystemObject::vcpu_getNumContainers( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + return MAKE_SCRIPT_INT( SkinParser::getNumContainers() ); +#else + RETURN_SCRIPT_NULL; +#endif +} + +scriptVar SystemObject::vcpu_enumContainer( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar n ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + Container *c = SkinParser::enumContainer( GET_SCRIPT_INT( n ) ); + return MAKE_SCRIPT_OBJECT( c ? c->getScriptObject() : NULL ); +#else + RETURN_SCRIPT_NULL; +#endif +} + +scriptVar SystemObject::vcpu_onLookForComponent( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar guid ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + PROCESS_HOOKS1( o, systemController, guid ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, guid ); +#else + RETURN_SCRIPT_VOID +#endif +} + +scriptVar SystemObject::vcpu_onGetCancelComponent( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar guid, scriptVar i ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + PROCESS_HOOKS2( o, systemController, guid, i ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT2( o, guid, i ); +#else + RETURN_SCRIPT_ZERO +#endif +} + +scriptVar SystemObject::vcpu_getCurAppLeft( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + RECT r = { 0 }; + int s = getCurAppRect( &r ); + return MAKE_SCRIPT_INT( s ? r.left : -1 ); +#else + RETURN_SCRIPT_ZERO +#endif +} + +scriptVar SystemObject::vcpu_getCurAppTop( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + RECT r = { 0 }; + int s = getCurAppRect( &r ); + return MAKE_SCRIPT_INT( s ? r.top : -1 ); +#else + RETURN_SCRIPT_ZERO +#endif +} + +scriptVar SystemObject::vcpu_getCurAppWidth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + RECT r = { 0 }; + int s = getCurAppRect( &r ); + return MAKE_SCRIPT_INT( s ? r.right - r.left : -1 ); +#else + RETURN_SCRIPT_ZERO +#endif +} + +scriptVar SystemObject::vcpu_getCurAppHeight( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + RECT r = { 0 }; + int s = getCurAppRect( &r ); + return MAKE_SCRIPT_INT( s ? r.bottom - r.top : -1 ); +#else + RETURN_SCRIPT_ZERO +#endif +} + +scriptVar SystemObject::vcpu_isAppActive( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + return MAKE_SCRIPT_BOOLEAN( isAppActive() ); +#else + RETURN_SCRIPT_ZERO +#endif +} + +scriptVar SystemObject::vcpu_showWindow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar wndguidorgroup, scriptVar prefcontainer, scriptVar transient ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + const wchar_t *s = GET_SCRIPT_STRING( wndguidorgroup ); + const wchar_t *p = GET_SCRIPT_STRING( prefcontainer ); + int t = GET_SCRIPT_INT( transient ); + if ( p != NULL && *p == 0 ) p = NULL; + GUID _g = nsGUID::fromCharW( s ); +#ifdef ON_CREATE_EXTERNAL_WINDOW_GUID + if ( _g != INVALID_GUID ) + { + int y = 0; + ON_CREATE_EXTERNAL_WINDOW_GUID( _g, y ); + if ( y ) RETURN_SCRIPT_NULL; + } +#endif + ifc_window *ret = NULL; + if ( _g != INVALID_GUID ) + ret = WASABI_API_WNDMGR->skinwnd_createByGuid( _g, p, 0, NULL, t ); + else + ret = WASABI_API_WNDMGR->skinwnd_createByGroupId( s, p, 0, NULL, t ); + if ( ret ) + { + if ( ret->getGuiObject() ) + { + return MAKE_SCRIPT_OBJECT( ret->getGuiObject()->guiobject_getScriptObject() ); + } + } +#endif + RETURN_SCRIPT_NULL; +} + +scriptVar SystemObject::vcpu_hideWindow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar hw ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + GuiObject *o = static_cast( GET_SCRIPT_OBJECT_AS( hw, guiObjectGuid ) ); + if ( o ) + WASABI_API_WNDMGR->skinwnd_destroy( o->guiobject_getRootWnd() ); +#endif + RETURN_SCRIPT_NULL; +} + +scriptVar SystemObject::vcpu_hideNamedWindow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar guidorgroup ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + const wchar_t *s = GET_SCRIPT_STRING( guidorgroup ); + GUID _g = nsGUID::fromCharW( s ); + ifc_window *w = NULL; + if ( _g != INVALID_GUID ) + { + int n = WASABI_API_WNDMGR->skinwnd_getNumByGuid( _g ); // benski> CUT: int n = skinEmbedder->getNumItems(_g); + if ( n > 0 ) + w = WASABI_API_WNDMGR->skinwnd_enumByGuid( _g, n - 1 ); // benski> CUT: w = skinEmbedder->enumItem(_g, n-1); + } + else + { + int n = WASABI_API_WNDMGR->skinwnd_getNumByGroupId( s ); // benski> CUT: int n = skinEmbedder->getNumItems(s); + if ( n > 0 ) + w = WASABI_API_WNDMGR->skinwnd_enumByGroupId( s, n - 1 ); // benski> CUT: w = skinEmbedder->enumItem(s, n-1); + } + if ( w ) + { + GuiObject *o = w->getGuiObject(); + if ( o ) + WASABI_API_WNDMGR->skinwnd_destroy( o->guiobject_getRootWnd() ); + } +#endif + RETURN_SCRIPT_NULL; +} + +scriptVar SystemObject::vcpu_isNamedWindowVisible( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar guidorgroup ) +{ + SCRIPT_FUNCTION_INIT; + const wchar_t *s = GET_SCRIPT_STRING( guidorgroup ); + GUID _g = nsGUID::fromCharW( s ); + ifc_window *w = NULL; + if ( _g != INVALID_GUID ) + { + int n = WASABI_API_WNDMGR->skinwnd_getNumByGuid( _g ); // benski> CUT: int n = skinEmbedder->getNumItems(_g); + if ( n > 0 ) + w = WASABI_API_WNDMGR->skinwnd_enumByGuid( _g, n - 1 ); // benski> CUT: w = skinEmbedder->enumItem(_g, n-1); + } + else + { + int n = WASABI_API_WNDMGR->skinwnd_getNumByGroupId( s ); // benski> CUT: int n = skinEmbedder->getNumItems(s); + if ( n > 0 ) + w = WASABI_API_WNDMGR->skinwnd_enumByGroupId( s, n - 1 ); // benski> CUT: w = skinEmbedder->enumItem(s, n-1); + } + if ( w ) + { + return MAKE_SCRIPT_BOOLEAN( w->isVisible() ); + } + RETURN_SCRIPT_ZERO; +} + +#endif // if defined (WASABI_COMPILE_WNDMGR) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + +#if defined(WASABI_COMPILE_MEDIACORE) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + +scriptVar SystemObject::vcpu_getStatus( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getStatus( 0 ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_getSongInfoText( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + +#ifdef GET_SONG_INFO_TEXT + const wchar_t *c; + GET_SONG_INFO_TEXT( c ); + WCSCPYN( staticStr, c, 4096 ); +#else + *staticStr = 0; +#pragma CHAT("lone", "bas", "need to get the song info text, the same as would be in a text field with SONGINFO") +#endif + return MAKE_SCRIPT_STRING( staticStr ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_getSongInfoTextTranslated( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + +#ifdef GET_SONG_INFO_TEXT_TRANSLATED + const wchar_t *c; + GET_SONG_INFO_TEXT_TRANSLATED( c ); + WCSCPYN( staticStr, c, 4096 ); +#else + *staticStr = 0; +#endif + return MAKE_SCRIPT_STRING( staticStr ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +#ifdef GEN_FF +#include "../../../../Plugins/General/gen_ff/wa2frontend.h" +#endif + +scriptVar SystemObject::vcpu_hasVideoSupport( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef GEN_FF + return MAKE_SCRIPT_INT( wa2.hasVideoSupport() ); +#else +#pragma CHAT("lone", "bas", "how can we ask if the currently playing file is video thru the core objects ?") + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_isVideo( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef GEN_FF + return MAKE_SCRIPT_INT( wa2.isPlayingVideo() ); +#else +#pragma CHAT("lone", "bas", "how can we ask if the currently playing file is video thru the core objects ?") + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_isVideoFullscreen( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef GEN_FF + return MAKE_SCRIPT_INT( wa2.isPlayingVideoFullscreen() ); +#else +#pragma CHAT("lone", "bas", "how can we ask if we are running fullscreen (either vis or video) ?") + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_setVideoFullscreen( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef GEN_FF + const bool vidfs = GET_SCRIPT_BOOLEAN( v ); + if ( vidfs ) + { + wa2.sendVidCmd( Winamp2FrontEnd::WA2_VIDCMD_FULLSCREEN ); + } + else + { + wa2.sendVidCmd( Winamp2FrontEnd::WA2_VIDCMD_EXIT_FS ); + } + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_getPlaylistIndex( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef GEN_FF + return MAKE_SCRIPT_INT( wa2.getCurPlaylistEntry() ); +#else +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( CoreHandle().getCurPlaybackNumber() ); +#else + RETURN_SCRIPT_ZERO; +#endif +#endif +} + +scriptVar SystemObject::vcpu_getPlaylistLength( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef GEN_FF + return MAKE_SCRIPT_INT( wa2.getPlaylistLength() ); +#else +#ifdef WASABI_COMPILE_MEDIACORE + //BU CoreHandle is your friend + return MAKE_SCRIPT_INT( CoreHandle().getNumTracks() ); +#else + //FG not always, heh + RETURN_SCRIPT_ZERO; +#endif +#endif +} + +scriptVar SystemObject::vcpu_getIdealVideoHeight( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef GEN_FF + int h = -1; + wa2.getIdealVideoSize( NULL, &h ); + return MAKE_SCRIPT_INT( h ); +#else +#pragma CHAT("lone", "bas", "how can we ask for the ideal video size thru the core objects ?") + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_getIdealVideoWidth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef GEN_FF + int w = -1; + wa2.getIdealVideoSize( &w, NULL ); + return MAKE_SCRIPT_INT( w ); +#else +#pragma CHAT("lone", "bas", "how can we ask for the ideal video size thru the core objects ?") + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_onStop( SCRIPT_FUNCTION_PARAMS, ScriptObject *o ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS0( o, systemController ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT0( o ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onShowNotification( SCRIPT_FUNCTION_PARAMS, ScriptObject *o ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS0( o, systemController ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT0( o ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onPlay( SCRIPT_FUNCTION_PARAMS, ScriptObject *o ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS0( o, systemController ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT0( o ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onPause( SCRIPT_FUNCTION_PARAMS, ScriptObject *o ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS0( o, systemController ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT0( o ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onResume( SCRIPT_FUNCTION_PARAMS, ScriptObject *o ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS0( o, systemController ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT0( o ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onTitleChange( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar title ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, title ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, title ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onTitle2Change( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar title ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, title ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, title ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onUrlChange( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar title ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, title ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, title ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onInfoChange( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar info ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, info ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, info ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onStatusMsg( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar info ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, info ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, info ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onEqBandChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar band, scriptVar val ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS2( o, systemController, band, val ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT2( o, band, val ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onEqFreqChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, val ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, val ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onEqPreAmpChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, val ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, val ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onEqChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, val ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, val ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onVolumeChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, val ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, val ); +#else + RETURN_SCRIPT_VOID +#endif +} + +scriptVar SystemObject::vcpu_onSeeked( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, val ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, val ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_getPlayItemString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + const wchar_t *cur = WASABI_API_MEDIACORE->core_getCurrent( 0 ); + if ( cur == NULL ) cur = L""; + return MAKE_SCRIPT_STRING( cur ); +#else + return MAKE_SCRIPT_STRING( L"" ); +#endif +} + +scriptVar SystemObject::vcpu_getPlayItemLength( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getLength( 0 ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_getPlayItemDisplayTitle( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + WCSCPYN( staticStr, WASABI_API_MEDIACORE->core_getTitle( 0 ), 4096 ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_getPlayItemMetadataString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar name ) +{ + SCRIPT_FUNCTION_INIT; +#if defined(WASABI_COMPILE_MEDIACORE) & defined(WASABI_COMPILE_METADB) + const char *cur = WASABI_API_MEDIACORE->core_getCurrent( 0 ); + if ( cur == NULL ) return MAKE_SCRIPT_STRING( "" ); + if ( cur && WASABI_API_METADB->metadb_getMetaData( cur, GET_SCRIPT_STRING( name ), staticStr, ( sizeof( staticStr ) / sizeof( *staticStr ) ) ) <= 0 ) return MAKE_SCRIPT_STRING( "" ); + return MAKE_SCRIPT_STRING( staticStr ); +#elif defined(WASABI_CUSTOM_MINIDB) + WASABI_CUSTOM_MINIDB( GET_SCRIPT_STRING( name ), staticStr, 4096 ); staticStr[ 4095 ] = 0; + return MAKE_SCRIPT_STRING( staticStr ); +#elif defined(WASABI_COMPILE_MEDIACORE) + STRNCPY( staticStr, WASABI_API_MEDIACORE->core_getCurrent( 0 ), 4095 ); staticStr[ 4095 ] = 0; + return MAKE_SCRIPT_STRING( staticStr ); +#endif +} + +scriptVar SystemObject::vcpu_getMetadataString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar filename, scriptVar name ) +{ + SCRIPT_FUNCTION_INIT; + wa2.getMetaData( GET_SCRIPT_STRING( filename ), GET_SCRIPT_STRING( name ), staticStr, 4096 ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_getExtFamily( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar ext ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + const wchar_t *ps = GET_SCRIPT_STRING( ext ); + staticStr[ 0 ] = '\0'; + if ( ps != NULL ) + { + const wchar_t *f = WASABI_API_MEDIACORE->core_getExtensionFamily( ps ); + if ( f == NULL ) f = L""; + WCSCPYN( staticStr, f, 4096 ); + } + return MAKE_SCRIPT_STRING( staticStr ); +#else + return MAKE_SCRIPT_STRING( L"" ); +#endif +} + +scriptVar SystemObject::vcpu_getDecoderName( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar ext ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + const wchar_t *ps = GET_SCRIPT_STRING( ext ); + staticStr[ 0 ] = '\0'; + if ( ps != NULL ) + { + const wchar_t *f = WASABI_API_MEDIACORE->core_getDecoderName( ps ); + if ( f == NULL ) f = L""; + WCSCPYN( staticStr, f, 4096 ); + } + return MAKE_SCRIPT_STRING( staticStr ); +#else + return MAKE_SCRIPT_STRING( L"" ); +#endif +} + +scriptVar SystemObject::vcpu_playFile( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar file ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE +#ifdef GEN_FF + StringW _file = GET_SCRIPT_STRING( file ); + const wchar_t *f = _file.getValue(); + if ( f && *f ) + { + if ( wcsstr( _file, L"://" ) ) + { + wa2.playFile( _file ); + } + else if ( f[ 1 ] != ':' && f[ 0 ] != '\\' && f[ 0 ] != '/' ) + { + PathParserW pp( f ); + if ( WCSCASEEQLSAFE( pp.enumString( 0 ), L"skins" ) + && WCSCASEEQLSAFE( pp.enumString( 1 ), WASABI_API_SKIN->getSkinName() ) ) + { + _file = L""; + for ( int i = 0; i < pp.getNumStrings() - 2; i++ ) + { + if ( i > 0 ) _file += L"\\"; + _file += pp.enumString( i + 2 ); + } + } + _file = StringPathCombine( WASABI_API_SKIN->getSkinPath(), _file ); + if ( !WACCESS( _file, 0 ) ) // avoid clearing playlist if file not found + wa2.playFile( _file ); + } + } +#else + svc_player *sp = SvcEnumByGuid(); + if ( sp ) sp->openFile( GET_SCRIPT_STRING( file ) ); + WASABI_API_SVC->service_release( sp ); +#endif + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_enqueueFile( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar file ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE +#ifdef GEN_FF + StringW _file = GET_SCRIPT_STRING( file ); + const wchar_t *f = _file.getValue(); + if ( f && *f ) + { + if ( wcsstr( _file, L"://" ) ) + { + wa2.enqueueFile( _file ); + } + else if ( f[ 1 ] != ':' && f[ 0 ] != '\\' && f[ 0 ] != '/' ) + { + PathParserW pp( f ); + if ( WCSCASEEQLSAFE( pp.enumString( 0 ), L"skins" ) + && WCSCASEEQLSAFE( pp.enumString( 1 ), WASABI_API_SKIN->getSkinName() ) ) + { + _file = L""; + for ( int i = 0; i < pp.getNumStrings() - 2; i++ ) + { + if ( i > 0 ) _file += L"\\"; + _file += pp.enumString( i + 2 ); + } + } + _file = StringPathCombine( WASABI_API_SKIN->getSkinPath(), _file ); + wa2.enqueueFile( _file ); + } + } +#else + svc_player *sp = SvcEnumByGuid(); + if ( sp ) sp->openFile( GET_SCRIPT_STRING( file ) ); + WASABI_API_SVC->service_release( sp ); +#endif + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_clearPlaylist( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + wa2.clearPlaylist(); + return MAKE_SCRIPT_VOID(); +} + +scriptVar SystemObject::vcpu_getLeftVuMeter( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getLeftVuMeter( 0 ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_getVisBand( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar chan, scriptVar band ) +{ + { + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + unsigned char visdata[ 576 * 2 * 2 ] = { 0 }; + int ret = WASABI_API_MEDIACORE->core_getVisData( 0, &visdata, sizeof( visdata ) ); + if ( !ret ) MEMSET( visdata, 0, sizeof( visdata ) ); + int b = MIN( MAX( 0, GET_SCRIPT_INT( band ) ), 74 ); + int a = MIN( MAX( 0, GET_SCRIPT_INT( chan ) ), 1 ); + return MAKE_SCRIPT_INT( MIN( 255, visdata[ 576 * a + b ] * 16 ) ); +#else + RETURN_SCRIPT_ZERO; +#endif + } +} + +scriptVar SystemObject::vcpu_getRightVuMeter( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getRightVuMeter( 0 ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_getVolume( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getVolume( 0 ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_setVolume( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_setVolume( 0, GET_SCRIPT_INT( v ) ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_play( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_userButton( 0, UserButton::PLAY ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_stop( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_userButton( 0, UserButton::STOP ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_pause( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_userButton( 0, UserButton::PAUSE ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_next( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_userButton( 0, UserButton::NEXT ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_previous( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_userButton( 0, UserButton::PREV ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_eject( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE +#ifdef GEN_FF + wa2.openFileDialog( WASABI_API_WND->main_getRootWnd()->gethWnd() ); +#else + svc_player *sp = SvcEnumByGuid(); + sp->openFiles(); + WASABI_API_SVC->service_release( sp ); +#endif + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_seekTo( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar to ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_setPosition( 0, GET_SCRIPT_INT( to ) ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_setEqBand( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar band, scriptVar val ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_setEqBand( 0, MAX( 0, MIN( 9, GET_SCRIPT_INT( band ) ) ), GET_SCRIPT_INT( val ) ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_setEqPreAmp( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_setEqPreamp( 0, GET_SCRIPT_INT( v ) ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_setEq( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_setEqStatus( 0, GET_SCRIPT_INT( v ) ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_getPosition( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getPosition( 0 ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_getEqBand( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar band ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getEqBand( 0, MAX( 0, MIN( 9, GET_SCRIPT_INT( band ) ) ) ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_getEqPreAmp( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getEqPreamp( 0 ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_getEq( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getEqStatus( 0 ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +#endif // #if defined(WASABI_COMPILE_MEDIACORE) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + +#if defined(WASABI_COMPILE_COMPONENTS) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + +scriptVar SystemObject::vcpu_getWac( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar guid ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_COMPONENTS + WACObject *wo = SOM::getWACObject( GET_SCRIPT_STRING( guid ) ); + return MAKE_SCRIPT_OBJECT( wo ? wo->getScriptObject() : NULL ); +#else + RETURN_SCRIPT_NULL; +#endif +} + +#endif // if defined(WASABI_COMPILE_COMPONENTS) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + +#if defined(WASABI_COMPILE_CONFIG) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + +scriptVar SystemObject::vcpu_setPrivateString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar section, scriptVar item, scriptVar str ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_CONFIG + WCSNPRINTF( staticStr, 4096, L"%s_%s", GET_SCRIPT_STRING( section ), GET_SCRIPT_STRING( item ) ); + WASABI_API_CONFIG->setStringPrivate( staticStr, GET_SCRIPT_STRING( str ) ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_setPrivateInt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar section, scriptVar item, scriptVar val ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_CONFIG + WCSNPRINTF( staticStr, 4096, L"%s_%s", GET_SCRIPT_STRING( section ), GET_SCRIPT_STRING( item ) ); + WASABI_API_CONFIG->setIntPrivate( staticStr, GET_SCRIPT_INT( val ) ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_getPrivateString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar section, scriptVar item, scriptVar defstr ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_CONFIG + wchar_t t[ 4096 ] = { 0 }; + StringCchPrintfW( t, 4096, L"%s_%s", GET_SCRIPT_STRING( section ), GET_SCRIPT_STRING( item ) ); + WASABI_API_CONFIG->getStringPrivate( t, staticStr, 4095, GET_SCRIPT_STRING( defstr ) ); + return MAKE_SCRIPT_STRING( staticStr ); +#else + return MAKE_SCRIPT_STRING( L"" ); +#endif +} + +scriptVar SystemObject::vcpu_getPrivateInt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar section, scriptVar item, scriptVar defval ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_CONFIG + wchar_t t[ 4096 ] = { 0 }; + StringCchPrintfW( t, 4096, L"%s_%s", GET_SCRIPT_STRING( section ), GET_SCRIPT_STRING( item ) ); + return MAKE_SCRIPT_INT( WASABI_API_CONFIG->getIntPrivate( t, GET_SCRIPT_INT( defval ) ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_setPublicString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar item, scriptVar str ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_CONFIG + WASABI_API_CONFIG->setStringPrivate( GET_SCRIPT_STRING( item ), GET_SCRIPT_STRING( str ) ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_setPublicInt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar item, scriptVar val ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_CONFIG + WASABI_API_CONFIG->setIntPrivate( GET_SCRIPT_STRING( item ), GET_SCRIPT_INT( val ) ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_getPublicString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar item, scriptVar defstr ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_CONFIG + WASABI_API_CONFIG->getStringPrivate( GET_SCRIPT_STRING( item ), staticStr, 4095, GET_SCRIPT_STRING( defstr ) ); + return MAKE_SCRIPT_STRING( staticStr ); +#else + return MAKE_SCRIPT_STRING( L"" ); +#endif +} + +scriptVar SystemObject::vcpu_getPublicInt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar item, scriptVar defval ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_CONFIG + return MAKE_SCRIPT_INT( WASABI_API_CONFIG->getIntPrivate( GET_SCRIPT_STRING( item ), GET_SCRIPT_INT( defval ) ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +#endif // #if defined(WASABI_COMPILE_CONFIG) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + +#if defined (WA3COMPATIBILITY) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + +scriptVar SystemObject::vcpu_ddeSend( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar ddetarget, scriptVar cmd, scriptVar minInterval ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WA3COMPATIBILITY + DdeCom::sendCommand( GET_SCRIPT_STRING( ddetarget ), GET_SCRIPT_STRING( cmd ), GET_SCRIPT_INT( minInterval ) ); +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_popMb( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WA3COMPATIBILITY + MainMiniBrowser::popMb(); +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_getMainMB( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WA3COMPATIBILITY + return MAKE_SCRIPT_OBJECT( MainMiniBrowser::getScriptObject() ); +#else + RETURN_SCRIPT_NULL; +#endif +} + +scriptVar SystemObject::vcpu_setMenuTransparency( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar a ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WA3COMPATIBILITY + WASABI_API_CONFIG->setIntPublic( "Popup alpha", GET_SCRIPT_INT( a ) ); +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_windowMenu( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WA3COMPATIBILITY + Main::thingerContextMenu( NULL ); +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_systemMenu( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WA3COMPATIBILITY + Main::appContextMenu( NULL, FALSE, FALSE ); +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_selectFile( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar extlist, scriptVar id, scriptVar prevfn ) +{ + SCRIPT_FUNCTION_INIT; + SelectFile sf( WASABI_API_WND->main_getRootWnd() ); + sf.setIdent( GET_SCRIPT_STRING( id ) ); + StringW ff = GET_SCRIPT_STRING( prevfn ); + if ( !ff.isempty() ) + { + wchar_t *p = const_cast(Wasabi::Std::filename( ff ) ); + if ( p != NULL ) *p = 0; + sf.setDefaultDir( ff ); + } + StringW exts = GET_SCRIPT_STRING( extlist ); + if ( exts.isempty() ) + exts = L"All files(*.*)|*.*||"; + exts.changeChar( '|', '\0' ); + int r = sf.runSelector( L"files", FALSE, exts ); + StringW t; + if ( !r || sf.getNumFiles() < 1 ) + { + t = GET_SCRIPT_STRING( prevfn ); + } + else + { + t = sf.enumFilename( 0 ); + } + WCSCPYN( staticStr, t, 4096 ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +#endif + +const wchar_t *dldir; + +BOOL CALLBACK browseEnumProc( HWND hwnd, LPARAM lParam ) +{ + wchar_t cl[ 32 ] = { 0 }; + GetClassName( hwnd, cl, ARRAYSIZE( cl ) ); + if ( !lstrcmpi( cl, WC_TREEVIEW ) ) + { + PostMessage( hwnd, TVM_ENSUREVISIBLE, 0, (LPARAM)TreeView_GetSelection( hwnd ) ); + return FALSE; + } + + return TRUE; +} + +static int CALLBACK BrowseCallbackProcX( HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData ) +{ + switch ( uMsg ) + { + case BFFM_INITIALIZED: + { + const wchar_t *wnd_title = (wchar_t *)lpData; + //if(wnd_title) wnd_title = _(wnd_title); + if ( WCSICMP( _( wnd_title ), L"" ) ) SetWindowTextW( hwnd, _( wnd_title ) ); + SendMessageW( hwnd, BFFM_SETSELECTIONW, 1, (LPARAM)dldir ); + + // this is not nice but it fixes the selection not working correctly on all OSes + EnumChildWindows( hwnd, browseEnumProc, 0 ); + } + return 0; + } + return 0; +} + +void Shell_Free( void *p ) +{ + IMalloc *m; + SHGetMalloc( &m ); + m->Free( p ); +} + +scriptVar SystemObject::vcpu_selectFolder( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar title, scriptVar info, scriptVar defPath ) +{ + SCRIPT_FUNCTION_INIT; + + dldir = defPath.data.sdata; + + BROWSEINFOW bi = { 0 }; + bi.hwndOwner = WASABI_API_WND->main_getRootWnd()->gethWnd(); + bi.lpszTitle = _( info.data.sdata ); // Info Text + bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE; + bi.lpfn = BrowseCallbackProcX; + bi.lParam = (LPARAM)title.data.sdata; // Window Title + + ITEMIDLIST *idlist = SHBrowseForFolderW( &bi ); + if ( idlist ) + { + SHGetPathFromIDListW( idlist, staticStr ); + Shell_Free( idlist ); + + return MAKE_SCRIPT_STRING( staticStr ); + } + + return MAKE_SCRIPT_STRING( L"" ); +} + +#ifdef WASABI_COMPILE_MEDIACORE + +int SystemObject::corecb_onVolumeChange( int newvol ) +{ + vcpu_onVolumeChanged( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT( newvol ) ); + return 0; +} + +int SystemObject::corecb_onEQStatusChange( int newval ) +{ + vcpu_onEqChanged( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT( newval ) ); + return 0; +} + +int SystemObject::corecb_onEQPreampChange( int newval ) +{ + vcpu_onEqPreAmpChanged( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT( newval ) ); + return 0; +} + +int SystemObject::corecb_onEQBandChange( int band, int newval ) +{ + vcpu_onEqBandChanged( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT( band ), MAKE_SCRIPT_INT( newval ) ); + return 0; +} + +int SystemObject::corecb_onEQFreqChange( int newval ) +{ + vcpu_onEqFreqChanged( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT( newval ) ); + return 0; +} + +int SystemObject::corecb_onStarted() +{ + vcpu_onPlay( SCRIPT_CALL, getScriptObject() ); + return 0; +} + +int SystemObject::corecb_onStopped() +{ + vcpu_onStop( SCRIPT_CALL, getScriptObject() ); + return 0; +} + +int SystemObject::corecb_onPaused() +{ + vcpu_onPause( SCRIPT_CALL, getScriptObject() ); + return 0; +} + +int SystemObject::corecb_onUnpaused() +{ + vcpu_onResume( SCRIPT_CALL, getScriptObject() ); + return 0; +} + +int SystemObject::corecb_onSeeked( int newpos ) +{ + vcpu_onSeeked( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT( newpos ) ); + return 0; +} + +int SystemObject::corecb_onTitleChange( const wchar_t *title ) +{ + vcpu_onTitleChange( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( title ) ); + return 0; +} + +int SystemObject::corecb_onTitle2Change( const wchar_t *title ) +{ + vcpu_onTitle2Change( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( title ) ); + return 0; +} + +int SystemObject::corecb_onUrlChange( const wchar_t *url ) +{ + vcpu_onUrlChange( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( url ) ); + return 0; +} + +int SystemObject::corecb_onInfoChange( const wchar_t *info ) +{ + vcpu_onInfoChange( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( info ) ); + return 0; +} + +int SystemObject::corecb_onStatusMsg( const wchar_t *info ) +{ + vcpu_onStatusMsg( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( info ) ); + return 0; +} +#endif + +scriptVar SystemObject::vcpu_getRating( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getRating() ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_setRating( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_setRating( GET_SCRIPT_INT( v ) ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_getDownloadPath( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + wa2.getDownloadPath( staticStr ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_setDownloadPath( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar new_path ) +{ + SCRIPT_FUNCTION_INIT; + wa2.setDownloadPath( new_path.data.sdata ); + return MAKE_SCRIPT_VOID(); +} + +scriptVar SystemObject::vcpu_downloadURL( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url, scriptVar filename, scriptVar title ) +{ + SCRIPT_FUNCTION_INIT; + wa2.DownloadFile( AutoChar( GET_SCRIPT_STRING( url ) ) ); + return MAKE_SCRIPT_VOID(); +} + +scriptVar SystemObject::vcpu_downloadMedia( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url, scriptVar filepath, scriptVar storeInMl, scriptVar notifyDownloadsList ) +{ + SCRIPT_FUNCTION_INIT; + wa2.DownloadFile( AutoChar( GET_SCRIPT_STRING( url ) ), GET_SCRIPT_STRING( filepath ), GET_SCRIPT_BOOLEAN( storeInMl ), GET_SCRIPT_BOOLEAN( notifyDownloadsList ) ); + return MAKE_SCRIPT_VOID(); +} + +scriptVar SystemObject::vcpu_onDownloadFinished( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar url, scriptVar success, scriptVar filename ) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS3( o, systemController, url, success, filename ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT3( o, url, success, filename ); +} + +scriptVar SystemObject::vcpu_getAlbumArt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar filename ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT( !!wa2.GetAlbumArt( GET_SCRIPT_STRING( filename ) ) ); +} + +scriptVar SystemObject::vcpu_isWinampPro( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT( !!wa2.IsWinampPro() ); +} + +static PtrList embed_guids; + +static int embed_guid_enumProc( embedWindowState *ws, struct embedEnumStruct *param ) +{ + if ( ws->flags & EMBED_FLAGS_GUID ) + { + wchar_t guid[ 39 ] = { 0 }; + nsGUID::toCharW( GET_EMBED_GUID( ws ), guid ); + embed_guids.addItem( new StringW( guid ) ); + } + return 0; +} +scriptVar SystemObject::vcpu_enumEmbedGUID( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _index ) +{ + SCRIPT_FUNCTION_INIT; + int index = GET_SCRIPT_INT( _index ); + if ( index == 0 ) // make the table + { + embed_guids.deleteAll(); + embedEnumStruct param; + param.user_data = 0; + param.enumProc = embed_guid_enumProc; + SendMessageW( wa2.getMainWindow(), WM_WA_IPC, (WPARAM)¶m, IPC_EMBED_ENUM ); + } + if ( index >= 0 && index < embed_guids.getNumItems() ) + return MAKE_SCRIPT_STRING( embed_guids[ index ]->getValue() ); + + return MAKE_SCRIPT_STRING( L"" ); +} + +scriptVar SystemObject::vcpu_getWinampVersion( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +/** This would have been the code to return a double. + double r = atof(wa2.getVersion()); + return MAKE_SCRIPT_DOUBLE(r); +*/ + return MAKE_SCRIPT_STRING( applicationApi->main_getVersionNumString() ); +} + +scriptVar SystemObject::vcpu_getBuildNumber( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT( applicationApi->main_getBuildNumber() ); +} + +scriptVar SystemObject::vcpu_getFileSize( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _file ) +{ + SCRIPT_FUNCTION_INIT; + const wchar_t *file = GET_SCRIPT_STRING( _file ); + if ( file == NULL ) // make the table + { + return MAKE_SCRIPT_INT( 0 ); + } + /*fileApi->fileOpen(file, 0); + int size = fileApi->fileGetFileSize(); + fileApi->fileClose(;*/ + OSFILETYPE in = WFOPEN( file, WF_READONLY_BINARY ); + if ( in == OPEN_FAILED ) return MAKE_SCRIPT_INT( 0 ); + int size = (int)FGETSIZE( in ); + FCLOSE( in ); + return MAKE_SCRIPT_INT( size ); +} + +wchar_t SystemObject::staticStr[ 4096 ] = { 0 }; +wchar_t SystemObject::translateStr[ 4096 ] = { 0 }; +PtrList < ScriptObject > SystemObject::scriptobjects; + +// END VCPU + +// --------------------------------------------------------------- +// -- END SCRIPT ------------------------------------------------- +// --------------------------------------------------------------- \ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/systemobj.h b/Src/Wasabi/api/script/objects/systemobj.h new file mode 100644 index 00000000..4b388692 --- /dev/null +++ b/Src/Wasabi/api/script/objects/systemobj.h @@ -0,0 +1,397 @@ +#ifndef _SYSTEMOBJ_H +#define _SYSTEMOBJ_H + +#include +#include +#include +#ifdef WASABI_COMPILE_MEDIACORE +#include +#endif +#include +#include + +#ifdef WASABI_COMPILE_WNDMGR +class WindowHolder; +#endif + +// {D6F50F64-93FA-49b7-93F1-BA66EFAE3E98} +static const GUID systemObjectGuid = +{ 0xd6f50f64, 0x93fa, 0x49b7, { 0x93, 0xf1, 0xba, 0x66, 0xef, 0xae, 0x3e, 0x98 } }; + +class SystemScriptObjectController : public ScriptObjectControllerI { + public: + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController() { return rootScriptObjectController; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual int getInstantiable(); + virtual int getReferenceable(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + static function_descriptor_struct exportedFunction[]; +}; + +extern SystemScriptObjectController *systemController; + +class Group; + +#ifdef WASABI_COMPILE_WNDMGR +class Layout; +class Container; +class WindowHolder; +#endif + +#ifdef WASABI_COMPILE_COMPONENTS +class WACObject; +#endif + +#define SYSTEMOBJECT_SCRIPTPARENT RootObjectInstance + +#ifdef WASABI_COMPILE_MEDIACORE +#define SYSTEMOBJECT_PARENT SYSTEMOBJECT_SCRIPTPARENT, public CoreCallbackI +#else +#define SYSTEMOBJECT_PARENT SYSTEMOBJECT_SCRIPTPARENT +#endif + +class SystemObject : public SYSTEMOBJECT_PARENT, public BrowserCallbackI { + public: + SystemObject(); + virtual ~SystemObject(); + void setScriptId(int id); + int getScriptId(); + void setTimer(int delay); + void setParam(const wchar_t *p); + void setParentGroup(Group *g); + Group *getParentGroup(); + const wchar_t *getParam(); + virtual void onLoad(); + virtual void onUnload(); + virtual int isLoaded() { return loaded; } +#ifdef WASABI_COMPILE_WNDMGR + WindowHolder *getSuitableWindowHolderByGuid(GUID g); + int onGetCancelComponent(GUID g, int i); + static void onCreateLayout(Layout *l); + static void onShowLayout(Layout *l); + static void onHideLayout(Layout *l); + static int getCurAppRect(RECT *r); +#endif + static void onQuit(); + static void onKeyDown(const wchar_t *s); + static void onKeyUp(const wchar_t *s); + static int onAccelerator(const wchar_t *action, const wchar_t *section, const wchar_t *key); + TList < int > *getTypesList(); + void setIsOldFormat(int is); + int isOldFormat(); + static int isAppActive(); + + static void onViewPortChanged(int width, int height); + static int onShowNotification(); + static void onDownloadFinished(const wchar_t * url, boolean success, const wchar_t * filename); + + static PtrList < ScriptObject > *getAllScriptObjects() { return &scriptobjects; } + void setSkinPartId(int _skinpartid); + int getSkinPartId(); + + void addInstantiatedObject(ScriptObject *obj); + void removeInstantiatedObject(ScriptObject *obj); + void garbageCollect(); + + static int isObjectValid(ScriptObject *o); + static void addScriptObject(ScriptObject *o); + static void removeScriptObject(ScriptObject *o); + +#ifdef WASABI_COMPILE_SKIN + void onSetXuiParam(const wchar_t *param, const wchar_t *value); +#endif + + const wchar_t *getFilename() { return filename; } + void setFilename(const wchar_t *file) { filename = file; } + static void navigateUrl(const wchar_t *url); + static void navigateUrlBrowser(const wchar_t *url); + + // called by vcpu + static scriptVar vcpu_getVersion( SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar vcpu_onScriptLoaded( SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar vcpu_onScriptUnloading( SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar vcpu_onQuit( SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +#ifdef WASABI_COMPILE_SKIN + static scriptVar vcpu_onSetXuiParam( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar param, scriptVar value); + static scriptVar vcpu_getSkinName( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_switchSkin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar skinname); + static scriptVar vcpu_isLoadingSkin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_lockUI( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_unlockUI( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); +#endif + static scriptVar vcpu_isObjectValid( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar o); + static scriptVar vcpu_getTimeOfDay( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_navigateUrl( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url); + static scriptVar vcpu_navigateUrlBrowser( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url); + static scriptVar vcpu_isKeyDown( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar vk_code); + static scriptVar vcpu_setClipboard( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar text); + static scriptVar vcpu_chr( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar n); + static scriptVar vcpu_onAccelerator( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar action, scriptVar section, scriptVar key); + static scriptVar vcpu_triggerAction( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar guiobj, scriptVar actionstr, scriptVar paramstr); + static scriptVar vcpu_getParam( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); +#ifdef WASABI_COMPILE_SKIN + static scriptVar vcpu_getScriptGroup( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_newGroup( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar groupname); +#endif + static scriptVar vcpu_getMousePosX( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getMousePosY( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_isMinimized( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_isDesktopAlphaAvailable( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_isTransparencyAvailable( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_minimizeApplication( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_restoreApplication( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_activateApplication( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_integerToString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar i); + static scriptVar vcpu_stringToInteger( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar s); + static scriptVar vcpu_floatToString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar f, scriptVar digits); + static scriptVar vcpu_stringToFloat( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar s); + static scriptVar vcpu_integerToTime( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_integerToLongTime( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_dateToTime( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_dateToLongTime( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_formatDate( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_formatLongDate( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_getDateYear( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_getDateMonth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_getDateDay( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_getDateDow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_getDateDoy( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_getDateHour( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_getDateMin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_getDateSec( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_getDateDst( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_getDate( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_strmid( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str, scriptVar start, scriptVar len); + static scriptVar vcpu_strleft( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str, scriptVar len); + static scriptVar vcpu_strright( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str, scriptVar _len); + static scriptVar vcpu_strsearch( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str, scriptVar substr); + static scriptVar vcpu_strlen( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str); + static scriptVar vcpu_strupper( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str); + static scriptVar vcpu_strlower( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str); + static scriptVar vcpu_urlencode( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str); + static scriptVar vcpu_urldecode( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str); + static scriptVar vcpu_removepath( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str); + static scriptVar vcpu_getpath( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str); + static scriptVar vcpu_getextension( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str); + static scriptVar vcpu_gettoken( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar tok, scriptVar sep, scriptVar num); + static scriptVar vcpu_sin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d); + static scriptVar vcpu_cos( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d); + static scriptVar vcpu_tan( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d); + static scriptVar vcpu_asin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d); + static scriptVar vcpu_acos( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d); + static scriptVar vcpu_atan( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d); + static scriptVar vcpu_atan2( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar y, scriptVar x); + static scriptVar vcpu_pow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y); + static scriptVar vcpu_sqr( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _d); + static scriptVar vcpu_sqrt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d); + static scriptVar vcpu_random( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar m); + static scriptVar vcpu_integer( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v); + static scriptVar vcpu_frac( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v); + static scriptVar vcpu_log( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v); + static scriptVar vcpu_log10( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v); + static scriptVar vcpu_getMonitorLeft( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getMonitorTop( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getMonitorWidth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getMonitorHeight( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getMonitorLeftFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y); + static scriptVar vcpu_getMonitorTopFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y); + static scriptVar vcpu_getMonitorLeftGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj); + static scriptVar vcpu_getMonitorTopGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj); + static scriptVar vcpu_getMonitorWidthFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y); + static scriptVar vcpu_getMonitorHeightFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y); + static scriptVar vcpu_getMonitorWidthGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj); + static scriptVar vcpu_getMonitorHeightGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj); + static scriptVar vcpu_onViewPortChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar width, scriptVar height); + static scriptVar vcpu_getViewportWidth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getViewportHeight( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getViewportWidthGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj); + static scriptVar vcpu_getViewportHeightGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj); + static scriptVar vcpu_getViewportLeft( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getViewportTop( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getViewportLeftGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj); + static scriptVar vcpu_getViewportTopGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj); + static scriptVar vcpu_getViewportWidthFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y); + static scriptVar vcpu_getViewportHeightFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y); + static scriptVar vcpu_getViewportLeftFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y); + static scriptVar vcpu_getViewportTopFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y); + static scriptVar vcpu_getTickCount( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_onKeyDown( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v); + static scriptVar vcpu_onKeyUp( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v); + static scriptVar vcpu_debugString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str, scriptVar severity); + static scriptVar vcpu_messageBox( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar msg, scriptVar title, scriptVar flags, scriptVar nam); + static scriptVar vcpu_getAtom( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar atomname); + static scriptVar vcpu_setAtom( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar atomname, scriptVar obj); +#ifdef WASABI_COMPILE_MAKIDEBUG + static scriptVar vcpu_invokeDebugger( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); +#endif +#if defined (WASABI_COMPILE_WNDMGR) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + static scriptVar vcpu_onCreateLayout( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar l); + static scriptVar vcpu_onShowLayout( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar l); + static scriptVar vcpu_onHideLayout( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar l); + static scriptVar vcpu_getContainer( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar contname); + static scriptVar vcpu_newDynamicContainer( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar contname); + static scriptVar vcpu_newGroupAsLayout( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar groupname); + static scriptVar vcpu_getNumContainers( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_enumContainer( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar n); + static scriptVar vcpu_onLookForComponent( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar guid); + static scriptVar vcpu_onGetCancelComponent( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar guid, scriptVar i); + static scriptVar vcpu_getCurAppLeft( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getCurAppTop( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getCurAppWidth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getCurAppHeight( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_isAppActive( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_showWindow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar wndguidorgroup, scriptVar prefcontainer, scriptVar transient); + static scriptVar vcpu_hideWindow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar container); + static scriptVar vcpu_hideNamedWindow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar wndguidorgroup); + static scriptVar vcpu_isNamedWindowVisible( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar wndguidorgroup); +#endif +#if defined(WASABI_COMPILE_MEDIACORE) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + static scriptVar vcpu_getStatus( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_onStop( SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar vcpu_onPlay( SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar vcpu_onPause( SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar vcpu_onResume( SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar vcpu_onTitleChange( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar title); + static scriptVar vcpu_onTitle2Change( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar title); + static scriptVar vcpu_onUrlChange( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar title); + static scriptVar vcpu_onInfoChange( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar info); + static scriptVar vcpu_onStatusMsg( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar info); + static scriptVar vcpu_onEqBandChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar band, scriptVar val); + static scriptVar vcpu_onEqFreqChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val); + static scriptVar vcpu_onEqPreAmpChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val); + static scriptVar vcpu_onEqChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val); + static scriptVar vcpu_onVolumeChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val); + static scriptVar vcpu_onSeeked( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val); + static scriptVar vcpu_getPlayItemDisplayTitle( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getPlayItemString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getPlayItemLength( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getPlayItemMetadataString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar name); + static scriptVar vcpu_getMetadataString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar filename, scriptVar name); + static scriptVar vcpu_getExtFamily( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar ext); + static scriptVar vcpu_getDecoderName( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar ext); + static scriptVar vcpu_playFile( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar file); + static scriptVar vcpu_enqueueFile( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar file); + static scriptVar vcpu_clearPlaylist( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getLeftVuMeter( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getRightVuMeter( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getVisBand( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar chan, scriptVar band); + static scriptVar vcpu_getVolume( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_setVolume( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v); + static scriptVar vcpu_play( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_stop( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_pause( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_next( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_previous( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_eject( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_seekTo( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar to); + static scriptVar vcpu_setEqBand( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar band, scriptVar val); + static scriptVar vcpu_setEqPreAmp( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v); + static scriptVar vcpu_setEq( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v); + static scriptVar vcpu_getPosition( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getEqBand( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar band); + static scriptVar vcpu_getEqPreAmp( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getEq( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_hasVideoSupport( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_isVideo( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_isVideoFullscreen( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_setVideoFullscreen( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar val); + static scriptVar vcpu_getIdealVideoWidth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getIdealVideoHeight( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getPlaylistLength( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getPlaylistIndex( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_onShowNotification( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getSongInfoText( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getSongInfoTextTranslated( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); +#endif +#if defined(WASABI_COMPILE_COMPONENTS) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + static scriptVar vcpu_getWac( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar guid); +#endif +#if defined (WASABI_COMPILE_CONFIG) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + static scriptVar vcpu_setPrivateString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar section, scriptVar item, scriptVar str); + static scriptVar vcpu_setPrivateInt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar section, scriptVar item, scriptVar val); + static scriptVar vcpu_getPrivateString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar section, scriptVar item, scriptVar defstr); + static scriptVar vcpu_getPrivateInt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar section, scriptVar item, scriptVar defval); + static scriptVar vcpu_setPublicString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar item, scriptVar str); + static scriptVar vcpu_setPublicInt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar item, scriptVar val); + static scriptVar vcpu_getPublicString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar item, scriptVar defstr); + static scriptVar vcpu_getPublicInt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar item, scriptVar defval); +#endif +#if defined (WA3COMPATIBILITY) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + static scriptVar vcpu_ddeSend( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar ddetarget, scriptVar cmd, scriptVar minInterval); + static scriptVar vcpu_popMb( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getMainMB( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_setMenuTransparency( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar a); + static scriptVar vcpu_windowMenu( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_systemMenu( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); +#endif + static scriptVar vcpu_selectFile( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar extlist, scriptVar id, scriptVar prevfn); + static scriptVar vcpu_selectFolder( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar title, scriptVar info, scriptVar defpath); + + static scriptVar vcpu_getRating( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_setRating ( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v); + +#ifdef WASABI_COMPILE_MEDIACORE + // core callbacks + virtual int corecb_onVolumeChange(int newvol); + virtual int corecb_onEQStatusChange(int newval); + virtual int corecb_onEQPreampChange(int newval); + virtual int corecb_onEQBandChange(int band, int newval); + virtual int corecb_onEQFreqChange(int newval); + virtual int corecb_onStarted(); + virtual int corecb_onStopped(); + virtual int corecb_onPaused(); + virtual int corecb_onUnpaused(); + virtual int corecb_onSeeked(int newpos); + virtual int corecb_onTitleChange(const wchar_t *title); + virtual int corecb_onTitle2Change(const wchar_t *title); + virtual int corecb_onUrlChange(const wchar_t *url); + virtual int corecb_onInfoChange(const wchar_t *info); + virtual int corecb_onStatusMsg(const wchar_t *info); +#endif + + virtual void browsercb_onOpenURL(wchar_t *url, bool *override); + static scriptVar vcpu_onOpenURL( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar url); + + static scriptVar vcpu_downloadURL(SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url,scriptVar filename,scriptVar title); + static scriptVar vcpu_downloadMedia(SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url, scriptVar filepath, scriptVar storeInMl, scriptVar notifyDownloadsList); + static scriptVar vcpu_onDownloadFinished(SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url,scriptVar success, scriptVar filename); + static scriptVar vcpu_getDownloadPath(SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_setDownloadPath(SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar new_path); + static scriptVar vcpu_getAlbumArt(SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar filename); + static scriptVar vcpu_isWinampPro(SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_enumEmbedGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar index); + static scriptVar vcpu_getWinampVersion(SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getBuildNumber(SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getFileSize(SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar file); + static scriptVar vcpu_translate(SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str); + static scriptVar vcpu_getString(SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar table, scriptVar id); + static scriptVar vcpu_getLanguageId(SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + + private: + int scriptVCPUId; + StringW param; + static wchar_t staticStr[4096]; + static wchar_t translateStr[4096]; + TList < int > typeslist; + int isoldformat; + Group * parentGroup; + int skinpartid; + static PtrList < ScriptObject > scriptobjects; + PtrList < ScriptObject > instantiated; + int loaded; + int started_up; + StringW filename; + + public: +}; + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/timer.cpp b/Src/Wasabi/api/script/objects/timer.cpp new file mode 100644 index 00000000..36449940 --- /dev/null +++ b/Src/Wasabi/api/script/objects/timer.cpp @@ -0,0 +1,165 @@ +#include +#include "timer.h" +#include +#include +//#include //CUT!! +//#include //CUT!! + +STimer::STimer() { + getScriptObject()->vcpu_setInterface(timerGuid, (void *)static_cast(this)); + getScriptObject()->vcpu_setClassName(L"Timer"); + getScriptObject()->vcpu_setController(timerController); + delay = 1000; + started = 0; +} + +STimer::~STimer() { +} + +void STimer::setDelay(int d) { + delay = d; + if (started) + timerclient_setTimer(STIMER_ID, getDelay()); +} + +int STimer::getDelay(void) { + return delay; +} + +void STimer::start(void) { + if (started) { stop(); } + timerclient_setTimer(STIMER_ID, getDelay()); + started = 1; +} + +void STimer::stop(void) { + if (!started) return; + timerclient_killTimer(STIMER_ID); + started = 0; +} + +void STimer::onTimer(void) +{ + if (started) + { + script_onTimer(SCRIPT_CALL, getScriptObject()); + } +} + +void STimer::timerclient_timerCallback(int id) +{ + if (id == STIMER_ID) + onTimer(); +} + +int STimer::isRunning() { + return started; +} + +TimerScriptController _timerController; +TimerScriptController *timerController=&_timerController; + +// -- Functions table ------------------------------------- +function_descriptor_struct TimerScriptController::exportedFunction[] = { + {L"setDelay", 1, (void*)STimer::script_setDelay }, + {L"getDelay", 0, (void*)STimer::script_getDelay }, + {L"start", 0, (void*)STimer::script_start }, + {L"stop", 0, (void*)STimer::script_stop }, + {L"onTimer", 0, (void*)STimer::script_onTimer }, + {L"isRunning",0, (void*)STimer::script_isRunning }, + {L"getSkipped",0, (void*)STimer::script_getSkipped }, +}; +// -------------------------------------------------------- + +const wchar_t *TimerScriptController::getClassName() { + return L"Timer"; +} + +const wchar_t *TimerScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObjectController *TimerScriptController::getAncestorController() { + return rootScriptObjectController; +} + +ScriptObject *TimerScriptController::instantiate() { + STimer *s = new STimer; + ASSERT(s != NULL); + return s->getScriptObject(); +} + +void TimerScriptController::destroy(ScriptObject *o) { + STimer *s = static_cast(o->vcpu_getInterface(timerGuid)); + ASSERT(s != NULL); + delete s; +} + +void *TimerScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for timer yet +} + +void TimerScriptController::deencapsulate(void *o) { +} + +int TimerScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *TimerScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID TimerScriptController::getClassGuid() { + return timerGuid; +} + +scriptVar STimer::script_onTimer(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, timerController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar STimer::script_setDelay(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar d) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&d)); + STimer *t = static_cast(o->vcpu_getInterface(timerGuid)); + if (t) t->setDelay(SOM::makeInt(&d)); + RETURN_SCRIPT_VOID; +} + +scriptVar STimer::script_getDelay(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + STimer *t = static_cast(o->vcpu_getInterface(timerGuid)); + if (t) return MAKE_SCRIPT_INT(t->getDelay()); + RETURN_SCRIPT_ZERO; +} + +scriptVar STimer::script_start(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + STimer *t = static_cast(o->vcpu_getInterface(timerGuid)); + if (t) t->start(); + RETURN_SCRIPT_VOID; +} + +scriptVar STimer::script_stop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + STimer *t = static_cast(o->vcpu_getInterface(timerGuid)); + if (t) t->stop(); + RETURN_SCRIPT_VOID; +} + +scriptVar STimer::script_isRunning(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + STimer *t = static_cast(o->vcpu_getInterface(timerGuid)); + if (t) return MAKE_SCRIPT_BOOLEAN(t->isRunning()); + RETURN_SCRIPT_ZERO; +} + +scriptVar STimer::script_getSkipped(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + STimer *t = static_cast(o->vcpu_getInterface(timerGuid)); + if (t) return MAKE_SCRIPT_INT(t->timerclient_getSkipped()); + RETURN_SCRIPT_ZERO; +} diff --git a/Src/Wasabi/api/script/objects/timer.h b/Src/Wasabi/api/script/objects/timer.h new file mode 100644 index 00000000..5506a20a --- /dev/null +++ b/Src/Wasabi/api/script/objects/timer.h @@ -0,0 +1,77 @@ +//PORTABLE +#ifndef _STIMER_H +#define _STIMER_H + +#include +#include +#include + +#include + +#define STIMER_PARENT RootObjectInstance + +// {5D0C5BB6-7DE1-4b1f-A70F-8D1659941941} +static const GUID timerGuid = +{ 0x5d0c5bb6, 0x7de1, 0x4b1f, { 0xa7, 0xf, 0x8d, 0x16, 0x59, 0x94, 0x19, 0x41 } }; + +class TimerScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern TimerScriptController *timerController; + + +#ifndef _NOSTUDIO + +#define STIMER_ID 2481 + +class STimer : public STIMER_PARENT, public TimerClientDI { +public: + STimer(); + virtual ~STimer(); + + void start(void); + void stop(void); + int getDelay(void); + void setDelay(int d); + void onTimer(void); + int isRunning(); + + void timerclient_timerCallback(int id); + +private: + int delay; + int started; + +#else +class STimer : public STIMER_SCRIPTPARENT { +#endif + +public: + + static scriptVar script_onTimer(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_setDelay(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar d); + static scriptVar script_getDelay(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_start(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_stop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_isRunning(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_getSkipped(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/wacobj.cpp b/Src/Wasabi/api/script/objects/wacobj.cpp new file mode 100644 index 00000000..6abba5bc --- /dev/null +++ b/Src/Wasabi/api/script/objects/wacobj.cpp @@ -0,0 +1,161 @@ +#include +#include +#include +#include +#include +#include +#include + +#ifdef _WASABIRUNTIME +#include +#include +#endif + +WacScriptController _wacController; +WacScriptController *wacController = &_wacController; + +// -- Functions table ------------------------------------- +function_descriptor_struct WacScriptController::exportedFunction[] = { + {L"getGUID", 1, (void*)WACObject::script_getGUID }, + {L"getName", 1, (void*)WACObject::script_getName }, + {L"onNotify", 3, (void*)WACObject::script_vcpu_onNotify }, + +// DEPRECATED! DO NOTHING + {L"sendCommand", 4, (void*)WACObject::script_vcpu_dummy4}, + {L"show", 0, (void*)WACObject::script_vcpu_dummy0}, + {L"hide", 0, (void*)WACObject::script_vcpu_dummy0}, + {L"isVisible", 0, (void*)WACObject::script_vcpu_dummy0}, + {L"onShow", 0, (void*)WACObject::script_vcpu_dummy0}, + {L"onHide", 0, (void*)WACObject::script_vcpu_dummy0}, + {L"setStatusBar", 1, (void*)WACObject::script_vcpu_dummy1}, + {L"getStatusBar", 0, (void*)WACObject::script_vcpu_dummy0}, +}; +// -------------------------------------------------------- + +const wchar_t *WacScriptController::getClassName() { + return L"Wac"; +} + +const wchar_t *WacScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObjectController *WacScriptController::getAncestorController() { return rootScriptObjectController; } + +int WacScriptController::getInstantiable() { + return 0; +} + +int WacScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *WacScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID WacScriptController::getClassGuid() { + return wacGuid; +} + +ScriptObject *WacScriptController::instantiate() { + return NULL; +} + +void WacScriptController::destroy(ScriptObject *o) { +} + +void *WacScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for wacobject yet +} + +void WacScriptController::deencapsulate(void *o ) { +} + +WACObject::WACObject() { + getScriptObject()->vcpu_setInterface(wacGuid, (void *)static_cast(this)); + getScriptObject()->vcpu_setClassName(L"Wac"); + getScriptObject()->vcpu_setController(wacController); + wacobjs.addItem(this); +} + +WACObject::~WACObject() { + wacobjs.delItem(this); +} + +void WACObject::setGUID(GUID g) { + myGUID = g; +} + +GUID WACObject::getGUID(void) { + return myGUID; +} + +int WACObject::onScriptNotify(const wchar_t *s, int i1, int i2) +{ + scriptVar _i1 = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_i1, i1); + scriptVar _i2 = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_i2, i2); + scriptVar _str = SOM::makeVar(SCRIPT_STRING); + SOM::assign(&_str, (wchar_t *)s); + script_vcpu_onNotify(SCRIPT_CALL, getScriptObject(), _str, _i1, _i2); + return 1; +} + +int WACObject::notifyScripts(WaComponent *comp, const wchar_t *s, int i1, int i2) +{ + for (int i=0;igetGUID(); + if (!MEMCMP(&g, &wacobjs.enumItem(i)->myGUID, sizeof(GUID))) + return wacobjs.enumItem(i)->onScriptNotify(s, i1, i2); + } + return 0; +} + +scriptVar WACObject::script_getGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + static wchar_t guid[nsGUID::GUID_STRLEN+1]; + WACObject *wo = static_cast(o->vcpu_getInterface(wacGuid)); + *guid=0; + if (wo) + nsGUID::toCharW(wo->myGUID, guid); + return MAKE_SCRIPT_STRING(guid); +} + +scriptVar WACObject::script_getName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_COMPONENTS + WACObject *wo = static_cast(o->vcpu_getInterface(wacGuid)); + if (wo) return MAKE_SCRIPT_STRING(WASABI_API_COMPONENT->getComponentName(wo->myGUID)); +#endif + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar WACObject::script_vcpu_onNotify(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar str, scriptVar i1, scriptVar i2) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS3(o, wacController, str, i1, i2); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT3(o, str, i1, i2); +} + +scriptVar WACObject::script_vcpu_dummy4(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a, scriptVar b, scriptVar c, scriptVar d) { + SCRIPT_FUNCTION_INIT; + RETURN_SCRIPT_ZERO; +} + +scriptVar WACObject::script_vcpu_dummy1(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a) { + SCRIPT_FUNCTION_INIT; + RETURN_SCRIPT_ZERO; +} + +scriptVar WACObject::script_vcpu_dummy0(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + RETURN_SCRIPT_ZERO; +} + + +PtrList WACObject::wacobjs; + diff --git a/Src/Wasabi/api/script/objects/wacobj.h b/Src/Wasabi/api/script/objects/wacobj.h new file mode 100644 index 00000000..44cf2d3e --- /dev/null +++ b/Src/Wasabi/api/script/objects/wacobj.h @@ -0,0 +1,75 @@ +#ifndef _WACOBJ_H +#define _WACOBJ_H + +#include +#include +#include +#include +#include + +// {00C074A0-FEA2-49a0-BE8D-FABBDB161640} +static const GUID wacGuid = +{ 0xc074a0, 0xfea2, 0x49a0, { 0xbe, 0x8d, 0xfa, 0xbb, 0xdb, 0x16, 0x16, 0x40 } }; + +#define WACOBJECT_SCRIPTPARENT RootObjectInstance + +class WacScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual int getInstantiable(); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern WacScriptController *wacController; + +#include + +class WACObject : public WACOBJECT_SCRIPTPARENT { + +public: + WACObject(); + virtual ~WACObject(); + + void setGUID(GUID g); + GUID getGUID(void); + + int onScriptNotify(const wchar_t *s, int i1, int i2); + + // VCPU + static scriptVar script_getGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_getName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_onNotify(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar str, scriptVar i1, scriptVar i2); + + static scriptVar script_vcpu_dummy4(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a, scriptVar b, scriptVar c, scriptVar d); + static scriptVar script_vcpu_dummy1(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar script_vcpu_dummy0(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + + // End VCPU + + static int notifyScripts(WaComponent *comp, const wchar_t *s, int i1, int i2); + + GUID myGUID; + +private: + + static PtrList wacobjs; + +public: +}; + + +#endif diff --git a/Src/Wasabi/api/script/objecttable.cpp b/Src/Wasabi/api/script/objecttable.cpp new file mode 100644 index 00000000..0f1f6149 --- /dev/null +++ b/Src/Wasabi/api/script/objecttable.cpp @@ -0,0 +1,748 @@ +#include +#include + +#ifndef _NOSTUDIO +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef WASABI_WIDGETS_LAYER +#include +#endif + +#ifdef WASABI_WIDGETS_ANIMLAYER +#include +#endif + +#include + +#ifdef WASABI_WIDGETS_BUTTON +#include +#endif + +#ifdef WASABI_COMPILE_WNDMGR +#ifdef WASABI_WIDGETS_WNDHOLDER +#include +#endif +#include +#endif // wndmgr + +#ifdef WASABI_WIDGETS_EDIT +#include +#endif + +#ifdef WASABI_WIDGETS_SLIDER +#include +#endif + +#ifdef WASABI_WIDGETS_MEDIAVIS +#include +#endif + +#ifdef WASABI_COMPILE_MEDIACORE + +#ifdef WASABI_WIDGETS_MEDIAEQCURVE +#include +#endif + +#ifdef WASABI_WIDGETS_MEDIASTATUS +#include +#endif + +#endif // mediacore + +#ifdef WASABI_WIDGETS_TEXT +#include +#endif + +#ifdef WASABI_WIDGETS_TGBUTTON +#include +#endif + +#ifdef WASABI_WIDGETS_TITLEBAR +#include +#endif + +#ifdef WASABI_SCRIPTOBJECTS_POPUP +#include +#endif + +#ifdef WASABI_SCRIPTOBJECTS_MAP +#include +#endif + +#ifdef WASABI_WIDGETS_GROUPLIST +#include +#endif + +#ifdef WASABI_WIDGETS_COMPBUCK +#include +#endif + +#ifdef WASABI_SCRIPTOBJECTS_WAC +#include +#endif + +#ifdef WASABI_SCRIPTOBJECTS_LIST +#include +#endif + + +#ifdef WASABI_SCRIPTOBJECTS_BITLIST +#include +#endif + +#ifdef WASABI_SCRIPTOBJECTS_REGION +#include +#endif + +#ifdef WASABI_WIDGETS_MOUSEREDIR +#include +#endif + +#ifdef WASABI_WIDGETS_BROWSER +#include +#endif + +#ifdef WASABI_WIDGETS_QUERYLIST +#include +#endif + +#ifdef WASABI_WIDGETS_FILTERLIST +#include +#endif + +#ifdef WASABI_WIDGETS_WNDHOLDER +#include +#endif + +#ifdef WASABI_WIDGETS_DROPDOWNLIST +#include +#endif + +#ifdef WASABI_SCRIPTOBJECTS_EMBEDDEDXUI +#include +#endif + +#ifdef WASABI_WIDGETS_LAYOUTSTATUS +#include +#endif + +#ifdef WASABI_WIDGETS_TABSHEET +#include +#endif + +#ifdef WASABI_WIDGETS_LIST +#include +#endif + +#ifdef WASABI_WIDGETS_TREE +#include +#endif + +#ifdef WASABI_WIDGETS_CHECKBOX +#include +#endif + +#include + +//Martin> This fixes Wa5 Menu Xml Object is not instanciable via maki - silly bug +#include + +//fileIO +#include +#include + +//ColorMgr +#include +#include +#include +#include + +#include +#include + +#include + +#include + +#include +#include +#include + +void ObjectTable::start() { + registerClass(rootScriptObjectController); + registerClass(systemController); +#ifdef WASABI_COMPILE_SKIN + registerClass(guiController); + registerClass(groupController); +#ifdef WASABI_SCRIPTOBJECTS_EMBEDDEDXUI + registerClass(embeddedXuiController); +#endif +#ifdef WASABI_WIDGETS_LAYER + registerClass(layerController); +#endif +#ifdef WASABI_WIDGETS_ANIMLAYER + registerClass(animlayerController); +#endif + registerClass(albumartController); +#ifdef WASABI_WIDGETS_BUTTON + registerClass(buttonController); +#endif +#ifdef WASABI_WIDGETS_TGBUTTON + registerClass(tgbuttonController); +#endif +#ifdef WASABI_WIDGETS_COMPBUCK + registerClass(cbucketController); +#endif +#ifdef WASABI_COMPILE_WNDMGR + registerClass(containerController); + registerClass(layoutController); +#endif +#ifdef WASABI_WIDGETS_EDIT + registerClass(editController); +#endif +#ifdef WASABI_WIDGETS_SLIDER + registerClass(sliderController); +#endif +#ifdef WASABI_WIDGETS_MEDIAVIS + registerClass(visController); +#endif +#ifdef WASABI_COMPILE_MEDIACORE +#ifdef WASABI_WIDGETS_MEDIAEQCURVE + registerClass(eqvisController); +#endif +#ifdef WASABI_WIDGETS_MEDIASTATUS + registerClass(statusController); +#endif +#endif // mediacore +#ifdef WASABI_WIDGETS_TEXT + registerClass(textController); +#endif + registerClass(frameController); +#ifdef WASABI_WIDGETS_TITLEBAR + registerClass(titleController); +#endif +#ifdef WASABI_SCRIPTOBJECTS_POPUP + registerClass(popupController); +#endif +#ifdef WASABI_SCRIPTOBJECTS_WAC + registerClass(wacController); +#endif +#endif +#ifdef WASABI_SCRIPTOBJECTS_LIST + registerClass(listController); +#endif +#ifdef WASABI_SCRIPTOBJECTS_BITLIST + registerClass(bitlistController); +#endif +#ifdef WASABI_SCRIPTOBJECTS_REGION + registerClass(regionController); +#endif +#ifdef WASABI_SCRIPTOBJECTS_MAP + registerClass(mapController); +#endif +#ifdef WASABI_COMPILE_SKIN +#ifdef WASABI_WIDGETS_GROUPLIST + registerClass(grouplistController); +#endif +#ifdef WASABI_WIDGETS_MOUSEREDIR + registerClass(mouseredirController); +#endif +#ifdef WASABI_COMPILE_CONFIG + registerClass(cfgGroupController); +#endif +#ifdef WASABI_WIDGETS_BROWSER + registerClass(browserController); +#endif +#ifdef WASABI_WIDGETS_QUERYLIST + registerClass(queryListController); +#endif +#ifdef WASABI_WIDGETS_FILTERLIST + registerClass(filterListController); +#endif +#ifdef WASABI_COMPILE_WNDMGR +#ifdef WASABI_WIDGETS_WNDHOLDER + registerClass(windowHolderController); +#endif +#endif // wndmgr +#ifdef WASABI_WIDGETS_DROPDOWNLIST + registerClass(dropDownListController); +#endif +#ifdef WASABI_WIDGETS_LAYOUTSTATUS + registerClass(layoutStatusController); +#endif +#ifdef WASABI_WIDGETS_TABSHEET + registerClass(tabsheetController); +#endif +#ifdef WASABI_WIDGETS_LIST + registerClass(guiListController); +#endif +#ifdef WASABI_WIDGETS_TREE + registerClass(guiTreeController); + registerClass(treeItemController); +#endif +#ifdef WASABI_WIDGETS_CHECKBOX + registerClass(checkBoxController); +#endif +#endif + + registerClass(fileController); + registerClass(xmlDocController); + registerClass(applicationController); + registerClass(SPrivateController); + registerClass(xuiMenuScriptController); + registerClass(colorMgrController); + registerClass(colorController); + registerClass(gammasetController); + registerClass(gammagroupController); +} + +void ObjectTable::shutdown() { + for (int i=0;iclassname); + } + classes.deleteAll(); + VCPU::resetDlf(); + externalloaded = 0; +} + +// unload external classes +void ObjectTable::unloadExternalClasses() { + for (int i=0;iexternal) { + class_entry *ce = classes.enumItem(i); + unlinkClass(ce); + classes.removeByPos(i); + i--; + } + } + classidx = classes.getNumItems(); + externalloaded = 0; +} + +void ObjectTable::unlinkClass(class_entry *e) { + if (e->sf != NULL && !WASABI_API_SVC->service_isvalid(WaSvc::SCRIPTOBJECT, e->sf)) return; + ScriptObjectController *c = e->controller; + const function_descriptor_struct *ds = c->getExportedFunctions(); + for (int j=0;jgetNumFunctions();j++) { + VCPU::DLF_reset(ds[j].physical_ptr, ds[j].nparams); + } +} + +void ObjectTable::loadExternalClasses() { + if (externalloaded) return; + externalloaded = 1; + ExternalScriptObjectEnum soe ; + svc_scriptObject *obj = soe.getFirst(); + while (obj) { + obj->onRegisterClasses(rootScriptObjectController); + int g=0; + while (1) { + ScriptObjectController *o = obj->getController(g); + if (!o) break; + //DebugString(StringPrintf("Registering script class %s\n", o->getClassName())); + ObjectTable::registerClass(o, soe.getLastFactory()); + g++; + } + WASABI_API_SVC->service_release(obj); + obj = soe.getNext(); + } +} + + +// returns classid. ancestorclass = 0 = Object +int ObjectTable::registerClass(ScriptObjectController *c, waServiceFactory *sf) { + ASSERT(c != NULL); + + c->onRegisterClass(rootScriptObjectController); + + const wchar_t *classname = c->getClassName(); + const wchar_t *ancestorclassname = c->getAncestorClassName(); + GUID g = c->getClassGuid(); + + if (getClassFromName(classname) > -1) { + ASSERTPR(0, StringPrintf("duplicate script class name %S", classname)); +#ifdef _WIN32 + ExitProcess(0); +#else + exit(0); +#endif + } + if (getClassFromGuid(g) > -1) { + ASSERTPR(0, "duplicate script class guid"); +#ifdef _WIN32 + ExitProcess(0); +#else + exit(0); +#endif + } + + int ancestorclassid = -1; + if (ancestorclassname != NULL) + ancestorclassid = getClassFromName(ancestorclassname); + + class_entry * en = new class_entry; + en->classid = CLASS_ID_BASE + classidx++; + c->setClassId(en->classid); + c->setAncestorClassId(ancestorclassid); + en->classname = WCSDUP(classname); + en->controller = c; + en->classGuid = g; + en->ancestorclassid = ancestorclassid; + en->instantiable = c->getInstantiable(); + en->referenceable = c->getReferenceable(); + en->external = sf != NULL; + en->sf = sf; + classes.addItem(en); + dlfAddClassRef(c, NULL); // FG> fucko + return classes.getNumItems()-1; +} + +int ObjectTable::addrefDLF(VCPUdlfEntry *dlf, int id) { + + int classid = dlf->basetype; + + while (classid) { + + class_entry *e = getClassEntry(classid); + if (!e) return 0; + function_descriptor_struct *s = (function_descriptor_struct *)e->controller->getExportedFunctions(); + + for (int i=0;icontroller->getNumFunctions();i++, s++) { + if (!WCSICMP(s->function_name, dlf->functionName)) { + int xid = VCPU::getDLFFromPointer(s->physical_ptr, s->nparams); + if (xid != -1) { + dlf->DLFid = xid; + dlf->ptr = s->physical_ptr; + dlf->nparams = s->nparams; + VCPU::DLF_addref(s->physical_ptr, s->nparams); + return 0; + } + dlf->DLFid = id; + dlf->ptr = s->physical_ptr; + dlf->nparams = s->nparams; + VCPU::setupDLFFunction(s->physical_ptr, s->nparams, id, dlf); + VCPU::DLF_addref(s->physical_ptr, s->nparams); + return 1; + } + } + + classid = e->controller->getAncestorClassId(); + } + return 0; +} + +void ObjectTable::delrefDLF(VCPUdlfEntry *dlf) { + int classid = dlf->basetype; + + while (classid) { + + class_entry *e = getClassEntry(classid); + if (!e) return; + function_descriptor_struct *s = (function_descriptor_struct *)e->controller->getExportedFunctions(); + + for (int i=0;icontroller->getNumFunctions();i++, s++) { + if (!WCSICMP(s->function_name, dlf->functionName)) { + VCPU::DLF_remref(s->physical_ptr, s->nparams); + return; + } + } + classid = e->controller->getAncestorClassId(); + } +} + +void ObjectTable::resetDLF(VCPUdlfEntry *dlf) { + int classid = dlf->basetype; + + while (classid) { + + class_entry *e = getClassEntry(classid); + if (!e) return; + function_descriptor_struct *s = (function_descriptor_struct *)e->controller->getExportedFunctions(); + + for (int i=0;icontroller->getNumFunctions();i++, s++) { + if (!WCSICMP(s->function_name, dlf->functionName)) { + VCPU::DLF_reset(s->physical_ptr, s->nparams); + return; + } + } + classid = e->controller->getAncestorClassId(); + } +} + +int ObjectTable::getClassFromName(const wchar_t *classname) { + for (int i=0;iclassname)) { + return classes.enumItem(i)->classid; + } + } + return -1; +} + +int ObjectTable::getClassFromGuid(GUID g) { + GUID t; + for (int i=0;iclassGuid; + if (g == t) + return classes.enumItem(i)->classid; + } + return -1; +} + +const wchar_t *ObjectTable::getClassName(int classid) { + class_entry *e =getClassEntry(classid); + if (!e) return NULL; + return e->classname; +} + +int ObjectTable::isExternal(int classid) { + for (int i=0;iclassid == classid) + return 1; + return 0; +} + +int ObjectTable::getNumGuids() { + return classes.getNumItems(); +} + +GUID ObjectTable::enumGuid(int i) { + return classes.enumItem(i)->classGuid; +} + +const wchar_t *ObjectTable::enumClassName(int n) { + return classes.enumItem(n)->classname; +} + +int ObjectTable::getClassEntryIdx(int classid) { + for (int i=0;iclassid == classid) + return i; + return -1; +} + +int ObjectTable::isDescendant(int class1, int classid) { + + if (classid < CLASS_ID_BASE) return 0; + if (class1 < CLASS_ID_BASE) return 0; + + class_entry *e = getClassEntry(classid); + //CUT: class_entry *_e = getClassEntry(class1); + + while (e) { + if (class1 == classid) return 1; + e = getClassEntry(e->ancestorclassid); + if (e) classid = e->classid; + } + return 0; +} + +int ObjectTable::isClassInstantiable(int classid) { + class_entry *e =getClassEntry(classid); + if (!e) return 0; + return e->instantiable; +} + +int ObjectTable::isClassReferenceable(int classid) { + class_entry *e =getClassEntry(classid); + if (!e) return 0; + return e->referenceable; +} + +ScriptObject *ObjectTable::instantiate(int classid) { + class_entry *e = getClassEntry(classid); + if (!e) return NULL; + ScriptObject *o = e->controller->instantiate(); + return o; +} + +void *ObjectTable::encapsulate(int classid, ScriptObject *o) { + class_entry *e = getClassEntry(classid); + if (!e) return NULL; + void *itf = e->controller->encapsulate(o); + if (itf) + o->vcpu_setInterface(e->classGuid, itf); + return itf; +} + +void ObjectTable::destroy(ScriptObject *o) { + if (!o) return; + class_entry *e = getClassEntry(getClassFromName(o->vcpu_getClassName())); + if (!e) return; + e->controller->destroy(o); +} + +void ObjectTable::deencapsulate(int classid, void *o) { + class_entry *e = getClassEntry(classid); + if (!e) return; + e->controller->deencapsulate(o); +} + +const wchar_t *ObjectTable::getFunction(int dlfid, int *n, ScriptObjectController **p) +{ + VCPUdlfEntry *e = VCPU::getGlobalDlfEntry(dlfid); + if (p) *p = getClassEntry(e->basetype)->controller; + if (n) *n = e->nparams; + return e->functionName; +} + +scriptVar ObjectTable::callFunction(ScriptObject *obj, int dlfid, scriptVar **params) { + VCPUdlfEntry *e = VCPU::getGlobalDlfEntry(dlfid); + VCPU::push(MAKE_SCRIPT_OBJECT(obj)); + for (int i=e->nparams-1;i>=0;i--) + VCPU::push(*params[i]); + return VCPU::callDLF(e, -1); +} + +int ObjectTable::dlfAddRef(ScriptObjectController *o, const wchar_t *function_name, void *host) +{ + ScriptObjectController *_o = o; + while (_o) { + const function_descriptor_struct *s = _o->getExportedFunctions(); + for (int i=0;i<_o->getNumFunctions();i++) { + if (!WCSICMP(function_name, s[i].function_name)) { + return dlfAddRef(_o, i, host); + } + } + // function not found, see if ancestor has it + _o = _o->getAncestorController(); + } + ASSERTALWAYS(StringPrintf("Function %s not found in %s class object hierarchy", function_name, o->getClassName())); + return -1; +} + +int ObjectTable::dlfAddRef(ScriptObjectController *o, int i, void *host) { + const function_descriptor_struct *s = o->getExportedFunctions(); + int id = VCPU::getDLFFromPointer(s[i].physical_ptr, s[i].nparams); + if (id < 0) { // not yet set + // allocate new vcpudlfentry and insert it in vcpu + id = VCPU::newDlf(); + VCPUdlfEntry e; + e.basetype = o->getClassId(); + e.DLFid = id; +// DebugString(" s = %08X\n", s); +// DebugString(" s[i] = %08X\n", s[i]); + ASSERT(s != NULL); + e.functionName = const_cast(s[i].function_name); +// DebugString(" %s\n", e.functionName); + e.nparams = s[i].nparams; + e.ptr = s[i].physical_ptr; + e.scriptId = -1; + VCPU::setupDLFFunction(e.ptr, e.nparams, id, &e); + } + VCPU::DLF_addref(s[i].physical_ptr, s[i].nparams); + if (host != NULL) { + hostrefstruct *r = new hostrefstruct; + r->host = host; + r->nargs = s[i].nparams; + r->ptr = s[i].physical_ptr; + hostrefs.addItem(r); + } + return id; +} + +void ObjectTable::dlfAddClassRef(ScriptObjectController *o, void *host) { +// while (o) { + //CUT: const function_descriptor_struct *s = o->getExportedFunctions(); + for (int i=0;igetNumFunctions();i++) { + dlfAddRef(o, i, host); + } +// o = o->getAncestorController(); +// } +} + + +void ObjectTable::dlfRemRef(void *host) { + for (int i=0;ihost == host) { + //VCPU::DLF_remref(r->ptr, r->nargs); // TODO: re-enable after fixup + delete r; + hostrefs.removeByPos(i); + i--; + } + } +} + +int ObjectTable::checkScript(SystemObject *o) { + TList *l = o->getTypesList(); + if (!l) return 0; + for (int i=0;igetNumItems();i++) { + if (l->enumItem(i) == -1) { +//#ifdef WASABI_COMPILE_WNDMGR +// WASABI_API_WNDMGR->messageBox("Error while loading a script, a component is missing", "Oops", 0, "", NULL); +//#else +// MessageBox(NULL, "Error while loading a script, a component is missing", "Oops", 0); +//#endif +// return 0; + } else { + + } + } + return 1; +} + +ScriptObjectController *ObjectTable::getController(GUID g) { + int i = getClassFromGuid(g); + if (i == -1) return NULL; + class_entry *e = getClassEntry(i); + if (e) + return e->controller; + return NULL; +} + +class_entry *ObjectTable::getClassEntry(int classid) { + for (int i=0;iclassid == classid) + return classes[i]; + return NULL; +} + +#ifdef _NOSTUDIO + +int ObjectTable::validateMember(int classid, char *member, ControlBlock *parms, int *ret) { + ControlBlock *p = parms; + int r=0; + for (int i=0;iclassid == classid) { + const function_descriptor_struct *s = classes.enumItem(i)->controller->getExportedFunctions(); + for (int j=0;jcontroller->getNumFunctions();j++) { + if (STRCASEEQL(s->function_name, member)) { + if (s->nparams == 0 && parms) + wrongParametersNumber(member, s->nparams); + for (int k=0;knparams&&!r;k++) { + int b = s->param[k]; + if (p == NULL) { + wrongParametersNumber(member, s->nparams); + } + if (!::isDescendant(p, b)) { + wrongParameterType(k, member, (char *)getClassName(p->getBaseClass()), (char *)getClassName(classid)); + } + p = p->getNext(); + } + *ret = tempExternalToInternal(s->return_type); + return 1; + } + s++; + } + } + return 0; +} + +#endif + +//----- + +PtrList < class_entry > ObjectTable::classes; +PtrList < hostrefstruct > ObjectTable::hostrefs; +int ObjectTable::classidx = 0; +int ObjectTable::externalloaded = 0; +#endif diff --git a/Src/Wasabi/api/script/objecttable.h b/Src/Wasabi/api/script/objecttable.h new file mode 100644 index 00000000..d0ab4c38 --- /dev/null +++ b/Src/Wasabi/api/script/objecttable.h @@ -0,0 +1,144 @@ +#ifndef __OBJECTTABLE +#define __OBJECTTABLE + +#ifdef __cplusplus + +#include + +#include +class ScriptObjectController; + +#ifdef _NOSTUDIO +//CUT #include "../../scriptcompiler/compiler.h" +//CUT #include "../../scriptcompiler/ctrlblock.h" +#endif + +#endif + +#include + +#define CLASS_ID_BASE 0x100 + + +#define MAKE_NEW_OBJECT(class, objclass) \ + case class: \ + s = new objclass; \ + objclass::instantiate((objclass *)s); \ + break; + +// For type names table +typedef struct { + wchar_t *name; + int type; + int instantiable; + int referenceable; +} typenames; + +// This is the table that link type names as they are +// recognized in scripts to actual basic types. + +// Non instantiable means you can't do v = new +// Non referenceable means you can't do v; +// Not a ref means content is not a reference to an object but rather the actual +// content itself +// * special case for strings which is a ref to a char *, but not an object +#define DEFINE_TYPES \ +typenames types[] = { \ + {L"", SCRIPT_VOID, 0, 0}, /* Non instantiable, non referenceable */ \ + {L"Event", SCRIPT_EVENT, 0, 0}, /* Non instantiable, non referenceable */ \ + {L"Int", SCRIPT_INT, 0, 1}, /* Not a ref */ \ + {L"Float", SCRIPT_FLOAT, 0, 1}, /* Not a ref */ \ + {L"Double", SCRIPT_DOUBLE, 0, 1}, /* Not a ref */ \ + {L"Boolean", SCRIPT_BOOLEAN, 0, 1}, /* Not a ref */ \ + {L"String", SCRIPT_STRING, 0, 1}, /* Not a ref (* special case) */ \ + {L"Any", SCRIPT_ANY, 0, 1}, /* Non instantiable, non referenceable */ \ +}; \ +int ntypes = sizeof(types)/sizeof(typenames); + +extern typenames types[]; +extern int ntypes; + +#define SVC_CLASS_BASE 1024 + +#ifdef __cplusplus + +class class_entry { +public: + const wchar_t *classname; + int classid; + int ancestorclassid; + ScriptObjectController *controller; + GUID classGuid; + int instantiable; + int referenceable; + int external; + waServiceFactory *sf; +}; + +typedef struct { + void *ptr; + int nargs; + void *host; +} hostrefstruct; + +class SystemObject; + +class ObjectTable { + + public : + + static void start(); // initialize tables, internal objects... + static void shutdown(); // free tables + static void unloadExternalClasses(); // unload external classes + static void loadExternalClasses(); // reload external classes + + static int registerClass(ScriptObjectController *c, waServiceFactory *sf = NULL); // returns classid. ancestorclass = 0 = Object + +// static void instantiate(ScriptObject *o, int classid); + static int addrefDLF(VCPUdlfEntry *dlf, int id); + static void delrefDLF(VCPUdlfEntry *dlf); + static void resetDLF(VCPUdlfEntry *dlf); + + static int getClassFromName(const wchar_t *classname); + static int getClassFromGuid(GUID g); + static const wchar_t *getClassName(int classid); + static int isExternal(int classid); + static int getNumGuids(); + static GUID enumGuid(int i); + static const wchar_t *enumClassName(int n); + static int getClassEntryIdx(int classid); + static int isDescendant(int class1, int classid); + static int isClassInstantiable(int classid); + static int isClassReferenceable(int classid); + static ScriptObject *instantiate(int classid); + static void *encapsulate(int classid, ScriptObject *o); + static void destroy(ScriptObject *o); + static void deencapsulate(int classid, void *o); + static const wchar_t *getFunction(int dlfid, int *n, ScriptObjectController **p); + static scriptVar callFunction(ScriptObject *obj, int dlfid, scriptVar **params); + static int dlfAddRef(ScriptObjectController *o, const wchar_t *function_name, void *host); + static int dlfAddRef(ScriptObjectController *o, int i, void *host); + static void dlfAddClassRef(ScriptObjectController *o, void *host); + static void dlfRemRef(void *host); + static int checkScript(SystemObject *o); + static ScriptObjectController *getController(GUID g); + static class_entry *getClassEntry(int classid); + static void unlinkClass(class_entry *e); + +#ifdef _NOSTUDIO + static int validateMember(int classid, wchar_t *member, ControlBlock *parms, int *ret); +#endif + + private: + + static PtrList < class_entry > classes; + static PtrList < hostrefstruct > hostrefs; + static int classidx; + static int externalloaded; +}; + +#endif + +#endif + + diff --git a/Src/Wasabi/api/script/opcodes.h b/Src/Wasabi/api/script/opcodes.h new file mode 100644 index 00000000..bedaf3be --- /dev/null +++ b/Src/Wasabi/api/script/opcodes.h @@ -0,0 +1,64 @@ +#ifndef __OPCODES_H +#define __OPCODES_H + + +#define OPCODE_NOP 0x00 + +#define OPCODE_PUSH 0x01 +#define OPCODE_POPI 0x02 +#define OPCODE_POP 0x03 + +#define OPCODE_CMPEQ 0x08 +#define OPCODE_CMPNE 0x09 +#define OPCODE_CMPA 0x0A +#define OPCODE_CMPAE 0x0B +#define OPCODE_CMPB 0x0C +#define OPCODE_CMPBE 0x0D + +#define OPCODE_JIZ 0x10 +#define OPCODE_JNZ 0x11 +#define OPCODE_JMP 0x12 + +#define OPCODE_CALLM 0x18 +#define OPCODE_CALLC 0x19 + +#define OPCODE_RET 0x20 +#define OPCODE_RETF 0x21 + +#define OPCODE_CMPLT 0x28 + +#define OPCODE_SET 0x30 + +#define OPCODE_INCS 0x38 +#define OPCODE_DECS 0x39 +#define OPCODE_INCP 0x3A +#define OPCODE_DECP 0x3B + +#define OPCODE_ADD 0x40 +#define OPCODE_SUB 0x41 +#define OPCODE_MUL 0x42 +#define OPCODE_DIV 0x43 +#define OPCODE_MOD 0x44 + +#define OPCODE_AND 0x48 +#define OPCODE_OR 0x49 +#define OPCODE_NOT 0x4A +#define OPCODE_BNOT 0x4B +#define OPCODE_NEG 0x4C +#define OPCODE_XOR 0x4D + +#define OPCODE_LAND 0x50 +#define OPCODE_LOR 0x51 + +#define OPCODE_SHL 0x58 +#define OPCODE_SHR 0x59 + +#define OPCODE_NEW 0x60 +#define OPCODE_DELETE 0x61 + +#define OPCODE_UMV 0x68 +#define OPCODE_UMC 0x69 + +#define OPCODE_CALLM2 0x70 + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/script/script.cpp b/Src/Wasabi/api/script/script.cpp new file mode 100644 index 00000000..4d0df190 --- /dev/null +++ b/Src/Wasabi/api/script/script.cpp @@ -0,0 +1,269 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef WASABI_COMPILE_SKIN +#include +#endif +#include +#ifdef WASABI_COMPILE_COMPONENTS +#include //CUT!! +#endif +#include +#include +#include + +extern StringW g_resourcepath; + +// insert the given script in the virtual machine +int Script::addScript(const wchar_t *path, const wchar_t *filename, const wchar_t *id) +{ + static int reentering = 0; + static int redisplay = 0; + + StringPathCombine fpn(path, filename); + + wchar_t olddir[WA_MAX_PATH] = {0}; + Wasabi::Std::getCurDir(olddir, WA_MAX_PATH); + Wasabi::Std::setCurDir(WASABI_API_APP->path_getAppPath()); + OSFILETYPE fp = WFOPEN(fpn, WF_READONLY_BINARY, NO_FILEREADERS); + Wasabi::Std::setCurDir(olddir); +#ifdef WASABI_COMPILE_SKIN + if (fp == OPEN_FAILED) + { + fpn = StringPathCombine(Skin::getDefaultSkinPath(), filename); + Wasabi::Std::getCurDir(olddir, WA_MAX_PATH); + Wasabi::Std::setCurDir(WASABI_API_APP->path_getAppPath()); + fp = WFOPEN(fpn, WF_READONLY_BINARY, NO_FILEREADERS); + Wasabi::Std::setCurDir(olddir); +#endif + if (fp == OPEN_FAILED) + { + if (reentering == 1) + { + redisplay = 1; + return -1; + } + reentering = 1; +#ifdef WANT_WASABI_API_WNDMGR + WASABI_API_SKIN->messageBox(StringPrintf("Could not load script \'%s%s\'\r\n\r\nPress \'OK\' to continue.", path, filename), "Skin Warning", MSGBOX_OK, NULL, NULL); +#else + Wasabi::Std::messageBox(StringPrintfW(L"Could not load script \'%s%s\'\r\n\r\nPress \'OK\' to continue.", path, filename), L"Skin Warning", 0); +#endif + if (redisplay) + { +#ifdef WANT_WASABI_API_WNDMGR + WASABI_API_WND->appdeactivation_setbypass(1); +#endif + Wasabi::Std::messageBox(StringPrintfW(L"Could not load script \'%s%s\'\r\n\r\nPress \'OK\' to continue.", path, filename), L"Skin Warning", 0); +#ifdef WANT_WASABI_API_WNDMGR + WASABI_API_WND->appdeactivation_setbypass(0); +#endif + redisplay = 0; + } + reentering = 0; + return -1; + } +#ifdef WASABI_COMPILE_SKIN + } +#endif + + int size = (int)FGETSIZE(fp); + + void *scriptBlock = MALLOC(size); + FREAD(scriptBlock, size, 1, fp); + FCLOSE(fp); + +#ifdef WASABI_COMPILE_COMPONENTS + WasabiKernelController *wkc = Main::getKernelController(); + if (wkc && !wkc->testScript(fpn, scriptBlock, size)) return -1; +#endif + + int vcpuid = VCPU::assignNewScriptId(); + + SystemObject *system = new SystemObject(); + system->setScriptId(vcpuid); + system->setFilename(filename); + + int r = VCPU::addScript(scriptBlock, size, vcpuid); + + if (r != vcpuid) + { + FREE(scriptBlock); + delete system; + return -1; + } + + scriptEntry *e = new scriptEntry; + e->scriptBlock = scriptBlock; + e->vcpuId = vcpuid; + + scriptslist.addItem(e); + + if (!ObjectTable::checkScript(system)) + { + unloadScript(vcpuid); + return -1; + } + + return vcpuid; +} + +// unload the given script +void Script::unloadScript(int id) +{ + for (int i=0;ivcpuId == id) { + VCPU::removeScript(id); + FREE(scriptslist.enumItem(i)->scriptBlock); + delete scriptslist.enumItem(i); + scriptslist.removeByPos(i); + } + } + if (scriptslist.getNumItems() == 0) scriptslist.removeAll(); // disable fortify warning +} + +// unload ALL scripts +void Script::unloadAllScripts() +{ + while (scriptslist.getNumItems()>0) + { + int n = scriptslist.getNumItems()-1; + VCPU::removeScript(scriptslist.enumItem(n)->vcpuId); + FREE(scriptslist.enumItem(n)->scriptBlock); + delete scriptslist.enumItem(n); + scriptslist.removeByPos(n); + } + scriptslist.removeAll(); // disable fortify warning +} + +PtrList Script::scriptslist; + +int Script::codeToSeverity(int code, wchar_t *t, int len) +{ + switch (code) + { + case GURU_INVALIDHEADER: + case GURU_OLDFORMAT: + wcsncpy(t, L"Ignoring script", len); + return 5; + case GURU_DIVBYZERO: + wcsncpy(t, L"Returning 0", len); + return 4; + case GURU_NEWFAILED: + wcsncpy(t, L"Returning NULL", len); + return 4; + case GURU_NULLCALLED: + wcsncpy(t, L"Ignoring call", len); + return 4; + case GURU_INCOMPATIBLEOBJECT: + wcsncpy(t, L"Assigning NULL", len); + return 4; + default: + wcsncpy(t, L"Internal error", len); + return 9; + } +} + +void Script::guruMeditation(SystemObject *script, int code, const wchar_t *pub, int intinfo) { + + wchar_t t[256] = {0}, u[256] = {0}; + codeToSeverity(code, u, 256); + if (pub) + WCSNPRINTF(t, 256, L"guru: %s - #%04X.%04X%04X", pub, code, (intinfo & 0xFFFF), VCPU::VIP & 0xFFFF); + else + WCSNPRINTF(t, 256, L"guru: #%04X.%04X%04X", pub, code, (intinfo & 0xFFFF), VCPU::VIP & 0xFFFF); + if (*u) { + wcscat(t, L" - "); + wcscat(t, u); + } + DebugStringW(L"%s\n", t); + + time_t now; + time(&now); + struct tm *lt = localtime(&now); +#ifdef _WIN32 + wchar_t *p = _wasctime(lt); +#else +#warning port me + wchar_t *p = L"port me"; +#endif + if (p && *p) p[wcslen(p)-1]=0; + + FILE *fout = _wfopen(StringPathCombine(WASABI_API_APP->path_getUserSettingsPath(), L"guru.log"), WF_APPEND_RW); + if (fout) + { + StringPrintfW z(L"%s (%s/%s) - ", p, WASABI_API_SKIN->getSkinName(),script->getFilename()); + if (*u) + { + z.cat(u); + z.cat(L" - "); + } + StringPrintfW log(L"%s#%04X.%04X%04X.%d%s%s\n", z.getValue(), code, (intinfo & 0xFFFF), VCPU::VIP & 0xFFFF, VCPU::VSD, pub?L" ":L"", pub?pub:L""); + fputws(log.getValue(), fout); + fclose(fout); + } + + Guru::spawn(script, code, pub, intinfo); + +#ifdef WASABI_COMPILE_MAKIDEBUG +// WASABI_API_MAKIDEBUG->debugger_createJITD(script->getScriptId(), 1); +// debugApi->debugger_trace(); +#endif +} + +void Script::setScriptParam(int id, const wchar_t *p) +{ + SystemObject *s = SOM::getSystemObjectByScriptId(id); + if (s) s->setParam(p); +} + +void Script::setParentGroup(int id, Group *g) +{ + SystemObject *s = SOM::getSystemObjectByScriptId(id); + if (s) s->setParentGroup(g); +} + +void Script::setSkinPartId(int id, int skinpartid) +{ + SystemObject *s = SOM::getSystemObjectByScriptId(id); + if (s) s->setSkinPartId(skinpartid); +} + +int Script::varIdToGlobal(int id, int script) +{ + return id + VCPU::varBase(script); +} + +int Script::getNumEventsLinked() +{ + return VCPU::eventsTable.getNumItems(); +} + +int Script::getLinkedEventParams(int num, int *dlfid, int *scriptid, int *varid) +{ + VCPUeventEntry *e = VCPU::eventsTable.enumItem(num); + if (dlfid) *dlfid = e->DLFid; + if (scriptid) *scriptid = e->scriptId; + if (varid) *varid = e->varId; + return num; +} + +int Script::getCacheCount() +{ + return VCPU::getCacheCount(); +} + +int Script::getUserAncestor(int varid, int scriptid) +{ + return VCPU::getUserAncestor(varid, scriptid); +} + +int Script::isValidScriptId(int id) +{ + return VCPU::isValidScriptId(id); +} \ No newline at end of file diff --git a/Src/Wasabi/api/script/script.h b/Src/Wasabi/api/script/script.h new file mode 100644 index 00000000..8f6e5986 --- /dev/null +++ b/Src/Wasabi/api/script/script.h @@ -0,0 +1,86 @@ +#ifndef __SCRIPT_H +#define __SCRIPT_H + +#include +#include + +class String; + +#define GURU_POPEMPTYSTACK 0 +#define GURU_INVALIDHEADER 1 +#define GURU_INVALIDFUNCINDLF 2 +#define GURU_INVALIDFUNCBT 3 +#define GURU_INVALIDVARBT 4 +#define GURU_INVALIDEVENTDLF 5 +#define GURU_INVALIDEVENTADDR 6 +#define GURU_INVALIDEVENTVAR 7 +#define GURU_INVALIDSCRIPTID 8 +#define GURU_DLFSETUPFAILED 9 +#define GURU_SETNONINTERNAL 10 +#define GURU_INCSNONNUM 11 +#define GURU_DECSNONNUM 12 +#define GURU_INCPNONNUM 13 +#define GURU_DECPNONNUM 14 +#define GURU_OBJECTADD 15 +#define GURU_SUBNONNUM 16 +#define GURU_MULNONNUM 17 +#define GURU_DIVNONNUM 18 +#define GURU_DIVBYZERO 19 +#define GURU_MODNONNUM 20 +#define GURU_NEGNONNUM 21 +#define GURU_BNOTNONNUM 22 +#define GURU_SHLNONNUM 23 +#define GURU_SHRNONNUM 24 +#define GURU_XORNONNUM 25 +#define GURU_ANDNONNUM 26 +#define GURU_NEWFAILED 27 +#define GURU_NULLCALLED 28 +#define GURU_OLDFORMAT 29 +#define GURU_INVALIDPEEKSTACK 30 +#define GURU_INVALIDOLDID 31 +#define GURU_INCOMPATIBLEOBJECT 32 +#define GURU_EXCEPTION 33 +#define GURU_FUTUREFORMAT 34 + +// This is our virtual machine basic type. Reducing of expression will use this +// type. We will not malloc or new it, but we'll pass it on the stack for speed +// and stability. 8 bytes should be ok for our stack. This way we won't have to +// maintain lists on dynamically allocated computation values, and we won't have +// to cleanup if some error (divide by zero ?) occurs in the middle of a +// statement. String values are an exception since sdata will point to dynamic +// data, but since every step of the virtual machine reducing strings will free +// that data, cleanup will be automatic + +typedef struct { + void *scriptBlock; + int vcpuId; // id of script in virtual CPU. will be used later for unloading +} scriptEntry; + +class Group; +class SystemObject; + +class Script +{ +public: + static int addScript(const wchar_t *path, const wchar_t *filename, const wchar_t *id); + static void unloadScript(int id); + static void unloadAllScripts(); + static void guruMeditation(SystemObject *script, int code, const wchar_t *pub=NULL, int intinfo=0); + static void setScriptParam(int id, const wchar_t *p); + static int varIdToGlobal(int id, int script); + static int getNumEventsLinked(); + static int getLinkedEventParams(int num, int *dlfid, int *scriptid, int *varid); + static int getCacheCount(); + static int getUserAncestor(int varid, int scriptid); + static int isValidScriptId(int id); + static void setParentGroup(int id, Group *g); + static void setSkinPartId(int id, int skinpartid); + static int getNumScripts() { return scriptslist.getNumItems(); } + + static PtrList scriptslist; + +private: + static int codeToSeverity(int code, wchar_t *t, int len); +}; + +#endif diff --git a/Src/Wasabi/api/script/scriptguid.h b/Src/Wasabi/api/script/scriptguid.h new file mode 100644 index 00000000..33035118 --- /dev/null +++ b/Src/Wasabi/api/script/scriptguid.h @@ -0,0 +1,143 @@ +#ifndef __SCRIPTGUID_H +#define __SCRIPTGUID_H + +#include + +// {C61F6050-6C0C-4b3b-B429-ACEAD0A51B11} +const GUID scriptObjectGuid = +{ 0xc61f6050, 0x6c0c, 0x4b3b, { 0xb4, 0x29, 0xac, 0xea, 0xd0, 0xa5, 0x1b, 0x11 } }; + +// {51654971-0D87-4a51-91E3-A6B53235F3E7} +const GUID rootObjectGuid = +{ 0x51654971, 0x0d87, 0x4a51, { 0x91, 0xe3, 0xa6, 0xb5, 0x32, 0x35, 0xf3, 0xe7 } }; + +// {4EE3E199-C636-4bec-97CD-78BC9C8628B0} +const GUID guiObjectGuid = +{ 0x4ee3e199, 0xc636, 0x4bec, { 0x97, 0xcd, 0x78, 0xbc, 0x9c, 0x86, 0x28, 0xb0 } }; + +// {45BE95E5-2072-4191-935C-BB5FF9F117FD} +const GUID groupGuid = +{ 0x45be95e5, 0x2072, 0x4191, { 0x93, 0x5c, 0xbb, 0x5f, 0xf9, 0xf1, 0x17, 0xfd } }; + +// {698EDDCD-8F1E-4fec-9B12-F944F909FF45} +const GUID buttonGuid = +{ 0x698eddcd, 0x8f1e, 0x4fec, { 0x9b, 0x12, 0xf9, 0x44, 0xf9, 0x9, 0xff, 0x45 } }; + +// {FB508805-53D0-4f74-A62D-A1A8EF2B242C} +const GUID xmlObjectGuid = +{ 0xfb508805, 0x53d0, 0x4f74, { 0xa6, 0x2d, 0xa1, 0xa8, 0xef, 0x2b, 0x24, 0x2c } }; + +// {EFAA8672-310E-41fa-B7DC-85A9525BCB4B} +const GUID textGuid = +{ 0xefaa8672, 0x310e, 0x41fa, { 0xb7, 0xdc, 0x85, 0xa9, 0x52, 0x5b, 0xcb, 0x4b } }; + +// {A8C2200D-51EB-4b2a-BA7F-5D4BC65D4C71} +const GUID browserGuid = +{ 0xa8c2200d, 0x51eb, 0x4b2a, { 0xba, 0x7f, 0x5d, 0x4b, 0xc6, 0x5d, 0x4c, 0x71 } }; + +//// {0B099223-4EB3-4780-9937-6D210372F2CF} +const GUID listGuid = +{ 0xb099223, 0x4eb3, 0x4780, { 0x99, 0x37, 0x6d, 0x21, 0x3, 0x72, 0xf2, 0xcf } }; + +// {CDCB785D-81F2-4253-8F05-61B872283CFA} +const GUID queryListGuid = +{ 0xcdcb785d, 0x81f2, 0x4253, { 0x8f, 0x5, 0x61, 0xb8, 0x72, 0x28, 0x3c, 0xfa } }; + +// {8A6D2485-47F7-4204-9448-7C9656F42DEE} +const GUID filterListGuid = +{ 0x8a6d2485, 0x47f7, 0x4204, { 0x94, 0x48, 0x7c, 0x96, 0x56, 0xf4, 0x2d, 0xee } }; + +// {403ABCC0-6F22-4bd6-8BA4-10C829932547} +const GUID windowHolderGuid = +{ 0x403abcc0, 0x6f22, 0x4bd6, { 0x8b, 0xa4, 0x10, 0xc8, 0x29, 0x93, 0x25, 0x47 } }; + +// {36D59B71-03FD-4af8-9795-0502B7DB267A} +const GUID dropDownListGuid = +{ 0x36d59b71, 0x3fd, 0x4af8, { 0x97, 0x95, 0x5, 0x2, 0xb7, 0xdb, 0x26, 0x7a } }; + +// {0808797D-3EE9-4e12-B88B-4E6274984FDF} +static const GUID formObjectGuid = +{ 0x808797d, 0x3ee9, 0x4e12, { 0xb8, 0x8b, 0x4e, 0x62, 0x74, 0x98, 0x4f, 0xdf } }; + +// {47D73EEF-2A8E-4593-AF70-45A9CFDBB329} +const GUID pathPickerGuid = +{ 0x47d73eef, 0x2a8e, 0x4593, { 0xaf, 0x70, 0x45, 0xa9, 0xcf, 0xdb, 0xb3, 0x29 } }; + +// {7FD5F210-ACC4-48df-A6A0-5451576CDC76} +const GUID layoutStatusGuid = +{ 0x7fd5f210, 0xacc4, 0x48df, { 0xa6, 0xa0, 0x54, 0x51, 0x57, 0x6c, 0xdc, 0x76 } }; + +// {64E4BBFA-81F4-49d9-B0C0-A85B2EC3BCFD} +const GUID editGuid = +{ 0x64e4bbfa, 0x81f4, 0x49d9, { 0xb0, 0xc0, 0xa8, 0x5b, 0x2e, 0xc3, 0xbc, 0xfd } }; + +// {E90DC47B-840D-4ae7-B02C-040BD275F7FC} +const GUID containerGuid = +{ 0xe90dc47b, 0x840d, 0x4ae7, { 0xb0, 0x2c, 0x4, 0xb, 0xd2, 0x75, 0xf7, 0xfc } }; + +// {60906D4E-537E-482e-B004-CC9461885672} +const GUID layoutGuid = +{ 0x60906d4e, 0x537e, 0x482e, { 0xb0, 0x4, 0xcc, 0x94, 0x61, 0x88, 0x56, 0x72 } }; + +// {B4DCCFFF-81FE-4bcc-961B-720FD5BE0FFF} +const GUID toggleButtonGuid = +{ 0xb4dccfff, 0x81fe, 0x4bcc, { 0x96, 0x1b, 0x72, 0xf, 0xd5, 0xbe, 0xf, 0xff } }; + +// {62B65E3F-375E-408d-8DEA-76814AB91B77} +const GUID sliderGuid = +{ 0x62b65e3f, 0x375e, 0x408d, { 0x8d, 0xea, 0x76, 0x81, 0x4a, 0xb9, 0x1b, 0x77 } }; + +// {A8F61649-AA6C-46d1-9415-0AE491999E25} +static const GUID tabSheetGuid = +{ 0xa8f61649, 0xaa6c, 0x46d1, { 0x94, 0x15, 0xa, 0xe4, 0x91, 0x99, 0x9e, 0x25 } }; + +// {1819D795-7A6F-4f2a-8A4D-7DB3EEA90911} +static const GUID embeddedXuiGuid = +{ 0x1819d795, 0x7a6f, 0x4f2a, { 0x8a, 0x4d, 0x7d, 0xb3, 0xee, 0xa9, 0x9, 0x11 } }; + +// {B5BAA535-05B3-4dcb-ADC1-E618D28F6896} +static const GUID tabsheetGuid = +{ 0xb5baa535, 0x5b3, 0x4dcb, { 0xad, 0xc1, 0xe6, 0x18, 0xd2, 0x8f, 0x68, 0x96 } }; + +// {6129FEC1-DAB7-4d51-9165-01CA0C1B70DB} +static const GUID guilistGuid = +{ 0x6129fec1, 0xdab7, 0x4d51, { 0x91, 0x65, 0x1, 0xca, 0xc, 0x1b, 0x70, 0xdb } }; +// {6129FEC1-DAB7-4d51-9165-01CA0C1B70DB} +static const GUID guiListGuid = +{ 0x6129fec1, 0xdab7, 0x4d51, { 0x91, 0x65, 0x1, 0xca, 0xc, 0x1b, 0x70, 0xdb } }; + +// {D59514F7-ED36-45e8-980F-3F4EA0522CD9} +static const GUID guitreeGuid = +{ 0xd59514f7, 0xed36, 0x45e8, { 0x98, 0xf, 0x3f, 0x4e, 0xa0, 0x52, 0x2c, 0xd9 } }; +// {D59514F7-ED36-45e8-980F-3F4EA0522CD9} +static const GUID guiTreeGuid = +{ 0xd59514f7, 0xed36, 0x45e8, { 0x98, 0xf, 0x3f, 0x4e, 0xa0, 0x52, 0x2c, 0xd9 } }; + +// {9B3B4B82-667A-420e-8FFC-794115809C02} +static const GUID treeitemGuid = +{ 0x9b3b4b82, 0x667a, 0x420e, { 0x8f, 0xfc, 0x79, 0x41, 0x15, 0x80, 0x9c, 0x2 } }; +// {9B3B4B82-667A-420e-8FFC-794115809C02} +static const GUID treeItemGuid = +{ 0x9b3b4b82, 0x667a, 0x420e, { 0x8f, 0xfc, 0x79, 0x41, 0x15, 0x80, 0x9c, 0x2 } }; + +// {1D8631C8-80D0-4792-9F98-BD5D36B49136} +static const GUID menuButtonGuid = +{ 0x1d8631c8, 0x80d0, 0x4792, { 0x9f, 0x98, 0xbd, 0x5d, 0x36, 0xb4, 0x91, 0x36 } }; + +// {C0492857-5E28-43b7-97EC-86278A646491} +static const GUID menuButtonSurfaceGuid = +{ 0xc0492857, 0x5e28, 0x43b7, { 0x97, 0xec, 0x86, 0x27, 0x8a, 0x64, 0x64, 0x91 } }; + +// {C7ED3199-5319-4798-9863-60B15A298CAA} +static const GUID checkBoxGuid = +{ 0xc7ed3199, 0x5319, 0x4798, { 0x98, 0x63, 0x60, 0xb1, 0x5a, 0x29, 0x8c, 0xaa } }; + +// {01E28CE1-B059-11d5-979F-E4DE6F51760A} +static const GUID groupListGuid = +{ 0x1e28ce1, 0xb059, 0x11d5, { 0x97, 0x9f, 0xe4, 0xde, 0x6f, 0x51, 0x76, 0xa } }; + +// {E2BBC14D-84F6-4173-BDB3-B2EB2F665550} +static const GUID scriptFrameGuid = +{ 0xe2bbc14d, 0x84f6, 0x4173, { 0xbd, 0xb3, 0xb2, 0xeb, 0x2f, 0x66, 0x55, 0x50 } }; + +#endif diff --git a/Src/Wasabi/api/script/scriptmgr.cpp b/Src/Wasabi/api/script/scriptmgr.cpp new file mode 100644 index 00000000..2ae3f0ec --- /dev/null +++ b/Src/Wasabi/api/script/scriptmgr.cpp @@ -0,0 +1,602 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef WASABI_COMPILE_WND +#include +#endif + +#ifdef WASABI_COMPILE_COMPONENTS +PtrList comps; +#endif + +extern GUID baseGUID; + +ScriptObjectManager::ScriptObjectManager() { + ASSERTPR(!inited, "don't create 2 scriptobjectmanager, you dumbass"); + inited=1; +#ifdef WASABI_COMPILE_COMPONENTS + for (int i=0;igetNumComponents();i++) { + GUID g = api->getComponentGUID(i); + WACObject *c = new WACObject(); + c->setGUID(g); + comps.addItem(c); + } + WACObject *m = new WACObject(); + m->setGUID(baseGUID); + comps.addItem(m); +#endif +} + +ScriptObjectManager::~ScriptObjectManager() { + inited=0; +#ifdef WASABI_COMPILE_COMPONENTS + comps.deleteAll(); +#endif +} + +// Create a variable of specified type +scriptVar ScriptObjectManager::makeVar(int type) +{ + scriptVar v; + v.type = type; + v.data.ddata = 0; + return v; +} + +// Create a variable of specified type and assigns an object to it +scriptVar ScriptObjectManager::makeVar(int type, ScriptObject *o) +{ + scriptVar v = makeVar(type); + v.data.odata = o; + return v; +} + +// Assigns a char* to a String variable. Frees old value if necessary +void ScriptObjectManager::assign(scriptVar *v, const wchar_t *str) +{ + ASSERT(v != NULL); + ASSERT(v->type == SCRIPT_STRING); // Compiler discarded + if (v->data.sdata) FREE((wchar_t *)v->data.sdata); + if ((int)str > 65536) { + v->data.sdata = WCSDUP(str); + VCPU::addStatementString(const_cast(v->data.sdata)); + } else + v->data.sdata = NULL; +} + +// Assigns an int to an int, float or double variable. +void ScriptObjectManager::assign(scriptVar *v, int i) { + ASSERT(v != NULL); + switch (v->type) { + case SCRIPT_FLOAT: + assign(v, (float)i); + return; + case SCRIPT_DOUBLE: + assign(v, (double)i); + return; + case SCRIPT_INT: + case SCRIPT_BOOLEAN: + v->data.idata = i; + return; + case SCRIPT_STRING: + assign(v, StringPrintfW(L"%d", i)); + return; + default: + assign(v, (ScriptObject*)NULL); + return; + } +} + +// Assigns a float to an int, float or double variable. +void ScriptObjectManager::assign(scriptVar *v, float f) { + ASSERT(v != NULL); + switch (v->type) { + case SCRIPT_INT: + case SCRIPT_BOOLEAN: + assign(v, (int)f); + return; + case SCRIPT_DOUBLE: + assign(v, (double)f); + return; + case SCRIPT_FLOAT: + v->data.fdata = f; + return; + case SCRIPT_STRING: + { + wchar_t t[96] = {0}; + WCSNPRINTF(t, 96, L"%f", f); + assign(v, t); + return; + } + default: + assign(v, (ScriptObject*)NULL); + return; + } +} + +// Assigns a double to an int, float or double variable. +void ScriptObjectManager::assign(scriptVar *v, double d) { + ASSERT(v != NULL); + switch (v->type) { + case SCRIPT_INT: + case SCRIPT_BOOLEAN: + assign(v, (int)d); + return; + case SCRIPT_FLOAT: + assign(v, (float)d); + return; + case SCRIPT_DOUBLE: + v->data.ddata = d; + return; + case SCRIPT_STRING: + { + wchar_t t[96] = {0}; + WCSNPRINTF(t, 96, L"%e", d); + assign(v, t); + return; + } + default: + assign(v, (ScriptObject*)NULL); + return; + } +} + +// Assigns a object to an object variable, handles hierarchy. +void ScriptObjectManager::assign(scriptVar *v, ScriptObject *o) { + ASSERT(v != NULL); + // TODO: temporarily assert descendancy + v->data.odata = o; +} + + +// Assigns a numerical scriptVar to another numerical scriptVar +// or an object to another object +// Autocasts +void ScriptObjectManager::assign(scriptVar *v1, scriptVar *v2) { + ASSERT(v1 != NULL); + ASSERT(v2 != NULL); + switch (v1->type) { + case SCRIPT_INT: + assign(v1, SOM::makeInt(v2)); + break; + case SCRIPT_FLOAT: + assign(v1, SOM::makeFloat(v2)); + break; + case SCRIPT_DOUBLE: + assign(v1, SOM::makeDouble(v2)); + break; + case SCRIPT_STRING: + assign(v1, v2->data.sdata); + break; + case SCRIPT_BOOLEAN: + assign(v1, SOM::makeBoolean(v2)); + break; + default: + assign(v1, v2->data.odata); + break; + } +} + +void ScriptObjectManager::assignPersistent(scriptVar *v1, scriptVar *v2) { + ASSERT(v1 != NULL); + ASSERT(v2 != NULL); + switch (v1->type) { + case SCRIPT_INT: + assign(v1, SOM::makeInt(v2)); + break; + case SCRIPT_FLOAT: + assign(v1, SOM::makeFloat(v2)); + break; + case SCRIPT_DOUBLE: + assign(v1, SOM::makeDouble(v2)); + break; + case SCRIPT_STRING: + persistentstrassign(v1, v2->data.sdata); + break; + case SCRIPT_BOOLEAN: + assign(v1, SOM::makeBoolean(v2)); + break; + default: + assign(v1, v2->data.odata); + break; + } +} + +void ScriptObjectManager::strflatassign(scriptVar *v, const wchar_t *str) +{ + ASSERT(v != NULL); + ASSERT(v->type == SCRIPT_STRING); // Compiler discarded + if (v->data.sdata) FREE((wchar_t *)v->data.sdata); + if ((int)str > 65536) + v->data.sdata = (wchar_t *)str; + else + v->data.sdata = NULL; +} + +void ScriptObjectManager::persistentstrassign(scriptVar *v, const wchar_t *str) { + ASSERT(v != NULL); + ASSERT(v->type == SCRIPT_STRING); // Compiler discarded + if (v->data.sdata) FREE((wchar_t *)v->data.sdata); + if ((int)str > 65536) + v->data.sdata = WCSDUP(str); + else + v->data.sdata = NULL; +} + +// comparision functions +int ScriptObjectManager::compEq(scriptVar *v1, scriptVar *v2) { + int r; + switch (v1->type) { + case SCRIPT_INT: + r = v1->data.idata == makeInt(v2); + break; + case SCRIPT_FLOAT: + r = v1->data.fdata == makeFloat(v2); + break; + case SCRIPT_DOUBLE: + r = v1->data.ddata == makeDouble(v2); + break; + case SCRIPT_BOOLEAN: + r = ((v1->data.idata == 0) ? 0 : 1) == ((makeBoolean(v2) == 0) ? 0 : 1); + break; + case SCRIPT_STRING: + if (v1->data.sdata && v2->data.sdata) + { + r = !wcscmp(v1->data.sdata, v2->data.sdata); + break; + } + // pass through + default: // any object, reference has to match + r = v1->data.odata == v2->data.odata; + break; + } + return r; +} + +int ScriptObjectManager::compNeq(scriptVar *v1, scriptVar *v2) { + int r; + switch (v1->type) { + case SCRIPT_INT: + r = v1->data.idata != makeInt(v2); + break; + case SCRIPT_FLOAT: + r = v1->data.fdata != makeFloat(v2); + break; + case SCRIPT_DOUBLE: + r = v1->data.ddata != makeDouble(v2); + break; + case SCRIPT_BOOLEAN: + r = ((v1->data.idata == 0) ? 0 : 1) != ((makeBoolean(v2) == 0) ? 0 : 1); + break; + case SCRIPT_STRING: + if (v1->data.sdata && v2->data.sdata) + r = (wcscmp(v1->data.sdata, v2->data.sdata) != 0) ? 1 : 0; + else + r = 0; + break; + default: + r = v1->data.odata != v2->data.odata; + break; + } + return r; +} + +int ScriptObjectManager::compA(scriptVar *v1, scriptVar *v2) { + int r; + switch (v1->type) { + case SCRIPT_BOOLEAN: + r = ((v1->data.idata == 0) ? 0 : 1) > ((makeBoolean(v2) == 0) ? 0 : 1); + break; + case SCRIPT_INT: + r = v1->data.idata > makeInt(v2); + break; + case SCRIPT_FLOAT: + r = v1->data.fdata > makeFloat(v2); + break; + case SCRIPT_DOUBLE: + r = v1->data.ddata > makeDouble(v2); + break; + case SCRIPT_STRING: + r = (wcscmp(v1->data.sdata, v2->data.sdata) > 0) ? 1 : 0; + break; + default: + r = 0; + break; + } + return r; +} + +int ScriptObjectManager::compAe(scriptVar *v1, scriptVar *v2) { + int r; + switch (v1->type) { + case SCRIPT_BOOLEAN: + r = ((v1->data.idata == 0) ? 0 : 1) >= ((makeBoolean(v2) == 0) ? 0 : 1); + break; + case SCRIPT_INT: + r = v1->data.idata >= makeInt(v2); + break; + case SCRIPT_FLOAT: + r = v1->data.fdata >= makeFloat(v2); + break; + case SCRIPT_DOUBLE: + r = v1->data.ddata >= makeDouble(v2); + break; + case SCRIPT_STRING: + r = (wcscmp(v1->data.sdata, v2->data.sdata) >= 0) ? 1 : 0; + break; + default: + r = 0; + break; + } + return r; +} + +int ScriptObjectManager::compB(scriptVar *v1, scriptVar *v2) { + int r; + switch (v1->type) { + case SCRIPT_BOOLEAN: + r = ((v1->data.idata == 0) ? 0 : 1) < ((makeBoolean(v2) == 0) ? 0 : 1); + break; + case SCRIPT_INT: + r = v1->data.idata < makeInt(v2); + break; + case SCRIPT_FLOAT: + r = v1->data.fdata < makeFloat(v2); + break; + case SCRIPT_DOUBLE: + r = v1->data.ddata < makeDouble(v2); + break; + case SCRIPT_STRING: + r = (wcscmp(v1->data.sdata, v2->data.sdata) < 0) ? 1 : 0; + break; + default: + r = 0; + break; + } + return r; +} + +int ScriptObjectManager::compBe(scriptVar *v1, scriptVar *v2) { + int r; + switch (v1->type) { + case SCRIPT_BOOLEAN: + r = ((v1->data.idata == 0) ? 0 : 1) <= ((makeBoolean(v2) == 0) ? 0 : 1); + break; + case SCRIPT_INT: + r = v1->data.idata <= makeInt(v2); + break; + case SCRIPT_FLOAT: + r = v1->data.fdata <= makeFloat(v2); + break; + case SCRIPT_DOUBLE: + r = v1->data.ddata <= makeDouble(v2); + break; + case SCRIPT_STRING: + r = (wcscmp(v1->data.sdata, v2->data.sdata) <= 0) ? 1 : 0; + break; + default: + r = 0; + break; + } + return r; +} + +void ScriptObjectManager::mid(wchar_t *dest, const wchar_t *str, int s, int l) { + if (str == NULL) return; + int rl = wcslen(str); + if (l == 0) return; + if (s >= rl) return; + if (s+l > rl || l == -1) l = rl-s; + WCSCPYN(dest, str+s, l+1); +} + +int ScriptObjectManager::makeInt(scriptVar *v) { + switch (v->type) { + case SCRIPT_INT: + return v->data.idata; + case SCRIPT_FLOAT: + return (int)v->data.fdata; + case SCRIPT_DOUBLE: + return (int)v->data.ddata; + case SCRIPT_BOOLEAN: + return (v->data.idata == 0) ? 0 : 1; + case SCRIPT_STRING: + return WTOI(v->data.sdata); + default: + return 0; + } +} + +float ScriptObjectManager::makeFloat(scriptVar *v) { + switch (v->type) { + case SCRIPT_INT: + return (float)v->data.idata; + case SCRIPT_FLOAT: + return v->data.fdata; + case SCRIPT_DOUBLE: + return (float)v->data.ddata; + case SCRIPT_BOOLEAN: + return (float)((v->data.idata == 0) ? 0 : 1); + case SCRIPT_STRING: + return (float)WTOF(v->data.sdata); + default: + return 0.0f; + } +} + +double ScriptObjectManager::makeDouble(scriptVar *v) { + switch (v->type) { + case SCRIPT_VOID: + return 0; + case SCRIPT_INT: + return (double)v->data.idata; + case SCRIPT_FLOAT: + return (double)v->data.fdata; + case SCRIPT_DOUBLE: + return v->data.ddata; + case SCRIPT_BOOLEAN: + return (double)((v->data.idata == 0) ? 0 : 1); + case SCRIPT_STRING: + return WTOF(v->data.sdata); + default: + return 0.0; + } +} + +bool ScriptObjectManager::makeBoolean(scriptVar *v) { + switch (v->type) { + case SCRIPT_INT: + case SCRIPT_BOOLEAN: + return (v->data.idata == 0) ? 0 : 1; + case SCRIPT_FLOAT: + return (v->data.fdata == 0) ? 0 : 1; + case SCRIPT_DOUBLE: + return (v->data.ddata == 0) ? 0 : 1; + case SCRIPT_STRING: { + StringW s = v->data.sdata; + if (s.iscaseequal(L"false") || s.iscaseequal(L"f")) + return 0; + if (s.iscaseequal(L"true") || s.iscaseequal(L"t")) + return 1; + return (WTOI(s.getValue()) != 0); + } + default: + return (v->data.odata != NULL) ? 1 : 0; + } +} + +int ScriptObjectManager::isNumeric(scriptVar *s) { + return isNumericType(s->type); +} + +int ScriptObjectManager::isString(scriptVar *s) { + return (s->type == SCRIPT_STRING); +} + +int ScriptObjectManager::isVoid(scriptVar *s) { + return (s->type == SCRIPT_VOID); +} + +int ScriptObjectManager::isObject(scriptVar *s) { + return (s->type == SCRIPT_OBJECT); +} + +int ScriptObjectManager::isNumericType(int t) { + return (t == SCRIPT_INT || t == SCRIPT_BOOLEAN || t == SCRIPT_FLOAT || t == SCRIPT_DOUBLE); +} + +#ifdef WASABI_COMPILE_COMPONENTS +WACObject *ScriptObjectManager::getWACObject(const char *guid) { + GUID cg; + //BU: let me use guid:avs please :) + cg = *SkinParser::getComponentGuid(guid); + return getWACObject(cg); +} + +WACObject *ScriptObjectManager::getWACObject(GUID cg) { + for (int i=0;igetGUID(); + if (!MEMCMP(&dg,&cg,sizeof(GUID))) + return comps[i]; + } + return NULL; +} +#endif + +SystemObject *ScriptObjectManager::getSystemObject(int n) { + return syslist.enumItem(n); +} + +SystemObject *ScriptObjectManager::getSystemObjectByScriptId(int id) { + static int lasti = -1; + static SystemObject *lasto = NULL; + if (lasti == id && syslist.haveItem(lasto)) return lasto; + for (int i=0;igetScriptId() == id) { + lasto = syslist.enumItem(i); + lasti = id; + return lasto; + } + } + return NULL; +} + +void ScriptObjectManager::registerSystemObject(SystemObject *o) { + syslist.addItem(o); +} + +void ScriptObjectManager::unregisterSystemObject(SystemObject *o) { + syslist.removeItem(o); +} + +int SOM::getNumSystemObjects() { + return syslist.getNumItems(); +} + +SystemObject *SOM::enumSystemObject(int n) { + return syslist.enumItem(n); +} + +int ScriptObjectManager::typeCheck(VCPUscriptVar *v, int fail) { + ASSERT(v); + ASSERT(v->v.data.odata); + int type = v->v.type; + while (type >= 0x10000) { + int id = VCPU::varBase(v->scriptId) + (type - 0x10000); + VCPUscriptVar *vc = VCPU::variablesTable.enumItem(id); + type = vc->v.type; + } + int otype = ObjectTable::getClassFromName(v->v.data.odata->vcpu_getClassName()); + ASSERT(otype >= 0); + if (ObjectTable::isDescendant(type, otype)) return 1; + if (fail) + Script::guruMeditation(getSystemObject(v->scriptId), GURU_INCOMPATIBLEOBJECT, L"VAR/OBJECT CLASS MISMATCH", v->varId); + return 0; +} + +#ifdef WASABI_COMPILE_WNDMGR +WindowHolder *ScriptObjectManager::getSuitableWindowHolderFromScript(GUID g) { + for (int i=0;igetSuitableWindowHolderByGuid(g); + if (so) return so; + } + return NULL; +} + +int ScriptObjectManager::checkAbortShowHideWindow(GUID g, int visible) { + for (int i=0;ionGetCancelComponent(g, visible); + if (r) + return r; + } + return 0; +} +#endif + +#ifdef WASABI_COMPILE_WND +ScriptObject *ScriptObjectManager::findObject(const wchar_t *name) +{ + for (int i=0;igetNumAllWindows();i++) + { + ScriptObject *so = static_cast(windowTracker->enumAllWindows(i)->getInterface(scriptObjectGuid)); + if (!so) continue; + GuiObject *go = static_cast(so->vcpu_getInterface(guiObjectGuid)); + if (!go) continue; + if (WCSCASEEQLSAFE(go->guiobject_getId(), name)) + return so; + } + return NULL; +} +#endif + +SystemObject * ScriptObjectManager::system; +PtrList < SystemObject > ScriptObjectManager::syslist; + +int ScriptObjectManager::inited = 0; diff --git a/Src/Wasabi/api/script/scriptmgr.h b/Src/Wasabi/api/script/scriptmgr.h new file mode 100644 index 00000000..45b4775e --- /dev/null +++ b/Src/Wasabi/api/script/scriptmgr.h @@ -0,0 +1,81 @@ +#ifndef _SCRIPT_H +#define _SCRIPT_H + +#include +#ifdef WASABI_COMPILE_CONFIG +#include +#endif + +#define SOM ScriptObjectManager + +// This class should ONLY contain generic functions which don't have to be duplicated for each script layer ! +// This is why this is (mostly) a static class. Please DO NOT add anything which relates to function pointers, +// variable tables, etc. + + +class ScriptObjectManager { +public: + ScriptObjectManager(); + ~ScriptObjectManager(); + + static scriptVar makeVar(int type); + static scriptVar makeVar(int type, ScriptObject *o); + static void assign(scriptVar *v, const wchar_t *str); + static void assign(scriptVar *v, int i); + static void assign(scriptVar *v, float f); + static void assign(scriptVar *v, double d); + static void assign(scriptVar *v, ScriptObject *o); + static void assign(scriptVar *v1, scriptVar *v2); + static void assignPersistent(scriptVar *v1, scriptVar *v2); + static void strflatassign(scriptVar *v, const wchar_t *str); + static void persistentstrassign(scriptVar *v, const wchar_t *str); + + static int compEq(scriptVar *v1, scriptVar *v2); + static int compNeq(scriptVar *v1, scriptVar *v2); + static int compA(scriptVar *v1, scriptVar *v2); + static int compAe(scriptVar *v1, scriptVar *v2); + static int compB(scriptVar *v1, scriptVar *v2); + static int compBe(scriptVar *v1, scriptVar *v2); + + static void mid(wchar_t *dest, const wchar_t *str, int s, int l); + + static int makeInt(scriptVar *v); + static float makeFloat(scriptVar *v); + static double makeDouble(scriptVar *v); + static bool makeBoolean(scriptVar *v); + static int isNumeric(scriptVar *s); + static int isString(scriptVar *s); + static int isVoid(scriptVar *s); + static int isObject(scriptVar *s); + static int isNumericType(int t); + +#ifdef WASABI_COMPILE_COMPONENTS + static WACObject *getWACObject(const wchar_t *guid); + static WACObject *getWACObject(GUID cg); +#endif + static SystemObject *getSystemObject(int n); + static SystemObject *getSystemObjectByScriptId(int id); + + static void registerSystemObject(SystemObject *o); + static void unregisterSystemObject(SystemObject *o); + static int getNumSystemObjects(); + static SystemObject *enumSystemObject(int n); + static int typeCheck(VCPUscriptVar *v, int fail = 1); + static WindowHolder *getSuitableWindowHolderFromScript(GUID g); + static int checkAbortShowHideWindow(GUID g, int visible); +#ifdef WASABI_COMPILE_WND + static ScriptObject *findObject(const wchar_t *name); +#endif + +private: + + static SystemObject * system; + static PtrList < SystemObject > syslist; + static int inited; +}; + +#ifdef WASABI_COMPILE_COMPONENTS +extern PtrList comps; +#endif + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/script/scriptobj.cpp b/Src/Wasabi/api/script/scriptobj.cpp new file mode 100644 index 00000000..397d15bc --- /dev/null +++ b/Src/Wasabi/api/script/scriptobj.cpp @@ -0,0 +1,12 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Thu May 15 21:09:17 2003] +// +// File : scriptobj.cpp +// Class : ScriptObject +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#include +#include "scriptobj.h" + + diff --git a/Src/Wasabi/api/script/scriptobj.h b/Src/Wasabi/api/script/scriptobj.h new file mode 100644 index 00000000..8286bfb9 --- /dev/null +++ b/Src/Wasabi/api/script/scriptobj.h @@ -0,0 +1,139 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Thu May 15 21:09:17 2003] +// +// File : scriptobj.h +// Class : ScriptObject +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#ifndef __SCRIPTOBJECT_H +#define __SCRIPTOBJECT_H + +#include +#include + +class ScriptHook; +class ScriptObject; +class ScriptObjectController; + +enum { + INTERFACE_GENERICVOIDPTR=0, + INTERFACE_SCRIPTOBJECT, +}; + +// ---------------------------------------------------------------------------- + +class ScriptObject: public Dispatchable { + protected: + ScriptObject() {} + ~ScriptObject() {} + public: + void *vcpu_getInterface(GUID g, int *interfacetype = NULL); + void *vcpu_getInterfaceObject(GUID g, ScriptObject **o); + int vcpu_getAssignedVariable(int start, int scriptid, int functionId, int *next, int *globalevententry, int *inheritedevent); + void vcpu_removeAssignedVariable(int var, int id); + void vcpu_addAssignedVariable(int var, int scriptid); + const wchar_t *vcpu_getClassName(); + ScriptObjectController *vcpu_getController(); + int vcpu_getScriptId(); + void vcpu_setScriptId(int i); + int vcpu_getMember(const wchar_t *id, int scriptid, int rettype); + void vcpu_delMembers(int scriptid); + void vcpu_setInterface(GUID g, void *v, int interfacetype = INTERFACE_SCRIPTOBJECT); + void vcpu_setClassName(const wchar_t *name); + void vcpu_setController(ScriptObjectController *c); + void vcpu_init(); + + protected: + enum { + SCRIPTOBJECT_VCPU_GETINTERFACE = 50, + SCRIPTOBJECT_VCPU_GETINTERFACEOBJECT = 60, + SCRIPTOBJECT_VCPU_GETASSIGNEDVARIABLE = 100, + SCRIPTOBJECT_VCPU_REMOVEASSIGNEDVARIABLE = 200, + SCRIPTOBJECT_VCPU_ADDASSIGNEDVARIABLE = 300, + SCRIPTOBJECT_VCPU_GETCLASSNAME = 400, + SCRIPTOBJECT_VCPU_GETCONTROLLER = 500, + SCRIPTOBJECT_VCPU_ADDCLASSHOOK = 600, + SCRIPTOBJECT_VCPU_ADDOBJECTHOOK = 700, + SCRIPTOBJECT_VCPU_GETSCRIPTID = 800, + SCRIPTOBJECT_VCPU_SETSCRIPTID = 900, + SCRIPTOBJECT_VCPU_GETMEMBER = 1000, + SCRIPTOBJECT_VCPU_DELMEMBERS = 1100, + SCRIPTOBJECT_VCPU_SETINTERFACE = 1200, + SCRIPTOBJECT_VCPU_SETCLASSNAME = 1300, + SCRIPTOBJECT_VCPU_SETCONTROLLER = 1400, + SCRIPTOBJECT_VCPU_INIT = 1500, + }; +}; + +// ---------------------------------------------------------------------------- + +inline void *ScriptObject::vcpu_getInterface(GUID g, int *interfacetype) { + void *__retval = _call(SCRIPTOBJECT_VCPU_GETINTERFACE, (void *)NULL, g, interfacetype); + return __retval; +} + +inline void *ScriptObject::vcpu_getInterfaceObject(GUID g, ScriptObject **o) { + void *__retval = _call(SCRIPTOBJECT_VCPU_GETINTERFACEOBJECT, (void *)NULL, g, o); + return __retval; +} + +inline int ScriptObject::vcpu_getAssignedVariable(int start, int scriptid, int functionId, int *next, int *globalevententry, int *inheritedevent) { + int __retval = _call(SCRIPTOBJECT_VCPU_GETASSIGNEDVARIABLE, (int)0, start, scriptid, functionId, next, globalevententry, inheritedevent); + return __retval; +} + +inline void ScriptObject::vcpu_removeAssignedVariable(int var, int id) { + _voidcall(SCRIPTOBJECT_VCPU_REMOVEASSIGNEDVARIABLE, var, id); +} + +inline void ScriptObject::vcpu_addAssignedVariable(int var, int scriptid) { + _voidcall(SCRIPTOBJECT_VCPU_ADDASSIGNEDVARIABLE, var, scriptid); +} + +inline const wchar_t *ScriptObject::vcpu_getClassName() { + return _call(SCRIPTOBJECT_VCPU_GETCLASSNAME, (const wchar_t *)0); +} + +inline ScriptObjectController *ScriptObject::vcpu_getController() { + ScriptObjectController *__retval = _call(SCRIPTOBJECT_VCPU_GETCONTROLLER, (ScriptObjectController *)NULL); + return __retval; +} + +inline int ScriptObject::vcpu_getScriptId() { + int __retval = _call(SCRIPTOBJECT_VCPU_GETSCRIPTID, (int)0); + return __retval; +} + +inline void ScriptObject::vcpu_setScriptId(int i) { + _voidcall(SCRIPTOBJECT_VCPU_SETSCRIPTID, i); +} + +inline int ScriptObject::vcpu_getMember(const wchar_t *id, int scriptid, int rettype) { + int __retval = _call(SCRIPTOBJECT_VCPU_GETMEMBER, (int)0, id, scriptid, rettype); + return __retval; +} + +inline void ScriptObject::vcpu_delMembers(int scriptid) { + _voidcall(SCRIPTOBJECT_VCPU_DELMEMBERS, scriptid); +} + +inline void ScriptObject::vcpu_setInterface(GUID g, void *v, int interfacetype) { + _voidcall(SCRIPTOBJECT_VCPU_SETINTERFACE, g, v, interfacetype); +} + +inline void ScriptObject::vcpu_setClassName(const wchar_t *name) { + _voidcall(SCRIPTOBJECT_VCPU_SETCLASSNAME, name); +} + +inline void ScriptObject::vcpu_setController(ScriptObjectController *c) { + _voidcall(SCRIPTOBJECT_VCPU_SETCONTROLLER, c); +} + +inline void ScriptObject::vcpu_init() { + _voidcall(SCRIPTOBJECT_VCPU_INIT); +} + +// ---------------------------------------------------------------------------- + +#endif // __SCRIPTOBJECT_H diff --git a/Src/Wasabi/api/script/scriptobji.cpp b/Src/Wasabi/api/script/scriptobji.cpp new file mode 100644 index 00000000..f9cbef46 --- /dev/null +++ b/Src/Wasabi/api/script/scriptobji.cpp @@ -0,0 +1,305 @@ +#include "api.h" +#include +#include +#include + +ScriptObjectI::ScriptObjectI(const wchar_t *class_name, ScriptObjectController *object_controller) +{ + classname = class_name; + controller = object_controller; + cache_count = -1; + membercachegid = -1; + membercachesid = -1; + ingetinterface = 0; + vcpu_init(); +} + +ScriptObjectI::~ScriptObjectI() +{ + assignedVariables.deleteAll(); + memberVariables.deleteAll(); + interfaceslist.deleteAll(); + WASABI_API_MAKI->vcpu_removeScriptObject(this); +} + +void *ScriptObjectI::vcpu_getInterface(GUID g, int *interfacetype) +{ + if (g == scriptObjectGuid) return this; + InterfaceEntry *entry = 0; + int n=0; + while (entry = interfaceslist.enumItem(n++)) + { + if (entry->getGuid() == g) + { + if (interfacetype != NULL) + *interfacetype = entry->getType(); + return entry->getInterface(); + } + } + + if (ingetinterface) return NULL; + ingetinterface = 1; + + void *i = NULL; + ScriptObjectController *c = controller; + //CUT: ScriptObject *no = NULL; + while (i == NULL && c != NULL) + { + i = c->cast(this, g); + if (i != NULL) break; + c = c->getAncestorController(); + } + + if (interfacetype != NULL) + *interfacetype = INTERFACE_SCRIPTOBJECT; + ingetinterface = 0; + return i; +} + +void *ScriptObjectI::vcpu_getInterfaceObject(GUID g, ScriptObject **o) +{ + if (g == scriptObjectGuid) return this; + InterfaceEntry *entry = 0; + int n=0; + while (entry = interfaceslist.enumItem(n++)) + { + if (entry && entry->getGuid() == g) + { + *o = NULL; + return entry->getInterface(); + } + } + if (ingetinterface) return NULL; + ingetinterface = 1; + + void *i = NULL; + ScriptObjectController *c = controller; + //CUT: ScriptObject *no = NULL; + while (i == NULL && c != NULL) + { + i = c->cast(this, g); + if (i != NULL) + { + if (o != NULL) + *o = (ScriptObject *)i; + break; + } + c = c->getAncestorController(); + } + + ingetinterface = 0; + return i; +} + +int ScriptObjectI::vcpu_getAssignedVariable(int start, int scriptid, int functionId, int *next, int *globalevententry, int *inheritedevent) +{ + if (start < 0) start = 0; + if (start >= assignedVariables.getNumItems()) return -1; + for (int i = start;i < assignedVariables.getNumItems();i++) + { + assvar *v = assignedVariables.enumItem(i); + if (WASABI_API_MAKI->vcpu_getCacheCount() != cache_count) + { + if (!WASABI_API_MAKI->vcpu_isValidScriptId(v->scriptid)) + { + vcpu_removeAssignedVariable(v->varid, v->scriptid); + i--; + continue; + } + } + if (scriptid == -1 || v->scriptid == scriptid) + { + int r = getEventForVar(v, functionId, inheritedevent); + if (r == -1) continue; + if (next) *next = i + 1; + if (globalevententry) *globalevententry = r; + return WASABI_API_MAKI->vcpu_mapVarId(v->varid, v->scriptid); + } + } + return -1; +} + +void ScriptObjectI::vcpu_removeAssignedVariable(int var, int id) +{ + for (int i = 0;i < assignedVariables.getNumItems();i++) + { + assvar *v = assignedVariables.enumItem(i); + if (v->varid == var && v->scriptid == id) + { + delete v; + assignedVariables.removeItem(v); + return ; + } + } +} + +void ScriptObjectI::vcpu_addAssignedVariable(int var, int scriptid) +{ + do + { + assvar *v = new assvar; + v->scriptid = scriptid; + v->varid = var; + assignedVariables.addItem(v); + computeEventList(v); + var = WASABI_API_MAKI->vcpu_getUserAncestorId(var, scriptid); + } + while (var != -1); +} + +const wchar_t *ScriptObjectI::vcpu_getClassName() +{ + return classname; +} + +ScriptObjectController *ScriptObjectI::vcpu_getController() +{ + return controller; +} + +int ScriptObjectI::vcpu_getScriptId() +{ + return id; +} + +void ScriptObjectI::vcpu_setScriptId(int i) +{ + id = i; +} + +int ScriptObjectI::vcpu_getMember(const wchar_t *id, int scriptid, int rettype) +{ + if (membercachesid == scriptid && !WCSICMP(membercacheid, id)) + return membercachegid; + membercacheid = id; + membercachesid = scriptid; + for (int i = 0;i < memberVariables.getNumItems();i++) + { + MemberVar *m = memberVariables.enumItem(i); + if (m->getScriptId() == scriptid && !WCSICMP(m->getName(), id)) + { + membercachegid = m->getGlobalId(); + return membercachegid; + } + } + MemberVar *m = new MemberVar(id, scriptid, rettype); + memberVariables.addItem(m); + membercachegid = m->getGlobalId(); + return membercachegid; +} + +void ScriptObjectI::vcpu_delMembers(int scriptid) +{ + for (int i = 0;i < memberVariables.getNumItems();i++) + if (memberVariables.enumItem(i)->getScriptId() == scriptid) + { + delete memberVariables.enumItem(i); + memberVariables.removeByPos(i--); + } +} + +void ScriptObjectI::vcpu_setInterface(GUID g, void *v, int interfacetype) +{ + for (int i = 0;i < interfaceslist.getNumItems();i++) + if (interfaceslist.enumItem(i)->getGuid() == g) + { + InterfaceEntry *p = interfaceslist.enumItem(i); + delete p; + interfaceslist.removeByPos(i); + i--; + } + interfaceslist.addItem(new InterfaceEntry(g, v, interfacetype)); +} + +void ScriptObjectI::vcpu_setClassName(const wchar_t *name) +{ + classname = name; +} + +void ScriptObjectI::vcpu_setController(ScriptObjectController *c) +{ + controller = c; +} + +void ScriptObjectI::vcpu_init() +{ + WASABI_API_MAKI->vcpu_addScriptObject(this); +} + +int ScriptObjectI::getEventForVar(assvar *var, int funcid, int *inheritedevent) +{ + if (WASABI_API_MAKI->vcpu_getCacheCount() != cache_count) + { + for (int i = 0;i < assignedVariables.getNumItems();i++) + { + assvar* ass = assignedVariables.enumItem(i); + // Martin> We need to ensure here that a valid script is called + // There are a few circumstances where the script is already deleted from SOM but we want to call it. + // Example: onMouseWheelDown() in a script embedded in a customobject and another script. + // another script can hide the customobject and thus the custom object's embedded script gets unloaded. + // the old scriptID is still cached and wants to be invoked! this will lead to an guru but the guru cannot be thrown + // since the ScriptID isn't valid anymore. this leads to a nullpointer assert crash. + if (!WASABI_API_MAKI->vcpu_isValidScriptId(ass->scriptid)) + { + continue; + } + computeEventList(ass); + } + cache_count = WASABI_API_MAKI->vcpu_getCacheCount(); + } + TList *list = &var->dlfs; + for (int i = 0;i < list->getNumItems();i += 4) + if (list->enumItem(i) == funcid && list->enumItem(i + 1) == var->varid) + { + *inheritedevent = list->enumItem(i + 3); + return list->enumItem(i + 2); + } + + return -1; +} + +void ScriptObjectI::computeEventList(assvar *a) +{ + a->dlfs.removeAll(); + + int dlfid; + int scriptid; + int varid; + + int var = a->varid; + int inheritedevent = 0; + + do + { + for (int i = 0;i < WASABI_API_MAKI->vcpu_getNumEvents();i++) + { + WASABI_API_MAKI->vcpu_getEvent(i, &dlfid, &scriptid, &varid); + if (scriptid == a->scriptid && varid == var) + { + a->dlfs.addItem(dlfid); + a->dlfs.addItem(varid); + a->dlfs.addItem(i); + a->dlfs.addItem(inheritedevent); + } + } + var = WASABI_API_MAKI->vcpu_getUserAncestorId(var, a->scriptid); + inheritedevent = 1; + } + while (var != -1); +} + + + +ScriptObjectI::MemberVar::MemberVar(const wchar_t *_name, int _scriptid, int _rettype) +{ + name = _name; + rettype = _rettype; + scriptid = _scriptid; + globalid = WASABI_API_MAKI->maki_createOrphan(rettype); +} + +ScriptObjectI::MemberVar::~MemberVar() +{ + WASABI_API_MAKI->maki_killOrphan(globalid); // heh :) +} + diff --git a/Src/Wasabi/api/script/scriptobji.h b/Src/Wasabi/api/script/scriptobji.h new file mode 100644 index 00000000..2a2aaf77 --- /dev/null +++ b/Src/Wasabi/api/script/scriptobji.h @@ -0,0 +1,134 @@ +#ifndef __SCRIPTOBJI_H +#define __SCRIPTOBJI_H + +#include +#include + +#include +#include +#include + +// +#include "scriptobj.h" +#include "scriptobjx.h" + +class ScriptHook; +class ScriptObject; +class ScriptObjectController; + +//?> + + +class ScriptObjectController; +class ScriptHook; + +/*[interface.header.h] +enum { + INTERFACE_GENERICVOIDPTR=0, + INTERFACE_SCRIPTOBJECT, +}; +*/ + +// ---------------------------------------------------------------------------------------------------------- + +/*class MemberVarCompare { + public: + static int compareItem(void *p1, void *p2); + static int compareAttrib(const wchar_t *attrib, void *p); +};*/ + +// ---------------------------------------------------------------------------------------------------------- + + + + +// ---------------------------------------------------------------------------------------------------------- + +class ScriptObjectI : public ScriptObjectX +{ +private: + /* These three classes are here to ensure they don't get used anywhere else */ + struct assvar + { + int scriptid; + int varid; + TList dlfs; + }; + + class InterfaceEntry + { + public: + InterfaceEntry(GUID _guid, void *_ptr, int _type = INTERFACE_GENERICVOIDPTR) : guid(_guid), ptr(_ptr), type(_type) {} + virtual ~InterfaceEntry() {} + + virtual GUID getGuid() { return guid; } + virtual void *getInterface() { return ptr; } + virtual int getType() { return type; } + + private: + + GUID guid; + void *ptr; + int type; +}; + + class MemberVar + { + public: + MemberVar(const wchar_t *name, int scriptid, int rettype); + virtual ~MemberVar(); + + const wchar_t *getName() { return name; } + int getScriptId() { return scriptid; } + int getReturnType() { return rettype; } + int getGlobalId() { return globalid; } + + private: + StringW name; + int scriptid; + int rettype; + int globalid; +}; + + +public: + ScriptObjectI(const wchar_t *class_name = NULL, ScriptObjectController *object_controller = NULL); + virtual ~ScriptObjectI(); + + DISPATCH(50) virtual void *vcpu_getInterface(GUID g, int *interfacetype = NULL); + DISPATCH(60) virtual void *vcpu_getInterfaceObject(GUID g, ScriptObject **o); + DISPATCH(100) int vcpu_getAssignedVariable(int start, int scriptid, int functionId, int *next, int *globalevententry, int *inheritedevent); + DISPATCH(200) void vcpu_removeAssignedVariable(int var, int id); + DISPATCH(300) void vcpu_addAssignedVariable(int var, int scriptid); + DISPATCH(400) virtual const wchar_t *vcpu_getClassName(); + DISPATCH(500) virtual ScriptObjectController *vcpu_getController(); +// DISPATCH(600) virtual void vcpu_addClassHook(ScriptHook *h); +// DISPATCH(700) virtual void vcpu_addObjectHook(ScriptHook *h); + DISPATCH(800) int vcpu_getScriptId(); + DISPATCH(900) void vcpu_setScriptId(int i); + DISPATCH(1000) int vcpu_getMember(const wchar_t *id, int scriptid, int rettype); + DISPATCH(1100) void vcpu_delMembers(int scriptid); + DISPATCH(1200) virtual void vcpu_setInterface(GUID g, void *v, int interfacetype = INTERFACE_SCRIPTOBJECT); + DISPATCH(1300) virtual void vcpu_setClassName(const wchar_t *name); + DISPATCH(1400) virtual void vcpu_setController(ScriptObjectController *c); + DISPATCH(1500) virtual void vcpu_init(); + +protected: + NODISPATCH int getEventForVar(assvar *var, int funcid, int *inheritedevent); + NODISPATCH void computeEventList(assvar *a); + PtrList < assvar > assignedVariables; + PtrList < MemberVar > memberVariables; + int cache_count; + int id; + StringW membercacheid; + int membercachesid; + int membercachegid; + PtrList < InterfaceEntry > interfaceslist; + const wchar_t *classname; + ScriptObjectController * controller; + int ingetinterface; + + +}; + +#endif diff --git a/Src/Wasabi/api/script/scriptobjx.cpp b/Src/Wasabi/api/script/scriptobjx.cpp new file mode 100644 index 00000000..e9a0bbcb --- /dev/null +++ b/Src/Wasabi/api/script/scriptobjx.cpp @@ -0,0 +1,34 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Thu May 15 21:09:18 2003] +// +// File : scriptobjx.cpp +// Class : ScriptObject +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- +#include "scriptobjx.h" +#include "scriptobji.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif + +#define CBCLASS ScriptObjectX +START_DISPATCH; + CB(SCRIPTOBJECT_VCPU_GETINTERFACE, vcpu_getInterface); + CB(SCRIPTOBJECT_VCPU_GETINTERFACEOBJECT, vcpu_getInterfaceObject); + CB(SCRIPTOBJECT_VCPU_GETASSIGNEDVARIABLE, vcpu_getAssignedVariable); + VCB(SCRIPTOBJECT_VCPU_REMOVEASSIGNEDVARIABLE, vcpu_removeAssignedVariable); + VCB(SCRIPTOBJECT_VCPU_ADDASSIGNEDVARIABLE, vcpu_addAssignedVariable); + CB(SCRIPTOBJECT_VCPU_GETCLASSNAME, vcpu_getClassName); + CB(SCRIPTOBJECT_VCPU_GETCONTROLLER, vcpu_getController); + CB(SCRIPTOBJECT_VCPU_GETSCRIPTID, vcpu_getScriptId); + VCB(SCRIPTOBJECT_VCPU_SETSCRIPTID, vcpu_setScriptId); + CB(SCRIPTOBJECT_VCPU_GETMEMBER, vcpu_getMember); + VCB(SCRIPTOBJECT_VCPU_DELMEMBERS, vcpu_delMembers); + VCB(SCRIPTOBJECT_VCPU_SETINTERFACE, vcpu_setInterface); + VCB(SCRIPTOBJECT_VCPU_SETCLASSNAME, vcpu_setClassName); + VCB(SCRIPTOBJECT_VCPU_SETCONTROLLER, vcpu_setController); + VCB(SCRIPTOBJECT_VCPU_INIT, vcpu_init); +END_DISPATCH; +#undef CBCLASS + diff --git a/Src/Wasabi/api/script/scriptobjx.h b/Src/Wasabi/api/script/scriptobjx.h new file mode 100644 index 00000000..b34fc4ad --- /dev/null +++ b/Src/Wasabi/api/script/scriptobjx.h @@ -0,0 +1,44 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Thu May 15 21:09:17 2003] +// +// File : scriptobjx.h +// Class : ScriptObject +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- + +#ifndef __SCRIPTOBJECTX_H +#define __SCRIPTOBJECTX_H + +#include "scriptobj.h" + +class ScriptHook; +class ScriptObject; +class ScriptObjectController; + +// ---------------------------------------------------------------------------- + +class ScriptObjectX : public ScriptObject { + protected: + ScriptObjectX() {} + public: + virtual void *vcpu_getInterface(GUID g, int *interfacetype = NULL)=0; + virtual void *vcpu_getInterfaceObject(GUID g, ScriptObject **o)=0; + virtual int vcpu_getAssignedVariable(int start, int scriptid, int functionId, int *next, int *globalevententry, int *inheritedevent)=0; + virtual void vcpu_removeAssignedVariable(int var, int id)=0; + virtual void vcpu_addAssignedVariable(int var, int scriptid)=0; + virtual const wchar_t *vcpu_getClassName()=0; + virtual ScriptObjectController *vcpu_getController()=0; + virtual int vcpu_getScriptId()=0; + virtual void vcpu_setScriptId(int i)=0; + virtual int vcpu_getMember(const wchar_t *id, int scriptid, int rettype)=0; + virtual void vcpu_delMembers(int scriptid)=0; + virtual void vcpu_setInterface(GUID g, void *v, int interfacetype = INTERFACE_SCRIPTOBJECT)=0; + virtual void vcpu_setClassName(const wchar_t *name)=0; + virtual void vcpu_setController(ScriptObjectController *c)=0; + virtual void vcpu_init()=0; + + protected: + RECVS_DISPATCH; +}; + +#endif // __SCRIPTOBJECTX_H diff --git a/Src/Wasabi/api/script/scriptvar.h b/Src/Wasabi/api/script/scriptvar.h new file mode 100644 index 00000000..0b225a50 --- /dev/null +++ b/Src/Wasabi/api/script/scriptvar.h @@ -0,0 +1,35 @@ +#ifndef __SCRIPTVAR_H +#define __SCRIPTVAR_H + +#ifdef __cplusplus + class ScriptObject; +#endif + +#ifdef _MSC_VER +#pragma pack(push, 1) +#else +#pragma pack(1) +#endif + +typedef struct { + int type; // basic type, see above + union { // union of 4 bytes of different types + int idata; // Integer + float fdata; // Float + double ddata; // Double +#ifdef __cplusplus + ScriptObject *odata; // Object +#else + void *odata; +#endif + const wchar_t *sdata; // String + } data; +} scriptVar; + +#ifdef _MSC_VER +#pragma pack(pop) +#else +#pragma pack() +#endif + +#endif diff --git a/Src/Wasabi/api/script/vcpu.cpp b/Src/Wasabi/api/script/vcpu.cpp new file mode 100644 index 00000000..1002ee57 --- /dev/null +++ b/Src/Wasabi/api/script/vcpu.cpp @@ -0,0 +1,2069 @@ +#include +#include +#include +#include +#include +#include "vcpu.h" +#include "opcodes.h" +#include +#include +#include +#include +#include "../nu/AutoWide.h" + +ScriptObjectManager *VCPU::scriptManager = NULL; + +void VCPU::shutdown() +{ + foreach(globalDlfList) + FREE(globalDlfList.getfor()->functionName); + delete globalDlfList.getfor(); + endfor + globalDlfList.removeAll(); + atoms.deleteAll(); +} + +// ------------------------------------------------------------- +void VCPU::push(VCPUscriptVar v) { + CpuStack.push(v); + VSP++; +} + +// ------------------------------------------------------------- +void VCPU::push(scriptVar v) { + VCPUscriptVar _v; + _v.v = v; + CpuStack.push(_v); + VSP++; +} + +void VCPU::RemoveOldScripts() +{ + while (scriptsToRemove.getNumItems()) + { + int id = scriptsToRemove.getFirst(); + VCPU::removeScript(id); + scriptsToRemove.delByPos(0); + } +} + +// ------------------------------------------------------------- +VCPUscriptVar VCPU::pop() { + if (VSP <= 0) { + Script::guruMeditation(SOM::getSystemObjectByScriptId(VSD), GURU_POPEMPTYSTACK); + VCPUscriptVar v; + MEMSET(&v, 0, sizeof(v)); + return v; +// ASSERT(0); + } + VCPUscriptVar v; + CpuStack.pop(&v); + VSP--; + if (VSP == 0) + VCPU::RemoveOldScripts(); // benski> TODO: dunno if this is the best place for this + return v; +} + +// ------------------------------------------------------------- +VCPUscriptVar VCPU::peekAt(int n) { + if (VSP <= n) { + Script::guruMeditation(SOM::getSystemObjectByScriptId(VSD), GURU_INVALIDPEEKSTACK); + VCPUscriptVar v; + MEMSET(&v, 0, sizeof(v)); + return v; +// ASSERT(0); + } + VCPUscriptVar v={0,{0},0}; + CpuStack.peekAt(&v, n); + return v; +} + +// ------------------------------------------------------------- +int VCPU::assignNewScriptId() { + return numScripts++; +} + +// ------------------------------------------------------------- +int VCPU::oldClassToClassId(int id) { + if (id < SCRIPT_OBJECT) return id; + if (id >= 0x10000) return id; + switch (id) { + case 7 : return ObjectTable::getClassFromName(L"Object"); + case 8 : return ObjectTable::getClassFromName(L"SystemObject"); + case 9 : return ObjectTable::getClassFromName(L"Container"); + case 10: return ObjectTable::getClassFromName(L"Layout"); + case 11: return ObjectTable::getClassFromName(L"Button"); + case 12: return ObjectTable::getClassFromName(L"Slider"); + case 13: return ObjectTable::getClassFromName(L"Text"); + case 14: return ObjectTable::getClassFromName(L"Image"); + case 15: return ObjectTable::getClassFromName(L"Anim"); + case 16: return ObjectTable::getClassFromName(L"Vis"); + case 17: return ObjectTable::getClassFromName(L"Component"); + case 18: return ObjectTable::getClassFromName(L"ToggleButton"); + case 19: return ObjectTable::getClassFromName(L"Timer"); + case 20: return ObjectTable::getClassFromName(L"Layer"); + case 21: return ObjectTable::getClassFromName(L"GuiObject"); + case 22: return ObjectTable::getClassFromName(L"AnimatedLayer"); + case 23: return ObjectTable::getClassFromName(L"Browser"); + case 24: return ObjectTable::getClassFromName(L"Edit"); + case 25: return ObjectTable::getClassFromName(L"Map"); + case 26: return ObjectTable::getClassFromName(L"Popup"); + case 27: return ObjectTable::getClassFromName(L"Title"); + case 28: return ObjectTable::getClassFromName(L"ComponentBucket"); + case 29: return ObjectTable::getClassFromName(L"Status"); + case 30: return ObjectTable::getClassFromName(L"Region"); + case 31: return ObjectTable::getClassFromName(L"Wac"); + case 32: return ObjectTable::getClassFromName(L"List"); + case 33: return ObjectTable::getClassFromName(L"SBitList"); + case 34: return ObjectTable::getClassFromName(L"SEqVis"); + default: Script::guruMeditation(NULL, GURU_INVALIDOLDID, L"xlat error", id); + break; + } + return SCRIPT_INT; // heh =) +} + + +// ------------------------------------------------------------- +int VCPU::addScript(void *mem, int memsize, int id) { + + int i,j; + int translateobjects = 0; + + char *p = (char *)mem; + + int hdr=0; + if (!MEMCMP(p, "FG\x03\x04\x14\00\00\00\00", 8)) + hdr=1; + else if (!MEMCMP(p, "FG\x03\x04\x15\00\00\00\00", 8)) + hdr=2; + else if (!MEMCMP(p, "FG\x03\x04\x16\00\00\00\00", 8)) + hdr=3; + else if (!MEMCMP(p, "FG\x03\x04\x17\00\00\00\00", 8)) + hdr=4; + else if (!MEMCMP(p, "FG\x03\x04", 4)) { + if (*(p+4) > 0x17) + hdr = -1; + } + + switch (hdr) { + case -1: + Script::guruMeditation(SOM::getSystemObjectByScriptId(id), GURU_FUTUREFORMAT, L"NEED LATEST VERSION"); + return -1; + case 0: + Script::guruMeditation(SOM::getSystemObjectByScriptId(id), GURU_INVALIDHEADER); + return -1; + case 1: + Script::guruMeditation(SOM::getSystemObjectByScriptId(id), GURU_OLDFORMAT, L"DEPRECATED BINARY"); + return -1; + case 2: + translateobjects=1; + break; + case 3: + case 4: + break; + } + + SOM::getSystemObjectByScriptId(id)->setIsOldFormat(translateobjects); + + p+=8; + + TList *typetable = SOM::getSystemObjectByScriptId(id)->getTypesList(); + typetable->removeAll(); + + if (!translateobjects) { + + int nGuids = *(int *)p; + p+=sizeof(int); + + for (int z=0;zaddItem(t); + } + } + + // ------------------------------------------------------------- + // Load DLF Table + + int DLFEntryBase = DLFentryTable.getNumItems(); + + int nDLFentries = *(int *)p; + p+=sizeof(int); + + for (i=0;i= CLASS_ID_BASE && basetype < 0x10000) + basetype = typetable->enumItem(basetype - CLASS_ID_BASE); + + if (basetype == -1) { +//CUT!!!! so annoying Std::messageBox("Error while loading a script, a component is missing", "Oops", 0); + DebugStringW(L"Tried to link DLF %d (class entry %d) but the class isn't here\n", i, pt - CLASS_ID_BASE); + //return -1; + } + + type = basetype; + + uint16_t stringLen = *(uint16_t *)p; + p+=sizeof(uint16_t); + char functionName[65536+1] = {0}; + MEMCPY(functionName, p, stringLen); + functionName[stringLen]=0; + p+=stringLen; + + // check if entry seems valid + + if (!*functionName) { + Script::guruMeditation(SOM::getSystemObjectByScriptId(id), GURU_INVALIDFUNCINDLF); +// api->messageBox("Invalid function name in DLF table", "Script Error", MSGBOX_OK, NULL, NULL); + return -1; + } + + // ok, register this function + VCPUdlfEntry *e = new VCPUdlfEntry; + e->basetype = type; +#ifdef _WIN32 + int size = MultiByteToWideChar(CP_UTF8, 0, functionName, -1, 0,0); + if (size) + { + wchar_t *wide = (wchar_t *)MALLOC(size*sizeof(wchar_t)); + MultiByteToWideChar(CP_UTF8, 0, functionName, -1, wide,size); + e->functionName = wide; + } + else + e->functionName = 0; +#else + e->functionName = WCSDUP(AutoWide(functionName)); +#warning port me +#endif + e->scriptId = id; + // insert safe values + e->nparams = -1; + e->DLFid = -1; + e->ptr = NULL; + DLFentryTable.addItem(e); + + setupDLF(e, DLFEntryBase); + + } + + // ------------------------------------------------------------- + // Load VAR Table + + int variableBase = variablesTable.getNumItems(); + + int nVariables = *(int *)p; + p+=sizeof(int); + + for (i=0;iisaclass = 0; + + if (e.type >= 0x10000) { + int type = e.type; + int id; + + do { + id = type - 0x10000; + VCPUscriptVar *v = variablesTable.enumItem(id+variableBase); + v->isaclass = 1; + type = v->v.type; + } while (type >= 0x10000); + + } + + if (translateobjects) { + e.type = oldClassToClassId(e.type); + } else + if (e.type >= CLASS_ID_BASE && e.type < 0x10000) + e.type = typetable->enumItem(e.type - CLASS_ID_BASE); + + v->scriptId = id; + v->varId = i; + v->transcient = (*p++ == 0); + if (hdr >= 4) + v->isstatic = *p++; + else + v->isstatic = 0; + + if (hdr < 4) { + // Autoassign system variables + if (e.type == ObjectTable::getClassFromName(L"SystemObject")) { + SystemObject *so = SOM::getSystemObjectByScriptId(id); + if (so) e.data.odata = so->getScriptObject(); else e.data.odata = NULL; + } + } else { + if (v->isstatic && e.type == ObjectTable::getClassFromName(L"SystemObject")) { + SystemObject *so = SOM::getSystemObjectByScriptId(id); + if (so) e.data.odata = so->getScriptObject(); else e.data.odata = NULL; + v->isstatic = 0; // disable deletion + } else if (v->isstatic) { + // Autoassign class variables + e.data.odata = ObjectTable::instantiate(e.type); + if (e.data.odata) + e.data.odata->vcpu_setScriptId(VSD); + } + } + + if (e.type == SCRIPT_STRING) + { + wchar_t *emptyString = WMALLOC(1); + emptyString[0]=0; + e.data.sdata = emptyString; + } + + if (e.type == SCRIPT_DOUBLE) + e.data.ddata = e.data.fdata; + + v->v = e; + variablesTable.addItem(v); + } + + // ------------------------------------------------------------- + // Load Strings into string vars + + int nStrings = *(int *)p; + p+=sizeof(int); + + j=0; + //CUT: int count=0; + + char string_buf[65536+1] = {0}; + for (i=0;iv.data.sdata)); + // strings are stored in UTF-8, but we're using UTF-16 here +#ifdef _WIN32 + int size = MultiByteToWideChar(CP_UTF8, 0, string_buf, -1, 0,0); + if (size) + { + wchar_t *wide = (wchar_t *)MALLOC(size*sizeof(wchar_t)); + MultiByteToWideChar(CP_UTF8, 0, string_buf, -1, wide,size); + v->v.data.sdata = wide; + } + else + v->v.data.sdata = 0; + +#else +#warning port me + // TODO: benski> change to do one malloc + v->v.data.sdata = WCSDUP(AutoWide(string_buf)); +#endif + //FREE(string); + + } + + + // ------------------------------------------------------------- + // Load Events into table + + int nEvents = *(int *)p; + p+=sizeof(int); + + for (i=0;i= nDLFentries || DLFentry < 0) { +// api->messageBox("Invalid event DLF descriptor", "Script Error", MSGBOX_OK, NULL, NULL); + Script::guruMeditation(SOM::getSystemObjectByScriptId(id), GURU_INVALIDEVENTDLF); + return -1; + } + + if (pointer < 0) { +// api->messageBox("Invalid event address", "Script Error", MSGBOX_OK, NULL, NULL); + Script::guruMeditation(SOM::getSystemObjectByScriptId(id), GURU_INVALIDEVENTADDR); + return -1; + } + + if (varId < 0 || varId >= nVariables) { +// api->messageBox("Invalid event variable", "Script Error", MSGBOX_OK, NULL, NULL); + Script::guruMeditation(SOM::getSystemObjectByScriptId(id), GURU_INVALIDEVENTVAR); + return -1; + } + + // insert event into table + + VCPUeventEntry *e = new VCPUeventEntry; + //e->DLFentry = DLFentry + DLFEntryBase; + e->DLFid = DLFentryTable.enumItem(DLFEntryBase+DLFentry)->DLFid; + e->pointer = pointer; + e->scriptId = id; + e->varId = varId; + + eventsTable.addItem(e); + } + + // ------------------------------------------------------------- + // Load Code block into code table + + int codeSize = *(int *)p; + p+=sizeof(int); + VCPUcodeBlock *c = new VCPUcodeBlock; + c->codeBlock = p; + c->dlfBase = DLFEntryBase; + c->varBase = variableBase; + c->scriptId = id; + c->size = codeSize; + + codeTable.addItem(c); + + SystemObject *so = SOM::getSystemObjectByScriptId(id); + if (so) { + ScriptObject *sso = so->getScriptObject(); + if (sso) + sso->vcpu_addAssignedVariable(0, id); + } + + cacheCount++; + + c->debugsymbols = c->codeBlock+codeSize; + c->debugsize = memsize - (c->debugsymbols-(char *)mem); + + //WASABI_API_MAKIDEBUG->debugger_createJITD(id); // fucko !! + + return id; +} + + +// ------------------------------------------------------------- +int VCPU::varBase(int scriptId) { + static int lasti=-1;; + static int lastb=0; + static int lastid=0; + if (lastid == scriptId && lasti>=0 && lasti < codeTable.getNumItems()) { + if (lastid == codeTable.enumItem(lasti)->scriptId) + return lastb; + } + for (int i=0;iscriptId == scriptId) { + lasti = i; + lastid = scriptId; + lastb = codeTable.enumItem(i)->varBase; + return lastb; + } + } + Script::guruMeditation(SOM::getSystemObjectByScriptId(scriptId), GURU_INVALIDSCRIPTID); + ASSERT(0); + return 0; +} + +// ------------------------------------------------------------- +int VCPU::nVars(int scriptId) { + for (int i=0;iscriptId == scriptId) { + if (codeTable.getNumItems() == i+1) + return variablesTable.getNumItems() - codeTable.enumItem(i)->varBase; + return codeTable.enumItem(i+1)->varBase - codeTable.enumItem(i)->varBase; + } + } + Script::guruMeditation(SOM::getSystemObjectByScriptId(scriptId), GURU_INVALIDSCRIPTID); + ASSERT(0); + return 0; +} + +// ------------------------------------------------------------- +int VCPU::dlfBase(int scriptId) { + for (int i=0;iscriptId == scriptId) + return codeTable.enumItem(i)->dlfBase; + } + Script::guruMeditation(SOM::getSystemObjectByScriptId(scriptId), GURU_INVALIDSCRIPTID); + ASSERT(0); + return 0; +} + +// ------------------------------------------------------------- +void VCPU::removeScript(int id) +{ +// ASSERTPR(VCPU::VSP==0, "Can't unload script while in script"); + if (VCPU::VSP != 0) + { + scriptsToRemove.addItem(id); + return; + } + + SystemObject *s = SOM::getSystemObjectByScriptId(id); + if (s) + { + s->onUnload(); + delete s; + } + + PtrList *l = SystemObject::getAllScriptObjects(); + int i; + for (i=0;igetNumItems();i++) { + ScriptObject *o = l->enumItem(i); + o->vcpu_delMembers(id); + } + + int dlfdeleted=0; + int vardeleted=0; + + for (i=0;iscriptId == id) { + delrefDLF(DLFentryTable.enumItem(i)); + if (DLFentryTable.enumItem(i)->functionName) + FREE(DLFentryTable.enumItem(i)->functionName); + delete DLFentryTable.enumItem(i); + DLFentryTable.delByPos(i); + dlfdeleted++; + i--; + } + } + + for (i=0;iscriptId == id) { + delete eventsTable.enumItem(i); + eventsTable.delByPos(i); + i--; + } + } + + for (i=0;iscriptId == id) { + VCPUscriptVar *v = variablesTable.enumItem(i); + if (v->isstatic && v->v.type) { + ObjectTable::destroy(v->v.data.odata); + } + if (v->v.type == SCRIPT_STRING) + if (v->v.data.sdata) + FREE((wchar_t *)v->v.data.sdata); + delete v; + variablesTable.delByPos(i); + vardeleted++; + i--; + } + } + + for (i=0;iscriptId == id) { + VCPUcodeBlock *b = codeTable.enumItem(i); + delete b; + codeTable.removeByPos(i); + for (;idlfBase-=dlfdeleted; + codeTable.enumItem(i)->varBase-=vardeleted; + } + } + } + + + cacheCount++; +} + +// ------------------------------------------------------------- +// Find next matching object, starting from start +int VCPU::findObject(ScriptObject *o, int start, int dlfid, int vcpuid) { +/* int stop; + if (vcpuid != -1) { + int b = varBase(vcpuid); + if (start < b) + start = b; + stop = b + nVars(vcpuid); + } else { + stop = variablesTable.getNumItems(); + if (start < 0) + start = 0; + }*/ + +/* while (start < stop) { + VCPUscriptVar *v = variablesTable.enumItem(start); + if (v->v.data.odata == o && !v->transcient && (vcpuid == -1 || v->scriptId == vcpuid)) + return start; + start++; + }*/ + return -1; +} + + + +// ------------------------------------------------------------- +// Assign DLF functionId to class exported functions, starting from the last non initialized DLF +void VCPU::setupDLF(VCPUdlfEntry *e, int dlfEntryBase) { + if (ObjectTable::addrefDLF(e, highestDLFId)) { + newDlf(); + } + +} + +int VCPU::newDlf() { + return highestDLFId++; +} + +void VCPU::resetDlf() { + highestDLFId = 0; +} + +void VCPU::registerGlobalDlf(VCPUdlfEntry *e, int dlf) { + ASSERT(dlf == globalDlfList.getNumItems()); + VCPUdlfEntry *_e = new VCPUdlfEntry; + MEMCPY(_e, e, sizeof(VCPUdlfEntry)); + _e->functionName = WCSDUP(e->functionName); + globalDlfList.addItem(_e); +} + +void VCPU::delrefDLF(VCPUdlfEntry *e) { + ObjectTable::delrefDLF(e); +} + +// ------------------------------------------------------------- + +TList VCPU::plist; + +// ------------------------------------------------------------- +int VCPU::runEvent(VCPUeventEntry *e, int np, int pbase) { + +#ifdef WASABI_COMPILE_MAKIDEBUG + /*if (WASABI_API_MAKIDEBUG && WASABI_API_MAKIDEBUG->debugger_isActive()) { + if (WASABI_API_MAKIDEBUG->debugger_filterEvent(e->scriptId, e->DLFid)) { + DebugString("Skipping event\n"); + scriptVar v; + v.type = SCRIPT_INT; + v.data.idata = 0; + VCPU::push(v); + return 1; + } + }*/ +#endif + + for (int z=0;zscriptId, e->pointer, np); + +#ifdef WASABI_COMPILE_MAKIDEBUG +/* if (WASABI_API_MAKIDEBUG && WASABI_API_MAKIDEBUG->debugger_isActive()) + WASABI_API_MAKIDEBUG->debugger_eventComplete();*/ +#endif + + return 1; +} + +// This is the function that actually executes the event. In the future, it will sequencially parse all loaded scripts in reversed load order and stop +// either at the end of the chain OR as soon as one of the event used "complete;" in its code + +// ------------------------------------------------------------- +scriptVar VCPU::executeEvent(scriptVar v, int functionId, int np, int vcpuid) { + + VCPUscriptVar retvar={0,{0},0}; + int pbase = plist.getNumItems(); + + int varId=0; + + complete = 0; + + for (int z=0;zvcpu_getAssignedVariable(next, vcpuid, functionId, &next, &event, &inheritedevent); + + if (varId < 0) break; + + VCPUscriptVar *vc = variablesTable.enumItem(varId); + ScriptObject *thisobject = (ScriptObject *)v.data.odata; + + VCPUeventEntry *e = eventsTable.enumItem(event); + + int r_varId = varId; + + if (!vc->isaclass && !inheritedevent) { + if (e && runEvent(e, np, pbase)) + retvar = pop(); + if (getComplete()) + break; + } + + while (vc->isaclass) { + ASSERT(r_varId < variablesTable.getNumItems()); + vclass = variablesTable.enumItem(r_varId); + vclass->v.data.odata = thisobject; + + if (runEvent(e, np, pbase)) + retvar = pop(); + + if (getComplete()) + break; + + vc = vclass; + if (vc->varId < 0x10000) break; + r_varId = varBase(vc->scriptId) + vc->v.type - 0x10000; + } + + if (getComplete()) + break; + + varId++; + } + + for (int i=0;iv); + double _v2=SOM::makeDouble(&v2->v); + if (_v2 != 0.0) + _r = _v1 / _v2; + else + Script::guruMeditation(SOM::getSystemObjectByScriptId(v1->scriptId), GURU_DIVBYZERO, L"Division by zero"); + + scriptVar r = SOM::makeVar(SCRIPT_DOUBLE); + SOM::assign(&r, _r); + return r; +} + +/* + +Registers : + +VIP : Instruction Pointer +VSP : Stack Pointer +VSD : Script Descriptor (ID of script we're in) + + +CALLM calls member function, pops a variable ID and a DLF entry, and pushs the result of +the function. CallC calls an address, so pushs the return address on its stack +(independant from the Push/Pop stack), and jumps to the code. Ret gets the last +address pushed and returns there. JIZ jumps to an address if the first value on the stack +is an int zero. JMP jumps unconditionnaly. + +The stack is a stack of 4 bytes integers containing scriptVar IDs. +Var IDs from binaries are being added the base ID of the current script so we +have only one variables segment for all scripts. Same for DLF entries. Events +aren't references in the bytecode other than in the event table that links +addresses in code to DLF entries, so we don't need that kind of tweaking. + +*/ + +// ------------------------------------------------------------- +char *VCPU::getCodeBlock(int id, int *size) { + for (int i=0;iscriptId == id) { + if (size != NULL) *size = codeTable.enumItem(i)->size; + return codeTable.enumItem(i)->codeBlock; + } + } + return NULL; +} + +// ------------------------------------------------------------- +VCPUcodeBlock *VCPU::getCodeBlockEntry(int id) { + for (int i=0;iscriptId == id) { + return codeTable.enumItem(i); + } + } + return NULL; +} + +// ------------------------------------------------------------- +void VCPU::runCode(int scriptId, int pointer, int np) { + int quit=0; + VIP = pointer; + VSD = scriptId; + +#ifdef WASABI_COMPILE_MAKIDEBUG + int debugger_present = debugApi ? debugApi->debugger_isActive() : 0; +#endif + + char *codeblock = (char *)getCodeBlock(VSD); + char *p = codeblock + VIP; + unsigned char opcode; + + int stackbase = VSP-np; + int callcbase = CallStack.peek(); + VCC = callcbase; + + while (!quit) { +#ifdef WASABI_COMPILE_MAKIDEBUG + if (debugger_present) { + VIPstack.push(VIP); + VSDstack.push(VSD); +// VSPstack.push(VSP); + VCCstack.push(VCC); + debugApi->debugger_trace(); + VIPstack.pop(&VIP); + VSDstack.pop(&VSD); +// VSPstack.pop(&VSP); + VCCstack.pop(&VCC); + } +#endif + opcode = *p; + p+=sizeof(opcode); + VIP+=sizeof(opcode); + + switch (opcode) { + case OPCODE_PUSH: { + int id; // var id + id = *(int *)p; + p+=sizeof(int); VIP+=sizeof(int); + VCPUscriptVar *var = variablesTable.enumItem(id+varBase(VSD)); + push(*var); + break; + } + case OPCODE_POPI: { + pop(); // discard + if (VSP == stackbase) + statementStringList.freeAll(); + break; + } + case OPCODE_POP: { + int id = *(int *)p; // var id + p+=sizeof(int); VIP+=sizeof(int); + VCPUscriptVar v = pop(); + VCPUassign(id, v.v, VSD); + break; + } + case OPCODE_SET: { + VCPUscriptVar v2 = pop(); + VCPUscriptVar v1 = pop(); + if (v1.varId == -1) { + Script::guruMeditation(SOM::getSystemObjectByScriptId(VSD), GURU_SETNONINTERNAL); + ASSERT(0); + } + scriptVar r = VCPUassign(v1.varId, v2.v, VSD); + push(r); + break; + } + case OPCODE_RETF: { + if (/*VSP == stackbase+1 && */CallStack.peek() == callcbase) { + quit = 1; + break; + } + CallStack.pop(&p); + VIP = p-(char *)getCodeBlock(VSD); + break; + } + case OPCODE_CALLC: { + int shift; // jump length + shift = *(int *)p; + p+=sizeof(int); VIP+=sizeof(int); + CallStack.push(p); + VCC++; + p+=shift; + VIP+=shift; + break; + } + case OPCODE_CALLM: { + int id; // DLF id + id = *(int *)p; + p+=sizeof(int); VIP+=sizeof(int); + VCPUdlfEntry *e = DLFentryTable.enumItem(id+dlfBase(VSD)); + int np = *(int *)p; + // OLD stack protection - was relying on a shody test based on the fact that the compiler should not be able to generate two FF's at this offset, replaced by new opcode but remains for backward compatibility + if ((np & 0xFFFF0000) == 0xFFFF0000) { + p += sizeof(int); + VIP += sizeof(int); + np &= 0xFFFF; + } else np = -1; + scriptVar r = callDLF(e, np); + VCPUscriptVar vr; + vr.scriptId = VSD; + vr.varId = -1; + vr.v = r; + push(vr); + break; + } + case OPCODE_CALLM2: { + int id; // DLF id + id = *(int *)p; + p+=sizeof(int); VIP+=sizeof(int); + VCPUdlfEntry *e = DLFentryTable.enumItem(id+dlfBase(VSD)); + int np = *(unsigned char *)p; p++; VIP+=1; + scriptVar r = callDLF(e, np); + VCPUscriptVar vr; + vr.scriptId = VSD; + vr.varId = -1; + vr.v = r; + push(vr); + break; + } + case OPCODE_UMV: + { + VCPUscriptVar name = pop(); + VCPUscriptVar obj = pop(); + ASSERT(obj.v.data.odata!=NULL); + ASSERT(name.v.data.sdata!=NULL); + + int rettype = *(int *)p; + p+=sizeof(int); VIP+=sizeof(int); + + if (rettype >= CLASS_ID_BASE) { + SystemObject *so = SOM::getSystemObjectByScriptId(VSD); + TList *typeslist = so->getTypesList(); + rettype = typeslist->enumItem(rettype - CLASS_ID_BASE); + } + + int oid = ((ScriptObject *)obj.v.data.odata)->vcpu_getMember(name.v.data.sdata, VSD, rettype); + VCPUscriptVar *v = getOrphan(oid); + ASSERT(v != NULL); + push(*v); + break; + } + case OPCODE_CMPEQ: { + VCPUscriptVar v2 = pop(); + VCPUscriptVar v1 = pop(); + VCPUscriptVar r; + r.v = SOM::makeVar(SCRIPT_INT); + SOM::assign(&r.v, SOM::compEq(&v1.v, &v2.v)); + push(r); + break; + } + case OPCODE_CMPNE: { + VCPUscriptVar v2 = pop(); + VCPUscriptVar v1 = pop(); + VCPUscriptVar r; + r.v = SOM::makeVar(SCRIPT_INT); + SOM::assign(&r.v, SOM::compNeq(&v1.v, &v2.v)); + push(r); + break; + } + case OPCODE_CMPA: { + VCPUscriptVar v2 = pop(); + VCPUscriptVar v1 = pop(); + VCPUscriptVar r; + r.v = SOM::makeVar(SCRIPT_INT); + SOM::assign(&r.v, SOM::compA(&v1.v, &v2.v)); + push(r); + break; + } + case OPCODE_CMPAE: { + VCPUscriptVar v2 = pop(); + VCPUscriptVar v1 = pop(); + VCPUscriptVar r; + r.v = SOM::makeVar(SCRIPT_INT); + SOM::assign(&r.v, SOM::compAe(&v1.v, &v2.v)); + push(r); + break; + } + case OPCODE_CMPB: { + VCPUscriptVar v2 = pop(); + VCPUscriptVar v1 = pop(); + VCPUscriptVar r; + r.v = SOM::makeVar(SCRIPT_INT); + SOM::assign(&r.v, SOM::compB(&v1.v, &v2.v)); + push(r); + break; + } + case OPCODE_CMPBE: { + VCPUscriptVar v2 = pop(); + VCPUscriptVar v1 = pop(); + VCPUscriptVar r; + r.v = SOM::makeVar(SCRIPT_INT); + SOM::assign(&r.v, SOM::compBe(&v1.v, &v2.v)); + push(r); + break; + } + case OPCODE_JIZ: { + int shift; // jump length + shift = *(int *)p; + p+=sizeof(int); VIP+=sizeof(int); + VCPUscriptVar v = pop(); + if (v.v.data.idata == 0) { + p+=shift; + VIP+=shift; + } + break; + } + case OPCODE_JNZ: { + int shift; // jump length + shift = *(int *)p; + p+=sizeof(int); VIP+=sizeof(int); + VCPUscriptVar v = pop(); + if (v.v.data.idata != 0) { + p+=shift; + VIP+=shift; + } + break; + } + case OPCODE_JMP: { + int shift; // jump length + shift = *(int *)p; + p+=sizeof(int); VIP+=sizeof(int); + p+=shift; + VIP+=shift; + break; + } + case OPCODE_NOT: { + VCPUscriptVar v = pop(); + VCPUscriptVar r; + r.v = SOM::makeVar(SCRIPT_BOOLEAN); + switch (v.v.type) { + case SCRIPT_BOOLEAN: + case SCRIPT_INT: + case SCRIPT_FLOAT: + case SCRIPT_DOUBLE: { + int i = SOM::makeBoolean(&v.v); + r.v.data.idata = i == 0 ? 1 : 0; + } + break; + case SCRIPT_STRING: + r.v.data.idata = (!v.v.data.sdata || !*v.v.data.sdata) ? 1 : 0; + break; + default: + r.v.data.idata = (v.v.data.odata == NULL) ? 1 : 0; + break; + } + push(r); + break; + } + case OPCODE_INCS: { + VCPUscriptVar v = pop(); + push(v); + switch (v.v.type) { + case SCRIPT_BOOLEAN: + v.v.data.idata = 1; + break; + case SCRIPT_INT: + v.v.data.idata++; + break; + case SCRIPT_FLOAT: + v.v.data.fdata = v.v.data.fdata+1; + break; + case SCRIPT_DOUBLE: + v.v.data.ddata = v.v.data.ddata+1; + break; + default: + Script::guruMeditation(SOM::getSystemObjectByScriptId(VSD), GURU_INCSNONNUM); + ASSERT(0); + break; + } + if (v.varId != -1) + VCPUassign(v.varId, v.v, VSD); + break; + } + case OPCODE_DECS: { + VCPUscriptVar v = pop(); + push(v); + switch (v.v.type) { + case SCRIPT_BOOLEAN: + v.v.data.idata = 0; + break; + case SCRIPT_INT: + v.v.data.idata--; + break; + case SCRIPT_FLOAT: + v.v.data.fdata = v.v.data.fdata-1; + break; + case SCRIPT_DOUBLE: + v.v.data.ddata = v.v.data.ddata-1; + break; + default: + Script::guruMeditation(SOM::getSystemObjectByScriptId(VSD), GURU_DECSNONNUM); + ASSERT(0); + break; + } + if (v.varId != -1) + VCPUassign(v.varId, v.v, VSD); + break; + } + case OPCODE_INCP: { + VCPUscriptVar v = pop(); + switch (v.v.type) { + case SCRIPT_BOOLEAN: + v.v.data.idata = 1; + break; + case SCRIPT_INT: + v.v.data.idata++; + break; + case SCRIPT_FLOAT: + v.v.data.fdata = v.v.data.fdata+1; + break; + case SCRIPT_DOUBLE: + v.v.data.ddata = v.v.data.ddata+1; + break; + default: + Script::guruMeditation(SOM::getSystemObjectByScriptId(VSD), GURU_INCPNONNUM); + ASSERT(0); + break; + } + if (v.varId != -1) + VCPUassign(v.varId, v.v, VSD); + push(v); + break; + } + case OPCODE_DECP: { + VCPUscriptVar v = pop(); + switch (v.v.type) { + case SCRIPT_BOOLEAN: + v.v.data.idata = 0; + break; + case SCRIPT_INT: + v.v.data.idata--; + break; + case SCRIPT_FLOAT: + v.v.data.fdata = v.v.data.fdata-1; + break; + case SCRIPT_DOUBLE: + v.v.data.ddata = v.v.data.ddata-1; + break; + default: + Script::guruMeditation(SOM::getSystemObjectByScriptId(VSD), GURU_DECSNONNUM); + ASSERT(0); + break; + } + if (v.varId != -1) + VCPUassign(v.varId, v.v, VSD); + push(v); + break; + } + case OPCODE_ADD: { + VCPUscriptVar v2 = pop(); + VCPUscriptVar v1 = pop(); + ASSERT(v1.v.type == SCRIPT_STRING || SOM::isNumeric(&v1.v)); + ASSERT(v2.v.type == SCRIPT_STRING || SOM::isNumeric(&v2.v)); + if (v2.v.type == SCRIPT_STRING) + { + int n=0; + if (!v2.v.data.sdata) break; + if (v1.v.data.sdata) n+= wcslen(v1.v.data.sdata); + n+= wcslen(v2.v.data.sdata); + wchar_t *s = (wchar_t *)WMALLOC((n+1)); + ASSERT(s != NULL); + + if (v1.v.data.sdata) + { + wcsncpy(s, v1.v.data.sdata, n); + wcsncat(s, (v2.v.data.sdata ? v2.v.data.sdata : L""), n); + } else + wcsncpy(s, (v2.v.data.sdata ? v2.v.data.sdata : L""), n); + + v1.v = SOM::makeVar(SCRIPT_STRING); + SOM::assign(&v1.v, s); + FREE(s); + push(v1); + } else { + scriptVar r = SOM::makeVar(SCRIPT_DOUBLE); + SOM::assign(&r, SOM::makeDouble(&v1.v) + SOM::makeDouble(&v2.v)); + push(r); + } + break; + } + case OPCODE_SUB: { + VCPUscriptVar v2 = pop(); + VCPUscriptVar v1 = pop(); + ASSERT(SOM::isNumeric(&v1.v)); + ASSERT(SOM::isNumeric(&v2.v)); + scriptVar r = SOM::makeVar(SCRIPT_DOUBLE); + SOM::assign(&r, SOM::makeDouble(&v1.v) - SOM::makeDouble(&v2.v)); + push(r); + break; + } + case OPCODE_MUL: { + VCPUscriptVar v2 = pop(); + VCPUscriptVar v1 = pop(); + ASSERT(SOM::isNumeric(&v1.v)); + ASSERT(SOM::isNumeric(&v2.v)); + scriptVar r = SOM::makeVar(SCRIPT_DOUBLE); + SOM::assign(&r, SOM::makeDouble(&v1.v) * SOM::makeDouble(&v2.v)); + push(r); + break; + } + case OPCODE_DIV: { + VCPUscriptVar v2 = pop(); + VCPUscriptVar v1 = pop(); + scriptVar r = safeDiv(&v1, &v2); + push(r); + break; + } + + case OPCODE_MOD: { + VCPUscriptVar v2 = pop(); + VCPUscriptVar v1 = pop(); + if (!SOM::isNumeric(&v2.v) || !SOM::isNumeric(&v1.v)) { + Script::guruMeditation(SOM::getSystemObjectByScriptId(VSD), GURU_MODNONNUM); + ASSERT(0); + } + SOM::assign(&v1.v, SOM::makeInt(&v1.v) % SOM::makeInt(&v2.v)); + push(v1); + break; + } + + case OPCODE_NEG: { + VCPUscriptVar v = pop(); + switch (v.v.type) { + case SCRIPT_BOOLEAN: + break; + case SCRIPT_INT: + v.v.data.idata = -v.v.data.idata; + break; + case SCRIPT_FLOAT: + v.v.data.fdata = -v.v.data.fdata; + break; + case SCRIPT_DOUBLE: + v.v.data.ddata = -v.v.data.ddata; + break; + default: + Script::guruMeditation(SOM::getSystemObjectByScriptId(VSD), GURU_NEGNONNUM); + ASSERT(0); + break; + } + push(v); + break; + } + + case OPCODE_BNOT: { + VCPUscriptVar v = pop(); + if (!SOM::isNumeric(&v.v)) { + Script::guruMeditation(SOM::getSystemObjectByScriptId(VSD), GURU_BNOTNONNUM); + ASSERT(0); + } + SOM::assign(&v.v, ~SOM::makeInt(&v.v)); + push(v); + break; + } + + case OPCODE_SHL: { + VCPUscriptVar v2 = pop(); + VCPUscriptVar v1 = pop(); + if (!SOM::isNumeric(&v1.v) || !SOM::isNumeric(&v2.v)) { + Script::guruMeditation(SOM::getSystemObjectByScriptId(VSD), GURU_SHLNONNUM); + ASSERT(0); + } + SOM::assign(&v1.v, SOM::makeInt(&v1.v) << SOM::makeInt(&v2.v)); + push(v1); + break; + } + case OPCODE_SHR: { + VCPUscriptVar v2 = pop(); + VCPUscriptVar v1 = pop(); + if (!SOM::isNumeric(&v1.v) || !SOM::isNumeric(&v2.v)) { + Script::guruMeditation(SOM::getSystemObjectByScriptId(VSD), GURU_SHRNONNUM); + ASSERT(0); + } + SOM::assign(&v1.v, SOM::makeInt(&v1.v) >> SOM::makeInt(&v2.v)); + push(v1); + break; + } + + case OPCODE_XOR: { + VCPUscriptVar v2 = pop(); + VCPUscriptVar v1 = pop(); + if (!SOM::isNumeric(&v1.v) || !SOM::isNumeric(&v2.v)) { + Script::guruMeditation(SOM::getSystemObjectByScriptId(VSD), GURU_XORNONNUM); + ASSERT(0); + } + SOM::assign(&v1.v, SOM::makeInt(&v1.v) ^ SOM::makeInt(&v2.v)); + push(v1); + break; + } + + case OPCODE_AND: { + VCPUscriptVar v2 = pop(); + VCPUscriptVar v1 = pop(); + if (!SOM::isNumeric(&v1.v) || !SOM::isNumeric(&v2.v)) { + Script::guruMeditation(SOM::getSystemObjectByScriptId(VSD), GURU_ANDNONNUM); + ASSERT(0); + } + SOM::assign(&v1.v, SOM::makeInt(&v1.v) & SOM::makeInt(&v2.v)); + push(v1); + break; + } + case OPCODE_OR: { + VCPUscriptVar v2 = pop(); + VCPUscriptVar v1 = pop(); + if (!SOM::isNumeric(&v1.v) || !SOM::isNumeric(&v2.v)) { + Script::guruMeditation(SOM::getSystemObjectByScriptId(VSD), GURU_ANDNONNUM); + ASSERT(0); + } + SOM::assign(&v1.v, SOM::makeInt(&v1.v) | SOM::makeInt(&v2.v)); + push(v1); + break; + } + + case OPCODE_LAND: { + VCPUscriptVar v2 = pop(); + VCPUscriptVar v1 = pop(); + VCPUscriptVar r; + r.v = SOM::makeVar(SCRIPT_BOOLEAN); + int a2 = SOM::makeBoolean(&v2.v); + int a1 = SOM::makeBoolean(&v1.v); + r.v.data.idata = (a2 && a1) ? 1 : 0; + push(r); + break; + } + case OPCODE_LOR: { + VCPUscriptVar v2 = pop(); + VCPUscriptVar v1 = pop(); + VCPUscriptVar r; + r.v = SOM::makeVar(SCRIPT_BOOLEAN); + int a2 = SOM::makeBoolean(&v2.v); + int a1 = SOM::makeBoolean(&v1.v); + r.v.data.idata = (a2 || a1) ? 1 : 0; + push(r); + break; + } + + case OPCODE_DELETE: { + VCPUscriptVar v1 = pop(); + int id = 0; + int type = v1.v.type; + if (type >= 0x10000) + do { + id = type - 0x10000; + VCPUscriptVar *v = variablesTable.enumItem(id+varBase(VSD)); + type = v->v.type; + } while (type >= 0x10000); + + if (isInstantiable(type)) { + ScriptObject *s = (ScriptObject *)v1.v.data.odata; + scriptVar v = SOM::makeVar(v1.v.type); + VCPUassign(v1.varId, v, v1.scriptId); + SystemObject *so = SOM::getSystemObjectByScriptId(VSD); + so->removeInstantiatedObject(s); + ObjectTable::destroy(s); + } + VCPU::push(v1); + break; + } + + + case OPCODE_NEW: { + int id = *(int *)p; // class id + p+=sizeof(int); VIP+=sizeof(int); + + SystemObject *so = SOM::getSystemObjectByScriptId(VSD); + TList *typeslist = so->getTypesList(); + + int _id; + if (id >= 0x10000) + do { + _id = id - 0x10000; + VCPUscriptVar *v = variablesTable.enumItem(_id+varBase(VSD)); + id = v->v.type; + } while (id >= 0x10000); + + if (SOM::getSystemObjectByScriptId(VSD)->isOldFormat()) + id = oldClassToClassId(id); + else + id = typeslist->enumItem(id); + + if (isInstantiable(id)) { + ScriptObject *s = ObjectTable::instantiate(id); + if (s) s->vcpu_setScriptId(VSD); + + so->addInstantiatedObject(s); + + if (s == NULL) { + Script::guruMeditation(SOM::getSystemObjectByScriptId(VSD), GURU_NEWFAILED); + } + VCPUscriptVar v={{SCRIPT_OBJECT, {0}}, 0}; + SOM::assign(&v.v, s); + push(v); + } else { + VCPUscriptVar n = {{SCRIPT_OBJECT,NULL}, 0}; + push(n); + } + break; + } + + case OPCODE_CMPLT : { + complete = 1; + break; + } + + case OPCODE_NOP : + { +#if defined(_WIN32) || defined(_WIN64) + OutputDebugStringA("Opcode 0 - NOP encountered, please check!\n"); +#else +#warning port me +#endif + break; + } + default: { + ASSERTALWAYS(StringPrintf("Opcode %X not implemented", opcode)); + break; + } + } + } + + ASSERT(VSP == stackbase + 1); +} + +// ------------------------------------------------------------- +scriptVar VCPU::VCPUassign(int id, scriptVar sv, int scriptId) { + VCPUscriptVar *v = NULL; + + if (id & (1 << 31)) { + id = id & ~(1 << 31); + v = getOrphan(id); + } else + v = variablesTable.enumItem(id+varBase(scriptId)); + + if (v->v.type != SCRIPT_STRING) { + if (!SOM::isNumeric(&v->v)) { + // assigning an object + + scriptVar _sv = sv; + + if (_sv.data.odata != NULL && !SystemObject::isObjectValid(_sv.data.odata)) + _sv.data.odata = NULL; + + if (v->v.data.odata != _sv.data.odata) { + + if (v->v.data.odata != NULL && !v->transcient && SystemObject::isObjectValid(v->v.data.odata)) + ((ScriptObject *)v->v.data.odata)->vcpu_removeAssignedVariable(v->varId, v->scriptId); + + if (_sv.data.odata == NULL) { + v->v.data.odata = NULL; + } else { + SOM::assign(&v->v, &sv); + if (SOM::typeCheck(v, 0)) { + if (!v->isaclass && !v->transcient) + ((ScriptObject *)sv.data.odata)->vcpu_addAssignedVariable(v->varId, v->scriptId); + } else { + int type = v->v.type; + if (type >= 0x10000) + do { + id = type - 0x10000; + VCPUscriptVar *v = variablesTable.enumItem(id+varBase(VSD)); + type = v->v.type; + } while (type >= 0x10000); + class_entry *e = ObjectTable::getClassEntry(type); + ASSERT(e != NULL); + GUID g = e->classGuid; + ScriptObject *o = NULL; + v->v.data.odata->vcpu_getInterfaceObject(g, &o); + if (o != NULL) { + v->v.data.odata = o; + if (!v->isaclass && !v->transcient) + o->vcpu_addAssignedVariable(v->varId, v->scriptId); + } else { + v->v.data.odata = NULL; + } + } + } + } + + } else { + // assigning a number + SOM::assign(&v->v, &sv); + } + } else { + ASSERT(sv.type == SCRIPT_STRING); + SOM::persistentstrassign(&v->v, sv.data.sdata); + } + + return v->v; +} + +// ------------------------------------------------------------- +void VCPU::traceState(VCPUscriptVar object, VCPUdlfEntry *e) { + _DebugString("vcpu[%2X]: %04X [%04X].%s", VCPU::VSD, VCPU::VIP, object.varId, e->functionName); +// CallbackManager::issueCallback(SysCallback::CONSOLE, ConsoleCallback::DEBUGMESSAGE, 0, reinterpret_cast(t)); +} + +// ------------------------------------------------------------- +// Calls the DLF function +scriptVar VCPU::callDLF(VCPUdlfEntry *e, int np) { + + static Stack cpuidstack; + + cpuidstack.push(VSD); + cpuidstack.push(VIP); + cpuidstack.push(VCC); + +/* if (e->external) { + char t[256] = {0}; + VCPUscriptVar v = VCPU::peekAt(e->nparams); + SPRINTF(t, "vcpu: %04X [%04X].%s", VCPU::VIP, v.varId, e->functionName); + Console::outputString(0, t); + DebugString("%s", t); + ((void(*)(int))e->ptr)(-1); + scriptVar rv = pop().v; // returned val + cpuidstack.pop(&VCC); + cpuidstack.pop(&VIP); + cpuidstack.pop(&VSD); + return rv; + }*/ + + +/* char t[256] = {0}; + SPRINTF(t, "e->nparams = %d\n", e->nparams); + DebugString("%s", t); */ + + //ASSERT(np == -1 || np == e->nparams); // fucko!!!!!!!! + + if (np == -1) { + np = e->nparams; + } + + for (int i=0;ivcpu_setScriptId(object.scriptId); + + if (e->ptr != NULL) { + switch (np) { + case 0: + r = ((scriptVar (*)(maki_cmd *, int vsd, class ScriptObject *))e->ptr)(NULL, VCPU::VSD, object.v.data.odata); + break; + case 1: + r = ((scriptVar (*)(maki_cmd *, int vsd, class ScriptObject *, scriptVar))e->ptr)(NULL, VCPU::VSD, object.v.data.odata, paramList[0]); + break; + case 2: + r = ((scriptVar (*)(maki_cmd *, int vsd, class ScriptObject *, scriptVar, scriptVar))e->ptr)(NULL, VCPU::VSD, object.v.data.odata, paramList[0], paramList[1]); + break; + case 3: + r = ((scriptVar (*)(maki_cmd *, int vsd, class ScriptObject *, scriptVar, scriptVar, scriptVar))e->ptr)(NULL, VCPU::VSD, object.v.data.odata, paramList[0], paramList[1], paramList[2]); + break; + case 4: + r = ((scriptVar (*)(maki_cmd *, int vsd, class ScriptObject *, scriptVar, scriptVar, scriptVar, scriptVar))e->ptr)(NULL, VCPU::VSD, object.v.data.odata, paramList[0], paramList[1], paramList[2], paramList[3]); + break; + case 5: + r = ((scriptVar (*)(maki_cmd *, int vsd, class ScriptObject *, scriptVar, scriptVar, scriptVar, scriptVar, scriptVar))e->ptr)(NULL, VCPU::VSD, object.v.data.odata, paramList[0], paramList[1], paramList[2], paramList[3], paramList[4]); + break; + case 6: + r = ((scriptVar (*)(maki_cmd *, int vsd, class ScriptObject *, scriptVar, scriptVar, scriptVar, scriptVar, scriptVar, scriptVar))e->ptr)(NULL, VCPU::VSD, object.v.data.odata, paramList[0], paramList[1], paramList[2], paramList[3], paramList[4], paramList[5]); + break; + case 7: + r = ((scriptVar (*)(maki_cmd *, int vsd, class ScriptObject *, scriptVar, scriptVar, scriptVar, scriptVar, scriptVar, scriptVar, scriptVar))e->ptr)(NULL, VCPU::VSD, object.v.data.odata, paramList[0], paramList[1], paramList[2], paramList[3], paramList[4], paramList[5], paramList[6]); + break; + case 8: + r = ((scriptVar (*)(maki_cmd *, int vsd, class ScriptObject *, scriptVar, scriptVar, scriptVar, scriptVar, scriptVar, scriptVar, scriptVar, scriptVar))e->ptr)(NULL, VCPU::VSD, object.v.data.odata, paramList[0], paramList[1], paramList[2], paramList[3], paramList[4], paramList[5], paramList[6], paramList[7]); + break; + case 9: + r = ((scriptVar (*)(maki_cmd *, int vsd, class ScriptObject *, scriptVar, scriptVar, scriptVar, scriptVar, scriptVar, scriptVar, scriptVar, scriptVar, scriptVar))e->ptr)(NULL, VCPU::VSD, object.v.data.odata, paramList[0], paramList[1], paramList[2], paramList[3], paramList[4], paramList[5], paramList[6], paramList[7], paramList[8]); + break; + case 10: + r = ((scriptVar (*)(maki_cmd *, int vsd, class ScriptObject *, scriptVar, scriptVar, scriptVar, scriptVar, scriptVar, scriptVar, scriptVar, scriptVar, scriptVar, scriptVar))e->ptr)(NULL, VCPU::VSD, object.v.data.odata, paramList[0], paramList[1], paramList[2], paramList[3], paramList[4], paramList[5], paramList[6], paramList[7], paramList[8], paramList[9]); + break; + } + } + } +#ifndef _DEBUG + catch(...) + { + Script::guruMeditation(SOM::getSystemObjectByScriptId(VCPU::VSD), GURU_EXCEPTION, L"Script Fatal Error", object.varId); + cpuidstack.pop(&VCC); + cpuidstack.pop(&VIP); + cpuidstack.pop(&VSD); + #ifdef ON_FATAL_SKIN_ERROR + ON_FATAL_SKIN_ERROR + #endif + return MAKE_SCRIPT_INT(0); + } +#endif + cpuidstack.pop(&VCC); + cpuidstack.pop(&VIP); + cpuidstack.pop(&VSD); + + return r; +} + +// ------------------------------------------------------------- +void VCPU::addStatementString(wchar_t *s) +{ + statementStringList.addItem(s); +} + +// ------------------------------------------------------------- +int VCPU::getComplete() { + return complete; +} + +// ------------------------------------------------------------- +int VCPU::isInstantiable(int id) { + ASSERT(!SOM::isNumericType(id)); + return ObjectTable::isClassInstantiable(id); +} + +// ------------------------------------------------------------- +int VCPU::getDlfGlobalIndex(int dlfid, int scriptid) { + static int lasti=-1; + static int lastid=0; + static int lastsid=0; + if (lasti>=0 && lasti < DLFentryTable.getNumItems()) { + if (lastsid == scriptid && lastid == dlfid) { + VCPUdlfEntry *e = DLFentryTable.enumItem(lasti); + if (e->DLFid == dlfid && e->scriptId == scriptid) + return lasti; + } + } + for (int i=0;iscriptId == scriptid && e->DLFid == dlfid) { + lasti = i; + lastsid = scriptid; + lastid = dlfid; + return lasti; + } + } + Script::guruMeditation(SOM::getSystemObjectByScriptId(scriptid), GURU_INVALIDEVENTDLF); + return -1; +} + +// ------------------------------------------------------------- +int VCPU::isValidScriptId(int id) { + for (int i=0;iscriptId == id) return 1; + return 0; +} + +// ------------------------------------------------------------- +int VCPU::getCacheCount() { + return cacheCount; +} + +// ------------------------------------------------------------- +int VCPU::getUserAncestor(int varid, int scriptid) { + VCPUscriptVar *vc = variablesTable.enumItem(varid+varBase(scriptid)) ; + if (vc->v.type < 0x10000) return -1; + int r_varId = vc->v.type - 0x10000; + ASSERT(r_varId < variablesTable.getNumItems()); + return r_varId; +} + +// ------------------------------------------------------------- +void VCPU::pushObject(void *o) { + scriptVar v = SOM::makeVar(SCRIPT_OBJECT, (ScriptObject *)o); + VCPU::push(v); +} + +// ------------------------------------------------------------- +void VCPU::pushInt(int i) { + scriptVar v = SOM::makeVar(SCRIPT_INT); + SOM::assign(&v, i); + VCPU::push(v); +} + +// ------------------------------------------------------------- +void VCPU::pushBoolean(int b) { + scriptVar v = SOM::makeVar(SCRIPT_BOOLEAN); + SOM::assign(&v, b); + VCPU::push(v); +} + +// ------------------------------------------------------------- +void VCPU::pushFloat(float f) { + scriptVar v = SOM::makeVar(SCRIPT_FLOAT); + SOM::assign(&v, f); + VCPU::push(v); +} + +// ------------------------------------------------------------- +void VCPU::pushDouble(double d) { + scriptVar v = SOM::makeVar(SCRIPT_DOUBLE); + SOM::assign(&v, d); + VCPU::push(v); +} + +// ------------------------------------------------------------- +void VCPU::pushString(const wchar_t *s) +{ + scriptVar v = SOM::makeVar(SCRIPT_STRING); + SOM::assign(&v, s); + VCPU::push(v); +} + +// ------------------------------------------------------------- +void VCPU::pushVoid() { + scriptVar v = SOM::makeVar(SCRIPT_VOID); + VCPU::push(v); +} + +// ------------------------------------------------------------- +void *VCPU::popObject() { + return (void *)VCPU::pop().v.data.odata; +} + +// ------------------------------------------------------------- +int VCPU::popInt() { + scriptVar v = VCPU::pop().v; + ASSERT(SOM::isNumeric(&v)); + return SOM::makeInt(&v); +} + +// ------------------------------------------------------------- +bool VCPU::popBoolean() { + scriptVar v = VCPU::pop().v; + ASSERT(SOM::isNumeric(&v)); + return SOM::makeBoolean(&v); +} + +// ------------------------------------------------------------- +float VCPU::popFloat() { + scriptVar v = VCPU::pop().v; + ASSERT(SOM::isNumeric(&v)); + return SOM::makeFloat(&v); +} + +// ------------------------------------------------------------- +double VCPU::popDouble() { + scriptVar v = VCPU::pop().v; + ASSERT(SOM::isNumeric(&v)); + return SOM::makeDouble(&v); +} + +// ------------------------------------------------------------- +const wchar_t *VCPU::popString() +{ + scriptVar v = VCPU::pop().v; + ASSERT(v.type == SCRIPT_STRING); + return v.data.sdata; +} + +// ------------------------------------------------------------- +void VCPU::popDiscard() { + VCPU::pop(); +} + +// ------------------------------------------------------------- +VCPUdlfEntry *VCPU::getGlobalDlfEntry(int dlfid) { + return globalDlfList.enumItem(dlfid); +} + +// ------------------------------------------------------------- +int VCPU::createOrphan(int type) { + orphans.addItem(new OrphanEntry(orphanid, type)); + return orphanid++; +} + +// ------------------------------------------------------------- +void VCPU::killOrphan(int id) { + int pos; + OrphanEntry *p = orphans.findItem((const wchar_t *)&id, &pos); + ASSERT(p != NULL && pos >= 0); + if (p->v.v.type == SCRIPT_STRING) + FREE((void *)p->v.v.data.sdata); + delete p; + orphans.removeByPos(pos); +} + +// ------------------------------------------------------------- +VCPUscriptVar *VCPU::getOrphan(int id) { + OrphanEntry *p = orphans.findItem((const wchar_t *)&id); + ASSERT(p != NULL); + return &p->v; +} + +// ------------------------------------------------------------- +int OrphanQuickSort::compareItem(void *p1, void *p2) { + if ((static_cast(p1))->id < (static_cast(p2))->id) return -1; + if ((static_cast(p1))->id > (static_cast(p2))->id) return 1; + return 0; +} + +// ------------------------------------------------------------- +int OrphanQuickSort::compareAttrib(const wchar_t *attr, void *p2) +{ + int id = *(reinterpret_cast(attr)); + int eid = (static_cast(p2))->id; + if (id < eid) return -1; + if (id > eid) return 1; + return 0; +} + +// ------------------------------------------------------------- +OrphanEntry::OrphanEntry(int _id, int type) { + id = _id; + MEMSET(&v, 0, sizeof(VCPUscriptVar)); + v.v.type = type; + v.scriptId = -1; + v.varId = id | (1 << 31); + v.transcient = 1; // so no event is trapped, will change later when compiler supports it +} + +// ------------------------------------------------------------- +void VCPU::setAtom(const wchar_t *atomname, ScriptObject *o) { + int pos; + ScriptAtom *sa = atoms.findItem(atomname, &pos); + if (pos >= 0) { + delete sa; + atoms.removeByPos(pos); + } + if (o) + atoms.addItem(new ScriptAtom(atomname, o)); +} + +// ------------------------------------------------------------- +ScriptObject *VCPU::getAtom(const wchar_t *atomname) { + ScriptAtom *sa = atoms.findItem(atomname); + if (sa) { + return sa->getAtomObject(); + } + return NULL; +} + +// ------------------------------------------------------------- +const wchar_t *VCPU::getClassName(int vcpuid, int localclassid) { + SystemObject *so = SOM::getSystemObject(vcpuid); + if (so != NULL) { + TList *l = so->getTypesList(); + if (l != NULL) { + int global = l->enumItem(localclassid); + class_entry *e = ObjectTable::getClassEntry(global); + if (e != NULL) + return e->classname; + } + } + return NULL; +} + + +// ------------------------------------------------------------- +int VCPU::cacheCount = 0; + +// segments +PtrList VCPU::variablesTable; +PtrList VCPU::eventsTable; +PtrList VCPU::DLFentryTable; +PtrList VCPU::globalDlfList; +PtrList VCPU::codeTable; +PtrList VCPU::statementStringList; +PtrListInsertSorted VCPU::orphans; +PtrListQuickSorted VCPU::atoms; +int VCPU::orphanid=0; + +// stacks +Stack VCPU::CpuStack; +Stack VCPU::CallStack; + +// registers +int VCPU::VIP=0; +int VCPU::VSP=0; +int VCPU::VSD=0; +int VCPU::VCC=0; + +Stack VCPU::VIPstack; +Stack VCPU::VSPstack; +Stack VCPU::VSDstack; +Stack VCPU::VCCstack; + +// misc +int VCPU::numScripts=0; +int VCPU::highestDLFId=0; +scriptVar VCPU::paramList[SCRIPT_MAXARGS]; +int VCPU::complete; + +TList VCPU::scriptsToRemove; +// NOTES + +// There is no reason why people would cast System, Layout and Container +// back to the common base class... so... +// GUI objects should descend from a GUIObject rather than ScriptObject +// GUIObject would descend from ScriptObject for the compiler and should +// be exported as "Object" for the script, ScriptObject should then not +// be exported at all, thus preventing someone from doing "Object o = System;" +// which makes no sense since System is not a GUI object. Of course you +// could still do "Layout l = System.getContainer("mqlksd").getLayout("lqsdkj");" +// but you won't be able to cast that to an "Object". Furthermore, to get a +// GUI object, you'll use the layout's function "getObject", so this +// will add consistency to the overall thing. + +/* +-------------------------------------------------------------------------------- + + VCPU: Virtual CPU, The virtual machine processor. + The VCPU actually takes care of some kinds of segments of variables, + events, and so on. The VCPU's task is to run any number of scripts + serially in reversed loading order. Last script loaded takes precedence + over previous ones. Events and functions fall back to the the previous + script if it also defines them, unless explicitly prevented via 'complete;' + The VCPU links DLFs in reverse hierarchy order, allowing overriding of + functions in objects. + + DLF : Dynamically Linked Function. Function name is used to link it to + whatever layout of functions we have in any release of the VCPU, allowing + us to reorder our functions in objects. + + TODO: Add versionning info so we can safely expand this format. + + Binaries format : + + + + Size Desc What + ----------------------------------------------------------------------------- + 8 Header FG\x03\x04\x14\00\00\00\00 + ----------------------------------------------------------------------------- + 4 # of DLF int + ----------------------------------------------------------------------------- + 4 DLF base type int + 1 Size of func name char + N Function name char[n] + ... + ----------------------------------------------------------------------------- + 4 # of variables int + ----------------------------------------------------------------------------- + 8 variable scriptVar + ... + ----------------------------------------------------------------------------- + 4 # of strings int + ----------------------------------------------------------------------------- + 1 Size of string char 1st string assigned to 1st string var + N String char[n] 2nd string assigned to 2nd string var... + ... + ----------------------------------------------------------------------------- + 4 # of events int + ----------------------------------------------------------------------------- + 4 variable id int Matching variable table + 4 DLF entry int Matching DLF table + 4 Function pointer int Pointer in code from base of code + ... + ----------------------------------------------------------------------------- + 4 Size of code int + ----------------------------------------------------------------------------- + N Compiled code char[n] + ----------------------------------------------------------------------------- + +*/ diff --git a/Src/Wasabi/api/script/vcpu.h b/Src/Wasabi/api/script/vcpu.h new file mode 100644 index 00000000..fdd90bb3 --- /dev/null +++ b/Src/Wasabi/api/script/vcpu.h @@ -0,0 +1,171 @@ +#ifndef __VCPU_H +#define __VCPU_H + +#include "script.h" +#include "opcodes.h" + +#include +#include +#include +#include +#include +#include +#include + +class ConsoleEnum; + +#include + +class OrphanEntry { + + public: + + OrphanEntry(int _id, int type); + virtual ~OrphanEntry() {} + + int id; + VCPUscriptVar v; +}; + +class OrphanQuickSort { + public: + static int compareItem(void *p1, void* p2); + static int compareAttrib(const wchar_t *attrib, void *item); + }; + +class ScriptAtom { + public: + ScriptAtom(const wchar_t *atomname, ScriptObject *object) : name(atomname), obj(object) {} + ~ScriptAtom() {} + + const wchar_t *getAtomName() { return name; } + ScriptObject *getAtomObject() { return obj; } + + private: + StringW name; + ScriptObject *obj; +}; + +class ScriptAtomSort { +public: + static int compareItem(ScriptAtom *p1, ScriptAtom*p2) { + return WCSICMP(p1->getAtomName(), p2->getAtomName()); + } + static int compareAttrib(const wchar_t *attrib, ScriptAtom *item) { + return WCSICMP(attrib, item->getAtomName()); + } +}; + + +class VCPU { + +public: + static void shutdown(); + static int assignNewScriptId(); + static int addScript(void *mem, int memsize, int cpuid); + static void removeScript(int id); + + static void push(VCPUscriptVar v); + static void push(scriptVar v); + static VCPUscriptVar pop(); + static VCPUscriptVar peekAt(int n); + + static scriptVar executeEvent(scriptVar v, int functionId, int np, int vcpuid=-1); + static int runEvent(VCPUeventEntry *e, int np, int pbase); + static void runCode(int scriptId, int pointer, int np); + static scriptVar callDLF(VCPUdlfEntry *e, int np); + static scriptVar VCPUassign(int id, scriptVar sv, int scriptId); + + static int findObject(ScriptObject *o, int start, int dlfid, int vcpuid=-1); + static int numScripts; + static void setupDLF(VCPUdlfEntry *e, int base); + static void delrefDLF(VCPUdlfEntry *e); + static void setupDLFFunction(void *ptr, int nargs, int DLFid, VCPUdlfEntry *e); + static int getDlfGlobalIndex(int dlfid, int scriptid); + + static scriptVar safeDiv(VCPUscriptVar*, VCPUscriptVar*); + static void setComplete() { complete=1; } + static void resetComplete() { complete=0; } + static int getComplete(); + static int newDlf(); + static void resetDlf(); + + static PtrList variablesTable; + static PtrList eventsTable; + static PtrList DLFentryTable; + static PtrList codeTable; + + static int highestDLFId; + static Stack CpuStack; + static Stack CallStack; + + static int varBase(int scriptId); + static int dlfBase(int scriptId); + static int nVars(int scriptId); + static char *getCodeBlock(int scriptId, int *size=NULL); + static VCPUcodeBlock *getCodeBlockEntry(int vcpuid); + + static void addStatementString(wchar_t *s); + + static int getCacheCount(); + static int getUserAncestor(int varid, int scriptid); + static int isValidScriptId(int id); + static int oldClassToClassId(int id); + static const wchar_t *getClassName(int vcpuid, int localclassid); + + static int VIP; + static int VSP; + static int VSD; + static int VCC; + static int complete; + static int cacheCount; + + static Stack VIPstack; + static Stack VSPstack; + static Stack VSDstack; + static Stack VCCstack; + + static void RemoveOldScripts(); + static TList scriptsToRemove; + + static scriptVar paramList[SCRIPT_MAXARGS]; + static TList plist; + static PtrList statementStringList; + + static int isInstantiable(int id); + + static void pushObject(void *o); + static void pushInt(int i); + static void pushBoolean(int b); + static void pushFloat(float f); + static void pushDouble(double d); + static void pushString(const wchar_t *s); + static void pushVoid(); + static void *popObject(); + static int popInt(); + static bool popBoolean(); + static float popFloat(); + static double popDouble(); + static const wchar_t *popString(); + static void popDiscard(); + static void callDlfCommand(void *ptr, int nargs, maki_cmd *cmd); + static int getDLFFromPointer(void *ptr, int nargs); + static void DLF_addref(void *ptr, int nargs); + static void DLF_reset(void *ptr, int nargs); + static void DLF_remref(void *ptr, int nargs); + static VCPUdlfEntry *getGlobalDlfEntry(int dlfid); + static void registerGlobalDlf(VCPUdlfEntry *e, int dlf); + static void traceState(VCPUscriptVar object, VCPUdlfEntry *e); + static PtrList globalDlfList; + static PtrListInsertSorted< OrphanEntry, OrphanQuickSort >orphans; + static int orphanid; + static VCPUscriptVar *getOrphan(int id); + static int createOrphan(int type); + static void killOrphan(int id); + static void setAtom(const wchar_t *atomname, ScriptObject *o); + static ScriptObject *getAtom(const wchar_t *atomname); + static PtrListQuickSorted atoms; + static ScriptObjectManager *scriptManager; +}; + +#endif diff --git a/Src/Wasabi/api/script/vcputypes.h b/Src/Wasabi/api/script/vcputypes.h new file mode 100644 index 00000000..b36cb6cb --- /dev/null +++ b/Src/Wasabi/api/script/vcputypes.h @@ -0,0 +1,78 @@ +#ifndef __VCPUTYPES_H +#define __VCPUTYPES_H + +#include + +// Basic types +#define SCRIPT_FIRSTTYPE SCRIPT_VOID +#define SCRIPT_VOID 0 +#define SCRIPT_EVENT 1 +#define SCRIPT_INT 2 +#define SCRIPT_FLOAT 3 +#define SCRIPT_DOUBLE 4 +#define SCRIPT_BOOLEAN 5 +#define SCRIPT_STRING 6 +#define SCRIPT_OBJECT 7 +#define SCRIPT_ANY 8 +#define SCRIPT_LASTTYPE SCRIPT_ANY + +static const GUID guidNull = +{ 0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }; + +#include + +#ifdef _MSC_VER +#pragma pack(push, 1) +#else +#pragma pack(1) +#endif + +typedef struct { + scriptVar v; + int scriptId; + int varId; + char transcient; + char isaclass; + char isstatic; +} VCPUscriptVar; + +typedef struct { + int varId; + int pointer; + int DLFid; + int scriptId; +} VCPUeventEntry; + +typedef struct { + wchar_t *functionName; + int basetype; + int scriptId; + int DLFid; + void *ptr; + int nparams; +} VCPUdlfEntry; + +typedef struct { + char *codeBlock; + int scriptId; + int dlfBase; + int varBase; + int size; + char *debugsymbols; + int debugsize; +} VCPUcodeBlock; + +typedef struct +{ + int cmd; + int id; +} maki_cmd; + +#ifdef _MSC_VER +#pragma pack(pop) +#else +#pragma pack() +#endif + +#endif + diff --git a/Src/Wasabi/api/service/api_service.cpp b/Src/Wasabi/api/service/api_service.cpp new file mode 100644 index 00000000..6d67c16d --- /dev/null +++ b/Src/Wasabi/api/service/api_service.cpp @@ -0,0 +1,12 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Wed May 07 00:56:11 2003] +// +// File : api_service.cpp +// Class : api_service +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#include +#include "api_service.h" + +api_service *serviceApi = NULL; \ No newline at end of file diff --git a/Src/Wasabi/api/service/api_service.h b/Src/Wasabi/api/service/api_service.h new file mode 100644 index 00000000..0d309000 --- /dev/null +++ b/Src/Wasabi/api/service/api_service.h @@ -0,0 +1,184 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Wed May 07 00:56:11 2003] +// +// File : api_service.h +// Class : api_service +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#ifndef __API_SERVICE_H +#define __API_SERVICE_H + +#include "bfc/dispatch.h" +#include "bfc/platform/types.h" + +namespace SvcNotify +{ + enum + { + ONREGISTERED = 100, // init yourself here -- not all other services are registered yet + ONSTARTUP = 200, // everyone is initialized, safe to talk to other services + ONAPPRUNNING = 210, // app is showing and processing events + ONSHUTDOWN = 300, // studio is shutting down, release resources from other services + ONDEREGISTERED = 400, // bye bye + ONDBREADCOMPLETE = 500, // after db is read in (happens asynchronously after ONSTARTUP) + ONBEFORESHUTDOWN = 600, // system is about to shutdown, call WASABI_API_APP->main_cancelShutdown() to cancel + }; +} + + class waServiceFactory; + +// ---------------------------------------------------------------------------- + + class NOVTABLE api_service : public Dispatchable + { + protected: + api_service() {} + ~api_service() {} + + public: + int service_register( waServiceFactory *svc ); + int service_deregister( waServiceFactory *svc ); + + size_t service_getNumServices( FOURCC svc_type ); + waServiceFactory *service_enumService( FOURCC svc_type, size_t n ); + + waServiceFactory *service_getServiceByGuid( GUID guid ); + + int service_lock( waServiceFactory *owner, void *svcptr ); + int service_clientLock( void *svcptr ); + int service_release( void *svcptr ); + const char *service_getTypeName( FOURCC svc_type ); + +#ifdef WASABI_COMPILE_COMPONENTS + GUID service_getOwningComponent( void *svcptr ); + GUID service_getLockingComponent( void *svcptr ); +#endif // WASABI_COMPILE_COMPONENTS + + int service_unlock( void *svcptr ); + int service_isvalid( FOURCC svctype, waServiceFactory *service ); + // removes "me" from the services list and finds a second service with the same GUID and puts it in the same position + // this is used by the lazy loader service factory - you shouldn't need it for any other purposes. + // returns 0 if compaction actually happened + int service_compactDuplicates( waServiceFactory *me ); + + protected: + enum + { + API_SERVICE_SERVICE_REGISTER = 10, + API_SERVICE_SERVICE_DEREGISTER = 20, + API_SERVICE_SERVICE_GETNUMSERVICES = 30, + API_SERVICE_SERVICE_ENUMSERVICE = 40, + API_SERVICE_SERVICE_GETSERVICEBYGUID = 50, + API_SERVICE_SERVICE_LOCK = 60, + API_SERVICE_SERVICE_CLIENTLOCK = 70, + API_SERVICE_SERVICE_RELEASE = 80, + API_SERVICE_SERVICE_GETTYPENAME = 90, + +#ifdef WASABI_COMPILE_COMPONENTS + API_SERVICE_SERVICE_GETOWNINGCOMPONENT = 100, + API_SERVICE_SERVICE_GETLOCKINGCOMPONENT = 110, +#endif // WASABI_COMPILE_COMPONENTS + + API_SERVICE_SERVICE_UNLOCK = 120, + API_SERVICE_ISVALID = 130, + API_SERVICE_COMPACT_DUPLICATES = 140, + }; + }; + +// ---------------------------------------------------------------------------- + + inline int api_service::service_register( waServiceFactory *svc ) + { + int __retval = _call( API_SERVICE_SERVICE_REGISTER, (int)0, svc ); + return __retval; + } + + inline int api_service::service_deregister( waServiceFactory *svc ) + { + int __retval = _call( API_SERVICE_SERVICE_DEREGISTER, (int)0, svc ); + return __retval; + } + + inline size_t api_service::service_getNumServices( FOURCC svc_type ) + { + int __retval = _call( API_SERVICE_SERVICE_GETNUMSERVICES, (int)0, svc_type ); + return __retval; + } + + inline waServiceFactory *api_service::service_enumService( FOURCC svc_type, size_t n ) + { + waServiceFactory *__retval = _call( API_SERVICE_SERVICE_ENUMSERVICE, (waServiceFactory *)0, svc_type, n ); + return __retval; + } + + inline waServiceFactory *api_service::service_getServiceByGuid( GUID guid ) + { + waServiceFactory *__retval = _call( API_SERVICE_SERVICE_GETSERVICEBYGUID, (waServiceFactory *)0, guid ); + return __retval; + } + + inline int api_service::service_lock( waServiceFactory *owner, void *svcptr ) + { + int __retval = _call( API_SERVICE_SERVICE_LOCK, (int)0, owner, svcptr ); + return __retval; + } + + inline int api_service::service_clientLock( void *svcptr ) + { + int __retval = _call( API_SERVICE_SERVICE_CLIENTLOCK, (int)0, svcptr ); + return __retval; + } + + inline int api_service::service_release( void *svcptr ) + { + int __retval = _call( API_SERVICE_SERVICE_RELEASE, (int)0, svcptr ); + return __retval; + } + + inline const char *api_service::service_getTypeName( FOURCC svc_type ) + { + const char *__retval = _call( API_SERVICE_SERVICE_GETTYPENAME, (const char *)0, svc_type ); + return __retval; + } + +#ifdef WASABI_COMPILE_COMPONENTS + inline GUID api_service::service_getOwningComponent( void *svcptr ) + { + GUID __retval = _call( API_SERVICE_SERVICE_GETOWNINGCOMPONENT, INVALID_GUID, svcptr ); + return __retval; + } + + inline GUID api_service::service_getLockingComponent( void *svcptr ) + { + GUID __retval = _call( API_SERVICE_SERVICE_GETLOCKINGCOMPONENT, INVALID_GUID, svcptr ); + return __retval; + } +#endif // WASABI_COMPILE_COMPONENTS + + inline int api_service::service_unlock( void *svcptr ) + { + int __retval = _call( API_SERVICE_SERVICE_UNLOCK, (int)0, svcptr ); + return __retval; + } + + inline int api_service::service_isvalid( FOURCC svctype, waServiceFactory *service ) + { + int __retval = _call( API_SERVICE_ISVALID, (int)0, svctype, service ); + return __retval; + } + + inline int api_service::service_compactDuplicates( waServiceFactory *me ) + { + return _call( API_SERVICE_COMPACT_DUPLICATES, (int)1, me ); + } +// ---------------------------------------------------------------------------- + + +extern api_service *serviceApi; + +#ifndef WASABI_API_SVC +#define WASABI_API_SVC serviceApi +#endif // !WASABI_API_SVC + +#endif // __API_SERVICE_H diff --git a/Src/Wasabi/api/service/api_servicei.cpp b/Src/Wasabi/api/service/api_servicei.cpp new file mode 100644 index 00000000..e5cae440 --- /dev/null +++ b/Src/Wasabi/api/service/api_servicei.cpp @@ -0,0 +1,83 @@ +#include +#ifndef NOSVCMGR +//" +#include "api_servicei.h" +//?> + +#include +#include + +api_service *serviceApi = NULL; + +api_serviceI::api_serviceI() { +} + +api_serviceI::~api_serviceI() { + ServiceManager::onShutdown(); +} + +int api_serviceI::service_register(waServiceFactory *svc) { +#ifdef WASABI_COMPILE_COMPONENTS + int r = ServiceManager::registerService(svc, WASABI_API_COMPONENT->getThisGuid()); +#else + int r = ServiceManager::registerService(svc, WASABI_API_APP->main_getGUID()); +#endif + return r; +} + +int api_serviceI::service_deregister(waServiceFactory *svc) { + int r = ServiceManager::deregisterService(svc); + return r; +} + +int api_serviceI::service_getNumServices(FOURCC svc_type) { + return ServiceManager::getNumServices(svc_type); +} + +waServiceFactory *api_serviceI::service_enumService(FOURCC svc_type, int n) { + return ServiceManager::enumService(svc_type, n); +} + +waServiceFactory *api_serviceI::service_getServiceByGuid(GUID guid) { + return ServiceManager::getServiceByGuid(guid); +} + + +int api_serviceI::service_lock(waServiceFactory *owner, void *svcptr) { + return ServiceManager::lock(owner, svcptr); +} + +int api_serviceI::service_clientLock(void *svcptr) { +#ifdef WASABI_COMPILE_COMPONENTS + return ServiceManager::clientLock(svcptr, WASABI_API_COMPONENT->getThisGuid()); +#else + return ServiceManager::clientLock(svcptr, WASABI_API_APP->main_getGUID()); +#endif +} + +int api_serviceI::service_release(void *svcptr) { + return ServiceManager::release(svcptr); +} + +const char *api_serviceI::service_getTypeName(FOURCC svc_type) { + return ServiceManager::getServiceTypeName(svc_type); +} + +#ifdef WASABI_COMPILE_COMPONENTS +GUID api_serviceI::service_getOwningComponent(void *svcptr) { + return ServiceManager::getOwningComponent(svcptr); +} + +GUID api_serviceI::service_getLockingComponent(void *svcptr) { + return ServiceManager::getLockingComponent(svcptr); +} +#endif + +int api_serviceI::service_unlock(void *svcptr) { + return ServiceManager::unlock(svcptr); +} + +int api_serviceI::service_isvalid(FOURCC svctype, waServiceFactory *service) { + return ServiceManager::isValidService(svctype, service); +} +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/service/api_servicei.h b/Src/Wasabi/api/service/api_servicei.h new file mode 100644 index 00000000..f50ceaa6 --- /dev/null +++ b/Src/Wasabi/api/service/api_servicei.h @@ -0,0 +1,150 @@ +#ifndef __SERVICE_APII_IMPL_H +#define __SERVICE_APII_IMPL_H + +/**/ +#include "api_service.h" +#include "api_servicex.h" + +class waServiceFactory; +/*?>*/ + +class api_serviceI : public api_serviceX { +public: + NODISPATCH api_serviceI(); + NODISPATCH virtual ~api_serviceI(); + +// services + /** + Register a service. Service registration is done + on creation of the WAC. + + @see WAComponentClient + @ret 1, success; 0, failure. + @param p Pointer to your service factory. + */ + DISPATCH(10) int service_register(waServiceFactory *svc); + + /** + Deregister a service. Service deregistration is done + on destruction of the WAC. + + @see WAComponentClient + @ret 1, success; 0, failure. + @param p Pointer to your service factory. + */ + DISPATCH(20) int service_deregister(waServiceFactory *svc); + + /** + Get the number of services registered for a specific + service type. This should only be called after + Wasabi is fully started (after WAC creation). + + @see FOURCC + @ret Number of services present in that service type. + @param svc_type Service type. + */ + DISPATCH(30) int service_getNumServices(FOURCC svc_type); // see common/svc_enum.h + + // enumerate by family + /** + Enumerate services by family. This should only + be called after Wasabi is fully started (after WAC creation). + + @see FOURCC + @ret Requested service. + @param svc_type Service type. + @param n Number of the service. + */ + DISPATCH(40) waServiceFactory *service_enumService(FOURCC svc_type, int n); + + // fetch by GUID + /** + Get a service by it's GUID. This should only + be called after Wasabi is fully started (after WAC creation). + + @ret Requested service. + @param guid Service GUID. + */ + DISPATCH(50) waServiceFactory *service_getServiceByGuid(GUID guid); + + // service owner calls this when it issues a service * + /** + Lock a service. Service owner must call this when + it issues a new service pointer to a client. + + @ret 1, success; 0, failure; + @param owner Service owner. + @param svcptr Service pointer returned to client. + */ + DISPATCH(60) int service_lock(waServiceFactory *owner, void *svcptr); + + // service client calls this when it uses a service * + /** + ClientLock a service. Service client must call + this before using the service. + + @ret 1, success; 0, failure; + @param svcptr Service pointer. + */ + DISPATCH(70) int service_clientLock(void *svcptr); + + // service client calls this when done w/ service * + /** + Release a service. Service client must call this + when he's finished using the service. If the service + is NOT released it will cause improper shutdown of + the service. + + @ret 1, success; 0, failure; + */ + DISPATCH(80) int service_release(void *svcptr); + /** + Get the pretty printed type name of a service type based + on it's FOURCC. + + @see FOURCC + @ret Service name (readable). + @param svc_type Service type. + */ + DISPATCH(90) const char *service_getTypeName(FOURCC svc_type); + +#ifdef WASABI_COMPILE_COMPONENTS + +/*[interface.service_getOwningComponent.cpp]#ifdef WASABI_COMPILE_COMPONENTS*/ +/*[interface.service_getOwningComponent.h]#ifdef WASABI_COMPILE_COMPONENTS*/ +/*[dispatchable.service_getOwningComponent.enum]#ifdef WASABI_COMPILE_COMPONENTS*/ +/*[dispatchable.service_getOwningComponent.bridge]#ifdef WASABI_COMPILE_COMPONENTS*/ + /** + Get the owning component of a service from + a service pointer. + + @ret GUID of the owning component. + @param svcptr Service pointer. + */ + DISPATCH(100) GUID service_getOwningComponent(void *svcptr); + + /** + Get the locking component for a service from + a service pointer. + + @ret GUID of the locking component. + @param svcptr Service pointer. + */ + DISPATCH(110) GUID service_getLockingComponent(void *svcptr); + +/*[interface.service_unlock.cpp]#endif // WASABI_COMPILE_COMPONENTS*/ +/*[interface.service_unlock.h]#endif // WASABI_COMPILE_COMPONENTS*/ +/*[dispatchable.service_unlock.enum]#endif // WASABI_COMPILE_COMPONENTS*/ +/*[dispatchable.service_unlock.bridge]#endif // WASABI_COMPILE_COMPONENTS*/ +#endif + + DISPATCH(120) int service_unlock(void *svcptr); + + DISPATCH(130) int service_isvalid(FOURCC svctype, waServiceFactory *service); +}; + +/*[interface.footer.h] +extern api_service *serviceApi; +*/ + +#endif // __SERVICE_APII_IMPL_H diff --git a/Src/Wasabi/api/service/api_servicex.cpp b/Src/Wasabi/api/service/api_servicex.cpp new file mode 100644 index 00000000..cc275b3f --- /dev/null +++ b/Src/Wasabi/api/service/api_servicex.cpp @@ -0,0 +1,35 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Wed May 07 00:56:11 2003] +// +// File : api_servicex.cpp +// Class : api_service +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- +#include +#ifndef NOSVCMGR +#include "api_servicex.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif + +#define CBCLASS api_serviceX +START_DISPATCH; + CB(API_SERVICE_SERVICE_REGISTER, service_register); + CB(API_SERVICE_SERVICE_DEREGISTER, service_deregister); + CB(API_SERVICE_SERVICE_GETNUMSERVICES, service_getNumServices); + CB(API_SERVICE_SERVICE_ENUMSERVICE, service_enumService); + CB(API_SERVICE_SERVICE_GETSERVICEBYGUID, service_getServiceByGuid); + CB(API_SERVICE_SERVICE_LOCK, service_lock); + CB(API_SERVICE_SERVICE_CLIENTLOCK, service_clientLock); + CB(API_SERVICE_SERVICE_RELEASE, service_release); + CB(API_SERVICE_SERVICE_GETTYPENAME, service_getTypeName); + #ifdef WASABI_COMPILE_COMPONENTS + CB(API_SERVICE_SERVICE_GETOWNINGCOMPONENT, service_getOwningComponent); + CB(API_SERVICE_SERVICE_GETLOCKINGCOMPONENT, service_getLockingComponent); + #endif // WASABI_COMPILE_COMPONENTS + CB(API_SERVICE_SERVICE_UNLOCK, service_unlock); + CB(API_SERVICE_ISVALID, service_isvalid); +END_DISPATCH; +#undef CBCLASS +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/service/api_servicex.h b/Src/Wasabi/api/service/api_servicex.h new file mode 100644 index 00000000..650d6b97 --- /dev/null +++ b/Src/Wasabi/api/service/api_servicex.h @@ -0,0 +1,44 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Wed May 07 00:56:11 2003] +// +// File : api_servicex.h +// Class : api_service +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- + +#ifndef __API_SERVICEX_H +#define __API_SERVICEX_H + +#include "api_service.h" + +class waServiceFactory; + + + +// ---------------------------------------------------------------------------- + +class api_serviceX : public api_service { + protected: + api_serviceX() {} + public: + virtual int service_register(waServiceFactory *svc)=0; + virtual int service_deregister(waServiceFactory *svc)=0; + virtual int service_getNumServices(FOURCC svc_type)=0; + virtual waServiceFactory *service_enumService(FOURCC svc_type, int n)=0; + virtual waServiceFactory *service_getServiceByGuid(GUID guid)=0; + virtual int service_lock(waServiceFactory *owner, void *svcptr)=0; + virtual int service_clientLock(void *svcptr)=0; + virtual int service_release(void *svcptr)=0; + virtual const char *service_getTypeName(FOURCC svc_type)=0; + #ifdef WASABI_COMPILE_COMPONENTS + virtual GUID service_getOwningComponent(void *svcptr)=0; + virtual GUID service_getLockingComponent(void *svcptr)=0; + #endif // WASABI_COMPILE_COMPONENTS + virtual int service_unlock(void *svcptr)=0; + virtual int service_isvalid(FOURCC svctype, waServiceFactory *service)=0; + + protected: + RECVS_DISPATCH; +}; + +#endif // __API_SERVICEX_H diff --git a/Src/Wasabi/api/service/service.h b/Src/Wasabi/api/service/service.h new file mode 100644 index 00000000..4ef710a6 --- /dev/null +++ b/Src/Wasabi/api/service/service.h @@ -0,0 +1,16 @@ +#ifndef _SERVICE_H +#define _SERVICE_H + +// this file defines the wasabi service factory class. this isn't the actual +// service, just the interface to get the service pointer + +#include +#include "services.h" + +#include "waservicefactory.h" +#include "waservicefactorybase.h" +#include "waservicefactoryt.h" +#include "waservicefactorytsingle.h" + + +#endif diff --git a/Src/Wasabi/api/service/servicei.cpp b/Src/Wasabi/api/service/servicei.cpp new file mode 100644 index 00000000..e3d87fca --- /dev/null +++ b/Src/Wasabi/api/service/servicei.cpp @@ -0,0 +1,5 @@ + +#include +#include "servicei.h" + + diff --git a/Src/Wasabi/api/service/servicei.h b/Src/Wasabi/api/service/servicei.h new file mode 100644 index 00000000..9d2bcc1b --- /dev/null +++ b/Src/Wasabi/api/service/servicei.h @@ -0,0 +1,180 @@ +#ifndef _SERVICEI_H +#define _SERVICEI_H + +// here is where we define some helper implementations of the service factory +// interface + +#include "service.h" + +#include "waservicefactoryi.h" +#include "waservicefactorybase.h" +#include "waservicefactoryt.h" +#include "waservicefactorytsingle.h" +#include +#include + +// DEPRECATED +#define waService waServiceFactory +#define waServiceT waServiceFactoryT +#define waServiceTSingle waServiceFactoryTSingle + +// Declaring services via macros +// ie: +// BEGIN_SERVICES(YourClass_Svc) +// DECLARE_SERVICE(SomeSvcCreator); +// DECLARE_SERVICE(SomeSvcCreator); +// DECLARE_SERVICE(SomeSvcCreator); +// DECLARE_SERVICETMULTI(svc_serviceclass, YourMultiInstanceServiceClass1>); +// DECLARE_SERVICETMULTI(svc_serviceclass, YourMultiInstanceServiceClass2>); +// DECLARE_SERVICETMULTI(svc_serviceclass, YourMultiInstanceServiceClass3>); +// DECLARE_SERVICETSINGLE(svc_serviceclass, YourSingleInstanceServiceClass1>); +// DECLARE_SERVICETSINGLE(svc_serviceclass, YourSingleInstanceServiceClass2>); +// DECLARE_SERVICETSINGLE(svc_serviceclass, YourSingleInstanceServiceClass3>); +// END_SERVICES(YourClass_Svc, _YourClass_Svc); + +// The macro DECLARE_MODULE_SVCMGR should be defined in your main cpp file if you are compiling +// a standalone exe without using the Application class. In this case you should also add +// MODULE_SVCMGR_ONINIT(); in your app startup and MODULE_SVCMGR_ONSHUTDOWN() in your app shutdown +// (class Application does this already) + +// You can use BEGIN_SYS_SERVICES to declare a service that is initialized in priority and +// shutdown late (normal version inits late, shutdowns early) + + +class StaticServices { + public: + virtual void registerServices()=0; + virtual void unregisterServices()=0; +}; + +class AutoServiceList : public PtrList { + public: + AutoServiceList() + { +#ifdef _WIN32 // PORT ME + OutputDebugStringA(">\n"); +#endif + } +}; + +class StaticServiceMgr { + public: + AutoServiceList __m_modules; + AutoServiceList __m_modules2; +}; + +#define DECLARE_MODULE_SVCMGR StaticServiceMgr *staticServiceMgr = NULL; + +extern StaticServiceMgr *staticServiceMgr; + +#define MODULE_SVCMGR_ONINIT() { \ +foreach(staticServiceMgr->__m_modules) \ + staticServiceMgr->__m_modules.getfor()->registerServices(); \ +endfor; \ +} + +#define MODULE_SVCMGR_ONINIT2() { \ +foreach(staticServiceMgr->__m_modules2) \ + staticServiceMgr->__m_modules2.getfor()->registerServices(); \ +endfor; \ +} + +#define MODULE_SVCMGR_ONSHUTDOWN() { \ +foreach(staticServiceMgr->__m_modules) \ + staticServiceMgr->__m_modules.getfor()->unregisterServices(); \ +endfor; \ +} + +#define MODULE_SVCMGR_ONSHUTDOWN2() { \ +foreach(staticServiceMgr->__m_modules2) \ + staticServiceMgr->__m_modules2.getfor()->unregisterServices(); \ +endfor; \ +} + +#define INIT_MODULE_SVCMGR() \ + if (!staticServiceMgr) staticServiceMgr = new StaticServiceMgr; + +#define BEGIN_SERVICES(CLASSNAME) \ +class CLASSNAME : public StaticServices { \ +public: \ + CLASSNAME() { \ + INIT_MODULE_SVCMGR() \ + staticServiceMgr->__m_modules.addItem(this); \ + } \ + virtual ~CLASSNAME() {} \ + virtual void registerServices() { \ + ASSERT(staticServiceMgr); + +#define BEGIN_SERVICES_DEBUG(CLASSNAME, TEXT) \ +class CLASSNAME : public StaticServices { \ +public: \ + CLASSNAME() { \ + INIT_MODULE_SVCMGR() \ + OutputDebugString("Registering "); \ + OutputDebugString(TEXT); \ + OutputDebugString("\n"); \ + staticServiceMgr->__m_modules.addItem(this); \ + } \ + virtual ~CLASSNAME() {} \ + virtual void registerServices() { \ + ASSERT(staticServiceMgr); + +#define BEGIN_SYS_SERVICES(CLASSNAME) \ +class CLASSNAME : public StaticServices { \ +public: \ + CLASSNAME() { \ + INIT_MODULE_SVCMGR() \ + staticServiceMgr->__m_modules2.addItem(this); \ + } \ + virtual ~CLASSNAME() {} \ + virtual void registerServices() { + +#define DECLARE_SERVICE(INSTANTIATIONCODE) \ + registerService(new INSTANTIATIONCODE); + +#define DECLARE_SERVICE_DEBUG(INSTANTIATIONCODE, TEXT) \ + OutputDebugString("Starting "); \ + OutputDebugString(TEXT); \ + OutputDebugString("\n"); \ + registerService(new INSTANTIATIONCODE); + +#define DECLARE_SERVICETMULTI(SVCTYPE, SVCCLASS) \ + registerService(new waServiceFactoryT); + +#define DECLARE_SERVICETMULTI_DEBUG(SVCTYPE, SVCCLASS, TEXT) \ + OutputDebugString("Starting "); \ + OutputDebugString(TEXT); \ + OutputDebugString("\n"); \ + registerService(new waServiceFactoryT); + +#define DECLARE_SERVICETSINGLE(SVCTYPE, SVCCLASS) \ + registerService(new waServiceFactoryTSingle); + +#define DECLARE_SERVICETSINGLE_DEBUG(SVCTYPE, SVCCLASS, TEXT) \ + OutputDebugString("Starting "); \ + OutputDebugString(TEXT); \ + OutputDebugString("\n"); \ + registerService(new waServiceFactoryTSingle, TEXT); + +#define END_SERVICES(CLASSNAME, INSTANCENAME) \ + } \ + virtual void unregisterServices() { \ + foreach(services) \ + waServiceFactoryI *svc = services.getfor(); \ + WASABI_API_SVC->service_deregister(svc); \ + delete svc; \ + endfor; \ + services.removeAll();\ + } \ +private: \ + void registerService(waServiceFactoryI *svc) { \ + if (svc != NULL) { \ + services.addItem(svc); \ + WASABI_API_SVC->service_register(svc); \ + } \ + } \ + PtrList services; \ +}; \ +CLASSNAME INSTANCENAME; + +#endif diff --git a/Src/Wasabi/api/service/services.h b/Src/Wasabi/api/service/services.h new file mode 100644 index 00000000..ab044459 --- /dev/null +++ b/Src/Wasabi/api/service/services.h @@ -0,0 +1,76 @@ +#ifndef _SERVICES_H +#define _SERVICES_H + +#include "bfc/std_mkncc.h" // for MKnCC() + +// lower-case service names are reserved by Nullsoft for future use +// upper-case service names are for 3rd parties to extend the service system + +// if you have a service that is unique to a component, make it type +// UNIQUE and register it by GUID + + +namespace WaSvc +{ + enum + { + NONE = MK4CC( 'n', 'o', 'n', 'e' ), + UNIQUE = MK4CC( 'u', 'n', 'i', 'q' ), // for unique services, enumed by GUID + OBJECT = MK4CC( 'o', 'b', 'j', 'f' ), // for unique objects, enumed by GUID + CONTEXTCMD = MK4CC( 'c', 'c', 'm', 'd' ), // context menu command svc_contextCmd.h + DEVICE = MK3CC( 'd', 'e', 'v' ), // portable device svc_device.h + FILEREADER = MK4CC( 'f', 's', 'r', 'd' ), // file system reader (disk, zip, http) + FILESELECTOR = MK4CC( 'f', 's', 'e', 'l' ), // file selector svc_filesel.h + STORAGEVOLENUM = MK4CC( 'f', 's', 'e', 'n' ), // storage volume enumerator. + IMAGEGENERATOR = MK4CC( 'i', 'm', 'g', 'n' ), // image generator svc_imggen.h + IMAGELOADER = MK4CC( 'i', 'm', 'g', 'l' ), // image loader svc_imgload.h + IMAGEWRITER = MK4CC( 'i', 'm', 'g', 'w' ), // image writer + ITEMMANAGER = MK4CC( 'i', 'm', 'g', 'r' ), // item manager svc_itemmgr.h + PLAYLISTREADER = MK4CC( 'p', 'l', 'r', 'd' ), // playlist reader - DEPRECATED - only for wa3 + PLAYLISTWRITER = MK4CC( 'p', 'l', 'w', 'r' ), // playlist writer - DEPRECATED - only for wa3 + MEDIACONVERTER = MK4CC( 'c', 'o', 'n', 'v' ), // media converter + MEDIACORE = MK4CC( 'c', 'o', 'r', 'e' ), // media core + MEDIARECORDER = MK4CC( 'm', 'r', 'e', 'c' ), // media recorder + SCRIPTOBJECT = MK4CC( 'm', 'a', 'k', 'i' ), // third party script object + // TRANSLATOR=MK4CC('x','l','a','t'), // text translator + WINDOWCREATE = MK4CC( 'w', 'n', 'd', 'c' ), // window creator + XMLPROVIDER = MK4CC( 'x', 'm', 'l', 'p' ), // xml provider + DB = MK2CC( 'd', 'b' ), // database + SKINFILTER = MK4CC( 'f', 'l', 't', 'r' ), // bitmap/colorref skin filter + METADATA = MK4CC( 'm', 't', 'd', 't' ), // play item meta data + METATAG = MK4CC( 'm', 't', 't', 'g' ), // metadata tagging of play items + EVALUATOR = MK4CC( 'e', 'v', 'a', 'l' ), // evaluate a string + MINIBROWSER = MK2CC( 'm', 'b' ), // minibrowser + TOOLTIPSRENDERER = MK4CC( 't', 't', 'i', 'p' ), // tooltips renderer + XUIOBJECT = MK4CC( 'x', 'u', 'i', 'o' ), // xml gui objects + STRINGCONVERTER = MK4CC( 'u', 't', 'f', '8' ), // unicode string conversion + ACTION = MK3CC( 'a', 'c', 't' ), // custom actions (ie: for buttons) + COREADMIN = MK4CC( 'c', 'a', 'd', 'm' ), // core administrator + DROPTARGET = MK4CC( 'd', 'r', 'o', 'p' ), // drop targets + OBJECTDIR = MK4CC( 'o', 'b', 'j', 'd' ), // object directory + TEXTFEED = MK4CC( 't', 'x', 't', 'f' ), // text feed, to send text to various XUI objects (ie: by using display="textfeedid" + ACCESSIBILITY = MK4CC( 'a', 'c', 'c', 's' ), // accessibility service + ACCESSIBILITYROLESERVER = MK4CC( 'r', 'o', 'l', 'e' ), // accessibility roleServer services + EXPORTER = MK3CC( 'e', 'x', 'p' ), // exporter + COLLECTION = MK4CC( 'c', 'l', 'c', 't' ), // named xml overridable collection + REDIRECT = MK4CC( 'r', 'e', 'd', 'r' ), // filename redirect + FONTRENDER = MK4CC( 'f', 'o', 'n', 't' ), // font renderer (bitmap/truetype/freetype) + SRCCLASSFACTORY = MK4CC( 'c', 'l', 'f', 'a' ), // source code class factory + SRCEDITOR = MK4CC( 's', 'e', 'd', 't' ), // source code editor + MP4AUDIODECODER = MK4CC( 'm', '4', 'a', 'd' ), // mp4 audio decoder + MP4VIDEODECODER = MK4CC( 'm', '4', 'v', 'd' ), // mp4 audio decoder + PLAYLISTREADER_WA5 = MK4CC( 'p', 'l', 'r', '5' ), // playlist reader + PLAYLISTWRITER_WA5 = MK4CC( 'p', 'l', 'w', '5' ), // playlist writer + PLAYLISTHANDLER = MK3CC( 'p', 'l', 'h' ), // playlist handler + TAGPROVIDER = MK4CC( 't', 'a', 'g', 'z' ), // tag provider (for ATF engine) + NSVFACTORY = MK4CC( 'n', 's', 'v', 'f' ), // NSV factory (to create NSV objects) + JSAPI2_APICREATOR = MK4CC( 'j', 's', 'a', 'c' ), // API Creator for the Javascript API + MKVDECODER = MK3CC( 'm', 'k', 'v' ), // MKV factory (to create MKV decoder objects) + FLVDECODER = MK3CC( 'f', 'l', 'v' ), // FLV factory (to create FLV decoder objects) + AVIDECODER = MK3CC( 'a', 'v', 'i' ), // AVI factory (to create AVI decoder objects) + OGGDECODER = MK3CC( 'o', 'g', 'g' ), // Ogg factory (to create Ogg decoder objects) + MP4DECODER = MK3CC( 'm', 'p', '4' ), // MP4 factory (to create MP4 decoder objects) + }; +}; + +#endif diff --git a/Src/Wasabi/api/service/svc_enum.cpp b/Src/Wasabi/api/service/svc_enum.cpp new file mode 100644 index 00000000..8ca8a1af --- /dev/null +++ b/Src/Wasabi/api/service/svc_enum.cpp @@ -0,0 +1,2 @@ +#include +#include "svc_enum.h" diff --git a/Src/Wasabi/api/service/svc_enum.h b/Src/Wasabi/api/service/svc_enum.h new file mode 100644 index 00000000..40f5c651 --- /dev/null +++ b/Src/Wasabi/api/service/svc_enum.h @@ -0,0 +1,24 @@ +#ifndef _SVC_ENUM_H +#define _SVC_ENUM_H + +// try to use this one, it does a clientLock for you +#include +template +class castService { +public: + castService(waServiceFactory *w, int global_lock=TRUE) : was(w), gl(global_lock) { } + operator T *() { + if (was == NULL) return NULL; + T *ret = static_cast(was->getInterface(gl)); + return ret; + } +private: + waServiceFactory *was; + int gl; +}; + +#include "svcenumbyguid.h" +#include "svcenum.h" +#include "svcenumt.h" + +#endif diff --git a/Src/Wasabi/api/service/svccache.cpp b/Src/Wasabi/api/service/svccache.cpp new file mode 100644 index 00000000..af3e47cf --- /dev/null +++ b/Src/Wasabi/api/service/svccache.cpp @@ -0,0 +1,35 @@ +#include +#include "svccache.h" +#include + +#if !defined(WASABI_API_SVC) +#error no no +#endif + +SvcCache::SvcCache(FOURCC type) { + int p = 0; + list.setAutoSort(FALSE); + for (;;) { + waServiceFactory *svc = WASABI_API_SVC->service_enumService(type, p++); + if (svc == NULL) break; + const wchar_t *teststr = svc->getTestString(); + if (teststr == NULL || *teststr == '\0') continue; +//CUT DebugString("cachin %s\n", teststr); + list.addItem(svc); + } + list.setAutoSort(TRUE); +} + +waServiceFactory *SvcCache::findServiceFactory(const wchar_t *searchval) { + return list.findItem(searchval); +} + +int SvcCache::waServiceFactoryCompare::compareItem(waServiceFactory *p1, waServiceFactory* p2) { + int r = WCSICMP(p1->getTestString(), p2->getTestString()); + if (r == 0) return CMP3(p1, p2); + return r; +} + +int SvcCache::waServiceFactoryCompare::compareAttrib(const wchar_t *attrib, waServiceFactory *item) { + return WCSICMP(attrib, item->getTestString()); +} diff --git a/Src/Wasabi/api/service/svccache.h b/Src/Wasabi/api/service/svccache.h new file mode 100644 index 00000000..1e989e57 --- /dev/null +++ b/Src/Wasabi/api/service/svccache.h @@ -0,0 +1,43 @@ +#ifndef _SVC_CACHE_H +#define _SVC_CACHE_H + +#include +#include + +/** + This is a caching version of SvcEnum. Upon creation, it enumerates all + service factories in the family and keeps them in a list. Then you can + call findService() with a search string to quickly find the service you + want. If you don't have a search string, you can still use a SvcEnum. +*/ + +class SvcCache { +protected: + SvcCache(FOURCC type); + +public: + waServiceFactory *findServiceFactory(const wchar_t *searchval); + +private: + class waServiceFactoryCompare { + public: + static int compareItem(waServiceFactory *p1, waServiceFactory* p2); + static int compareAttrib(const wchar_t *attrib, waServiceFactory *item); + }; + PtrListQuickSorted list; +}; + +template +class SvcCacheT : public SvcCache { +public: + SvcCacheT() : SvcCache(T::getServiceType()) { } + + T *findService(const char *key, int global_lock=TRUE) { + waServiceFactory *sf = findServiceFactory(key); + if (sf == NULL) return NULL; + T *ret = castService(sf, global_lock); + return ret; + } +}; + +#endif diff --git a/Src/Wasabi/api/service/svcenum.cpp b/Src/Wasabi/api/service/svcenum.cpp new file mode 100644 index 00000000..f9219654 --- /dev/null +++ b/Src/Wasabi/api/service/svcenum.cpp @@ -0,0 +1,45 @@ +#include + +//" +#include "svcenum.h" +//?> + + +#include +#include +#include + +SvcEnum::SvcEnum() : type(WaSvc::NONE), factory(NULL) { + reset(); +} + +void *SvcEnum::_getNext(int global_lock) { + if (WASABI_API_SVC == NULL) return NULL; + for (;;) { + factory = WASABI_API_SVC->service_enumService(type, pos++); + if (factory == NULL) return NULL; + void *s = factory->getInterface(FALSE);// get but don't lock + if (s) + { + if (_testService(s)) { + if (global_lock) + WASABI_API_SVC->service_lock(factory, s); // lock in sys tables + return s; + } + factory->releaseInterface(s); + } + } +} + +void SvcEnum::reset() { + pos = 0; + factory = NULL; +} + +int SvcEnum::release(void *ptr) { + return WASABI_API_SVC->service_release(ptr); +} + +waServiceFactory *SvcEnum::getLastFactory() { + return factory; +} diff --git a/Src/Wasabi/api/service/svcenum.h b/Src/Wasabi/api/service/svcenum.h new file mode 100644 index 00000000..bdfbb7df --- /dev/null +++ b/Src/Wasabi/api/service/svcenum.h @@ -0,0 +1,37 @@ +#ifndef _SVCENUM_H +#define _SVCENUM_H + + +/**/ +class waServiceFactory; +/*?>*/ + +// abstract base class +class NOVTABLE SvcEnum { +protected: + SvcEnum(); + + void *_getNext(int global_lock = TRUE); + void reset(); + + virtual int _testService(void *)=0; + +public: +#ifdef ASSERTS_ENABLED + static int release(waServiceFactory *ptr) { ASSERTALWAYS("never ever call release() with a waServiceFactory * !!!"); return 0; } +#endif + static int release(void *ptr); + + waServiceFactory *getLastFactory(); + +protected: + FOURCC type; + +private: + int pos; + waServiceFactory * factory; +}; + + +#endif // _SVCENUM_H + diff --git a/Src/Wasabi/api/service/svcenumbyguid.cpp b/Src/Wasabi/api/service/svcenumbyguid.cpp new file mode 100644 index 00000000..28b315a0 --- /dev/null +++ b/Src/Wasabi/api/service/svcenumbyguid.cpp @@ -0,0 +1,5 @@ +#include +//" +#include "svcenumbyguid.h" +//?> + diff --git a/Src/Wasabi/api/service/svcenumbyguid.h b/Src/Wasabi/api/service/svcenumbyguid.h new file mode 100644 index 00000000..412523c3 --- /dev/null +++ b/Src/Wasabi/api/service/svcenumbyguid.h @@ -0,0 +1,37 @@ +#ifndef _SVCENUMBYGUID_H +#define _SVCENUMBYGUID_H + +/**/ +/*?>*/ + +#include "svc_enum.h" + +/* + * this is a helper class to fetch a service * by GUID + * usage: svc_something *svc = SvcEnumByGuid(svcguid); + * @short: Helper class to fetch unique service by GUID +*/ +template +class SvcEnumByGuid { +public: +/** +@param _guid The GUID of the service factory to fetch the service from. +*/ + SvcEnumByGuid() : guid(SERVICETYPE::getServiceGuid()) {} + SvcEnumByGuid(GUID _guid) : guid(_guid) {} + +/** +@return The pointer to the service. +*/ + SERVICETYPE *getInterface() { + waServiceFactory *svc = WASABI_API_SVC->service_getServiceByGuid(guid); + return castService(svc); + } + + operator SERVICETYPE *() { return getInterface(); } + +private: + GUID guid; +}; + +#endif // _SVCENUMBYGUID_H diff --git a/Src/Wasabi/api/service/svcenumt.cpp b/Src/Wasabi/api/service/svcenumt.cpp new file mode 100644 index 00000000..2fa45792 --- /dev/null +++ b/Src/Wasabi/api/service/svcenumt.cpp @@ -0,0 +1,5 @@ +#include +//" +#include "svcenumt.h" +//?> + diff --git a/Src/Wasabi/api/service/svcenumt.h b/Src/Wasabi/api/service/svcenumt.h new file mode 100644 index 00000000..e423b542 --- /dev/null +++ b/Src/Wasabi/api/service/svcenumt.h @@ -0,0 +1,30 @@ +#ifndef _SVCENUMT_H +#define _SVCENUMT_H + +#include "svcenum.h" + +template +class SvcEnumT : private SvcEnum { +protected: + SvcEnumT() { type = T::getServiceType(); } + +public: + void reset() { SvcEnum::reset(); } + T *getFirst(int global_lock = TRUE) { reset(); return getNext(global_lock); } + T *getNext(int global_lock = TRUE) { return static_cast(_getNext(global_lock)); } + + // these would just be 'using' but msvc.net sucks butt + inline int release(void *ptr) { return SvcEnum::release(ptr); } + inline waServiceFactory *getLastFactory() { return SvcEnum::getLastFactory(); } + +protected: + // override this one (or don't if you want to return all of them) + virtual int testService(T *svc) { return TRUE; } + +private: + virtual int _testService(void *svc) { + return testService(static_cast(svc)); + } +}; + +#endif // _SVCENUMT_H diff --git a/Src/Wasabi/api/service/svcmgr.cpp b/Src/Wasabi/api/service/svcmgr.cpp new file mode 100644 index 00000000..78eec802 --- /dev/null +++ b/Src/Wasabi/api/service/svcmgr.cpp @@ -0,0 +1,365 @@ +#include +#ifndef NOSVCMGR +#include "svcmgr.h" + +#ifdef WASABI_COMPILE_COMPONENTS +#include +#include +#endif + +#ifdef WASABI_COMPILE_SYSCB +#include +#include +#include +#endif + +#include +#include +#include + +static MultiMap services;// list of factories by class +static Map ownermap; // who presented it +static Map services_by_guid;// unique services +static Map lockmap; // who to tell when it's unlocked +//CUTstatic Map clientmap; // who locked it + +static CriticalSection cs; + +int ServiceManager::registerService(waServiceFactory *service, GUID owner) { + ASSERT(owner != INVALID_GUID); + if (owner == INVALID_GUID) return 0; + FOURCC svctype = service->getServiceType(); + cs.enter(); + if (!services.multiHaveItem(svctype, service)) { + services.multiAddItem(svctype, service); + + ownermap.addItem(service, owner); + + GUID svcguid = service->getGuid(); + if (svcguid != INVALID_GUID) services_by_guid.addItem(svcguid, service); + } + cs.leave(); + + service->serviceNotify(SvcNotify::ONREGISTERED); + + #ifdef WASABI_COMPILE_SYSCB + CallbackManager::issueCallback(SysCallback::SERVICE, + SvcCallback::ONREGISTER, + (int)svctype, reinterpret_cast(service)); + #endif + + return 1; +} + +int ServiceManager::deregisterService(waServiceFactory *service, int internal) { + FOURCC svctype = service->getServiceType(); + // make sure it was there + cs.enter(); + if (services.multiHaveItem(svctype, service)) { + // make sure there aren't still services issued by this guy +// ASSERT(internal || !lockmap.reverseGetItem(service)); + services.multiDelItem(svctype, service); + ownermap.delItem(service); + services_by_guid.reverseDelItem(service); + } + cs.leave(); + service->serviceNotify(SvcNotify::ONDEREGISTERED); + + #ifdef WASABI_COMPILE_SYSCB + CallbackManager::issueCallback(SysCallback::SERVICE, + SvcCallback::ONDEREGISTER, + (int)svctype, reinterpret_cast(service)); + #endif + + return 1; +} + +int ServiceManager::getNumServices(FOURCC svc_type) { + INCRITICALSECTION(cs); + return services.multiGetNumItems(svc_type); +} + +int ServiceManager::getNumServices() { + return services.getNumItems(); +} + +waServiceFactory *ServiceManager::enumService(int n) { + return services_by_guid.enumItemByPos(n, NULL); +} + +int ServiceManager::getNumOwners() { + return ownermap.getNumItems(); +} + +int ServiceManager::getNumServicesByGuid() { + return services_by_guid.getNumItems(); +} + +int ServiceManager::getNumLocks() { + return lockmap.getNumItems(); +} + +waServiceFactory *ServiceManager::enumService(FOURCC svc_type, int n) { + INCRITICALSECTION(cs); + waServiceFactory *ret = NULL; + services.multiGetItem(svc_type, n, &ret); + return ret; +} + +waServiceFactory *ServiceManager::getServiceByGuid(GUID guid) { + INCRITICALSECTION(cs); + if (guid == INVALID_GUID) return NULL; + waServiceFactory *ret=NULL; + services_by_guid.getItem(guid, &ret); + return ret; +} + +void ServiceManager::sendNotification(int msg, int param1, int param2) { + cs.enter(); + for (int x = 0; x < services.multiGetNumPairs(); x++) { + for (int y = 0; ; y++) { + waServiceFactory *svc; + if (!services.multiGetItemDirect(x, y, &svc)) { + break; + } + svc->serviceNotify(msg, param1, param2); + } + } + cs.leave(); +#ifdef WASABI_COMPILE_COMPONENTS + // also notify components + for (int i = 0; ; i++) { + WaComponent *wac = ComponentManager::enumComponent(i); + if (wac == NULL) break; + wac->onNotify(WAC_NOTIFY_SERVICE_NOTIFY, msg, param1, param2); + } +#endif + #ifdef WASABI_COMPILE_SYSCB + // and syscallbacks + CallbackManager::issueCallback(SysCallback::RUNLEVEL, msg); + #endif +} + +int ServiceManager::lock(waServiceFactory *owner, void *svcptr) { + INCRITICALSECTION(cs); + if (owner == NULL || svcptr == NULL) return 0; + // we allow multiple entries for same service + lockmap.addItem(svcptr, owner); + return 1; +} + +int ServiceManager::unlock(void *svcptr) { + if (svcptr == NULL) return 0; + + waServiceFactory *wsvc = NULL; + cs.enter(); + if (!lockmap.getItem(svcptr, &wsvc)) { + cs.leave(); + DebugString("WARNING: got unlock with no lock record!"); + return 0; + } + + int r = lockmap.delItem(svcptr); + ASSERT(r); + +//CUT // this might fail, client locking isn't enforceable +//CUT clientmap.delItem(svcptr); + + cs.leave(); + + return 1; +} + +int ServiceManager::clientLock(void *svcptr, GUID lockedby) { +//CUT INCRITICALSECTION(cs); +//CUT ASSERT(svcptr != NULL); +//CUT if (svcptr == NULL) return 0; +//CUT ASSERT(lockedby != INVALID_GUID); +//CUT if (lockedby == INVALID_GUID) return 0; +//CUT clientmap.addItem(svcptr, lockedby); + return 1; +} + +int ServiceManager::release(void *svcptr) { + if (svcptr == NULL) return 0; + + waServiceFactory *wsvc = NULL; + cs.enter(); // note cs getting locked twice via release+unlock + if (!lockmap.getItem(svcptr, &wsvc)) { + cs.leave(); + DebugString("WARNING: got release with no lock record!"); + return 0; + } + unlock(svcptr); + cs.leave(); + + ASSERT(wsvc != NULL); + return wsvc->releaseInterface(svcptr); +} + +#ifdef WASABI_COMPILE_COMPONENTS +GUID ServiceManager::getOwningComponent(void *svcptr) { + INCRITICALSECTION(cs); + GUID ret = INVALID_GUID; + waServiceFactory *svc=NULL; + if (lockmap.getItem(svcptr, &svc)) ownermap.getItem(svc, &ret); + return ret; +} + +GUID ServiceManager::getLockingComponent(void *svcptr) { + INCRITICALSECTION(cs); + GUID ret = INVALID_GUID; +//CUT clientmap.getItem(svcptr, &ret); + return ret; +} +#endif + +using namespace WaSvc; + +static struct { + FOURCC type; + const char *name; +} svc_names[] = { + { DEVICE, "Portable Device" }, + { FILEREADER, "File Reader" }, + { FILESELECTOR, "File Selector" }, + { IMAGEGENERATOR, "Image Generator" }, + { IMAGELOADER, "Image Loader" }, + { ITEMMANAGER, "Item Manager" }, + { MEDIACONVERTER, "Media Converter" }, + { MEDIACORE, "Media Core" }, + { PLAYLISTREADER, "Playlist Reader" }, + { PLAYLISTWRITER, "Playlist Writer" }, + { SCRIPTOBJECT, "Script Class" }, + { XMLPROVIDER, "XML Provider" }, + { DB, "Database" }, + { EVALUATOR, "Evaluator" }, + { COREADMIN, "Core Administrator" }, + { NONE, NULL }, // this one has to be last +}; + +const char *ServiceManager::getServiceTypeName(FOURCC svc_type) { + for (int i = 0; ; i++) { + if (svc_names[i].name == NULL) break; + if (svc_names[i].type == svc_type) return svc_names[i].name; + } + return NULL; +} + +FOURCC ServiceManager::safe_getServiceType(waServiceFactory *was) { +#ifndef _DEBUG + return 0; +#endif + FOURCC type = 0; + _TRY + { + type = was->getServiceType(); + } + _EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + OutputDebugString("EXCEPTION_EXECUTE_HANDLER\n"); + } + return type; +} + +const char *ServiceManager::safe_getServiceName(waServiceFactory *was) { +#ifndef _DEBUG + return 0; +#endif + const char *name = NULL; + _TRY + { + name = was->getServiceName(); + } + _EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + OutputDebugString("EXCEPTION_EXECUTE_HANDLER\n"); + } + return name; +} + +void ServiceManager::onShutdown() { +/* + ownermap.purge(); + services.purge(); + services_by_guid.purge(); + clientmap.purge(); +*/ + + int nlocks = lockmap.getNumPairs(); + if (nlocks <= 0) { + //lockmap.purge(); + #ifdef GEN_FF // i need this to have clean session restart, feel free to remove the ifdef if you fgeel that should always be done + ownermap.deleteAll(); + services.multiRemoveAll(); + services_by_guid.deleteAll(); + lockmap.deleteAll(); + #endif + return; + } + +#ifndef _DEBUG + DebugString("-----------------\n"); + for (int i = 0; i < nlocks; i++) { + void *ptr = lockmap.enumIndexByPos(i, NULL); ASSERT(ptr != NULL); + StringPrintf s("lock: %d type:'", (int)ptr); + +// GUID g = lockermap.enumItemByPos(i, INVALID_GUID);ASSERT(g != INVALID_GUID); +// s += g; +// WaComponent *wac = ComponentManager::getComponentFromGuid(g); + + waServiceFactory *was=NULL; + was = lockmap.enumItemByPos(i, NULL); + ASSERT(was != NULL); + FOURCC type = safe_getServiceType(was); + const char *tname = ServiceManager::getServiceTypeName(type); + if (tname != NULL) { + s += tname; + } else { + FOURCC v = BSWAP(type); + unsigned char bleh[5]=" "; + MEMCPY(bleh, &v, 4); + s += String((char *)bleh); + } + s += "' from service:'"; + s += safe_getServiceName(was); + +// s += " wac:"; +// if (wac) s += wac->getName(); +#ifdef WASABI_COMPILE_COMPONENTS + s += "' owned by:'"; + + GUID g = INVALID_GUID; + ownermap.getItem(was, &g); + if (g != INVALID_GUID) { + s += g; + WaComponent *wac = ComponentManager::getComponentFromGuid(g); + if (wac) s += wac->getName(); + } else s += "(unregistered)"; +#else + GUID g; +#endif + + s += "' registered lock to '"; + g = INVALID_GUID; + //clientmap.getItem(ptr, &g); + s += g; + + s += "'\n"; + DebugString(s.v()); + } + DebugString("-----------------\n"); +#endif +#ifdef GEN_FF // i need this to have clean session restart, feel free to remove the ifdef if you fgeel that should always be done + ownermap.deleteAll(); + services.multiRemoveAll(); + services_by_guid.deleteAll(); + lockmap.deleteAll(); +#endif +} + +int ServiceManager::isValidService(FOURCC svctype, waServiceFactory *service) { + INCRITICALSECTION(cs); + return services.multiHaveItem(svctype, service); +} +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/service/svcmgr.h b/Src/Wasabi/api/service/svcmgr.h new file mode 100644 index 00000000..a9bcdc66 --- /dev/null +++ b/Src/Wasabi/api/service/svcmgr.h @@ -0,0 +1,41 @@ +#ifndef _SVCMGR_H +#define _SVCMGR_H + +#include + +class ServiceManager { +public: + static int registerService(waServiceFactory *service, GUID owner); + static int deregisterService(waServiceFactory *service, int internal = 0); + + static int getNumServices(FOURCC svc_type); + static waServiceFactory *enumService(FOURCC svc_type, int n); + + static waServiceFactory *getServiceByGuid(GUID guid); + + static void sendNotification(int msg, int param1 = 0, int param2 = 0); + + static int lock(waServiceFactory *owner, void *svcptr); + static int unlock(void *svcptr); + static int clientLock(void *svcptr, GUID lockedby); + static int release(void *svcptr); + + static GUID getOwningComponent(void *svcptr); + static GUID getLockingComponent(void *svcptr); + static const char *getServiceTypeName(FOURCC svc_type); + + static void onShutdown(); + + static FOURCC safe_getServiceType(waServiceFactory *was); + static const char *safe_getServiceName(waServiceFactory *was); + + static int getNumServices(); + static waServiceFactory *enumService(int n); + static int getNumServicesByGuid(); + static int getNumOwners(); + static int getNumLocks(); + + static int isValidService(FOURCC svctype, waServiceFactory *service); +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_accessibility.cpp b/Src/Wasabi/api/service/svcs/svc_accessibility.cpp new file mode 100644 index 00000000..37e6287b --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_accessibility.cpp @@ -0,0 +1,10 @@ +#include +#include "svc_accessibility.h" + +#define CBCLASS svc_accessibilityI +START_DISPATCH; + CB(SVC_ACCESSIBILITY_CREATEACCESSIBLEOBJECT, createAccessibleObject); +END_DISPATCH; +#undef CBCLASS + + diff --git a/Src/Wasabi/api/service/svcs/svc_accessibility.h b/Src/Wasabi/api/service/svcs/svc_accessibility.h new file mode 100644 index 00000000..60ad0c30 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_accessibility.h @@ -0,0 +1,43 @@ +#ifndef _SVC_ACCESSIBILITY_H +#define _SVC_ACCESSIBILITY_H + +#include +#include + +class Accessible; +class ifc_window; + +class NOVTABLE svc_accessibility : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::ACCESSIBILITY; } + + Accessible *createAccessibleObject(ifc_window *w); + + enum { + SVC_ACCESSIBILITY_CREATEACCESSIBLEOBJECT=10, + }; +}; + +inline Accessible *svc_accessibility::createAccessibleObject(ifc_window *w) { + return _call(SVC_ACCESSIBILITY_CREATEACCESSIBLEOBJECT, (Accessible *)NULL, w); +} + +class NOVTABLE svc_accessibilityI: public svc_accessibility { + public: + virtual Accessible *createAccessibleObject(ifc_window *w)=0; + + protected: + RECVS_DISPATCH; +}; + +#include +template +class AccessibilityCreatorSingle : public waServiceFactoryTSingle { +public: + svc_accessibility *getHandler() { + return waServiceFactoryTSingle::getSingleService(); + } +}; + + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_accroleserver.cpp b/Src/Wasabi/api/service/svcs/svc_accroleserver.cpp new file mode 100644 index 00000000..84bbaabf --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_accroleserver.cpp @@ -0,0 +1,70 @@ +#include + +#include "svc_accroleserver.h" +#include +#include + +#define CBCLASS svc_accRoleServerI +START_DISPATCH; + CB(RS_HANDLEROLE, handleRole); + CB(RS_CREATEOBJECT, createObject); + VCB(RS_DESTROYOBJECT, destroyObject); +END_DISPATCH; +#undef CBCLASS + + +#define CBCLASS roleServerObjectI +START_DISPATCH; + CB(RSO_WNDPROC, wndProc); + CB(RSO_GETHWND, gethWnd); + CB(RSO_FLATTENCONTENT, flattenContent); +END_DISPATCH; +#undef CBCLASS + + +roleServerObjectI::roleServerObjectI(HWND par, api_window *w) { + wnd = w; + hwnd = NULL; + parent = par; + triedyet = 0; +} + +roleServerObjectI::~roleServerObjectI() { + if (hwnd != NULL) + DestroyWindow(hwnd); +} + +api_window *roleServerObjectI::getWnd() { + return wnd; +} + +HWND roleServerObjectI::gethWnd() { + if (!triedyet) { + triedyet = 1; + hwnd = createWindow(parent); + if (hwnd !=NULL) + oldproc = (WNDPROC)GetWindowLong(hwnd, GWL_WNDPROC); + else + oldproc = NULL; + } + return hwnd; +} + +ScriptObject *roleServerObjectI::getScriptObject() { + if (wnd == NULL) return NULL; + GuiObject *go = wnd->getGuiObject(); + if (go == NULL) return NULL; + return go->guiobject_getScriptObject(); +} + +WNDPROC roleServerObjectI::getOldProc() { + return oldproc; +} + +int roleServerObjectI::wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + return CallWindowProc(oldproc, hWnd, uMsg, wParam, lParam); +} + +int roleServerObjectI::flattenContent(HWND *w) { + return FLATTENFLAG_ASKPARENT; +} diff --git a/Src/Wasabi/api/service/svcs/svc_accroleserver.h b/Src/Wasabi/api/service/svcs/svc_accroleserver.h new file mode 100644 index 00000000..ad40c149 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_accroleserver.h @@ -0,0 +1,132 @@ +#ifndef __SVC_ROLESERVER_H +#define __SVC_ROLESERVER_H + +#include +#include +#include +#include +#include + +class ifc_window; + +#define FLATTENFLAG_FLATTEN 1 +#define FLATTENFLAG_UNFLATTEN -1 +#define FLATTENFLAG_ASKPARENT 0 + +class NOVTABLE roleServerObject : public Dispatchable { + public: + int wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + HWND gethWnd(); + int flattenContent(HWND *w); + + enum { + RSO_WNDPROC=0, + RSO_GETHWND=10, + RSO_FLATTENCONTENT=20, + }; +}; + +inline int roleServerObject::wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + return _call(RSO_WNDPROC, 0, hWnd, uMsg, wParam, lParam); +} + +inline HWND roleServerObject::gethWnd() { + return _call(RSO_GETHWND, (HWND)NULL); +} + +inline int roleServerObject::flattenContent(HWND *w) { + return _call(RSO_FLATTENCONTENT, 0, w); +} + +class roleServerObjectI : public roleServerObject { + public: + + roleServerObjectI(HWND parent, ifc_window *w); + virtual ~roleServerObjectI(); + + virtual int wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + virtual HWND createWindow(HWND parent)=0; + virtual int flattenContent(HWND *w); + + protected: + + ScriptObject *getScriptObject(); + virtual ifc_window *getWnd(); + virtual HWND gethWnd(); + WNDPROC getOldProc(); + + HWND hwnd, parent; + ifc_window *wnd; + long (__stdcall *oldproc)(struct HWND__ *,unsigned int,unsigned int,long); + int triedyet; + + RECVS_DISPATCH; +}; + +class NOVTABLE svc_accRoleServer : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::ACCESSIBILITYROLESERVER; } + + int handleRole(int role); + roleServerObject *createObject(HWND parent, ifc_window *attached_wnd); + void destroyObject(roleServerObject *obj); + + enum { + RS_HANDLEROLE=10, + RS_CREATEOBJECT=20, + RS_DESTROYOBJECT=30 + }; + +}; + +inline int svc_accRoleServer::handleRole(int role) { + return _call(RS_HANDLEROLE, 0, role); +} + +inline roleServerObject *svc_accRoleServer::createObject(HWND parent, ifc_window *attached_wnd) { + return _call(RS_CREATEOBJECT, (roleServerObject *)NULL, parent, attached_wnd); +} + +inline void svc_accRoleServer::destroyObject(roleServerObject *obj) { + _voidcall(RS_DESTROYOBJECT, obj); +} + + + +class svc_accRoleServerI : public svc_accRoleServer { + + public: + + virtual int handleRole(int role)=0; + virtual roleServerObject *createObject(HWND parent, ifc_window *attached_wnd)=0; + virtual void destroyObject(roleServerObject *obj)=0; + + protected: + RECVS_DISPATCH; +}; + +#include +template +class AccRoleServerCreatorSingle : public waServiceFactoryTSingle { +public: + svc_accRoleServer *getHandler() { + return getSingleService(); + } +}; + +#include +#include + +class AccRoleServerEnum : public SvcEnumT { +public: + AccRoleServerEnum(int role) : roletest(role) { } +protected: + virtual int testService(svc_accRoleServer *svc) { + return (svc->handleRole(roletest)); + } +private: + int roletest; +}; + + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_action.cpp b/Src/Wasabi/api/service/svcs/svc_action.cpp new file mode 100644 index 00000000..bb6954de --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_action.cpp @@ -0,0 +1,38 @@ +#include + +#include "svc_action.h" + +#define CBCLASS svc_actionI +START_DISPATCH; +CB(HASACTION, hasAction); +CB(ONACTION, onAction); +END_DISPATCH; +#undef CBCLASS + +svc_actionI::~svc_actionI() +{ + actions.deleteAll(); +} + +void svc_actionI::registerAction(const wchar_t *actionid, int pvtid) +{ + ASSERT(actionid != NULL); + actions.addItem(new ActionEntry(actionid, pvtid)); +} + +int svc_actionI::hasAction(const wchar_t *name) +{ + if (name == NULL) return FALSE; + return (actions.findItem(name) != NULL); +} + +int svc_actionI::onAction(const wchar_t *action, const wchar_t *param, intptr_t p1, intptr_t p2, void *data, size_t datalen, ifc_window *source) +{ + if (action == NULL) return 0; + int pos = -1; + if (actions.findItem(action, &pos)) + { + return onActionId(actions.enumItem(pos)->getId(), action, param, p1, p2, data, datalen, source); + } + return 0; +} \ No newline at end of file diff --git a/Src/Wasabi/api/service/svcs/svc_action.h b/Src/Wasabi/api/service/svcs/svc_action.h new file mode 100644 index 00000000..45b87004 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_action.h @@ -0,0 +1,154 @@ +#ifndef _SVC_ACTION_H +#define _SVC_ACTION_H + +#include +#include +#include + +#include + +class ifc_window; + +class NOVTABLE svc_action : public Dispatchable { +protected: + svc_action() { } + +public: + static FOURCC getServiceType() { return WaSvc::ACTION; } + + int hasAction(const wchar_t *name); + int onAction(const wchar_t *action, const wchar_t *param=NULL, intptr_t p1=0, intptr_t p2=0, void *data=NULL, size_t datalen=0, ifc_window *source=NULL); + + enum { + HASACTION=10, + ONACTION=20, + }; + +}; + +inline int svc_action::hasAction(const wchar_t *name) { + return _call(HASACTION, 0, name); +} + +inline int svc_action::onAction(const wchar_t *action, const wchar_t *param, intptr_t p1, intptr_t p2, void *data, size_t datalen, ifc_window *source) { + return _call(ONACTION, 0, action, param, p1, p2, data, datalen, source); +} + +class ActionEntry { + public: + ActionEntry(const wchar_t *_action, int _id) : action(_action), id(_id) {} + virtual ~ActionEntry() { } + + const wchar_t *getAction() { return action; } + int getId() { return id; } + + private: + StringW action; + int id; +}; + +class SortActions { +public: + static int compareItem(ActionEntry *p1, ActionEntry *p2) { + return WCSICMP(p1->getAction(), p2->getAction()); + } + static int compareAttrib(const wchar_t *attrib, ActionEntry *item) { + return WCSICMP(attrib, item->getAction()); + } +}; + +class NOVTABLE svc_actionI : public svc_action { +public: + virtual ~svc_actionI(); + void registerAction(const wchar_t *actionid, int pvtid); + virtual int onActionId(int pvtid, const wchar_t *action, const wchar_t *param=NULL, int p1=0, int p2=0, void *data=NULL, int datalen=0, ifc_window *source=NULL)=0; + +protected: + virtual int hasAction(const wchar_t *name); + virtual int onAction(const wchar_t *action, const wchar_t *param=NULL, intptr_t p1=0, intptr_t p2=0, void *data=NULL, size_t datalen=0, ifc_window *source=NULL); + + PtrListQuickSorted actions; + + RECVS_DISPATCH; +}; +#include +template +class ActionCreator : public waServiceFactoryT {}; +template +class ActionCreatorSingle : public waServiceFactoryTSingle { +public: + svc_action *getHandler() { + return waServiceFactoryT::getSingleService(); + } +}; + +#include +#include + +class ActionEnum : public SvcEnumT { +public: + ActionEnum(const wchar_t *_action) : action(_action) { } +protected: + virtual int testService(svc_action *svc) { + return (!action.isempty() && svc->hasAction(action)); + } +private: + StringW action; +}; + +class FireAction { +public: + enum { + ACTION_NOT_HANDLED = 0x80000000 + }; + /** + Fire a named action out into the system with the given parameters. + + This method will only send the action to the first registered handler for that action. + + This prevents the action from being overridden or handled by newer wacs. + + The content and syntax of the generalized params are defined by the handler of the action string. + + Read: Using Wasabi: General Development: Actions + + @see svc_actionI + @param action The action string. + @param param A string parameter to the action. + @param p1 The first integer parameter to the action. + @param p2 The second integer parameter to the action. + @param data An untyped data buffer parameter to the action. + @param datalen The size in bytes of the data buffer parameter. + @param source A window object that can be given as the source object, if the action handler is expecting one. Actions bound to guiobjects use that guiobject's rootwnd pointer as the source. + @param apply_to_all Send the action to everyone. (If false only sends to first registered) + */ + FireAction(const wchar_t *action, const wchar_t *param = NULL, intptr_t p1 = 0, intptr_t p2 = 0, void *data = NULL, size_t datalen = 0, ifc_window *source = NULL, int apply_to_all = TRUE) { + lastretval = ACTION_NOT_HANDLED; + ActionEnum ae(action); + svc_action *act; + while ((act = ae.getNext()) != NULL) { + lastretval = act->onAction(action, param, p1, p2, data, datalen, source); + ae.release(act); + if (!apply_to_all) break; + } + } + /** + More robust retval handling is needed. + + I ought to be grabbing all of the return values into a list an exposing that. + + Later. + + Read: Using Wasabi: General Development: Actions + + @see svc_actionI + @ret The return code of the action sent. + */ + int getLastReturnValue() { + return lastretval; + } +private: + int lastretval; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_burner.cpp b/Src/Wasabi/api/service/svcs/svc_burner.cpp new file mode 100644 index 00000000..896a984b --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_burner.cpp @@ -0,0 +1,70 @@ +#include +#include "svc_burner.h" +#include + +#define CBCLASS svc_mediaRecorderI +START_DISPATCH; + CB(ISSESSIONSUPPORTED,isSessionSupported) + CB(ISMEDIASUPPORTED,isMediaSupported) + CB(GETNUMDEVICES,getNumDevices) + CB(ENUMDEVICE,enumDevice) + VCB(REFRESHDEVICES,refreshDevices) +END_DISPATCH; +#undef CBCLASS + +#define CBCLASS MediaRecorder::DeviceI +START_DISPATCH; + CB(GETDEPENDENCYPTR,getDependencyPtr) + CB(GETDEVICENAME,getDeviceName) + CB(GETDEVICETYPE,getDeviceType) + CB(GETDEVICEDESCRIPTION,getDeviceDescription) + CB(ENUMDEVICESPEEDS,enumDeviceSpeeds) + CB(GETMEDIASIZE,getMediaSize) + CB(GETMEDIAFREE,getMediaFree) + VCB(CLEARSESSIONS,clearSessions) + CB(ADDSESSION,addSession) + CB(GETSESSION,getSession) + CB(SETRECORDSPEED,setRecordSpeed) + CB(SETTEST,setTest) + CB(SETCLOSEDISC,setCloseDisc) + CB(CANBURNNOW,canBurnNow) + CB(CANCANCEL,canCancel) + CB(BEGIN,begin) + CB(END,end) + CB(CANCEL,cancel) + CB(GETSTATUS,getStatus) + CB(GETPROGRESS,getProgress) + CB(GETSTATUSTEXT,getStatusText) + CB(GETLASTERROR,getLastError) +END_DISPATCH; +#undef CBCLASS + +#define CBCLASS MediaRecorder::SessionI +START_DISPATCH; + CB(GETSESSIONTYPE,getSessionType) + CB(CLOSESESSION,closeSession) + CB(GETNUMENTRIES,getNumEntries) + CB(ENUMENTRY,enumEntry) + CB(GETTOTALBYTES,getTotalBytes) + CB(GETTOTALTIME,getTotalTime) +END_DISPATCH; +#undef CBCLASS + +const char *MediaRecorder::RedbookSession::enumEntry(int n) { + if( n>=getNumEntries()) return NULL; + return m_tracks[n]->getValue(); +} + +int MediaRecorder::RedbookSession::getTotalBytes() { + double length=(double)getTotalTime(); + return (int)(length*(44100*4)/1000); //always 44khz 16bps stereo +} + +int MediaRecorder::RedbookSession::getTotalTime() { + int total=0; + for(int i=0;imetadb_getLength(m_tracks[i]->getValue()))!=-1) total+=length; + } + return total; +} diff --git a/Src/Wasabi/api/service/svcs/svc_burner.h b/Src/Wasabi/api/service/svcs/svc_burner.h new file mode 100644 index 00000000..88f690af --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_burner.h @@ -0,0 +1,243 @@ +#ifndef _SVC_BURNER_H +#define _SVC_BURNER_H + +#include +#include +#include +#include + +namespace MediaRecorder { + +class Session : public Dispatchable { +protected: + Session() {} // protect constructor + +public: + int getSessionType() { return _call(GETSESSIONTYPE,0); } + enum { + Session_REDBOOK, Session_DATA, Session_ISO + }; + int closeSession() { return _call(CLOSESESSION,0); } + int getNumEntries() { return _call(GETNUMENTRIES,0); } + const char *enumEntry(int n) { return _call(ENUMENTRY,(const char *)NULL,n); } + int getTotalBytes() { return _call(GETTOTALBYTES,0); } + int getTotalTime() { return _call(GETTOTALTIME,0); } + + enum { + GETSESSIONTYPE=10, + CLOSESESSION=20, + GETNUMENTRIES=30, + ENUMENTRY=40, + GETTOTALBYTES=50, + GETTOTALTIME=60, + }; +}; + +// this represents one session on the cd +// normal audio cds have 1 redbook session, mixed mode has 2 (or more), with +// 1 audio followed by 1 or more data +class SessionI : public Session { +public: + virtual int getSessionType()=0; + + virtual int closeSession()=0; + virtual int getNumEntries()=0; + virtual const char *enumEntry(int n)=0; + virtual int getTotalBytes()=0; //total space used in bytes + virtual int getTotalTime()=0; //total time used in ms + +protected: + RECVS_DISPATCH; +}; + +class RedbookSession : public SessionI { +public: + virtual ~RedbookSession() { m_tracks.deleteAll(); } + + int getSessionType() { return Session_REDBOOK; } + + int closeSession() { return 1; } + + void addEntry(const char *file) { m_tracks.addItem(new String(file)); } + int getNumEntries() { return m_tracks.getNumItems(); } + void removeEntry(int n) { m_tracks.deleteItem(n); } + void clearEntries() { m_tracks.deleteAll(); } + + const char *enumEntry(int n); + int getTotalBytes(); + int getTotalTime(); + +protected: + PtrList m_tracks; +}; + +// this is the physical device +class Device : public Dispatchable { +protected: + Device() {} // protect constructor + +public: + static const GUID *depend_getClassGuid() { + // {23F48039-455D-4348-86D5-0A82754678FC} + static const GUID ret = + { 0x23f48039, 0x455d, 0x4348, { 0x86, 0xd5, 0xa, 0x82, 0x75, 0x46, 0x78, 0xfc } }; + return &ret; + } + + api_dependent *getDependencyPtr() { return _call(GETDEPENDENCYPTR,(api_dependent *)NULL); } + + const char *getDeviceName() { return _call(GETDEVICENAME,(const char *)NULL); } + const char *getDeviceType() { return _call(GETDEVICETYPE,(const char *)NULL); } + const char *getDeviceDescription() { return _call(GETDEVICEDESCRIPTION,(const char *)NULL); } + + int enumDeviceSpeeds(int n) { return _call(ENUMDEVICESPEEDS,0,n); } + + int getMediaSize() { return _call(GETMEDIASIZE,0); } + int getMediaFree() { return _call(GETMEDIAFREE,0); } + + void clearSessions() { _voidcall(CLEARSESSIONS); } + int addSession(Session *session) { return _call(ADDSESSION,0,session); } + Session *getSession(int num) { return _call(GETSESSION,(Session *)NULL,num); } + + int setRecordSpeed(int kbps) { return _call(SETRECORDSPEED,0,kbps); } + int setTest(int testmode) { return _call(SETTEST,0,testmode); } + int setCloseDisc(int closedisc) { return _call(SETCLOSEDISC,0,closedisc); } + + int canBurnNow() { return _call(CANBURNNOW,0); } + int canCancel() { return _call(CANCANCEL,0); } + + int begin() { return _call(BEGIN,0); } + int end() { return _call(END,0); } + int cancel() { return _call(CANCEL,0); } + + int getStatus() { return _call(GETSTATUS,0); } + enum { + Status_IDLE, Status_PREPARING, Status_BURNING, Status_DONE, + }; + + int getProgress() { return _call(GETPROGRESS,0); } + const char *getStatusText() { return _call(GETSTATUSTEXT,(const char *)NULL); } + + const char *getLastError() { return _call(GETLASTERROR,(const char *)NULL); } + + enum { + Event_PREPAREBEGIN=100, + Event_MEDIATRANSCODED=200, // params is item # + Event_PREPAREEND=300, + Event_BURNBEGIN=400, + Event_ENTRYCOMPLETE=500, // param is the position in bytes + Event_SESSIONCOMPLETE=600, + Event_BURNEND=700, + Event_ERROR=800, + Event_MEDIACHANGE=900, // user put in a different disc + }; + + enum { + GETDEPENDENCYPTR=10, + GETDEVICENAME=20, + GETDEVICETYPE=30, + GETDEVICEDESCRIPTION=40, + ENUMDEVICESPEEDS=50, + GETMEDIASIZE=60, + GETMEDIAFREE=70, + CLEARSESSIONS=80, + ADDSESSION=90, + GETSESSION=100, + SETRECORDSPEED=110, + SETTEST=120, + SETCLOSEDISC=130, + CANBURNNOW=140, + CANCANCEL=150, + BEGIN=160, + END=170, + CANCEL=180, + GETSTATUS=190, + GETPROGRESS=200, + GETSTATUSTEXT=210, + GETLASTERROR=220, + }; +}; + +class DeviceI : public Device { +public: + virtual api_dependent *getDependencyPtr()=0; // for events + + virtual const char *getDeviceName()=0; // internal device name + virtual const char *getDeviceType()=0; // "CD-R", "CD-RW", "DVD-R" etc + virtual const char *getDeviceDescription()=0; // user readable string + + virtual int enumDeviceSpeeds(int n)=0; // in kb/s + + virtual int getMediaSize()=0; // total space in bytes + virtual int getMediaFree()=0; // free space in bytes + + virtual void clearSessions()=0; + virtual int addSession(Session *session)=0; + virtual Session *getSession(int num)=0; + + virtual int setRecordSpeed(int kbps)=0; //kbps==0 means max speed + virtual int setTest(int testmode)=0; // if true, don't really burn + virtual int setCloseDisc(int closedisc)=0; // if true, close entire disc at end + + virtual int canBurnNow()=0; // return 1 if everything's ready + virtual int canCancel()=0; // return 1 if we can cancel (during burning) + + virtual int begin()=0; + virtual int end()=0; + virtual int cancel()=0; + + virtual int getStatus()=0; + virtual int getProgress()=0; // # of bytes written + virtual const char *getStatusText()=0; // like "xx% complete" or something + + virtual const char *getLastError()=0; + +protected: + RECVS_DISPATCH; +}; + +}; // end namespace MediaRecorder + +//don't override this one +class NOVTABLE svc_mediaRecorder : public Dispatchable { +protected: + svc_mediaRecorder() {} // protect constructor + +public: + static FOURCC getServiceType() { return WaSvc::MEDIARECORDER; } + + int isSessionSupported(MediaRecorder::Session *session) { return _call(ISSESSIONSUPPORTED,0,session); } + int isMediaSupported(const char *medianame) { return _call(ISMEDIASUPPORTED,0,medianame); } + + int getNumDevices() { return _call(GETNUMDEVICES,0); } + MediaRecorder::Device *enumDevice(int n) { return _call(ENUMDEVICE,(MediaRecorder::Device*)NULL,n); } + + void refreshDevices() { _voidcall(REFRESHDEVICES); } + + enum { + ISSESSIONSUPPORTED=10, + ISMEDIASUPPORTED=20, + GETNUMDEVICES=30, + ENUMDEVICE=40, + REFRESHDEVICES=50, + }; +}; + +// this should be implemented by a given burning lib +class NOVTABLE svc_mediaRecorderI : public svc_mediaRecorder { +public: + static FOURCC getServiceType() { return WaSvc::MEDIARECORDER; } + + virtual int isSessionSupported(MediaRecorder::Session *session)=0; + virtual int isMediaSupported(const char *medianame)=0;// "CD-R", "DVD-R", etc. + + virtual int getNumDevices()=0; + virtual MediaRecorder::Device *enumDevice(int n)=0; + + virtual void refreshDevices()=0; + +protected: + RECVS_DISPATCH; +}; + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/service/svcs/svc_collection.cpp b/Src/Wasabi/api/service/svcs/svc_collection.cpp new file mode 100644 index 00000000..9e9e3a67 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_collection.cpp @@ -0,0 +1,194 @@ +#include + +#include "svc_collection.h" + +// an named xml overridable collection of objects + +#define CBCLASS svc_collectionI +START_DISPATCH; + CB(COLLECTION_TESTTAG, testTag); + VCB(COLLECTION_ADDELEMENT, addElement); + VCB(COLLECTION_REMOVEELEMENT, removeElement); + VCB(COLLECTION_REMOVEALLELEMENTS, removeAllElements); + CB(COLLECTION_GETNUMELEMENTS, getNumElements); + CB(COLLECTION_GETNUMELEMENTSUNIQUE, getNumElementsUnique); + CB(COLLECTION_ENUMELEMENT, enumElement); + CB(COLLECTION_ENUMELEMENTUNIQUE, enumElementUnique); + CB(COLLECTION_GETELEMENT, getElement); +END_DISPATCH; +#undef CBCLASS + +#define CBCLASS CollectionElementI +START_DISPATCH; + CB(COLLECTIONELEMENT_GETID, getId); + CB(COLLECTIONELEMENT_GETPARAMVALUE, getParamValue); + CB(COLLECTIONELEMENT_GETPARAMVALUEINT, getParamValueInt); + CB(COLLECTIONELEMENT_GETINCLUDEPATH, getIncludePath); +END_DISPATCH; +#undef CBCLASS + + +svc_collectionI::svc_collectionI() { + count = 0; + elements.setAutoSort(1); +} + +svc_collectionI::~svc_collectionI() { +} + +void svc_collectionI::addElement(const char *id, const char *includepath, int incrementalremovalid, skin_xmlreaderparams *params) { + CollectionElementI *cei = new CollectionElementI(this, id, params, incrementalremovalid, includepath); + elements.addItem(cei); +} + +void svc_collectionI::removeElement(int removalid) { + for (int i=0;igetSecCount() == removalid) { + elements.removeItem(e); + delete e; + i--; + } + } +} + +void svc_collectionI::removeAllElements() { + elements.deleteAll(); +} + +int svc_collectionI::getNumElements() { + return elements.getNumItems(); +} + +int svc_collectionI::getNumElementsUnique() { + int i=0; + int n=0; + const char *previous = NULL; + for (i=0;igetId(); + if (!STRCASEEQLSAFE(id, previous)) + n++; + previous = id; + } + return n; +} + +CollectionElement *svc_collectionI::enumElementUnique(int n, int *ancestor) { + int i=0; + int _n=-1; + CollectionElement *e=NULL; + CollectionElement *previous = NULL; + elements.sort(1); + for (i=0;igetId(), previous ? previous->getId() : NULL)) { + if (_n == n) + break; + _n++; + } + previous = c; + } + if (_n == n) + e = previous; + else + e = NULL; + if (ancestor != NULL) { + if (e != NULL) { + int pos=-1; + elements.findItem(static_cast(e), &pos); + if (pos > 0) { + CollectionElement *f = elements.enumItem(pos-1); + if (!STRCASEEQLSAFE(f ? f->getId() : NULL, e->getId())) *ancestor = -1; + } else { + *ancestor = -1; + e = NULL; + } + } else + *ancestor = -1; + } + return e; +} + +CollectionElement *svc_collectionI::enumElement(int n, int *ancestor) { + CollectionElement *e = elements.enumItem(n); + if (ancestor != NULL) { + CollectionElement *a = elements.enumItem(n-1); + if (!STRCASEEQL(a->getId(), e->getId())) *ancestor = -1; + *ancestor = n-1; + } + return e; +} + +CollectionElement *svc_collectionI::getElement(const char *id, int *ancestor) { + int pos=-1; + CollectionElement *e = elements.findLastItem(id, &pos); + if (ancestor != NULL) { + CollectionElement *a = elements.enumItem(pos-1); + if (!STRCASEEQL(a->getId(), e->getId())) *ancestor = -1; + *ancestor = pos-1; + } + return e; +} + +CollectionElement *svc_collectionI::getAncestor(CollectionElement *e) { + int pos=-1; + CollectionElementI *ei = static_cast(e); + elements.findItem(ei, &pos); + if (pos >= 0) { + pos--; + if (STRCASEEQL(elements.enumItem(pos)->getId(), e->getId())) return elements.enumItem(pos); + } + return NULL; +} + +CollectionElementI::CollectionElementI(svc_collectionI *col, const char *_id, skin_xmlreaderparams *p, int _seccount, const char *_path) { + id = _id; + for (int i=0;igetNbItems();i++) { + Pair < String, String > *pr = new Pair < String, String >("",""); + pr->a = p->getItemName(i); + pr->b = p->getItemValue(i); + params.addItem(pr); + } + seccount = _seccount; + collection = col; + path = _path; +} + +CollectionElementI::~CollectionElementI() { + params.deleteAll(); +} + +const char *CollectionElementI::getId() { + return id; +} + +const char *CollectionElementI::getParamValue(const char *param, CollectionElement **item){ + CollectionElement *e = getAncestor(); + const char *a = e ? e->getParamValue(param) : NULL; + Pair *p = params.findItem(param); + a = p ? p->b.getValue() : a; + if (item && p != NULL) *item = this; + return a; +} + +int CollectionElementI::getParamValueInt(const char *param){ + const char *a = getParamValue(param); + return ATOI(a); +} + +int CollectionElementI::getSecCount() { + return seccount; +} + +CollectionElement *CollectionElementI::getAncestor() { + return collection->getAncestor(this); +} + +const char *CollectionElementI::getIncludePath(const char *param/* =NULL */) { + if (param == NULL) return path; + CollectionElement *i; + if (!getParamValue(param, &i)) return NULL; + if (i != NULL) + return i->getIncludePath(NULL); + return NULL; +} \ No newline at end of file diff --git a/Src/Wasabi/api/service/svcs/svc_collection.h b/Src/Wasabi/api/service/svcs/svc_collection.h new file mode 100644 index 00000000..9769d5a3 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_collection.h @@ -0,0 +1,226 @@ +#ifndef _SVC_COLLECTION_H +#define _SVC_COLLECTION_H + +#include +#include +#include +#include +#include + +class CollectionElement; +class svc_collectionI; + +class NOVTABLE svc_collection : public Dispatchable +{ +public: + static FOURCC getServiceType() { return WaSvc::COLLECTION; } + int testTag(const wchar_t *xmltag); + void addElement(const wchar_t *id, const wchar_t *includepath, int removalid, skin_xmlreaderparams *params); + void removeElement(int recored_value); + void removeAllElements(); + int getNumElements(); + int getNumElementsUnique(); + CollectionElement *enumElement(int n, int *ancestor); + CollectionElement *enumElementUnique(int n, int *ancestor); + CollectionElement *getElement(const wchar_t *id, int *ancestor); + CollectionElement *getAncestor(CollectionElement *e); + + enum + { + COLLECTION_TESTTAG=10, + COLLECTION_ADDELEMENT=20, + COLLECTION_REMOVEELEMENT=30, + COLLECTION_REMOVEALLELEMENTS=35, + COLLECTION_GETNUMELEMENTS=40, + COLLECTION_GETNUMELEMENTSUNIQUE=50, + COLLECTION_ENUMELEMENT=60, + COLLECTION_ENUMELEMENTUNIQUE=70, + COLLECTION_GETELEMENT=80, + }; +}; + +inline int svc_collection::testTag(const wchar_t *xmltag) { + return _call(COLLECTION_TESTTAG, 0, xmltag); +} + +inline void svc_collection::addElement(const wchar_t *id, const wchar_t *includepath, int incrementalremovalid, skin_xmlreaderparams *params) { + _voidcall(COLLECTION_ADDELEMENT, id, includepath, incrementalremovalid, params); +} + +inline void svc_collection::removeElement(int removalid) { + _voidcall(COLLECTION_REMOVEELEMENT, removalid); +} + +inline void svc_collection::removeAllElements() { + _voidcall(COLLECTION_REMOVEALLELEMENTS); +} + +inline int svc_collection::getNumElements() { + return _call(COLLECTION_GETNUMELEMENTS, 0); +} + +inline int svc_collection::getNumElementsUnique() { + return _call(COLLECTION_GETNUMELEMENTSUNIQUE, 0); +} + +inline CollectionElement *svc_collection::enumElement(int n, int *ancestor) { + return _call(COLLECTION_ENUMELEMENT, (CollectionElement *)NULL, n, ancestor); +} + +inline CollectionElement *svc_collection::enumElementUnique(int n, int *ancestor) { + return _call(COLLECTION_ENUMELEMENTUNIQUE, (CollectionElement *)NULL, n, ancestor); +} + +inline CollectionElement *svc_collection::getElement(const wchar_t *id, int *ancestor) { + return _call(COLLECTION_GETELEMENT, (CollectionElement *)NULL, id, ancestor); +} + +class SortPairString { +public: + static int compareItem(Pair *p1, Pair *p2) { + return WCSICMP(p1->a, p2->a); + } + static int compareAttrib(const wchar_t *attrib, Pair *item) { + return WCSICMP(attrib, item->a); + } +}; + +class CollectionElement : public Dispatchable { + public: + const wchar_t *getId(); + const wchar_t *getParamValue(const wchar_t *param, CollectionElement **item=NULL); + int getParamValueInt(const wchar_t *param); + const wchar_t *getIncludePath(const wchar_t *param=NULL); + CollectionElement *getAncestor(); + + enum { + COLLECTIONELEMENT_GETID=10, + COLLECTIONELEMENT_GETPARAMVALUE=20, + COLLECTIONELEMENT_GETPARAMVALUEINT=30, + COLLECTIONELEMENT_GETANCESTOR=40, + COLLECTIONELEMENT_GETINCLUDEPATH=50, + }; +}; + +inline const wchar_t *CollectionElement::getId() { + return _call(COLLECTIONELEMENT_GETID, (const wchar_t *)NULL); +} + +inline const wchar_t *CollectionElement::getParamValue(const wchar_t *param, CollectionElement **item) { + return _call(COLLECTIONELEMENT_GETPARAMVALUE, (const wchar_t *)NULL, param, item); +} + +inline int CollectionElement::getParamValueInt(const wchar_t *param) { + return _call(COLLECTIONELEMENT_GETPARAMVALUEINT, 0, param); +} + +inline CollectionElement *CollectionElement::getAncestor() { + return _call(COLLECTIONELEMENT_GETANCESTOR, (CollectionElement *)NULL); +} + +inline const wchar_t *CollectionElement::getIncludePath(const wchar_t *param) { + return _call(COLLECTIONELEMENT_GETINCLUDEPATH, (const wchar_t *)NULL, param); +} + +class CollectionElementI : public CollectionElement { + public: + CollectionElementI(svc_collectionI *collectionI, const wchar_t *id, skin_xmlreaderparams *params, int seccount, const wchar_t *includepath); + virtual ~CollectionElementI(); + + virtual const wchar_t *getId(); + virtual const wchar_t *getParamValue(const wchar_t *param, CollectionElement **item=NULL); + virtual int getParamValueInt(const wchar_t *param); + virtual CollectionElement *getAncestor(); + const wchar_t *getIncludePath(const wchar_t *param=NULL); // null returns last override's include path + + int getSecCount(); + + protected: + RECVS_DISPATCH; + + PtrListQuickSorted < Pair < StringW, StringW >, SortPairString > params; + StringW id; + int seccount; + svc_collectionI *collection; + StringW path; +}; + +class SortCollectionElementsI { +public: + static int compareItem(CollectionElementI *p1, CollectionElementI *p2) { + int r = WCSICMP(p1->getId(), p2->getId()); + if (r == 0) { + if (p1->getSecCount() < p2->getSecCount()) return -1; + if (p1->getSecCount() > p2->getSecCount()) return 1; + return 0; + } + return r; + } + static int compareAttrib(const wchar_t *attrib, CollectionElementI *item) { + return WCSICMP(attrib, item->getId()); + } +}; + +// derive from this one +class svc_collectionI : public svc_collection { +public: + svc_collectionI(); + virtual ~svc_collectionI(); + virtual int testTag(const wchar_t *xmltag)=0; + virtual void addElement(const wchar_t *id, const wchar_t *includepath, int incrementalremovalid, skin_xmlreaderparams *params); + virtual void removeElement(int removalid); + virtual void removeAllElements(); + virtual int getNumElements(); + virtual int getNumElementsUnique(); + virtual CollectionElement *enumElement(int n, int *ancestor); + virtual CollectionElement *enumElementUnique(int n, int *ancestor); + virtual CollectionElement *getElement(const wchar_t *id, int *ancestor); + virtual CollectionElement *getAncestor(CollectionElement *e); + +protected: + RECVS_DISPATCH; + + PtrListQuickMultiSorted < CollectionElementI, SortCollectionElementsI > elements; + int count; +}; + +#include +template +class CollectionCreator : public waServiceFactoryTSingle {}; + +template +class CollectionSvc : public svc_collectionI { + public: + int testTag(const wchar_t *xmltag) { + if (!WCSICMP(xmltag, TAG)) return 1; + return 0; + } + static const char *getServiceName() { return StringPrintf("Collection Service for \"%S\"", TAG); } +}; + +template +class CollectionSvc2 : public svc_collectionI { + public: + int testTag(const wchar_t *xmltag) { + if (STRCASEEQL(xmltag, T::collection_getXmlTag())) return 1; + return 0; + } + static const char *getServiceName() { return StringPrintf("Collection Service for \"%S\"", T::collection_getXmlTag()); } +}; + + +#include +#include +class CollectionSvcEnum : public SvcEnumT +{ +public: + CollectionSvcEnum(const wchar_t *xmltag) : tag(xmltag) {} +protected: + virtual int testService(svc_collection *svc) { + return (svc->testTag(tag)); + } +private: + StringW tag; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_console.cpp b/Src/Wasabi/api/service/svcs/svc_console.cpp new file mode 100644 index 00000000..c34bb156 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_console.cpp @@ -0,0 +1,10 @@ + +#include + +#define CBCLASS svc_consoleI +START_DISPATCH; + CB(ACTIVATED, activated); + CB(OUTPUTSTRING, outputString); +END_DISPATCH; +#undef CBCLASS + diff --git a/Src/Wasabi/api/service/svcs/svc_console.h b/Src/Wasabi/api/service/svcs/svc_console.h new file mode 100644 index 00000000..696b7897 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_console.h @@ -0,0 +1,36 @@ +#ifndef _SVC_CONSOLE_H +#define _SVC_CONSOLE_H + +#include + +class NOVTABLE svc_console : public Dispatchable +{ +public: + int activated(); + int outputString(int severity, const char *string); + + enum { + ACTIVATED=10, + OUTPUTSTRING=20, + }; +}; + +inline int svc_console::activated() { + return _call(ACTIVATED, 0); +} + +inline int svc_console::outputString(int severity, const char *string) { + return _call(OUTPUTSTRING, 0, severity, string); +} + +// derive from this one +class svc_consoleI : public svc_console { +public: + virtual int activated()=0; + virtual int outputString(int severity, const char *string)=0; + +protected: + RECVS_DISPATCH; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_contextCmd.cpp b/Src/Wasabi/api/service/svcs/svc_contextCmd.cpp new file mode 100644 index 00000000..da220cfa --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_contextCmd.cpp @@ -0,0 +1,16 @@ +#include + +#include "svc_contextcmd.h" + +#define CBCLASS svc_contextCmdI +START_DISPATCH; + CB(TESTITEM, testItem); + CB(GETSUBMENU, getSubMenu); + CB(GETSUBMENUTEXT, getSubMenuText); + CB(GETCOMMAND, getCommand); + CB(GETENABLED, getEnabled); + CB(GETCHECKED, getChecked); + CB(GETSORTVAL, getSortVal); + VCB(ONCOMMAND, onCommand); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_contextCmd.h b/Src/Wasabi/api/service/svcs/svc_contextCmd.h new file mode 100644 index 00000000..06a0aff5 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_contextCmd.h @@ -0,0 +1,127 @@ +#ifndef _SVC_CONTEXTCMD_H +#define _SVC_CONTEXTCMD_H + +#include +#include + +namespace ContextCmdSortVal { + enum ContextCmdSortVal { + BEGINNING = 0, + MIDDLE = 32767, + END = 65535, + }; +}; + +class DragItem; + +class NOVTABLE svc_contextCmd : public Dispatchable { +protected: + svc_contextCmd() {} + ~svc_contextCmd() {} +public: + static FOURCC getServiceType() { return WaSvc::CONTEXTCMD; } + + int testItem(DragItem *item, const wchar_t *menu_path); + + int getSubMenu(DragItem *item, const wchar_t *menu_path); + const wchar_t *getSubMenuText(const wchar_t *menu_path); + + const wchar_t *getCommand(DragItem *item, int n); + + int getEnabled(DragItem *item, int n); + int getChecked(DragItem *item, int n); + int getSortVal(DragItem *item, int n); + + void onCommand(DragItem *item, int n); + +protected: + enum { + TESTITEM, + GETSUBMENU, + GETSUBMENUTEXT, + GETCOMMAND, + GETENABLED, + GETCHECKED, + GETSORTVAL, + ONCOMMAND, + }; +}; + +inline int svc_contextCmd::testItem(DragItem *item, const wchar_t *menu_path) { + return _call(TESTITEM, 0, item, menu_path); +} + +inline +int svc_contextCmd::getSubMenu(DragItem *item, const wchar_t *menu_path) { + return _call(GETSUBMENU, 0, item, menu_path); +} + +inline +const wchar_t *svc_contextCmd::getSubMenuText(const wchar_t *menu_path) { + return _call(GETSUBMENUTEXT, (const wchar_t *)NULL, menu_path); +} + +inline const wchar_t *svc_contextCmd::getCommand(DragItem *item, int n) { + return _call(GETCOMMAND, (const wchar_t *)0, item, n); +} + +inline int svc_contextCmd::getEnabled(DragItem *item, int n) { + return _call(GETENABLED, TRUE, item, n); +} + +inline int svc_contextCmd::getChecked(DragItem *item, int n) { + return _call(GETCHECKED, FALSE, item, n); +} + +inline int svc_contextCmd::getSortVal(DragItem *item, int n) { + return _call(GETSORTVAL, ContextCmdSortVal::MIDDLE, item, n); +} + +inline void svc_contextCmd::onCommand(DragItem *item, int n) { + _voidcall(ONCOMMAND, item, n); +} + +class NOVTABLE svc_contextCmdI : public svc_contextCmd { +public: + virtual int testItem(DragItem *item, const wchar_t *menu_path)=0; + + virtual int getSubMenu(DragItem *item, const wchar_t *menu_path) { return 0; } + virtual const wchar_t *getSubMenuText(const wchar_t *menu_path) { return NULL; } + + virtual const wchar_t *getCommand(DragItem *item, int n)=0; + + // override these as needed + virtual int getEnabled(DragItem *item, int n) { return TRUE; } + virtual int getChecked(DragItem *item, int n) { return FALSE; } + virtual int getSortVal(DragItem *item, int n) { return ContextCmdSortVal::MIDDLE; } + + virtual void onCommand(DragItem *item, int n)=0; + +protected: + RECVS_DISPATCH; +}; + +#include + +template +class ContextCmdCreator : public waServiceFactoryT { }; + +#include +#include + +class ContextCmdEnum : public SvcEnumT { +public: + ContextCmdEnum(DragItem *_item, const wchar_t *_menu_path) + : item(_item), menu_path(_menu_path) {} + +protected: + virtual int testService(svc_contextCmd *svc) { + return svc->testItem(item, menu_path); + } + +private: + DragItem *item; + StringW menu_path; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_coreadmin.cpp b/Src/Wasabi/api/service/svcs/svc_coreadmin.cpp new file mode 100644 index 00000000..5b7890e9 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_coreadmin.cpp @@ -0,0 +1,70 @@ +#include + +#include "svc_coreadmin.h" + +#define CBCLASS svc_coreAdminI +START_DISPATCH; + CB(CREATECORE,createCore) + CB(NAMETOTOKEN,nameToToken) + CB(FREECOREBYTOKEN,freeCoreByToken) + CB(FREECOREBYNAME,freeCoreByName) + CB(VERIFYTOKEN,verifyToken) + + CB(GETSUPPORTEDEXTENSIONS,getSupportedExtensions) + CB(GETEXTSUPPORTEDEXTENSIONS,getExtSupportedExtensions) + VCB(REGISTEREXTENSION,registerExtension) + CB(GETEXTENSIONFAMILY, getExtensionFamily); + VCB(UNREGISTEREXTENSION,unregisterExtension) + + CB(SETNEXTFILE,setNextFile) + CB(SETNEXTFILEOLD,setNextFile) + + CB(GETSTATUS,getStatus) + CB(GETCURRENT,getCurrent) + CB(GETCURPLAYBACKNUMBER,getCurPlaybackNumber) + CB(GETNUMTRACKS, getNumTracks); + CB(GETPOSITION,getPosition) + CB(GETWRITEPOSITION,getWritePosition) + CB(GETLENGTH,getLength) + CB(GETPLUGINDATA,getPluginData) + CB(GETVOLUME,getVolume) + CB(GETPAN,getPan) + CB(GETVISDATA,getVisData) + CB(GETLEFTVUMETER,getLeftVuMeter) + CB(GETRIGHTVUMETER,getRightVuMeter) + CB(GETEQSTATUS,getEqStatus) + CB(GETEQPREAMP,getEqPreamp) + CB(GETEQBAND,getEqBand) + CB(GETEQAUTO,getEqAuto) + CB(GETMUTE,getMute) + + CB(SETPOSITION,setPosition) + VCB(SETVOLUME,setVolume) + VCB(SETPAN,setPan) + VCB(SETEQSTATUS,setEqStatus) + VCB(SETEQPREAMP,setEqPreamp) + VCB(SETEQBAND,setEqBand) + VCB(SETEQAUTO,setEqAuto) + VCB(SETMUTE,setMute) + CB(GETTITLE,getTitle); + + VCB(ADDCALLBACK,addCallback) + VCB(DELCALLBACK,delCallback) + + CB(REGISTERSEQUENCER,registerSequencer) + CB(DEREGISTERSEQUENCER,deregisterSequencer) + CB(GETSEQUENCER,getSequencer) + + VCB(USERBUTTON,userButton) + + VCB(SETCUSTOMMSG, setCustomMsg) + + VCB(SETPRIORITY, setPriority) + CB(GETPRIORITY, getPriority) + + VCB(REBUILDCONVERTERSCHAIN, rebuildConvertersChain) + CB(SENDCONVERTERSMSG, sendConvertersMsg) + +END_DISPATCH; +#undef CBCLASS + diff --git a/Src/Wasabi/api/service/svcs/svc_coreadmin.h b/Src/Wasabi/api/service/svcs/svc_coreadmin.h new file mode 100644 index 00000000..276b48c2 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_coreadmin.h @@ -0,0 +1,230 @@ +#ifndef _SVC_COREADMIN_H +#define _SVC_COREADMIN_H + +#include +#include +#include +#include + +// There is only ONE INSTANCE of the coreadmin running in the application +class NOVTABLE svc_coreAdmin : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::COREADMIN; } + + // create a new playback core + CoreToken createCore(const char *name=NULL) { return _call(CREATECORE,0,name); } + + // (CoreToken)0 is the maincore + // "main" is the maincore + CoreToken nameToToken(const char *name) { return _call(NAMETOTOKEN,0,name); } + + int freeCoreByToken(CoreToken core) { return _call(FREECOREBYTOKEN,0,core); } + int freeCoreByName(const char *name) { return _call(FREECOREBYNAME,0,name); } + + // returns 1 if present, 0 if non existent + int verifyToken(CoreToken token) { return _call(VERIFYTOKEN,0,token); } + + //just the *.mp3 or whatever + const char *getSupportedExtensions() { return _call(GETSUPPORTEDEXTENSIONS,(const char *)0); } + // including names + const char *getExtSupportedExtensions() { return _call(GETEXTSUPPORTEDEXTENSIONS,(const char *)0); } + void registerExtension(const char *extensions, const char *extension_name, const char *family=NULL) { _voidcall(REGISTEREXTENSION,extensions,extension_name,family); } + const char *getExtensionFamily(const char *extension) { + return _call(GETEXTENSIONFAMILY, (const char *)0, extension); + } + void unregisterExtension(const char *extensions) { _voidcall(UNREGISTEREXTENSION,extensions); } + + int setNextFile(CoreToken core, const char *playstring, const char *destination=NULL) { return _call(SETNEXTFILE,0,core,playstring,destination); } + // returns -1 if paused, 0 if stopped and 1 if playing + int getStatus(CoreToken core) { return _call(GETSTATUS,0,core); } + const char *getCurrent(CoreToken core) { return _call(GETCURRENT,(const char *)0,core); } + int getCurPlaybackNumber(CoreToken core) { return _call(GETCURPLAYBACKNUMBER,-1,core); } + int getNumTracks(CoreToken core) { return _call(GETNUMTRACKS, -1, core); } + int getPosition(CoreToken core) { return _call(GETPOSITION,0,core); } + int getWritePosition(CoreToken core) { return _call(GETWRITEPOSITION,0,core); } + int setPosition(CoreToken core, int ms) { return _call(SETPOSITION,0,core,ms); } + int getLength(CoreToken core) { return _call(GETLENGTH,-1,core); } + // this method queries the core plugins directly, bypassing the db + // returns size of data + int getPluginData(const char *playstring, const char *name, + char *data, int data_len, int data_type=0) { return _call(GETPLUGINDATA,0,playstring,name,data,data_len,data_type); } + unsigned int getVolume(CoreToken core) { return _call(GETVOLUME,0,core); } + // 0..255 + void setVolume(CoreToken core, unsigned int vol) { _voidcall(SETVOLUME,core,vol); } + // -127..127 + int getPan(CoreToken core) { return _call(GETPAN,0,core); } + // -127..127 + void setPan(CoreToken core, int bal) { _voidcall(SETPAN,core,bal); } + + void setMute(CoreToken core, int mute) { _voidcall(SETMUTE,core,mute); } + int getMute(CoreToken core) { return _call(GETMUTE,0,core); } + + // register here for general callbacks in core status. + void addCallback(CoreToken core, CoreCallback *cb) { _voidcall(ADDCALLBACK,core,cb); } + void delCallback(CoreToken core, CoreCallback *cb) { _voidcall(DELCALLBACK,core,cb); } + // get visualization data, returns 0 if you should blank out + int getVisData(CoreToken core, void *dataptr, int sizedataptr) { return _call(GETVISDATA,0,core,dataptr,sizedataptr); } + int getLeftVuMeter(CoreToken core) { return _call(GETLEFTVUMETER,0,core); } + int getRightVuMeter(CoreToken core) { return _call(GETRIGHTVUMETER,0,core); } + + int registerSequencer(CoreToken core, ItemSequencer *seq) { return _call(REGISTERSEQUENCER,0,core,seq); } + int deregisterSequencer(CoreToken core, ItemSequencer *seq) { return _call(DEREGISTERSEQUENCER,0,core,seq); } + ItemSequencer *getSequencer(CoreToken core) { return _call(GETSEQUENCER, (ItemSequencer*)NULL,core); } + // see buttons.h + void userButton(CoreToken core, int button) { _voidcall(USERBUTTON,core,button); } + + // returns 1 if on, 0 if off + int getEqStatus(CoreToken core) { return _call(GETEQSTATUS,0,core); } + void setEqStatus(CoreToken core, int enable) { _voidcall(SETEQSTATUS,core,enable); } + // -127 to 127 (-20db to +20db) + int getEqPreamp(CoreToken core) { return _call(GETEQPREAMP,0,core); } + void setEqPreamp(CoreToken core, int pre) { _voidcall(SETEQPREAMP,core,pre); } + // band=0-9 + int getEqBand(CoreToken core, int band) { return _call(GETEQBAND,0,core,band); } + void setEqBand(CoreToken core, int band, int val) { _voidcall(SETEQBAND,core,band,val); } + // returns 1 if on, 0 if off + int getEqAuto(CoreToken core) { return _call(GETEQAUTO,0,core); } + void setEqAuto(CoreToken core, int enable) { _voidcall(SETEQAUTO,core,enable); } + + // for status msgs + void setCustomMsg(CoreToken core, const char *text) { _voidcall(SETCUSTOMMSG,core,text); } + + void setPriority(CoreToken core, int priority) { _voidcall(SETPRIORITY,core,priority); } + int getPriority(CoreToken core) { return _call(GETPRIORITY,0,core); } + + void rebuildConvertersChain(CoreToken core) { _voidcall(REBUILDCONVERTERSCHAIN,core); } + + int sendConvertersMsg(CoreToken core, const char *msg, const char *value) { return _call(SENDCONVERTERSMSG,0,core,msg,value); } + const char *getTitle(CoreToken core) { return _call(GETTITLE,(const char *)NULL, core); } + + enum { + CREATECORE=10, + NAMETOTOKEN=20, + FREECOREBYTOKEN=30, + FREECOREBYNAME=40, + VERIFYTOKEN=50, + + GETSUPPORTEDEXTENSIONS=100, + GETEXTSUPPORTEDEXTENSIONS=110, + REGISTEREXTENSION=121, //120 retired + GETEXTENSIONFAMILY=122, + UNREGISTEREXTENSION=130, + + SETNEXTFILEOLD=200, + SETNEXTFILE=210, + + GETSTATUS=300, + GETCURRENT=310, + GETCURPLAYBACKNUMBER=315, + GETNUMTRACKS=317, + GETPOSITION=320, + GETWRITEPOSITION=330, + GETLENGTH=340, + GETPLUGINDATA=350, + GETVOLUME=360, + GETPAN=370, + GETVISDATA=380, + GETLEFTVUMETER=390, + GETRIGHTVUMETER=400, + GETEQSTATUS=410, + GETEQPREAMP=420, + GETEQBAND=430, + GETEQAUTO=440, + GETMUTE=450, + + SETPOSITION=500, + SETVOLUME=510, + SETPAN=520, + SETEQSTATUS=530, + SETEQPREAMP=540, + SETEQBAND=550, + SETEQAUTO=560, + SETMUTE=570, + + ADDCALLBACK=700, + DELCALLBACK=710, + + REGISTERSEQUENCER=800, + DEREGISTERSEQUENCER=810, + GETSEQUENCER=812, + + USERBUTTON=820, + + SETCUSTOMMSG=900, + + SETPRIORITY=1000, + GETPRIORITY=1100, + + REBUILDCONVERTERSCHAIN=1200, + + SENDCONVERTERSMSG=1300, + GETTITLE=1400, + }; +}; + +class NOVTABLE svc_coreAdminI : public svc_coreAdmin { +public: + virtual CoreToken createCore(const char *name=NULL)=0; + virtual CoreToken nameToToken(const char *name)=0; + virtual int freeCoreByToken(CoreToken core)=0; + virtual int freeCoreByName(const char *name)=0; + + virtual int verifyToken(CoreToken token)=0; + + virtual const char *getSupportedExtensions()=0; + virtual const char *getExtSupportedExtensions()=0; + virtual void registerExtension(const char *extensions, const char *extension_name, const char *family=NULL)=0; + virtual const char *getExtensionFamily(const char *extension)=0; + virtual void unregisterExtension(const char *extensions)=0; + + virtual int setNextFile(CoreToken core, const char *playstring, const char *destination)=0; + virtual int getStatus(CoreToken core)=0; + virtual const char *getCurrent(CoreToken core)=0; + virtual int getCurPlaybackNumber(CoreToken core)=0; + virtual int getNumTracks(CoreToken core)=0; + virtual int getPosition(CoreToken core)=0; + virtual int getWritePosition(CoreToken core)=0; + virtual int setPosition(CoreToken core, int ms)=0; + virtual int getLength(CoreToken core)=0; + virtual int getPluginData(const char *playstring, const char *name, char *data, int data_len, int data_type=0)=0; + virtual unsigned int getVolume(CoreToken core)=0; + virtual void setVolume(CoreToken core, unsigned int vol)=0; + virtual int getPan(CoreToken core)=0; + virtual void setPan(CoreToken core, int bal)=0; + virtual void addCallback(CoreToken core, CoreCallback *cb)=0; + virtual void delCallback(CoreToken core, CoreCallback *cb)=0; + virtual int getVisData(CoreToken core, void *dataptr, int sizedataptr)=0; + virtual int getLeftVuMeter(CoreToken core)=0; + virtual int getRightVuMeter(CoreToken core)=0; + virtual void setMute(CoreToken core, int mute)=0; + virtual int getMute(CoreToken core)=0; + + virtual int registerSequencer(CoreToken core, ItemSequencer *seq)=0; + virtual int deregisterSequencer(CoreToken core, ItemSequencer *seq)=0; + virtual ItemSequencer *getSequencer(CoreToken core)=0; + virtual void userButton(CoreToken core, int button)=0; + + virtual int getEqStatus(CoreToken core)=0; + virtual void setEqStatus(CoreToken core, int enable)=0; + virtual int getEqPreamp(CoreToken core)=0; + virtual void setEqPreamp(CoreToken core, int pre)=0; + virtual int getEqBand(CoreToken core, int band)=0; + virtual void setEqBand(CoreToken core, int band, int val)=0; + virtual int getEqAuto(CoreToken core)=0; + virtual void setEqAuto(CoreToken core, int enable)=0; + + virtual void setCustomMsg(CoreToken core, const char *text)=0; + + virtual void setPriority(CoreToken core, int priority)=0; + virtual int getPriority(CoreToken core)=0; + + virtual void rebuildConvertersChain(CoreToken core)=0; + + virtual int sendConvertersMsg(CoreToken core, const char *msg, const char *value)=0; + virtual const char *getTitle(CoreToken core)=0; + +protected: + RECVS_DISPATCH; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_db.cpp b/Src/Wasabi/api/service/svcs/svc_db.cpp new file mode 100644 index 00000000..7a5852b2 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_db.cpp @@ -0,0 +1,78 @@ +#include + +#include "svc_db.h" + +#define CBCLASS svc_dbI +START_DISPATCH; + CB(OPENTABLE, openTable); + VCB(CLOSETABLE, closeTable); + CB(TESTQUERYFORMAT, testQueryFormat); +END_DISPATCH; +#undef CBCLASS + + +#define CBCLASS dbSvcTableI +START_DISPATCH; + CB(GETSCANNER, getScanner); + CB(NEWSCANNER, newScanner); + VCB(DELETESCANNER, deleteScanner); + VCB(CBNEW, _new); + VCB(CBINSERT, insert); + VCB(CBCANCEL, cancel); + VCB(CBEDIT, edit); + VCB(CBPOST, post); + VCB(CBDELETE, _delete); + CB(EDITING, editing); + VCB(SETFIELDBYNAME, setFieldByName); + VCB(SETFIELDBYID, setFieldById); + VCB(DELETEFIELDBYNAME, deleteFieldByName); + VCB(DELETEFIELDBYID, deleteFieldById); + VCB(ADDCOLUMN, addColumn); + VCB(ADDINDEXBYNAME, addIndexByName); + VCB(ADDINDEXBYID, addIndexById); + VCB(DROPINDEXBYNAME, dropIndexByName); + VCB(DROPINDEXBYID, dropIndexById); + VCB(SYNC, sync); +END_DISPATCH; +#undef CBCLASS + +#define CBCLASS dbSvcScannerI +START_DISPATCH; + VCB(CBFIRST, first); + VCB(CBLAST, last); + VCB(CBNEXT, block_next); + VCB(CBPREVIOUS, block_previous); + CB(CBNEXT2, next); + CB(CBPREVIOUS2, previous); + VCB(CBPUSH, push); + VCB(CBPOP, pop); + CB(CBEOF, eof); + CB(CBBOF, bof); + CB(GETNUMROWS, getNumRows); + VCB(MOVETOROW, moveToRow); + CB(GETCURROW, getCurRow); + CB(LOCATEBYNAME, locateByName); + CB(LOCATEBYID, locateById); + CB(GETNUMCOLS, getNumCols); + CB(ENUMCOL, enumCol); + CB(GETCOLBYNAME, getColByName); + CB(GETCOLBYID, getColByName); + CB(GETFIELDBYNAME, getFieldByName); + CB(GETFIELDBYID, getFieldById); + VCB(SETINDEXBYNAME, setIndexByName); + VCB(SETINDEXBYID, setIndexById); + CB(UNIQUEBYNAME, newUniqueScannerByName); + CB(UNIQUEBYID, newUniqueScannerById); + VCB(DELETEUNIQUE, deleteUniqueScanner); + CB(QUERY, query); + VCB(CANCELQUERY, cancelQuery); + CB(INDEXCHANGED, hasIndexChanged); + VCB(CLEARDIRTYBIT, clearDirtyBit); + VCB(JOINSCANNER, joinScanner); + VCB(UNJOINSCANNER, unjoinScanner); + CB(GETLASTQUERY, getLastQuery); + VCB(SETBLOCKING, setBlocking); +END_DISPATCH; +#undef CBCLASS + + diff --git a/Src/Wasabi/api/service/svcs/svc_db.h b/Src/Wasabi/api/service/svcs/svc_db.h new file mode 100644 index 00000000..6ea5b8d4 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_db.h @@ -0,0 +1,512 @@ +#ifndef _SVC_DB_H +#define _SVC_DB_H + +#include +#include + +typedef enum { + DBSVC_DATATYPE_UNKNOWN = 0, + DBSVC_DATATYPE_INT = 1, + DBSVC_DATATYPE_STRING = 2, + DBSVC_DATATYPE_BINARY = 3, + DBSVC_DATATYPE_GUID = 4, + DBSVC_DATATYPE_FLOAT = 5, +} dbSvcDatatypeEnum; + +typedef struct { + void *data; + dbSvcDatatypeEnum datatype; + int datalen; +} dbSvcDatachunk; + +typedef struct { + const char *name; + dbSvcDatatypeEnum datatype; + int id; + int indexed; + int uniques_indexed; +} dbSvcColInfo; + +class dbSvcScanner; + +class NOVTABLE dbSvcScanner : public Dispatchable { + + public: + + void first(); + void last(); + void block_next(); // blocking call for baclkward compat + void block_previous(); // blocking call for baclkward compat + int next(); // if non blocking, returns 0 for "HOLD ON!" and 1 for "GOT A ROW!" + int previous(); // if non blocking, returns 0 for "HOLD ON!" and 1 for "GOT A ROW!" + void push(); + void pop(); + int eof(); + int bof(); + + int getNumRows(); + void moveToRow(int row); + int getCurRow(); + + int locateByName(const char *col, int from_row, dbSvcDatachunk *data); + int locateById(int id, int from_row, dbSvcDatachunk *data); + + int getNumCols(); + dbSvcColInfo *enumCol(int n); + dbSvcColInfo *getColById(int n); + dbSvcColInfo *getColByName(const char *col); + + dbSvcDatachunk *getFieldByName(const char *col); + dbSvcDatachunk *getFieldById(int id); + + void setIndexByName(const char *col); + void setIndexById(int id); + + dbSvcScanner *newUniqueScannerByName(const char *col); + dbSvcScanner *newUniqueScannerById(int colid); + void deleteUniqueScanner(dbSvcScanner *); + + int query(const char *query); + const char *getLastQuery(); + void cancelQuery(); + int hasIndexChanged(); + void clearDirtyBit(); + + void joinScanner(dbSvcScanner *scanner, const char *field); + void unjoinScanner(dbSvcScanner *scanner); + + void setBlocking(int b); // blocking is the default behavior + + enum { + CBFIRST = 100, + CBLAST = 110, + CBNEXT = 120, // retired + CBPREVIOUS = 130, // retired + CBNEXT2 = 121, + CBPREVIOUS2 = 131, + CBPUSH = 140, + CBPOP = 150, + CBEOF = 160, + CBBOF = 170, + GETNUMROWS = 180, + MOVETOROW = 190, + GETCURROW = 200, + LOCATEBYNAME = 210, + LOCATEBYID = 220, + GETNUMCOLS = 230, + ENUMCOL = 240, + GETCOLBYID = 250, + GETCOLBYNAME = 260, + GETFIELDBYNAME = 270, + GETFIELDBYID = 280, + SETINDEXBYNAME = 290, + SETINDEXBYID = 300, + QUERY = 310, + CANCELQUERY = 320, + INDEXCHANGED = 330, + CLEARDIRTYBIT = 340, + UNIQUEBYNAME = 350, + UNIQUEBYID = 360, + DELETEUNIQUE = 370, + GETLASTQUERY = 380, + JOINSCANNER = 390, + UNJOINSCANNER = 400, + SETBLOCKING = 410, + }; +}; + + +inline void dbSvcScanner::first() { + _voidcall(CBFIRST); +} + +inline void dbSvcScanner::last() { + _voidcall(CBLAST); +} + +inline void dbSvcScanner::block_next() { + _voidcall(CBNEXT); +} + +inline int dbSvcScanner::next() { + return _call(CBNEXT2, 0); +} + +inline void dbSvcScanner::block_previous() { + _voidcall(CBPREVIOUS); +} + +inline int dbSvcScanner::previous() { + return _call(CBPREVIOUS2, 0); +} + +inline void dbSvcScanner::push() { + _voidcall(CBPUSH); +} + +inline void dbSvcScanner::pop() { + _voidcall(CBPOP); +} + +inline int dbSvcScanner::eof() { + return _call(CBEOF, 0); +} + +inline int dbSvcScanner::bof() { + return _call(CBBOF, 0); +} + +inline int dbSvcScanner::getNumRows() { + return _call(GETNUMROWS, 0); +} + +inline void dbSvcScanner::moveToRow(int row) { + _voidcall(MOVETOROW, row); +} + +inline int dbSvcScanner::getCurRow() { + return _call(GETCURROW, 0); +} + +inline int dbSvcScanner::locateByName(const char *col, int from_row, dbSvcDatachunk *data) { + return _call(LOCATEBYNAME, 0, col, from_row, data); +} + +inline int dbSvcScanner::locateById(int colid, int from_row, dbSvcDatachunk *data) { + return _call(LOCATEBYNAME, 0, colid, from_row, data); +} + +inline int dbSvcScanner::getNumCols() { + return _call(GETNUMCOLS, 0); +} + +inline dbSvcColInfo *dbSvcScanner::enumCol(int n) { + return _call(ENUMCOL, ((dbSvcColInfo *)NULL), n); +} + +inline dbSvcColInfo *dbSvcScanner::getColByName(const char *col) { + return _call(GETCOLBYNAME, ((dbSvcColInfo *)NULL), col); +} + +inline dbSvcColInfo *dbSvcScanner::getColById(int colid) { + return _call(GETCOLBYID, ((dbSvcColInfo *)NULL), colid); +} + +inline dbSvcDatachunk *dbSvcScanner::getFieldByName(const char *col) { + return _call(GETFIELDBYNAME, ((dbSvcDatachunk *)NULL), col); +} + +inline dbSvcDatachunk *dbSvcScanner::getFieldById(int colid) { + return _call(GETFIELDBYNAME, ((dbSvcDatachunk *)NULL), colid); +} + +inline void dbSvcScanner::setIndexByName(const char *col) { + _voidcall(SETINDEXBYNAME, col); +} + +inline void dbSvcScanner::setIndexById(int colid) { + _voidcall(SETINDEXBYID, colid); +} + +inline dbSvcScanner *dbSvcScanner::newUniqueScannerByName(const char *col) { + return _call(UNIQUEBYNAME, (dbSvcScanner *)NULL, col); +} + +inline dbSvcScanner *dbSvcScanner::newUniqueScannerById(int colid) { + return _call(UNIQUEBYID, (dbSvcScanner *)NULL, colid); +} + +inline void dbSvcScanner::deleteUniqueScanner(dbSvcScanner *s) { + _voidcall(DELETEUNIQUE, s); +} + +inline int dbSvcScanner::query(const char *q) { + return _call(QUERY, 0, q); +} + +inline void dbSvcScanner::cancelQuery() { + _voidcall(CANCELQUERY); +} + +inline int dbSvcScanner::hasIndexChanged() { + return _call(INDEXCHANGED, 0); +} + +inline void dbSvcScanner::clearDirtyBit() { + _voidcall(CLEARDIRTYBIT); +} + +inline const char *dbSvcScanner::getLastQuery() { + return _call(GETLASTQUERY, (const char *)NULL); +} + +inline void dbSvcScanner::joinScanner(dbSvcScanner *scanner, const char *field) { + _voidcall(JOINSCANNER, scanner, field); +} + +inline void dbSvcScanner::unjoinScanner(dbSvcScanner *scanner) { + _voidcall(UNJOINSCANNER, scanner); +} + +inline void dbSvcScanner::setBlocking(int b) { + _voidcall(SETBLOCKING, b); +} + +class NOVTABLE dbSvcScannerI : public dbSvcScanner { +public: + virtual void first()=0; + virtual void last()=0; + virtual void block_next()=0; + virtual void block_previous()=0; + virtual int next()=0; + virtual int previous()=0; + virtual void push()=0; + virtual void pop()=0; + virtual int eof()=0; + virtual int bof()=0; + virtual int getNumRows()=0; + virtual void moveToRow(int row)=0; + virtual int getCurRow()=0; + virtual int locateByName(const char *col, int from_row, dbSvcDatachunk *data)=0; + virtual int locateById(int id, int from_row, dbSvcDatachunk *data)=0; + virtual int getNumCols()=0; + virtual dbSvcColInfo *enumCol(int n)=0; + virtual dbSvcColInfo *getColById(int n)=0; + virtual dbSvcColInfo *getColByName(const char *col)=0; + virtual dbSvcDatachunk *getFieldByName(const char *col)=0; + virtual dbSvcDatachunk *getFieldById(int id)=0; + virtual void setIndexByName(const char *col)=0; + virtual void setIndexById(int id)=0; + virtual dbSvcScanner *newUniqueScannerByName(const char *col)=0; + virtual dbSvcScanner *newUniqueScannerById(int colid)=0; + virtual void deleteUniqueScanner(dbSvcScanner *)=0; + virtual int query(const char *query)=0; + virtual void cancelQuery()=0; + virtual int hasIndexChanged()=0; + virtual void clearDirtyBit()=0; + virtual const char *getLastQuery()=0; + virtual void joinScanner(dbSvcScanner *scanner, const char *field)=0; + virtual void unjoinScanner(dbSvcScanner *scanner)=0; + virtual void setBlocking(int block)=0; + +protected: + RECVS_DISPATCH; +}; + +class NOVTABLE dbSvcTable : public Dispatchable { +public: + dbSvcScanner *getScanner(); + dbSvcScanner *newScanner(); + void deleteScanner(dbSvcScanner *scanner); + void _new(); + void insert(); + void cancel(); + void edit(); + void post(); + void _delete(); + int editing(); + void setFieldByName(const char *col, dbSvcDatachunk *data); + void setFieldById(int colid, dbSvcDatachunk *data); + void deleteFieldByName(const char *col); + void deleteFieldById(int colid); + void addColumn(const char *colname, int colid, int datatype, int uniques_indexed); + void addIndexByName(const char *col); + void addIndexById(int colid); + void dropIndexByName(const char *col); + void dropIndexById(int colid); + void sync(); + + enum { + GETSCANNER = 100, + NEWSCANNER = 110, + DELETESCANNER = 111, + CBNEW = 120, + CBINSERT = 130, + CBCANCEL = 140, + CBEDIT = 150, + CBPOST = 160, + CBDELETE = 170, + EDITING = 180, + SETFIELDBYNAME = 190, + SETFIELDBYID = 200, + DELETEFIELDBYNAME = 210, + DELETEFIELDBYID = 220, + ADDCOLUMN = 230, + ADDINDEXBYNAME = 240, + ADDINDEXBYID = 250, + SYNC = 260, + DROPINDEXBYNAME = 270, + DROPINDEXBYID = 280, + }; +}; + +inline dbSvcScanner *dbSvcTable::getScanner() { + return _call(GETSCANNER, static_cast(NULL)); +} + +inline dbSvcScanner *dbSvcTable::newScanner() { + return _call(NEWSCANNER, static_cast(NULL)); +} + +inline void dbSvcTable::deleteScanner(dbSvcScanner *scanner) { + _voidcall(DELETESCANNER, scanner); +} + +inline void dbSvcTable::_new() { + _voidcall(CBNEW); +} + +inline void dbSvcTable::insert() { + _voidcall(CBINSERT); +} + +inline void dbSvcTable::cancel() { + _voidcall(CBCANCEL); +} + +inline void dbSvcTable::edit() { + _voidcall(CBEDIT); +} + +inline void dbSvcTable::post() { + _voidcall(CBPOST); +} + +inline void dbSvcTable::_delete() { + _voidcall(CBDELETE); +} + +inline int dbSvcTable::editing() { + return _call(EDITING, 0); +} + +inline void dbSvcTable::setFieldByName(const char *col, dbSvcDatachunk *data) { + _voidcall(SETFIELDBYNAME, col, data); +} + +inline void dbSvcTable::setFieldById(int colid, dbSvcDatachunk *data) { + _voidcall(SETFIELDBYID, colid, data); +} + +inline void dbSvcTable::deleteFieldByName(const char *col) { + _voidcall(DELETEFIELDBYNAME, col); +} + +inline void dbSvcTable::deleteFieldById(int colid) { + _voidcall(DELETEFIELDBYID, colid); +} + +inline void dbSvcTable::addColumn(const char *colname, int colid, int datatype, int index_uniques) { + _voidcall(ADDCOLUMN, colname, colid, datatype, index_uniques); +} + +inline void dbSvcTable::addIndexByName(const char *col) { + _voidcall(ADDINDEXBYNAME, col); +} + +inline void dbSvcTable::addIndexById(int colid) { + _voidcall(ADDINDEXBYID, colid); +} + +inline void dbSvcTable::dropIndexByName(const char *col) { + _voidcall(DROPINDEXBYNAME, col); +} + +inline void dbSvcTable::dropIndexById(int colid) { + _voidcall(DROPINDEXBYID, colid); +} + +inline void dbSvcTable::sync() { + _voidcall(SYNC); +} + +class NOVTABLE dbSvcTableI : public dbSvcTable { +public: + virtual dbSvcScanner *getScanner()=0; + virtual dbSvcScanner *newScanner()=0; + virtual void deleteScanner(dbSvcScanner *scanner)=0; + virtual void _new()=0; + virtual void insert()=0; + virtual void cancel()=0; + virtual void edit()=0; + virtual void post()=0; + virtual void _delete()=0; + virtual int editing()=0; + virtual void setFieldByName(const char *col, dbSvcDatachunk *data)=0; + virtual void setFieldById(int colid, dbSvcDatachunk *data)=0; + virtual void deleteFieldByName(const char *col)=0; + virtual void deleteFieldById(int colid)=0; + virtual void addColumn(const char *colname, int colid, int datatype, int index_uniques)=0; + virtual void addIndexByName(const char *col)=0; + virtual void addIndexById(int colid)=0; + virtual void dropIndexByName(const char *col)=0; + virtual void dropIndexById(int colid)=0; + virtual void sync()=0; + +protected: + RECVS_DISPATCH; +}; + +class NOVTABLE svc_db : public Dispatchable { +protected: + svc_db() {} + ~svc_db() {} +public: + static FOURCC getServiceType() { return WaSvc::DB; } + + int testQueryFormat(int queryformat); + + dbSvcTable *openTable(const char *tablefilename, int create_if_not_exist, int cache_in_memory); + void closeTable(dbSvcTable *table); + + enum { + TESTQUERYFORMAT = 10, + OPENTABLE = 20, + CLOSETABLE = 30, + }; +}; + +inline int svc_db::testQueryFormat(int queryformat) { + return _call(TESTQUERYFORMAT, 0, queryformat); +} + +inline dbSvcTable *svc_db::openTable(const char *tablename, int create_if_not_exist, int cache_in_memory) { + return _call(OPENTABLE, static_cast(NULL), tablename, create_if_not_exist, cache_in_memory); +} + +inline void svc_db::closeTable(dbSvcTable *table) { + _voidcall(CLOSETABLE, table); +} + +// derive from this one +class NOVTABLE svc_dbI : public svc_db{ +public: + virtual int testQueryFormat(int queryformat)=0; + virtual dbSvcTable *openTable(const char *filename, int create_if_not_exist, int cache_in_memory)=0; + virtual void closeTable(dbSvcTable *table)=0; + +protected: + RECVS_DISPATCH; +}; + +#include + +enum { + DBQFORMAT_MINIQUERY =1, + DBQFORMAT_SQL =2, +}; + +class DatabaseEnum : public SvcEnumT { +public: + DatabaseEnum(int queryformat=DBQFORMAT_MINIQUERY) : + query_format(queryformat) {} +protected: + virtual int testService(svc_db *svc) { + return svc->testQueryFormat(query_format); + } + +private: + int query_format; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_debuggerui.cpp b/Src/Wasabi/api/service/svcs/svc_debuggerui.cpp new file mode 100644 index 00000000..240baad2 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_debuggerui.cpp @@ -0,0 +1,10 @@ +#include + +#include "svc_debuggerui.h" + +#define CBCLASS svc_debuggerUII +START_DISPATCH; + CB(CREATEUI, createUI); + VCB(DESTROYUI, destroyUI); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_debuggerui.h b/Src/Wasabi/api/service/svcs/svc_debuggerui.h new file mode 100644 index 00000000..5e96a15f --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_debuggerui.h @@ -0,0 +1,44 @@ +#ifndef _SVC_DEBUGGERUI_H +#define _SVC_DEBUGGERUI_H + +#include +#include + +class DebuggerUI; + +// {8B055A0D-9A57-428c-BCFC-88F75AEF2CAD} +static const GUID SERVICE_DEBUGGERUI = +{ 0x8b055a0d, 0x9a57, 0x428c, { 0xbc, 0xfc, 0x88, 0xf7, 0x5a, 0xef, 0x2c, 0xad } }; + +class svc_debuggerUI : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::UNIQUE; } + + DebuggerUI *createUI(); + void destroyUI(DebuggerUI *ui); + +protected: + enum { + CREATEUI=10, + DESTROYUI=20, + }; +}; + +inline DebuggerUI *svc_debuggerUI::createUI() { + return _call(CREATEUI, (DebuggerUI *)NULL); +} + +inline void svc_debuggerUI::destroyUI(DebuggerUI *ui) { + _voidcall(DESTROYUI, ui); +} + +class svc_debuggerUII : public svc_debuggerUI { +public: + virtual DebuggerUI *createUI()=0; + virtual void destroyUI(DebuggerUI *ui)=0; + +protected: + RECVS_DISPATCH; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_device.h b/Src/Wasabi/api/service/svcs/svc_device.h new file mode 100644 index 00000000..9a75f2b0 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_device.h @@ -0,0 +1,54 @@ +#ifndef _SVC_DEVICE_H +#define _SVC_DEVICE_H + +#include + +// not done at all :) BU + +class NOVTABLE svc_device : public Dispatchable { +public: + const char *getDeviceName(); + const char *getDeviceUID(); // some kind of unique per-device id if possible + + // return total storage space and + int getDeviceSpace(unsigned int *space, unsigned int *spacefree); + // return (estimated) # of seconds stored/available + int getDeviceTime(unsigned int *time, unsigned int *timefree); + + // high-level stuff + // give us a filename we should use if we transfer object to you + // this name will be used as the media conversion pipeline's output + // filename so your transfer filter will kick in... of course something + // like d:\music\blah.mp3 is fine too + int getTargetFilename(const char *playstring, char *fn, int buflen); + + // file/directory enumeration +// int opendir(const char *path); +// int readdir(const char *path); + +#if 0 + // return a handle like C-style open + int openFile(const char *filename, const char *mode); + void closeFile(int handle); + + int writeToFile(int handle, const void *data, int length); + int seek(int handle, int + + int putFile(const char *filename, const void *data, unsigned int length); + int readFile(const char *filename, void *buffer, unsigned int offset, unsigned int length)=0; + int getFileAttrib(const char *filename, const char *name, char *buf, int len); + int setFileAttrib(const char *filename, const char *name, const char *buf, int len); +#endif + + // playlist manipulation + int playlistCreate(const char *playlist_name); + int playlistDelete(const char *playlist_name); + + int playlistGetNumItems(const char *playlist_name); + int playlistEnumItem(const char *playlist_name, char *playstring, int len); + + int playlistAppendItem(const char *playlist_name, const char *playstring); + int playlistRemoveItem(const char *playlist_name, int position); +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_droptarget.cpp b/Src/Wasabi/api/service/svcs/svc_droptarget.cpp new file mode 100644 index 00000000..42ff876e --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_droptarget.cpp @@ -0,0 +1,11 @@ +#include + +#include "svc_droptarget.h" + +#define CBCLASS svc_dropTargetI +START_DISPATCH; + CB(TESTTARGET, testTarget); + CB(GETDRAGINTERFACEFORTYPE, getDragInterfaceForType); + CB(RELEASEDRAGINTERFACE, releaseDragInterface); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_droptarget.h b/Src/Wasabi/api/service/svcs/svc_droptarget.h new file mode 100644 index 00000000..73b4b6aa --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_droptarget.h @@ -0,0 +1,82 @@ +#ifndef _SVC_DROPTARGET_H +#define _SVC_DROPTARGET_H + +#include +#include + +class DragInterface; // see bfc/drag.h + +class NOVTABLE svc_dropTarget : public Dispatchable +{ +public: + static FOURCC getServiceType() { return WaSvc::DROPTARGET; } + + int testTarget(FOURCC type); + + DragInterface *getDragInterfaceForType(FOURCC type); + int releaseDragInterface(DragInterface *di); + +protected: + enum { + TESTTARGET=100, + GETDRAGINTERFACEFORTYPE=200, + RELEASEDRAGINTERFACE=210, + }; +}; + +inline +int svc_dropTarget::testTarget(FOURCC type) { + return _call(TESTTARGET, 0, type); +} + +inline +DragInterface *svc_dropTarget::getDragInterfaceForType(FOURCC type) { + return _call(GETDRAGINTERFACEFORTYPE, (DragInterface*)NULL, type); +} + +inline +int svc_dropTarget::releaseDragInterface(DragInterface *di) { + return _call(RELEASEDRAGINTERFACE, 0, di); +} + +class svc_dropTargetI : public svc_dropTarget { +public: + virtual int testTarget(FOURCC type)=0; + + virtual DragInterface *getDragInterfaceForType(FOURCC type)=0; + virtual int releaseDragInterface(DragInterface *di)=0; + +protected: + RECVS_DISPATCH; +}; + +#include + +template +class DropTargetCreator : public waServiceFactoryTSingle { }; + +#include +#include + +class DropTargetEnum : public SvcEnumT { +public: + DropTargetEnum(FOURCC type) : dt_type(type) {} + static int throwDrop(FOURCC type, ifc_window *sourceWnd, int x=0, int y=0) { + DropTargetEnum dte(type); + svc_dropTarget *sdt = dte.getFirst(); + if (sdt == NULL) return 0; + DragInterface *di = sdt->getDragInterfaceForType(type); + int r = 0; + if (di != NULL) r = di->dragDrop(sourceWnd, 0, 0); + sdt->releaseDragInterface(di); + return r; + } +protected: + virtual int testService(svc_dropTarget *svc) { + return (svc->testTarget(dt_type)); + } +private: + FOURCC dt_type; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_eval.cpp b/Src/Wasabi/api/service/svcs/svc_eval.cpp new file mode 100644 index 00000000..cb03f2de --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_eval.cpp @@ -0,0 +1,11 @@ +#include + +#include "svc_eval.h" + +#define CBCLASS svc_evaluatorI +START_DISPATCH + CB(GETEVALTYPE, getEvalType); + CB(SETEVALSTRING, setEvalString); + CB(EVALUATE, evaluate); +END_DISPATCH +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_eval.h b/Src/Wasabi/api/service/svcs/svc_eval.h new file mode 100644 index 00000000..d198c1d1 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_eval.h @@ -0,0 +1,64 @@ +#ifndef _SVC_EVAL_H +#define _SVC_EVAL_H + +#include +#include + +class NOVTABLE svc_evaluator : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::EVALUATOR; } + + const char *getEvalType(); // "php", "perl", "math", "xmlgen", etc. + +// these are for future optimization -- BU + // void assignVar(const char *name, const char *value); + // const char *getVarValue(const char *name); + // int getVarIndex(const char *name); + // const char *getVarValueByIndex(int pos); + + int setEvalString(const char *string, int length, BOOL isBinary); + // free the returned memory with api->sysFree() + const char *evaluate(int *length, BOOL *isBinary); + +protected: + enum { + GETEVALTYPE, ASSIGNVAR, GETVARVALUE, GETVARINDEX, GETVARVALUEBYINDEX, + SETEVALSTRING, EVALUATE + }; +}; + +inline +const char *svc_evaluator::getEvalType() { + return _call(GETEVALTYPE, (const char *)NULL); +} + +inline +int svc_evaluator::setEvalString(const char *string, int length, BOOL isBinary){ + return _call(SETEVALSTRING, FALSE, string, length, isBinary); +} + +inline +const char *svc_evaluator::evaluate(int *length, BOOL *isBinary) { + return _call(EVALUATE, (const char *)NULL, length, isBinary); +} + +// implementor derives from this one +class NOVTABLE svc_evaluatorI : public svc_evaluator { +public: + virtual const char *getEvalType()=0; + +// void assignVar(const char *name, const char *value); +// const char *getVarValue(const char *name); +// int getVarIndex(const char *name); +// const char *getVarValueByIndex(int pos); + + // implementor should make a copy of the string (if needed) + virtual int setEvalString(const char *string, int length, BOOL isBinary)=0; + // implementor should alloc returned mem w/ api->sysMalloc() + virtual const char *evaluate(int *length, BOOL *isBinary)=0; + +protected: + RECVS_DISPATCH; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_export.h b/Src/Wasabi/api/service/svcs/svc_export.h new file mode 100644 index 00000000..4b6085f1 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_export.h @@ -0,0 +1,32 @@ +#ifndef _SVC_EXPORT_H +#define _SVC_EXPORT_H + +#include +#include + +class svc_fileReader; + +class svc_exporter /*: public Dispatchable*/ { +public: + static FOURCC getServiceType() { return WaSvc::EXPORTER; } + + virtual int isMine(const char *exportid, const char *family)=0; + + virtual svc_fileReader *open()=0; + virtual close(svc_fileReader *reader)=0; +}; + +class ExporterEnum : public SvcEnumT { +public: + ExporterEnum(const char *exportid, const char *family=NULL) : + id(exportid), fam(family) { } + + virtual int testService(svc_exporter *svc) { + return svc->isMine(id, fam); + } + +private: + String id, fam; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_fileread.cpp b/Src/Wasabi/api/service/svcs/svc_fileread.cpp new file mode 100644 index 00000000..95fbfd5a --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_fileread.cpp @@ -0,0 +1,30 @@ +#include + +#include + +#define CBCLASS svc_fileReaderI +START_DISPATCH; + CB(ISMINE, isMine); + CB(OPEN, open); + CB(READ, read); + CB(WRITE, write); + VCB(CLOSE, close); + VCB(ABORT, abort); + CB(GETLENGTH, getLength); + CB(GETPOS, getPos); + CB(CANSEEK, canSeek); + CB(SEEK, seek); + CB(HASHEADERS,hasHeaders); + CB(GETHEADER,getHeader); + CB(EXISTS,exists); + CB(REMOVE,remove); + CB(REMOVEUNDOABLE,removeUndoable); + CB(MOVE,move); + CB(BYTESAVAILABLE,bytesAvailable); + VCB(SETMETADATACALLBACK,setMetaDataCallback); + CB(CANPREFETCH,canPrefetch); + CB(CANSETEOF, canSetEOF); + CB(SETEOF, setEOF); +END_DISPATCH; +#undef CBCLASS + diff --git a/Src/Wasabi/api/service/svcs/svc_fileread.h b/Src/Wasabi/api/service/svcs/svc_fileread.h new file mode 100644 index 00000000..c26007dc --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_fileread.h @@ -0,0 +1,199 @@ +#ifndef _SVC_FILEREAD_H +#define _SVC_FILEREAD_H + +#include +#include +#include +#include + +namespace SvcFileReader +{ + enum { + READ = 1, + WRITE = 2, + APPEND = 4, + PLUS = 8, + BINARY = 16, + TEXT = 32, + }; +}; + +class api_readercallback; + +class NOVTABLE svc_fileReader : public Dispatchable +{ +public: + static FOURCC getServiceType() { return WaSvc::FILEREADER; } + + int isMine(const wchar_t *filename, int mode = SvcFileReader::READ); //don't really open. returns -1 if "don't know until I open it" + int open(const wchar_t *filename, int mode = SvcFileReader::READ); + size_t read(int8_t *buffer, size_t length); + size_t write(const int8_t *buffer, size_t length); + void close(); // safe to call even when not open + + int canSetEOF(); + /** + Asks the file reader to change the file length to newlen. Will fail if file + was not opened for writing. + @ret 1 on success, 0 on failure, -1 if operation is unsupported by this reader. + */ + int setEOF(uint64_t newlen); + + void abort(); + + uint64_t getLength(); + uint64_t getPos(); + + int canSeek(); + int seek(uint64_t position); + uint64_t bytesAvailable(uint64_t requested); + + int hasHeaders(); + const char *getHeader(const char *header); + + int exists(const wchar_t *filename); + + int remove(const wchar_t *filename); + + int removeUndoable(const wchar_t *filename); + + int move(const wchar_t *filename, const wchar_t *destfilename); + + int canPrefetch(); + + void setMetaDataCallback(api_readercallback *cb); + + enum + { + ISMINE = 0, + OPEN = 10, + READ = 20, + WRITE = 30, + CLOSE = 40, + ABORT = 50, + GETLENGTH = 60, + GETPOS = 70, + CANSEEK = 80, + SEEK = 90, + HASHEADERS = 100, + GETHEADER = 110, + EXISTS = 120, + REMOVE = 130, + REMOVEUNDOABLE = 135, + BYTESAVAILABLE = 140, + SETMETADATACALLBACK = 150, + MOVE = 160, + CANPREFETCH = 170, + CANSETEOF = 180, + SETEOF = 190, + }; +}; + +inline +int svc_fileReader::isMine(const wchar_t *filename, int mode) +{ + return _call(ISMINE, -1, filename, mode); +} + +inline int svc_fileReader::open(const wchar_t *filename, int mode) +{ + return _call(OPEN, 0, filename, mode); +} + +inline size_t svc_fileReader::read(int8_t *buffer, size_t length) +{ + return _call(READ, 0, buffer, length); +} + +inline size_t svc_fileReader::write(const int8_t *buffer, size_t length) +{ + return _call(WRITE, 0, buffer, length); +} + +inline void svc_fileReader::close() +{ + _voidcall(CLOSE); +} + +inline int svc_fileReader::canSetEOF() +{ + return _call(CANSETEOF, 0); +} + +inline int svc_fileReader::setEOF(uint64_t newlen) +{ + return _call(SETEOF, -1, newlen); +} + +inline void svc_fileReader::abort() +{ + _voidcall(ABORT); +} + +inline uint64_t svc_fileReader::getLength() +{ + return _call(GETLENGTH, (uint64_t)-1); +} + +inline uint64_t svc_fileReader::getPos() +{ + return _call(GETPOS, (uint64_t)0); +} + +inline int svc_fileReader::canSeek() +{ + return _call(CANSEEK, 0); +} + +inline int svc_fileReader::seek(uint64_t position) +{ + return _call(SEEK, 0, position); +} + +inline uint64_t svc_fileReader::bytesAvailable(uint64_t requested) +{ + return _call(BYTESAVAILABLE, requested, requested); +} + +inline int svc_fileReader::hasHeaders() +{ + return _call(HASHEADERS, 0); +} + +inline const char *svc_fileReader::getHeader(const char *header) +{ + return _call(GETHEADER, (const char *)NULL, header); +} + +inline int svc_fileReader::exists(const wchar_t *filename) +{ + return _call(EXISTS, -1, filename); +} + +inline int svc_fileReader::remove(const wchar_t *filename) +{ + return _call(REMOVE, 0, filename); +} + +inline +int svc_fileReader::removeUndoable(const wchar_t *filename) +{ + return _call(REMOVEUNDOABLE, -1, filename); +} + +inline int svc_fileReader::move(const wchar_t *filename, const wchar_t *destfilename) +{ + return _call(MOVE, 0, filename, destfilename); +} + +inline void svc_fileReader::setMetaDataCallback(api_readercallback *cb) +{ + _voidcall(SETMETADATACALLBACK, cb); +} + +inline int svc_fileReader::canPrefetch() +{ + return _call(CANPREFETCH, 1); +} + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_filesel.cpp b/Src/Wasabi/api/service/svcs/svc_filesel.cpp new file mode 100644 index 00000000..fc8826b5 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_filesel.cpp @@ -0,0 +1,15 @@ +#include + +#include "svc_filesel.h" + +#define CBCLASS svc_fileSelectorI +START_DISPATCH; + CB(TESTPREFIX, testPrefix); + CB(GETPREFIX, getPrefix); + CB(SETEXTLIST, setExtList); + CB(RUNSELECTOR, runSelector); + CB(GETNUMFILESSELECTED, getNumFilesSelected); + CB(ENUMFILENAME, enumFilename); + CB(GETDIRECTORY, getDirectory); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_filesel.h b/Src/Wasabi/api/service/svcs/svc_filesel.h new file mode 100644 index 00000000..870a18cc --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_filesel.h @@ -0,0 +1,89 @@ +#ifndef _SVC_FILESEL_H +#define _SVC_FILESEL_H + +#include +#include + +class ifc_window; + +class NOVTABLE svc_fileSelector : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::FILESELECTOR; } + + int testPrefix(const wchar_t *prefix) { + return _call(TESTPREFIX, 0, prefix); + } + const wchar_t *getPrefix() { + return _call(GETPREFIX, L""); + } + int setTitle(const wchar_t *title) { + return _call(SETTITLE, 0, title); + } + int setExtList(const wchar_t *ext) { + return _call(SETEXTLIST, 0, ext); + } + int runSelector(ifc_window *parWnd, int type, int allow_multiple, const wchar_t *ident=NULL, const wchar_t *default_dir=NULL) { + return _call(RUNSELECTOR, 0, parWnd, type, allow_multiple, ident, default_dir); + } + int getNumFilesSelected() { + return _call(GETNUMFILESSELECTED, 0); + } + const wchar_t *enumFilename(int n) { + return _call(ENUMFILENAME, L"", n); + } + const wchar_t *getDirectory() { + return _call(GETDIRECTORY, L""); + } + +protected: + enum { + TESTPREFIX=0, + GETPREFIX=10, + SETTITLE=20, + SETEXTLIST=30, + RUNSELECTOR=40, + GETNUMFILESSELECTED=50, + ENUMFILENAME=60, + GETDIRECTORY=70, + }; +}; + +namespace FileSel { + enum { + OPEN=1, SAVEAS=2, + }; +}; + + +class NOVTABLE svc_fileSelectorI : public svc_fileSelector { +public: + virtual int testPrefix(const wchar_t *prefix)=0; + virtual const wchar_t *getPrefix()=0; + virtual int setTitle(const wchar_t *title) { return 0; } + virtual int setExtList(const wchar_t *ext) { return 0; } + virtual int runSelector(ifc_window *parWnd, int type, int allow_multiple, const wchar_t *ident=NULL, const wchar_t *default_dir=NULL)=0; + virtual int getNumFilesSelected()=0; + virtual const wchar_t *enumFilename(int n)=0; + virtual const wchar_t *getDirectory()=0; + +protected: + RECVS_DISPATCH; +}; + +#include +#include + +class FileSelectorEnum : public SvcEnumT { +public: + FileSelectorEnum(const wchar_t *_prefix=L"files") : prefix(_prefix) { } + +protected: + virtual int testService(svc_fileSelector *svc) { + return prefix.isempty() || svc->testPrefix(prefix); + } + +private: + StringW prefix; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_font.cpp b/Src/Wasabi/api/service/svcs/svc_font.cpp new file mode 100644 index 00000000..61c77d5d --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_font.cpp @@ -0,0 +1,27 @@ +#include +#include + +#define CBCLASS svc_fontI +START_DISPATCH + VCB(TEXTOUT, textOut); + VCB(TEXTOUT2, textOut2); + VCB(TEXTOUTELLIPSED, textOutEllipsed); + VCB(TEXTOUTWRAPPED, textOutWrapped); + VCB(TEXTOUTWRAPPEDPATHED, textOutWrappedPathed); + VCB(TEXTOUTCENTERED, textOutCentered); + CB(GETTEXTWIDTH, getTextWidth); + CB(GETTEXTHEIGHT, getTextHeight); + CB(GETTEXTHEIGHT2, getTextHeight2); + VCB(GETTEXTEXTENT, getTextExtent); + VCB(SETFONTID, setFontId); + CB(GETFONTID, getFontId); + CB(GETFACENAME_, getFaceName); + CB(ISBITMAP, isBitmap); + CB(GETSCRIPTID, getScriptId); + VCB(SETSCRIPTID, setScriptId); + VCB(SETFONTFACE, setFontFace); + CB(ADDFONTRESOURCE, addFontResource); + CB(ADDFONTRESOURCE2, addFontResource2); + CB(GETFONTSVCNAME, getFontSvcName); +END_DISPATCH +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_font.h b/Src/Wasabi/api/service/svcs/svc_font.h new file mode 100644 index 00000000..9e301489 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_font.h @@ -0,0 +1,178 @@ +#ifndef _SVC_FONT_H +#define _SVC_FONT_H + +#include +#include +#include +#include +//#include + +class ifc_canvas; + +#ifdef _WIN32 +enum +{ + STDFONT_LEFT = DT_LEFT, + STDFONT_RIGHT = DT_RIGHT, + STDFONT_CENTER = DT_CENTER, +}; +#else +#warning TODO: find good values for these +enum +{ + STDFONT_RIGHT = 1, + STDFONT_CENTER = 2, + STDFONT_LEFT = 4, +}; +#endif + +class NOVTABLE svc_font : public Dispatchable +{ +public: + static FOURCC getServiceType() { return WaSvc::FONTRENDER; } + + void textOut(ifc_canvas *c, int x, int y, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias); // abstract interface + void textOut(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias); + void textOutEllipsed(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias); + void textOutWrapped(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias); + void textOutWrappedPathed(ifc_canvas *c, int x, int y, int w, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias); + void textOutCentered(ifc_canvas *c, RECT *r, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias); + int getTextWidth(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialias); + int getTextHeight(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialias); + int getTextHeight(ifc_canvas *c, int size, int bold, int underline, int italic, int antialias); + void getTextExtent(ifc_canvas *c, const wchar_t *text, int *w, int *h, int size, int bold, int underline, int italic, int antialias); + + void setFontId(const wchar_t *id); + const wchar_t *getFontId(); + const wchar_t *getFaceName(); + int isBitmap(); + int getScriptId(); + void setScriptId(int id); + + void setFontFace(const wchar_t *face); + int addFontResource(HANDLE f, const wchar_t *name); + int addFontResource2(void *mem, int datalen, const wchar_t *name); + + const wchar_t *getFontSvcName(); + +protected: + enum { + TEXTOUT, + TEXTOUT2, + TEXTOUTELLIPSED, + TEXTOUTWRAPPED, + TEXTOUTWRAPPEDPATHED, + TEXTOUTCENTERED, + GETTEXTWIDTH, + GETTEXTHEIGHT, + GETTEXTHEIGHT2, + GETTEXTEXTENT, + SETFONTID, + GETFONTID, + GETFACENAME_, // GETFACENAME is taken in win32 + ISBITMAP, + GETSCRIPTID, + SETSCRIPTID, + SETFONTFACE, + ADDFONTRESOURCE, + ADDFONTRESOURCE2, + GETFONTSVCNAME, + }; +}; + +inline void svc_font::textOut(ifc_canvas *c, int x, int y, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias) +{ + _voidcall(TEXTOUT, c, x, y, txt, size, bold, opaque, underline, italic, color, bkcolor, xoffset, yoffset, antialias); +} + +inline void svc_font::textOut(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias) +{ + _voidcall(TEXTOUT2, c, x, y, w, h, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialias); +} + +inline void svc_font::textOutEllipsed(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias) +{ + _voidcall(TEXTOUTELLIPSED, c, x, y, w, h, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialias); +} + +inline void svc_font::textOutWrapped(ifc_canvas *c, int x, int y, int w, int h, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias) +{ + _voidcall(TEXTOUTWRAPPED, c, x, y, w, h, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialias); +} + +inline void svc_font::textOutWrappedPathed(ifc_canvas *c, int x, int y, int w, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias) +{ + _voidcall(TEXTOUTWRAPPEDPATHED, c, x, y, w, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialias); +} + +inline void svc_font::textOutCentered(ifc_canvas *c, RECT *r, const wchar_t *txt, int size, int bold, int opaque, int underline, int italic, int align, ARGB32 color, ARGB32 bkcolor, int xoffset, int yoffset, int antialias) +{ + _voidcall(TEXTOUTCENTERED, c, r, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialias); +} + +inline int svc_font::getTextWidth(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialias) +{ + return _call(GETTEXTWIDTH, (int)0, c, text, size, bold, underline, italic, antialias); +} + +inline int svc_font::getTextHeight(ifc_canvas *c, const wchar_t *text, int size, int bold, int underline, int italic, int antialias) { + return _call(GETTEXTHEIGHT, (int)0, c, text, size, bold, underline, italic, antialias); +} + +inline int svc_font::getTextHeight(ifc_canvas *c, int size, int bold, int underline, int italic, int antialias) { + return _call(GETTEXTHEIGHT, (int)0, c, size, bold, underline, italic, antialias); +} + +inline void svc_font::getTextExtent(ifc_canvas *c, const wchar_t *text, int *w, int *h, int size, int bold, int underline, int italic, int antialias) { + _voidcall(GETTEXTEXTENT, c, text, w, h, size, bold, underline, italic, antialias); +} + +inline void svc_font::setFontId(const wchar_t *id) { + _voidcall(SETFONTID, id); +} + +inline const wchar_t *svc_font::getFontId() +{ + return _call(GETFONTID, (const wchar_t *)0); +} + +inline const wchar_t *svc_font::getFaceName() +{ + return _call(GETFACENAME_, (const wchar_t *)0); +} + +inline int svc_font::isBitmap() { + return _call(ISBITMAP, (int)0); +} + +inline int svc_font::getScriptId() { + return _call(GETSCRIPTID, (int)0); +} + +inline void svc_font::setScriptId(int id) { + _voidcall(SETSCRIPTID, id); +} + +inline void svc_font::setFontFace(const wchar_t *face) +{ + _voidcall(SETFONTFACE, face); +} + +inline int svc_font::addFontResource(HANDLE f, const wchar_t *name) { + return _call(ADDFONTRESOURCE, (int)0, f, name); +} + +inline int svc_font::addFontResource2(void *mem, int datalen, const wchar_t *name) { + return _call(ADDFONTRESOURCE2, (int)0, mem, datalen, name); +} + +inline const wchar_t *svc_font::getFontSvcName() { + return _call(GETFONTSVCNAME, (const wchar_t *)0); +} + + + + + + +#endif // _SVC_FONT_H diff --git a/Src/Wasabi/api/service/svcs/svc_fontmaker.cpp b/Src/Wasabi/api/service/svcs/svc_fontmaker.cpp new file mode 100644 index 00000000..5003d8fe --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_fontmaker.cpp @@ -0,0 +1,9 @@ +#include "svc_fontmaker.h" + +#define CBCLASS svc_fontMakerI +START_DISPATCH + CB(GETFONTMAKERNAME, getFontMakerName); + CB(NEWTRUETYPEFONT, newTrueTypeFont); + CB(DELETETRUETYPEFONT, deleteTrueTypeFont); +END_DISPATCH +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_fontmaker.h b/Src/Wasabi/api/service/svcs/svc_fontmaker.h new file mode 100644 index 00000000..5ea25875 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_fontmaker.h @@ -0,0 +1,73 @@ +#ifndef _SVC_FONTMAKER_H +#define _SVC_FONTMAKER_H + +#include +#include +#include +#include +#include + +class svc_font; + +// +// This class doesn't do anything fantastic. It's just the way +// you make your OS-Specific font class available to the system. + +class NOVTABLE svc_fontMaker : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::FONTRENDER; } + + // You implement these: + const char *getFontMakerName(); + svc_font *newTrueTypeFont(); + int deleteTrueTypeFont(svc_font *font); + +protected: + enum { + GETFONTMAKERNAME, + NEWTRUETYPEFONT, + DELETETRUETYPEFONT, + }; +}; + + +inline const char *svc_fontMaker::getFontMakerName() { + return _call(GETFONTMAKERNAME, (const char *)0); +} + +inline svc_font *svc_fontMaker::newTrueTypeFont() { + return _call(NEWTRUETYPEFONT, (svc_font *)0); +} + +inline int svc_fontMaker::deleteTrueTypeFont(svc_font *font) { + return _call(DELETETRUETYPEFONT, (int)0, font); +} + +// implementor derives from this one +class NOVTABLE svc_fontMakerI : public svc_fontMaker { +public: + virtual const char *getFontMakerName() = 0; + virtual svc_font *newTrueTypeFont() = 0; + virtual int deleteTrueTypeFont(svc_font *font) = 0; + +protected: + RECVS_DISPATCH; +}; + +class FontMakerEnum : public SvcEnumT { +public: + FontMakerEnum(const char *_maker_name = NULL) : maker_name(_maker_name) {} +protected: + virtual int testService(svc_fontMaker *svc) { + if (!maker_name.len()) return 1; // blank name returns all services. + return (STRCASEEQL(svc->getFontMakerName(),maker_name)); + } +private: + String maker_name; +}; + +template +class FontMakerCreator : public waServiceFactoryTSingle {}; + + +#endif // _SVC_FONTMAKER_H diff --git a/Src/Wasabi/api/service/svcs/svc_fontrender.cpp b/Src/Wasabi/api/service/svcs/svc_fontrender.cpp new file mode 100644 index 00000000..67577fd2 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_fontrender.cpp @@ -0,0 +1,16 @@ +#include "svc_fontrender.h" + +#define CBCLASS svc_fontRenderI +START_DISPATCH + CB(ISNAMED, isNamed); + VCB(INSTALLTRUETYPEFONT, installTrueTypeFont); + VCB(INSTALLBITMAPFONT, installBitmapFont); + VCB(UNINSTALLALL, uninstallAll); + VCB(UNINSTALLBYSCRIPTID, uninstallByScriptId); + CB(REQUESTSKINFONT, requestSkinFont); + VCB(DISPATCHTEXTOUT, dispatchTextOut); + CB(DISPATCHGETINFO, dispatchGetInfo); + CB(USETRUETYPEOVERRIDE, useTrueTypeOverride); + CB(GETTRUETYPEOVERRIDE, getTrueTypeOverride); +END_DISPATCH +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_fontrender.h b/Src/Wasabi/api/service/svcs/svc_fontrender.h new file mode 100644 index 00000000..a377e76c --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_fontrender.h @@ -0,0 +1,126 @@ +#ifndef _svc_fONTRENDER_H +#define _svc_fONTRENDER_H + +#include +#include +#include +#include +#include + +class svc_font; +class ifc_canvas; + +class NOVTABLE svc_fontRender : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::FONTRENDER; } + + // test the type. + int isNamed(const char *renderer_name); + + // static methods from Font:: + void installTrueTypeFont(const char *filename, const char *path, const char *id, int scriptid); // call this to install a new font + void installBitmapFont(const char *filename, const char *path, const char *id, int charwidth, int charheight, int hspacing, int vspacing, int scriptid); + void uninstallAll(); + void uninstallByScriptId(int scriptid); + svc_font *requestSkinFont(const char *id); // call this to get a Font pointer to a font id + void dispatchTextOut(ifc_canvas *c, int style, int x, int y, int w, int h, const char *txt); + int dispatchGetInfo(ifc_canvas *c, const char *font, int infoid, const char *txt, int *w, int *h); + int useTrueTypeOverride(); + const char *getTrueTypeOverride(); + + +protected: + enum { + ISNAMED, + INSTALLTRUETYPEFONT, + INSTALLBITMAPFONT, + UNINSTALLALL, + UNINSTALLBYSCRIPTID, + REQUESTSKINFONT, + DISPATCHTEXTOUT, + DISPATCHGETINFO, + USETRUETYPEOVERRIDE, + GETTRUETYPEOVERRIDE, + }; +}; + + +inline int svc_fontRender::isNamed(const char *renderer_name) { + return _call(ISNAMED, (int)0, renderer_name); +} + +inline void svc_fontRender::installTrueTypeFont(const char *filename, const char *path, const char *id, int scriptid) { + _voidcall(INSTALLTRUETYPEFONT, filename, path, id, scriptid); +} + +inline void svc_fontRender::installBitmapFont(const char *filename, const char *path, const char *id, int charwidth, int charheight, int hspacing, int vspacing, int scriptid) { + _voidcall(INSTALLBITMAPFONT, filename, path, id, charwidth, charheight, hspacing, vspacing, scriptid); +} + +inline void svc_fontRender::uninstallAll() { + _voidcall(UNINSTALLALL); +} + +inline void svc_fontRender::uninstallByScriptId(int scriptid) { + _voidcall(UNINSTALLBYSCRIPTID, scriptid); +} + +inline svc_font *svc_fontRender::requestSkinFont(const char *id) { + return _call(REQUESTSKINFONT, (svc_font *)0, id); +} + +inline void svc_fontRender::dispatchTextOut(ifc_canvas *c, int style, int x, int y, int w, int h, const char *txt) { + _voidcall(DISPATCHTEXTOUT, c, style, x, y, w, h, txt); +} + +inline int svc_fontRender::dispatchGetInfo(ifc_canvas *c, const char *font, int infoid, const char *txt, int *w, int *h) { + return _call(DISPATCHGETINFO, (int)0, c, font, infoid, txt, w, h ); +} + +inline int svc_fontRender::useTrueTypeOverride() { + return _call(USETRUETYPEOVERRIDE, (int)0); +} + +inline const char *svc_fontRender::getTrueTypeOverride() { + return _call(GETTRUETYPEOVERRIDE, (const char *)0); +} + +// implementor derives from this one +class NOVTABLE svc_fontRenderI : public svc_fontRender { +public: + + // test the type + virtual int isNamed(const char *renderer_name) = 0; + + // static methods from Font:: + virtual void installTrueTypeFont(const char *filename, const char *path, const char *id, int scriptid) = 0; + virtual void installBitmapFont(const char *filename, const char *path, const char *id, int charwidth, int charheight, int hspacing, int vspacing, int scriptid) = 0; + virtual void uninstallAll() = 0; + virtual void uninstallByScriptId(int scriptid) = 0; + virtual svc_font *requestSkinFont(const char *id) = 0; // call this to get a Font pointer to a font id + virtual void dispatchTextOut(ifc_canvas *c, int style, int x, int y, int w, int h, const char *txt) = 0; + virtual int dispatchGetInfo(ifc_canvas *c, const char *font, int infoid, const char *txt, int *w, int *h) = 0; + virtual int useTrueTypeOverride() = 0; + virtual const char *getTrueTypeOverride() = 0; + + +protected: + RECVS_DISPATCH; +}; + +class FontRenderEnum : public SvcEnumT { +public: + FontRenderEnum(const char *_renderer_name = NULL) : renderer_name(_renderer_name) {} +protected: + virtual int testService(svc_fontRender *svc) { + return (svc->isNamed(renderer_name)); + } +private: + String renderer_name; +}; + +template +class FontRenderCreator : public waServiceFactoryTSingle {}; + + +#endif // _svc_fONTRENDER_H diff --git a/Src/Wasabi/api/service/svcs/svc_imggen.cpp b/Src/Wasabi/api/service/svcs/svc_imggen.cpp new file mode 100644 index 00000000..44f25d24 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_imggen.cpp @@ -0,0 +1,11 @@ +#include + +#include "svc_imggen.h" + +#define CBCLASS svc_imageGeneratorI +START_DISPATCH; + CB(TESTDESC, testDesc); + CB(GENIMAGE, genImage); + CB(OUTPUTCACHEABLE, outputCacheable); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_imggen.h b/Src/Wasabi/api/service/svcs/svc_imggen.h new file mode 100644 index 00000000..a36377c8 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_imggen.h @@ -0,0 +1,68 @@ +#ifndef _SVC_IMGGEN_H +#define _SVC_IMGGEN_H + +#include +#include + + +class NOVTABLE svc_imageGenerator : public Dispatchable +{ +public: + static FOURCC getServiceType() { return WaSvc::IMAGEGENERATOR; } + int testDesc(const wchar_t *desc); + ARGB32 *genImage(const wchar_t *desc, int *has_alpha, int *w, int *h, ifc_xmlreaderparams *params = NULL); + int outputCacheable(); + + enum { + TESTDESC = 10, + GENIMAGE = 30, + OUTPUTCACHEABLE = 40, + }; +}; + +inline int svc_imageGenerator::testDesc(const wchar_t *desc) +{ + return _call(TESTDESC, 0, desc); +} + +inline ARGB32 *svc_imageGenerator::genImage(const wchar_t *desc, int *has_alpha, int *w, int *h, ifc_xmlreaderparams *params) +{ + return _call(GENIMAGE, (ARGB32 *)0, desc, has_alpha, w, h, params); +} + +inline int svc_imageGenerator::outputCacheable() +{ + return _call(OUTPUTCACHEABLE, 0); +} + +// derive from this one +class NOVTABLE svc_imageGeneratorI : public svc_imageGenerator +{ +public: + virtual int testDesc(const wchar_t *desc) = 0; + virtual ARGB32 *genImage(const wchar_t *desc, int *has_alpha, int *w, int *h, ifc_xmlreaderparams *params = NULL) = 0; + virtual int outputCacheable() { return 0; } + +protected: + RECVS_DISPATCH; +}; + +#include +#include + +class ImgGeneratorEnum : public SvcEnumT +{ +public: + ImgGeneratorEnum(const wchar_t *_desc) : desc(_desc) { } + +protected: + virtual int testService(svc_imageGenerator *svc) + { + return svc->testDesc(desc); + } + +private: + StringW desc; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_imgload.cpp b/Src/Wasabi/api/service/svcs/svc_imgload.cpp new file mode 100644 index 00000000..d8eb3cfc --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_imgload.cpp @@ -0,0 +1,14 @@ +#include + +#include "svc_imgload.h" + +#define CBCLASS svc_imageLoaderI +START_DISPATCH; + CB(ISMINE, isMine); + CB(TESTDATA, testData); + CB(GETHEADERSIZE, getHeaderSize); + CB(GETDIMENSIONS, getDimensions); + CB(LOADIMAGE, loadImage); +END_DISPATCH; +#undef CBCLASS + diff --git a/Src/Wasabi/api/service/svcs/svc_imgload.h b/Src/Wasabi/api/service/svcs/svc_imgload.h new file mode 100644 index 00000000..22f3851c --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_imgload.h @@ -0,0 +1,101 @@ +#ifndef _SVC_IMGLOAD_H +#define _SVC_IMGLOAD_H + +#include +#include +#include + + +class ifc_xmlreaderparams; + +class NOVTABLE svc_imageLoader : public Dispatchable +{ +public: + static FOURCC getServiceType() { return WaSvc::IMAGELOADER; } + + // assuming there is an extension of this type, is it yours? + int isMine(const wchar_t *filename); + + // returns the mime type for this type of image + const wchar_t *mimeType(); + + // returns how many bytes needed to get image info + int getHeaderSize(); + + // test image data, return TRUE if you can load it + int testData(const void *data, int datalen); + + // just gets the width and height from the data, if possible + int getDimensions(const void *data, int datalen, int *w, int *h); + + // converts the data into pixels + premultiply, use api->sysFree to deallocate + ARGB32 *loadImage(const void *data, int datalen, int *w, int *h, ifc_xmlreaderparams *params=NULL);\ + + // converts the data into pixels, use api->sysFree to deallocate + ARGB32 *loadImageData(const void *data, int datalen, int *w, int *h, ifc_xmlreaderparams *params=NULL); + + enum { + ISMINE=50, + MIMETYPE=75, + GETHEADERSIZE=100, + TESTDATA=200, + GETDIMENSIONS=300, + LOADIMAGE=400, + LOADIMAGEDATA=500, + }; +}; + +inline int svc_imageLoader::isMine(const wchar_t *filename) { + return _call(ISMINE, 0, filename); +} + +inline const wchar_t *svc_imageLoader::mimeType() { + return _call(MIMETYPE, L""); +} + +inline int svc_imageLoader::getHeaderSize() { + return _call(GETHEADERSIZE, -1); +} + +inline int svc_imageLoader::testData(const void *data, int datalen) { + return _call(TESTDATA, 0, data, datalen); +} + +inline int svc_imageLoader::getDimensions(const void *data, int datalen, int *w, int *h) { + return _call(GETDIMENSIONS, 0, data, datalen, w, h); +} + +inline ARGB32 *svc_imageLoader::loadImage(const void *data, int datalen, int *w, int *h, ifc_xmlreaderparams *params) { + return _call(LOADIMAGE, (ARGB32*)0, data, datalen, w, h, params); +} + +inline ARGB32 *svc_imageLoader::loadImageData(const void *data, int datalen, int *w, int *h, ifc_xmlreaderparams *params) { + return _call(LOADIMAGEDATA, (ARGB32*)0, data, datalen, w, h, params); +} + +// derive from this one +class NOVTABLE svc_imageLoaderI : public svc_imageLoader +{ +public: + virtual int isMine(const wchar_t *filename)=0; + virtual const wchar_t *mimeType(void)=0; + // return the header size needed to get w/h and determine if it can be loaded + virtual int getHeaderSize() { return -1; }//don't know + // test image data, return TRUE if you can load it + virtual int testData(const void *data, int datalen)=0; + // just gets the width and height from the data, if possible + virtual int getDimensions(const void *data, int datalen, int *w, int *h) { return 0; } + // converts the data into pixels + premultiply, use api->sysFree to deallocate + virtual ARGB32 *loadImage(const void *data, int datalen, int *w, int *h, ifc_xmlreaderparams *params=NULL)=0; +#if 0 + // converts the data into pixels, use api->sysFree to deallocate + virtual ARGB32 *loadImageData(const void *data, int datalen, int *w, int *h, ifc_xmlreaderparams *params=NULL)=0; +#endif + +protected: + RECVS_DISPATCH; +}; + + + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_imgwrite.h b/Src/Wasabi/api/service/svcs/svc_imgwrite.h new file mode 100644 index 00000000..e699bc57 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_imgwrite.h @@ -0,0 +1,101 @@ +#ifndef _SVC_IMGWRITE_H +#define _SVC_IMGWRITE_H + +#include +#include +#include + +class NOVTABLE svc_imageWriter : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::IMAGEWRITER; } + + // returns a human readable string about the format. eg "JPEG" + const wchar_t * getImageTypeName(); + + // returns a semi-colon delimited list of file extensions for this format. eg "jpg;jpeg" + // MUST BE LOWER CASE + const wchar_t * getExtensions(); + + // valid items include "quality" for jpeg files with value "0" to "100" + // return value is 1 if the config item is supported, 0 if it is not. + int setConfig(const wchar_t * item, const wchar_t * value); + + // valid items include "quality" for jpeg files with value "0" to "100", "lossless" returns "1" if it is "0" otherwise + // return value is 1 if the config item is supported, 0 if it is not. + int getConfig(const wchar_t * item, wchar_t * value, int valuelen); + + // returns 1 if the bit depth is supported (eg 32 for ARGB32, 24 for RGB24) + // ARGB32 MUST be supported + int bitDepthSupported(int depth); + + // returns the image in our format, free the returned buffer with api_memmgr::sysFree() + void * convert(const void *pixels, int bitDepth, int w, int h, int *length); + + enum { + GETIMAGETYPENAME=10, + GETEXTENSIONS=20, + SETCONFIG=30, + GETCONFIG=40, + BITDEPTHSUPPORTED=50, + CONVERT=60, + }; +}; + +inline const wchar_t *svc_imageWriter::getImageTypeName() { + return _call(GETIMAGETYPENAME, L""); +} + +inline const wchar_t *svc_imageWriter::getExtensions() { + return _call(GETEXTENSIONS, L""); +} + +inline int svc_imageWriter::setConfig(const wchar_t * item, const wchar_t * value) { + return _call(SETCONFIG, (int)0, item, value); +} + +inline int svc_imageWriter::getConfig(const wchar_t * item, wchar_t * value, int valuelen) { + return _call(GETCONFIG, (int)0, item, value, valuelen); +} + +inline int svc_imageWriter::bitDepthSupported(int depth) { + return _call(BITDEPTHSUPPORTED, (int)0, depth); +} + +inline void * svc_imageWriter::convert(const void *pixels, int bitDepth, int w, int h, int *length) { + return _call(CONVERT, (void*)0, pixels, bitDepth, w, h, length); +} + +// derive from this one +class NOVTABLE svc_imageWriterI : public svc_imageWriter { +public: + virtual const wchar_t * getExtensions()=0; + virtual const wchar_t * getImageTypeName()=0; + virtual int setConfig(const wchar_t * item, const wchar_t * value){return 0;} + virtual int getConfig(const wchar_t * item, wchar_t * value, int valuelen){return 0;} + virtual int bitDepthSupported(int depth)=0; + virtual void * convert(const void *pixels, int bitDepth, int w, int h, int *length)=0; +protected: + RECVS_DISPATCH; +}; + +/* do we still use svc_enum? +#include + +class ImgWriterEnum : public SvcEnumT { +public: + ImgWriterEnum(const char *_ext=NULL) : ext(_ext) { } + +protected: + virtual int testService(svc_imageWriter *svc) { + if (ext.isempty()) return 1; + else { + PathParser pp(svc->getExtensions(), ";"); + for (int i = 0; i < pp.getNumStrings(); i++) + if (STRCASEEQL(ext, pp.enumString(i))) return 1; + return 0; + } + } + String ext; +}; +*/ +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_itemmgr.cpp b/Src/Wasabi/api/service/svcs/svc_itemmgr.cpp new file mode 100644 index 00000000..3cadb94e --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_itemmgr.cpp @@ -0,0 +1,20 @@ +#include + +#include "svc_itemmgr.h" + +#define CBCLASS svc_itemMgrI +START_DISPATCH; + CB(ISMINE, isMine); + CB(OPTIMIZEPLAYSTRING, optimizePlaystring); + CB(CREATEINITIALNAME, createInitialName); + CB(OPTIMIZEFILEDATA, optimizeFileData); + CB(ONDATABASEADD, onDatabaseAdd); + CB(ONDATABASEDEL, onDatabaseDel); + CB(ONTITLECHANGE, onTitleChange); + CB(ONTITLE2CHANGE, onTitle2Change); + VCB(ONNEXTFILE, onNextFile); + VCB(ONFILECOMPLETE, onFileComplete); + CB(WANTSCANDATA, wantScanData); + CB(GETSORTORDER, getSortOrder); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_itemmgr.h b/Src/Wasabi/api/service/svcs/svc_itemmgr.h new file mode 100644 index 00000000..c2e3e416 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_itemmgr.h @@ -0,0 +1,112 @@ +#ifndef _SVC_ITEMMGR_H +#define _SVC_ITEMMGR_H + +#include +#include + +class NOVTABLE svc_itemMgr : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::ITEMMANAGER; } + + int isMine(const char *playstring) { return _call(ISMINE, 0, playstring); } + + int optimizePlaystring(char *playstring) { + return _call(OPTIMIZEPLAYSTRING, 0, playstring); + } + int createInitialName(const char *playstring, char *buf, int buflen) { + return _call(CREATEINITIALNAME, 0, playstring, buf, buflen); + } + int optimizeFileData(const char *playstring, const char *fieldname, int datatype, char *data, int datalen) { + return _call(OPTIMIZEFILEDATA, -1, playstring, fieldname, datatype, data, datalen); + } + + int onDatabaseAdd(const char *playstring) { + return _call(ONDATABASEADD, 0, playstring); + } + int onDatabaseDel(const char *playstring) { + return _call(ONDATABASEDEL, 0, playstring); + } + + //return 1 if changed + int onTitleChange(const char *playstring, const char *newtitle) { + return _call(ONTITLECHANGE, 0, playstring, newtitle); + } + int onTitle2Change(const char *playstring, const char *newtitle) { + return _call(ONTITLE2CHANGE, 0, playstring, newtitle); + } + + void onNextFile(const char *playstring) { + _voidcall(ONNEXTFILE, playstring); + } + + void onFileComplete(const char *playstring) { + _voidcall(ONFILECOMPLETE, playstring); + } + + int wantScanData(const char *playstring) { + return _call(WANTSCANDATA, 1, playstring); + } + + int getSortOrder() { + return _call(GETSORTORDER, 0); + } + + enum { + ISMINE=100, + OPTIMIZEPLAYSTRING=200, + OPTIMIZEFILEDATA=211, //210 retired + CREATEINITIALNAME=300, + ONDATABASEADD=400, + ONDATABASEDEL=401, + ONTITLECHANGE=600, + ONTITLE2CHANGE=601, + ONNEXTFILE=700, + ONFILECOMPLETE=800, + WANTSCANDATA=900, + GETSORTORDER=1000, + }; +}; + +// derive from this one +class NOVTABLE svc_itemMgrI : public svc_itemMgr { +public: + virtual int isMine(const char *playstring)=0; + virtual int optimizePlaystring(char *playstring) { return 0; } + virtual int createInitialName(const char *playstring, char *buf, int buflen) { return 0; } + virtual int optimizeFileData(const char *playstring, const char *fieldname, int datatype, char *data, int datalen) { return -1; } + virtual int onDatabaseAdd(const char *playstring) { return 0; } + virtual int onDatabaseDel(const char *playstring) { return 0; } + virtual int onTitleChange(const char *playstring, const char *newtitle) { return 0; } + virtual int onTitle2Change(const char *playstring, const char *newtitle) { return 0; } + virtual void onNextFile(const char *playstring) { } + virtual void onFileComplete(const char *playstring) { } + + virtual int wantScanData(const char *playstring) { return 1; } + + virtual int getSortOrder() { return 0; } + +protected: + RECVS_DISPATCH; +}; + +#include +#include + +class ItemMgrEnum : private Named, public SvcEnumT { +public: + ItemMgrEnum(const char *ps) : Named(ps) { } + + void setPlaystring(const char *ps) { Named::setName(ps); } + +protected: + virtual int testService(svc_itemMgr *svc) { + return svc->isMine(getName()); + } +}; + +#include + +template +class ItemMgrCreator : public waServiceFactoryTSingle { }; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_loadlib.h b/Src/Wasabi/api/service/svcs/svc_loadlib.h new file mode 100644 index 00000000..25a72a06 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_loadlib.h @@ -0,0 +1,16 @@ +#ifndef _LOADLIB_H +#define _LOADLIB_H + +//UNDER CONSTRUCTION + +class NOVTABLE svc_loadLib +{ +public: + int isMine(const char *filename); + + int load(const char *filename); + void unload(); + void *getProcAddress(const char *name); +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_mediaconverter.cpp b/Src/Wasabi/api/service/svcs/svc_mediaconverter.cpp new file mode 100644 index 00000000..98ab19f0 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_mediaconverter.cpp @@ -0,0 +1,23 @@ +#include + +#include "svc_mediaconverter.h" + +#define CBCLASS svc_mediaConverterNI +START_DISPATCH; + CB(CANCONVERTFROM,canConvertFrom) + CB(GETCONVERTERTO,getConverterTo) + CB(GETINFOS,getInfos) + CB(SETINFOS,setInfos) + CB(GETINFOSXMLGROUP,getInfosXmlGroup) + CB(PROCESSDATA,processData) + CB(GETPOSITION,getPosition) + CB(GETLATENCY,getLatency) + CB(GETCORECALLBACK,getCoreCallback) + CB(SORTPLACEMENT,sortPlacement) + CB(ISSELECTABLEOUTPUT,isSelectableOutput) + CB(CANSUPPORTCONTENTTYPE,canSupportContentType) + VCB(SETCORETOKEN,setCoreToken) + CB(ONCOREUSERMSG,onCoreUserMsg) +END_DISPATCH; +#undef CBCLASS + diff --git a/Src/Wasabi/api/service/svcs/svc_mediaconverter.h b/Src/Wasabi/api/service/svcs/svc_mediaconverter.h new file mode 100644 index 00000000..c08c2932 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_mediaconverter.h @@ -0,0 +1,161 @@ +#ifndef _SVC_MEDIACONVERTER_H +#define _SVC_MEDIACONVERTER_H + +#include + +#include +#include +#include + +#include + +// do NOT derive from these ones +class NOVTABLE svc_mediaConverter : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::MEDIACONVERTER; } + + // test if the converter can handle that stream, filename or chunktype: + // if your converter can accept streams depending on the data stream you should + // test the file thru the reader interface (like to test if the file header is ok) + // if your converter can accept files thru a test on the filename string, you should + // test the name string (like tone://... or *.wav) + // if your converter can accept depending on the chunktype, you should test the chunktype + // (like MP3, PCM, etc...) + // returns 1 if ok + int canConvertFrom(svc_fileReader *reader, const char *name, const char *chunktype) { return _call(CANCONVERTFROM,0,reader,name,chunktype); } + + // returns the chunk type that the converter will convert to + // (PCM, MP3, etc...) + const char *getConverterTo() { return _call(GETCONVERTERTO,""); } + + // override this one if your converter can decode depending on a "Content-Type:" HTTP header + int canSupportContentType(const char *contenttype) { return _call(CANSUPPORTCONTENTTYPE,0,contenttype); } + + // fills up the infos class + int getInfos(MediaInfo *infos) { return _call(GETINFOS,0,infos); } + + // writes back the infos on the file. + // note: the reader you get in the infos class has the filename opened in read/write mode + // return 1 if update succeeded, 0 if error + int setInfos(MediaInfo *infos) { return _call(SETINFOS,0,infos); } + + // returns the id of the xml group the media info editor will use for displaying/editing infos + const char *getInfosXmlGroup() { return _call(GETINFOSXMLGROUP,(const char *)NULL); } + + // process current file data + // returns 1 if ok, 0 when file/stream has ended + int processData(MediaInfo *infos, ChunkList *chunk_list, bool *killswitch) { return _call(PROCESSDATA,0,infos,chunk_list,killswitch); } + + // returns the current position in ms + // usually the position is automatically calculated with the amount of PCM data converters send back to the core + // so you don't have to override this function. however, if you want to force the position, return a value other than -1 + int getPosition(void) { return _call(GETPOSITION,-1); } + + // returns the latency of the converter in ms + int getLatency(void) { return _call(GETLATENCY,0); } + + // sort function to be able to specify where you want your converter placed in the converter list + // (like if you want to be before or after the crossfader for example, override this function) + // return -1 to be placed before "otherconverter", 1 to be placed after "otherconverter", otherwise 0 + int sortPlacement(const char *otherconverter) { return _call(SORTPLACEMENT,0,otherconverter); } + + // return 1 if you want this converter to be selectable as output in prefs->audio + int isSelectableOutput(void) { return _call(ISSELECTABLEOUTPUT,0); } + + // message received by sendConvertersMsg() in the core + int onCoreUserMsg(const char *msg, const char *value) { return _call(ONCOREUSERMSG,0,msg,value); } + + + // internally used by wasabi + CoreCallback *getCoreCallback(void) { return _call(GETCORECALLBACK,(CoreCallback *)0); } + void setCoreToken(CoreToken t) { _voidcall(SETCORETOKEN,t); } + + enum { + CANCONVERTFROM=10, + GETCONVERTERTO=20, + GETINFOS=30, + PROCESSDATA=40, + GETPOSITION=50, + GETLATENCY=60, + GETCORECALLBACK=70, + SORTPLACEMENT=80, + CANSUPPORTCONTENTTYPE=90, + SETCORETOKEN=100, + SETINFOS=110, + GETINFOSXMLGROUP=120, + ISSELECTABLEOUTPUT=130, + ONCOREUSERMSG=140, + }; +}; + +class NOVTABLE svc_mediaConverterNI : public svc_mediaConverter { +public: + virtual int canConvertFrom(svc_fileReader *reader, const char *name, const char *chunktype)=0; + virtual const char *getConverterTo()=0; + virtual int canSupportContentType(const char *contenttype) { return 0; } + + virtual int getInfos(MediaInfo *infos)=0; + + virtual int setInfos(MediaInfo *infos)=0; + + virtual const char *getInfosXmlGroup()=0; + + virtual int processData(MediaInfo *infos, ChunkList *chunk_list, bool *killswitch)=0; + + virtual int getPosition(void) { return -1; } + + virtual int getLatency(void) { return 0; } + + virtual int sortPlacement(const char *otherconverter) { return 0; } + + virtual int isSelectableOutput(void) { return 0; } + + virtual int onCoreUserMsg(const char *msg, const char *value) { return 0; } + + virtual CoreCallback *getCoreCallback(void)=0; + + virtual void setCoreToken(CoreToken t)=0; +protected: + RECVS_DISPATCH; +}; + +// derive from this one +class NOVTABLE svc_mediaConverterI : public svc_mediaConverterNI, public CoreCallbackI { +public: + svc_mediaConverterI() : m_coretoken(0) { } + + virtual int canConvertFrom(svc_fileReader *reader, const char *name, const char *chunktype)=0; + virtual const char *getConverterTo()=0; + virtual int canSupportContentType(const char *contenttype) { return 0; } + + virtual int getInfos(MediaInfo *infos)=0; + + virtual int setInfos(MediaInfo *infos) { return 0; } + + virtual const char *getInfosXmlGroup() { return (const char *)NULL; } + + virtual int processData(MediaInfo *infos, ChunkList *chunk_list, bool *killswitch)=0; + + virtual int getPosition(void) { return -1; } + + virtual int getLatency(void) { return 0; } + + virtual int sortPlacement(const char *otherconverter) { return 0; } + + virtual int isSelectableOutput(void) { return 0; } + + virtual int onCoreUserMsg(const char *msg, const char *value) { return 0; } + + virtual CoreCallback *getCoreCallback(void) { return this; } + + virtual void setCoreToken(CoreToken t) { m_coretoken=t; } + +protected: + CoreToken m_coretoken; +}; + +#include +template +class MediaConverterCreator : public waServiceFactoryT { }; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_mediacore.cpp b/Src/Wasabi/api/service/svcs/svc_mediacore.cpp new file mode 100644 index 00000000..154b7a00 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_mediacore.cpp @@ -0,0 +1,45 @@ +#include + +#include "svc_mediacore.h" + +#define CBCLASS svc_mediaCoreI +START_DISPATCH; + VCB(SETCALLBACK,setCallback); + VCB(SETNEXTFILE,setNextFile); + VCB(START,start); + VCB(PAUSE,pause); + VCB(SETPOSITION,setPosition); + VCB(SETVOLUME,setVolume); + VCB(SETPAN,setPan); + VCB(ABORTCURRENTSONG,abortCurrentSong); + VCB(STOP,stop); + CB(GETPLAYING,getPlaying); + CB(GETPOSITION,getPosition); + CB(GETWRITEPOSITION,getWritePosition); + CB(GETTITLE,getTitle); + VCB(GETINFO,getInfo); + CB(GETLENGTH,getLength); + CB(GETVOLUME,getVolume); + CB(GETPAN,getPan); + VCB(SETEQSTATUS,setEQStatus); + CB(GETEQSTATUS,getEQStatus); + VCB(SETEQPREAMP,setEQPreamp); + CB(GETEQPREAMP,getEQPreamp); + VCB(SETEQBAND,setEQBand); + CB(GETEQBAND,getEQBand); + VCB(SETEQBANDS,setEQBands); + VCB(GETEQBANDS,getEQBands); + VCB(SETEQ,setEQ); + VCB(GETEQ,getEQ); + CB(GETMETADATA,getMetaData); + CB(GETVISDATA,getVisData); + VCB(MUTE,mute); + CB(ISMUTED,isMuted); + VCB(SETCORETOKEN,setCoreToken); + VCB(SETPRIORITY,setPriority); + CB(GETPRIORITY,getPriority); + VCB(REBUILDCONVERTERSCHAIN, rebuildConvertersChain) + CB(SENDCONVERTERSMSG, sendConvertersMsg) +END_DISPATCH; +#undef CBCLASS + diff --git a/Src/Wasabi/api/service/svcs/svc_mediacore.h b/Src/Wasabi/api/service/svcs/svc_mediacore.h new file mode 100644 index 00000000..2ddbdceb --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_mediacore.h @@ -0,0 +1,172 @@ +#ifndef _SVC_MEDIACORE_H +#define _SVC_MEDIACORE_H + +#include +#include +#include + +class NOVTABLE svc_mediaCore : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::MEDIACORE; } + + void setCallback(CoreCallback *callback) { _voidcall(SETCALLBACK,callback); } + void setCoreToken(CoreToken t) { _voidcall(SETCORETOKEN,t); } + + void setNextFile(const char *file, const char *to=NULL, int uniqueid=0) { _voidcall(SETNEXTFILE,file,to,uniqueid); } + + void start(void) { _voidcall(START); } + void pause(int pause) { _voidcall(PAUSE,pause); } + void setPosition(int ms) { _voidcall(SETPOSITION,ms); } + + void setVolume(int volume) { _voidcall(SETVOLUME,volume); } + void setPan(int pan) { _voidcall(SETPAN,pan); } + + void abortCurrentSong() { _voidcall(ABORTCURRENTSONG); } + void stop(int suppress_callback=FALSE) { _voidcall(STOP,suppress_callback); } + + int getPlaying(void) { return _call(GETPLAYING,0); } + int getPosition(void) { return _call(GETPOSITION,0); } + int getWritePosition(void) { return _call(GETWRITEPOSITION,0); } + + int getTitle(char *title, int maxlen) { return _call(GETTITLE,0,title,maxlen); } + void getInfo(char *info, int maxlen) { _voidcall(GETINFO,info,maxlen); } + int getLength(void) { return _call(GETLENGTH,0); } + + int getVolume(void) { return _call(GETVOLUME,0); } + int getPan(void) { return _call(GETPAN,0); } + + void mute(int mute) { _voidcall(MUTE,mute); } + int isMuted() { return _call(ISMUTED,0); } + + void setEQStatus(int enable) { _voidcall(SETEQSTATUS,enable); } + int getEQStatus() { return _call(GETEQSTATUS,0); } + void setEQPreamp(char pre) { _voidcall(SETEQPREAMP,pre); } + char getEQPreamp() { return _call(GETEQPREAMP,0); } + void setEQBand(int band, char val) { _voidcall(SETEQBAND,band,val); } + char getEQBand(int band) { return _call(GETEQBAND,0,band); } + void setEQBands(char tab[10]) { _voidcall(SETEQBANDS,tab); } + void getEQBands(char *tab) { _voidcall(GETEQBANDS,tab); } + + void setEQ(int enable, char pre, char tab[10]) { _voidcall(SETEQ,enable,pre,tab); } + void getEQ(int *enable, char *pre, char *tab) { _voidcall(GETEQ,enable,pre,tab); } + + int getMetaData(const char *name, char *data, int data_len) { return _call(GETMETADATA,0,name,data,data_len); } + + int getVisData(void *dataptr, int sizedataptr) { return _call(GETVISDATA,0,dataptr,sizedataptr); } + + void setPriority(int priority) { _voidcall(SETPRIORITY,priority); } + int getPriority() { return _call(GETPRIORITY,0); } + + void rebuildConvertersChain() { _voidcall(REBUILDCONVERTERSCHAIN); } + + int sendConvertersMsg(const char *msg, const char *value) { return _call(SENDCONVERTERSMSG,0,msg,value); } + + enum { + SETCALLBACK=10, + SETNEXTFILE=20, + START=30, + PAUSE=40, + SETPOSITION=50, + SETVOLUME=60, + SETPAN=70, + ABORTCURRENTSONG=80, + STOP=90, + GETPLAYING=100, + GETPOSITION=110, + GETWRITEPOSITION=120, + GETTITLE=130, + GETINFO=140, + GETLENGTH=150, + GETVOLUME=160, + GETPAN=170, + SETEQSTATUS=180, + GETEQSTATUS=190, + SETEQPREAMP=200, + GETEQPREAMP=210, + SETEQBAND=220, + GETEQBAND=230, + SETEQBANDS=240, + GETEQBANDS=250, + SETEQ=260, + GETEQ=270, + GETMETADATA=280, + GETVISDATA=290, + MUTE=300, + ISMUTED=310, + SETCORETOKEN=320, + SETPRIORITY=330, + GETPRIORITY=340, + REBUILDCONVERTERSCHAIN=350, + SENDCONVERTERSMSG=360, + }; +}; + +// derive from this one +class NOVTABLE svc_mediaCoreI : public svc_mediaCore { +public: + svc_mediaCoreI() : m_coretoken(0) { } + + virtual void setCallback(CoreCallback *callback)=0; + virtual void setCoreToken(CoreToken t) { m_coretoken=t; } + + virtual void setNextFile(const char *file, const char *to=NULL, int uniqueid=0)=0; + /* call to specify next file from WCM_NEEDNEXTFILE, or before calling start() */ + + virtual void start(void)=0; /* start playback */ + virtual void pause(int pause)=0; /* set/unset paused state (nonzero is paused, zero is unpaused) */ + virtual void setPosition(int ms)=0; /* set position of current stream in ms */ + + virtual void setVolume(int volume)=0; /* volume is 0 to 255 */ + virtual void setPan(int pan)=0; /* pan is -127 to 127 */ + virtual void abortCurrentSong()=0; /* abort decoding of current song and start playing the next one */ + virtual void stop(int suppress_callback=FALSE)=0; + + virtual int getPlaying(void)=0; /* 0 is not playing, 1 is playing, -1 is paused */ + virtual int getPosition(void)=0; /* get position of current stream in ms */ + virtual int getWritePosition(void)=0; /* get written position of current stream in ms */ + + virtual int getTitle(char *title, int maxlen)=0; // returns uniqueid + virtual void getInfo(char *info, int maxlen)=0; + virtual int getLength(void)=0; /* get length of track in ms. -1 indicates infinite/unknown */ + + virtual int getVolume(void)=0; /* get volume (0-255) */ + virtual int getPan(void)=0; /* get panning (-127 to 127) */ + + virtual void mute(int mute)=0; + virtual int isMuted()=0; + + virtual void setEQStatus(int enable)=0; /* 0 if off, 1 if on */ + virtual int getEQStatus()=0; /* 0 if off, 1 if on */ + virtual void setEQPreamp(char pre)=0; /* -127 to 127 (-20db to +20db) */ + virtual char getEQPreamp()=0; /* -127 to 127 (-20db to +20db) */ + virtual void setEQBand(int band, char val)=0; /* band=0-9 */ + virtual char getEQBand(int band)=0; /* band=0-9 */ + virtual void setEQBands(char tab[10])=0; /* eq values are -127 to 127 (-20db to +20db) */ + virtual void getEQBands(char *tab)=0; /* eq values are -127 to 127 (-20db to +20db) */ + + virtual void setEQ(int enable, char pre, char tab[10])=0; + virtual void getEQ(int *enable, char *pre, char *tab)=0; + + virtual int getMetaData(const char *name, char *data, int data_len)=0; // returns size of data + + virtual int getVisData(void *dataptr, int sizedataptr)=0; // returns size of data it wanted to copy, if any. + + virtual void setPriority(int priority)=0; + virtual int getPriority()=0; + + virtual void rebuildConvertersChain()=0; + + virtual int sendConvertersMsg(const char *msg, const char *value)=0; + +protected: + RECVS_DISPATCH; + + CoreToken m_coretoken; +}; + +#include + +template +class MediaCoreCreator : public waServiceFactoryT { }; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_metadata.cpp b/Src/Wasabi/api/service/svcs/svc_metadata.cpp new file mode 100644 index 00000000..dfacc342 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_metadata.cpp @@ -0,0 +1,14 @@ +#include + +#include "svc_metadata.h" + +#define CBCLASS svc_metaDataI +START_DISPATCH; + CB(ENUMMETADATA, enumMetaData); + CB(HASMETADATA, hasMetaData); + CB(ALLOWOPERATION, allowOperation); + CB(GETGUID, getGUID); + CB(GETMETANAME, getMetaTableName); +END_DISPATCH; +#undef CBCLASS + diff --git a/Src/Wasabi/api/service/svcs/svc_metadata.h b/Src/Wasabi/api/service/svcs/svc_metadata.h new file mode 100644 index 00000000..f237849d --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_metadata.h @@ -0,0 +1,97 @@ +#ifndef _SVC_METADATA_H +#define _SVC_METADATA_H + +// see helper class in common/metadatasvc.h to implement this + +#include +#include +#include +#include + +class NOVTABLE svc_metaData : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::METADATA; } + + int enumMetaData(int n, char *mdName, int mdNameMaxLength, int *mdType, BOOL *mdIndexed, BOOL *mdMaintainUniques); + int hasMetaData(const char *name, int type); + int allowOperation(GUID whom, const char *playstring, int op, char *field, void *data, int data_len); + GUID getGUID(); + const char *getMetaTableName(); + + enum { + HASMETADATA=10, + ENUMMETADATA=20, + ALLOWOPERATION=30, + GETGUID=40, + GETMETANAME=50, + }; + +}; + +inline int svc_metaData::hasMetaData(const char *name, int type) { + return _call(HASMETADATA, 0, name, type); +} + +inline int svc_metaData::enumMetaData(int n, char *mdName, int mdNameMaxLength, int *mdType, BOOL *mdIndexed, BOOL *mdMaintainUniques) { + return _call(ENUMMETADATA, 0, n, mdName, mdNameMaxLength, mdType, mdIndexed, mdMaintainUniques); +} + +inline int svc_metaData::allowOperation(GUID whom, const char *playstring, int op, char *field, void *data, int data_len) { + return _call(ALLOWOPERATION, 0, whom, playstring, op, field, data, data_len); +} + +inline GUID svc_metaData::getGUID() { + return _call(GETGUID, INVALID_GUID); +} + +inline const char *svc_metaData::getMetaTableName() { + return _call(GETMETANAME, (const char *)NULL); +} + +// see helper class in common/metadatasvc.h to implement this +class NOVTABLE svc_metaDataI : public svc_metaData { +public: + virtual int enumMetaData(int n, char *mdName, int mdNameMaxLength, int *mdType, BOOL *mdIndexed, BOOL *mdMaintainUniques)=0; + virtual int hasMetaData(const char *name, int type)=0; + virtual int allowOperation(GUID whom, const char *playstring, int op, char *field, void *data, int data_len)=0; + virtual GUID getGUID()=0; + virtual const char *getMetaTableName()=0; + +protected: + RECVS_DISPATCH; +}; + +#include + +// if you want to use class MetaDataSvc (instead of deriving from +// svc_metaDataI yourself) use class MetaDataSvcFactory in common/metadatasvc.h +template +class MetaDataSvcCreator : public waServiceFactoryTSingle {}; + +#include + +class MetaDataSvcEnum : public SvcEnumT { +public: + MetaDataSvcEnum(const char *metadata=NULL, int mdtype=MDT_NONE) : md(metadata), type(mdtype) {} +protected: + virtual int testService(svc_metaData *svc) { + if (md.isempty() || type == MDT_NONE) return TRUE; + return svc->hasMetaData(md, type); + } +private: + String md; + int type; +}; + +class MetaDataSvcEnumGuid : public SvcEnumT { +public: + MetaDataSvcEnumGuid(GUID g) : guid(g) {} +protected: + virtual int testService(svc_metaData *svc) { + return (svc->getGUID() == guid); + } +private: + GUID guid; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_minibrowser.cpp b/Src/Wasabi/api/service/svcs/svc_minibrowser.cpp new file mode 100644 index 00000000..65c3c0dd --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_minibrowser.cpp @@ -0,0 +1,12 @@ +#include +#include "svc_minibrowser.h" + +#define CBCLASS svc_miniBrowserI +START_DISPATCH; + CB(TESTGUID, testGuid); + CB(CREATEMINIBROWSER, createMiniBrowser); + VCB(DESTROYMINIBROWSER, destroyMiniBrowser); +END_DISPATCH; +#undef CBCLASS + + diff --git a/Src/Wasabi/api/service/svcs/svc_minibrowser.h b/Src/Wasabi/api/service/svcs/svc_minibrowser.h new file mode 100644 index 00000000..9772131b --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_minibrowser.h @@ -0,0 +1,69 @@ +#ifndef _SVC_MINIBROWSER_H +#define _SVC_MINIBROWSER_H + +#include +#include + +class MiniBrowser; + +#include + +// {2E41D2E8-19A5-4029-9339-8FDF7481000A} +static const GUID GUID_MINIBROWSER_ANY = +{ 0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }; + +// {C0A3D1AC-2430-45a7-B51B-AB04B74DD9EA} +static const GUID GUID_MINIBROWSER_IEACTIVEX = +{ 0xc0a3d1ac, 0x2430, 0x45a7, { 0xb5, 0x1b, 0xab, 0x4, 0xb7, 0x4d, 0xd9, 0xea } }; + +class NOVTABLE svc_miniBrowser : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::MINIBROWSER; } + + int testGuid(GUID g); + MiniBrowser *createMiniBrowser(); + void destroyMiniBrowser(MiniBrowser *b); + + enum { + TESTGUID =10, + CREATEMINIBROWSER =20, + DESTROYMINIBROWSER =30, + }; +}; + +inline int svc_miniBrowser::testGuid(GUID g) { + return _call(TESTGUID, 0, g); +} + +inline MiniBrowser *svc_miniBrowser::createMiniBrowser() { + return _call(CREATEMINIBROWSER, (MiniBrowser *)0); +} + +inline void svc_miniBrowser::destroyMiniBrowser(MiniBrowser *b) { + _voidcall(DESTROYMINIBROWSER, b); +} + +class NOVTABLE svc_miniBrowserI : public svc_miniBrowser { +public: + virtual int testGuid(GUID g)=0; + virtual MiniBrowser *createMiniBrowser()=0; + virtual void destroyMiniBrowser(MiniBrowser *b)=0; + +protected: + RECVS_DISPATCH; +}; + +#include + +class MiniBrowserSvcEnum : public SvcEnumT { +public: + MiniBrowserSvcEnum(GUID g) : guid(g) {} +protected: + virtual int testService(svc_miniBrowser *svc) { + return (svc->testGuid(guid)); + } +private: + GUID guid; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_objectdir.cpp b/Src/Wasabi/api/service/svcs/svc_objectdir.cpp new file mode 100644 index 00000000..e79e5a48 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_objectdir.cpp @@ -0,0 +1,32 @@ +#include + +#include "svc_objectdir.h" +#include + +#define CBCLASS svc_objectDirI +START_DISPATCH; + CB(GETDEPENDENCYPTR, getDependencyPtr); + CB(GETDIRTYPE, getDirType); + CB(GETNUMOBJECTS, getNumObjects); + CB(ENUMOBJECT, enumObject); + CB(GETOBJECT, getObject); + CB(GETOBJECTLABEL, getObjectLabel); + CB(SETOBJECTLABEL, setObjectLabel); + CB(INSERTOBJECT, insertObject); + CB(REMOVEOBJECT, removeObject); + VCB(CLEARALL, clearAll); + CB(ONACTION, onAction); + VCB(ONPRERENDER, onPrerender); + VCB(ONPOSTRENDER, onPostrender); + CB(GETOBJECTPATH, getObjectPath); + CB(GETOBJECTDISPLAYGROUP, getObjectDisplayGroup); + CB(GETOBJECTICON, getObjectIcon); + CB(GETOBJECTSELECTABLE, getObjectSelectable); + CB(GETOBJECTSORTORDER, getObjectSortOrder); + CB(TAGOBJECT, tagObject); + CB(UNTAGOBJECT, untagObject); + CB(ENUMOBJECTBYTAG, enumObjectByTag); + CB(ISTAGGED, isTagged); + CB(CONTEXTMENU, contextMenu); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_objectdir.h b/Src/Wasabi/api/service/svcs/svc_objectdir.h new file mode 100644 index 00000000..fdf5cd2f --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_objectdir.h @@ -0,0 +1,294 @@ +#ifndef _SVC_OBJECTDIR_H +#define _SVC_OBJECTDIR_H + +#include +#include +#include +#include + +// there is class ObjectDir in bfc/wnds, you should derive from it +// also class ContextCmdObjDir + +typedef size_t ObjectHandle; +#define INVALID_OBJECT_HANDLE ((ObjectHandle)0) + +#define DD_OBJECTDIR L"service:svc_objectDir" + +class ifc_window; +class ifc_dependent; +class BaseCanvas; + +class svc_objectDir : public Dispatchable +{ +public: + static int getServiceType() { return WaSvc::OBJECTDIR; } + static const wchar_t *dragitem_getDatatype() { return DD_OBJECTDIR; } + static const GUID *depend_getClassGuid() { + // {2364D110-0F12-40d4-BBAE-D2DA174751B5} + static const GUID ret = + { 0x2364d110, 0xf12, 0x40d4, { 0xbb, 0xae, 0xd2, 0xda, 0x17, 0x47, 0x51, 0xb5 } }; + return &ret; + } + + api_dependent *getDependencyPtr(); + + const wchar_t *getDirType(); + + int getNumObjects(); + ObjectHandle enumObject(int n); + + void *getObject(ObjectHandle handle); + + const wchar_t *getObjectLabel(ObjectHandle handle); + int setObjectLabel(ObjectHandle handle, const wchar_t *newlabel); + + ObjectHandle insertObject(const wchar_t *parameter=NULL, const wchar_t *label=NULL, const wchar_t *path=NULL); + int removeObject(ObjectHandle handle); + + void clearAll(); + + const wchar_t *getObjectPath(ObjectHandle handle); + const wchar_t *getObjectDisplayGroup(ObjectHandle handle); + const wchar_t *getObjectIcon(ObjectHandle handle); + int getObjectSelectable(ObjectHandle handle); + int getObjectSortOrder(ObjectHandle handle); // -32767..32767 + + // tagging + int tagObject(const wchar_t *tag, ObjectHandle handle, int exclusive=FALSE); + int untagObject(const wchar_t *tag, ObjectHandle handle); + ObjectHandle enumObjectByTag(const wchar_t *tag, int n); + int isTagged(const wchar_t *tag, ObjectHandle handle); + + int onAction(int action, ifc_window *from, const wchar_t *target, ObjectHandle handle); + enum { + ODACTION_SELECTED=100, + ODACTION_DESELECTED=200, + ODACTION_CONTEXTMENU=300, + }; + + int contextMenu(ifc_window *from, int x, int y, ObjectHandle handle); + + void onPrerender(ObjectHandle handle, const RECT *r, BaseCanvas *c, int style); + void onPostrender(ObjectHandle handle, const RECT *r, BaseCanvas *c, int style); + // render styles + enum { + RENDERSTYLE_TREEWND=10, + }; + + // dependency events, param is handle of object in question + enum { + Event_OBJECT_ADDED=100, + Event_OBJECT_REMOVED=110, + Event_OBJECT_LABELCHANGE=200, + Event_OBJECT_ICONCHANGE=300, + Event_OBJECT_PATHCHANGE=400, + Event_OBJECT_SELECTABLECHANGE=500, + Event_OBJECT_SORTORDERCHANGE=600, + Event_OBJECT_TAGCHANGE=700, + }; + + // dispatchable codes + enum { + GETDEPENDENCYPTR=100, + GETNUMOBJECTS=200, + ENUMOBJECT=300, + GETOBJECT=400, + GETOBJECTLABEL=500, + SETOBJECTLABEL=510, + INSERTOBJECT=600, + REMOVEOBJECT=610, + CLEARALL=700, + GETDIRTYPE=800, + ONACTION=900, + ONPRERENDER=1000, + ONPOSTRENDER=1010, + GETOBJECTPATH=1100, + GETOBJECTDISPLAYGROUP=1200, + GETOBJECTICON=1300, + GETOBJECTSELECTABLE=1400, + GETOBJECTSORTORDER=1500, + TAGOBJECT=1600, + UNTAGOBJECT=1700, + ENUMOBJECTBYTAG=1800, + ISTAGGED=1900, + CONTEXTMENU=3000, + }; +}; + +inline +api_dependent *svc_objectDir::getDependencyPtr() { + return _call(GETDEPENDENCYPTR, (api_dependent*)NULL); +} + +inline +const wchar_t *svc_objectDir::getDirType() { + return _call(GETDIRTYPE, (const wchar_t *)NULL); +} + +inline +int svc_objectDir::getNumObjects() { + return _call(GETNUMOBJECTS, 0); +} + +inline +ObjectHandle svc_objectDir::enumObject(int n) { + return _call(ENUMOBJECT, INVALID_OBJECT_HANDLE, n); +} + +inline +void *svc_objectDir::getObject(ObjectHandle handle) { + return _call(GETOBJECT, (void*)NULL, handle); +} + +inline +const wchar_t *svc_objectDir::getObjectLabel(ObjectHandle handle) { + return _call(GETOBJECTLABEL, (const wchar_t *)NULL, handle); +} + +inline +int svc_objectDir::setObjectLabel(ObjectHandle handle, const wchar_t *newlabel) { + return _call(SETOBJECTLABEL, 0, handle, newlabel); +} + +inline +ObjectHandle svc_objectDir::insertObject(const wchar_t *parameter, const wchar_t *label, const wchar_t *path) { + return _call(INSERTOBJECT, INVALID_OBJECT_HANDLE, parameter, label, path); +} + +inline +int svc_objectDir::removeObject(ObjectHandle handle) { + return _call(REMOVEOBJECT, 0, handle); +} + +inline +void svc_objectDir::clearAll() { + _voidcall(CLEARALL); +} + +inline +const wchar_t *svc_objectDir::getObjectPath(ObjectHandle handle) { + return _call(GETOBJECTPATH, (const wchar_t *)NULL, handle); +} + +inline +const wchar_t *svc_objectDir::getObjectDisplayGroup(ObjectHandle handle) { + return _call(GETOBJECTDISPLAYGROUP, L"", handle); +} + +inline +const wchar_t *svc_objectDir::getObjectIcon(ObjectHandle handle) { + return _call(GETOBJECTICON, (const wchar_t *)NULL, handle); +} + +inline +int svc_objectDir::getObjectSelectable(ObjectHandle handle) { + return _call(GETOBJECTSELECTABLE, TRUE, handle); +} + +inline +int svc_objectDir::getObjectSortOrder(ObjectHandle handle) { + return _call(GETOBJECTSORTORDER, 0, handle); +} + +inline +int svc_objectDir::tagObject(const wchar_t *tag, ObjectHandle handle, int exclusive) { + return _call(TAGOBJECT, 0, tag, handle, exclusive); +} +inline +int svc_objectDir::untagObject(const wchar_t *tag, ObjectHandle handle) { + return _call(UNTAGOBJECT, 0, tag, handle); +} +inline +ObjectHandle svc_objectDir::enumObjectByTag(const wchar_t *tag, int n) { + return _call(ENUMOBJECTBYTAG, INVALID_OBJECT_HANDLE, tag, n); +} +inline +int svc_objectDir::isTagged(const wchar_t *tag, ObjectHandle handle) { + return _call(ISTAGGED, 0, tag, handle); +} + +inline +int svc_objectDir::onAction(int action, ifc_window *from, const wchar_t *target, ObjectHandle handle) { + return _call(ONACTION, 0, action, from, target, handle); +} + +inline +int svc_objectDir::contextMenu(ifc_window *from, int x, int y, ObjectHandle handle) { + return _call(CONTEXTMENU, 0, from, x, y, handle); +} + +inline +void svc_objectDir::onPrerender(ObjectHandle handle, const RECT *r, BaseCanvas *c, int style) { + _voidcall(ONPRERENDER, handle, r, c, style); +} +inline +void svc_objectDir::onPostrender(ObjectHandle handle, const RECT *r, BaseCanvas *c, int style) { + _voidcall(ONPOSTRENDER, handle, r, c, style); +} + + +/** + Service implementation. Usually you'll derive from ObjectDir, not this. + You can still derive from this if you want to fully implement the interface yourself for some reason though. + @see ObjectDir +*/ +class svc_objectDirI : public svc_objectDir { +public: + virtual api_dependent *getDependencyPtr()=0; + + virtual const wchar_t *getDirType()=0; + + virtual int getNumObjects()=0; + virtual ObjectHandle enumObject(int n)=0; + + virtual void *getObject(ObjectHandle handle)=0; + + virtual const wchar_t *getObjectLabel(ObjectHandle handle)=0; + virtual int setObjectLabel(ObjectHandle handle, const wchar_t *newlabel)=0; + + virtual ObjectHandle insertObject(const wchar_t *parameter=NULL, const wchar_t *label=NULL, const wchar_t *path=NULL)=0; + virtual int removeObject(ObjectHandle handle)=0; + + virtual void clearAll()=0; + + virtual const wchar_t *getObjectPath(ObjectHandle handle)=0; + virtual const wchar_t *getObjectDisplayGroup(ObjectHandle handle)=0; + virtual const wchar_t *getObjectIcon(ObjectHandle handle)=0; + virtual int getObjectSelectable(ObjectHandle handle)=0; + virtual int getObjectSortOrder(ObjectHandle handle)=0; + + virtual int tagObject(const wchar_t *tag, ObjectHandle handle, int exclusive=FALSE)=0; + virtual int untagObject(const wchar_t *tag, ObjectHandle handle)=0; + virtual ObjectHandle enumObjectByTag(const wchar_t *tag, int n)=0; + virtual int isTagged(const wchar_t *tag, ObjectHandle handle)=0; + + virtual int onAction(int action, ifc_window *from, const wchar_t *target, ObjectHandle handle)=0; + + // return -1 to request renaming the item, 0 normally + virtual int contextMenu(ifc_window *from, int x, int y, ObjectHandle handle)=0; + + virtual void onPrerender(ObjectHandle handle, const RECT *r, BaseCanvas *c, int style) { } + virtual void onPostrender(ObjectHandle handle, const RECT *r, BaseCanvas *c, int style) { } + +protected: + RECVS_DISPATCH; +}; + +#include + +template +class ObjectDirCreator : public waServiceFactoryTSingle { }; + +#include + +class ObjectDirEnum : public SvcEnumT { +public: + ObjectDirEnum(const wchar_t *_name) : name(_name) {} + virtual int testService(svc_objectDir *svc) { + return !WCSICMP(svc->getDirType(), name); + } +private: + StringW name; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_player.h b/Src/Wasabi/api/service/svcs/svc_player.h new file mode 100644 index 00000000..cf6f136e --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_player.h @@ -0,0 +1,35 @@ +#ifndef _SVC_PLAYER_H +#define _SVC_PLAYER_H + +#include + +#include + +class api_window; + +class svc_player { +public: + static const char *getServiceName() { return "Standard player service"; } + static int getServiceType() { return WaSvc::UNIQUE; } + static GUID getServiceGuid() { + // {9DE79C4A-B9E6-46f4-9AE2-40E0F09CCA51} + const GUID guid = + { 0x9de79c4a, 0xb9e6, 0x46f4, { 0x9a, 0xe2, 0x40, 0xe0, 0xf0, 0x9c, 0xca, 0x51 } }; + return guid; + } + virtual void openFile(const char *filename, FOURCC droptarg=MK3CC('d','e','f'))=0; + virtual void openFiles(api_window *parent=NULL, const char *type=NULL, FOURCC droptarg=MK3CC('d','e','f'))=0; +}; + +class svc_playerI : public svc_player { +}; + +#include + +template +class PlayerCreator : public waServiceFactoryTSingle { +public: + PlayerCreator() : waServiceFactoryTSingle(svc_player::getServiceGuid()) {} +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_playlist.cpp b/Src/Wasabi/api/service/svcs/svc_playlist.cpp new file mode 100644 index 00000000..88b81c53 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_playlist.cpp @@ -0,0 +1,28 @@ +#include + +#include "svc_playlist.h" + +#define CBCLASS svc_playlistReaderI +START_DISPATCH; + CB(GETEXTENSION, getExtension); + CB(TESTFILENAME, testFilename); + CB(GETDESCRIPTION, getDescription); + CB(READPLAYLIST, readPlaylist); + CB(GETLABEL, getLabel); + CB(GETNUMENTRIES, getNumEntries); + CB(ENUMENTRY, enumEntry); + VCB(ENABLEDATABASEADD, enableDatabaseAdd); +END_DISPATCH; +#undef CBCLASS + +#define CBCLASS svc_playlistWriterI +START_DISPATCH; + CB(GETEXTENSION, getExtension); + CB(GETDESCRIPTION, getDescription); + CB(WRITEPLAYLIST, writePlaylist); + CB(BEGINWRITE, beginWrite); + VCB(WRITEENTRY, writeEntry); + VCB(ENDWRITE, endWrite); + VCB(ENABLEMETADATA, enableMetadata); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_playlist.h b/Src/Wasabi/api/service/svcs/svc_playlist.h new file mode 100644 index 00000000..928da339 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_playlist.h @@ -0,0 +1,216 @@ +#ifndef _SVC_PLAYLIST_H +#define _SVC_PLAYLIST_H + +#include +#include + +class Playlist; + +class NOVTABLE svc_playlistReader : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::PLAYLISTREADER; } + + const char *getExtension(); + int testFilename(const char *filename); + const char *getDescription(); + + void setAllowedMetadataColumns(const char *columnslist); // "a;b;c" ""=all + void setBannedMetadataColumns(const char *columnslist); // "a;b;c" ""==all + + void enableDatabaseAdd(int enabled); // defaults to TRUE +// void enableMetadata(int enabled); // defaults to TRUE + + int readPlaylist(const char *filename); + + const char *getLabel(); + int getNumEntries(); + const char *enumEntry(int n); + +protected: + enum { + GETEXTENSION=0, READPLAYLIST=1, GETLABEL=2, GETNUMENTRIES=3, ENUMENTRY=4, + TESTFILENAME=100, + GETDESCRIPTION=110, + ENABLEDATABASEADD=200, + }; +}; + +inline +const char *svc_playlistReader::getExtension() { + return _call(GETEXTENSION, ""); +} + +inline +int svc_playlistReader::testFilename(const char *filename) { + return _call(TESTFILENAME, -1, filename); +} + +inline +const char *svc_playlistReader::getDescription() { + return _call(GETDESCRIPTION, (const char *)NULL); +} + +inline +void svc_playlistReader::enableDatabaseAdd(int enabled) { + _voidcall(ENABLEDATABASEADD, enabled); +} + +inline +int svc_playlistReader::readPlaylist(const char *filename) { + return _call(READPLAYLIST, 0, filename); +} + +inline +const char *svc_playlistReader::getLabel() { + return _call(GETLABEL, (const char *)0); +} + +inline +int svc_playlistReader::getNumEntries() { + return _call(GETNUMENTRIES, 0); +} + +inline +const char *svc_playlistReader::enumEntry(int n) { + return _call(ENUMENTRY, (const char *)NULL, n); +} + +class NOVTABLE svc_playlistReaderI : public svc_playlistReader { +public: + virtual const char *getExtension()=0; + virtual int testFilename(const char *filename) { return -1; } + virtual const char *getDescription() { return NULL; } + + virtual void enableDatabaseAdd(int enabled)=0; + + virtual int readPlaylist(const char *filename)=0; + + virtual const char *getLabel()=0; + virtual int getNumEntries()=0; + virtual const char *enumEntry(int n)=0; + +private: + RECVS_DISPATCH; +}; + +class NOVTABLE svc_playlistWriter : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::PLAYLISTWRITER; } + + const char *getExtension(); + const char *getDescription(); + + void enableMetadata(int enabled); + + int writePlaylist(const char *filename, Playlist *pl, int full_data, int first, int last); + +// old-style, DEPRECATED + int beginWrite(const char *filename, int n, const char *label); + void writeEntry(const char *playstring); + void endWrite(); + +protected: + enum { + GETEXTENSION=0, + GETDESCRIPTION=1, + BEGINWRITE=2, + WRITEENTRY=3, + ENDWRITE=4, + WRITEPLAYLIST=100, + ENABLEMETADATA=200, + }; +}; + +inline +const char *svc_playlistWriter::getExtension() { + return _call(GETEXTENSION, (const char *)0); +} + +inline +const char *svc_playlistWriter::getDescription() { + return _call(GETDESCRIPTION, (const char *)0); +} + +inline +void svc_playlistWriter::enableMetadata(int enabled) { + _voidcall(ENABLEMETADATA, enabled); +} + +inline +int svc_playlistWriter::writePlaylist(const char *filename, Playlist *pl, int full_data, int first, int last) { + return _call(WRITEPLAYLIST, -1, filename, pl, full_data, first, last); +} + +inline +int svc_playlistWriter::beginWrite(const char *filename, int n, const char *label) { + return _call(BEGINWRITE, 0, filename, n, label); +} + +inline +void svc_playlistWriter::writeEntry(const char *playstring) { + _voidcall(WRITEENTRY, playstring); +} + +inline +void svc_playlistWriter::endWrite() { + _voidcall(ENDWRITE); +} + +class NOVTABLE svc_playlistWriterI : public svc_playlistWriter { +public: + virtual const char *getExtension()=0; + virtual const char *getDescription() { return NULL; } + + virtual void enableMetadata(int enabled) { } + + virtual int writePlaylist(const char *filename, Playlist *pl, int full_data, int first, int last) { return -1; } + +// old-style, DEPRECATED + virtual int beginWrite(const char *filename, int n, const char *label) { return 0; } + virtual void writeEntry(const char *playstring) { } + virtual void endWrite() { } + +protected: + RECVS_DISPATCH; +}; + +#include + +template +class PlaylistReaderCreator : public waServiceFactoryT {}; + +template +class PlaylistWriterCreator : public waServiceFactoryT {}; + +#include +#include + +class PlaylistReaderEnum : public SvcEnumT { +public: + PlaylistReaderEnum(const char *filename) : fn(filename) {} + +protected: + virtual int testService(svc_playlistReader *svc) { + int r = svc->testFilename(fn); + if (r == -1) return STRCASEEQL(svc->getExtension(), Std::extension(fn)); + return r; + } + +private: + String fn; +}; + +class PlaylistWriterEnum : public SvcEnumT { +public: + PlaylistWriterEnum(const char *filename) : + ext(Std::extension(filename)) {} +protected: + virtual int testService(svc_playlistWriter *svc) { + return STRCASEEQL(svc->getExtension(), ext); + } + +private: + String ext; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_redir.cpp b/Src/Wasabi/api/service/svcs/svc_redir.cpp new file mode 100644 index 00000000..ab7d42f6 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_redir.cpp @@ -0,0 +1,10 @@ +#include + +#include "svc_redir.h" + +#define CBCLASS svc_redirectI +START_DISPATCH; + CB(ISMINE, isMine); + CB(REDIRECT, redirect); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_redir.h b/Src/Wasabi/api/service/svcs/svc_redir.h new file mode 100644 index 00000000..9ab82b8a --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_redir.h @@ -0,0 +1,63 @@ +#ifndef _SVC_REDIR_H +#define _SVC_REDIR_H + +#include +#include + +/* Domains: + "Filename" + "Url" +*/ + +// if you want to redirect a string easily, look at RedirString in +// bfc/util/redirstr.h + +class svc_redirect : public Dispatchable +{ +public: + static FOURCC getServiceType() { return WaSvc::REDIRECT; } + + int isMine(const wchar_t *str, const wchar_t *domain); + int redirect(const wchar_t *orig_str, const wchar_t *domain, wchar_t *buf, int buflen); + +protected: + enum { + ISMINE=100, + REDIRECT=200, + }; +}; + +inline int svc_redirect::isMine(const wchar_t *str, const wchar_t *domain) { + return _call(ISMINE, 0, str, domain); +} + +inline int svc_redirect::redirect(const wchar_t *orig_str, const wchar_t *domain, wchar_t *buf, int buflen) { + return _call(REDIRECT, 0, orig_str, domain, buf, buflen); +} + +class svc_redirectI : public svc_redirect { +public: + virtual int isMine(const wchar_t *str, const wchar_t *domain)=0; + virtual int redirect(const wchar_t *orig_str, const wchar_t *domain, wchar_t *buf, int buflen)=0; + +protected: + RECVS_DISPATCH; +}; + +#include + +class RedirectEnum : public SvcEnumT { +public: + RedirectEnum(const wchar_t *filename, const wchar_t *domain=L"Filename") : + fn(filename), dom(domain) { + } + + virtual int testService(svc_redirect *svc) { + if (svc->isMine(fn, dom)) return 1; + return 0; + } + +private: + const wchar_t *fn, *dom; +}; +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_scriptobj.cpp b/Src/Wasabi/api/service/svcs/svc_scriptobj.cpp new file mode 100644 index 00000000..4d154c85 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_scriptobj.cpp @@ -0,0 +1,10 @@ +#include + +#include "svc_scriptobji.h" + +#define CBCLASS svc_scriptObjectI +START_DISPATCH; + CB(GETCONTROLLER, getController); + VCB(ONREGISTER, onRegisterClasses); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_scriptobj.h b/Src/Wasabi/api/service/svcs/svc_scriptobj.h new file mode 100644 index 00000000..8cdae362 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_scriptobj.h @@ -0,0 +1,29 @@ +#ifndef _SVC_SCRIPTOBJECT_H +#define _SVC_SCRIPTOBJECT_H + +#include +#include + +class ScriptObjectController; + +class svc_scriptObject : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::SCRIPTOBJECT; } + ScriptObjectController *getController(int n); + void onRegisterClasses(ScriptObjectController *rootController); + + enum { + GETCONTROLLER=10, + ONREGISTER=20, + }; +}; + +inline ScriptObjectController *svc_scriptObject::getController(int n) { + return _call(GETCONTROLLER, (ScriptObjectController *)0, n); +} + +inline void svc_scriptObject::onRegisterClasses(ScriptObjectController *rootController) { + _voidcall(ONREGISTER, rootController); +} + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_scriptobji.h b/Src/Wasabi/api/service/svcs/svc_scriptobji.h new file mode 100644 index 00000000..59014cf0 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_scriptobji.h @@ -0,0 +1,51 @@ +#pragma once +#include "svc_scriptobji.h" +// derive from this one +class svc_scriptObjectI : public svc_scriptObject { +public: + virtual ScriptObjectController *getController(int n)=0; + virtual void onRegisterClasses(ScriptObjectController *rootController) {}; + +protected: + RECVS_DISPATCH; +}; + +template +class ScriptObjectControllerCreator : public svc_scriptObjectI { +public: + static const char *getServiceName() { return "ScriptObjectControllerCreator"; } + + ScriptObjectControllerCreator() + { + } + + virtual ~ScriptObjectControllerCreator() + { + } + + virtual ScriptObjectController *getController(int n) + { + if (n == 0) return &single_controller; + return NULL; + } + +private: + T single_controller; +}; + +#include +template +class ScriptObjectCreator : public waServiceFactoryTSingle {}; + +#include + +class ExternalScriptObjectEnum : public SvcEnumT { +public: + ExternalScriptObjectEnum() { } + +protected: + virtual int testService(svc_scriptObject*svc) { + return (svc->getController(0) != NULL); + } +}; + diff --git a/Src/Wasabi/api/service/svcs/svc_skinfilter.cpp b/Src/Wasabi/api/service/svcs/svc_skinfilter.cpp new file mode 100644 index 00000000..34d2adf4 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_skinfilter.cpp @@ -0,0 +1,10 @@ +#include + +#include "svc_skinfilter.h" + +#define CBCLASS svc_skinFilterI +START_DISPATCH; + CB(FILTERBITMAP, filterBitmap); + CB(FILTERCOLOR, filterColor); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_skinfilter.h b/Src/Wasabi/api/service/svcs/svc_skinfilter.h new file mode 100644 index 00000000..ef3fae71 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_skinfilter.h @@ -0,0 +1,56 @@ +#ifndef _SVC_SKINFILTER_H +#define _SVC_SKINFILTER_H + +#include +#include + +// TODO: make some sort of ifc_bitmap so we can do OS-level manipulations if necessary + +class NOVTABLE svc_skinFilter : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::SKINFILTER; } + int filterBitmap(uint8_t *bits, int w, int h, int bpp, const wchar_t *element_id, const wchar_t *forcegroup=NULL); + ARGB32 filterColor(ARGB32 color, const wchar_t *element_id, const wchar_t *forcegroup=NULL); + + enum { + FILTERBITMAP=100, + FILTERCOLOR=200, + }; +}; + +inline int svc_skinFilter::filterBitmap(uint8_t *bits, int w, int h, int bpp, const wchar_t *element_id, const wchar_t *forcegroup) { + return _call(FILTERBITMAP, 0, bits, w, h, bpp, element_id, forcegroup); +} + +inline ARGB32 svc_skinFilter::filterColor(ARGB32 color, const wchar_t *element_id, const wchar_t *forcegroup) { + return _call(FILTERCOLOR, (ARGB32)0, color, element_id, forcegroup); +} + +// derive from this one +class NOVTABLE svc_skinFilterI : public svc_skinFilter +{ +public: + virtual int filterBitmap(uint8_t *bits, int w, int h, int bpp, const wchar_t *element_id, const wchar_t *forcegroup=NULL)=0; + virtual ARGB32 filterColor(ARGB32 color, const wchar_t *element_id, const wchar_t *forcegroup=NULL) + { + // easy cheesy helper + filterBitmap((uint8_t *)&color, 1, 1, 32, element_id, forcegroup); + return color; + } + +protected: + RECVS_DISPATCH; +}; + +#include + +class SkinFilterEnum : public SvcEnumT { +public: + SkinFilterEnum() {} +protected: + virtual int testService(svc_skinFilter* svc) { + return TRUE; + } +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_storagevolenum.cpp b/Src/Wasabi/api/service/svcs/svc_storagevolenum.cpp new file mode 100644 index 00000000..8e26b793 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_storagevolenum.cpp @@ -0,0 +1,30 @@ +#include +#include "svc_storagevolenum.h" + +//----------------------------------------------------------------- + +#define CBCLASS StorageVolumeI +START_DISPATCH; + CB(GETVOLUMENAME, getVolumeName); + CB(GETMOUNTPATH, getMountPath); + CB(GETLABEL, getLabel); + CB(GETTYPE, getType); + CB(ISREMOVABLE, isRemovable); + CB(ISWRITABLE, isWritable); + CB(GETFREESPACE, getFreeSpace); + CB(GETSIZE, getSize); +END_DISPATCH; +#undef CBCLASS + +//----------------------------------------------------------------- + +#define CBCLASS svc_storageVolumeEnumI +START_DISPATCH; + CB(GETNUMVOLUMES, getNumVolumes); + CB(ENUMVOLUME, enumVolume); +END_DISPATCH; +#undef CBCLASS + +//----------------------------------------------------------------- + + diff --git a/Src/Wasabi/api/service/svcs/svc_storagevolenum.h b/Src/Wasabi/api/service/svcs/svc_storagevolenum.h new file mode 100644 index 00000000..15d60ed7 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_storagevolenum.h @@ -0,0 +1,96 @@ +#ifndef __SVC_STORAGEVOLENUM_H +#define __SVC_STORAGEVOLENUM_H + +#include +#include + +enum StorageVolumeTypes { + NOT_VALID = 0, //Not a valid Volume. + UNKNOWN = 1, //Unknown Drive Type. + LOCAL = 1<<1, //Local (Fixed) Hard Drive. + REMOVABLE = 1<<2, //Removable Drive (Floppy, LS-120, Zip, USB FlashCard Reader, etc.) + NETWORK = 1<<3, //Network Drive (SMB, NFS, etc.) + CDROM = 1<<4, //CD / DVD ROM, WRITER, Re-WRITER, etc. + RAMDISK = 1<<5, //RAM Drive. +}; + +//----------------------------------------------------------------- + +class NOVTABLE StorageVolume : public Dispatchable { +public: + const char *getVolumeName() { return _call(GETVOLUMENAME, (const char *) NULL); } + const char *getMountPath() { return _call(GETMOUNTPATH, (const char *) NULL); } + const char *getLabel() { return _call(GETLABEL, (const char *) NULL); } + + int getType() { return _call(GETTYPE, 0); } + + int isRemovable() { return _call(ISREMOVABLE, -1); } + int isWritable() { return _call(ISWRITABLE, -1); } + + __int64 getFreeSpace() { return _call(GETFREESPACE, -1); } + __int64 getSize() { return _call(GETSIZE, -1); } + + enum { + GETVOLUMENAME = 10, + GETMOUNTPATH = 20, + GETLABEL = 30, + GETTYPE = 40, + ISREMOVABLE = 50, + ISWRITABLE = 60, + GETFREESPACE = 70, + GETSIZE = 80 + }; +}; + +//----------------------------------------------------------------- + +class StorageVolumeI : public StorageVolume { +public: + virtual const char *getVolumeName()=0; + virtual const char *getMountPath()=0; + virtual const char *getLabel()=0; + + virtual int getType()=0; + + virtual int isRemovable()=0; + virtual int isWritable()=0; + + virtual __int64 getFreeSpace()=0; + virtual __int64 getSize()=0; + +protected: + RECVS_DISPATCH; + +}; + +//----------------------------------------------------------------- + +class NOVTABLE svc_storageVolumeEnum : public Dispatchable +{ +public: + static FOURCC getServiceType() { return WaSvc::STORAGEVOLENUM; } + + int getNumVolumes() { return _call(GETNUMVOLUMES, (int) 0); } + StorageVolume *enumVolume(int which) { return _call(ENUMVOLUME, (StorageVolume *)NULL); } + + enum { + GETNUMVOLUMES = 10, + ENUMVOLUME = 20, + }; + +}; + +//----------------------------------------------------------------- + +class svc_storageVolumeEnumI : public svc_storageVolumeEnum { +public: + virtual int getNumVolumes()=0; //Get the number of Storage Volumes. + //Enum a Storage Volume. + virtual StorageVolume *enumVolume(int which)=0; + +protected: + RECVS_DISPATCH; + +}; + +#endif //__SVC_STORAGEVOLENUM_H \ No newline at end of file diff --git a/Src/Wasabi/api/service/svcs/svc_stringconverter.cpp b/Src/Wasabi/api/service/svcs/svc_stringconverter.cpp new file mode 100644 index 00000000..cf1c1222 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_stringconverter.cpp @@ -0,0 +1,12 @@ +#include +#include "svc_stringconverter.h" + +#define CBCLASS svc_stringConverterI +START_DISPATCH + CB(CANCONVERT, canConvert); + CB(CONVERTTOUTF8, convertToUTF8); + CB(PREFLIGHTTOUTF8, preflightToUTF8); + CB(CONVERTFROMUTF8, convertFromUTF8); + CB(PREFLIGHTFROMUTF8, preflightFromUTF8); +END_DISPATCH +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_stringconverter.h b/Src/Wasabi/api/service/svcs/svc_stringconverter.h new file mode 100644 index 00000000..c03baac0 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_stringconverter.h @@ -0,0 +1,94 @@ +#ifndef _SVC_STRINGCONVERTER_H +#define _SVC_STRINGCONVERTER_H + +#include +#include +#include + +// Porting Rule: A new service to respond to at least OSNATIVE and UTF16 shall be +// provided for every new platform. This service should provide transcoding +// to and from the platform's native internationalized string encoding format +// (ie: MBCS under Win9x, WorldScript on the Mac, etc etc etc).and to and from +// UTF16. If the OSNATIVE string _IS_ UTF16, just respond that you can convert +// both. + +class NOVTABLE svc_stringConverter : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::STRINGCONVERTER; } + + // test the type. + int canConvert(FOURCC encoding_type); + + // The return code is the number of bytes written to the output buffer, or the error. + // A return code of 0 is not an error, other than you passing NULL or a size 0 buffer won't do much interesting. + int convertToUTF8(FOURCC encoding_type, const void *in_buffer, int size_in_bytes, char *out_buffer, int size_out_bytes); + int preflightToUTF8(FOURCC encoding_type, const void *in_buffer, int size_in_bytes); + int convertFromUTF8(FOURCC encoding_type, const char *in_buffer, int size_in_bytes, void *out_buffer, int size_out_bytes); + int preflightFromUTF8(FOURCC encoding_type, const char *in_buffer, int size_in_bytes); + +protected: + enum { + CANCONVERT, + CONVERTTOUTF8, + PREFLIGHTTOUTF8, + CONVERTFROMUTF8, + PREFLIGHTFROMUTF8 + }; +}; + + +inline +int svc_stringConverter::canConvert(FOURCC encoding_type) { + return _call(CANCONVERT, (int)0, encoding_type); +} + +inline +int svc_stringConverter::convertToUTF8(FOURCC encoding_type, const void *in_buffer, int size_in_bytes, char *out_buffer, int size_out_bytes) { + return _call(CONVERTTOUTF8, (int)0, encoding_type, in_buffer, size_in_bytes, out_buffer, size_out_bytes); +} + +inline +int svc_stringConverter::preflightToUTF8(FOURCC encoding_type, const void *in_buffer, int size_in_bytes) { + return _call(PREFLIGHTTOUTF8, (int)0, encoding_type, in_buffer, size_in_bytes); +} + +inline +int svc_stringConverter::convertFromUTF8(FOURCC encoding_type, const char *in_buffer, int size_in_bytes, void *out_buffer, int size_out_bytes) { + return _call(CONVERTFROMUTF8, (int)0, encoding_type, in_buffer, size_in_bytes, out_buffer, size_out_bytes); +} + +inline +int svc_stringConverter::preflightFromUTF8(FOURCC encoding_type, const char *in_buffer, int size_in_bytes) { + return _call(PREFLIGHTFROMUTF8, (int)0, encoding_type, in_buffer, size_in_bytes); +} + +// implementor derives from this one +class NOVTABLE svc_stringConverterI : public svc_stringConverter { +public: + + // test the type + virtual int canConvert(FOURCC encoding_type) = 0; + + virtual int convertToUTF8(FOURCC encoding_type, const void *in_buffer, int size_in_bytes, char *out_buffer, int size_out_bytes) = 0; + virtual int preflightToUTF8(FOURCC encoding_type, const void *in_buffer, int size_in_bytes) = 0; + virtual int convertFromUTF8(FOURCC encoding_type, const char *in_buffer, int size_in_bytes, void *out_buffer, int size_out_bytes) = 0; + virtual int preflightFromUTF8(FOURCC encoding_type, const char *in_buffer, int size_in_bytes) = 0; + +protected: + RECVS_DISPATCH; +}; + +#include + +class StringConverterEnum : public SvcEnumT { +public: + StringConverterEnum(FOURCC enc_type) : encoding_type(enc_type) {} +protected: + virtual int testService(svc_stringConverter *svc) { + return (svc->canConvert(encoding_type)); + } +private: + FOURCC encoding_type; +}; + +#endif // _SVC_STRINGCONVERTER_H diff --git a/Src/Wasabi/api/service/svcs/svc_stringtypes.h b/Src/Wasabi/api/service/svcs/svc_stringtypes.h new file mode 100644 index 00000000..bff5cf9f --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_stringtypes.h @@ -0,0 +1,35 @@ +#ifndef _SVC_STRINGTYPES_H +#define _SVC_STRINGTYPES_H + +// Here, you look like you're in need of some error codes. +namespace SvcStrCnv { + typedef enum { + // The conversion failed for some generic 'fatal' reason, not covered by the + // other reasons below. (Possibly a bug in the service implementation). + ERROR_FATAL = -1, + + // The conversion failed because your output buffer was too small. + ERROR_BUFFER_OVERRUN = -2, + + // The conversion failed because your input string had unrecoverable errors in it + ERROR_INPUT = -3, + + // The service instance does not support that type of encoding for conversion + ERROR_INVALID = -4, + + // The service instance isn't available (ONLY generated by EncodedStr.cpp, obviously) + ERROR_UNAVAILABLE = -5, + + } ConvertErrors; + + // These types MUST be supported by the platform port for this service. + typedef enum { + OSNATIVE=MK4CC('n','a','t','v'), + UTF16=MK4CC('u','-','1','6'), + } EncodingTypes; + // Other service instances may implement other encoding types. + // They all should provide their own FOURCC #define or enum in their headers. +} + + +#endif // _SVC_STRINGTYPES_H diff --git a/Src/Wasabi/api/service/svcs/svc_textfeed.cpp b/Src/Wasabi/api/service/svcs/svc_textfeed.cpp new file mode 100644 index 00000000..7ede4ce4 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_textfeed.cpp @@ -0,0 +1,18 @@ +#include + +#include "svc_textfeed.h" +#include + +#define CBCLASS svc_textFeedI +START_DISPATCH; + CB(SVCTEXTFEED_HASFEED, hasFeed); + CB(SVCTEXTFEED_GETFEEDTEXT, getFeedText); + CB(SVCTEXTFEED_GETFEEDDESC, getFeedDescription); + CB(SVCTEXTFEED_GETDEPENDENCYPTR, getDependencyPtr); +END_DISPATCH; +#undef CBCLASS + +void *svc_textFeedI::dependent_getInterface(const GUID *classguid) { + HANDLEGETINTERFACE(svc_textFeed); + return NULL; +} diff --git a/Src/Wasabi/api/service/svcs/svc_textfeed.h b/Src/Wasabi/api/service/svcs/svc_textfeed.h new file mode 100644 index 00000000..c37754f7 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_textfeed.h @@ -0,0 +1,21 @@ +#ifndef _SVC_TEXTFEED_H +#define _SVC_TEXTFEED_H + +//#include +#include + +class NOVTABLE svc_textFeedI : public svc_textFeed +{ +public: + virtual int hasFeed(const wchar_t *name) = 0; + virtual const wchar_t *getFeedText(const wchar_t *name) = 0; + virtual const wchar_t *getFeedDescription(const wchar_t *name) = 0; + virtual api_dependent *getDependencyPtr() = 0; + virtual void *dependent_getInterface(const GUID *classguid); //implemented for you + +protected: + RECVS_DISPATCH; +}; + + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_tooltips.cpp b/Src/Wasabi/api/service/svcs/svc_tooltips.cpp new file mode 100644 index 00000000..f42f7fed --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_tooltips.cpp @@ -0,0 +1,10 @@ +#include +#include "svc_tooltips.h" + +#define CBCLASS svc_toolTipsRendererI +START_DISPATCH; + CB(SPAWNTOOLTIP, spawnTooltip); +END_DISPATCH; +#undef CBCLASS + + diff --git a/Src/Wasabi/api/service/svcs/svc_tooltips.h b/Src/Wasabi/api/service/svcs/svc_tooltips.h new file mode 100644 index 00000000..c3591146 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_tooltips.h @@ -0,0 +1,30 @@ +#ifndef _SVC_TOOLTIPS_H +#define _SVC_TOOLTIPS_H + +#include +#include + +class NOVTABLE svc_toolTipsRenderer : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::TOOLTIPSRENDERER; } + + int spawnTooltip(const wchar_t *text); + + enum { + SPAWNTOOLTIP =10, + }; +}; + +inline int svc_toolTipsRenderer::spawnTooltip(const wchar_t *text) { + return _call(SPAWNTOOLTIP, 0, text); +} + +class NOVTABLE svc_toolTipsRendererI : public svc_toolTipsRenderer { +public: + virtual int spawnTooltip(const wchar_t *text)=0; + +protected: + RECVS_DISPATCH; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_wndcreate.cpp b/Src/Wasabi/api/service/svcs/svc_wndcreate.cpp new file mode 100644 index 00000000..168e7a2f --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_wndcreate.cpp @@ -0,0 +1,16 @@ +#include + +#include "svc_wndcreate.h" + +#define CBCLASS svc_windowCreateI +START_DISPATCH; + CB(TESTGUID, testGuid); + CB(CREATEWINDOWBYGUID, createWindowByGuid); + CB(TESTTYPE, testType); + CB(CREATEWINDOWOFTYPE, createWindowOfType); + CB(DESTROYWINDOW, destroyWindow); + CB(REFCOUNT, refcount); +END_DISPATCH; +#undef CBCLASS + + diff --git a/Src/Wasabi/api/service/svcs/svc_wndcreate.h b/Src/Wasabi/api/service/svcs/svc_wndcreate.h new file mode 100644 index 00000000..95e46f89 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_wndcreate.h @@ -0,0 +1,120 @@ +#ifndef _SVC_WNDCREATE_H +#define _SVC_WNDCREATE_H + +#include +#include + +#define BUCKETITEM L"buck" +#define PLAYLISTSIDECAR L"plsc" + +class ifc_window; + +class NOVTABLE svc_windowCreate : public Dispatchable +{ +public: + static FOURCC getServiceType() { return WaSvc::WINDOWCREATE; } + + int testGuid(GUID g); + ifc_window *createWindowByGuid(GUID g, ifc_window *parent); + int testType(const wchar_t *windowtype); + ifc_window *createWindowOfType(const wchar_t *windowtype, ifc_window *parent, int n = 0); + int destroyWindow(ifc_window *w); + + int refcount(); // how many windows created + + enum { + TESTGUID = 100, + CREATEWINDOWBYGUID = 200, + TESTTYPE = 301, + CREATEWINDOWOFTYPE = 402, + DESTROYWINDOW = 500, + REFCOUNT = 600, + }; +}; + +inline int svc_windowCreate::testGuid(GUID g) +{ + return _call(TESTGUID, 0, g); +} + +inline ifc_window *svc_windowCreate::createWindowByGuid(GUID g, ifc_window *parent) +{ + return _call(CREATEWINDOWBYGUID, (ifc_window*)0, g, parent); +} + +inline int svc_windowCreate::destroyWindow(ifc_window *w) +{ + return _call(DESTROYWINDOW, 0, w); +} + +inline int svc_windowCreate::testType(const wchar_t *windowtype) +{ + return _call(TESTTYPE, 0, windowtype); +} + +inline ifc_window *svc_windowCreate::createWindowOfType(const wchar_t * windowtype, ifc_window *parent, int n) +{ + return _call(CREATEWINDOWOFTYPE, (ifc_window*)0, windowtype, parent, n); +} + +inline int svc_windowCreate::refcount() +{ + return _call(REFCOUNT, -1); +} + +class NOVTABLE svc_windowCreateI : public svc_windowCreate +{ +public: + virtual ~svc_windowCreateI() { } + virtual int testGuid(GUID g) { return 0; } + virtual ifc_window *createWindowByGuid(GUID g, ifc_window *parent) { return NULL; } + virtual int testType(const wchar_t *windowtype) { return 0; } + virtual ifc_window *createWindowOfType(const wchar_t *windowtype, ifc_window *parent, int n) { return NULL; } + virtual int destroyWindow(ifc_window *w) = 0; + + virtual int refcount() { return -1; } // FUCKO: make pure abstract + +protected: + RECVS_DISPATCH; +}; + +#include +template +class WndCreateCreator : public waServiceFactoryT {}; + +template +class WndCreateCreatorSingle : public waServiceFactoryTSingle {}; + +#include +#include + +class WindowCreateByGuidEnum : public SvcEnumT +{ +public: + WindowCreateByGuidEnum(GUID _g) : targetguid(_g) { } + +protected: + virtual int testService(svc_windowCreate *svc) + { + return svc->testGuid(targetguid); + } + +private: + GUID targetguid; +}; + +class WindowCreateByTypeEnum : public SvcEnumT +{ +public: + WindowCreateByTypeEnum(const wchar_t *_wtype) : wtype(_wtype) { } + +protected: + virtual int testService(svc_windowCreate *svc) + { + return svc->testType(wtype); + } + +private: + StringW wtype; +}; +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_xmlprov.cpp b/Src/Wasabi/api/service/svcs/svc_xmlprov.cpp new file mode 100644 index 00000000..b84826eb --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_xmlprov.cpp @@ -0,0 +1,10 @@ +#include + +#include "svc_xmlprov.h" + +#define CBCLASS svc_xmlProviderI +START_DISPATCH; + CB(TESTDESC, testDesc); + CB(GETXMLDATA, getXmlData); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_xmlprov.h b/Src/Wasabi/api/service/svcs/svc_xmlprov.h new file mode 100644 index 00000000..d6c27f01 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_xmlprov.h @@ -0,0 +1,56 @@ +#ifndef _SVC_XMLPROVIDER_H +#define _SVC_XMLPROVIDER_H + +#include +#include + +class skin_xmlreaderparams; + +class NOVTABLE svc_xmlProvider : public Dispatchable { +public: + static FOURCC getServiceType() { return WaSvc::XMLPROVIDER; } + + int testDesc(const wchar_t *desc); + const wchar_t *getXmlData(const wchar_t *desc, const wchar_t *incpath, skin_xmlreaderparams *params=NULL); + + enum { + TESTDESC=10, + GETXMLDATA=20, + }; +}; + +inline int svc_xmlProvider::testDesc(const wchar_t *desc) { + return _call(TESTDESC, 0, desc); +} + +inline const wchar_t *svc_xmlProvider::getXmlData(const wchar_t *desc, const wchar_t *incpath, skin_xmlreaderparams *params) { + return _call(GETXMLDATA, (const wchar_t *)0, desc, incpath, params); +} + +// derive from this one +class NOVTABLE svc_xmlProviderI : public svc_xmlProvider { +public: + virtual int testDesc(const wchar_t *desc)=0; + virtual const wchar_t *getXmlData(const wchar_t *desc, const wchar_t *incpath, skin_xmlreaderparams *params=NULL)=0; + +protected: + RECVS_DISPATCH; +}; + +#include +#include + +class XmlProviderEnum : public SvcEnumT { +public: + XmlProviderEnum(const wchar_t *_desc) : desc(_desc) { } + +protected: + virtual int testService(svc_xmlProvider *svc) { + return svc->testDesc(desc); + } + +private: + StringW desc; +}; + +#endif diff --git a/Src/Wasabi/api/service/svcs/svc_xuiobject.cpp b/Src/Wasabi/api/service/svcs/svc_xuiobject.cpp new file mode 100644 index 00000000..52973975 --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_xuiobject.cpp @@ -0,0 +1,12 @@ +#include + +#include "svc_xuiobject.h" + +#define CBCLASS svc_xuiObjectI +START_DISPATCH; + CB(XUI_TESTTAG, testTag); +// CB(XUI_INSTANTIATE, instantiate); + CB(XUI_INSTANTIATEWITHPARAMS, instantiate); + VCB(XUI_DESTROY, destroy); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/svcs/svc_xuiobject.h b/Src/Wasabi/api/service/svcs/svc_xuiobject.h new file mode 100644 index 00000000..de825b5b --- /dev/null +++ b/Src/Wasabi/api/service/svcs/svc_xuiobject.h @@ -0,0 +1,76 @@ +#ifndef _SVC_XUIOBJECT_H +#define _SVC_XUIOBJECT_H + +#include +#include +#include +#include +class GuiObject; +class skin_xmlreaderparams; + +class NOVTABLE svc_xuiObject : public Dispatchable +{ +public: + static FOURCC getServiceType() + { + return WaSvc::XUIOBJECT; + } + int testTag( const wchar_t *xmltag ); + GuiObject *instantiate( const wchar_t *xmltag, ifc_xmlreaderparams *params = NULL ); + void destroy( GuiObject *g ); + + enum + { + XUI_TESTTAG = 10, + //XUI_INSTANTIATE=20, // RETIRED + XUI_INSTANTIATEWITHPARAMS = 25, + XUI_DESTROY = 30, + }; +}; + +inline int svc_xuiObject::testTag(const wchar_t *xmltag) { + return _call(XUI_TESTTAG, 0, xmltag); +} + +inline GuiObject *svc_xuiObject::instantiate(const wchar_t *xmltag, ifc_xmlreaderparams *params) { + return _call(XUI_INSTANTIATEWITHPARAMS, (GuiObject *)NULL, xmltag, params); +} + +inline void svc_xuiObject::destroy(GuiObject *o) { + _voidcall(XUI_DESTROY, o); +} + +// derive from this one +class svc_xuiObjectI : public svc_xuiObject +{ +public: + virtual int testTag(const wchar_t *xmltag)=0; + virtual GuiObject *instantiate(const wchar_t *xmltag, ifc_xmlreaderparams *params=NULL)=0; + virtual void destroy(GuiObject *o)=0; + +protected: + RECVS_DISPATCH; +}; + +#include +template +class XuiObjectCreator : public waServiceFactoryTSingle { +public: + virtual const wchar_t *svc_getTestString() { return T::xuisvc_getXmlTag(); } +}; + +#include +#include + +class XuiObjectSvcEnum : public SvcEnumT { +public: + XuiObjectSvcEnum(const wchar_t *xmltag) : tag(xmltag) {} +protected: + virtual int testService(svc_xuiObject *svc) { + return (svc->testTag(tag)); + } +private: + StringW tag; +}; + +#endif diff --git a/Src/Wasabi/api/service/waservicefactory.cpp b/Src/Wasabi/api/service/waservicefactory.cpp new file mode 100644 index 00000000..7ed88b65 --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactory.cpp @@ -0,0 +1,12 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Wed May 07 00:57:16 2003] +// +// File : waservicefactory.cpp +// Class : waServiceFactory +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#include +#include "waservicefactory.h" + + diff --git a/Src/Wasabi/api/service/waservicefactory.h b/Src/Wasabi/api/service/waservicefactory.h new file mode 100644 index 00000000..88a72104 --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactory.h @@ -0,0 +1,109 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Wed May 07 00:57:16 2003] +// +// File : waservicefactory.h +// Class : waServiceFactory +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#ifndef __WASERVICEFACTORY_H +#define __WASERVICEFACTORY_H + +#include +#include +#include "api_service.h" +// ---------------------------------------------------------------------------- + +class NOVTABLE waServiceFactory : public Dispatchable +{ +protected: + waServiceFactory() throw( ) {} + ~waServiceFactory() {} + +public: + FOURCC getServiceType(); + const char *getServiceName(); + GUID getGuid(); + const wchar_t *getTestString(); + + void *getInterface( int global_lock = TRUE ); + int releaseInterface( void *ifc ); + + int supportNonLockingGetInterface(); + int serviceNotify( int msg, intptr_t param1 = 0, intptr_t param2 = 0 ); + +protected: + enum + { + WASERVICEFACTORY_GETSERVICETYPE = 100, + WASERVICEFACTORY_GETSERVICENAME = 200, + WASERVICEFACTORY_GETGUID = 210, + WASERVICEFACTORY_GETINTERFACE = 300, + WASERVICEFACTORY_SUPPORTNONLOCKINGGETINTERFACE = 301, + WASERVICEFACTORY_RELEASEINTERFACE = 310, + WASERVICEFACTORY_GETTESTSTRING = 500, + WASERVICEFACTORY_SERVICENOTIFY = 600, + }; +}; + +// ---------------------------------------------------------------------------- + +inline FOURCC waServiceFactory::getServiceType() +{ + FOURCC __retval = _call( WASERVICEFACTORY_GETSERVICETYPE, (FOURCC)NULL ); + return __retval; +} + +inline const char *waServiceFactory::getServiceName() +{ + const char *__retval = _call( WASERVICEFACTORY_GETSERVICENAME, (const char *)0 ); + return __retval; +} + +inline GUID waServiceFactory::getGuid() +{ + GUID __retval = _call( WASERVICEFACTORY_GETGUID, INVALID_GUID ); + return __retval; +} + +inline const wchar_t *waServiceFactory::getTestString() +{ + return _call( WASERVICEFACTORY_GETTESTSTRING, (const wchar_t *)0 ); +} + + +inline void *waServiceFactory::getInterface( int global_lock ) +{ + void *__retval = _call( WASERVICEFACTORY_GETINTERFACE, (void *)NULL, global_lock ); + +#if 0 // unused in Winamp 5 + // -- generated code - edit in waservicefactoryi.h + // support old code that always locks even when global_lock==FALSE + if ( !global_lock && __retval != NULL && !supportNonLockingGetInterface() ) + WASABI_API_SVC->service_unlock( __retval ); +#endif + return __retval; +} + +inline int waServiceFactory::releaseInterface( void *ifc ) +{ + int __retval = _call( WASERVICEFACTORY_RELEASEINTERFACE, (int)0, ifc ); + return __retval; +} + + +inline int waServiceFactory::supportNonLockingGetInterface() +{ + int __retval = _call( WASERVICEFACTORY_SUPPORTNONLOCKINGGETINTERFACE, (int)0 ); + return __retval; +} + +inline int waServiceFactory::serviceNotify( int msg, intptr_t param1, intptr_t param2 ) +{ + int __retval = _call( WASERVICEFACTORY_SERVICENOTIFY, (int)0, msg, param1, param2 ); + return __retval; +} + +// ---------------------------------------------------------------------------- + +#endif // __WASERVICEFACTORY_H diff --git a/Src/Wasabi/api/service/waservicefactorybase.cpp b/Src/Wasabi/api/service/waservicefactorybase.cpp new file mode 100644 index 00000000..793842b3 --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactorybase.cpp @@ -0,0 +1,5 @@ +#include +//" +#include "waservicefactorybase.h" +//?> + diff --git a/Src/Wasabi/api/service/waservicefactorybase.h b/Src/Wasabi/api/service/waservicefactorybase.h new file mode 100644 index 00000000..19c9c56d --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactorybase.h @@ -0,0 +1,76 @@ +#ifndef __WASERVICEFACTORYBASE_IMPL_H +#define __WASERVICEFACTORYBASE_IMPL_H + +/**/ +class CfgItem; +/*?>*/ + +#include "waservicefactoryi.h" + +template +class NOVTABLE waServiceFactoryBaseX : public waServiceFactoryI { +public: + waServiceFactoryBaseX(GUID myGuid = INVALID_GUID) : guid(myGuid) {} + virtual FOURCC svc_serviceType()=0; + virtual const char *svc_getServiceName() { return SERVICE::getServiceName(); } + virtual GUID svc_getGuid() { return guid; } + virtual void *svc_getInterfaceAndLock() {// this is only for back compat + return getInterface(TRUE); + } + + virtual void *svc_getInterface(int global_lock)=0; + virtual int svc_releaseInterface(void *ptr)=0; + + virtual CfgItem *svc_getCfgInterface() { return NULL; } + virtual const wchar_t *svc_getTestString() { return NULL; } + + virtual int svc_notify(int msg, int param1 = 0, int param2 = 0) { return 0; } + +private: + GUID guid; +}; + +// if you derive from this, all you have to do is override the newService() +// and delService() methods... if all you need to do is instantiate a class +// and destroy it use the helper below (waServiceFactoryT) +template +class NOVTABLE waServiceFactoryBase : public waServiceFactoryBaseX { +public: + waServiceFactoryBase(GUID myGuid = INVALID_GUID) : waServiceFactoryBaseX(myGuid) {} + virtual FOURCC svc_serviceType() { return SERVICETYPE::getServiceType(); } + virtual void *svc_getInterface(int global_lock) { // new style, client optionally does the locking + SERVICETYPE *ret = newService(); + if (global_lock) WASABI_API_SVC->service_lock(this, ret); + return ret; + } + virtual int svc_releaseInterface(void *ptr) { + return delService(static_cast(static_cast(ptr))); + } +protected: + virtual SERVICETYPE *newService()=0; + virtual int delService(SERVICETYPE *service)=0; +}; + +// and this one just exposes a service pointer, without factory. note that +// SERVICETYPE and SERVICE do not have to be related (unlike waServiceFactoryBase +// who needs a relationship between the classes in releaseInterface) +template +class NOVTABLE waServiceBase : public waServiceFactoryBaseX { +public: + waServiceBase(GUID myGuid = INVALID_GUID) : waServiceFactoryBaseX(myGuid) {} + virtual FOURCC svc_serviceType() { return SERVICE::getServiceType(); } + virtual void *svc_getInterface(int global_lock) { // new style, client optionally does the locking + SERVICETYPE *ret = getService(); + if (global_lock) WASABI_API_SVC->service_lock(this, ret); + return ret; + } + virtual int svc_releaseInterface(void *ptr) { + return TRUE; + } +protected: + virtual SERVICETYPE *getService()=0; +}; + + + +#endif // __WASERVICEFACTORYBASE_IMPL_H diff --git a/Src/Wasabi/api/service/waservicefactoryi.cpp b/Src/Wasabi/api/service/waservicefactoryi.cpp new file mode 100644 index 00000000..18ad97dd --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactoryi.cpp @@ -0,0 +1,2 @@ +#include +#include diff --git a/Src/Wasabi/api/service/waservicefactoryi.h b/Src/Wasabi/api/service/waservicefactoryi.h new file mode 100644 index 00000000..28d0b846 --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactoryi.h @@ -0,0 +1,73 @@ +#ifndef __WASERVICEFACTORY_IMPL_H +#define __WASERVICEFACTORY_IMPL_H + +/**/ +#include "waservicefactory.h" +#include "waservicefactoryx.h" + +class CfgItem; +/*?>*/ +/*[interface.header.h] +#include "common/nsguid.h" +#include "studio/api.h" +*/ + +// this is a wasabi service factory. it's a static object you can query to +// fetch the * to your real service interface +class NOVTABLE waServiceFactoryI : public waServiceFactoryX { +public: + virtual ~waServiceFactoryI() {} +protected: +/*[interface.x_getServiceType.h] + public: +*/ + DISPATCH(100) virtual FOURCC x_getServiceType() { return svc_serviceType(); } // see services.h + DISPATCH(200) virtual const char *x_getServiceName() { return svc_getServiceName(); } + DISPATCH(210) virtual GUID getGuid() { return svc_getGuid(); } // GUID per service factory, can be INVALID_GUID +/** + Fetches a pointer to an instance of the service. Optionally locks it into the + global table, so that it can be safely released via service_release() + @see ComponentAPI::service_release() + @param global_lock If TRUE, calls service_lock() with the service * + @see releaseInterface() +*/ +/*[dispatchable.getInterface.postcall] + // -- generated code - edit in waservicefactoryi.h + // support old code that always locks even when global_lock==FALSE + if (!global_lock && __retval != NULL && !supportNonLockingGetInterface()) + WASABI_API_SVC->service_unlock(__retval); +*/ + DISPATCH(300) virtual void *getInterface(int global_lock = TRUE) { return svc_getInterface(global_lock); } + DISPATCH(300) virtual void *_RETIRED_getInterface() { return getInterface(); } // for back compat + DISPATCH(301) virtual int supportNonLockingGetInterface() { return svc_supportNonLockingGetInterface(); } + +/** + Releases a pointer to an instance of the service. Call this when you're done + with a service interface. Do NOT just call delete on it! Only the original + service factory can safely delete it. Also, do not pass in any pointers + that were not allocated from this factory. + @see getInterface() + @ret TRUE if no error, FALSE if error. +*/ + DISPATCH(310) virtual int releaseInterface(void *ifc) { return svc_releaseInterface(ifc); } // when they're done w/ it + +/** + Fetches a string for optional quick lookup of a service factory. This string + is defined on a service family type basis. e.g. the xuitag for xuicreators. +*/ + DISPATCH(500) virtual const wchar_t *getTestString() { return svc_getTestString(); } + DISPATCH(600) virtual int serviceNotify(int msg, int param1 = 0, int param2 = 0) { return svc_notify(msg, param1, param2); } +public: + + NODISPATCH virtual FOURCC svc_serviceType()=0; // see services.h + NODISPATCH virtual const char *svc_getServiceName()=0; + NODISPATCH virtual GUID svc_getGuid()=0; // GUID per service factory, can be INVALID_GUID + NODISPATCH virtual void *svc_getInterface(int global_lock = TRUE)=0; + NODISPATCH virtual int svc_supportNonLockingGetInterface() { return TRUE; } + NODISPATCH virtual int svc_releaseInterface(void *ifc)=0; // when they're done w/ it + NODISPATCH virtual CfgItem *svc_getCfgInterface()=0; + NODISPATCH virtual const wchar_t *svc_getTestString()=0; + NODISPATCH virtual int svc_notify(int msg, int param1 = 0, int param2 = 0)=0; +}; + +#endif // __WASERVICEFACTORY_IMPL_H diff --git a/Src/Wasabi/api/service/waservicefactoryt.cpp b/Src/Wasabi/api/service/waservicefactoryt.cpp new file mode 100644 index 00000000..fdab05e0 --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactoryt.cpp @@ -0,0 +1,5 @@ +#include +//" +#include "waservicefactoryt.h" +//?> + diff --git a/Src/Wasabi/api/service/waservicefactoryt.h b/Src/Wasabi/api/service/waservicefactoryt.h new file mode 100644 index 00000000..f2cc6e67 --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactoryt.h @@ -0,0 +1,28 @@ +#ifndef __WASERVICEFACTORYT_IMPL_H +#define __WASERVICEFACTORYT_IMPL_H + +/**/ +/*?>*/ + +#include "waservicefactorybase.h" + +// this is a service factory template that will manufacture any number +// of a given class SERVICE, which is derived from service class SERVICETYPE +template +class waServiceFactoryT : public waServiceFactoryBase { +public: + waServiceFactoryT(GUID myGuid = INVALID_GUID) : + waServiceFactoryBase(myGuid) {} + virtual SERVICETYPE *newService() { + SERVICE *ret = new SERVICE; + ASSERT(ret != NULL); + return ret; + } + virtual int delService(SERVICETYPE *service) { + ASSERT(service != NULL); + delete static_cast(service); + return 1; + } +}; + +#endif // __WASERVICEFACTORYT_IMPL_H diff --git a/Src/Wasabi/api/service/waservicefactorytsingle.cpp b/Src/Wasabi/api/service/waservicefactorytsingle.cpp new file mode 100644 index 00000000..358de389 --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactorytsingle.cpp @@ -0,0 +1,5 @@ +#include +//" +#include "waservicefactorytsingle.h" +//?> + diff --git a/Src/Wasabi/api/service/waservicefactorytsingle.h b/Src/Wasabi/api/service/waservicefactorytsingle.h new file mode 100644 index 00000000..3a3a8d2f --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactorytsingle.h @@ -0,0 +1,47 @@ +#ifndef __WASERVICEFACTORYTSINGLE_IMPL_H +#define __WASERVICEFACTORYTSINGLE_IMPL_H + +/**/ +/*?>*/ + +#include "waservicefactorybase.h" + +#include + +// this is a service factory template that holds one copy of a class +// and reissues the pointer as needed, with reference counting +template +class waServiceFactoryTSingle : public waServiceFactoryBase { +public: + waServiceFactoryTSingle(GUID myGuid = INVALID_GUID) : + refcount(0), waServiceFactoryBase(myGuid) { + singleService = new SERVICE; + } + waServiceFactoryTSingle(SERVICE *svc, GUID myGuid = INVALID_GUID) : + singleService(svc), refcount(0), + waServiceFactoryBase(myGuid) { } + ~waServiceFactoryTSingle() { + delete singleService; + } + virtual SERVICETYPE *newService() { + ASSERT(singleService != NULL); + refcount++; + return singleService; + } + virtual int delService(SERVICETYPE *service) { + ASSERT(static_cast(service) == singleService); + refcount--; + ASSERT(refcount >= 0); + return 1; + } + + SERVICE *getSingleService() { return singleService; } + +private: + SERVICE * singleService; + int refcount; +}; + + + +#endif // __WASERVICEFACTORYTSINGLE_IMPL_H diff --git a/Src/Wasabi/api/service/waservicefactoryx.cpp b/Src/Wasabi/api/service/waservicefactoryx.cpp new file mode 100644 index 00000000..5853b833 --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactoryx.cpp @@ -0,0 +1,32 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Wed May 07 00:57:16 2003] +// +// File : waservicefactoryx.cpp +// Class : waServiceFactory +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- +#include + +#include "waservicefactoryx.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif + +#define CBCLASS waServiceFactoryX +START_DISPATCH; + CB(WASERVICEFACTORY_GETSERVICETYPE, x_getServiceType); + CB(WASERVICEFACTORY_GETSERVICENAME, x_getServiceName); + CB(WASERVICEFACTORY_GETGUID, getGuid); + case WASERVICEFACTORY_GETINTERFACE: + switch (nparam) { + default: cb(&CBCLASS::getInterface, retval, params); break; + case 0: cb(&CBCLASS::_RETIRED_getInterface, retval, params); break; + } + break; + CB(WASERVICEFACTORY_SUPPORTNONLOCKINGGETINTERFACE, supportNonLockingGetInterface); + CB(WASERVICEFACTORY_RELEASEINTERFACE, releaseInterface); + CB(WASERVICEFACTORY_GETTESTSTRING, getTestString); + CB(WASERVICEFACTORY_SERVICENOTIFY, serviceNotify); +END_DISPATCH; +#undef CBCLASS diff --git a/Src/Wasabi/api/service/waservicefactoryx.h b/Src/Wasabi/api/service/waservicefactoryx.h new file mode 100644 index 00000000..dd00a241 --- /dev/null +++ b/Src/Wasabi/api/service/waservicefactoryx.h @@ -0,0 +1,37 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Wed May 07 00:57:16 2003] +// +// File : waservicefactoryx.h +// Class : waServiceFactory +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- + +#ifndef __WASERVICEFACTORYX_H +#define __WASERVICEFACTORYX_H + +#include "waservicefactory.h" + +// ---------------------------------------------------------------------------- + +class NOVTABLE waServiceFactoryX : public waServiceFactory { + protected: + waServiceFactoryX() {} + protected: + + public: + + virtual FOURCC x_getServiceType()=0; + virtual const char *x_getServiceName()=0; + virtual GUID getGuid()=0; + virtual void *getInterface(int global_lock = TRUE)=0; + virtual void *_RETIRED_getInterface()=0; + virtual int supportNonLockingGetInterface()=0; + virtual int releaseInterface(void *ifc)=0; + virtual const wchar_t *getTestString()=0; + virtual int serviceNotify(int msg, int param1 = 0, int param2 = 0)=0; + + protected: + RECVS_DISPATCH; +}; + +#endif // __WASERVICEFACTORYX_H diff --git a/Src/Wasabi/api/skin/SkinElementAlias.cpp b/Src/Wasabi/api/skin/SkinElementAlias.cpp new file mode 100644 index 00000000..6c66d842 --- /dev/null +++ b/Src/Wasabi/api/skin/SkinElementAlias.cpp @@ -0,0 +1,8 @@ +#include +#include "SkinElementAlias.h" +#include + +SkinItem *SkinElementAlias::getAncestor() +{ + return paletteManager.getAliasAncestor(this); +} diff --git a/Src/Wasabi/api/skin/SkinElementAlias.h b/Src/Wasabi/api/skin/SkinElementAlias.h new file mode 100644 index 00000000..1957825c --- /dev/null +++ b/Src/Wasabi/api/skin/SkinElementAlias.h @@ -0,0 +1,65 @@ +#pragma once +#include +#include +struct SkinElementAlias : public SkinItemI +{ +public: + + SkinElementAlias(const wchar_t *_aliasname, const wchar_t *_idtarget, int _scriptid = -1, int _secondarycounter = 0) + : aliasname(_aliasname), idtarget(_idtarget), scriptid(_scriptid), seccount(_secondarycounter) //, rootpath(path) + { + params = NULL; + /* + if (p != NULL) { + params = new XmlReaderParamsI(); + for (int i=0;igetNbItems();i++) { + params->addItem(p->getItemName(i), p->getItemValue(i)); + } + } + */ + } + virtual ~SkinElementAlias() + { + delete params; + } + + const wchar_t *getAliasName() { return aliasname; } + const wchar_t *getTargetId() { return idtarget; } + int getSecCount() { return seccount; } + + virtual const wchar_t *getXmlRootPath() { return rootpath; } + virtual const wchar_t *getName() { return L"elementalias"; } + virtual ifc_xmlreaderparams *getParams() { return params; } + virtual int getSkinPartId() { return scriptid; } + virtual SkinItem *getAncestor(); + +private: + StringW aliasname; + StringW idtarget; + int scriptid; + int seccount; + XmlReaderParamsI *params; + StringW rootpath; +}; + +class SortSkinElementAlias +{ +public: + static int compareItem(SkinElementAlias *p1, SkinElementAlias *p2) + { + int r = WCSICMP(p1->getAliasName(), p2->getAliasName()); + if (!r) + { + if (p1->getSkinPartId() < p2->getSkinPartId()) return -1; + if (p1->getSkinPartId() > p2->getSkinPartId()) return 1; + if (p1->getSecCount() < p2->getSecCount()) return -1; + if (p1->getSecCount() > p2->getSecCount()) return 1; + return 0; + } + return r; + } + static int compareAttrib(const wchar_t *attrib, SkinElementAlias *item) + { + return WCSICMP(attrib, item->getAliasName()); + } +}; \ No newline at end of file diff --git a/Src/Wasabi/api/skin/SkinVersion.cpp b/Src/Wasabi/api/skin/SkinVersion.cpp new file mode 100644 index 00000000..ae112c49 --- /dev/null +++ b/Src/Wasabi/api/skin/SkinVersion.cpp @@ -0,0 +1,42 @@ +#include +#include "SkinVersion.h" +#include "../xml/obj_xml.h" +#include +#include + +void LoadXmlFile(obj_xml *parser, const wchar_t *filename); + +SkinVersionXmlReader::SkinVersionXmlReader(const wchar_t *skinname) +{ + waServiceFactory *parserFactory = WASABI_API_SVC->service_getServiceByGuid(obj_xmlGUID); + if (parserFactory) + { + obj_xml *parser = (obj_xml *)parserFactory->getInterface(); + + if (parser) + { + parser->xmlreader_registerCallback(L"WinampAbstractionLayer", this); + parser->xmlreader_registerCallback(L"WasabiXML", this); + parser->xmlreader_open(); + + StringPathCombine fn(WASABI_API_SKIN->getSkinPath(), L"skin.xml"); + LoadXmlFile(parser, fn); + parser->xmlreader_unregisterCallback(this); + + parser->xmlreader_close(); + parserFactory->releaseInterface(parser); + parser = 0; + } + } +} + +void SkinVersionXmlReader::xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params) +{ + const wchar_t *version = params->getItemValue(L"version"); + if (version) + walversion = version; +} +const wchar_t *SkinVersionXmlReader::getWalVersion() +{ + return walversion; +} diff --git a/Src/Wasabi/api/skin/SkinVersion.h b/Src/Wasabi/api/skin/SkinVersion.h new file mode 100644 index 00000000..baaf46a1 --- /dev/null +++ b/Src/Wasabi/api/skin/SkinVersion.h @@ -0,0 +1,18 @@ +#ifndef NULLSOFT_WASABI_SKINVERSION_H +#define NULLSOFT_WASABI_SKINVERSION_H + +#include "../xml/ifc_xmlreadercallbacki.h" +#include + +class ifc_xmlreaderparams; +class SkinVersionXmlReader : public ifc_xmlreadercallbackI +{ +public: + SkinVersionXmlReader(const wchar_t *skinname); + void xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params); + const wchar_t *getWalVersion(); +private: + StringW walversion; +}; + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/skin/api_colorthemes.cpp b/Src/Wasabi/api/skin/api_colorthemes.cpp new file mode 100644 index 00000000..f346774b --- /dev/null +++ b/Src/Wasabi/api/skin/api_colorthemes.cpp @@ -0,0 +1,3 @@ +#include "api_colorthemes.h" + +/* benski> this file left intentionally blank */ \ No newline at end of file diff --git a/Src/Wasabi/api/skin/api_colorthemes.h b/Src/Wasabi/api/skin/api_colorthemes.h new file mode 100644 index 00000000..b61c2eb2 --- /dev/null +++ b/Src/Wasabi/api/skin/api_colorthemes.h @@ -0,0 +1,161 @@ +#pragma once +#include +#include + +class api_colorthemes : public Dispatchable +{ +protected: + api_colorthemes(){} + ~api_colorthemes(){} +public: + /* Gamma Sets */ + size_t getNumGammaSets(); + const wchar_t *enumGammaSet(size_t n); + void deleteGammaSet(const wchar_t *set); + void deleteAllGammaSets(); + void resetGammaSet(const wchar_t *set); + void renameGammaSet(const wchar_t *set, const wchar_t *newname); + size_t newGammaSet(const wchar_t *set); // returns index of your new gamma group + void updateGammaSet(const wchar_t *set); + + /* Gamma Groups */ + int getNumGammaGroups(const wchar_t *gammaset); + const wchar_t *enumGammaGroup(const wchar_t *gammaset, int n); + ColorThemeGroup *enumColorThemeGroup(int colorset, int colorgroup); + ColorThemeGroup *getColorThemeGroup(const wchar_t *colorset, const wchar_t *colorgroup); + int getGammaForGroup(const wchar_t *group, int *r, int *g, int *b, int *gray, int *boost); + void addGammaGroup(const wchar_t *set, ColorThemeGroup *group); + void addGammaGroup(size_t gammaSetIndex, ColorThemeGroup *group); + + /* Active Gamma Set */ + const wchar_t *getGammaSet(); + void setGammaSet(const wchar_t *set); + + /* Call these if you are loading a whole bunch of color themes at once */ + void StartTransaction(); + void EndTransaction(); + + enum + { + API_COLORTHEMES_GETNUMGAMMASETS = 0, + API_COLORTHEMES_ENUMGAMMASET = 1, + API_COLORTHEMES_DELETEGAMMASET = 2, + API_COLORTHEMES_DELETEALLGAMMASETS = 3, + API_COLORTHEMES_RESETGAMMASET = 4, + API_COLORTHEMES_RENAMEGAMMASET = 5, + API_COLORTHEMES_NEWGAMMASET = 6, + API_COLORTHEMES_UPDATEGAMMASET = 7, + API_COLORTHEMES_GETNUMGAMMAGROUPS = 8, + API_COLORTHEMES_ENUMGAMMAGROUP = 9, + API_COLORTHEMES_ENUMCOLORTHEMEGROUP = 10, + API_COLORTHEMES_GETCOLORTHEMEGROUP = 11, + API_COLORTHEMES_GETGAMMAFORGROUP = 12, + API_COLORTHEMES_ADDGAMMAGROUP = 13, + API_COLORTHEMES_ADDGAMMAGROUP2 = 14, + API_COLORTHEMES_GETGAMMASET = 15, + API_COLORTHEMES_SETGAMMASET = 16, + API_COLORTHEMES_STARTTRANSACTION = 17, + API_COLORTHEMES_ENDTRANSACTION = 18, + }; +}; + +inline size_t api_colorthemes::getNumGammaSets() +{ + return _call(API_COLORTHEMES_GETNUMGAMMASETS, (size_t)0); +} + +inline const wchar_t *api_colorthemes::enumGammaSet(size_t n) +{ + return _call(API_COLORTHEMES_ENUMGAMMASET, (const wchar_t *)0, n); +} + +inline void api_colorthemes::deleteGammaSet(const wchar_t *set) +{ + _voidcall(API_COLORTHEMES_DELETEGAMMASET, set); +} + +inline void api_colorthemes::deleteAllGammaSets() +{ + _voidcall(API_COLORTHEMES_DELETEALLGAMMASETS); +} + +inline void api_colorthemes::resetGammaSet(const wchar_t *set) +{ + _voidcall(API_COLORTHEMES_RESETGAMMASET, set); +} + +inline void api_colorthemes::renameGammaSet(const wchar_t *set, const wchar_t *newname) +{ + _voidcall(API_COLORTHEMES_RENAMEGAMMASET, set, newname); +} + +inline size_t api_colorthemes::newGammaSet(const wchar_t *set) +{ + return _call(API_COLORTHEMES_NEWGAMMASET, (size_t)-1, set); +} + +inline void api_colorthemes::updateGammaSet(const wchar_t *set) +{ + _voidcall(API_COLORTHEMES_UPDATEGAMMASET, set); +} + +inline int api_colorthemes::getNumGammaGroups(const wchar_t *gammaset) +{ + return _call(API_COLORTHEMES_GETNUMGAMMAGROUPS, (int)0, gammaset); +} + +inline const wchar_t *api_colorthemes::enumGammaGroup(const wchar_t *gammaset, int n) +{ + return _call(API_COLORTHEMES_ENUMGAMMAGROUP, (const wchar_t *)0, gammaset, n); +} + +inline ColorThemeGroup *api_colorthemes::enumColorThemeGroup(int colorset, int colorgroup) +{ + return _call(API_COLORTHEMES_ENUMCOLORTHEMEGROUP, (ColorThemeGroup *)0, colorset, colorgroup); +} + +inline ColorThemeGroup *api_colorthemes::getColorThemeGroup(const wchar_t *colorset, const wchar_t *colorgroup) +{ + return _call(API_COLORTHEMES_GETCOLORTHEMEGROUP, (ColorThemeGroup *)0, colorset, colorgroup); +} + +inline int api_colorthemes::getGammaForGroup(const wchar_t *group, int *r, int *g, int *b, int *gray, int *boost) +{ + return _call(API_COLORTHEMES_GETGAMMAFORGROUP, (int)0, group, r, g, b, gray, boost); +} + +inline void api_colorthemes::addGammaGroup(const wchar_t *set, ColorThemeGroup *group) +{ + _voidcall(API_COLORTHEMES_ADDGAMMAGROUP, set, group); +} + +inline void api_colorthemes::addGammaGroup(size_t gammaSetIndex, ColorThemeGroup *group) +{ + _voidcall(API_COLORTHEMES_ADDGAMMAGROUP2, gammaSetIndex, group); +} + +inline const wchar_t *api_colorthemes::getGammaSet() +{ + return _call(API_COLORTHEMES_GETGAMMASET, (const wchar_t *)0); +} + +inline void api_colorthemes::setGammaSet(const wchar_t *set) +{ + _voidcall(API_COLORTHEMES_SETGAMMASET, set); +} + +inline void api_colorthemes::StartTransaction() +{ + _voidcall(API_COLORTHEMES_STARTTRANSACTION); +} + +inline void api_colorthemes::EndTransaction() +{ + _voidcall(API_COLORTHEMES_ENDTRANSACTION); +} + +// {A3AAB98E-1634-4763-81A7-8D397F9E3154} +static const GUID ColorThemesAPIGUID= +{ 0xa3aab98e, 0x1634, 0x4763, { 0x81, 0xa7, 0x8d, 0x39, 0x7f, 0x9e, 0x31, 0x54 } }; + +extern api_colorthemes *colorThemesApi; diff --git a/Src/Wasabi/api/skin/api_palette.cpp b/Src/Wasabi/api/skin/api_palette.cpp new file mode 100644 index 00000000..e02f8d42 --- /dev/null +++ b/Src/Wasabi/api/skin/api_palette.cpp @@ -0,0 +1 @@ +#include "api_palette.h" diff --git a/Src/Wasabi/api/skin/api_palette.h b/Src/Wasabi/api/skin/api_palette.h new file mode 100644 index 00000000..6f5361cc --- /dev/null +++ b/Src/Wasabi/api/skin/api_palette.h @@ -0,0 +1,273 @@ +#pragma once +#include +#include +#include +#include + +class api_palette : public Dispatchable +{ +protected: + api_palette() {} + ~api_palette() {} +public: + void StartTransaction(); // if you add a bunch of stuff at once, it's faster to call this at the beginning + void EndTransaction(); // and this at the end. + + void Reset(); // clear everything + + const int *getSkinPartIteratorPtr(); // call this to get a pointer that's faster to check than calling getSkinPartIterator via Dispatchable + int newSkinPart(); // call this before adding your elements, let's you easily remove just your stuff via UnloadElements + int getSkinPartIterator(); // if this value changes, then something in the skin palette has changed + + void UnloadElements(int skinpart); // unload just your skin elements (get a skinpart value via newSkinPart) + + /* Aliases */ + void AddAlias(const wchar_t *id, const wchar_t *target); + const wchar_t *getElementAlias(const wchar_t *alias); + SkinItem *getAliasAncestor(SkinItem *item); + + /* Colors */ + void AddColor(const wchar_t *id, ARGB32 value, const wchar_t *colorgrp = NULL, const wchar_t *path = NULL, ifc_xmlreaderparams *p = NULL); + int getNumColorElements(); + const wchar_t *enumColorElement(int n); + ARGB32 *getColorElementRef(const wchar_t *type, const wchar_t **grp = NULL); + SkinItem *getColorAncestor(SkinItem *item); + ARGB32 getColorElement(const wchar_t *type, const wchar_t **grp = NULL); + + /* Cursors */ + void AddCursor(const wchar_t *id, const wchar_t *bitmapid, int x, int y, const wchar_t *path = NULL, ifc_xmlreaderparams *params = NULL); + int getCursorElement(const wchar_t *id); + OSCURSOR getCursor(const wchar_t *id); + SkinItem *getCursorAncestor(SkinItem *item); + const wchar_t *getSkinCursorBitmapId(const wchar_t *cursor); + + /* Bitmaps */ + void AddBitmap(const wchar_t *id, const wchar_t *filename, const wchar_t *path, int x, int y, int w, int h, ifc_xmlreaderparams *params = NULL, const wchar_t *colorgroup = NULL); + int getBitmapElement(const wchar_t *type); + SkinItem *getBitmapAncestor(SkinItem *item); + int getNumBitmapElement(); + const wchar_t *getSkinBitmapFilename(const wchar_t *id, int *x, int *y, int *w, int *h, const wchar_t **rootpath, ifc_xmlreaderparams **params); + const wchar_t *getGammaGroupFromId(const wchar_t *id); + int getLayerFromId(const wchar_t *id); + + /* Region Server (part of Bitmaps) */ + RegionServer *requestSkinRegion(const wchar_t *id); + void cacheSkinRegion(const wchar_t *id, api_region *r); + + enum + { + API_PALETTE_STARTTRANSACTION=0, + API_PALETTE_ENDTRANSACTION=1, + API_PALETTE_RESET=2, + API_PALETTE_GETSKINPARTITERATORPTR=3, + API_PALETTE_NEWSKINPART=4, + API_PALETTE_GETSKINPARTITERATOR=5, + API_PALETTE_UNLOADELEMENTS=6, + API_PALETTE_ADDALIAS=7, + API_PALETTE_GETELEMENTALIAS=8, + API_PALETTE_GETALIASANCESTOR=9, + API_PALETTE_ADDCOLOR=10, + API_PALETTE_GETNUMCOLORELEMENTS=11, + API_PALETTE_ENUMCOLORELEMENT=12, + API_PALETTE_GETCOLORELEMENTREF=13, + API_PALETTE_GETCOLORANCESTOR=14, + API_PALETTE_GETCOLORELEMENT=15, + API_PALETTE_ADDCURSOR=16, + API_PALETTE_GETCURSORELEMENT=17, + API_PALETTE_GETCURSOR=18, + API_PALETTE_GETCURSORANCESTOR=19, + API_PALETTE_GETSKINCURSORBITMAPID=20, + API_PALETTE_ADDBITMAP=21, + API_PALETTE_GETBITMAPELEMENT=22, + API_PALETTE_GETBITMAPANCESTOR=23, + API_PALETTE_GETNUMBITMAPELEMENT=24, + API_PALETTE_GETSKINBITMAPFILENAME=25, + API_PALETTE_GETGAMMAGROUPFROMID=26, + API_PALETTE_GETLAYERFROMID=27, + API_PALETTE_REQUESTSKINREGION=28, + API_PALETTE_CACHESKINREGION=29, + }; +}; + +inline void api_palette::StartTransaction() +{ + _voidcall(API_PALETTE_STARTTRANSACTION); +} + + +inline void api_palette::EndTransaction() +{ + _voidcall(API_PALETTE_ENDTRANSACTION); +} + + +inline void api_palette::Reset() +{ + _voidcall(API_PALETTE_RESET); +} + + +inline const int *api_palette::getSkinPartIteratorPtr() +{ + return _call(API_PALETTE_GETSKINPARTITERATORPTR, (const int *)0); +} + + +inline int api_palette::newSkinPart() +{ + return _call(API_PALETTE_NEWSKINPART, (int)0); +} + + +inline int api_palette::getSkinPartIterator() +{ + return _call(API_PALETTE_GETSKINPARTITERATOR, (int)0); +} + + +inline void api_palette::UnloadElements(int skinpart) +{ + _voidcall(API_PALETTE_UNLOADELEMENTS, skinpart); +} + + +inline void api_palette::AddAlias(const wchar_t *id, const wchar_t *target) +{ + _voidcall(API_PALETTE_ADDALIAS, id, target); +} + + +inline const wchar_t *api_palette::getElementAlias(const wchar_t *alias) +{ + return _call(API_PALETTE_GETELEMENTALIAS, (const wchar_t *)0, alias); +} + + +inline SkinItem *api_palette::getAliasAncestor(SkinItem *item) +{ + return _call(API_PALETTE_GETALIASANCESTOR, (SkinItem *)0, item); +} + + +inline void api_palette::AddColor(const wchar_t *id, ARGB32 value, const wchar_t *colorgrp, const wchar_t *path, ifc_xmlreaderparams *p) +{ + _voidcall(API_PALETTE_ADDCOLOR, id, value, colorgrp, path, p); +} + + +inline int api_palette::getNumColorElements() +{ + return _call(API_PALETTE_GETNUMCOLORELEMENTS, (int)0); +} + + +inline const wchar_t *api_palette::enumColorElement(int n) +{ + return _call(API_PALETTE_ENUMCOLORELEMENT, (const wchar_t *)0, n); +} + + +inline ARGB32 *api_palette::getColorElementRef(const wchar_t *type, const wchar_t **grp) +{ + return _call(API_PALETTE_GETCOLORELEMENTREF, (ARGB32 *)0, type, grp); +} + + +inline SkinItem *api_palette::getColorAncestor(SkinItem *item) +{ + return _call(API_PALETTE_GETCOLORANCESTOR, (SkinItem *)0, item); +} + + +inline ARGB32 api_palette::getColorElement(const wchar_t *type, const wchar_t **grp) +{ + return _call(API_PALETTE_GETCOLORELEMENT, (ARGB32)RGB(255, 0, 255), type, grp); +} + + +inline void api_palette::AddCursor(const wchar_t *id, const wchar_t *bitmapid, int x, int y, const wchar_t *path, ifc_xmlreaderparams *params) +{ + _voidcall(API_PALETTE_ADDCURSOR, id, bitmapid, x, y, path, params); +} + + +inline int api_palette::getCursorElement(const wchar_t *id) +{ + return _call(API_PALETTE_GETCURSORELEMENT, (int)-1, id); +} + + +inline OSCURSOR api_palette::getCursor(const wchar_t *id) +{ + return _call(API_PALETTE_GETCURSOR, INVALIDOSCURSORHANDLE, id); +} + + +inline SkinItem *api_palette::getCursorAncestor(SkinItem *item) +{ + return _call(API_PALETTE_GETCURSORANCESTOR, (SkinItem *)0, item); +} + + +inline const wchar_t *api_palette::getSkinCursorBitmapId(const wchar_t *cursor) +{ + return _call(API_PALETTE_GETSKINCURSORBITMAPID, (const wchar_t *)0, cursor); +} + + +inline void api_palette::AddBitmap(const wchar_t *id, const wchar_t *filename, const wchar_t *path, int x, int y, int w, int h, ifc_xmlreaderparams *params, const wchar_t *colorgroup) +{ + _voidcall(API_PALETTE_ADDBITMAP, id, filename, path, x, y, w, h, params, colorgroup); +} + + +inline int api_palette::getBitmapElement(const wchar_t *type) +{ + return _call(API_PALETTE_GETBITMAPELEMENT, (int)-1, type); +} + + +inline SkinItem *api_palette::getBitmapAncestor(SkinItem *item) +{ + return _call(API_PALETTE_GETBITMAPANCESTOR, (SkinItem *)0, item); +} + + +inline int api_palette::getNumBitmapElement() +{ + return _call(API_PALETTE_GETNUMBITMAPELEMENT, (int)0); +} + + +inline const wchar_t *api_palette::getSkinBitmapFilename(const wchar_t *id, int *x, int *y, int *w, int *h, const wchar_t **rootpath, ifc_xmlreaderparams **params) +{ + return _call(API_PALETTE_GETSKINBITMAPFILENAME, (const wchar_t *)0,id,x,y,w,h,rootpath, params); +} + + +inline const wchar_t *api_palette::getGammaGroupFromId(const wchar_t *id) +{ + return _call(API_PALETTE_GETGAMMAGROUPFROMID, (const wchar_t *)0, id); +} + + +inline int api_palette::getLayerFromId(const wchar_t *id) +{ + return _call(API_PALETTE_GETLAYERFROMID, (int)-1, id); +} + + +inline RegionServer *api_palette::requestSkinRegion(const wchar_t *id) +{ + return _call(API_PALETTE_REQUESTSKINREGION, (RegionServer *)0, id); +} + + +inline void api_palette::cacheSkinRegion(const wchar_t *id, api_region *r) +{ + _voidcall(API_PALETTE_CACHESKINREGION, id, r); +} + +// {DCA2E3C2-4C3E-4dd9-AB1A-1940F2CA31F7} +static const GUID PaletteManagerGUID = +{ 0xdca2e3c2, 0x4c3e, 0x4dd9, { 0xab, 0x1a, 0x19, 0x40, 0xf2, 0xca, 0x31, 0xf7 } }; diff --git a/Src/Wasabi/api/skin/api_skin.cpp b/Src/Wasabi/api/skin/api_skin.cpp new file mode 100644 index 00000000..ca441ede --- /dev/null +++ b/Src/Wasabi/api/skin/api_skin.cpp @@ -0,0 +1,63 @@ +#include +#include "api_skin.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif +#define CBCLASS api_skinI +START_DISPATCH; + CB(API_SKIN_SKIN_GETCOLORELEMENT, skin_getColorElement); + CB(API_SKIN_SKIN_GETCOLORELEMENTREF, skin_getColorElementRef); + CB(API_SKIN_SKIN_GETITERATOR, skin_getIterator); + VCB(API_SKIN_SKIN_SWITCHSKIN, skin_switchSkin); + VCB(API_SKIN_SKIN_UNLOADSKIN, skin_unloadSkin); + CB(API_SKIN_GETSKINNAME, getSkinName); + CB(API_SKIN_GETSKINPATH, getSkinPath); + CB(API_SKIN_GETSKINSPATH, getSkinsPath); + CB(API_SKIN_GETDEFAULTSKINPATH, getDefaultSkinPath); + CB(API_SKIN_IMGLDR_REQUESTSKINBITMAP, imgldr_requestSkinBitmap); + VCB(API_SKIN_IMGLDR_RELEASESKINBITMAP, imgldr_releaseSkinBitmap); + CB(API_SKIN_FILTERSKINCOLOR, filterSkinColor); + VCB(API_SKIN_REAPPLYSKINFILTERS, reapplySkinFilters); + CB(API_SKIN_COLORTHEME_GETNUMCOLORSETS, colortheme_getNumColorSets); + CB(API_SKIN_COLORTHEME_ENUMCOLORSET, colortheme_enumColorSet); + CB(API_SKIN_COLORTHEME_GETNUMCOLORGROUPS, colortheme_getNumColorGroups); + CB(API_SKIN_COLORTHEME_ENUMCOLORGROUPNAME, colortheme_enumColorGroupName); + CB(API_SKIN_COLORTHEME_ENUMCOLORGROUP, colortheme_enumColorGroup); + CB(API_SKIN_COLORTHEME_GETCOLORGROUP, colortheme_getColorGroup); + VCB(API_SKIN_COLORTHEME_SETCOLORSET, colortheme_setColorSet); + CB(API_SKIN_COLORTHEME_GETCOLORSET, colortheme_getColorSet); + VCB(API_SKIN_COLORTHEME_NEWCOLORSET, colortheme_newColorSet); + VCB(API_SKIN_COLORTHEME_UPDATECOLORSET, colortheme_updateColorSet); + VCB(API_SKIN_COLORTHEME_RENAMESET, colortheme_renameColorSet); + VCB(API_SKIN_COLORTHEME_DELETE, colortheme_deleteColorSet); + CB(API_SKIN_LOADSKINFILE, loadSkinFile); + CB(API_SKIN_LOADGROUPDEFDATA, loadGroupDefData); + VCB(API_SKIN_UNLOADSKINPART, unloadSkinPart); + CB(API_SKIN_GROUP_CREATE, group_create); +#ifdef WASABI_COMPILE_CONFIG + CB(API_SKIN_GROUP_CREATE_CFG, group_create_cfg); +#endif // WASABI_COMPILE_CONFIG +#ifdef WASABI_COMPILE_WNDMGR + CB(API_SKIN_GROUP_CREATE_LAYOUT, group_create_layout); +#endif //WASABI_COMPILE_WNDMGR + CB(API_SKIN_GROUP_DESTROY, group_destroy); + CB(API_SKIN_GROUP_EXISTS, group_exists); + CB(API_SKIN_PARSE, parse); + CB(API_SKIN_XUI_NEW, xui_new); + VCB(API_SKIN_XUI_DELETE, xui_delete); + CB(API_SKIN_CURSOR_REQUEST, cursor_request); + CB(API_SKIN_GETNUMGROUPS, getNumGroupDefs); + CB(API_SKIN_ENUMGROUP, enumGroupDef); + CB(API_SKIN_GROUP_CREATEBYITEM, group_createBySkinItem); + CB(API_SKIN_GETGROUPANCESTOR, getGroupDefAncestor); + CB(API_SKIN_GROUPDEF_GETNUMOBJECTS, groupdef_getNumObjects); + CB(API_SKIN_GROUPDEF_ENUMOBJECT, groupdef_enumObject); + VCB(API_SKIN_SETLOCKUI, skin_setLockUI); + CB(API_SKIN_GETLOCKUI, skin_getLockUI); + CB(API_SKIN_GETVERSION, skin_getVersion); +#ifdef WASABI_COMPILE_IMGLDR + CB(API_SKIN_GETBITMAPCOLOR, skin_getBitmapColor); +#endif + CB(API_SKIN_ISLOADED, skin_isLoaded); +END_DISPATCH; diff --git a/Src/Wasabi/api/skin/api_skin.h b/Src/Wasabi/api/skin/api_skin.h new file mode 100644 index 00000000..136712e9 --- /dev/null +++ b/Src/Wasabi/api/skin/api_skin.h @@ -0,0 +1,429 @@ +#ifndef __API_SKIN_H +#define __API_SKIN_H + +#include +#include + +class ifc_window; +class GuiObject; +class ColorThemeGroup; +class ifc_xmlreaderparams; +class SkinItem; + +#ifdef WASABI_COMPILE_CONFIG +class CfgItem; +#endif //WASABI_COMPILE_CONFIG + +#ifdef WASABI_COMPILE_WNDMGR +class CfgItem; +#endif //WASABI_COMPILE_WNDMGR + +#ifdef _WIN32 +#ifndef OSCURSOR +#define OSCURSOR HICON +#endif +#elif defined(__APPLE__) +#define OSCURSOR CGImageRef +#endif + +class NOVTABLE api_skin : public Dispatchable +{ + public: + // skin colors + ARGB32 skin_getColorElement(const wchar_t *type, const wchar_t **color_group = NULL); + const ARGB32 *skin_getColorElementRef(const wchar_t *type, const wchar_t **color_group = NULL); + const int *skin_getIterator(); + + // possibly make a svc_skinloader + void skin_switchSkin(const wchar_t *skin_name, const wchar_t *skin_path=NULL); + void skin_unloadSkin(); + int loadSkinFile(const wchar_t *xmlfile); + int loadGroupDefData(const wchar_t *groupdef, SkinItem **lastgroupitem); + void unloadSkinPart(int skinpartid); + const wchar_t *getSkinName(); + const wchar_t *getSkinPath(); + const wchar_t *getSkinsPath(); + const wchar_t *getDefaultSkinPath(); + + // skin bitmaps + ARGB32 *imgldr_requestSkinBitmap(const wchar_t *file, int *has_alpha, int *x, int *y, int *subw, int *subh, int *w, int *h, int cached); + void imgldr_releaseSkinBitmap(ARGB32 *bmpbits); +#ifdef WASABI_COMPILE_IMGLDR + ARGB32 skin_getBitmapColor(const wchar_t *bitmapid); +#endif + + // skin filters + ARGB32 filterSkinColor(ARGB32 color, const wchar_t *elementid, const wchar_t *groupname); + void reapplySkinFilters(); + int colortheme_getNumColorSets(); + const wchar_t *colortheme_enumColorSet(int n); + int colortheme_getNumColorGroups(const wchar_t *colorset); + const wchar_t *colortheme_enumColorGroupName(const wchar_t *colorset, int n); + ColorThemeGroup *colortheme_enumColorGroup(int colorset, int n); + ColorThemeGroup *colortheme_getColorGroup(const wchar_t *colorset, const wchar_t *colorgroup); + void colortheme_setColorSet(const wchar_t *colorset); + const wchar_t *colortheme_getColorSet(); + void colortheme_newColorSet(const wchar_t *set); + void colortheme_updateColorSet(const wchar_t *set); + void colortheme_renameColorSet(const wchar_t *set, const wchar_t *newname); + void colortheme_deleteColorSet(const wchar_t *set); + + // groups + ifc_window *group_create(const wchar_t *groupid, int scripts_enabled=1); + int group_exists(const wchar_t *groupid); +#ifdef WASABI_COMPILE_CONFIG + ifc_window *group_create_cfg(const wchar_t *groupid, CfgItem *cfgitem, const wchar_t *attributename, int scripts_enabled=1); +#endif // WASABI_COMPILE_CONFIG +#ifdef WASABI_COMPILE_WNDMGR + ifc_window *group_create_layout(const wchar_t *groupid, int scripts_enabled=1); +#endif //WASABI_COMPILE_WNDMGR + int group_destroy(ifc_window *group); + + int parse(const wchar_t *str, const wchar_t *how); + GuiObject *xui_new(const wchar_t *classname); + void xui_delete(GuiObject *o); + OSCURSOR cursor_request(const wchar_t *id); + int getNumGroupDefs(); + SkinItem *enumGroupDef(int n); + ifc_window *group_createBySkinItem(SkinItem *groupitem, int scripts_enabled=1); + SkinItem *getGroupDefAncestor(SkinItem *groupitem); + int groupdef_getNumObjects(SkinItem *groupitem); + SkinItem *groupdef_enumObject(SkinItem *item, int n); + void skin_setLockUI(int l); + int skin_getLockUI(); + double skin_getVersion(); + bool skin_isLoaded(); + + + enum { + API_SKIN_SKIN_GETCOLORELEMENT = 0, + API_SKIN_SKIN_GETCOLORELEMENTREF = 10, + API_SKIN_SKIN_GETITERATOR = 20, + API_SKIN_SKIN_SWITCHSKIN = 30, + API_SKIN_SKIN_UNLOADSKIN = 35, + API_SKIN_GETSKINNAME = 40, + API_SKIN_GETSKINPATH = 50, + API_SKIN_GETSKINSPATH = 60, + API_SKIN_GETDEFAULTSKINPATH = 70, + API_SKIN_IMGLDR_REQUESTSKINBITMAP = 80, + API_SKIN_IMGLDR_RELEASESKINBITMAP = 90, + API_SKIN_FILTERSKINCOLOR = 100, + API_SKIN_REAPPLYSKINFILTERS = 110, + API_SKIN_COLORTHEME_GETNUMCOLORSETS = 120, + API_SKIN_COLORTHEME_ENUMCOLORSET = 130, + API_SKIN_COLORTHEME_GETNUMCOLORGROUPS = 140, + API_SKIN_COLORTHEME_ENUMCOLORGROUPNAME = 150, + API_SKIN_COLORTHEME_ENUMCOLORGROUP = 160, + API_SKIN_COLORTHEME_GETCOLORGROUP = 165, + API_SKIN_COLORTHEME_SETCOLORSET = 170, + API_SKIN_COLORTHEME_GETCOLORSET = 180, + API_SKIN_COLORTHEME_NEWCOLORSET = 190, + API_SKIN_COLORTHEME_RENAMESET = 191, + API_SKIN_COLORTHEME_DELETE = 192, + API_SKIN_COLORTHEME_UPDATECOLORSET = 193, + API_SKIN_LOADSKINFILE = 200, + API_SKIN_UNLOADSKINPART = 210, + API_SKIN_GROUP_CREATE = 220, + API_SKIN_GROUP_EXISTS = 225, +#ifdef WASABI_COMPILE_CONFIG + API_SKIN_GROUP_CREATE_CFG = 230, +#endif // WASABI_COMPILE_CONFIG +#ifdef WASABI_COMPILE_WNDMGR + API_SKIN_GROUP_CREATE_LAYOUT = 240, +#endif //WASABI_COMPILE_WNDMGR + API_SKIN_GROUP_DESTROY = 250, + API_SKIN_PARSE = 260, + API_SKIN_XUI_NEW = 270, + API_SKIN_XUI_DELETE = 280, + API_SKIN_CURSOR_REQUEST = 290, + API_SKIN_GETNUMGROUPS = 300, + API_SKIN_ENUMGROUP = 310, + API_SKIN_GROUP_CREATEBYITEM = 320, + API_SKIN_GETGROUPANCESTOR = 330, + API_SKIN_GROUPDEF_GETNUMOBJECTS = 340, + API_SKIN_GROUPDEF_ENUMOBJECT = 350, + API_SKIN_LOADGROUPDEFDATA = 360, + API_SKIN_SETLOCKUI = 370, + API_SKIN_GETLOCKUI = 380, + API_SKIN_GETVERSION = 390, + API_SKIN_GETBITMAPCOLOR = 400, + API_SKIN_ISLOADED = 410, + }; +}; + +inline ARGB32 api_skin::skin_getColorElement(const wchar_t *type, const wchar_t **color_group) { + return _call(API_SKIN_SKIN_GETCOLORELEMENT, (ARGB32)NULL, type, color_group); +} + +inline const ARGB32 *api_skin::skin_getColorElementRef(const wchar_t *type, const wchar_t **color_group) { + return _call(API_SKIN_SKIN_GETCOLORELEMENTREF, (ARGB32 *)NULL, type, color_group); +} + +inline const int *api_skin::skin_getIterator() { + return _call(API_SKIN_SKIN_GETITERATOR, (const int *)0); +} + +inline void api_skin::skin_switchSkin(const wchar_t *skin_name, const wchar_t *skin_path) { + _voidcall(API_SKIN_SKIN_SWITCHSKIN, skin_name, skin_path); +} + +inline void api_skin::skin_unloadSkin() { + _voidcall(API_SKIN_SKIN_UNLOADSKIN); +} + +inline const wchar_t *api_skin::getSkinName() { + return _call(API_SKIN_GETSKINNAME, (const wchar_t *)0); +} + +inline const wchar_t *api_skin::getSkinPath() { + return _call(API_SKIN_GETSKINPATH, (const wchar_t *)0); +} + +inline const wchar_t *api_skin::getSkinsPath() { + return _call(API_SKIN_GETSKINSPATH, (const wchar_t *)0); +} + +inline const wchar_t *api_skin::getDefaultSkinPath() { + return _call(API_SKIN_GETDEFAULTSKINPATH, (const wchar_t *)0); +} + +inline ARGB32 *api_skin::imgldr_requestSkinBitmap(const wchar_t *file, int *has_alpha, int *x, int *y, int *subw, int *subh, int *w, int *h, int cached) { + return _call(API_SKIN_IMGLDR_REQUESTSKINBITMAP, (ARGB32 *)NULL, file, has_alpha, x, y, subw, subh, w, h, cached); +} + +inline void api_skin::imgldr_releaseSkinBitmap(ARGB32 *bmpbits) { + _voidcall(API_SKIN_IMGLDR_RELEASESKINBITMAP, bmpbits); +} + +inline ARGB32 api_skin::filterSkinColor(ARGB32 color, const wchar_t *elementid, const wchar_t *groupname) { + return _call(API_SKIN_FILTERSKINCOLOR, (ARGB32)NULL, color, elementid, groupname); +} + +inline void api_skin::reapplySkinFilters() { + _voidcall(API_SKIN_REAPPLYSKINFILTERS); +} + +inline int api_skin::colortheme_getNumColorSets() { + return _call(API_SKIN_COLORTHEME_GETNUMCOLORSETS, (int)0); +} + +inline const wchar_t *api_skin::colortheme_enumColorSet(int n) { + return _call(API_SKIN_COLORTHEME_ENUMCOLORSET, (const wchar_t *)0, n); +} + +inline int api_skin::colortheme_getNumColorGroups(const wchar_t *colorset) { + return _call(API_SKIN_COLORTHEME_GETNUMCOLORGROUPS, (int)0, colorset); +} + +inline const wchar_t *api_skin::colortheme_enumColorGroupName(const wchar_t *colorset, int n) { + return _call(API_SKIN_COLORTHEME_ENUMCOLORGROUPNAME, (const wchar_t *)0, colorset, n); +} + +inline ColorThemeGroup *api_skin::colortheme_enumColorGroup(int colorset, int n) { + return _call(API_SKIN_COLORTHEME_ENUMCOLORGROUP, (ColorThemeGroup *)NULL, colorset, n); +} + +inline ColorThemeGroup *api_skin::colortheme_getColorGroup(const wchar_t *colorset, const wchar_t *group) { + return _call(API_SKIN_COLORTHEME_GETCOLORGROUP, (ColorThemeGroup *)NULL, colorset, group); +} + +inline void api_skin::colortheme_setColorSet(const wchar_t *colorset) +{ + _voidcall(API_SKIN_COLORTHEME_SETCOLORSET, colorset); +} + +inline const wchar_t *api_skin::colortheme_getColorSet() +{ + return _call(API_SKIN_COLORTHEME_GETCOLORSET, (const wchar_t *)0); +} + +inline void api_skin::colortheme_newColorSet(const wchar_t *set) { + _voidcall(API_SKIN_COLORTHEME_NEWCOLORSET, set); +} + +inline void api_skin::colortheme_updateColorSet(const wchar_t *set) { + _voidcall(API_SKIN_COLORTHEME_UPDATECOLORSET, set); +} + +inline void api_skin::colortheme_renameColorSet(const wchar_t *set, const wchar_t *newname) { + _voidcall(API_SKIN_COLORTHEME_RENAMESET, set, newname); +} + +inline void api_skin::colortheme_deleteColorSet(const wchar_t *set) { + _voidcall(API_SKIN_COLORTHEME_DELETE, set); +} + + +inline int api_skin::loadSkinFile(const wchar_t *xmlfile) { + return _call(API_SKIN_LOADSKINFILE, (int)0, xmlfile); +} + +inline void api_skin::unloadSkinPart(int skinpartid) { + _voidcall(API_SKIN_UNLOADSKINPART, skinpartid); +} + +inline ifc_window *api_skin::group_create(const wchar_t *groupid, int scripts_enabled) { + return _call(API_SKIN_GROUP_CREATE, (ifc_window *)NULL, groupid, scripts_enabled); +} + +inline int api_skin::group_exists(const wchar_t *groupid) { + return _call(API_SKIN_GROUP_EXISTS, 1, groupid); +} + +#ifdef WASABI_COMPILE_CONFIG +inline ifc_window *api_skin::group_create_cfg(const wchar_t *groupid, CfgItem *cfgitem, const wchar_t *attributename, int scripts_enabled) { + return _call(API_SKIN_GROUP_CREATE_CFG, (ifc_window *)NULL, groupid, cfgitem, attributename, scripts_enabled); +} +#endif // WASABI_COMPILE_CONFIG + +#ifdef WASABI_COMPILE_WNDMGR +inline ifc_window *api_skin::group_create_layout(const wchar_t *groupid, int scripts_enabled) { + return _call(API_SKIN_GROUP_CREATE_LAYOUT, (ifc_window *)NULL, groupid, scripts_enabled); +} +#endif //WASABI_COMPILE_WNDMGR + +inline int api_skin::group_destroy(ifc_window *group) { + return _call(API_SKIN_GROUP_DESTROY, (int)0, group); +} + +inline int api_skin::parse(const wchar_t *str, const wchar_t *how) { + return _call(API_SKIN_PARSE, (int)0, str, how); +} + +inline GuiObject *api_skin::xui_new(const wchar_t *classname) { + return _call(API_SKIN_XUI_NEW, (GuiObject *)NULL, classname); +} + +inline void api_skin::xui_delete(GuiObject *o) { + _voidcall(API_SKIN_XUI_DELETE, o); +} + +inline OSCURSOR api_skin::cursor_request(const wchar_t *id) +{ + return _call(API_SKIN_CURSOR_REQUEST, (OSCURSOR)NULL, id); +} + +inline int api_skin::getNumGroupDefs() { + return _call(API_SKIN_GETNUMGROUPS, (int)0); +} + +inline SkinItem *api_skin::enumGroupDef(int n) { + return _call(API_SKIN_ENUMGROUP, (SkinItem *)NULL, n); +} + +inline ifc_window *api_skin::group_createBySkinItem(SkinItem *item, int scripts_enabled) { + return _call(API_SKIN_GROUP_CREATEBYITEM, (ifc_window *)NULL, item, scripts_enabled); +} + +inline SkinItem *api_skin::getGroupDefAncestor(SkinItem *item) { + return _call(API_SKIN_GETGROUPANCESTOR, (SkinItem *)NULL, item); +} + +inline int api_skin::groupdef_getNumObjects(SkinItem *groupitem) { + return _call(API_SKIN_GROUPDEF_GETNUMOBJECTS, 0, groupitem); +} + +inline SkinItem *api_skin::groupdef_enumObject(SkinItem *item, int n) { + return _call(API_SKIN_GROUPDEF_ENUMOBJECT, (SkinItem *)NULL, item, n); +} + +inline int api_skin::loadGroupDefData(const wchar_t *groupdef, SkinItem **lastgroupitem) { + return _call(API_SKIN_LOADGROUPDEFDATA, -1, groupdef, lastgroupitem); +} + +inline void api_skin::skin_setLockUI(int l) { + _voidcall(API_SKIN_SETLOCKUI, l); +} + +inline int api_skin::skin_getLockUI() { + return _call(API_SKIN_GETLOCKUI, 0); +} + +inline double api_skin::skin_getVersion() { + return _call(API_SKIN_GETVERSION, 0.8); +} + +#ifdef WASABI_COMPILE_IMGLDR +inline ARGB32 api_skin::skin_getBitmapColor(const wchar_t *bitmapid) { + return _call(API_SKIN_GETBITMAPCOLOR, 0xFFFF00FF, bitmapid); +} +#endif + +inline bool api_skin::skin_isLoaded() +{ + return _call(API_SKIN_ISLOADED, false); +} + +class api_skinI : public api_skin +{ + protected: + api_skinI() {} + virtual ~api_skinI() {} + + public: + virtual ARGB32 skin_getColorElement(const wchar_t *type, const wchar_t **color_group = NULL)=0; + virtual const ARGB32 *skin_getColorElementRef(const wchar_t *type, const wchar_t **color_group = NULL)=0; + virtual const int *skin_getIterator()=0; + virtual void skin_switchSkin(const wchar_t *skin_name, const wchar_t *skin_path=NULL)=0; + virtual void skin_unloadSkin()=0; + virtual const wchar_t *getSkinName()=0; + virtual const wchar_t *getSkinPath()=0; + virtual const wchar_t *getSkinsPath()=0; + virtual const wchar_t *getDefaultSkinPath()=0; + virtual ARGB32 *imgldr_requestSkinBitmap(const wchar_t *file, int *has_alpha, int *x, int *y, int *subw, int *subh, int *w, int *h, int cached)=0; + virtual void imgldr_releaseSkinBitmap(ARGB32 *bmpbits)=0; + virtual ARGB32 filterSkinColor(ARGB32 color, const wchar_t *elementid, const wchar_t *groupname)=0; + virtual void reapplySkinFilters()=0; + virtual int colortheme_getNumColorSets()=0; + virtual const wchar_t *colortheme_enumColorSet(int n)=0; + virtual int colortheme_getNumColorGroups(const wchar_t *colorset)=0; + virtual const wchar_t *colortheme_enumColorGroupName(const wchar_t *colorset, int n)=0; + virtual ColorThemeGroup *colortheme_enumColorGroup(int colorset, int n)=0; + virtual ColorThemeGroup *colortheme_getColorGroup(const wchar_t *colorset, const wchar_t *group)=0; + virtual void colortheme_setColorSet(const wchar_t *colorset)=0; + virtual const wchar_t *colortheme_getColorSet()=0; + virtual void colortheme_newColorSet(const wchar_t *set)=0; + virtual void colortheme_updateColorSet(const wchar_t *set)=0; + virtual void colortheme_renameColorSet(const wchar_t *set, const wchar_t *newname)=0; + virtual void colortheme_deleteColorSet(const wchar_t *set)=0; + virtual int loadSkinFile(const wchar_t *xmlfile)=0; + virtual int loadGroupDefData(const wchar_t *groupdef, SkinItem **lastgroupitem)=0; + virtual void unloadSkinPart(int skinpartid)=0; + virtual ifc_window *group_create(const wchar_t *groupid, int scripts_enabled=1)=0; + virtual int group_exists(const wchar_t *groupid)=0; +#ifdef WASABI_COMPILE_CONFIG + virtual ifc_window *group_create_cfg(const wchar_t *groupid, CfgItem *cfgitem, const wchar_t *attributename, int scripts_enabled=1)=0; +#endif // WASABI_COMPILE_CONFIG +#ifdef WASABI_COMPILE_WNDMGR + virtual ifc_window *group_create_layout(const wchar_t *groupid, int scripts_enabled=1)=0; +#endif //WASABI_COMPILE_WNDMGR + virtual int group_destroy(ifc_window *group)=0; + virtual int parse(const wchar_t *str, const wchar_t *how)=0; + virtual GuiObject *xui_new(const wchar_t *classname)=0; + virtual void xui_delete(GuiObject *o)=0; + virtual OSCURSOR cursor_request(const wchar_t *id)=0; + virtual int getNumGroupDefs()=0; + virtual SkinItem *enumGroupDef(int n)=0; + virtual ifc_window *group_createBySkinItem(SkinItem *item, int scripts_enabled=1)=0; + virtual SkinItem *getGroupDefAncestor(SkinItem *groupitem)=0; + virtual int groupdef_getNumObjects(SkinItem *groupitem)=0; + virtual SkinItem *groupdef_enumObject(SkinItem *groupitem, int n)=0; + virtual void skin_setLockUI(int l)=0; + virtual int skin_getLockUI()=0; + virtual double skin_getVersion()=0; +#ifdef WASABI_COMPILE_IMGLDR + virtual ARGB32 skin_getBitmapColor(const wchar_t *id)=0; +#endif + virtual bool skin_isLoaded()=0; + protected: + RECVS_DISPATCH; +}; + +// {F2398F09-63B0-4442-86C9-F8BC473F6DA7} +static const GUID skinApiServiceGuid = +{ 0xf2398f09, 0x63b0, 0x4442, { 0x86, 0xc9, 0xf8, 0xbc, 0x47, 0x3f, 0x6d, 0xa7 } }; + +extern api_skin *skinApi; + + +#endif diff --git a/Src/Wasabi/api/skin/colorthemes.h b/Src/Wasabi/api/skin/colorthemes.h new file mode 100644 index 00000000..fe11ec17 --- /dev/null +++ b/Src/Wasabi/api/skin/colorthemes.h @@ -0,0 +1,87 @@ +#ifndef __COLORTHEMEGROUP_H +#define __COLORTHEMEGROUP_H + +#include + +class ColorThemeGroup : public Dispatchable +{ + public: + const wchar_t *getName(); + int getRed(); + int getGreen(); + int getBlue(); + int getGray(); + int getBoost(); + + void setName(const wchar_t *name); + void setRed(int r); + void setGreen(int g); + void setBlue(int b); + void setGray(int g); + void setBoost(int b); + + enum { + COLORTHEMEGROUPGETNAME=10, + COLORTHEMEGROUPGETRED=20, + COLORTHEMEGROUPGETGREEN=30, + COLORTHEMEGROUPGETBLUE=40, + COLORTHEMEGROUPGETGRAY=50, + COLORTHEMEGROUPGETBOOST=60, + COLORTHEMEGROUPSETNAME=70, + COLORTHEMEGROUPSETRED=80, + COLORTHEMEGROUPSETGREEN=90, + COLORTHEMEGROUPSETBLUE=100, + COLORTHEMEGROUPSETGRAY=110, + COLORTHEMEGROUPSETBOOST=120, + }; +}; + +inline const wchar_t *ColorThemeGroup::getName() { + return _call(COLORTHEMEGROUPGETNAME, (const wchar_t *)NULL); +} + +inline int ColorThemeGroup::getRed() { + return _call(COLORTHEMEGROUPGETRED, 0); +} + +inline int ColorThemeGroup::getGreen() { + return _call(COLORTHEMEGROUPGETGREEN, 0); +} + +inline int ColorThemeGroup::getBlue() { + return _call(COLORTHEMEGROUPGETBLUE, 0); +} + +inline int ColorThemeGroup::getGray() { + return _call(COLORTHEMEGROUPGETGRAY, 0); +} + +inline int ColorThemeGroup::getBoost() { + return _call(COLORTHEMEGROUPGETBOOST, 0); +} + +inline void ColorThemeGroup::setName(const wchar_t *name) { + _voidcall(COLORTHEMEGROUPSETNAME, name); +} + +inline void ColorThemeGroup::setRed(int r) { + _voidcall(COLORTHEMEGROUPSETRED, r); +} + +inline void ColorThemeGroup::setGreen(int g) { + _voidcall(COLORTHEMEGROUPSETGREEN, g); +} + +inline void ColorThemeGroup::setBlue(int b) { + _voidcall(COLORTHEMEGROUPSETBLUE, b); +} + +inline void ColorThemeGroup::setGray(int g) { + _voidcall(COLORTHEMEGROUPSETGRAY, g); +} + +inline void ColorThemeGroup::setBoost(int b) { + _voidcall(COLORTHEMEGROUPSETBOOST, b); +} + +#endif diff --git a/Src/Wasabi/api/skin/cursormgr.cpp b/Src/Wasabi/api/skin/cursormgr.cpp new file mode 100644 index 00000000..bf5ab3e8 --- /dev/null +++ b/Src/Wasabi/api/skin/cursormgr.cpp @@ -0,0 +1,29 @@ +#include "precomp.h" +#include +#include "cursormgr.h" +#include + + + +OSCURSOR CursorMgr::requestCursor(const wchar_t *id) +{ + // Martin> Register os cursors, perhaps find a better way to do this in basewnd.cpp + if (_wcsicmp(id, L"IDC_ARROW") == 0) return LoadCursor(NULL, IDC_ARROW); + if (_wcsicmp(id, L"IDC_SIZENS") == 0) return LoadCursor(NULL, IDC_SIZENS); + if (_wcsicmp(id, L"IDC_SIZEWE") == 0) return LoadCursor(NULL, IDC_SIZEWE); + if (_wcsicmp(id, L"IDC_SIZENWSE") == 0) return LoadCursor(NULL, IDC_SIZENWSE); + if (_wcsicmp(id, L"IDC_SIZENESW") == 0) return LoadCursor(NULL, IDC_SIZENESW); + if (_wcsicmp(id, L"IDC_SIZEALL") == 0) return LoadCursor(NULL, IDC_SIZEALL); + if (_wcsicmp(id, L"IDC_IBEAM") == 0) return LoadCursor(NULL, IDC_IBEAM); + if (_wcsicmp(id, L"IDC_WAIT") == 0) return LoadCursor(NULL, IDC_WAIT); + if (_wcsicmp(id, L"IDC_CROSS") == 0) return LoadCursor(NULL, IDC_CROSS); + if (_wcsicmp(id, L"IDC_UPARROW") == 0) return LoadCursor(NULL, IDC_UPARROW); + if (_wcsicmp(id, L"IDC_NO") == 0) return LoadCursor(NULL, IDC_NO); + if (_wcsicmp(id, L"IDC_HAND") == 0) return LoadCursor(NULL, IDC_HAND); + if (_wcsicmp(id, L"IDC_APPSTARTING") == 0) return LoadCursor(NULL, IDC_APPSTARTING); + if (_wcsicmp(id, L"IDC_HELP") == 0) return LoadCursor(NULL, IDC_HELP); + + OSCURSOR cursor = WASABI_API_PALETTE->getCursor(id); + return cursor; +} + diff --git a/Src/Wasabi/api/skin/cursormgr.h b/Src/Wasabi/api/skin/cursormgr.h new file mode 100644 index 00000000..a70d6eaf --- /dev/null +++ b/Src/Wasabi/api/skin/cursormgr.h @@ -0,0 +1,18 @@ +#ifndef __CURSORMGR_H +#define __CURSORMGR_H + +#include +#include + +class ifc_window; + +class CursorMgr +{ + public: + CursorMgr() {} + virtual ~CursorMgr() {} + + static OSCURSOR requestCursor(const wchar_t *id); +}; + +#endif diff --git a/Src/Wasabi/api/skin/feeds/TextFeedEnum.h b/Src/Wasabi/api/skin/feeds/TextFeedEnum.h new file mode 100644 index 00000000..62405cfe --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/TextFeedEnum.h @@ -0,0 +1,35 @@ +#ifndef NULLSOFT_WASABI_TEXTFEEDENUM_H +#define NULLSOFT_WASABI_TEXTFEEDENUM_H + + +#include +#include +// see helper class TextFeed + +#include +template +class TextFeedCreatorSingle : public waServiceFactoryTSingle +{ +public: + svc_textFeed *getFeed() + { + return getSingleService(); + } +}; + +#include + +class TextFeedEnum : public SvcEnumT +{ +public: + TextFeedEnum(const wchar_t *_feedid) : feedid(_feedid) {} +protected: + virtual int testService(svc_textFeed *svc) + { + return (svc->hasFeed(feedid)); + } +private: + StringW feedid; +}; + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/skin/feeds/api_textfeed.cpp b/Src/Wasabi/api/skin/feeds/api_textfeed.cpp new file mode 100644 index 00000000..d7b3d2f1 --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/api_textfeed.cpp @@ -0,0 +1,2 @@ +#include +#include "api_textfeed.h" \ No newline at end of file diff --git a/Src/Wasabi/api/skin/feeds/api_textfeed.h b/Src/Wasabi/api/skin/feeds/api_textfeed.h new file mode 100644 index 00000000..fecde4d4 --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/api_textfeed.h @@ -0,0 +1,66 @@ +#ifndef __WASABI_API_TEXTFEED_H +#define __WASABI_API_TEXTFEED_H + +#include +#include +#include + +class ifc_dependent; + +// {A04E3420-CBA1-4ae1-B3C0-8DE127D2B861} +static const GUID textfeed_dependent_GUID = { 0xa04e3420, 0xcba1, 0x4ae1, { 0xb3, 0xc0, 0x8d, 0xe1, 0x27, 0xd2, 0xb8, 0x61 } }; + +class NOVTABLE svc_textFeed : public Dispatchable +{ +public: + static FOURCC getServiceType() { return WaSvc::TEXTFEED; } + static const GUID *depend_getClassGuid() + { + return &textfeed_dependent_GUID; + } + static const char *getServiceName() { return "Untitled Textfeed"; } + +public: + int hasFeed(const wchar_t *name); + const wchar_t *getFeedText(const wchar_t *name); + const wchar_t *getFeedDescription(const wchar_t *name); + ifc_dependent *getDependencyPtr(); + +public: + enum + { + Event_TEXTCHANGE = 100, // param is const char* to id, ptr points to new text + }; + + DISPATCH_CODES + { + SVCTEXTFEED_HASFEED = 10, + //20,30 retired + SVCTEXTFEED_GETFEEDTEXT = 40, + SVCTEXTFEED_GETFEEDDESC = 45, + SVCTEXTFEED_GETDEPENDENCYPTR = 100, + }; +}; + +inline int svc_textFeed::hasFeed(const wchar_t *name) +{ + return _call(SVCTEXTFEED_HASFEED, 0, name); +} + +inline const wchar_t *svc_textFeed::getFeedText(const wchar_t *name) +{ + return _call(SVCTEXTFEED_GETFEEDTEXT, (const wchar_t *)NULL, name); +} + +inline const wchar_t *svc_textFeed::getFeedDescription(const wchar_t *name) +{ + return _call(SVCTEXTFEED_GETFEEDDESC, (const wchar_t *)NULL, name); +} + +inline ifc_dependent *svc_textFeed::getDependencyPtr() +{ + return _call(SVCTEXTFEED_GETDEPENDENCYPTR, (ifc_dependent*)NULL); +} + + +#endif diff --git a/Src/Wasabi/api/skin/feeds/ezfeed.h b/Src/Wasabi/api/skin/feeds/ezfeed.h new file mode 100644 index 00000000..cc607d10 --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/ezfeed.h @@ -0,0 +1,27 @@ +#ifndef _EZFEED_H +#define _EZFEED_H + +//#include +#include +#include + +class EzFeed : public waServiceFactoryBase, public TextFeed +{ +public: + EzFeed() : registered(0) { } + static const char *getServiceName() { return "EzTextFeed"; } + virtual svc_textFeed *newService() { return this; } + virtual int delService(svc_textFeed *service) { return TRUE; } + + virtual int svc_notify(int msg, int param1 = 0, int param2 = 0) + { + if (msg == SvcNotify::ONREGISTERED) registered = 1; + else if (msg == SvcNotify::ONDEREGISTERED) registered = 0; + return 1; + } + +private: + int registered; +}; + +#endif diff --git a/Src/Wasabi/api/skin/feeds/feedwatch.cpp b/Src/Wasabi/api/skin/feeds/feedwatch.cpp new file mode 100644 index 00000000..e200c20e --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/feedwatch.cpp @@ -0,0 +1,90 @@ +#include +#pragma warning(disable:4355) + +//" +#include "feedwatch.h" +//?> + +#include + + +FeedWatcher::FWDV::FWDV(FeedWatcher *_parent) : parent(_parent) { } + +int FeedWatcher::FWDV::viewer_onItemDeleted(ifc_dependent *item) { + return parent->fwdv_onItemDeleted(item); +} + +int FeedWatcher::FWDV::viewer_onEvent(ifc_dependent *item, const GUID *classguid, int event, intptr_t param, void *ptr, size_t ptrlen) { + return parent->fwdv_onEvent(item, event, param, ptr, ptrlen); +} + +FeedWatcher::FeedWatcher() : + registered_syscb(0), textfeed(NULL), fwdv(this) +{ +} + + +FeedWatcher::~FeedWatcher() { + releaseFeed(); + if (registered_syscb) { + WASABI_API_SYSCB->syscb_deregisterCallback(static_cast(this)); + DebugStringW(L"unreg syscb"); + } +} + +int FeedWatcher::setFeed(const wchar_t *feedid) +{ + if (!registered_syscb++) WASABI_API_SYSCB->syscb_registerCallback(static_cast(this)); + + releaseFeed(); + + feed_id = feedid; + if (!feed_id.isempty()) textfeed = TextFeedEnum(feed_id).getFirst(); + + if (textfeed != NULL) { + fwdv.viewer_addViewItem(textfeed->getDependencyPtr()); + feedwatcher_onSetFeed(textfeed); +//CUT if (first_cb) feedwatcher_onFeedChange(textfeed->getFeedText(feed_id)); + } + + return 1; +} + +void FeedWatcher::releaseFeed() { + if (textfeed) { + fwdv.viewer_delViewItem(textfeed->getDependencyPtr()); + feed_id = L""; + SvcEnum::release(textfeed); + textfeed = NULL; + } +} + +const wchar_t *FeedWatcher::getFeedId() { + return feed_id; +} + +int FeedWatcher::fwdv_onItemDeleted(ifc_dependent *item) { + textfeed = NULL; + // send text change msg? dunno for sure + return 1; +} + +int FeedWatcher::fwdv_onEvent(ifc_dependent *item, int event, intptr_t param2, void *ptr, size_t ptrlen) { + if (textfeed && item == textfeed->getDependencyPtr() + && event == svc_textFeed::Event_TEXTCHANGE + && WCSCASEEQLSAFE((const wchar_t *)param2, feed_id)) { + feedwatcher_onFeedChange((const wchar_t *)ptr); + return 1; + } + return 0; +} + +void FeedWatcher::svccb_onSvcRegister(FOURCC type, waServiceFactory *svc) { + // brand new feed and we don't have one, try to register it +//CUT __asm int 3; + if (type == WaSvc::TEXTFEED && textfeed == NULL) { + if (!feed_id.isempty()) { + setFeed(feed_id); + } + } +} \ No newline at end of file diff --git a/Src/Wasabi/api/skin/feeds/feedwatch.h b/Src/Wasabi/api/skin/feeds/feedwatch.h new file mode 100644 index 00000000..3e3bd7a2 --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/feedwatch.h @@ -0,0 +1,54 @@ +#ifndef __FEEDWATCH_H +#define __FEEDWATCH_H + +#include +#include +#include "feedwatcherso.h" + +class svc_textFeed; +class ifc_dependent; + + + +class FeedWatcher : private SvcCallbackI, public FeedWatcherScriptObject { +public: + FeedWatcher(); + virtual ~FeedWatcher(); + + int setFeed(const wchar_t *feedid); + void releaseFeed(); + + const wchar_t *getFeedId(); + + virtual void feedwatcher_onSetFeed(svc_textFeed *svc) { } + virtual void feedwatcher_onFeedChange(const wchar_t *data) { } + +protected: + class FWDV : public DependentViewerI +{ +public: + friend class FeedWatcher; + + FWDV(FeedWatcher *parent); + + virtual int viewer_onItemDeleted(ifc_dependent *item); + virtual int viewer_onEvent(ifc_dependent *item, const GUID *classguid, int event, intptr_t param, void *ptr, size_t ptrlen); + + FeedWatcher *parent; +}; + + // catches text feed change events + virtual int fwdv_onItemDeleted(ifc_dependent *item); + virtual int fwdv_onEvent(ifc_dependent *item, int event, intptr_t param2, void *ptr, size_t ptrlen); + +private: + // catches new feeds being registered + virtual void svccb_onSvcRegister(FOURCC type, waServiceFactory *svc); + + int registered_syscb; + StringW feed_id; + svc_textFeed *textfeed; + FWDV fwdv; +}; + +#endif diff --git a/Src/Wasabi/api/skin/feeds/feedwatcherso.cpp b/Src/Wasabi/api/skin/feeds/feedwatcherso.cpp new file mode 100644 index 00000000..af8d5ff0 --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/feedwatcherso.cpp @@ -0,0 +1,136 @@ +// ---------------------------------------------------------------------------- +// Generated by ScriptObjectFactory [Sat Sep 27 01:24:57 2003] +// +// File : +// Class : FeedWatcherScriptObject +// class layer : Automatic Object Scripting +// ---------------------------------------------------------------------------- +#include "precomp.h" + +#include "feedwatch.h" +#include "FeedWatcherSO.h" +// ScriptController Instance +static FeedWatcherScriptController _feedWatcherScriptController;FeedWatcherScriptController *feedWatcherScriptController = &_feedWatcherScriptController; + +// Function Descriptor Table +function_descriptor_struct FeedWatcherScriptController::exportedFunctions[] = { + { L"setFeed", 1, script_setFeed }, + { L"releaseFeed", 0, script_releaseFeed }, + { L"onFeedChange", 1, script_feedwatcher_onFeedChange }, +}; + +// Script Object Methods +FeedWatcherScriptObject::FeedWatcherScriptObject() { + if (!getScriptObject()) return; + feedWatcherScriptObject_init(); +} + +FeedWatcherScriptObject::~FeedWatcherScriptObject() { +} + +void FeedWatcherScriptObject::feedWatcherScriptObject_init() { + // Assign the script interface to this instance. + getScriptObject()->vcpu_setInterface(FeedWatcherGuid, (void *)static_cast(this)); + // Assign the class name to this instance. + getScriptObject()->vcpu_setClassName(L"FeedWatcher"); + // Assign the controller instance to this script object instance. + getScriptObject()->vcpu_setController(feedWatcherScriptController); +} + +// Script Object Methods + +void FeedWatcherScriptObject::feedwatcher_onFeedChange(const wchar_t *data) { + FeedWatcherScriptController::script_feedwatcher_onFeedChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(data)); +} + +scriptVar /*int */ FeedWatcherScriptController::script_setFeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *_pSO, scriptVar /*const char **/ feedid) { + // Begin all script methods with the init block. + SCRIPT_FUNCTION_INIT; + // Find the proper pointer for the "this" object, _pSO. + FeedWatcher*_pObj = static_cast(_pSO->vcpu_getInterface(FeedWatcherGuid)); + if (_pObj) { + return MAKE_SCRIPT_INT(_pObj->setFeed(GET_SCRIPT_STRING(feedid))); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar /*void */ FeedWatcherScriptController::script_releaseFeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *_pSO) { + // Begin all script methods with the init block. + SCRIPT_FUNCTION_INIT; + // Find the proper pointer for the "this" object, _pSO. + FeedWatcher*_pObj = static_cast(_pSO->vcpu_getInterface(FeedWatcherGuid)); + if (_pObj) { + // Then properly call the hosted object; + _pObj->releaseFeed(); + } + RETURN_SCRIPT_VOID; +} + +scriptVar /*void */ FeedWatcherScriptController::script_feedwatcher_onFeedChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *_pSO, scriptVar /*const char **/ data) { + // Begin all script methods with the init block + SCRIPT_FUNCTION_INIT; + // Honnor C++ hooks + PROCESS_HOOKS1(_pSO, feedWatcherScriptController, data); + // If there are no script hooks to execute, we abort here. + SCRIPT_FUNCTION_CHECKABORTEVENT; + // Otherwise we execute the script methods by calling this. + SCRIPT_EXEC_EVENT1(_pSO, data); +} + +// Script Controller + +// This method returns the human readable name of the class in script files. +const wchar_t *FeedWatcherScriptController::getClassName() { + return L"FeedWatcher"; +} + +// This method returns the human readable name of the parent of this class. +const wchar_t *FeedWatcherScriptController::getAncestorClassName() { + return FEEDWATCHER_SCRIPTPARENTCLASS; +} + +// This method returns the controller object for the parent class. +ScriptObjectController *FeedWatcherScriptController::getAncestorController() { + /* XML-Template-TODO : Support inheritance */ + return NULL; +} + +// This method returns the number of methods this class publishes. +int FeedWatcherScriptController::getNumFunctions() { + return sizeof(exportedFunctions) / sizeof(function_descriptor_struct); +} + +// This method returns the block of published function descriptors. +const function_descriptor_struct *FeedWatcherScriptController::getExportedFunctions() { + return exportedFunctions; +} + +// This method returns the GUID assigned to this script class. +GUID FeedWatcherScriptController::getClassGuid() { + return FeedWatcherGuid; +} + +// This method creates and returns a new script class instance. +ScriptObject *FeedWatcherScriptController::instantiate() { + FeedWatcher*_pObj = new FeedWatcher(); + ASSERT(_pObj != NULL); + return _pObj->getScriptObject(); +} + +// This method deletes a given script class instance. +void FeedWatcherScriptController::destroy(ScriptObject *o) { + FeedWatcher*_pObj = static_cast(o->vcpu_getInterface(FeedWatcherGuid)); + ASSERT(_pObj != NULL); + delete _pObj; +} + +// This method returns an encapsulated interface for the given instance. +void *FeedWatcherScriptController::encapsulate(ScriptObject *o) { + // No automatic encapsulation + return NULL; +} + +// This method frees a previously encapsulated interface. +void FeedWatcherScriptController::deencapsulate(void *o) { +} + diff --git a/Src/Wasabi/api/skin/feeds/feedwatcherso.h b/Src/Wasabi/api/skin/feeds/feedwatcherso.h new file mode 100644 index 00000000..852964fa --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/feedwatcherso.h @@ -0,0 +1,64 @@ +// ---------------------------------------------------------------------------- +// Generated by ScriptObjectFactory [Sat Sep 27 01:24:57 2003] +// +// File : +// Class : FeedWatcherScriptObject +// class layer : Automatic Object Scripting +// ---------------------------------------------------------------------------- + +#ifndef __FEEDWATCHERSCRIPTOBJECT_H +#define __FEEDWATCHERSCRIPTOBJECT_H + + +#include +#include + +#define FEEDWATCHER_SCRIPTPARENT RootObjectInstance +#define FEEDWATCHER_SCRIPTPARENTCLASS L"Object" + +class svc_textFeed; + +// ---------------------------------------------------------------------------- +// {A5376FA1-4E94-411a-83F6-05EC5EEA5F0A} +static const GUID FeedWatcherGuid = +{ 0xa5376fa1, 0x4e94, 0x411a, { 0x83, 0xf6, 0x5, 0xec, 0x5e, 0xea, 0x5f, 0xa } }; + +// ----------------------------------------------------------------------------- + +class FeedWatcherScriptObject : public FEEDWATCHER_SCRIPTPARENT { +public: + FeedWatcherScriptObject(); + virtual ~FeedWatcherScriptObject(); + + void feedWatcherScriptObject_init(); + +public: + virtual void feedwatcher_onFeedChange(const wchar_t *data); +}; + +// ----------------------------------------------------------------------------- +class FeedWatcherScriptController : public ScriptObjectControllerI { +public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + static scriptVar script_setFeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *_pSO, scriptVar feedid); + static scriptVar script_releaseFeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *_pSO); + static scriptVar script_feedwatcher_onFeedChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *_pSO, scriptVar data); + +private:static function_descriptor_struct exportedFunctions[]; +}; + +extern FeedWatcherScriptController *feedWatcherScriptController; +// ---------------------------------------------------------------------------- + +#endif // __FEEDWATCHERSCRIPTOBJECT_H diff --git a/Src/Wasabi/api/skin/feeds/textfeed.cpp b/Src/Wasabi/api/skin/feeds/textfeed.cpp new file mode 100644 index 00000000..feebe097 --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/textfeed.cpp @@ -0,0 +1,116 @@ +#include +#include "textfeed.h" +#include + +int TextFeed::registerFeed(const wchar_t *feedid, const wchar_t *initial_text, const wchar_t *description) +{ + //if (feeds.getItem(StringW(feedid))) + // return FALSE; + auto it = feeds.find(feedid); + if (feeds.end() != it) + { + return FALSE; + } + + //std::pair pair(initial_text, description); + + feeds.insert({ feedid, {initial_text, description} }); + + dependent_sendEvent(svc_textFeed::depend_getClassGuid(), Event_TEXTCHANGE, (intptr_t)feedid, (void*)initial_text, wcslen(initial_text) + 1); + return TRUE; +} + +int TextFeed::sendFeed(const wchar_t *feedid, const wchar_t *text) +{ + //Pair ft(L"", L""); + //if (!feeds.getItem(StringW(feedid), &ft)) + //{ + // //CUT ASSERTALWAYS("hey, you're trying to send a feed you didn't register. stop it."); + // DebugString("TextFeed::sendFeed(), feedid '%s' not registered", feedid); + // return FALSE; + //} + auto it = feeds.find(feedid); + if (feeds.end() == it) + { + return FALSE; + } + + //StringW id(feedid); + //feeds.getItem(id, &ft); + //ft.a = StringW(text); + //feeds.setItem(StringW(feedid), ft); + + auto &ft = feeds[feedid]; + ft.first = text; + + dependent_sendEvent(svc_textFeed::depend_getClassGuid(), Event_TEXTCHANGE, (intptr_t)feedid, (void*)text, wcslen(text) + 1); + return TRUE; +} + +const wchar_t *TextFeed::getFeedText(const wchar_t *name) +{ + //const Pair *ft = feeds.getItemRef(StringW(name)); + //if (ft == NULL) + // return NULL; + //ft->a.getValue(); + + auto it = feeds.find(name); + if (it == feeds.end()) + { + return NULL; + } + auto& ft = it->second; + return ft.first.c_str(); +} + +const wchar_t *TextFeed::getFeedDescription(const wchar_t *name) +{ + //const Pair *ft = feeds.getItemRef(StringW(name)); + //if (ft == NULL) return NULL; + //return ft->b.getValue(); + + auto it = feeds.find(name); + if (it == feeds.end()) + { + return NULL; + } + + auto& ft = it->second; + return ft.second.c_str(); +} + +int TextFeed::hasFeed(const wchar_t *name) +{ + return feeds.count(name); +} + +void TextFeed::dependent_onRegViewer(api_dependentviewer *viewer, int add) +{ + if (add) + { + //for (int i = 0; i < feeds.getNumItems(); i++) + //{ + // StringW a = feeds.enumIndexByPos(i, StringW(L"")); + // Pair sp(L"", L""); + // StringW b = feeds.enumItemByPos(i, sp).a; + // dependent_sendEvent(svc_textFeed::depend_getClassGuid(), Event_TEXTCHANGE, (intptr_t)a.getValue(), (void*)b.getValue(), b.len() + 1, viewer); //send to this viewer only + //} + + for (auto it = feeds.begin(); it != feeds.end(); it++) + { + std::wstring key = it->first; + auto val = it->second; + std::wstring val_first = val.first; + dependent_sendEvent(svc_textFeed::depend_getClassGuid(), Event_TEXTCHANGE, (intptr_t)key.c_str(), (void*)val_first.c_str(), wcslen(val_first.c_str()) + 1, viewer); //send to this viewer only + } + } + + if (add) onRegClient(); + else onDeregClient(); +} + +void *TextFeed::dependent_getInterface(const GUID *classguid) +{ + HANDLEGETINTERFACE(svc_textFeed); + return NULL; +} diff --git a/Src/Wasabi/api/skin/feeds/textfeed.h b/Src/Wasabi/api/skin/feeds/textfeed.h new file mode 100644 index 00000000..1c2d9bc1 --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/textfeed.h @@ -0,0 +1,57 @@ +#ifndef _TEXTFEED_H +#define _TEXTFEED_H + +#include +#include +#include +#include +#include +#include +#include + +/** + This is the standard helper class for implementing a textfeed. + Be sure to check out class EzFeed in ezfeed.h, which combines this + class with a service factory. +*/ +class TextFeed : public svc_textFeedI, public DependentI +{ +public: +/** + Call this to register your feeds by id. Make the ids unique! + @see sendFeed() + @ret TRUE if succeeded, FALSE on error (i.e. nonunique id) +*/ + int registerFeed(const wchar_t *feedid, const wchar_t *initial_text=L"", const wchar_t *description=L""); + +/** + Call this to send text into a feed. + @see registerFeed() + @ret TRUE if succeeded, FALSE on error (i.e. feedid not registered) +*/ + int sendFeed(const wchar_t *feedid, const wchar_t *text); + +// Gives the most recently sent text on a feed. + virtual const wchar_t *getFeedText(const wchar_t *feedid); + +// Gives a description for the feed (used by accessibility). + virtual const wchar_t *getFeedDescription(const wchar_t *feedid); + +protected: + virtual api_dependent *getDependencyPtr() { return this; } + virtual void dependent_onRegViewer(api_dependentviewer *viewer, int add); + virtual void *dependent_getInterface(const GUID *classguid); + +/** + Called when someone subscribes to this feed. +*/ + virtual void onRegClient() { } + virtual void onDeregClient() { } + + virtual int hasFeed(const wchar_t *name); + +private: + std::map > feeds; +}; + +#endif diff --git a/Src/Wasabi/api/skin/feeds/textfeedcb.cpp b/Src/Wasabi/api/skin/feeds/textfeedcb.cpp new file mode 100644 index 00000000..61542fb3 --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/textfeedcb.cpp @@ -0,0 +1,9 @@ +#include "precomp.h" +#if 0//CUT +#include "textfeedcb.h" + +#define CBCLASS TextFeedCallbackI +START_DISPATCH; + VCB(TEXTFEEDCB_ONRECEIVETEXT, textfeed_onReceiveText); +END_DISPATCH; +#endif diff --git a/Src/Wasabi/api/skin/feeds/textfeedcb.h b/Src/Wasabi/api/skin/feeds/textfeedcb.h new file mode 100644 index 00000000..da8d804a --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/textfeedcb.h @@ -0,0 +1,34 @@ +#error this file is going away +#if 0 +#ifndef __TEXTFEEDCB_H +#define __TEXTFEEDCB_H + +#include "dispatch.h" +#include "../common/common.h" + +class TextFeedCallback : public Dispatchable { + public: + + void textfeed_onReceiveText(const wchar_t *text); + + enum { + TEXTFEEDCB_ONRECEIVETEXT = 10, + }; +}; + +inline void TextFeedCallback::textfeed_onReceiveText(const wchar_t *text) { + _voidcall(TEXTFEEDCB_ONRECEIVETEXT, text); +} + +class TextFeedCallbackI : public TextFeedCallback { + public: + TextFeedCallbackI() {} + virtual ~TextFeedCallbackI() {} + + virtual void textfeed_onReceiveText(const wchar_t *text)=0; + + protected: + RECVS_DISPATCH; +}; +#endif +#endif diff --git a/Src/Wasabi/api/skin/gammamgr.cpp b/Src/Wasabi/api/skin/gammamgr.cpp new file mode 100644 index 00000000..9df1c88e --- /dev/null +++ b/Src/Wasabi/api/skin/gammamgr.cpp @@ -0,0 +1,135 @@ +#include +#include +#include "gammamgr.h" +#include +#include +#include + + + +void GammaMgr::init() +{ + skinXML.registerCallback(L"WinampAbstractionLayer\fgammaset", &xmlreader); //back compat + skinXML.registerCallback(L"WinampAbstractionLayer\fgammaset\fgammagroup", &xmlreader); //back compat + skinXML.registerCallback(L"WasabiXML\fgammaset", &xmlreader); + skinXML.registerCallback(L"WasabiXML\fgammaset\fgammagroup", &xmlreader); + + curset = -1; +} + +void GammaMgr::deinit() +{ + WASABI_API_COLORTHEMES->deleteAllGammaSets(); + skinXML.unregisterCallback(&xmlreader); +} + +void GammaMgr::onBeforeLoadingGammaGroups() +{ + WASABI_API_COLORTHEMES->deleteAllGammaSets(); + curset = -1; +} + +void GammaMgr::onAfterLoadingGammaGroups() +{} + +void GammaMgr::loadDefault() +{ + WASABI_API_COLORTHEMES->StartTransaction(); +#ifdef ON_LOAD_EXTRA_COLORTHEMES + ON_LOAD_EXTRA_COLORTHEMES(); +#endif + WASABI_API_COLORTHEMES->EndTransaction(); + + if (WASABI_API_COLORTHEMES->getGammaSet() == NULL) + { + wchar_t txt[256] = {0}; + WASABI_API_CONFIG->getStringPrivate(StringPrintfW(L"Color Themes/%s", WASABI_API_SKIN->getSkinName()), txt, 256, L"Default"); + WASABI_API_COLORTHEMES->setGammaSet(txt); + } +} + +int GammaMgr::gammaEqual(const wchar_t *id1, const wchar_t *id2) +{ + const wchar_t *a = WASABI_API_PALETTE->getGammaGroupFromId(id1); + const wchar_t *b = WASABI_API_PALETTE->getGammaGroupFromId(id2); + if (!a || !b) return 1; + return !WCSICMP(a, b); +} + +void GammaMgrXmlReader::xmlReaderOnStartElementCallback(const wchar_t *xmltag, skin_xmlreaderparams *params) +{ + GammaMgr::xmlReaderOnStartElementCallback(xmltag, params); +} + +void GammaMgr::xmlReaderOnStartElementCallback(const wchar_t *xmltag, skin_xmlreaderparams *params) +{ + if (!WCSICMP(xmltag, L"gammaset")) + { + const wchar_t *id = params->getItemValue(L"id"); + WASABI_API_COLORTHEMES->resetGammaSet(id); + curset = WASABI_API_COLORTHEMES->newGammaSet(id); + } + else if (!WCSICMP(xmltag, L"gammagroup")) + { + const wchar_t *id = params->getItemValue(L"id"); + if (!id) // TODO: should we pop up a skin error msgbox? + return; + StringW value = params->getItemValue(L"value"); + int r = 0, g = 0, b = 0; + wchar_t *p = value.getNonConstVal(); + if (!p) // TODO: should we pop up a skin error msgbox? + return; + wchar_t *q = p; + while (q && *q && *q != ',') q++; + if (q && *q == ',') *q++ = 0; + r = WTOI(p); + if (*q) + { + p = q; + while (*q && *q != ',') q++; + if (*q == ',') *q++ = 0; + g = WTOI(p); + if (*q) b = WTOI(q); + } + + int makegray = params->getItemValueInt(L"gray"); + int boost = params->getItemValueInt(L"boost"); + if (!WCSICMP(id, L"General") && curset>=0) + { + ColorThemeGroup *generalgroup = WASABI_API_COLORTHEMES->enumColorThemeGroup(curset, -1); + if (generalgroup) + { + generalgroup->setRed(r); + generalgroup->setGreen(g); + generalgroup->setBlue(b); + generalgroup->setGray(makegray); + generalgroup->setBoost(boost); + } + } + else if (curset != -1) + { + ColorThemeGroupI new_group(id, r, g, b, makegray, boost); + WASABI_API_COLORTHEMES->addGammaGroup(curset, &new_group); + } + } + +} + +GammaMgrXmlReader GammaMgr::xmlreader; +int GammaMgr::curset; + +#define CBCLASS ColorThemeGroupI +START_DISPATCH; +CB(COLORTHEMEGROUPGETNAME, getName); +CB(COLORTHEMEGROUPGETRED, getRed); +CB(COLORTHEMEGROUPGETGREEN, getGreen); +CB(COLORTHEMEGROUPGETBLUE, getBlue); +CB(COLORTHEMEGROUPGETGRAY, getGray); +CB(COLORTHEMEGROUPGETBOOST, getBoost); +VCB(COLORTHEMEGROUPSETNAME, setName); +VCB(COLORTHEMEGROUPSETRED, setRed); +VCB(COLORTHEMEGROUPSETGREEN, setGreen); +VCB(COLORTHEMEGROUPSETBLUE, setBlue); +VCB(COLORTHEMEGROUPSETGRAY, setGray); +VCB(COLORTHEMEGROUPSETBOOST, setBoost); +END_DISPATCH; \ No newline at end of file diff --git a/Src/Wasabi/api/skin/gammamgr.h b/Src/Wasabi/api/skin/gammamgr.h new file mode 100644 index 00000000..1d09319e --- /dev/null +++ b/Src/Wasabi/api/skin/gammamgr.h @@ -0,0 +1,91 @@ +#ifndef _GAMMAMGR_H +#define _GAMMAMGR_H + +#include +#include + +#include +#include + + +class ColorThemeGroupI : public ColorThemeGroup +{ +public: + ColorThemeGroupI(const wchar_t *pname, int pred, int pgreen, int pblue, int pgray, int pboost) + : name(pname), red(pred), green(pgreen), blue(pblue), make_grayscale(pgray), boost_levels(pboost) { } + ColorThemeGroupI(ColorThemeGroup ©_group) + { + name = copy_group.getName(); + red = copy_group.getRed(); + green = copy_group.getGreen(); + blue = copy_group.getBlue(); + make_grayscale = copy_group.getGray(); + boost_levels = copy_group.getBoost(); + } + virtual const wchar_t *getName() { return name; } + virtual int getRed() { return red; } + virtual int getGreen() { return green; } + virtual int getBlue() { return blue; } + virtual int getGray() { return make_grayscale; } + virtual int getBoost() { return boost_levels; } + virtual void setName(const wchar_t *pname) { name = pname; } + virtual void setRed(int r) { red = r; } + virtual void setGreen(int g) { green = g; } + virtual void setBlue(int b) { blue = b; } + virtual void setGray(int g) { make_grayscale = g; } + virtual void setBoost(int b) { boost_levels = b; } + + protected: + RECVS_DISPATCH; + + StringW name; + int red; + int green; + int blue; + int make_grayscale; + int boost_levels; +}; + + + + +class GammaMgrXmlReader : public XmlReaderCallbackI +{ +public: + void xmlReaderOnStartElementCallback(const wchar_t *xmltag, skin_xmlreaderparams *params); +}; + +class GammaMgr +{ +public: + static void init(); + static void deinit(); + + static void onBeforeLoadingGammaGroups(); + static void onAfterLoadingGammaGroups(); + static int gammaEqual(const wchar_t *id1, const wchar_t *id2); + + static void xmlReaderOnStartElementCallback(const wchar_t *xmltag, skin_xmlreaderparams *params); + + static int filterBitmap(uint8_t *bits, int w, int h, int bpp, const wchar_t *element_id, const wchar_t *forcegroup=NULL); + static ARGB32 filterColor(ARGB32 color, const wchar_t *element_id, const wchar_t *forcegroup=NULL); +/* + static void setGammaSet(const wchar_t *set); + static int getNumGammaSets(); + static const wchar_t *enumGammaSet(int n); + static int getNumGammaGroups(const wchar_t *gammaset); + static const wchar_t *enumGammaGroup(const wchar_t *gammaset, int n); + static ColorThemeGroup *enumColorThemeGroup(int colorset, int colorgroup); + static ColorThemeGroup *getColorThemeGroup(const wchar_t *colorset, const wchar_t *colorgroup); + static void newGammaSet(const wchar_t *set); + static void updateGammaSet(const wchar_t *set); + static void renameGammaSet(const wchar_t *set, const wchar_t *newname); + static void deleteGammaSet(const wchar_t *set);*/ + static void loadDefault(); + +private: + static void onGammaSet(); + static GammaMgrXmlReader xmlreader; + static int curset; // current while parsing xml +}; +#endif diff --git a/Src/Wasabi/api/skin/group.h b/Src/Wasabi/api/skin/group.h new file mode 100644 index 00000000..e4a9ad5f --- /dev/null +++ b/Src/Wasabi/api/skin/group.h @@ -0,0 +1,366 @@ +#include "widgets/group.h" +#if 0 // not in use +#ifndef __GROUP_H +#define __GROUP_H + +#ifndef _NOSTUDIO + +class Group; +class Container; +class Layout; +class CfgItem; +class CfgGroup; +class SRegion; + +#include +#include +#include +#include +#include +#include +#include +#ifdef WASABI_COMPILE_CONFIG +#include +#endif // wasabi_compile_config + +#include + +#endif // _nostudio + +#include +#include +#ifdef WASABI_WIDGETS_GUIOBJECT +#include +#endif +// {80F0F8BD-1BA5-42a6-A093-3236A00C8D4A} +static const GUID cfgGroupGuid = +{ 0x80f0f8bd, 0x1ba5, 0x42a6, { 0xa0, 0x93, 0x32, 0x36, 0xa0, 0xc, 0x8d, 0x4a } }; + +#define RESIZE_MINW 96 +#define RESIZE_MINH 24 + +class XmlObject; + +class GroupScriptController : public GuiObjectScriptController { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController() { return guiController; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + virtual int getInstantiable(); + virtual ScriptObject *cast(ScriptObject *, GUID g); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern GroupScriptController *groupController; + +class XuiParam { + public: + XuiParam(const wchar_t *_param, const wchar_t *_value) : param(_param), value(_value) {} + virtual ~XuiParam() {} + StringW param; + StringW value; +}; + +#define GROUP_PARENT EmbeddedXuiObject + +class Group : public GROUP_PARENT { + +public: + Group(); + virtual ~Group(); + + int onPaint(Canvas *canvas); + + virtual int onResize(); + virtual int onPostedMove(); + virtual int onInit(); + virtual Container *getParentContainer(); + virtual int childNotify(ifc_window *child, int msg, intptr_t p1, intptr_t p2); + + virtual void setBaseTexture(const wchar_t *b, int regis=1); + virtual SkinBitmap *getBaseTexture(); + virtual ifc_window *getBaseTextureWindow(); + + virtual int setXmlParam(const wchar_t *paramname, const wchar_t *strvalue); + virtual int setXuiParam(int _xuihandle, int xuiid, const wchar_t *paramname, const wchar_t *strvalue); + virtual api_region *getRegion(); + virtual void setRegion(api_region *r); + void reloadDefaults(); + virtual int onGroupChange(const wchar_t *id); + virtual void autoResize(); + virtual void startScripts(); + + void onCreateObject(GuiObject *o); + GuiObject *getObject(const wchar_t *id); + + void sendNotifyToAllChildren(int notifymsg, int param1, int param2); + + int isDeleting() { return deleting; } + + void updatePos(GuiObject *o, RECT *r=NULL); + + AutoSkinBitmap *background; + int x, y; + + LPARAM wndHolder_getParentParam(int i=0); + + virtual void setDesignWidth(int w); + virtual void setDesignHeight(int h); + virtual int getDesignWidth(); + virtual int getDesignHeight(); + + virtual void invalidateWindowRegion(); + virtual void setRegionOp(int o); + virtual void setGroupContent(const wchar_t *id, SkinItem *specific_item, int scripts_enabled); + virtual const wchar_t *getGroupContentId(); + virtual SkinItem *getGroupContentSkinItem(); + virtual void setAutoWidthSource(const wchar_t *obj); + virtual void setAutoHeightSource(const wchar_t *obj); + + virtual void cancelCapture() {}; + virtual int getPreferences(int what); + + virtual const wchar_t *vcpu_getClassName(); + virtual ScriptObjectController *vcpu_getController() { return groupController; } + + int getNumObjects(); + ifc_window *enumObjects(int i); + + void addChild(GuiObject *g); + void removeChild(GuiObject *g); + +#ifdef WASABI_COMPILE_WNDMGR + virtual void mouseResize(int x, int y, int resizeway);// screen coords! + virtual void beginMove(); + virtual void beginScale(); + virtual void beginResize(); + virtual void endMove(); + virtual void endScale(); + virtual void endResize(); +#endif + + virtual int getAutoWidth(void); + virtual int getAutoHeight(void); + + virtual int isLayout(); + + void setDrawBackground(int t); + int getDrawBackground(void); + +#ifdef WASABI_COMPILE_CONFIG + static int isCfgGroup(Group *ptr); +#endif + + void addScript(int scriptid); + void deleteScripts(); + int enumScript(int n); + int getNumScripts(); + virtual int isDesktopAlphaSafe(); + virtual int isTransparencySafe(int excludeme=0); + + static int isGroup(Group *o); + const wchar_t *getBackgroundStr(); + int getWidthBasedOn(GuiObject *o=NULL); + int getHeightBasedOn(GuiObject *o=NULL); + + void fixPosition(); + + const wchar_t *embeddedxui_getEmbeddedObjectId() { return xui_embedded_id; } + virtual void onFillGroup(); + virtual int onUnknownXuiParam(const wchar_t *xmlattributename, const wchar_t *value); + + virtual ScriptObject *script_cast(GUID g); + + virtual void onMinMaxEnforcerChanged(); + virtual int isTransparencyForcedOff() { return 0; } + +protected: + static PtrList cfggrouplist; + +private: + StringW basetextureStr; + StringW xui_embedded_id; + + void invalidateScaledReg(); + void ensureScaledRegValid(); + + int resizing; + int size_w,size_h; + int cX,cY; + int captured; + POINT mousepos; + int propagatesize; + + PtrList xuiparams; + + int moving; + int mover; + int drawbackground; + RECT oldRect; + int groupmaxheight; + int groupmaxwidth; + int groupminheight; + int groupminwidth; + int lockminmax; +// int regionop; + TList scripts; + RegionI *subtractedreg; + static PtrList groups; + StringW backgroundstr; + StringW instanceid; + RegionI *reg; + RegionI *scaledreg; + int scaledregionvalid; + int autoregionop; + StringW content_id; + SkinItem *content_item; + int no_init_on_addchild; + StringW autoheightsource; + StringW autowidthsource; + GuiObject *lastheightsource; + GuiObject *lastwidthsource; + int lastgetwidthbasedon, lastgetheightbasedon; + + int default_w, default_h; + int design_w, design_h; + int scripts_enabled; + int xuihandle; + static XMLParamPair groupParams[]; +protected: + enum { + XUIGROUP_INSTANCEID=0, + XUIGROUP_BACKGROUND, + XUIGROUP_DRAWBACKGROUND, + XUIGROUP_DEFAULT_W, + XUIGROUP_DEFAULT_H, + XUIGROUP_MAXIMUM_H, + XUIGROUP_MAXIMUM_W, + XUIGROUP_MINIMUM_H, + XUIGROUP_MINIMUM_W, + XUIGROUP_PROPAGATESIZE, + XUIGROUP_LOCKMINMAX, + XUIGROUP_NAME, + XUIGROUP_AUTOWIDTHSOURCE, + XUIGROUP_AUTOHEIGHTSOURCE, + XUIGROUP_EMBED_XUI, + XUIGROUP_XUITAG, + XUIGROUP_INHERIT_GROUP, + XUIGROUP_INHERIT_CONTENT, + XUIGROUP_DESIGN_W, + XUIGROUP_DESIGN_H, + XUIGROUP_NUMPARAMS, + }; + +// FG> +// -- SCRIPT ----------------------------------------------------- +private: + PtrList script_objects; + PtrList gui_objects; + int deleting; + int skinpart; + int alpha; + int disable_update_pos; + +public: + void addObject(GuiObject *o); + void removeObject(GuiObject *o); + void setSkinPartId(int i) { skinpart = i; } + int getSkinPartId() { return skinpart; } + + static scriptVar script_vcpu_getObject(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj); + static scriptVar script_vcpu_getNumObjects(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_enumObject(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i); + static scriptVar script_vcpu_onCreateObject(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar ob); + static scriptVar script_vcpu_getMousePosX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getMousePosY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_subtractRegion(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar reg); + static scriptVar script_vcpu_isLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_autoResize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + + static void instantiate(Layout *l); + +}; + +extern const wchar_t groupXuiObjectStr[]; +extern char groupXuiSvcName[]; +class GroupXuiSvc : public XuiObjectSvc {}; + + +#ifdef WASABI_COMPILE_CONFIG + +class CfgGroupScriptController : public GroupScriptController { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController() { return groupController; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual int getInstantiable(); + + private: + + static function_descriptor_struct exportedFunction[]; +}; + +extern CfgGroupScriptController *cfgGroupController; + +class CfgGroup : public Group, public DependentViewerTPtr { + public: + + CfgGroup(); + virtual ~CfgGroup(); + + void setAttr(CfgItem *item, const wchar_t *name); + const wchar_t *vcpu_getClassName(); + virtual ScriptObjectController *vcpu_getController() { return cfgGroupController; } + + virtual int viewer_onEvent(CfgItem *item, int event, intptr_t param, void *ptr, size_t ptrlen); + virtual void dataChanged(); + + CfgItem *getCfgItem(); + const wchar_t *getAttributeName(); + const wchar_t *getCfgGuid() { return cfgguid; } + virtual int onInit(); + + static scriptVar script_vcpu_cfgGetInt(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_cfgSetInt(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v); + static scriptVar script_vcpu_cfgGetFloat(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_cfgSetFloat(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v); + static scriptVar script_vcpu_cfgGetString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_cfgSetString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v); + static scriptVar script_vcpu_cfgGetName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_cfgGetGuid(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_onCfgChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + + private: + + CfgItem *cfgitem; + StringW attrname; + StringW cfgguid; + static wchar_t txt[512]; +}; + +extern const wchar_t cfgGroupXuiObjectStr[]; +extern char cfgGroupXuiSvcName[]; +class CfgGroupXuiSvc : public XuiObjectSvc {}; + +#endif // wasabi_compile_config + + +#endif // group.h +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/skin/groupmgr.cpp b/Src/Wasabi/api/skin/groupmgr.cpp new file mode 100644 index 00000000..dea7672c --- /dev/null +++ b/Src/Wasabi/api/skin/groupmgr.cpp @@ -0,0 +1,51 @@ +#include +#include +#include +#include +#include +#include + +Group *GroupMgr::instantiate(const wchar_t *groupid, int grouptype, SkinItem *specific_item, int scripts_enabled) +{ + InCriticalSection in_cs(&cs_grp); + GuiObject *go = SkinParser::newDynamicGroup(groupid, grouptype, specific_item, 0, scripts_enabled); + Group *g = static_cast(go->guiobject_getScriptObject()->vcpu_getInterface(groupGuid)); + if (!g) return NULL; + grouplist.addItem(g); + return g; +} + +#ifdef WASABI_COMPILE_CONFIG + +Group *GroupMgr::instantiate(const wchar_t *groupid, CfgItem *i, const wchar_t *name, int scripts_enabled) { + InCriticalSection in_cs(&cs_grp); + CfgGroup *g = static_cast(instantiate(groupid, GROUP_CFGGROUP, NULL, scripts_enabled)); + ASSERTPR(g != NULL, StringPrintf("couldn't load groupid '%S'", groupid)); + g->setAttr(i, name); + grouplist.addItem(g); + return g; +} + +#endif + +int GroupMgr::destroy(Group *group) { + InCriticalSection in_cs(&cs_grp); + if (!grouplist.haveItem(group)) { + DebugStringW(L"you cannot destroy a group that you have not instatiated\n"); + return 0; + } + delete group; + grouplist.removeItem(group); + return 1; +} + +int GroupMgr::exists(const wchar_t *groupid) +{ + SkinItem *si = guiTree->getGroupDef(groupid); + if (si) return 1; + return 0; +} + + +PtrList GroupMgr::grouplist; +CriticalSection GroupMgr::cs_grp; diff --git a/Src/Wasabi/api/skin/groupmgr.h b/Src/Wasabi/api/skin/groupmgr.h new file mode 100644 index 00000000..4e4457ca --- /dev/null +++ b/Src/Wasabi/api/skin/groupmgr.h @@ -0,0 +1,42 @@ +#ifndef __GROUPMGR_H +#define __GROUPMGR_H + +#include +#include +#include +#include + +class Group; +class CfgItem; + +class ifc_window; +class SkinItem; + +class CfgGroupEntry +{ + public: + CfgGroupEntry(const wchar_t *_id, int _type) : id(_id), type(_type) {} + ~CfgGroupEntry() {} + + StringW id; + int type; +}; + +class GroupMgr +{ + public: + static Group *instantiate(const wchar_t *groupid, int grouptype=GROUP_GROUP, SkinItem *specific_item=NULL, int scripts_enabled=1); +#ifdef WASABI_COMPILE_CONFIG + static Group *instantiate(const wchar_t *groupid, CfgItem *i, const wchar_t *name, int scripts_enabled); +#endif + static int destroy(Group *group); + static int hasGroup(Group *g) { return grouplist.haveItem(g); } + static int getNumGroups() { return grouplist.getNumItems(); } + static int exists(const wchar_t *groupid); + + private: + static PtrList grouplist; + static CriticalSection cs_grp; +}; + +#endif diff --git a/Src/Wasabi/api/skin/groupwndcreate.cpp b/Src/Wasabi/api/skin/groupwndcreate.cpp new file mode 100644 index 00000000..adf5daa6 --- /dev/null +++ b/Src/Wasabi/api/skin/groupwndcreate.cpp @@ -0,0 +1,51 @@ +#include + +#include "groupwndcreate.h" + +#include +#include + +// 5/15/2002, removed serving of groups by guid xui param, guid is 'non-overriden window guaranteed', groupid is 'allow override implicitly' + +/*int GroupWndCreateSvc::testGuid(GUID g) { + return (GuiTree::getGroupDef(g) >= 0); +} + +api_window *GroupWndCreateSvc::createWindowByGuid(GUID g, api_window *parent) { + int n = GuiTree::getGroupDef(g); + if (n < 0) return NULL; + + return createGuiTreeItem(n, parent); +}*/ + +ifc_window *GroupWndCreateSvc::createWindowOfType(const wchar_t *windowtype, ifc_window *parent, int i) +{ + SkinItem *item = guiTree->enumGroupDefOfType(windowtype, i); + if (item == NULL) return NULL; + + return createGuiTreeItem(item, parent); +} + +ifc_window *GroupWndCreateSvc::createGuiTreeItem(SkinItem*item, ifc_window *parent) +{ + ifc_window *wnd = GroupMgr::instantiate(NULL, GROUP_GROUP, item); + if (!wnd) return NULL; + wnd->setParent(parent); + group_list.addItem(wnd); + num_group_list = group_list.getNumItems(); + return wnd; +} + +int GroupWndCreateSvc::destroyWindow(ifc_window *w) +{ + if (group_list.haveItem(w)) + { + group_list.removeItem(w); + WASABI_API_SKIN->group_destroy(w); + num_group_list = group_list.getNumItems(); + return 1; + } + return 0; +} + +int GroupWndCreateSvc::num_group_list = 0; diff --git a/Src/Wasabi/api/skin/groupwndcreate.h b/Src/Wasabi/api/skin/groupwndcreate.h new file mode 100644 index 00000000..c142e2c4 --- /dev/null +++ b/Src/Wasabi/api/skin/groupwndcreate.h @@ -0,0 +1,25 @@ +#ifndef __WNDCREATE_H +#define __WNDCREATE_H + +#include +#include + +class GroupWndCreateSvc : public svc_windowCreateI +{ +public: + static const char *getServiceName() { return "WindowType to Group window creator"; } + + virtual int testType(const wchar_t *windowtype) { return 1; } + // virtual int testGuid(GUID g) ; + // virtual ifc_window *createWindowByGuid(GUID g, ifc_window *parent); + virtual ifc_window *createWindowOfType(const wchar_t *windowtype, ifc_window *parent, int n); + virtual int destroyWindow(ifc_window *w); + + static int num_group_list; + +private: + ifc_window *createGuiTreeItem(SkinItem *item, ifc_window *parent); + PtrList group_list; +}; + +#endif diff --git a/Src/Wasabi/api/skin/guitree.cpp b/Src/Wasabi/api/skin/guitree.cpp new file mode 100644 index 00000000..e5196f28 --- /dev/null +++ b/Src/Wasabi/api/skin/guitree.cpp @@ -0,0 +1,379 @@ +#include +#include "guitree.h" +#include +#include +#ifdef WASABI_COMPILE_WNDMGR +#include +#endif +#include +#include + +GuiTree *guiTree=NULL; + +GuiTreeItem::GuiTreeItem(int type, const wchar_t *name, ifc_xmlreaderparams *p, int scriptid, const wchar_t *path, GUID g, const wchar_t *windowtype, const wchar_t *xuitag) +{ + if (p) + { + for (size_t i=0;i!=p->getNbItems();i++) + params.addItem(p->getItemName(i), p->getItemValue(i)); + } + object_type = type; + object_name = name; + scriptId = scriptid; + rootpath = path; + guid = g; + idx=-1; + seccount = incrementor++; + wndtype = windowtype; + tag = xuitag; +} + +int GuiTreeItem::incrementor=0; + +GuiTreeItem::~GuiTreeItem() { +} + +int GuiTreeItem::getScriptId() { + return scriptId; +} + +ifc_xmlreaderparams *GuiTreeItem::getParams() +{ + // TODO: benski> helps replicate old logic.. we really fix the parts of the code that are assuming getValue() always succeeds with this returned object + if (params.getNbItems()) + return ¶ms; + else + return 0; +} + +const wchar_t *GuiTreeItem::getXmlRootPath() { + return rootpath; +} + + +int GuiTreeItem::getType() { + return object_type; +} + +const wchar_t *GuiTreeItem::getName() +{ + return object_name; +} + +SkinItem *GuiTreeItem::getAncestor() { + if (object_type == XML_TAG_GROUPDEF) + return guiTree->getGroupDefAncestor(this); + if (object_type == XML_TAG_CONTAINER) + return guiTree->getContainerAncestor(this); + return NULL; +} + +GuiTree::GuiTree() { + cached=-1; + cachedtype=-1; + cached_guid_idx=-1; + cached_guid=INVALID_GUID; + lastdefinedgroupdef = NULL; +} + +GuiTree::~GuiTree() { + list.deleteAll(); + groupdefs.removeAll(); + wndtypes.removeAll(); + //groupdefsbyguid.removeAll(); +} + +void GuiTree::addItem(int object_type, const wchar_t *name, ifc_xmlreaderparams *params, int scriptid, const wchar_t *rootpath) { + cached = -1; + cached_guid_idx = -1; + GUID guid=INVALID_GUID; + const wchar_t *wtype=NULL; + int has_ancestor=0; + const wchar_t *xuitag=NULL; + + const wchar_t *_id = NULL; + if (params) + { + _id = params->getItemValue(L"id"); + xuitag = params->getItemValue(L"xuitag"); +#ifdef WASABI_COMPILE_WNDMGR + if (params->getItemValueInt(L"register_autopopup")) + AutoPopup::registerGroupId(scriptid, _id, params->getItemValue(L"name")); +#endif + const wchar_t *strguid = params->getItemValue(L"guid"); + if (strguid) + guid = nsGUID::fromCharW(strguid); + wtype = params->getItemValue(L"windowtype"); + } + if (object_type == XML_TAG_GROUPDEF && params) + { + has_ancestor = (getGroupDef(_id) != NULL); + } + + GuiTreeItem *item = new GuiTreeItem(object_type, name, params, scriptid, rootpath, guid, wtype, xuitag); + item->setIdx(list.getNumItems()); + list.addItem(item); + + if (object_type == XML_TAG_GROUPDEF && params) { + lastdefinedgroupdef = item; +// groupdefsbyguid.setAutoSort(0); + groupdefs.addItem(item); +// groupdefsbyguid.addItem(item); + if (wtype && *wtype) { + wndtypes.addItem(item); + deferredInvalidateType(wtype); + } + if (xuitag && *xuitag) { + xuigroupdefs.addItem(item); + } + if (has_ancestor) + deferredInvalidateGroup(_id); + } else if (object_type == XML_TAG_CONTAINER && params && (params->getItemValueInt(L"dynamic", 0) == 1)) { + containers_by_id.setAutoSort(0); + containers_by_id.addItem(item); + } +} + +int GuiTree::getNumObject() { + return list.getNumItems(); +} + +int GuiTree::getNumObject(int object_type) { + if (cachedtype == object_type && cached != -1) return cached; + int n=0; + for (int i=0;igetType() == object_type) + n++; + } + cachedtype = object_type; + cached = n; + return n; +} + +SkinItem *GuiTree::getObject(int object_type, int nth) { + int n=0; + for (int i=0;igetType() == object_type) { + if (n++ == nth) return it; + } + } + return NULL; +} + +SkinItem *GuiTree::getGroupDef(const wchar_t *id) +{ + return groupdefs.findLastItem(id); +} + +SkinItem *GuiTree::getXuiGroupDef(const wchar_t *xuitag) +{ + xuigroupdefs.sort(); // doesn't sort if not necessary + return xuigroupdefs.findLastItem(xuitag); +} + +SkinItem *GuiTree::getGroupDefAncestor(SkinItem *_item) +{ + //groupdefs.sort(); // doesn't sort if not necessary + int pos = -1; + GuiTreeItem *item = static_cast(_item); + if (!item) return NULL; + ASSERT(item->getParams() != NULL); + const wchar_t *iid = item->getParams()->getItemValue(L"id"); + + pos = groupdefs.searchItem(item); + if (pos <= 0) return NULL; + pos--; + + GuiTreeItem *ritem = groupdefs.enumItem(pos); + if (!ritem) return NULL; + ASSERT(ritem->getParams() != NULL); + if (WCSICMP(iid, ritem->getParams()->getItemValue(L"id"))) return NULL; + return ritem; +} + +SkinItem *GuiTree::getContainerAncestor(SkinItem *_item) { + int pos = -1; + GuiTreeItem *item = static_cast(_item); + if (!item) return NULL; + ASSERT(item->getParams() != NULL); + const wchar_t *iid = item->getParams()->getItemValue(L"id"); + + pos = containers_by_id.searchItem(item); + + if (pos <= 0) return NULL; + pos--; + + GuiTreeItem *ritem = containers_by_id.enumItem(pos); + if (!ritem) return NULL; + ASSERT(ritem->getParams() != NULL); + if (WCSICMP(iid, ritem->getParams()->getItemValue(L"id"))) return NULL; + return ritem; +} + + +/*int GuiTree::getGroupDef(GUID guid) { + groupdefsbyguid.sort(); // doesn't sort if not necessary + GuiTreeItem *item = groupdefsbyguid.findItem(reinterpret_cast(&guid)); + if (item) + return item->getIdx(); + return -1; +}*/ + +SkinItem *GuiTree::enumGroupDefOfType(const wchar_t *type, int n) { + int c = 0; + foreach(wndtypes) + GuiTreeItem *item = wndtypes.getfor(); + if (WCSCASEEQLSAFE(type, item->getWindowType())) { + if (c == n) { +/* if (item->getGuid() != INVALID_GUID) { // see if it has a GUID, in which case we need to instantiate the last overriden version + int n = getGroupDef(item->getGuid()); + if (n != -1) return n; + }*/ + // take its groupid and find its latest overriden version + ifc_xmlreaderparams *p = item->getParams(); + if (p) + { + const wchar_t *id = p->getItemValue(L"id"); + if (id) + { + SkinItem *m = getGroupDef(id); + if (m != NULL) return m; + } + } + return item; + } + c++; + } + endfor; + return NULL; +} + + +int GuiTree::getObjectType(SkinItem *item) { + GuiTreeItem *i = static_cast(item); + return i->getType(); +} + +PtrList *GuiTree::getList() { + return &list; +} + +PtrList *GuiTree::getGroupList() { + return &groupdefs; +} + +SkinItem *GuiTree::getContainerById(const wchar_t *id) +{ + containers_by_id.sort(); // doesn't sort if not necessary + return containers_by_id.findLastItem(id); +} + +void GuiTree::removeSkinPart(int scriptid) { + for (int i=0;igetScriptId() == scriptid) { + ifc_xmlreaderparams *par = item->getParams(); + if (item->getType() == XML_TAG_CONTAINER && par != NULL) { + int p = containers_by_id.searchItem(item); + if (p != -1) + containers_by_id.removeByPos(p); + } + if (item->getType() == XML_TAG_GROUPDEF && par != NULL) + { + const wchar_t *grpid = par->getItemValue(L"id"); + if (grpid) + { + int p = groupdefs.searchItem(item); + if (p != -1) + groupdefs.removeByPos(p); + p = xuigroupdefs.searchItem(item); + if (p != -1) + xuigroupdefs.removeByPos(p); + p = wndtypes.searchItem(item); + if (p != -1) { + deferredInvalidateType(item->getWindowType()); + wndtypes.removeByPos(p); + } + deferredInvalidateGroup(grpid); + } + } + delete item; + list.removeByPos(i); + i--; + } + } + foreach(list) + list.getfor()->setIdx(foreach_index); + endfor; +} + +void GuiTree::reset() { + list.deleteAll(); + groupdefs.removeAll(); + wndtypes.removeAll(); + xuigroupdefs.removeAll(); + containers_by_id.removeAll(); +} + +void GuiTree::deferredInvalidateGroup(const wchar_t *id) { + if (!Skin::isDynamicGroupReloadEnabled()) return; + if (!id || !*id) return; + StringW *s = new StringW; + s->setValue(id); + + GuiTreeCB *cb = new GuiTreeCB; + cb->cmd = INVALIDATEGRP; + cb->ptr = s; + + timerclient_postDeferredCallback(CB_GUITREE, reinterpret_cast(cb)); +} + +void GuiTree::deferredInvalidateType(const wchar_t *type) { + if (!Skin::isDynamicGroupReloadEnabled()) return; + StringW *s = new StringW; + s->setValue(type); + + GuiTreeCB *cb = new GuiTreeCB; + cb->cmd = INVALIDATETYPE; + cb->ptr = s; + + timerclient_postDeferredCallback(CB_GUITREE, reinterpret_cast(cb)); +} + +int GuiTree::timerclient_onDeferredCallback(intptr_t param1, intptr_t param2) +{ + if (param1 == CB_GUITREE) { + GuiTreeCB *c = reinterpret_cast(param2); + switch (c->cmd) { + case INVALIDATEGRP: { + StringW *s = reinterpret_cast(c->ptr); + WndInfo wi; + wi.groupid = s->getValue(); + wi.wndtype = NULL; + wi.guid = INVALID_GUID; + WASABI_API_SYSCB->syscb_issueCallback(SysCallback::WINDOW, WndCallback::GROUPCHANGE, reinterpret_cast(&wi)); + delete s; + break; + } + case INVALIDATETYPE: { + StringW *s = reinterpret_cast(c->ptr); + WndInfo wi; + ZERO(wi); + wi.wndtype = s->getValue(); + wi.guid = INVALID_GUID; + WASABI_API_SYSCB->syscb_issueCallback(SysCallback::WINDOW, WndCallback::TYPECHANGE, reinterpret_cast(&wi)); + delete s; + break; + } + } + return 1; + } + return GUITREE_PARENT::timerclient_onDeferredCallback(param1, param2); +} + +int GuiTree::getObjectIdx(SkinItem *item) { + if (item == NULL) return -1; + return (static_cast(item))->getIdx(); +} diff --git a/Src/Wasabi/api/skin/guitree.h b/Src/Wasabi/api/skin/guitree.h new file mode 100644 index 00000000..cdf74cf0 --- /dev/null +++ b/Src/Wasabi/api/skin/guitree.h @@ -0,0 +1,171 @@ +#ifndef __GUITREE_H +#define __GUITREE_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#define CB_GUITREE 0x987 + +#define INVALIDATEGRP 1 +#define INVALIDATETYPE 2 + +class GuiTreeCB { + public: + int cmd; + StringW *ptr; +}; + +class GuiTreeItem : public SkinItemI +{ + public: + GuiTreeItem(int type, const wchar_t *name, ifc_xmlreaderparams *p, int scriptid, const wchar_t *rootpath, GUID g, const wchar_t *windowtype, const wchar_t *xuitag); + virtual ~GuiTreeItem(); + virtual int getType(); + virtual const wchar_t *getName(); + virtual int getSkinPartId() { return getScriptId(); } + virtual int getScriptId(); + virtual ifc_xmlreaderparams *getParams(); + virtual const wchar_t *getXmlRootPath(); + virtual void setIdx(int i) { idx = i; } + virtual int getIdx() { return idx; } + virtual int getSecCount() { return seccount; } + virtual void setGuid(GUID g) { guid = g; } + virtual GUID getGuid() { return guid; } + virtual const wchar_t *getWindowType() { return wndtype; } + virtual const wchar_t *getXuiTag() { return tag; } + virtual void setXuiTag(const wchar_t *xuitag) { tag = xuitag; } + virtual SkinItem *getAncestor(); + + private: + XmlReaderParamsI params; + int object_type; + StringW object_name; + int scriptId; + StringW rootpath; + int idx; + int seccount; + GUID guid; + StringW wndtype; + StringW tag; + + static int incrementor; +}; + +class SortGuiTreeItem +{ +public: + static int compareItem(GuiTreeItem *p1, GuiTreeItem *p2) { + int r = WCSICMP(p1->getParams()->getItemValue(L"id"), p2->getParams()->getItemValue(L"id")); + if (!r) { + if (p1->getScriptId() < p2->getScriptId()) return -1; + if (p1->getScriptId() > p2->getScriptId()) return 1; + if (p1->getSecCount() < p2->getSecCount()) return -1; + if (p1->getSecCount() > p2->getSecCount()) return 1; + return 0; + } + return r; + } + static int compareAttrib(const wchar_t *attrib, GuiTreeItem *item) { + return WCSICMP(attrib, item->getParams()->getItemValue(L"id")); + } +}; + +class SortGuiTreeItemByXuiTag { +public: + static int compareItem(GuiTreeItem *p1, GuiTreeItem *p2) { + int r = WCSICMP(p1->getParams()->getItemValue(L"xuitag"), p2->getParams()->getItemValue(L"xuitag")); + if (!r) { + if (p1->getScriptId() < p2->getScriptId()) return -1; + if (p1->getScriptId() > p2->getScriptId()) return 1; + if (p1->getSecCount() < p2->getSecCount()) return -1; + if (p1->getSecCount() > p2->getSecCount()) return 1; + return 0; + } + return r; + } + static int compareAttrib(const wchar_t *attrib, GuiTreeItem *item) { + return WCSICMP(attrib, item->getParams()->getItemValue(L"xuitag")); + } +}; + +class SortGuiTreeItemByGuid +{ +public: + static int compareItem(GuiTreeItem *p1, GuiTreeItem *p2) { + GUID g1 = p1->getGuid(); + GUID g2 = p2->getGuid(); + if (g1 == g2) { + if (p1->getScriptId() < p2->getScriptId()) return -1; + if (p1->getScriptId() > p2->getScriptId()) return 1; + if (p1->getSecCount() < p2->getSecCount()) return -1; + if (p1->getSecCount() > p2->getSecCount()) return 1; + return 0; + } + return nsGUID::compare(g1, g2) < 0 ? -1 : 1; + } + static int compareAttrib(const wchar_t *attrib, GuiTreeItem *item) { + const GUID *g = reinterpret_cast(attrib); + ASSERT(g); + GUID g1 = *g; + GUID g2 = item->getGuid(); + if (g1 == g2) return 0; + return nsGUID::compare(g1, g2) < 0 ? -1 : 1; + } +}; + +#define GUITREE_PARENT TimerClientDI +class GuiTree : public GUITREE_PARENT { + public: + + GuiTree(); + virtual ~GuiTree(); + + void addItem(int object_type, const wchar_t *object_name, ifc_xmlreaderparams *params, int scriptId, const wchar_t *rootpath); + SkinItem *getGroupDef(const wchar_t *id); + SkinItem *enumGroupDefOfType(const wchar_t *type, int n); + SkinItem *getGroupDefAncestor(SkinItem *item); + SkinItem *getContainerAncestor(SkinItem *item); + //int getGroupDef(GUID g); + SkinItem *getXuiGroupDef(const wchar_t *xuitag); + int getObjectType(SkinItem *item); + int getNumObject(); // total number of objects + int getNumObject(int object_type); // return the number of objects of this type + SkinItem *getObject(int object_type, int nth); // get nth object_type, return its index + SkinItem *getContainerById(const wchar_t *id); + int getObjectIdx(SkinItem *item); + void reset(void); + PtrList *getList();; + PtrList *getGroupList();; + void removeSkinPart(int scriptid); + void deferredInvalidateGroup(const wchar_t *id); + void deferredInvalidateType(const wchar_t *type); + int timerclient_onDeferredCallback(intptr_t param1, intptr_t param2); + SkinItem *getLastDefinedGroup() { return lastdefinedgroupdef; } + SkinItem *enumGroupDef(int n) { return groupdefs.enumItem(n); } + int getNumGroupDefs() { return groupdefs.getNumItems(); } + + + private: + int cached; + int cachedtype; + PtrList list; + PtrListInsertMultiSorted groupdefs; +// PtrListQuickMultiSorted groupdefsbyguid; + PtrListQuickMultiSorted xuigroupdefs; + PtrListQuickMultiSorted containers_by_id; + PtrList wndtypes; + int cached_guid_idx; + GUID cached_guid; + SkinItem *lastdefinedgroupdef; +}; + +extern GuiTree *guiTree; + +#endif + diff --git a/Src/Wasabi/api/skin/nakedobject.cpp b/Src/Wasabi/api/skin/nakedobject.cpp new file mode 100644 index 00000000..9e0a3a78 --- /dev/null +++ b/Src/Wasabi/api/skin/nakedobject.cpp @@ -0,0 +1,34 @@ +#include +#include "nakedobject.h" + +NakedObject::NakedObject() { + reentry_onresize = 0; + reentry_onsetvisible = 0; +} + +int NakedObject::getPreferences(int what) { + return 0; +} + +int NakedObject::onResize() { + int rt = NAKEDOBJECT_PARENT::onResize(); + RECT r; + getClientRect(&r); + if (!reentry_onresize && r.left != r.right || r.top != r.bottom) { + reentry_onresize = 1; + resize(r.left, r.top, 0, 0); + reentry_onresize = 0; + } + return rt; +} + +void NakedObject::onSetVisible(int i) { + NAKEDOBJECT_PARENT::onSetVisible(i); + if (!i) return; + if (!reentry_onsetvisible) { + reentry_onsetvisible = 1; + setVisible(0); + reentry_onsetvisible = 0; + } +} + diff --git a/Src/Wasabi/api/skin/nakedobject.h b/Src/Wasabi/api/skin/nakedobject.h new file mode 100644 index 00000000..ad689533 --- /dev/null +++ b/Src/Wasabi/api/skin/nakedobject.h @@ -0,0 +1,24 @@ +#ifndef __NAKEDOBJECT_H +#define __NAKEDOBJECT_H + +#include + +// NakedObject, an invisible GuiObject + +#define NAKEDOBJECT_PARENT GuiObjectWnd + +class NakedObject : public GuiObjectWnd { + public: + NakedObject(); + virtual ~NakedObject() {} + + virtual int getPreferences(int what); + virtual int onResize(); + virtual void onSetVisible(int i); + + protected: + int reentry_onresize; + int reentry_onsetvisible; +}; + +#endif diff --git a/Src/Wasabi/api/skin/objectactuator.cpp b/Src/Wasabi/api/skin/objectactuator.cpp new file mode 100644 index 00000000..f9eb1ee1 --- /dev/null +++ b/Src/Wasabi/api/skin/objectactuator.cpp @@ -0,0 +1,106 @@ +#include +#include "objectactuator.h" +#include +#include +#include + +XMLParamPair ObjectActuator::params[]= +{ + {OBJECTACTUATOR_GROUP, L"GROUP"}, + {OBJECTACTUATOR_TARGET, L"TARGET"} +}; + +// ----------------------------------------------------------------------- +ObjectActuator::ObjectActuator() +{ + myxuihandle = newXuiHandle(); + CreateXMLParameters(myxuihandle); +} + +void ObjectActuator::CreateXMLParameters(int master_handle) +{ + //OBJECTACTUATOR_PARENT::CreateXMLParameters(master_handle); + int numParams = sizeof(params) / sizeof(params[0]); + hintNumberOfParams(myxuihandle, numParams); + for (int i = 0;i < numParams;i++) + addParam(myxuihandle, params[i], XUI_ATTRIBUTE_IMPLIED); +} + +// ----------------------------------------------------------------------- +ObjectActuator::~ObjectActuator() { +} + +// ----------------------------------------------------------------------- +int ObjectActuator::setXuiParam(int xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *value) { + if (xuihandle != myxuihandle) + return OBJECTACTUATOR_PARENT::setXuiParam(xuihandle, xmlattributeid, xmlattributename, value); + + switch (xmlattributeid) { + case OBJECTACTUATOR_TARGET: + if (actuator_wantTargetParam()) + actuator_setTarget(value); + break; + case OBJECTACTUATOR_GROUP: + if (actuator_wantGroupParam()) + actuator_setGroup(value); + break; + default: + return 0; + } + return 1; +} + +// ----------------------------------------------------------------------- +void ObjectActuator::actuator_setTarget(const wchar_t *value) { + objectsid = value; + if (isInited() && actuator_wantAutoPerform()) + performActions(); +} + +// ----------------------------------------------------------------------- +void ObjectActuator::actuator_setGroup(const wchar_t *value) { + groupid = value; +} + +// ----------------------------------------------------------------------- +int ObjectActuator::onInit() { + int rt = OBJECTACTUATOR_PARENT::onInit(); + + if (actuator_wantAutoPerform()) performActions(); + + return rt; +} + + +// ----------------------------------------------------------------------- +void ObjectActuator::performActions() +{ + ifc_window *group = getParent(); + + if (!groupid.isempty()) + { + GuiObject *o = getGuiObject()->guiobject_findObject(groupid); + if (o != NULL) { + group = o->guiobject_getRootWnd(); + } + } + + GuiObject *go = static_cast(group->getInterface(guiObjectGuid)); + if (go == NULL) { + DebugStringW(L"%s:group:%s\n", getActuatorTag(), groupid.getValue()); + return; + } + + ParamParser pp(objectsid); + for (int i=0;iguiobject_findObject(pp.enumItem(i)); + if (target != NULL) + actuator_onPerform(target); + else + DebugStringW(L"%s:%s/%s\n", getActuatorTag(), groupid.getValue(), objectsid.getValue()); + } +} + +const wchar_t *ObjectActuator::getActuatorTag() { + return L"ObjectActuator"; +} diff --git a/Src/Wasabi/api/skin/objectactuator.h b/Src/Wasabi/api/skin/objectactuator.h new file mode 100644 index 00000000..c5437a1c --- /dev/null +++ b/Src/Wasabi/api/skin/objectactuator.h @@ -0,0 +1,49 @@ +#ifndef __OBJECTACTUATOR_H +#define __OBJECTACTUATOR_H + +#include + +#define OBJECTACTUATOR_PARENT NakedObject + +// ----------------------------------------------------------------------- +// Your wnd object class +class ObjectActuator : public OBJECTACTUATOR_PARENT { + + public: + + ObjectActuator(); + virtual ~ObjectActuator(); + + virtual int onInit(); + virtual int setXuiParam(int xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *value); + + virtual void actuator_setTarget(const wchar_t *value); + virtual void actuator_setGroup(const wchar_t *value); + + virtual int actuator_wantTargetParam() { return 1; } + virtual int actuator_wantGroupParam() { return 1; } + virtual int actuator_wantAutoPerform() { return 1; } + virtual void actuator_onPerform(GuiObject *target) { } // called back n times for n targets found (separated by ';'), guaranteed non NULL + + virtual const wchar_t *getActuatorTag(); // for error msgs purposes + + +protected: + void performActions(); +/*static */void CreateXMLParameters(int master_handle); + private: + static XMLParamPair params[]; + int myxuihandle; + + + enum { + OBJECTACTUATOR_TARGET= 0, + OBJECTACTUATOR_GROUP, + }; + + StringW groupid; + StringW objectsid; +}; + + +#endif diff --git a/Src/Wasabi/api/skin/regioncache.cpp b/Src/Wasabi/api/skin/regioncache.cpp new file mode 100644 index 00000000..68dc58aa --- /dev/null +++ b/Src/Wasabi/api/skin/regioncache.cpp @@ -0,0 +1,32 @@ +#include "precomp.h" +#include "regioncache.h" + + +RegionServer *RegionCache::requestSkinRegion(const wchar_t *filename) +{ + int n = -1; + cache.findItem(filename, &n); + if (n == -1) return NULL; + + RegionCacheItem *el = cache.enumItem(n); +// if (el->region != NULL) el->region->getRegion()->debug(); + return el->region; +} + +void RegionCache::cacheSkinRegion(const wchar_t *filename, api_region *r) +{ + int n = -1; + cache.findItem(filename, &n); + if (n == -1) return; + RegionCacheItem *el = cache.enumItem(n); + ASSERT(el != NULL); + if (el->region != NULL) { + DebugString("Trying to cache a region but cache is already set!\n"); + return; + } + el->region = new CacheRegionServer(r); + //el->region->getRegion()->debug(); +} + + +PtrListQuickSorted RegionCache::cache; diff --git a/Src/Wasabi/api/skin/regioncache.h b/Src/Wasabi/api/skin/regioncache.h new file mode 100644 index 00000000..ea2df961 --- /dev/null +++ b/Src/Wasabi/api/skin/regioncache.h @@ -0,0 +1,53 @@ +#ifndef __REGIONCACHE_H +#define __REGIONCACHE_H + +#include +#include +#include + +class CacheRegionServer : public RegionServerI { + public: + CacheRegionServer(api_region *r) { + reg = new RegionI(r->getOSHandle()); + } + ~CacheRegionServer() { + delete reg; + } + + virtual api_region *getRegion() { + return reg; + } + + private: + RegionI *reg; +}; + +struct RegionCacheItem { + RegionCacheItem(const wchar_t *filename) : region(NULL) { } + virtual ~RegionCacheItem() { } + StringW filename; + CacheRegionServer *region; +}; + +class SortRegionCacheItem { +public: + static int compareItem(RegionCacheItem *p1, RegionCacheItem *p2) { + return WCSICMP(p1->filename, p2->filename); + } + static int compareAttrib(const wchar_t *attrib, RegionCacheItem *item) { + return WCSICMP(attrib, item->filename); + } +}; + + +class RegionCache { + public: + + static RegionServer *requestSkinRegion(const wchar_t *id); + static void cacheSkinRegion(const wchar_t *id, api_region *r); + + static PtrListQuickSorted cache; + static int getNumCaches() { return cache.getNumItems(); } +}; + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/skin/skin.cpp b/Src/Wasabi/api/skin/skin.cpp new file mode 100644 index 00000000..9348d4c9 --- /dev/null +++ b/Src/Wasabi/api/skin/skin.cpp @@ -0,0 +1,812 @@ +#include +#include +#include "skin.h" +#include +#include +#include +#include +#include +#include +//#include // CUT!! +#include +#include + +#ifdef WASABI_COMPILE_WNDMGR +#include +#endif + +#include +#include +#include +#include +#include + +#ifdef WASABI_COMPILE_PAINTSETS +#include +#endif + +#include + +#ifdef WIN32 +#include "resource.h" +#include "../Agave/Language/api_language.h" +#endif + +// Version number has now a style of x.yz (same as gen_ff version) +#define SKIN_LEGACY_VERSION 80.f // oldest supported is 0.8 +#define SKIN_VERSION 136.f // current version is 1.36 + +Skin *tha = NULL; + + +static wchar_t *loadSkinList = NULL, skName[64]; + +Skin::Skin() +{ + if (deferedskinset == NULL) + { + deferedskinset = new SkinTimer(); + } + base = NULL; + scaled = NULL; + scale_x = 0; + scale_y = 0; + validRgn = NULL; + resizing = FALSE; +} + +Skin::~Skin() +{ + if (this == tha) + { + delete deferedskinset; + deferedskinset = NULL; + } + delete validRgn; + validRgn = NULL; + delete base; + delete scaled; + if (this == tha) + { + if (loadSkinList) + { + FREE(loadSkinList); + loadSkinList = NULL; + } + } +} + +Skin *Skin::getCurSkin() +{ + return tha; +} + +void Skin::setSkinName(const wchar_t *newskinname, const wchar_t *skinpath) +{ + if (newskinname) + skinName = newskinname; + else + skinName = WASABI_API_LNGSTRINGW_BUF(IDS_NO_SKIN_LOADED_,skName,64); + + if (skinpath == NULL) + { + skinPath = WASABI_API_SKIN->getSkinsPath(); + skinPath.AppendFolder(newskinname); + } + else + { + skinPath = skinpath; + skinPath.AddBackslash(); + } +} + +const wchar_t *Skin::getSkinName() +{ + return skinName.getValue(); +} + +const wchar_t *Skin::getSkinPath() +{ + return skinPath.getValue(); +} + +const wchar_t *Skin::getDefaultSkinPath() +{ + defSkinPath = WASABI_API_SKIN->getSkinsPath(); + defSkinPath.AppendFolder(L"Default"); + return defSkinPath; +} + +void Skin::setBaseTexture(const wchar_t *b) +{ + if (b == NULL) + { + delete base; + base = NULL; + return ; + } + base = new AutoSkinBitmap(); + base->setBitmap(b); +} + +void Skin::rescaleBaseTexture(int w, int h) +{ + /* if (scaled != NULL && scale_x == w && scale_y == h) + return; + if ((resizing && (w > m_x || h > m_y)) || (!resizing && (w != m_x || h != m_y))) + { + delete scaled; + int lw = resizing ? maxw : w; + int lh = resizing ? maxh : h; + scaled = new BltCanvas(lw , lh); + m_x = lw; m_y = lh; + api_region *reg = new api_region(0,0,lw,lh); + scaled->selectClipRgn(reg); + delete reg; + lastw = w; + lasth = h; + } + // Empty valid region + if (validRgn) + validRgn->empty(); + else + validRgn = new api_region(); + scale_x = w; + scale_y = h;*/ +} + +void Skin::invalidateBaseTexture(Skin *s) +{ //FG + if (!s) s = tha; + if (s) s->_invalidateBaseTexture(); +} + +void Skin::invalidateAllBaseTextures() +{ //FG + tha->_invalidateBaseTexture(); + for (int i = 0;i < skinList.getNumItems();i++) + { + Skin *s = skinList.enumItem(i); + s->_invalidateBaseTexture(); + } +} + +void Skin::unloadAllBaseTextures() +{ + if (tha) tha->_unloadBaseTexture(); + for (int i = 0;i < skinList.getNumItems();i++) + { + Skin *s = skinList.enumItem(i); + s->_unloadBaseTexture(); + } +} + +void Skin::reloadAllBaseTextures() +{ + if (tha) tha->_reloadBaseTexture(); + for (int i = 0;i < skinList.getNumItems();i++) + { + Skin *s = skinList.enumItem(i); + s->_reloadBaseTexture(); + } + invalidateAllBaseTextures(); +} + +void Skin::_unloadBaseTexture() +{ + if (base) + base->reset(); +} + +void Skin::_reloadBaseTexture() +{ + if (!tha) return ; + + if (base) + base->reload(); +} + +void Skin::_invalidateBaseTexture(void) +{ //FG + if (validRgn) + validRgn->empty(); +} + +void Skin::registerBaseSkin(Skin *s, ifc_window *b) +{ + skinList.addItem(s); + baseList.addItem(b); +} + +Skin *Skin::unregisterBaseSkin(ifc_window *b) +{ + for (int i = 0;i < baseList.getNumItems();i++) + { + if (baseList.enumItem(i) == b) + { + Skin *s = skinList.enumItem(i); + baseList.delByPos(i); + skinList.delByPos(i); + if (baseList.getNumItems() == 0) + baseList.removeAll(); + if (skinList.getNumItems() == 0) + skinList.removeAll(); + return s; + } + } + return NULL; +} + +Skin *Skin::baseToSkin(ifc_window *b) +{ + if (b == NULL) return NULL; + for (int i = 0;i < baseList.getNumItems();i++) + if (baseList.enumItem(i) == b) + return skinList.enumItem(i); + return NULL; +} + +void Skin::renderBaseTexture(ifc_window *base, ifc_canvas *c, const RECT &r, ifc_window *dest, int alpha) +{ + renderBaseTexture(base, baseToSkin(base), c, r, dest, alpha); +} + +void Skin::renderBaseTexture(ifc_window *base, Skin *s, ifc_canvas *c, const RECT &r, ifc_window *dest, int alpha) +{ + ASSERT(tha != NULL); + if (!s) + { + DebugStringW(L"Warning, base texture from main wnd?!\n"); + s = tha; + } + + s->_renderBaseTexture(base, c, r, dest, alpha); +} + +void Skin::validateBaseTextureRect(RECT *r) +{ + /* if (!base) { + ASSERT(!(tha && this == tha)); + if (origbase) + base = new SkinBitmap(origbase, origbase->getWidth(), origbase->getHeight()); + else + base = new SkinBitmap(tha->base, tha->base->getWidth(), tha->base->getHeight()); + if (!base) return; + } + + // make a region with the rect we have to draw + api_region *newregion = new api_region(r); + + // check if newregion is enclosed in validRgn, put whatever is outside back into newregion + if (newregion->enclosed(validRgn, newregion)) { + delete newregion; + return; + } + // compute projected coordinates + RECT destRect, srcRect; + newregion->getRgnBox(&destRect); + srcRect.left = (int)(((float)destRect.left / scale_x) * base->getWidth()); + srcRect.right = (int)(((float)destRect.right / scale_x) * base->getWidth()); + srcRect.top = (int)(((float)destRect.top / scale_y) * base->getHeight()); + srcRect.bottom = (int)(((float)destRect.bottom / scale_y) * base->getHeight()); + + // stretch the relevant portion of the image + base->stretchRectToRect(scaled, &srcRect, &destRect); + + #if 0 //FG> debug purpose + HDC dc = GetDC(NULL); + BitBlt(dc, 0, 0, scale_x, scale_y, scaled->getHDC(), 0, 0, SRCCOPY); + ReleaseDC(NULL, dc); + #endif + + // add this region to the valid region + validRgn->add(newregion); + delete newregion;*/ +} + +#define SAFEROUND(d) ((float)(int)d == d) ? (int)d : (d - (float)(int)d > 0) ? ((int)d)+1 : ((int)d)-1 + +// FG> Please change this only if you REALLY know what you are doing. this needs to account for basewnd +// coordinates (start from 0,0), as well as virtualwnd (relative to parent), at any depth (group holding +// texture as 2nd group of the tree, and rendering the base texture in a basewnd in a virtual in the group), +// and should handle resized textures and scaled windows. ooch + +void Skin::_renderBaseTexture(ifc_window *wndbase, ifc_canvas *c, const RECT &r, ifc_window *dest, int alpha) +{ + // pick our basetexture + AutoSkinBitmap *b = base ? base : tha->base; + + if (!b) return ; + + // srcRect is the source rectangle in the basetexture + RECT srcRect; + // destProjectedRect is the basetexture rectangle projected to dest coordinates + RECT destProjectedRect; + + ifc_window *p = dest; + POINT pt; + int sx = 0, sy = 0; + while (p && p != wndbase) + { + if (!p->isVirtual()) + { + p->getPosition(&pt); + sx += pt.x; + sy += pt.y; + } + p = p->getParent(); + } + ASSERT(p); + + wndbase->getNonClientRect(&destProjectedRect); + destProjectedRect.left -= sx; + destProjectedRect.top -= sy; + destProjectedRect.right -= sx; + destProjectedRect.bottom -= sy; + + srcRect.left = 0; + srcRect.top = 0; + srcRect.right = b->getBitmap()->getWidth(); + srcRect.bottom = b->getBitmap()->getHeight(); + +#if 0//CUT + // NONPORTABLE + HDC hdc = c->getHDC(); + HRGN oldRgn = CreateRectRgn(0, 0, 0, 0); + HRGN newRgn = CreateRectRgnIndirect(&r); + + int cs = GetClipRgn(hdc, oldRgn); + + ExtSelectClipRgn(hdc, newRgn, (cs != 1) ? RGN_COPY : RGN_AND); + + b->getBitmap()->stretchToRectAlpha(c, &srcRect, &destProjectedRect, alpha); + + SelectClipRgn(hdc, cs ? oldRgn : NULL); + + DeleteObject(oldRgn); + DeleteObject(newRgn); +#endif + BaseCloneCanvas clone(c); + RegionI oldRgn, newRgn(&r); +#ifdef _WIN32 + int cs = clone.getClipRgn(&oldRgn); + if (cs) newRgn.andRegion(&oldRgn); + clone.selectClipRgn(&newRgn); + b->getBitmap()->stretchToRectAlpha(&clone, &srcRect, &destProjectedRect, alpha); + clone.selectClipRgn(cs ? &oldRgn : NULL); +#else +#warning port me + b->getBitmap()->stretchToRectAlpha(&clone, &srcRect, &destProjectedRect, alpha); +#endif +} + +wchar_t *Skin::enumLoadableSkins(int refresh) +{ + static size_t loadSkinListSize = 1024; + + if (loadSkinList) + { + if (!refresh) + return loadSkinList; + FREE(loadSkinList); + } + + loadSkinList = WMALLOC(loadSkinListSize); + loadSkinList[0] = 0; + + int first = 1; + ReadDir skins(L"skins"); + + while (skins.next()) + { + const wchar_t *filename = skins.getFilename(); + + wchar_t *ext = const_cast(Wasabi::Std::extension(filename)); + + if (skins.isDir() || !WCSICMP(ext, L"wal") || + !WCSICMP(ext, L"wsz") || !WCSICMP(ext, L"zip")) + { + if (!skins.isDotDir() && !skins.isDotDotDir()) + { + if (!skins.isDir() ) + { + if (ext && *ext) *(ext - 1) = 0; + } + + // check loadSkinList size + if ((wcslen(loadSkinList) + wcslen(filename) + 2) > loadSkinListSize) + { + loadSkinListSize *= 2; + loadSkinList = (wchar_t *)REALLOC(loadSkinList, sizeof(wchar_t) * loadSkinListSize); + } + + if (!first) + wcscat(loadSkinList, L"/"); + wcscat(loadSkinList, filename); + first = 0; + } + } + } + + return loadSkinList; +} + +int Skin::loadSkinPart(const wchar_t *xmlfile) +{ +#ifdef WASABI_COMPILE_COMPONENTS + WasabiKernelController *wkc = Main::getKernelController(); + if (wkc && !wkc->testSkinFile(xmlfile)) return -1; +#endif + + int id = WASABI_API_PALETTE->newSkinPart(); + SkinElementsMgr::onBeforeLoadingScriptElements(xmlfile, id); + SkinParser::loadScriptXml(xmlfile, id); + SkinElementsMgr::onAfterLoadingScriptElements(); +#ifdef WASABI_COMPILE_WNDMGR + SkinParser::startupContainers(id); +#endif + return id; +} + +void Skin::unloadSkinPart(int skinpartid) +{ + SkinElementsMgr::unloadScriptElements(skinpartid); + SkinParser::cleanupScript(skinpartid); +} + +int Skin::checkSkin(const wchar_t *skinname) +{ + OSFILETYPE fh = WFOPEN(StringPathCombine(WASABI_API_SKIN->getSkinPath(), L"skin.xml"), WF_READONLY_BINARY); + if (fh != OPEN_FAILED) + { + FCLOSE(fh); + // ok it's a wa3 skin, now check the skin version number in the xml file + SkinVersionXmlReader r(skinname); + if (!r.getWalVersion()) return CHKSKIN_ISWA3OLD; + #ifndef LC_NUMERIC + #define LC_NUMERIC 4 + #endif + float v = (float)(WTOF(r.getWalVersion()) * 100); // Since wa5.51 we will do a check for x.yz style + if (v < (SKIN_LEGACY_VERSION-0.5f)) return CHKSKIN_ISWA3OLD; + if (v > (SKIN_VERSION+0.5f)) return CHKSKIN_ISWA3FUTURE; + return CHKSKIN_ISWA3; + } + fh = WFOPEN(StringPathCombine(WASABI_API_SKIN->getSkinPath(), L"Main.bmp"), WF_READONLY_BINARY); + if (fh != OPEN_FAILED) + { + FCLOSE(fh); + return CHKSKIN_ISWA2; + } + return CHKSKIN_UNKNOWN; +} + +void Skin::toggleSkin(const wchar_t *skin_name, const wchar_t *skin_path, int deferred) +{ + StringW skinName = skin_name; + + if (sendAbortCallback(skinName)) return ; + + enable_group_reload = 0; + + StringW oldSkinPath = skinPath; + char title[32] = {0}; + setSkinName(skinName, skin_path); + int skinType = checkSkin(skinName); + skinPath = oldSkinPath; + +#ifdef WASABI_COMPILE_COMPONENTS + WasabiKernelController *wkc = Main::getKernelController(); + if (wkc && !wkc->testSkin(skinName)) skinType = CHKSKIN_DISALLOWED; +#endif + + switch (skinType) + { + case CHKSKIN_ISWA3OLD: + { +#ifdef WIN32 + WASABI_API_WND->appdeactivation_setbypass(1); + int ret = MessageBoxA(GetActiveWindow(), WASABI_API_LNGSTRING(IDS_SKIN_LOAD_FORMAT_OLD), + WASABI_API_LNGSTRING_BUF(IDS_SKIN_LOAD_WARNING,title,32), + MB_ICONWARNING | MB_YESNO); + WASABI_API_WND->appdeactivation_setbypass(0); + if (ret == IDNO) return ; +#else + DebugString( "The skin you are trying to load is meant for an older Winamp3 version.\n" ); +#endif + break; + } + case CHKSKIN_ISWA3FUTURE: + { +#ifdef WIN32 + WASABI_API_WND->appdeactivation_setbypass(1); + int ret = MessageBoxA(GetActiveWindow(), WASABI_API_LNGSTRING(IDS_SKIN_LOAD_FORMAT_TOO_RECENT), + WASABI_API_LNGSTRING_BUF(IDS_SKIN_LOAD_WARNING,title,32), + MB_ICONWARNING | MB_YESNO); + WASABI_API_WND->appdeactivation_setbypass(0); + if (ret == IDNO) return ; +#else + DebugString( "The skin you are trying to load is meant for an older Winamp3 version.\n" ); +#endif + break; + } + case CHKSKIN_UNKNOWN: +#ifdef WIN32 + WASABI_API_WND->appdeactivation_setbypass(1); + MessageBoxA(GetActiveWindow(), WASABI_API_LNGSTRING(IDS_SKIN_LOAD_NOT_SUPPORTED), + WASABI_API_LNGSTRING_BUF(IDS_ERROR,title,32), MB_ICONERROR); + WASABI_API_WND->appdeactivation_setbypass(0); +#else + DebugString( "The skin you are trying to load is meant for an older Winamp3 version.\n" ); +#endif + return ; + + case CHKSKIN_DISALLOWED: + + // kernel controller should output its own error message + + return ; + + case CHKSKIN_ISWA2: break; + } + + WASABI_API_COLORTHEMES->StartTransaction(); + if (skin_loaded) + { + sendUnloadingCallback(); + } + + loading = 1; + + if (skin_loaded) + { + //ComponentManager::detachAllTemporary(); + //ComponentManager::destroyAllCompContainer(); + +#ifdef WASABI_COMPILE_WNDMGR + #ifdef WASABI_COMPILE_CONFIG + #ifndef WASABI_WNDMGR_NORESPAWN + skinEmbedder->saveState(); +#endif + #endif + #endif + + // unload current skin + SkinParser::cleanUp(); + + delete(tha); + tha = NULL; + //delete(VCPU::scriptManager); + + unloadResources(); + + // TODO: benski> unload WAC files inside skin. + // we should have saved a list of WacComponent * when loading + // add a new method ComponentManager::unload(WacComponent *); + + Skin::sendResetCallback(); + + // VCPU::scriptManager = new ScriptObjectManager(); + Skin *n = new Skin; + tha = n; + } + + setSkinName(skinName, skin_path); + + if (skin_loaded) + { + SkinElementsMgr::resetSkinElements(); + //SkinElementsMgr::loadSkinElements(skinName); // only loads element definitions, not actual bitmaps + + sendReloadCallback(); + + reloadResources(); + } + + // TODO: benski> load WAC files inside skin. save list of WacComponent * to a list to unload later + // make ComponentManager::load() return the WacComponent to allow this + +#ifdef WASABI_COMPILE_WNDMGR + int ncont = SkinParser::loadContainers(skinName); //sends guiloaded cb +#endif + + GammaMgr::loadDefault(); + +#ifdef WASABI_COMPILE_WNDMGR + SkinParser::startupContainers(); +#ifdef WASABI_COMPILE_CONFIG +#ifndef WASABI_WNDMGR_NORESPAWN + skinEmbedder->restoreSavedState(); +#endif +#endif +#endif + + enable_group_reload = 1; + + sendLoadedCallback(); + +#ifdef WASABI_COMPILE_WNDMGR + SkinParser::centerSkin(); +#endif + + loading = 0; + +#ifdef WASABI_COMPILE_WNDMGR +#ifdef WA3COMPATIBILITY + if (ncont == 0) + SkinParser::emmergencyReloadDefaultSkin(); +#endif +#endif + skin_loaded = 1; + WASABI_API_COLORTHEMES->EndTransaction(); +} + +void Skin::unloadSkin() +{ + if (!skin_loaded) return ; + + sendUnloadingCallback(); + + loading = -1; + +#ifdef WASABI_COMPILE_WNDMGR + #ifdef WASABI_COMPILE_CONFIG + #ifndef WASABI_WNDMGR_NORESPAWN + skinEmbedder->saveState(); +#endif + #endif + #endif + + // unload current skin + SkinParser::cleanUp(); + + delete(tha); + tha = NULL; + //delete(VCPU::scriptManager); + + unloadResources(); + + Skin::sendResetCallback(); + + // VCPU::scriptManager = new ScriptObjectManager(); + Skin *n = new Skin; + tha = n; + + setSkinName(WASABI_API_LNGSTRINGW_BUF(IDS_NO_SKIN_LOADED_,skName,64)); + + SkinElementsMgr::resetSkinElements(); + //SkinElementsMgr::loadSkinElements(skinName); // only loads element definitions, not actual bitmaps + + sendReloadCallback(); + + reloadResources(); + loading = 0; + skin_loaded = 0; +} + +void Skin::sendUnloadingCallback() +{ +#if defined(WASABI_COMPILE_COMPONENTS) | defined(GEN_FF) // MULTIAPI-FIXME!! + ComponentManager::broadcastNotify(WAC_NOTIFY_SKINUNLOADING, WASABI_API_PALETTE->getSkinPartIterator()); +#endif + WASABI_API_SYSCB->syscb_issueCallback(SysCallback::SKINCB, SkinCallback::UNLOADING); +} + +int Skin::sendAbortCallback(const wchar_t *skinname) +{ + int a = 0; + WASABI_API_SYSCB->syscb_issueCallback(SysCallback::SKINCB, SkinCallback::CHECKPREVENTSWITCH, (intptr_t)skinname, (intptr_t)&a); + return a; +} + +void Skin::sendResetCallback() +{ + WASABI_API_SYSCB->syscb_issueCallback(SysCallback::SKINCB, SkinCallback::RESET); +} + +void Skin::sendReloadCallback() +{ +#if defined(WASABI_COMPILE_COMPONENTS) | defined(GEN_FF) // MULTIAPI-FIXME!! + ComponentManager::broadcastNotify(WAC_NOTIFY_SWITCHINGSKIN, WASABI_API_PALETTE->getSkinPartIterator()); // this msg primilarily here to insert stuff between unloading of the old skin and reloading of the new one +#endif + WASABI_API_SYSCB->syscb_issueCallback(SysCallback::SKINCB, SkinCallback::RELOAD); +} + +void Skin::sendBeforeLoadingElementsCallback() +{ +#if defined(WASABI_COMPILE_COMPONENTS) | defined(GEN_FF) // MULTIAPI-FIXME!! + ComponentManager::broadcastNotify(WAC_NOTIFY_BEFORELOADINGSKINELEMENTS, WASABI_API_PALETTE->getSkinPartIterator()); // this msg primilarily here to insert stuff between unloading of the old skin and reloading of the new one +#endif + WASABI_API_SYSCB->syscb_issueCallback(SysCallback::SKINCB, SkinCallback::BEFORELOADINGELEMENTS); +} + +void Skin::sendGuiLoadedCallback() +{ + WASABI_API_SYSCB->syscb_issueCallback(SysCallback::SKINCB, SkinCallback::GUILOADED); +} + +void Skin::sendLoadedCallback() +{ +#if defined(WASABI_COMPILE_COMPONENTS) | defined(GEN_FF) // MULTIAPI-FIXME!! + ComponentManager::broadcastNotify(WAC_NOTIFY_SKINLOADED, WASABI_API_PALETTE->getSkinPartIterator()); +#endif + WASABI_API_SYSCB->syscb_issueCallback(SysCallback::SKINCB, SkinCallback::LOADED); +} + +void Skin::setSkinReady(int i) +{ + loading = !i; +} + +void Skin::main_notifySkinLoaded() +{ + skin_loaded = 1; +} + +int Skin::isSkinReady() +{ + return !loading; +} + +int Skin::unloadResources() +{ + if (windowTracker) + { + for (int i = 0;i < windowTracker->getNumAllWindows();i++) + { + ifc_window *w = windowTracker->enumAllWindows(i); +#ifdef _WIN32 + if (w) w->wndProc(w->gethWnd(), WM_WA_RELOAD, 0, 0); +#else +#warning port me +#endif + } + Skin::unloadAllBaseTextures(); +#ifdef WASABI_COMPILE_PAINTSETS + paintset_reset(); +#endif + + } + + sendResetCallback(); + + return 1; +} + +int Skin::reloadResources() +{ + if (windowTracker) + { + for (int i = 0;i < windowTracker->getNumAllWindows();i++) + { + ifc_window *w = windowTracker->enumAllWindows(i); +#ifdef _WIN32 + if (w) w->wndProc(w->gethWnd(), WM_WA_RELOAD, 1, 0); +#else +#warning port me +#endif + } + Skin::reloadAllBaseTextures(); + } + + sendReloadCallback(); + + return 1; +} + +bool Skin::isLoaded() +{ + return !!skin_loaded; +} + +PtrList Skin::skinList; +PtrList Skin::baseList; +StringW Skin::skinName; +StringW Skin::skinPath; +int Skin::isDefaultSkin = 0; +int Skin::loading = 0; +int Skin::highest_id = 0; +int Skin::reloadingskin = 0; +int Skin::enable_group_reload = 0; +StringW Skin::defSkinPath; +SkinTimer *Skin::deferedskinset = NULL; +int Skin::skin_loaded = 0; \ No newline at end of file diff --git a/Src/Wasabi/api/skin/skin.h b/Src/Wasabi/api/skin/skin.h new file mode 100644 index 00000000..0f9da315 --- /dev/null +++ b/Src/Wasabi/api/skin/skin.h @@ -0,0 +1,150 @@ +#ifndef _SKIN_H +#define _SKIN_H + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class SkinBitmap; +#include "SkinVersion.h" + +#define CB_SETSKINDEFERRED 0x5492 + +class SkinTimer; + +class Skin +{ +public: + enum { + CHKSKIN_UNKNOWN = -1, + CHKSKIN_ISWA3 = 1, + CHKSKIN_ISWA3OLD = 2, + CHKSKIN_ISWA3FUTURE = 3, + CHKSKIN_ISWA2 = 4, + CHKSKIN_DISALLOWED = 5, + }; + + Skin(); + virtual ~Skin(); + + static const wchar_t *getSkinName(); + static void setSkinName(const wchar_t *newskinname, const wchar_t *skinpath = NULL); + static const wchar_t *getSkinPath(); + static const wchar_t *getDefaultSkinPath(); + static Skin *getCurSkin(); + + void setBaseTexture(const wchar_t *b); + + //CUT static int registerCallback(SkinCallback *cb); + //CUT static int deregisterCallback(SkinCallback *cb); + + static void renderBaseTexture(ifc_window *base, Skin *s, ifc_canvas *c, const RECT &r, ifc_window *dest, int alpha = 255); + static void renderBaseTexture(ifc_window *s, ifc_canvas *c, const RECT &r, ifc_window *dest, int alpha = 255); + + static void invalidateBaseTexture(Skin *s); + static void invalidateAllBaseTextures(); + static Skin *baseToSkin(ifc_window *b); + static void registerBaseSkin(Skin *s, ifc_window *b); + static Skin *unregisterBaseSkin(ifc_window *b); + + + static void unloadAllBaseTextures(); + static void reloadAllBaseTextures(); + void _unloadBaseTexture(); + void _reloadBaseTexture(); + + static wchar_t *enumLoadableSkins(int refresh = FALSE); + + static int checkSkin(const wchar_t *name); + static void toggleSkin(const wchar_t *name, const wchar_t *skin_path = NULL, int deferred = 0); + static void unloadSkin(); + static void parseSkinFilename(const wchar_t *filename, const wchar_t *incpath); + static int isDefaultSkin; + static void sendUnloadingCallback(); + static int sendAbortCallback(const wchar_t *skinname); + static void sendResetCallback(); + static void sendReloadCallback(); + static void sendBeforeLoadingElementsCallback(); + static void sendGuiLoadedCallback(); + static void sendLoadedCallback(); + static int isSkinReady(); + static void setSkinReady(int i); + static int isDynamicGroupReloadEnabled() { return enable_group_reload; } + static void unloadSkinPart(int id); + static int loadSkinPart(const wchar_t *xmlfile); + static void main_notifySkinLoaded(); + static int isLoading() { return loading; } + + static int unloadResources(); + static int reloadResources(); + static bool isLoaded(); +private: + void rescaleBaseTexture(int w, int h); + void _renderBaseTexture(ifc_window *base, ifc_canvas *c, const RECT &r, ifc_window *dest, int alpha); + void _invalidateBaseTexture(void); + void validateBaseTextureRect(RECT *r); + + AutoSkinBitmap *base; + BltCanvas *scaled; + int scale_x, scale_y; + bool forceinvalid; + int m_x, m_y; + int lastw, lasth, maxw, maxh; + bool resizing; + RegionI *validRgn; + static int loading; + static int enable_group_reload; + + static PtrList skinList; + static PtrList baseList; + + static StringW skinName; + static StringW skinPath; + static StringW defSkinPath; + static int highest_id; + static int reloadingskin; + static int skin_loaded; + + static SkinTimer *deferedskinset; +}; + +class SkinTimer : public TimerClientDI +{ +public : + SkinTimer() {} + virtual ~SkinTimer() {} + + void setSkinDeferred(const wchar_t *skinname) + { + skin = skinname; + timerclient_postDeferredCallback(CB_SETSKINDEFERRED, 0); + } + + virtual int timerclient_onDeferredCallback(intptr_t p1, intptr_t p2) + { + if (p1 == CB_SETSKINDEFERRED) + { + Skin::toggleSkin(skin); + skin.trunc(0); + } + else + return TimerClientDI::timerclient_onDeferredCallback(p1, p2); + return 1; + } + +private: + StringW skin; +}; + + +extern Skin *tha; + +#endif diff --git a/Src/Wasabi/api/skin/skinapi.cpp b/Src/Wasabi/api/skin/skinapi.cpp new file mode 100644 index 00000000..f68a0614 --- /dev/null +++ b/Src/Wasabi/api/skin/skinapi.cpp @@ -0,0 +1,347 @@ +#include +#include +#include "skinapi.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +api_skin *skinApi; +static waServiceTSingle groupWndCreate; + +SkinApi::SkinApi() +{ + lockui = 0; + tha = new Skin(); + SkinParser::initialize(); + + WASABI_API_SVC->service_register(&groupWndCreate); + + SkinElementsMgr::init(); + GammaMgr::init(); + + // fixed this for 5.58+ so it'll use the correct skins directory + // and not the winamp.exe folder + "skins" - fixes @SKINSPATH@ + // when the skins directory has been altered - from Bento notifier.xml + skinspath = WASABI_API_APP->path_getSkinSettingsPath(); +} + +SkinApi::~SkinApi() +{ + delete tha; tha = NULL; +#ifdef WASABI_COMPILE_WNDMGR + AutoPopup::reset(); +#endif + SkinElementsMgr::deinit(); + GammaMgr::deinit(); + WASABI_API_SVC->service_deregister(&groupWndCreate); + SkinParser::shutdown(); +} + +void SkinApi::preShutdown() +{ + Skin::unloadSkin(); + SkinElementsMgr::resetSkinElements(); +} + +ARGB32 SkinApi::skin_getColorElement(const wchar_t *type, const wchar_t **color_group) +{ + return WASABI_API_PALETTE->getColorElement(type, color_group); +} + +const ARGB32 *SkinApi::skin_getColorElementRef(const wchar_t *type, const wchar_t **color_group) +{ + return WASABI_API_PALETTE->getColorElementRef(type, color_group); +} + +const int *SkinApi::skin_getIterator() +{ + return WASABI_API_PALETTE->getSkinPartIteratorPtr(); +} + +void SkinApi::skin_switchSkin(const wchar_t *skin_name, const wchar_t *skin_path) +{ + if (skin_name && *skin_name) Skin::toggleSkin(skin_name, skin_path, 1); +} + +void SkinApi::skin_unloadSkin() +{ + Skin::unloadSkin(); +} + +const wchar_t *SkinApi::getSkinName() +{ + return Skin::getSkinName(); +} + +const wchar_t *SkinApi::getSkinPath() +{ + return Skin::getSkinPath(); +} + +const wchar_t *SkinApi::getSkinsPath() +{ + return skinspath; +} + +const wchar_t *SkinApi::getDefaultSkinPath() +{ + return Skin::getDefaultSkinPath(); +} + +ARGB32 *SkinApi::imgldr_requestSkinBitmap(const wchar_t *file, int *has_alpha, int *x, int *y, int *subw, int *subh, int *w, int *h, int cached) +{ + if (file == NULL) + { + DebugStringW(L"illegal param : file == NULL\n"); + return NULL; + } + return imageLoader::requestSkinBitmap(file, has_alpha, x, y, subw, subh, w, h, cached); +} + +void SkinApi::imgldr_releaseSkinBitmap(ARGB32 *bmpbits) +{ + if (bmpbits == NULL) + { + DebugStringW(L"illegal param : bmpbits == NULL\n"); + return ; + } + imageLoader::releaseSkinBitmap(bmpbits); +} + +ARGB32 SkinApi::filterSkinColor(ARGB32 color, const wchar_t *elementid, const wchar_t *groupname) +{ + return imageLoader::filterSkinColor(color, elementid, groupname); +} + +void SkinApi::reapplySkinFilters() +{ + imageLoader::applySkinFilters(); +} + +/* ---------------------------------------- */ +int SkinApi::colortheme_getNumColorSets() +{ + return WASABI_API_COLORTHEMES->getNumGammaSets(); +} + +const wchar_t *SkinApi::colortheme_enumColorSet(int n) +{ + return WASABI_API_COLORTHEMES->enumGammaSet(n); +} + +int SkinApi::colortheme_getNumColorGroups(const wchar_t *colorset) +{ + return WASABI_API_COLORTHEMES->getNumGammaGroups(colorset); +} + +const wchar_t *SkinApi::colortheme_enumColorGroupName(const wchar_t *colorset, int n) +{ + return WASABI_API_COLORTHEMES->enumGammaGroup(colorset, n); +} + +ColorThemeGroup *SkinApi::colortheme_enumColorGroup(int colorset, int colorgroup) +{ + return WASABI_API_COLORTHEMES->enumColorThemeGroup(colorset, colorgroup); +} + +ColorThemeGroup *SkinApi::colortheme_getColorGroup(const wchar_t *colorset, const wchar_t *colorgroup) +{ + return WASABI_API_COLORTHEMES->getColorThemeGroup(colorset, colorgroup); +} + +void SkinApi::colortheme_setColorSet(const wchar_t *colorset) +{ + WASABI_API_COLORTHEMES->setGammaSet(colorset); + // TODO: benski> move this to a syscallback: SysCallback::SKINCB, SkinCallback::COLORTHEMECHANGED + WASABI_API_CONFIG->setStringPrivate(StringPrintfW(L"Color Themes/%s", getSkinName()), colorset); +} + +const wchar_t *SkinApi::colortheme_getColorSet() +{ + return WASABI_API_COLORTHEMES->getGammaSet(); +} + +void SkinApi::colortheme_newColorSet(const wchar_t *set) +{ + WASABI_API_COLORTHEMES->newGammaSet(set); +} + +void SkinApi::colortheme_updateColorSet(const wchar_t *set) +{ + WASABI_API_COLORTHEMES->updateGammaSet(set); +} + +void SkinApi::colortheme_renameColorSet(const wchar_t *set, const wchar_t *newname) +{ + WASABI_API_COLORTHEMES->renameGammaSet(set, newname); +} + +void SkinApi::colortheme_deleteColorSet(const wchar_t *set) +{ + WASABI_API_COLORTHEMES->deleteGammaSet(set); +} + + /* -------------------------------------------- */ + +int SkinApi::loadSkinFile(const wchar_t *xmlfile) +{ + return Skin::loadSkinPart(xmlfile); +} + +void SkinApi::unloadSkinPart(int skinpartid) +{ + Skin::unloadSkinPart(skinpartid); +} + +ifc_window *SkinApi::group_create(const wchar_t *groupid, int scripts_enabled) +{ + return GroupMgr::instantiate(groupid, GROUP_GROUP, NULL, scripts_enabled); +} + +int SkinApi::group_destroy(ifc_window *group) +{ + return GroupMgr::destroy(static_cast(group)); +} + +int SkinApi::group_exists(const wchar_t *groupid) +{ + return GroupMgr::exists(groupid); +} + +#ifdef WASABI_COMPILE_CONFIG +ifc_window *SkinApi::group_create_cfg(const wchar_t *groupid, CfgItem *cfgitem, const wchar_t *attributename, int scripts_enabled) +{ + return GroupMgr::instantiate(groupid, cfgitem, attributename, scripts_enabled); +} +#endif // WASABI_COMPILE_CONFIG + +#ifdef WASABI_COMPILE_WNDMGR +ifc_window *SkinApi::group_create_layout(const wchar_t *groupid, int scripts_enabled) +{ + return GroupMgr::instantiate(groupid, GROUP_LAYOUTGROUP, NULL, scripts_enabled); +} +#endif //WASABI_COMPILE_WNDMGR + +OSCURSOR SkinApi::cursor_request(const wchar_t *id) +{ + return CursorMgr::requestCursor(id); +} + +int SkinApi::parse(const wchar_t *str, const wchar_t *how) +{ + return SkinParser::parse(str, how); +} + +GuiObject *SkinApi::xui_new(const wchar_t *classname) +{ + return SkinParser::xui_new(classname); +} + +void SkinApi::xui_delete(GuiObject *o) +{ + SkinParser::xui_delete(o); +} + +int SkinApi::getNumGroupDefs() +{ + return guiTree->getNumGroupDefs(); +} + +SkinItem *SkinApi::enumGroupDef(int n) +{ + return guiTree->enumGroupDef(n); +} + +ifc_window *SkinApi::group_createBySkinItem(SkinItem *item, int scripts_enabled) +{ + return GroupMgr::instantiate(NULL, GROUP_GROUP, item, scripts_enabled); +} + +SkinItem *SkinApi::getGroupDefAncestor(SkinItem *item) +{ + return guiTree->getGroupDefAncestor(item); +} + +int SkinApi::groupdef_getNumObjects(SkinItem *_item) +{ + GuiTreeItem *item = static_cast(_item); + int idx = item->getIdx(); + idx++; + int n = 0; + while (1) + { + GuiTreeItem *it = guiTree->getList()->enumItem(idx); + if (it->getType() == XML_TAG_GROUPDEF && it->getParams() == NULL) break; + idx++; n++; + } + return n; +} + +SkinItem *SkinApi::groupdef_enumObject(SkinItem *_item, int n) +{ + GuiTreeItem *item = static_cast(_item); + int idx = item->getIdx(); + idx++; + int _n = 0; + GuiTreeItem *it = NULL; + while (1) + { + it = guiTree->getList()->enumItem(idx); + if (it->getType() == XML_TAG_GROUPDEF && it->getParams() == NULL) break; + if (n == _n) break; + idx++; _n++; + } + return it; +} + +int SkinApi::loadGroupDefData(const wchar_t *groupdef, SkinItem **lastgroupdef) +{ + StringW s; + s = L"buf:"; + + s += L"" + L""; + + s += groupdef; + + s += L""; + + int r = Skin::loadSkinPart(s); + if (lastgroupdef != NULL) + *lastgroupdef = guiTree->getLastDefinedGroup(); + return r; +} + +double SkinApi::skin_getVersion() +{ + return SkinParser::getSkinVersion(); +} +#ifdef WASABI_COMPILE_IMGLDR +ARGB32 SkinApi::skin_getBitmapColor(const wchar_t *id) +{ + SkinBitmap bitmap(id); + BltCanvas c(bitmap.getWidth() + 1, bitmap.getHeight() + 1, 0); // TODO: this won't work on the mac i don't think + bitmap.blit(&c, 0, 0); + int x = bitmap.getWidth() / 2; + int y = bitmap.getHeight() / 2; + int *bits = (int *)c.getBits(); + if (bits != NULL) + { + return bits[x + y*bitmap.getWidth() + 1]; + } + return 0xFFFF00FF; +} +#endif + +bool SkinApi::skin_isLoaded() +{ + return Skin::isLoaded(); +} \ No newline at end of file diff --git a/Src/Wasabi/api/skin/skinapi.h b/Src/Wasabi/api/skin/skinapi.h new file mode 100644 index 00000000..b4cedc99 --- /dev/null +++ b/Src/Wasabi/api/skin/skinapi.h @@ -0,0 +1,79 @@ +#ifndef __SKINAPI_H +#define __SKINAPI_H + +#include +#include +#include +#include + +class SkinApi : public api_skinI +{ + public: + + SkinApi(); + virtual ~SkinApi(); + virtual void preShutdown(); + + virtual ARGB32 skin_getColorElement(const wchar_t *type, const wchar_t **color_group = NULL); + virtual const ARGB32 *skin_getColorElementRef(const wchar_t *type, const wchar_t **color_group = NULL); + virtual const int *skin_getIterator(); + virtual void skin_switchSkin(const wchar_t *skin_name, const wchar_t *skin_path); + virtual void skin_unloadSkin(); + virtual const wchar_t *getSkinName(); + virtual const wchar_t *getSkinPath(); + virtual const wchar_t *getSkinsPath(); + virtual const wchar_t *getDefaultSkinPath(); + virtual ARGB32 *imgldr_requestSkinBitmap(const wchar_t *file, int *has_alpha, int *x, int *y, int *subw, int *subh, int *w, int *h, int cached); + virtual void imgldr_releaseSkinBitmap(ARGB32 *bmpbits); + virtual ARGB32 filterSkinColor(ARGB32 color, const wchar_t *elementid, const wchar_t *groupname); + virtual void reapplySkinFilters(); + virtual int colortheme_getNumColorSets(); + virtual const wchar_t *colortheme_enumColorSet(int n); + virtual int colortheme_getNumColorGroups(const wchar_t *colorset); + virtual const wchar_t *colortheme_enumColorGroupName(const wchar_t *colorset, int n); + virtual ColorThemeGroup *colortheme_enumColorGroup(int colorset, int n); + virtual ColorThemeGroup *colortheme_getColorGroup(const wchar_t *colorset, const wchar_t *group); + virtual void colortheme_setColorSet(const wchar_t *colorset); + virtual const wchar_t *colortheme_getColorSet(); + virtual void colortheme_newColorSet(const wchar_t *set); + virtual void colortheme_updateColorSet(const wchar_t *set); + virtual void colortheme_renameColorSet(const wchar_t *set, const wchar_t *newname); + virtual void colortheme_deleteColorSet(const wchar_t *set); + virtual int loadSkinFile(const wchar_t *xmlfile); + virtual int loadGroupDefData(const wchar_t *groupdef, SkinItem **lastgroupitem); + virtual void unloadSkinPart(int skinpartid); + virtual ifc_window *group_create(const wchar_t *groupid, int scripts_enabled=1); + virtual int group_exists(const wchar_t *groupid); +#ifdef WASABI_COMPILE_CONFIG + virtual ifc_window *group_create_cfg(const wchar_t *groupid, CfgItem *cfgitem, const wchar_t *attributename, int scripts_enabled=1); +#endif // WASABI_COMPILE_CONFIG +#ifdef WASABI_COMPILE_WNDMGR + virtual ifc_window *group_create_layout(const wchar_t *groupid, int scripts_enabled=1); +#endif //WASABI_COMPILE_WNDMGR + virtual int group_destroy(ifc_window *group); + virtual int parse(const wchar_t *str, const wchar_t *how); + virtual GuiObject *xui_new(const wchar_t *classname); + virtual void xui_delete(GuiObject *o); + virtual OSCURSOR cursor_request(const wchar_t *id); + + virtual int getNumGroupDefs(); + virtual SkinItem *enumGroupDef(int n); + virtual ifc_window *group_createBySkinItem(SkinItem *item, int scripts_enabled=1); + virtual SkinItem *getGroupDefAncestor(SkinItem *item); + virtual int groupdef_getNumObjects(SkinItem *item); + virtual SkinItem *groupdef_enumObject(SkinItem *groupitem, int n); + virtual void skin_setLockUI(int l) { if (l) lockui++; else if (lockui) lockui--; } + virtual int skin_getLockUI() { return lockui; } + virtual double skin_getVersion(); +#ifdef WASABI_COMPILE_IMGLDR + virtual ARGB32 skin_getBitmapColor(const wchar_t *id); +#endif + bool skin_isLoaded(); + + private: + + StringW skinspath; + int lockui; +}; + +#endif diff --git a/Src/Wasabi/api/skin/skinbmps.h b/Src/Wasabi/api/skin/skinbmps.h new file mode 100644 index 00000000..dab8568c --- /dev/null +++ b/Src/Wasabi/api/skin/skinbmps.h @@ -0,0 +1,122 @@ +#ifndef _SKINBMPS_H +#define _SKINBMPS_H +/* +typedef enum { + SKIN_BITMAP_UNKNOWN, + + // Base texture + SKIN_BITMAP_BASE_TEXTURE, + + // Framewnd + SKIN_BITMAP_FRAME_VERTICAL_DIVIDER, + SKIN_BITMAP_FRAME_HORIZONTAL_DIVIDER, + + // Listwnd/Treewnd + SKIN_BITMAP_LIST_BACKGROUND, + SKIN_BITMAP_TREE_BACKGROUND, + + // Appctrl + SKIN_BITMAP_APPCTRL_LEFTARROW_NONPRESSED, + SKIN_BITMAP_APPCTRL_LEFTARROW_PRESSED, + SKIN_BITMAP_APPCTRL_RIGHTARROW_NONPRESSED, + SKIN_BITMAP_APPCTRL_RIGHTARROW_PRESSED, + SKIN_BITMAP_APPCTRL_WINDOWSIZER, + SKIN_BITMAP_APPCTRL_PLAYERMODE_NONPRESSED, + SKIN_BITMAP_APPCTRL_PLAYERMODE_PRESSED, + SKIN_BITMAP_APPCTRL_MINIMIZE_NONPRESSED, + SKIN_BITMAP_APPCTRL_MINIMIZE_PRESSED, + SKIN_BITMAP_APPCTRL_MAXIMIZE_NONPRESSED, + SKIN_BITMAP_APPCTRL_MAXIMIZE_PRESSED, + SKIN_BITMAP_APPCTRL_CLOSE_NONPRESSED, + SKIN_BITMAP_APPCTRL_CLOSE_PRESSED, + SKIN_BITMAP_APPCTRL_SYSTEMICON, + SKIN_BITMAP_APPCTRL_PLACEHOLDER_LEFT, + SKIN_BITMAP_APPCTRL_PLACEHOLDER_MIDDLE, + SKIN_BITMAP_APPCTRL_PLACEHOLDER_RIGHT, + SKIN_BITMAP_APPCTRL_TITLEBAR, + + // Controls + SKIN_BITMAP_PLAYBACKCONTROLS_PREVIOUS_NONPRESSED, + SKIN_BITMAP_PLAYBACKCONTROLS_PREVIOUS_PRESSED, + SKIN_BITMAP_PLAYBACKCONTROLS_PLAY_NONPRESSED, + SKIN_BITMAP_PLAYBACKCONTROLS_PLAY_PRESSED, + SKIN_BITMAP_PLAYBACKCONTROLS_PAUSE_NONPRESSED, + SKIN_BITMAP_PLAYBACKCONTROLS_PAUSE_PRESSED, + SKIN_BITMAP_PLAYBACKCONTROLS_STOP_NONPRESSED, + SKIN_BITMAP_PLAYBACKCONTROLS_STOP_PRESSED, + SKIN_BITMAP_PLAYBACKCONTROLS_NEXT_NONPRESSED, + SKIN_BITMAP_PLAYBACKCONTROLS_NEXT_PRESSED, + + // Paintset + SKIN_BITMAP_LABEL_UPPERLEFT, + SKIN_BITMAP_LABEL_TOP, + SKIN_BITMAP_LABEL_UPPERRIGHT, + SKIN_BITMAP_LABEL_LEFT, + SKIN_BITMAP_LABEL_MIDDLE, + SKIN_BITMAP_LABEL_RIGHT, + SKIN_BITMAP_LABEL_LOWERLEF, + SKIN_BITMAP_LABEL_BOTTOM, + SKIN_BITMAP_LABEL_LOWERRIGHT, + SKIN_BITMAP_APPBORDER_UPPERLEFT, + SKIN_BITMAP_APPBORDER_TOP, + SKIN_BITMAP_APPBORDER_UPPERRIGHT, + SKIN_BITMAP_APPBORDER_LEFT, + SKIN_BITMAP_APPBORDER_RIGHT, + SKIN_BITMAP_APPBORDER_LOWERLEFT, + SKIN_BITMAP_APPBORDER_BOTTOM, + SKIN_BITMAP_APPBORDER_LOWERRIGHT, + + // Seeker + SKIN_BITMAP_SEEKBAR_LEFT, + SKIN_BITMAP_SEEKBAR_MIDDLE, + SKIN_BITMAP_SEEKBAR_RIGHT, + SKIN_BITMAP_SEEKBAR_BUTTON_NONPRESSED, + SKIN_BITMAP_BUTTON_PRESSED, + + // Status + SKIN_BITMAP_STATUSBAR_LEFT, + SKIN_BITMAP_STATUSBAR_MIDDLE, + SKIN_BITMAP_STATUSBAR_RIGHT, + + // Volbar + SKIN_BITMAP_VOLBAR_LEFT, + SKIN_BITMAP_VOLBAR_MIDDLE, + SKIN_BITMAP_VOLBAR_RIGHT, + SKIN_BITMAP_VOLBAR_BUTTON_NONPRESSED, + SKIN_BITMAP_VOLBAR_BUTTON_PRESSED, + + // Titlewnd + SKIN_BITMAP_COMPONENT_PROP_TOP, + SKIN_BITMAP_COMPONENT_PROP, + SKIN_BITMAP_COMPONENT_PROP_MIDDLE, + SKIN_BITMAP_COMPONENT_PROP_BOTTOM, + + // Videownd + SKIN_BITMAP_MOVIE_BACKGROUND, + + // Seditwnd + SKIN_BITMAP_AVS_SCRIPT_MARKER, + SKIN_BITMAP_AVS_SCRIPT_PLAY_NONPRESSED, + SKIN_BITMAP_AVS_SCRIPT_PLAY_PRESSED, + SKIN_BITMAP_AVS_SCRIPT_PAUSE_NONPRESSED, + SKIN_BITMAP_AVS_SCRIPT_PAUSE_PRESSED, + SKIN_BITMAP_AVS_SCRIPT_STOP_NONPRESSED, + SKIN_BITMAP_AVS_SCRIPT_STOP_PRESSED, + SKIN_BITMAP_AVS_SCRIPT_TIMEARROW, + SKIN_BITMAP_AVS_SCRIPT_BACKGROUND, + SKIN_BITMAP_AVS_SCRIPT_ZOOMER_TOP, + SKIN_BITMAP_AVS_SCRIPT_ZOOMER_MIDDLE, + SKIN_BITMAP_AVS_SCRIPT_ZOOMER_BOTTOM, + SKIN_BITMAP_AVS_SCRIPT_ZOOMER_BUTTON_NONPRESSED, + SKIN_BITMAP_AVS_SCRIPT_ZOOMER_BUTTON_PRESSED, + +// ComponentAPI1 ends here + NUM_SKIN_BITMAP_ELEMENT_IDS +} SkinBitmapElementId; + +typedef struct { + SkinBitmapElementId id; + char *fn; + } SkinBitmapTableElement; +*/ +#endif diff --git a/Src/Wasabi/api/skin/skinelem.cpp b/Src/Wasabi/api/skin/skinelem.cpp new file mode 100644 index 00000000..45d1a39f --- /dev/null +++ b/Src/Wasabi/api/skin/skinelem.cpp @@ -0,0 +1,316 @@ +#include +#include +#include "skinelem.h" +#include +#include +#include +#include +#include +#include +#include +#include + +xml_elementtag elementtaglist[] = + { + {L"bitmap", XML_ELEMENTTAG_BITMAP, 0}, + {L"bitmapfont", XML_ELEMENTTAG_BITMAPFONT, 0}, + {L"color", XML_ELEMENTTAG_COLOR, 0}, + {L"cursor", XML_ELEMENTTAG_CURSOR, 0}, + {L"elements", XML_ELEMENTTAG_ELEMENTS, 1}, + {L"elementalias", XML_ELEMENTTAG_ELEMENTALIAS, 0}, + {L"truetypefont", XML_ELEMENTTAG_TRUETYPEFONT, 0}, + }; + +//------------------------- + + + + + + + +//------------------------- + +void SkinElementsMgr::init() +{ + if (!quickxmltaglist.getNumItems()) + { + for (int i = 0;i < sizeof(elementtaglist) / sizeof(xml_elementtag);i++) + quickxmltaglist.addItem(&elementtaglist[i]); + } + skinXML.registerCallback(L"WinampAbstractionLayer\felements\f*", &xmlreader); //back compat + skinXML.registerCallback(L"WasabiXML\felements\f*", &xmlreader); +} + +void SkinElementsMgr::deinit() +{ + resetSkinElements(); + skinXML.unregisterCallback(&xmlreader); +} + +void SkinElementsMgr::onBeforeLoadingSkinElements(const wchar_t *_rootpath) +{ + Skin::sendBeforeLoadingElementsCallback(); + elementScriptId = WASABI_API_PALETTE->newSkinPart(); + + WASABI_API_PALETTE->StartTransaction(); + + rootpath = _rootpath; + original_rootpath = rootpath; + last_includepath = L""; +} + +void SkinElementsMgr::onAfterLoadingSkinElements() +{ + WASABI_API_PALETTE->EndTransaction(); + +#ifdef WASABI_COMPILE_COMPONENTS + ComponentManager::broadcastNotify(WAC_NOTIFY_SKINELEMENTSLOADED, Skin::getSkinPartIterator()); +#endif +} + +void SkinElementsXmlReader::xmlReaderOnEndElementCallback(const wchar_t *xmltag) +{ + SkinElementsMgr::xmlReaderOnEndElementCallback(xmltag); +} + +void SkinElementsMgr::xmlReaderOnEndElementCallback(const wchar_t *xmltag) +{ + xml_elementtag *i = quickxmltaglist.findItem(xmltag); + if (!i) return ; + if (i->id == XML_ELEMENTTAG_ELEMENTS) + { + if (inelements) + inelements = 0; + } +} + +void SkinElementsXmlReader::xmlReaderOnStartElementCallback(const wchar_t *xmltag, skin_xmlreaderparams *params) +{ + SkinElementsMgr::xmlReaderOnStartElementCallback(xmltag, params); +} + +void SkinElementsMgr::xmlReaderOnStartElementCallback(const wchar_t *xmltag, skin_xmlreaderparams *params) +{ + xml_elementtag *i = quickxmltaglist.findItem(xmltag); + if (i) + _xmlReaderOnStartElementCallback( i->id, xmltag, params); + else + _xmlReaderOnStartElementCallback( XML_ELEMENTTAG_UNKNOWN, xmltag, params); +} + +void SkinElementsMgr::_xmlReaderOnStartElementCallback(int tagid, const wchar_t *xmltag, skin_xmlreaderparams *params) +{ + const wchar_t *ic = skinXML.getIncludePath(); + if (WCSICMP(ic, last_includepath)) + { + last_includepath = skinXML.getIncludePath(); + rootpath = getSkinRootpathFromIncludePath(last_includepath, original_rootpath); + } + // If we're loading from a buffer, there should be no rootpath prefix. + if (!WCSNICMP(rootpath, L"buf:", 4)) + { + rootpath = NULL; + } + if (tagid == XML_ELEMENTTAG_ELEMENTALIAS) + { + WASABI_API_PALETTE->AddAlias(params->getItemValue(L"id"), params->getItemValue(L"target")); + } + else if (tagid == XML_ELEMENTTAG_BITMAP) + { + StringW id; + const wchar_t *fn; + id = params->getItemValue(L"id"); + fn = params->getItemValue(L"file"); + int x = params->getItemValueInt(L"x", -1); + int y = params->getItemValueInt(L"y", -1); + int w = params->getItemValueInt(L"w", -1); + int h = params->getItemValueInt(L"h", -1); + + const wchar_t *aliastarget = WASABI_API_PALETTE->getElementAlias(id); + if (aliastarget) + id = aliastarget; + + const wchar_t *colorgroup = params->getItemValue(L"colorgroup"); + if (!colorgroup || !*colorgroup) + colorgroup = params->getItemValue(L"gammagroup"); + + WASABI_API_PALETTE->AddBitmap(id, fn, rootpath, x, y, w, h, params, colorgroup); + + } + else if (tagid == XML_ELEMENTTAG_COLOR) + { + const wchar_t *colorstr = params->getItemValue(L"value"); + StringW id = params->getItemValue(L"id"); + const wchar_t *aliastarget = WASABI_API_PALETTE->getElementAlias(id); + if (aliastarget) + id = aliastarget; + const wchar_t *colorgroup = params->getItemValue(L"colorgroup"); + if (!colorgroup || !*colorgroup) + colorgroup = params->getItemValue(L"gammagroup"); + if (!wcschr(colorstr, ',')) + { + ARGB32 c = WASABI_API_PALETTE->getColorElement((colorstr)); + WASABI_API_PALETTE->AddColor(id, c, colorgroup, rootpath, params); + } + else + { + WASABI_API_PALETTE->AddColor((id), SkinParser::parseColor(colorstr), colorgroup, rootpath, params); + } + } + else if (tagid == XML_ELEMENTTAG_BITMAPFONT) + { + Font::installBitmapFont(params->getItemValue(L"file"), rootpath, params->getItemValue(L"id"), params->getItemValueInt(L"charwidth", 0), params->getItemValueInt(L"charheight", 0), params->getItemValueInt(L"hspacing", 0), params->getItemValueInt(L"vspacing", 0), elementScriptId, params->getItemValueInt(L"allowmapping", 1)); + } + else if (tagid == XML_ELEMENTTAG_TRUETYPEFONT) + { + Font::installTrueTypeFont(params->getItemValue(L"file"), rootpath, params->getItemValue(L"id"), elementScriptId, params->getItemValueInt(L"allowmapping", 1), 0); + } + else if (tagid == XML_ELEMENTTAG_CURSOR) + { + const wchar_t *bitmap = params->getItemValue(L"bitmap"); + StringW id = params->getItemValue(L"id"); + const wchar_t *aliastarget = WASABI_API_PALETTE->getElementAlias(id); + int x = params->getItemValueInt(L"hotspot_x", 0); + int y = params->getItemValueInt(L"hotspot_y", 0); + if (aliastarget) + id = aliastarget; + WASABI_API_PALETTE->AddCursor(id, bitmap, x, y, rootpath, params); + } + else if (tagid == XML_ELEMENTTAG_UNKNOWN) + { + CollectionSvcEnum cse(xmltag); + svc_collection *svc; + if (svc = cse.getFirst()) + { // got one! + svc->addElement(params->getItemValue(L"id"), rootpath, elementScriptId, params); + WASABI_API_SVC->service_release(svc); + } + } + else + { + DebugStringW(L"SkinElementsMgr: tag %s was recognized but not handled!\n", xmltag); + } +} + +void SkinElementsMgr::resetSkinElements() +{ + WASABI_API_PALETTE->Reset(); + + Font::uninstallAll(); + // remove any element inserted into a hierarchical collection + for (int i = 0;i < (int)WASABI_API_SVC->service_getNumServices(WaSvc::COLLECTION);i++) + { + waServiceFactory *f = WASABI_API_SVC->service_enumService(WaSvc::COLLECTION, i); + if (f != NULL) + { + svc_collection *svc = static_cast(f->getInterface(FALSE)); + svc->removeAllElements(); + f->releaseInterface(svc); + } + } +} + +void SkinElementsMgr::onBeforeLoadingScriptElements(const wchar_t *name, int script_id) +{ + SkinElementsMgr::rootpathstack.addItem(new StringW(rootpath)); + oldid = elementScriptId; + oldinel = inelements; + + WASABI_API_PALETTE->StartTransaction(); + wchar_t buf[WA_MAX_PATH] = {0}; + WCSCPYN(buf, name, WA_MAX_PATH); + + wchar_t *ptr = const_cast(Wasabi::Std::filename(buf)); + if (ptr != NULL) *ptr = '\0'; + rootpath = buf; + rootpath.AddBackslash(); + + original_rootpath = rootpath; + + last_includepath = L""; + + inelements = 0; + elementScriptId = script_id; +} + +void SkinElementsMgr::onAfterLoadingScriptElements() +{ + WASABI_API_PALETTE->EndTransaction(); + elementScriptId = oldid; + inelements = oldinel; + rootpath = SkinElementsMgr::rootpathstack.getLast(); + delete SkinElementsMgr::rootpathstack.getLast(); + SkinElementsMgr::rootpathstack.removeLastItem(); +} + +void SkinElementsMgr::unloadScriptElements(int scriptid) +{ + int i; + + + WASABI_API_PALETTE->UnloadElements(scriptid); + + Font::uninstallByScriptId(scriptid); + // remove any element inserted into a hierarchical collection + for (i = 0;i < (int)WASABI_API_SVC->service_getNumServices(WaSvc::COLLECTION);i++) + { + waServiceFactory *f = WASABI_API_SVC->service_enumService(WaSvc::COLLECTION, i); + if (f != NULL) + { + svc_collection *svc = static_cast(f->getInterface(FALSE)); + svc->removeElement(scriptid); + f->releaseInterface(svc); + } + } +} + +int SkinElementsMgr::elementEqual(const wchar_t *file1, const wchar_t *rootpath1, + const wchar_t *file2, const wchar_t *rootpath2) +{ + + StringPathCombine a(rootpath1, file1); + StringPathCombine b(rootpath2, file2); + + return PATHEQL(a, b); +} + +const wchar_t *SkinElementsMgr::getSkinRootpathFromIncludePath(const wchar_t *includepath, const wchar_t *def) +{ + if (!wcsstr(includepath, L"..")) return def; + + PathParserW pp(includepath); + if (pp.getNumStrings() < 2 || !WCSCASEEQLSAFE(pp.enumString(0), L"skins")) // UNSAFE if the skinpath isn't "skins" + return def; + + StringW baseskin = pp.enumString(1); + + if (wcsstr(includepath, L"..")) + { + int x = 0; + for (int i = 0;i < pp.getNumStrings();i++) + { + const wchar_t *p = pp.enumString(i); + if (WCSICMP(p, L"..")) + { + if (x == 1) + baseskin = pp.enumString(i); + x++; + } + else + x--; + } + } + + t_rootpath = pp.enumString(0); + t_rootpath.AppendFolder(baseskin); + return t_rootpath; +} + +SkinElementsXmlReader SkinElementsMgr::xmlreader; +int SkinElementsMgr::inelements = 0; +int SkinElementsMgr::elementScriptId = -1; +int SkinElementsMgr::oldid, SkinElementsMgr::oldinel; +StringW SkinElementsMgr::rootpath, SkinElementsMgr::original_rootpath, SkinElementsMgr::t_rootpath, SkinElementsMgr::last_includepath; +PtrList SkinElementsMgr::rootpathstack; +PtrListQuickSorted SkinElementsMgr::quickxmltaglist; diff --git a/Src/Wasabi/api/skin/skinelem.h b/Src/Wasabi/api/skin/skinelem.h new file mode 100644 index 00000000..bc4f8185 --- /dev/null +++ b/Src/Wasabi/api/skin/skinelem.h @@ -0,0 +1,106 @@ +#ifndef _SKINELEM_H +#define _SKINELEM_H + +#include +#include + +#include +#include + +typedef struct +{ + const wchar_t *tagname; + int id; + int needclosetag; +} +xml_elementtag; + +class XmlElementTagComp +{ +public: + static int compareItem(void *p1, void *p2) + { + return WCSICMP(((xml_elementtag *)p1)->tagname, ((xml_elementtag *)p2)->tagname); + } + static int compareAttrib(const wchar_t *attrib, void *item) + { + return WCSICMP(attrib, ((xml_elementtag *)item)->tagname); + } +}; + +enum { + XML_ELEMENTTAG_UNKNOWN = 0, + XML_ELEMENTTAG_ELEMENTS, + XML_ELEMENTTAG_ELEMENTALIAS, + XML_ELEMENTTAG_BITMAP, + XML_ELEMENTTAG_COLOR, + XML_ELEMENTTAG_BITMAPFONT, + XML_ELEMENTTAG_TRUETYPEFONT, + XML_ELEMENTTAG_CURSOR, + +}; + + +class ElementRegionServer; + +/*typedef enum { + SKIN_BITMAP_ELEMENT, + SKIN_FONT_ELEMENT, + SKIN_CURSOR_ELEMENT, + SKIN_COLOR_ELEMENT +} SkinElementType;*/ + + + + +class SkinElementsXmlReader : public XmlReaderCallbackI +{ +public: + void xmlReaderOnStartElementCallback(const wchar_t *xmltag, skin_xmlreaderparams *params); + void xmlReaderOnEndElementCallback(const wchar_t *xmltag); +}; + +class SkinElementsMgr +{ +public: + static void init(); + static void deinit(); + + static void onBeforeLoadingSkinElements(const wchar_t *rootpath); + static void onAfterLoadingSkinElements(); + + static void onBeforeLoadingScriptElements(const wchar_t *name, int script_id); + static void onAfterLoadingScriptElements(); + + static void resetSkinElements(); + static void unloadScriptElements(int scriptid); + + static void xmlReaderOnStartElementCallback( const wchar_t *xmltag, skin_xmlreaderparams *params); + static void _xmlReaderOnStartElementCallback( int tagid, const wchar_t *xmltag, skin_xmlreaderparams *params); + static void xmlReaderOnEndElementCallback( const wchar_t *xmltag); + + static const wchar_t *getSkinRootpathFromIncludePath(const wchar_t *includepath, const wchar_t *def); + static int elementEqual(const wchar_t *file1, const wchar_t *rootpath1, + const wchar_t *file2, const wchar_t *rootpath2); + + + +private: + static SkinElementsXmlReader xmlreader; + + static int inelements; + static int elementScriptId; + + static int oldid, oldinel; + static StringW rootpath; + static StringW original_rootpath; + static StringW t_rootpath; + static StringW last_includepath; + static PtrList rootpathstack; + + static PtrListQuickSorted quickxmltaglist; +}; + + + +#endif diff --git a/Src/Wasabi/api/skin/skinfilter.cpp b/Src/Wasabi/api/skin/skinfilter.cpp new file mode 100644 index 00000000..03dca473 --- /dev/null +++ b/Src/Wasabi/api/skin/skinfilter.cpp @@ -0,0 +1,18 @@ +#include +#include "skinfilter.h" +#include + +void ApplySkinFilters::apply(const wchar_t *elementid, const wchar_t *forced_gammagroup, ARGB32 *bits, int w, int h, int bpp) +{ + if ((elementid == NULL && forced_gammagroup == NULL) || bits == NULL || w <= 0 || h <= 0) + return; + SkinFilterEnum sfe; + + while (1) + { + svc_skinFilter *obj = sfe.getNext(FALSE); + if (!obj) break; + obj->filterBitmap((uint8_t *)bits, w, h, bpp, elementid, forced_gammagroup); + sfe.getLastFactory()->releaseInterface(obj); + } +} diff --git a/Src/Wasabi/api/skin/skinfilter.h b/Src/Wasabi/api/skin/skinfilter.h new file mode 100644 index 00000000..7fa0aaa8 --- /dev/null +++ b/Src/Wasabi/api/skin/skinfilter.h @@ -0,0 +1,12 @@ +#ifndef _SKINFILTER_H +#define _SKINFILTER_H + +#include + +class ApplySkinFilters +{ +public: + static void apply(const wchar_t *element_id, const wchar_t *forced_gammagroup, ARGB32 *bits, int w, int h, int bpp=32); +}; + +#endif diff --git a/Src/Wasabi/api/skin/skinfont.cpp b/Src/Wasabi/api/skin/skinfont.cpp new file mode 100644 index 00000000..1c370e3f --- /dev/null +++ b/Src/Wasabi/api/skin/skinfont.cpp @@ -0,0 +1,48 @@ +#include + +#include "skinfont.h" + +#include + +SkinFont::SkinFont() +{} + +SkinFont::~SkinFont() +{ + if (!tempFn.isempty()) + { +#ifdef WIN32 + RemoveFontResourceW(tempFn); +#else + DebugString( "portme -- SkinFont::~SkinFont\n" ); +#endif + UNLINK(tempFn); + } +} + +int SkinFont::setXmlOption(const wchar_t *paramname, const wchar_t *strvalue) +{ + return 0; +} + +void SkinFont::installFont(const wchar_t *filename, const wchar_t *path) +{ + OSFILETYPE in, out; + StringPathCombine temp(path, filename); + in = WFOPEN(temp, WF_READONLY_BINARY); + if (in == OPEN_FAILED) return ; + int len = (int)FGETSIZE(in); + MemBlock m(len); + FREAD(m.getMemory(), len, 1, in); + tempFn = TMPNAM(NULL); + out = WFOPEN(tempFn, WF_WRITE_BINARY); + ASSERT(out != OPEN_FAILED); + FWRITE(m.getMemory(), len, 1, out); + FCLOSE(out); + FCLOSE(in); +#ifdef WIN32 + AddFontResourceW(tempFn); +#else + DebugString( "portme -- SkinFont::installFont\n" ); +#endif +} \ No newline at end of file diff --git a/Src/Wasabi/api/skin/skinfont.h b/Src/Wasabi/api/skin/skinfont.h new file mode 100644 index 00000000..b70895e0 --- /dev/null +++ b/Src/Wasabi/api/skin/skinfont.h @@ -0,0 +1,17 @@ +#ifndef _SKINFONT_H +#define _SKINFONT_H + +#include + +class SkinFont : public XmlObjectI +{ +public: + SkinFont(); + ~SkinFont(); + void installFont(const wchar_t *filename, const wchar_t *path); + virtual int setXmlOption(const wchar_t *name, const wchar_t *val); +private: + StringW tempFn; +}; + +#endif diff --git a/Src/Wasabi/api/skin/skinitem.cpp b/Src/Wasabi/api/skin/skinitem.cpp new file mode 100644 index 00000000..d4f0f1b3 --- /dev/null +++ b/Src/Wasabi/api/skin/skinitem.cpp @@ -0,0 +1,14 @@ +#include +#include "skinitem.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif +#define CBCLASS SkinItemI +START_DISPATCH; + CB(SKINITEM_GETXMLROOTPATH, getXmlRootPath); + CB(SKINITEM_GETNAME, getName); + CB(SKINITEM_GETPARAMS, getParams); + CB(SKINITEM_GETSKINPARTID, getSkinPartId); + CB(SKINITEM_GETANCESTOR, getAncestor); +END_DISPATCH; diff --git a/Src/Wasabi/api/skin/skinitem.h b/Src/Wasabi/api/skin/skinitem.h new file mode 100644 index 00000000..88d82c13 --- /dev/null +++ b/Src/Wasabi/api/skin/skinitem.h @@ -0,0 +1,66 @@ +#ifndef __SKINITEM_H +#define __SKINITEM_H + +#include +#include "../xml/ifc_xmlreaderparams.h" + +class skin_xmlreaderparams; + +class SkinItem : public Dispatchable +{ + public: + const wchar_t *getXmlRootPath(); + const wchar_t *getName(); + ifc_xmlreaderparams *getParams(); + int getSkinPartId(); + SkinItem *getAncestor(); + + enum + { + SKINITEM_GETXMLROOTPATH = 0, + SKINITEM_GETNAME = 10, + SKINITEM_GETPARAMS = 20, + SKINITEM_GETSKINPARTID = 30, + SKINITEM_GETANCESTOR = 40, + }; +}; + +inline const wchar_t *SkinItem::getXmlRootPath() +{ + return _call(SKINITEM_GETXMLROOTPATH, (const wchar_t *)0); +} + +inline const wchar_t *SkinItem::getName() +{ + return _call(SKINITEM_GETNAME, (const wchar_t *)0); +} + +inline ifc_xmlreaderparams *SkinItem::getParams() +{ + return _call(SKINITEM_GETPARAMS, (ifc_xmlreaderparams *)NULL); +} + +inline int SkinItem::getSkinPartId() +{ + return _call(SKINITEM_GETSKINPARTID, (int)0); +} + +inline SkinItem *SkinItem::getAncestor() +{ + return _call(SKINITEM_GETANCESTOR, (SkinItem *)NULL); +} + +class SkinItemI : public SkinItem +{ + public: + virtual const wchar_t *getXmlRootPath()=0; + virtual const wchar_t *getName()=0; + virtual ifc_xmlreaderparams *getParams()=0; + virtual int getSkinPartId()=0; + virtual SkinItem *getAncestor()=0; + + protected: + RECVS_DISPATCH; +}; + +#endif diff --git a/Src/Wasabi/api/skin/skinparse.cpp b/Src/Wasabi/api/skin/skinparse.cpp new file mode 100644 index 00000000..7df77e81 --- /dev/null +++ b/Src/Wasabi/api/skin/skinparse.cpp @@ -0,0 +1,1822 @@ +#include +#include +#include +#include +#include +//#include //CUT!! +#include +#include +#include +#include +#include +#include +#include +#ifdef WASABI_COMPILE_COMPONENTS +#include +#endif +#include +#include +#ifdef WASABI_COMPILE_WNDMGR +#include +#endif +#include +#include +#include +#ifdef WASABI_COMPILE_LOCALES +#include +#include +#else +#define _ +#endif +#include +#include + +#ifdef _WIN32 +extern HINSTANCE hInstance; +#endif + +#define COLOR_WHITE (0xffffff) +#define COLOR_BLACK (0x000000) +#define COLOR_ERROR (0xff00ff) + +// with alpha +#define COLOR_WHITEA (0xffffffff) +#define COLOR_BLACKA (0xff000000) +#define COLOR_ERRORA (0xffff00ff) + +xml_tag taglist[] = { + {L"groupdef", XML_TAG_GROUPDEF, 1}, + {L"group", XML_TAG_GROUP, 1}, + {L"cfggroup", XML_TAG_CFGGROUP, 1}, + {L"elements", XML_TAG_ELEMENTS, 1}, + {L"snappoint", XML_TAG_SNAPPOINT, 0}, + {L"script", XML_TAG_SCRIPT, 0}, + {L"container", XML_TAG_CONTAINER, 1}, + {L"layout", XML_TAG_LAYOUT, 1}, + {L"elements", XML_ELEMENTTAG_ELEMENTS, 1}, + {L"accelerators", XML_TAG_ACCELERATORS, 1}, + {L"accelerator", XML_TAG_ACCELERATOR, 1}, + {L"stringtable", XML_TAG_STRINGTABLE, 1}, + {L"stringentry", XML_TAG_STRINGENTRY, 1}, + }; + +BEGIN_STRINGDICTIONARY(_resizevalues) +SDI(L"top", RESIZE_TOP); +SDI(L"left", RESIZE_LEFT); +SDI(L"right", RESIZE_RIGHT); +SDI(L"bottom", RESIZE_BOTTOM); +SDI(L"topleft", RESIZE_TOPLEFT); +SDI(L"topright", RESIZE_TOPRIGHT); +SDI(L"bottomleft", RESIZE_BOTTOMLEFT); +SDI(L"bottomright", RESIZE_BOTTOMRIGHT); +END_STRINGDICTIONARY(_resizevalues, resizevalues) + +BEGIN_STRINGDICTIONARY(_parsetypes) +SDI(L"resize", PARSETYPE_RESIZE); +SDI(L"color", PARSETYPE_COLOR); +SDI(L"coloralpha", PARSETYPE_COLORALPHA); +SDI(L"regionop", PARSETYPE_REGIONOP); +SDI(L"internal_action", PARSETYPE_INTERNALACTION); +SDI(L"group_inheritance", PARSETYPE_GROUPINHERITANCE); +END_STRINGDICTIONARY(_parsetypes, parsetypes) + +BEGIN_STRINGDICTIONARY(_actionlist) +SDI(L"none", ACTION_NONE); +#ifdef WA3COMPATIBILITY +SDI(L"about", ACTION_ABOUT); +SDI(L"mb_forward", ACTION_MB_FORWARD); +SDI(L"mb_back", ACTION_MB_BACK); +SDI(L"mb_url", ACTION_MB_URL); +SDI(L"mb_home", ACTION_MB_HOME); +SDI(L"mb_stop", ACTION_MB_STOP); +SDI(L"mb_refresh", ACTION_MB_REFRESH); +SDI(L"text_larger", ACTION_TEXT_LARGER); +SDI(L"text_smaller", ACTION_TEXT_SMALLER); +SDI(L"preferences", ACTION_PREFERENCES); +SDI(L"view_file_info", ACTION_VIEW_FILE_INFO); +SDI(L"doublesize", ACTION_DOUBLESIZE); +SDI(L"add_bookmark", ACTION_ADD_BOOKMARK); +SDI(L"menu", ACTION_MENU); +SDI(L"sysmenu", ACTION_SYSMENU); +SDI(L"windowmenu", ACTION_WINDOWMENU); +SDI(L"controlmenu", ACTION_CONTROLMENU); +#endif // wa3compatibility +#ifdef WASABI_WIDGETS_COMPBUCK +SDI(L"cb_next", ACTION_CB_NEXT); +SDI(L"cb_prev", ACTION_CB_PREV); +SDI(L"cb_prevpage", ACTION_CB_PREVPAGE); +SDI(L"cb_nextpage", ACTION_CB_NEXTPAGE); +#endif +#ifdef WASABI_COMPILE_WNDMGR +SDI(L"endmodal", ACTION_ENDMODAL); +SDI(L"minimize", ACTION_MINIMIZE); +SDI(L"maximize", ACTION_MAXIMIZE); +SDI(L"close", ACTION_CLOSE); +SDI(L"close_window", ACTION_CLOSE_WINDOW); +SDI(L"switch", ACTION_SWITCH); +SDI(L"toggle", ACTION_TOGGLE); +SDI(L"reload_skin", ACTION_RELOAD_SKIN); +SDI(L"enforce_minmax", ACTION_ENFORCEMINMAX); +SDI(L"toggle_always_on_top", ACTION_TOGGLE_ALWAYS_ON_TOP); +#endif // wndmgr +END_STRINGDICTIONARY(_actionlist, actionlist) + +#ifdef WASABI_COMPILE_MEDIACORE +BEGIN_STRINGDICTIONARY(_displaylist) +SDI(L"songname", DISPLAY_SONGNAME); +SDI(L"songinfo", DISPLAY_SONGINFO); +SDI(L"songartist", DISPLAY_SONGARTIST); +SDI(L"songtitle", DISPLAY_SONGTITLE); +SDI(L"songalbum", DISPLAY_SONGALBUM); +SDI(L"songlength", DISPLAY_SONGLENGTH); +SDI(L"time", DISPLAY_TIME); +SDI(L"timeelapsed", DISPLAY_TIME); +SDI(L"timeremaining", DISPLAY_TIME); +SDI(L"componentbucket", DISPLAY_CB); +SDI(L"songbitrate", DISPLAY_SONGBITRATE); +SDI(L"songsamplerate", DISPLAY_SONGSAMPLERATE); +SDI(L"songinfo_localise", DISPLAY_SONGINFO_TRANSLATED); +END_STRINGDICTIONARY(_displaylist, displaylist) +#endif // mediacore + +static GUID staticguid; + +void SkinParser::initialize() +{ + if (!quickxmltaglist.getNumItems()) + { + for (int i = 0;i < sizeof(taglist) / sizeof(xml_tag);i++) + quickxmltaglist.addItem(&taglist[i]); + } + + // first two are for back compatibility + skinXML.registerCallback(L"WinampAbstractionLayer", xmlReaderCallback); + skinXML.registerCallback(L"WinampAbstractionLayer\f*", xmlReaderCallback); + skinXML.registerCallback(L"WasabiXML", xmlReaderCallback); + skinXML.registerCallback(L"WasabiXML\f*", xmlReaderCallback); + + guiTree = new GuiTree(); + + xuiCache = new SvcCacheT; +} + +void SkinParser::shutdown() +{ + skinXML.unregisterCallback((void*)xmlReaderCallback); + delete guiTree; guiTree = NULL; + delete xuiCache; xuiCache = NULL; +} + +#ifdef WASABI_COMPILE_WNDMGR +void SkinParser::setInitialFocus() +{ + for (int i = 0;i < containers.getNumItems();i++) + { + if (containers[i]->isVisible()) + { + Layout *l = containers[i]->getCurrentLayout(); + if (l) + { + l->setFocus(); + return ; + } + } + } +#ifdef WIN32 +#ifdef WA3COMPATIBILITY + SetFocus(Main::gethWnd()); +#endif //WA3COMPATIBILITY +#else + DebugString( "portme -- SkinParser::setInitialFocus\n" ); +#endif //WIN32 +} +#endif + +#ifdef WASABI_COMPILE_WNDMGR +// do not forget to popParserState(); before returning +int SkinParser::loadContainers(const wchar_t *skin) +{ + wchar_t olddir[WA_MAX_PATH] = {0}; + Wasabi::Std::getCurDir(olddir, WA_MAX_PATH); + Wasabi::Std::setCurDir(WASABI_API_APP->path_getAppPath()); + int oldncontains = getNumContainers(); + pushParserState(); + allowscripts = 1; + centerskin = 1; + staticloading = 1; + instantiatinggroup = 0; + transcientcontainer = 0; + inContainer = inLayout = 0; + curGroup = NULL; + recording_container = 0; + recording_groupdef = 0; + inElements = inGroup = inGroupDef = inAccelerators = inStringTable = 0; + includepath = WASABI_API_SKIN->getSkinPath(); + loading_main_skinfile = 0; + SkinElementsMgr::onBeforeLoadingSkinElements(includepath); + GammaMgr::onBeforeLoadingGammaGroups(); + scriptId = WASABI_API_PALETTE->getSkinPartIterator(); + int skinType = Skin::checkSkin(skin); + int retcode = 0; + loading_main_skinfile = 1; + switch (skinType) + { + case Skin::CHKSKIN_UNKNOWN: + popParserState(); + break; +#ifdef WA3COMPATIBILITY + case Skin::CHKSKIN_ISWA2: + retcode = XmlReader::loadFile("svc:wa2skinxml", includepath); + break; +#endif + default: + { + retcode = skinXML.loadFile(StringPathCombine(includepath, L"skin.xml"), includepath); + break; + } + } + + int n = guiTree->getNumObject(XML_TAG_CONTAINER); + for (int i = 0;i < n;i++) + { + SkinItem *item = guiTree->getObject(XML_TAG_CONTAINER, i); + if (item && item->getParams()) + { + if (item->getParams()->getItemValueInt(L"dynamic")) + { + if (item->getParams()->getItemValueInt(L"default_visible")) + { + const wchar_t *name = item->getParams()->getItemValue(L"name"); +#ifdef ON_TWEAK_CONTAINER_NAMEW + ON_TWEAK_CONTAINER_NAMEW(name); +#endif + wchar_t c[512]=L"-"; +#ifdef WASABI_COMPILE_CONFIG + WASABI_API_CONFIG->getStringPrivate(StringPrintfW(L"everloaded/%s", name), c, 511, L"-"); +#endif + c[510] = 0; + if (c[0] == '-') + { + // never been created, create it now since it has default_visible + staticloading = 0; + /*Container *c = */instantiateDynamicContainer(item); + staticloading = 1; + } + } + } + } + } + + loading_main_skinfile = 0; + + Wasabi::Std::setCurDir(olddir); + + int ncontainersloaded = getNumContainers() - oldncontains; + if (retcode == 0 || ncontainersloaded == 0) + { + return 0; + } + +#ifdef WASABI_COMPILE_CONFIG + WASABI_API_CONFIG->setStringPrivate(L"last_skin", Skin::getSkinName()); +#endif + + ASSERT(tha != NULL); + SkinElementsMgr::onAfterLoadingSkinElements(); + GammaMgr::onAfterLoadingGammaGroups(); + +#ifdef WASABI_COMPILE_COMPONENTS + ComponentManager::broadcastNotify(WAC_NOTIFY_SKINGUILOADED, WASABI_API_PALETTE->getSkinPartIterator()); +#endif + + Skin::sendGuiLoadedCallback(); + popParserState(); + return ncontainersloaded; +} + +void SkinParser::centerSkin() +{ + RECT sr; + if (centerskin && getSkinRect(&sr)) + { + int l = getNumContainers(); + int w = (Wasabi::Std::getScreenWidth() - (sr.right - sr.left)) / 2; + int h = (Wasabi::Std::getScreenHeight() - (sr.bottom - sr.top)) / 2; + for (int i = 0;i < l;i++) + { + Container *c = enumContainer(i); + if (!c->isVisible()) continue; + Layout *l = c->getCurrentLayout(); + RECT r; + l->getWindowRect(&r); + r.left += w; + r.right += w; + r.bottom += h; + r.top += h; + l->move(r.left, r.top); + } + } + foreach(containers) + containers.getfor()->savePositions(); + endfor; +} + +int SkinParser::getSkinRect(RECT *r, ifc_window *exclude) +{ + if (!r) return 0; + ZERO(*r); + Container *cexcluded = NULL; + if (exclude != NULL) + { + Layout *l = static_cast(exclude->getDesktopParent()); + if (l != NULL) cexcluded = l->getParentContainer(); + } + int x = 99999, y = 99999, x2 = -1, y2 = -1; + int l = getNumContainers(); + for (int i = 0;i < l;i++) + { + Container *c = enumContainer(i); + if (c == cexcluded) continue; + if (!c->isInited()) c->onInit(); + if (c->isDeleting() || !c->getCurrentLayout()) continue; + int cx = c->getDefaultPositionX(); + int cy = c->getDefaultPositionY(); + if (cx == -1) cx = 0; + if (cy == -1) cy = 0; + RECT r; + c->getWindowRect(&r); + int cw = r.right - r.left; + int ch = r.bottom - r.top; + if (cx < x) x = cx; + if (cy < y) y = cy; + if ((cx + cw) > x2) x2 = cx + cw; + if ((cy + ch) > y2) y2 = cy + ch; + } + if (x2 > 0 && y2 > 0 && x != 99999 && y != 99999) + { + Wasabi::Std::setRect(r, x, y, x2, y2); + return 1; + } + return 0; +} +#endif + +// do not forget to popParserState(); before returning +void SkinParser::loadScriptXml(const wchar_t *filename, int scriptid) +{ + pushParserState(); + allowscripts = 1; + instantiatinggroup = 0; +#ifdef WASABI_COMPILE_WNDMGR + transcientcontainer = 0; + inContainer = inLayout = 0; +#endif + staticloading = 1; + recording_container = 0; + recording_groupdef = 0; + curGroup = NULL; + inElements = inGroup = inGroupDef = inAccelerators = inStringTable = 0; + scriptId = scriptid; + + //CUT char file[WA_MAX_PATH]; + //CUT char drive[WA_MAX_PATH]; + //CUT char dir[WA_MAX_PATH]; + //CUT char fname[WA_MAX_PATH]; + //CUT char ext[WA_MAX_PATH]; + + + includepath.setValue(L""); + + wchar_t olddir[WA_MAX_PATH] = {0}; + Wasabi::Std::getCurDir(olddir, WA_MAX_PATH); + Wasabi::Std::setCurDir(WASABI_API_APP->path_getAppPath()); + + if (!WCSNICMP(filename, L"buf:", 4)) + { + skinXML.loadFile(filename, includepath); + } + else + { + //CUT DebugString("filename is %s\n", filename); + includepath = filename; + includepath.RemovePath(); + + skinXML.loadFile(filename /*file*/, includepath); + } + + Wasabi::Std::setCurDir(olddir); + + popParserState(); +} + + +#ifdef WASABI_COMPILE_WNDMGR +// do not forget to popParserState(); before returning +Container *SkinParser::loadContainerForWindowHolder(const wchar_t *groupid, GUID g, int initit, int transcient, const wchar_t *containerid, int container_flag) +{ + ASSERTPR((g == INVALID_GUID || groupid == NULL) && (g != INVALID_GUID || groupid != NULL), "sorry, one or the other, indulge aristotle"); + pushParserState(); + allowscripts = 1; + instantiatinggroup = 0; + transcientcontainer = transcient; + staticloading = 0; + recording_container = 0; + recording_groupdef = 0; + curContainer = NULL; + lastCreatedContainer = NULL; + curGroup = NULL; + inContainer = inLayout = inElements = inGroup = inGroupDef = inAccelerators = inStringTable = 0; + scriptId = -1; //WASABI_API_PALETTE->getSkinPartIterator(); + SkinItem *found = NULL; + SkinItem *generic = NULL; + + for (int i = guiTree->getNumObject(XML_TAG_CONTAINER) - 1;i >= 0 && found == NULL;i--) + { + SkinItem *item = guiTree->getObject(XML_TAG_CONTAINER, i); + if (item == NULL) continue; + ifc_xmlreaderparams *par = item->getParams(); + if (!par) continue; + + if (g != INVALID_GUID) + { + for (size_t j = 0;found == NULL && j != par->getNbItems();j++) + { + const wchar_t *p = par->getItemName(j); + if (!WCSICMP(p, L"component") || !WCSICMP(p, L"hold")) + { + ParamParser pp(par->getItemValue(j)); + if (pp.hasGuid(g) && found == NULL) + { + found = item; + break; + } + if (generic == NULL && (pp.hasGuid(GENERIC_GUID) || pp.hasString(L"@ALL@"))) + { + generic = item; + } + } + } + } + else if (groupid != NULL) + { + for (size_t j = 0;j != par->getNbItems() && found == NULL;j++) + { + const wchar_t *p = par->getItemName(j); + if (!WCSICMP(p, L"hold")) + { + ParamParser pp(par->getItemValue(j)); + if (pp.hasString(groupid)) + { + found = item; + break; + } + if (pp.hasString(L"@ALL@")) + { + generic = item; + } + } + } + } + } + + if (found == NULL && generic == NULL) + { + popParserState(); + return NULL; + } + + if (!found) + { + if (containerid != NULL) + { + SkinItem *item = guiTree->getContainerById(containerid); + if (item != NULL) + { + Container *c = instantiateDynamicContainer(item, initit); + popParserState(); + return c; + } + } + else + { + if (container_flag != 0) return NULL; + } + } + + Container *c = instantiateDynamicContainer(found != NULL ? found : generic, initit); + popParserState(); + return c; +} + +Container *SkinParser::instantiateDynamicContainer(SkinItem *containeritem, int initit) +{ + + int quit = 0; + int guitreeid = guiTree->getObjectIdx(containeritem); + for (int i = guitreeid;i < guiTree->getNumObject() && !quit;i++) + { + SkinItem *ii = guiTree->getList()->enumItem(i); + ifc_xmlreaderparams *params = ii->getParams(); + const wchar_t *path = ii->getXmlRootPath(); + if (path) + includepath = path; + int object_type = guiTree->getObjectType(ii); + const wchar_t *name = ii->getName(); + if (!params) + { + if (object_type == XML_TAG_CONTAINER) + quit = 1; + _onXmlEndElement(object_type, name); + } + else + { + _onXmlStartElement(object_type, name, params); + } + } + return lastCreatedContainer; +} + +// do not forget to popParserState(); before returning +Container *SkinParser::newDynamicContainer(const wchar_t *containerid, int transcient) +{ + + pushParserState(); + + allowscripts = 1; + instantiatinggroup = 0; + transcientcontainer = transcient; + staticloading = 0; + recording_container = 0; + recording_groupdef = 0; + curContainer = NULL; + lastCreatedContainer = NULL; + curGroup = NULL; + inContainer = inLayout = inElements = inGroup = inGroupDef = inAccelerators = inStringTable = 0; + scriptId = WASABI_API_PALETTE->getSkinPartIterator(); + SkinItem *found = NULL; + + for (int i = guiTree->getNumObject(XML_TAG_CONTAINER) - 1;i >= 0 && found == NULL;i--) + { + SkinItem *item = guiTree->getObject(XML_TAG_CONTAINER, i); + ifc_xmlreaderparams *par = item->getParams(); + if (!par) continue; + const wchar_t *p = par->getItemValue(L"id"); + if (!WCSICMP(p, containerid)) + { + found = item; + break; + } + } + + Container *c = NULL; + if (found != NULL) + c = instantiateDynamicContainer(found); + + popParserState(); + + return c; +} + +#endif + +// do not forget to popParserState(); before returning +void SkinParser::fillGroup(Group *group, const wchar_t *groupid, SkinItem *specific_item, int params_only, int no_params, int scripts_enabled) +{ + ASSERT(group != NULL); + pushParserState(); + + instantiatinggroup = 1; + +#ifdef WASABI_COMPILE_WNDMGR + transcientcontainer = 0; +#endif + + allowscripts = scripts_enabled; + staticloading = 0; + recording_container = 0; + recording_groupdef = 0; + lastCreatedGroup = NULL; + scriptId = group->getSkinPartId(); + SkinItem *found = NULL; + + PtrList ancestor_param_list; + + found = specific_item == NULL ? guiTree->getGroupDef(groupid) : specific_item; + + if (found == NULL) + { + popParserState(); + return ; + } + + curGroup = group; + inGroup = 1; + parseGroup(found, &ancestor_param_list, params_only); + + if (!no_params) + { + XmlObject *xo = static_cast(curGroup->getScriptObject()->vcpu_getInterface(xmlObjectGuid)); + for (int i = ancestor_param_list.getNumItems() - 1;i >= 0;i--) + initXmlObject(xo, ancestor_param_list.enumItem(i), 1); + } + + popParserState(); +} + +GuiObject *SkinParser::newDynamicGroup(const wchar_t *groupid, int grouptype, SkinItem *specific_item, int specific_scriptid, int scripts_enabled) +{ +#ifdef WASABI_COMPILE_CONFIG + int iscfggroup = (grouptype == GROUP_CFGGROUP); +#endif + +#ifdef WASABI_COMPILE_WNDMGR + int islayoutgroup = (grouptype == GROUP_LAYOUTGROUP); +#endif + + Group *r = NULL; +#ifdef WASABI_COMPILE_CONFIG + if (!iscfggroup) + { +#endif +#ifdef WASABI_COMPILE_WNDMGR + if (!islayoutgroup) + r = new Group; + else + { + Layout *l = new Layout; + r = l; + l->setParentContainer(NULL); + } +#else // wndmgr + r = new Group; +#endif // wndmgr +#ifdef WASABI_COMPILE_CONFIG + + } + else + r = new CfgGroup; +#endif + + r->setSkinPartId(specific_scriptid > -1 ? specific_scriptid : WASABI_API_PALETTE->getSkinPartIterator()); + + if (r != NULL) + { + r->setXmlParam(L"id", groupid); + r->setGroupContent(groupid, specific_item, scripts_enabled); + fillGroup(r, groupid, specific_item, 1, 0, scripts_enabled); + return r->getGuiObject(); + } + return NULL; +} + +void SkinParser::pushParserState() +{ + parser_status *p = new parser_status; +#ifdef WASABI_COMPILE_WNDMGR + p->curContainer = curContainer; + p->curLayout = curLayout; + p->inContainer = inContainer; + p->inLayout = inLayout; + p->transcientcontainer = transcientcontainer; +#endif + p->staticloading = staticloading; + p->curGroup = curGroup; + p->includepath = includepath; + p->inElements = inElements; + p->inGroup = inGroup; + p->inGroupDef = inGroupDef; + p->instantiatinggroup = instantiatinggroup; + p->scriptid = scriptId; + p->allowscripts = allowscripts; + p->inAccelerators = inAccelerators; + p->inStringTable = inStringTable; + statusstack.addItem(p); +} + +void SkinParser::popParserState() +{ + ASSERT(statusstack.getNumItems() > 0); + parser_status *p = statusstack.enumItem(statusstack.getNumItems() - 1); + statusstack.removeByPos(statusstack.getNumItems() - 1); + ASSERT(p != NULL); +#ifdef WASABI_COMPILE_WNDMGR + curContainer = p->curContainer; + curLayout = p->curLayout; + inContainer = p->inContainer; + inLayout = p->inLayout; + transcientcontainer = p->transcientcontainer; +#endif + curGroup = p->curGroup; + includepath = p->includepath; + inElements = p->inElements; + inAccelerators = p->inAccelerators; + inStringTable = p->inStringTable; + inGroup = p->inGroup; + inGroupDef = p->inGroupDef; + staticloading = p->staticloading; + instantiatinggroup = p->instantiatinggroup; + scriptId = p->scriptid; + allowscripts = p->allowscripts; + delete p; +} + +#ifdef WASABI_COMPILE_WNDMGR + +Container *SkinParser::getContainer(const wchar_t *id) +{ + for (int i = 0;i < containers.getNumItems();i++) + if (!WCSICMP(id, containers.enumItem(i)->getId())) + return containers.enumItem(i); + return NULL; +} + +Layout *SkinParser::getLayout(const wchar_t *contlay) +{ + PathParserW pp(contlay, L","); + if (pp.getNumStrings() == 2) + { + Container *c = SkinParser::getContainer(pp.enumString(0)); + if (c) + { + Layout *l = c->getLayout(pp.enumString(1)); + if (l) + { + return l; + } + } + } + return NULL; +} + +int SkinParser::script_getNumContainers() +{ + return containers.getNumItems(); +} + +Container *SkinParser::script_enumContainer(int n) +{ + return containers.enumItem(n); +} + +int SkinParser::isContainer(Container *c) +{ + return containers.haveItem(c); +} + +Container *SkinParser::script_getContainer(const wchar_t *id) +{ + for (int i = 0;i < containers.getNumItems();i++) + { + Container *c = containers.enumItem(i); + if (c) + { + const wchar_t *c_id = containers.enumItem(i)->getId(); + if (c_id && !WCSICMP(id, c_id)) + return containers.enumItem(i); + } + } + return NULL; +} + +void SkinParser::componentToggled(GUID *g, int visible) +{ + for (int i = 0;i < containers.getNumItems();i++) + containers[i]->componentToggled(g, visible); +} + +void SkinParser::sendNotifyToAllContainers(int notifymsg, int param1, int param2) +{ + for (int i = 0;i < containers.getNumItems();i++) + containers[i]->sendNotifyToAllLayouts(notifymsg, param1, param2); +} + + +void SkinParser::toggleContainer(int num) +{ + if (num < 0) return ; + if (num > containers.getNumItems()) return ; + + Container *c = containers[num]; + if (!c) return ; + c->toggle(); +} + +void SkinParser::startupContainers(int scriptid) +{ + for (int i = 0;i < containers.getNumItems();i++) + { + if (scriptid == -1 || containers[i]->getScriptId() == scriptid && !containers[i]->isDynamic()) + containers[i]->onInit(); + } +} + +void SkinParser::showContainer(int num, int show) +{ + if (num < 0) return ; + if (num > containers.getNumItems()) return ; + + Container *c = containers[num]; + c->setVisible(show); +} + +#endif // wndmgr + +int SkinParser::getHex(const wchar_t *p, int size) +{ + int v = 0, i = 0; + while (*p != 0 && *p != '-' && *p != '}') + { + unsigned int a = *p; + if (a >= '0' && a <= '9') a -= '0'; + if (a >= 'a' && a <= 'f') a -= 'a' -10; + if (a >= 'A' && a <= 'F') a -= 'A' -10; + v = (v * 16) + a; + p++; + i++; if (size != -1 && i == size) return v; + } + return v; +} + +#ifdef WASABI_COMPILE_WNDMGR +int SkinParser::getComponentGuid(GUID *g, const wchar_t *p) +{ + g->Data1 = getHex(p); + while (*p != 0 && *p != '-') p++; + if (*p == '-') + { + p++; + g->Data2 = getHex(p); + while (*p != 0 && *p != '-') p++; + if (*p == '-') + { + p++; + g->Data3 = getHex(p); + while (*p != 0 && *p != '-') p++; + if (*p == '-') + { + p++; + g->Data4[0] = getHex(p, 2); p += 2; + g->Data4[1] = getHex(p, 2); p += 3; + g->Data4[2] = getHex(p, 2); p += 2; + g->Data4[3] = getHex(p, 2); p += 2; + g->Data4[4] = getHex(p, 2); p += 2; + g->Data4[5] = getHex(p, 2); p += 2; + g->Data4[6] = getHex(p, 2); p += 2; + g->Data4[7] = getHex(p, 2); + return 1; + } + } + } + return 0; +} + +GUID *SkinParser::getComponentGuid(const wchar_t *id) +{ + static GUID g; + g = nsGUID::fromCharW(id); + if (g == INVALID_GUID) return NULL; + return &g; +} + +#endif + +int SkinParser::parse(const wchar_t *str, const wchar_t *what) +{ + int a = parsetypes.getId(what); + if (a < 0) return WTOI(str); + switch (a) + { + case PARSETYPE_RESIZE: return parseResize(str); + case PARSETYPE_COLOR: return parseColor(str); + case PARSETYPE_COLORALPHA: return parseColorAlpha(str); + case PARSETYPE_REGIONOP: return parseRegionOp(str); + case PARSETYPE_INTERNALACTION: return getAction(str); + case PARSETYPE_GROUPINHERITANCE: return parseGroupInheritance(str); + } + // todo: add svc_intParser + return 0; +} + +int SkinParser::parseGroupInheritance(const wchar_t *str) +{ + if (WCSCASEEQLSAFE(str, L"1")) return GROUP_INHERIT_ALL; + if (WCSCASEEQLSAFE(str, L"0")) return GROUP_INHERIT_NOTHING; + ParamParser pp(str); + int v = 0; + for (int i = 0;i < pp.getNumItems();i++) + { + const wchar_t *s = pp.enumItem(i); + if (WCSCASEEQLSAFE(s, L"xui")) v |= GROUP_INHERIT_XUIOBJECTS; + if (WCSCASEEQLSAFE(s, L"scripts")) v |= GROUP_INHERIT_SCRIPTS; + if (WCSCASEEQLSAFE(s, L"params")) v |= GROUP_INHERIT_PARAMS; + } + return v; +} + +ARGB32 SkinParser::parseColor(const wchar_t *color, int *error) +{ + if (color == NULL || *color == '\0') { if (error) *error = 1; return COLOR_ERROR; } + if (!WCSICMP(color, L"white")) return COLOR_WHITE; + if (!WCSICMP(color, L"black")) return COLOR_BLACK; + if (wcschr(color, ',')) + { + int r = 0, g = 0, b = 0; + if (swscanf(color, L"%d,%d,%d", &r, &g, &b) != 3) return COLOR_ERROR; + return RGB(r, g, b); // our colors are reversed internally + } + if (*color == '#') + { + int r = 0, g = 0, b = 0; + if (swscanf(color, L"#%02x%02x%02x", &r, &g, &b) != 3) return COLOR_ERROR; + return RGB(r, g, b); + } + if (error) *error = 1; + return COLOR_ERROR; +} + +ARGB32 SkinParser::parseColorAlpha(const wchar_t *color) +{ + if (color == NULL || *color == '\0') return COLOR_BLACKA; + if (!WCSICMP(color, L"white")) return COLOR_WHITEA; + if (!WCSICMP(color, L"black")) return COLOR_BLACKA; + if (wcschr(color, ',')) + { + int r = 0, g = 0, b = 0, a = 255; + // note that 3 params is ok + if (swscanf(color, L"%d,%d,%d,%d", &r, &g, &b, &a) < 3) return COLOR_ERRORA; + ARGB32 ret = RGB(r, g, b); // our colors are reversed internally + ret |= ((a & 0xff) << 24); + return ret; + } + if (*color == '#') + { + int r = 0, g = 0, b = 0, a = 255; + if (swscanf(color, L"#%02x%02x%02x%02x", &r, &g, &b, &a) < 3) return COLOR_ERRORA; + ARGB32 ret = RGB(r, g, b); // our colors are reversed internally + ret |= ((a & 0xff) << 24); + return ret; + } + return COLOR_ERRORA; +} + +#ifdef WASABI_COMPILE_WNDMGR + +void SkinParser::toggleContainer(const wchar_t *id) +{ + // component toggling + GUID *g; + if (g = getComponentGuid(id)) + { + GUID g2; + MEMCPY(&g2, g, sizeof(GUID)); + WASABI_API_WNDMGR->skinwnd_toggleByGuid(g2); + return ; + } + for (int i = 0;i < containers.getNumItems();i++) + if (!WCSICMP(id, containers[i]->getId())) toggleContainer(i); +} + +void SkinParser::showContainer(const wchar_t *id, int show) +{ + // component guid + /* GUID *g; + if (g = getComponentGuid(id)) { + WASABI_API_WNDMGR->setComponentVisible(*g, show); + return; + }*/ + + foreach(containers) + if (!WCSICMP(id, containers.getfor()->getId())) + showContainer(foreach_index, show); + endfor +} + +#endif // wndmgr + +#pragma warning( disable : 4065 ) +int SkinParser::getAction(const wchar_t *action, const wchar_t **name) +{ + //CT> this should be a binary search for more efficiency + if (name != NULL) *name = NULL; + int a = actionlist.getId(action); + if (a == -1) return ACTION_NONE; + + // these strings are for accessibility when no text has been assigned to the control that triggers these actions + if (name != NULL) + { + switch (a) + { +#ifdef WASABI_COMPILE_WNDMGR + case ACTION_RELOAD_SKIN: *name = _(L"Reload skin"); break; + case ACTION_MINIMIZE: *name = _(L"Minimize window"); break; + case ACTION_MAXIMIZE: *name = _(L"Maximize window"); break; + case ACTION_CLOSE: *name = _(L"Close"); break; + case ACTION_SWITCH: *name = _(L"Switch to"); break; + case ACTION_TOGGLE: *name = _(L"Toggle"); break; + case ACTION_CLOSE_WINDOW: *name = _(L"Close window"); break; +#endif + +#ifdef WA3COMPATIBILITY + case ACTION_ABOUT: *name = _(L"About"); break; + case ACTION_SYSMENU: *name = _(L"Open system menu"); break; + case ACTION_CONTROLMENU: *name = _(L"Open control menu"); break; + case ACTION_MENU: *name = _(L"Open menu"); break; + case ACTION_WINDOWMENU: *name = _(L"Window menu"); break; + case ACTION_MB_FORWARD: *name = _(L"Forward"); break; + case ACTION_MB_BACK: *name = _(L"Back"); break; + case ACTION_MB_URL: *name = _(L"Url"); break; + case ACTION_MB_HOME: *name = _(L"Home"); break; + case ACTION_MB_STOP: *name = _(L"Stop loading"); break; + case ACTION_MB_REFRESH: *name = _(L"Refresh"); break; + case ACTION_TEXT_LARGER: *name = _(L"Increase text size"); break; + case ACTION_TEXT_SMALLER: *name = _(L"Decrease text size"); break; + case ACTION_PREFERENCES: *name = _(L"Preferences"); break; + case ACTION_TOGGLE_ALWAYS_ON_TOP: *name = _(L"Toggle Always on top"); break; + case ACTION_VIEW_FILE_INFO: *name = _(L"View file info"); break; + case ACTION_ADD_BOOKMARK: *name = _(L"Add bookmark"); break; + case ACTION_DOUBLESIZE: *name = _(L"Toggle double size mode"); break; +#endif +#ifdef WASABI_WIDGETS_COMPBUCK + case ACTION_CB_NEXT: *name = _(L"More"); break; + case ACTION_CB_PREV: *name = _(L"More"); break; +#endif + default: break; + } + } + return a; +} +#pragma warning( default : 4065 ) + +#ifdef WASABI_COMPILE_MEDIACORE +int SkinParser::getDisplay(const wchar_t *display) +{ + int a = displaylist.getId(display); + if (a == -1) return DISPLAY_SERVICE; + return a; +} +#endif + +int SkinParser::getAlign(const wchar_t *align) +{ +#ifdef _WIN32 + if (!WCSICMP(align, L"LEFT")) return ALIGN_LEFT; + if (!WCSICMP(align, L"CENTER")) return ALIGN_CENTER; + if (!WCSICMP(align, L"RIGHT")) return ALIGN_RIGHT; + if (!WCSICMP(align, L"TOP")) return ALIGN_TOP; + if (!WCSICMP(align, L"BOTTOM")) return ALIGN_BOTTOM; +#else +#warning port me +#endif + return DISPLAY_NONE; +} + +int SkinParser::getOrientation(const wchar_t *orient) +{ + if (!WCSICMP(orient, L"V") || !WCSICMP(orient, L"VERTICAL")) + return ORIENTATION_VERTICAL; + return ORIENTATION_HORIZONTAL; +} + +// link guiobject to guiobject +void SkinParser::initGuiObject(GuiObject *g, Group *pgroup) +{ + ASSERT(pgroup); + pgroup->addObject(g); +} + +// This sends the params to the script object through its XmlObject +// interface. Try not to add code here, but instead in setXmlParam/XmlInit +// in the object itself +void SkinParser::initXmlObject(XmlObject *o, ifc_xmlreaderparams *params, int no_id) +{ + ASSERT(o); + if (params) + for (size_t i = 0;i != params->getNbItems();i++) + if (!no_id || WCSICMP(params->getItemName(i), L"id")) // don't pass along id="blah" stuff + o->setXmlParam(params->getItemName(i), params->getItemValue(i)); + // o->XmlInit(); //fg> now defered +} + +#ifdef WASABI_COMPILE_WNDMGR + +// This sends the params to the script object through its XmlObject +// interface. Try not to add code here, but instead in setXmlParam/XmlInit +// in the object itself +void SkinParser::initLayout(Layout *l, Container *pcont) +{ + ASSERT(pcont); + l->setParentContainer(pcont); + pcont->addLayout(l); +} + +#endif + +void SkinParser::xmlReaderCallback(int start, const wchar_t *xmltag, skin_xmlreaderparams *params) +{ + if (start) onXmlStartElement(xmltag, params); + else onXmlEndElement(xmltag); +} + +void SkinParser::onXmlStartElement(const wchar_t *name, skin_xmlreaderparams *params) +{ + xml_tag *i = quickxmltaglist.findItem(name); + if (i) _onXmlStartElement(i->id, name, params); + else _onXmlStartElement(XML_TAG_UNKNOWN, name, params); +} + +void SkinParser::onXmlEndElement(const wchar_t *name) +{ + xml_tag *i = quickxmltaglist.findItem(name); + if (i) + { + if (i->needclosetag) + _onXmlEndElement(i->id, name); + } /*else + _onXmlEndElement(XML_TAG_UNKNOWN, name);*/ // not needed yet +} + + + +void SkinParser::parseGroup(SkinItem *groupitem, PtrList *ancestor_param_list, int params_only, int overriding_inheritance_flags) +{ + ifc_xmlreaderparams *par = groupitem->getParams(); + const wchar_t *groupid = par->getItemValue(L"id"); + const wchar_t *ic = par->getItemValue(L"inherit_content"); + const wchar_t *og = par->getItemValue(L"inherit_group"); + const wchar_t *ip = par->getItemValue(L"inherit_params"); + + int inheritance_flags = parseGroupInheritance(ic); + int inherit_params = 1; + if (ip != NULL && *ip != 0) inherit_params = WTOI(ip); + if ((og && *og) && (!ic || !*ic)) inheritance_flags = GROUP_INHERIT_ALLCONTENT; + + if (inherit_params) inheritance_flags |= GROUP_INHERIT_PARAMS; + + if (WCSCASEEQLSAFE(og, groupid)) og = NULL; + + + if (inheritance_flags != GROUP_INHERIT_NOTHING) + { + SkinItem *prior_item = NULL; + if (og != NULL && *og) + prior_item = guiTree->getGroupDef(og); + else + prior_item = guiTree->getGroupDefAncestor(groupitem); + if (prior_item != NULL) + parseGroup(prior_item, ancestor_param_list, params_only, inheritance_flags); + } + + if (overriding_inheritance_flags & GROUP_INHERIT_PARAMS) + ancestor_param_list->addItem(groupitem->getParams()); + + if (!params_only) + { + int guitreeid = guiTree->getObjectIdx(groupitem); + for (int i = guitreeid + 1;i < guiTree->getNumObject();i++) + { + SkinItem *item = guiTree->getList()->enumItem(i); + ifc_xmlreaderparams *params = item->getParams();; + const wchar_t *path = item->getXmlRootPath(); + if (path) + includepath = path; + int object_type = guiTree->getObjectType(item); + if (object_type == XML_TAG_GROUPDEF && !params) break; + if (object_type == XML_TAG_SCRIPT && !(overriding_inheritance_flags & GROUP_INHERIT_SCRIPTS)) continue; + if (object_type != XML_TAG_SCRIPT && !(overriding_inheritance_flags & GROUP_INHERIT_XUIOBJECTS)) continue; + const wchar_t *name = item->getName(); + if (!params) + _onXmlEndElement(object_type, name); + else + _onXmlStartElement(object_type, name, params); + } + } + +} + +void SkinParser::_onXmlStartElement(int object_type, const wchar_t *object_name, ifc_xmlreaderparams *params) +{ + GuiObject *g = NULL; // We'll need to build a GUI object + XmlObject *x = NULL; + Group *g_group = NULL; + + if (object_type == XML_TAG_UNKNOWN) + { + if (loading_main_skinfile && (!WCSICMP(object_name, L"WinampAbstractionLayer") || !WCSICMP(object_name, L"WasabiXML"))) + { + skinversion = WTOF(params->getItemValue(L"version")); + } + } + +/*#ifdef WASABI_COMPILE_WNDMGR + int isacontainer = 0; +#endif // wndmgr*/ + + if (object_type == XML_TAG_GROUPDEF) + { + if (staticloading) + { + recording_groupdef++; + } + inGroupDef++; + } + + if (object_type == XML_TAG_ACCELERATORS) + { + const wchar_t *section = params->getItemValue(L"section"); + if (!section) + LocalesManager::setAcceleratorSection(L"general"); + else + LocalesManager::setAcceleratorSection(section); + + inAccelerators = 1; + } + + if (object_type == XML_TAG_STRINGTABLE) + { + const wchar_t *section = params->getItemValue(L"id"); + if (!section) + LocalesManager::SetStringTable(L"nullsoft.wasabi"); + else + LocalesManager::SetStringTable(section); + + inStringTable = 1; + } + + if (inStringTable && object_type == XML_TAG_STRINGENTRY) + { + const wchar_t *b = params->getItemValue(L"id"); + const wchar_t *a = params->getItemValue(L"string"); + if (b && a) + { + LocalesManager::AddString(WTOI(b), a); + } + } + + if (inAccelerators && object_type == XML_TAG_ACCELERATOR) + { + const wchar_t *b = params->getItemValue(L"bind"); + const wchar_t *a = params->getItemValue(L"action"); + if (b && a) + { + //LocalesManager::addAccelerator(b, a); + //Martin> this is a temporary fix to protect skin.xml from overriding the language pack accels + LocalesManager::addAcceleratorFromSkin(b, a); + } + } + + if ((!recording_container && !recording_groupdef) && !inGroupDef) + { + if (object_type == XML_TAG_SCRIPT) + { + // const char *id = params->getItemValue(L"id"); + if (1) + { + if (allowscripts) + { + int vcpuid = Script::addScript(includepath, params->getItemValue(L"file"), params->getItemValue(L"id")); + if (vcpuid != -1) + { + Script::setScriptParam(vcpuid, params->getItemValue(L"param")); + Script::setParentGroup(vcpuid, curGroup); + Script::setSkinPartId(vcpuid, scriptId); + if (curGroup != NULL) + curGroup->addScript(vcpuid); + else // todo: schedule this for the end of skinparse, after all layouts are inited + SOM::getSystemObjectByScriptId(vcpuid)->onLoad(); + } + } + } + } + } + +#ifdef WASABI_COMPILE_WNDMGR + if ((!recording_groupdef && !recording_container) && (inContainer || inGroup) && !inGroupDef) + { // Am I in a container definition ? + if (inLayout || inGroup) + { // Am I in a layout or in a group ? +#else // wndmgr + if ((!recording_groupdef && !recording_container) && inGroup && !inGroupDef) + { + { // Am I in definition ? +#endif // wndmgr + + + // Create appropriate GuiObject descendant + if (object_type == XML_TAG_GROUP || object_type == XML_TAG_CFGGROUP) + { + Group *old = curGroup; + GuiObject *newgrp = newDynamicGroup(params->getItemValue(L"id"), (object_type == XML_TAG_CFGGROUP) ? GROUP_CFGGROUP : GROUP_GROUP); + if (newgrp) + { + x = static_cast(newgrp->guiobject_getScriptObject()->vcpu_getInterface(xmlObjectGuid)); + g = newgrp; + } + curGroup = old; + } +#ifdef WASABI_COMPILE_WNDMGR + else if (object_type == XML_TAG_SNAPPOINT) + { + x = new SnapPoint(curLayout, curContainer); + } +#endif + else if (object_type != XML_TAG_UNKNOWN) + { + g = NULL; + } + else + { + SkinItem *item = guiTree->getXuiGroupDef(object_name); + if (item != NULL) + { + Group *old = curGroup; + const wchar_t *grpid = NULL; + if (item->getParams() != NULL) + grpid = item->getParams()->getItemValue(L"id"); + GuiObject *newgrp = NULL; + if (grpid == NULL) + newgrp = newDynamicGroup(params->getItemValue(L"id"), GROUP_GROUP, item); + else + newgrp = newDynamicGroup(grpid, GROUP_GROUP, NULL, -1, allowscripts); + if (newgrp) + { + x = static_cast(newgrp->guiobject_getScriptObject()->vcpu_getInterface(xmlObjectGuid)); + g = newgrp; + } + curGroup = old; + } + else + { + g = createExternalGuiObject(object_name, &x, params); + } + } + } +#ifdef WASABI_COMPILE_WNDMGR + else + { // if inlayout + + if (object_type == XML_TAG_LAYOUT) + { // Now enters a new layout + curLayout = new Layout; + curGroup = curLayout; + inLayout = 1; + initLayout(curLayout, curContainer); + x = static_cast(curLayout->getGuiObject()->guiobject_getScriptObject()->vcpu_getInterface(xmlObjectGuid)); + } + } +#endif // wndmgr + + } +#ifdef WASABI_COMPILE_WNDMGR + else + { // if inContainer + + if (inElements) + { + // do nothing + } + else if (object_type == XML_TAG_CONTAINER) + { + //isacontainer = 1; + const wchar_t *d = params->getItemValue(L"dynamic"); + int dyn = WASABI_WNDMGR_ALLCONTAINERSDYNAMIC ? 1 : (d ? WTOI(d) : 0); + + if (dyn && staticloading) + { + recording_container = 1; + } + else + { + inContainer = 1; + curContainer = new Container(scriptId); + curContainer->setId(params->getItemValue(L"id")); + containers.addItem(curContainer); +#ifdef _DEBUG + DebugStringW(L"new Container - skinpartid = %d\n", scriptId); +#endif + if (transcientcontainer) curContainer->setTranscient(1); + x = curContainer; + } + } + else + { + if (object_type == XML_TAG_SCRIPTS) + inScripts = 1; + else if (object_type == XML_TAG_ELEMENTS) + inElements = 1; + } + + } // if container else +#endif // wndmgr + + if (g_group) + { + curGroup = g_group; + } + else if (g) + initGuiObject(g, curGroup); + + if (x) + initXmlObject(x, params); + + if (recording_container || recording_groupdef) + guiTree->addItem(object_type, object_name, params, scriptId, includepath.v()); +} + +void SkinParser::_onXmlEndElement(int object_type, const wchar_t *name) +{ + if (recording_container || recording_groupdef) + guiTree->addItem(object_type, name, NULL, scriptId, includepath); + + if (object_type == XML_TAG_GROUPDEF) + { + lastCreatedGroup = curGroup; + if (staticloading) + recording_groupdef--; + if (recording_groupdef < 0) recording_groupdef = 0; + inGroup = 0; + inGroupDef--; + curGroup = NULL; + } + +#ifdef WASABI_COMPILE_WNDMGR + if (object_type == XML_TAG_CONTAINER) + { + if (inContainer) + { + //if (!curContainer->isDynamic()) containers.addItem(curContainer); //FG>script + //containers.addItem(curContainer); + lastCreatedContainer = curContainer; + curContainer = NULL; + inContainer = 0; + } + recording_container = 0; + if (recording_groupdef) + { + WASABI_API_WNDMGR->messageBox(L"container closed but group still open, closing group", L"error in xml data", 0, NULL, NULL); + recording_groupdef = 0; + } + } + + if (inLayout && object_type == XML_TAG_LAYOUT) + { +#ifdef WA3COMPATIBILITY + curLayout->setForwardMsgWnd(WASABI_API_WND->main_getRootWnd()->gethWnd()); +#endif + curLayout->setAutoResizeAfterInit(1); +#ifndef WA3COMPATIBILITY +#ifdef _WIN32 + curLayout->init(hInstance, curLayout->getCustomOwner() ? curLayout->getCustomOwner()->gethWnd() : WASABI_API_WND->main_getRootWnd()->gethWnd(), TRUE); +#else +#warning port me + curLayout->init(0, curLayout->getCustomOwner() ? curLayout->getCustomOwner()->gethWnd() : WASABI_API_WND->main_getRootWnd()->gethWnd(), TRUE); +#endif +#else + curLayout->init(hInstance, curLayout->getCustomOwner() ? curLayout->getCustomOwner()->gethWnd() : Main::gethWnd(), TRUE); +#endif + curLayout->getGuiObject()->guiobject_onStartup(); + curLayout = NULL; + inLayout = 0; + curGroup = NULL; + } +#endif + + if (inScripts && object_type == XML_TAG_SCRIPTS) + { + inScripts = 0; + } + + if (inElements && object_type == XML_TAG_ELEMENTS) + { + inElements = 0; + } + + if (inAccelerators && object_type == XML_TAG_ACCELERATORS) + { + LocalesManager::setAcceleratorSection(L""); + inAccelerators = 0; + } + + if (inStringTable && object_type == XML_TAG_STRINGTABLE) + { + LocalesManager::SetStringTable(L""); + inStringTable = 0; + } +} + +#ifdef WASABI_COMPILE_WNDMGR +int SkinParser::verifyContainer(Container *c) +{ + for (int i = 0;i < containers.getNumItems();i++) + { + if (containers.enumItem(i) == c) + return 1; + } + return 0; +} +#endif + +int SkinParser::parseResize(const wchar_t *r) +{ + int a = resizevalues.getId(r); + if (a < 0) return WTOI(r); + return a; +} + +int SkinParser::parseRegionOp(const wchar_t *r) +{ + if (!WCSICMP(r, L"or")) return REGIONOP_OR; + if (!WCSICMP(r, L"and")) return REGIONOP_AND; + if (!WCSICMP(r, L"sub")) return REGIONOP_SUB; + if (!WCSICMP(r, L"sub2")) return REGIONOP_SUB2; + return WTOI(r); +} + +void SkinParser::cleanupScript(int scriptid) +{ + if (scriptid == -1) scriptid = WASABI_API_PALETTE->getSkinPartIterator(); + int i; + for (i = 0;i < SOM::getNumSystemObjects();i++) + { + if (SOM::getSystemObject(i)->getSkinPartId() == scriptid) + { + int vcpu = SOM::getSystemObject(i)->getScriptId(); + Script::unloadScript(vcpu); + i--; + } + } +#ifdef WASABI_COMPILE_WNDMGR + for (i = 0;i < containers.getNumItems();i++) + { + Container *c = containers[i]; + if (c->getScriptId() == scriptid) + { + c->setDeleting(); + delete c; // c autodeletes from containers + i--; + } + } +#endif + guiTree->removeSkinPart(scriptid); +#ifdef WASABI_COMPILE_WNDMGR + AutoPopup::removeSkinPart(scriptid); +#endif +} + +#ifdef WASABI_COMPILE_WNDMGR +void SkinParser::unloadAllContainers() +{ + foreach(containers) + containers.getfor()->setDeleting(); + endfor; + containers.deleteAllSafe(); + //script_containers.removeAll(); +} +#endif + +void SkinParser::cleanUp() +{ +#ifdef WASABI_COMPILE_WNDMGR + AutoPopup::removeAllAddons(); +#endif + Script::unloadAllScripts(); +#ifdef WASABI_COMPILE_WNDMGR + unloadAllContainers(); +#endif + guiTree->reset(); +} + +#ifdef WASABI_COMPILE_WNDMGR +int SkinParser::getNumContainers() +{ + return containers.getNumItems(); +} + +Container *SkinParser::enumContainer(int n) +{ + return containers.enumItem(n); +} +#endif + +const wchar_t *SkinParser::getXmlRootPath() +{ + return includepath; +} + +#ifdef WASABI_COMPILE_WNDMGR +const wchar_t *SkinParser::getCurrentContainerId() +{ + if (curContainer) return curContainer->getId(); + return NULL; +} + +const wchar_t *SkinParser::getCurrentGroupId() +{ + if (curGroup) return curGroup->getGuiObject()->guiobject_getId(); + return NULL; +} +#endif + +GuiObject *SkinParser::createExternalGuiObject(const wchar_t *object_name, XmlObject **x, ifc_xmlreaderparams *params) +{ + svc_xuiObject *svc = NULL; + waServiceFactory *sf = xuiCache->findServiceFactory(object_name); + if (sf != NULL) + svc = castService(sf, FALSE); + else + { + XuiObjectSvcEnum xose(object_name); + svc = xose.getNext(FALSE); + sf = xose.getLastFactory(); + } + if (svc != NULL) + { + GuiObject *go = svc->instantiate(object_name, params); + if (!go) return NULL; + go->guiobject_setXuiService(svc); + go->guiobject_setXuiServiceFactory(sf); + ScriptObject *so = go->guiobject_getScriptObject(); + ASSERTPR(so != NULL, "tell francis to fix scriptobjectless xuiobjects"); + if (x) *x = static_cast(so->vcpu_getInterface(xmlObjectGuid)); + return go; + } + return NULL; +} + +void SkinParser::destroyGuiObject(GuiObject *o) +{ + svc_xuiObject *svc = o->guiobject_getXuiService(); + if (!svc) + { + ScriptObject *so = o->guiobject_getScriptObject(); + ASSERT(so != NULL); + GuiObjectWnd *go = static_cast(so->vcpu_getInterface(guiObjectWndGuid)); + ASSERT(go != NULL); + delete go; + } + else + { + waServiceFactory *sf = o->guiobject_getXuiServiceFactory(); + svc->destroy(o); + sf->releaseInterface(svc); + } +} + +#ifdef WASABI_COMPILE_WNDMGR +void SkinParser::focusFirst() +{ + foreach(containers) + for (int j = 0;j < containers.getfor()->getNumLayouts();j++) + { + Layout *l = containers.getfor()->enumLayout(j); + if (l != NULL && l->isVisible()) + { + l->setFocus(); + return ; + } + } + endfor; +} + +#ifdef WA3COMPATIBILITY +// non portable, the skin might be missing/buggy as hell, we need to use the os' msgbox +void SkinParser::emmergencyReloadDefaultSkin() +{ + if (!Main::revert_on_error) + { + if (!STRCASEEQLSAFE("Default", WASABI_API_SKIN->getSkinName())) + { + WASABI_API_WND->appdeactivation_setbypass(1); + Std::messageBox(StringPrintfW(L"Failed to load the skin (%s). Did you remove it ?\nThis could also be due to missing components (ie: wa2skin.wac for winamp 2 skins), please check the skin's documentation.\nReverting to default skin.", WASABI_API_SKIN->getSkinName()), "Error", 0); + WASABI_API_WND->appdeactivation_setbypass(0); + Skin::toggleSkin("Default"); + } + else + { + WASABI_API_WND->appdeactivation_setbypass(1); + Std::messageBox("The default skin did not load any user interface! Ooch! What should I do ? Oh well, good luck...", "Danger Danger Will Robinson!", 0); + WASABI_API_WND->appdeactivation_setbypass(0); + } + } +} +#endif +#endif + +GuiObject *SkinParser::xui_new(const wchar_t *classname) +{ + SkinItem *item = guiTree->getXuiGroupDef(classname); + if (item != NULL) + { + Group *old = curGroup; + const wchar_t *grpid = NULL; + if (item->getParams() != NULL) + grpid = item->getParams()->getItemValue(L"id"); + GuiObject *newgrp = NULL; + if (grpid != NULL) + newgrp = newDynamicGroup(grpid, GROUP_GROUP); + curGroup = old; + if (newgrp != NULL) return newgrp; + } + return createExternalGuiObject(classname, NULL, NULL); +} + +void SkinParser::xui_delete(GuiObject *o) +{ + destroyGuiObject(o); +} + +double SkinParser::getSkinVersion() +{ + return skinversion; +} + +void SkinParser::setAllLayoutsRatio(double ra) +{ + foreach(containers) + Container *c = containers.getfor(); + int n = c->getNumLayouts(); + for (int i = 0;i < n;i++) + { + Layout *l = c->enumLayout(i); + if (l->getNoParent() != 1) + l->setRenderRatio(ra); + } + endfor; +} + +void SkinParser::setAllLayoutsTransparency(int v) +{ + foreach(containers) + Container *c = containers.getfor(); + int n = c->getNumLayouts(); + for (int i = 0;i < n;i++) + { + Layout *l = c->enumLayout(i); + if (l->getNoParent() != 1) + l->setAlpha(v); + } + endfor; +} + +Layout *SkinParser::getMainLayout() +{ + foreach(containers) + Container *c = containers.getfor(); + if (!c->isMainContainer()) continue; + return c->enumLayout(0); + endfor; + return NULL; +} + +/* +void SkinParser::setAllLayoutsAutoOpacify(int ao, int force) { + foreach(containers) + Container *c = containers.getfor(); + int n = c->getNumLayouts(); + for (int i=0;ienumLayout(i); + if (l->getNoParent() != 1) + l->setAutoOpacify(ao, force); + } + endfor; +} + +void SkinParser::setAllLayoutsOverrideAlpha(int oa) { + foreach(containers) + Container *c = containers.getfor(); + int n = c->getNumLayouts(); + for (int i=0;ienumLayout(i); + if (l->isInited() && l->isTransparencySafe() && l->getTransparencyOverride() == -1) { + if (l->getNoParent() != 1) + l->setTransparency(oa); + } + } + endfor; +} +*/ + +Group *SkinParser::curGroup, *SkinParser::lastCreatedGroup; +int SkinParser::inScripts = 0, SkinParser::inElements = 0, SkinParser::inGroupDef = 0, SkinParser::inGroup = 0, SkinParser::inAccelerators = 0, SkinParser::inStringTable = 0; +int SkinParser::scriptId = 0; +int SkinParser::recording_container = 0; +int SkinParser::recording_groupdef = 0; +int SkinParser::staticloading = 0; +PtrList SkinParser::statusstack; +int SkinParser::instantiatinggroup = 0; +int SkinParser::allowscripts = 0; +skin_xmlreaderparams *SkinParser::groupparams = NULL; +PtrListQuickSorted SkinParser::quickxmltaglist; +double SkinParser::skinversion = 0.0; + +#ifdef WASABI_COMPILE_WNDMGR +Container *SkinParser::curContainer, *SkinParser::lastCreatedContainer; +Layout *SkinParser::curLayout; +int SkinParser::inContainer, SkinParser::inLayout; +//PtrList SkinParser::script_containers; +PtrList SkinParser::containers; +int SkinParser::centerskin; +int SkinParser::transcientcontainer; +SvcCacheT *SkinParser::xuiCache; +int SkinParser::loading_main_skinfile = 0; +StringW SkinParser::includepath; +#endif diff --git a/Src/Wasabi/api/skin/skinparse.h b/Src/Wasabi/api/skin/skinparse.h new file mode 100644 index 00000000..b232e92d --- /dev/null +++ b/Src/Wasabi/api/skin/skinparse.h @@ -0,0 +1,337 @@ +#ifndef __SKINPARSER_H +#define __SKINPARSER_H + +#include +#include +#include + +#ifdef WASABI_COMPILE_WNDMGR +#include +#include +#else +class Container; +class Layout; +#endif + +#ifdef WASABI_COMPILE_FONTS +#include +#endif + +#ifdef WASABI_COMPILE_XMLPARSER +#include +#else +class skin_xmlreaderparams; +#endif + +#ifdef WASABI_COMPILE_SKIN +#include +#else +class Group; +class SkinItem; +#endif + +class XmlObject; + +enum { + PARSETYPE_RESIZE=0, + PARSETYPE_COLOR, + PARSETYPE_COLORALPHA, + PARSETYPE_REGIONOP, + PARSETYPE_INTERNALACTION, + PARSETYPE_GROUPINHERITANCE, +} ; + +enum { + XML_TAG_CONTAINER, + XML_TAG_GROUP, + XML_TAG_CFGGROUP, + XML_TAG_GROUPDEF, + XML_TAG_LAYOUT, + XML_TAG_ACCELERATORS, + XML_TAG_ACCELERATOR, + XML_TAG_ELEMENTS, + XML_TAG_STRINGTABLE, + XML_TAG_STRINGENTRY, + XML_TAG_SCRIPTS, + XML_TAG_SNAPPOINT, + XML_TAG_TRUETYPEFONT, + XML_TAG_BITMAPFONT, + XML_TAG_SCRIPT, + XML_TAG_UNKNOWN, +}; + +#define GROUP_INHERIT_NOTHING 0 +#define GROUP_INHERIT_XUIOBJECTS 1 +#define GROUP_INHERIT_SCRIPTS 2 +#define GROUP_INHERIT_PARAMS 4 +#define GROUP_INHERIT_ALL GROUP_INHERIT_XUIOBJECTS | GROUP_INHERIT_SCRIPTS | GROUP_INHERIT_PARAMS +#define GROUP_INHERIT_ALLCONTENT GROUP_INHERIT_XUIOBJECTS | GROUP_INHERIT_SCRIPTS + +#define GROUP_GROUP 0 +#define GROUP_CFGGROUP 1 + +#ifdef WASABI_COMPILE_WNDMGR +#define GROUP_LAYOUTGROUP 2 +#endif + +enum { + ACTION_NONE, + ACTION_UNIMPLEMENTED=0x1000, + ACTION_MINIMIZE, + ACTION_MAXIMIZE, + ACTION_CLOSE, + ACTION_ABOUT, + ACTION_SWITCH, + ACTION_TOGGLE, + ACTION_SYSMENU, + ACTION_CONTROLMENU, + ACTION_REPORT_BUGS, + ACTION_MB_BACK, //FG + ACTION_MB_FORWARD, //FG + ACTION_MB_URL, //FG + ACTION_MB_STOP, //FG + ACTION_MB_REFRESH, //FG + ACTION_MB_HOME, //FG + ACTION_CB_NEXT, //FG + ACTION_CB_PREV, //FG + ACTION_CB_NEXTPAGE, + ACTION_CB_PREVPAGE, + ACTION_SCALE_50, //FG + ACTION_SCALE_75, //FG + ACTION_SCALE_100, //FG + ACTION_SCALE_125, //FG + ACTION_SCALE_150, //FG + ACTION_SCALE_200, //FG + ACTION_SCALE_400, //BU :) + ACTION_RELOAD_SKIN, + ACTION_TEXT_LARGER, + ACTION_TEXT_SMALLER, + ACTION_PREFERENCES, + ACTION_REGISTRY, + ACTION_ALPHA_10, //FG + ACTION_ALPHA_20, //FG + ACTION_ALPHA_30, //FG + ACTION_ALPHA_40, //FG + ACTION_ALPHA_50, //FG + ACTION_ALPHA_60, //FG + ACTION_ALPHA_70, //FG + ACTION_ALPHA_80, //FG + ACTION_ALPHA_90, //FG + ACTION_ALPHA_100, //FG + ACTION_AOT, //BU always-on-top for this window only + ACTION_TOGGLE_ALWAYS_ON_TOP, + ACTION_MENU, + ACTION_VIEW_FILE_INFO, + ACTION_ADD_BOOKMARK, + ACTION_EDIT_BOOKMARKS, + ACTION_ENDMODAL, + ACTION_ENFORCEMINMAX, + ACTION_DOUBLESIZE, + ACTION_CLOSE_WINDOW, + ACTION_WINDOWMENU, + ACTION_EQ_TOGGLE, + ACTION_AUTOOPACIFY, +}; + +enum { + DISPLAY_NONE, + DISPLAY_SONGNAME, + DISPLAY_SONGINFO, + DISPLAY_SONGTITLE, //BU + DISPLAY_SONGARTIST, + DISPLAY_SONGALBUM, + DISPLAY_SONGLENGTH, + DISPLAY_TIME, + DISPLAY_CB, //FG + DISPLAY_SONGBITRATE, + DISPLAY_SONGSAMPLERATE, + DISPLAY_SERVICE, + DISPLAY_SONGINFO_TRANSLATED, +}; + +enum { + ORIENTATION_HORIZONTAL, + ORIENTATION_VERTICAL +}; + +enum { + ALIGN_TOP, + ALIGN_BOTTOM, +}; + +typedef struct +{ + const wchar_t *tagname; + int id; + int needclosetag; +} xml_tag; + +class XmlTagComp +{ +public: + static int compareItem(void *p1, void *p2) + { + return WCSICMP(((xml_tag *)p1)->tagname, ((xml_tag *)p2)->tagname); + } + static int compareAttrib(const wchar_t *attrib, void *item) + { + return WCSICMP(attrib, ((xml_tag *)item)->tagname); + } +}; + +typedef struct { + int staticloading; + int recording_container; + int recording_groupdef; + Group *curGroup; + int inElements; + int inAccelerators; + int inStringTable; + int inGroupDef; + int inGroup; + StringW includepath; + skin_xmlreaderparams *groupparams; + int instantiatinggroup; + int scriptid; + int allowscripts; +#ifdef WASABI_COMPILE_WNDMGR + Container *curContainer; + Layout *curLayout; + int inContainer; + int inLayout; + int transcientcontainer; +#endif +} parser_status; + +class SkinParser { + +public: + static void initialize(); + static void shutdown(); + + static void setInitialFocus(); + + static GuiObject *newDynamicGroup(const wchar_t *groupid, int grouptype=GROUP_GROUP, SkinItem *item=NULL, int specific_scriptid=-1, int scripts_enabled=1); + static void parseGroup(SkinItem *groupitem, PtrList *ancestor_param_list, int params_only=0, int content_flags=GROUP_INHERIT_ALL); + static void loadScriptXml(const wchar_t *filename, int scriptid); + + static void xmlReaderCallback(int start, const wchar_t *xmltag, skin_xmlreaderparams *params); + static void onXmlStartElement(const wchar_t *name, skin_xmlreaderparams *params); + static void onXmlEndElement(const wchar_t *name); + + static void _onXmlStartElement(int object_type, const wchar_t *object_name, ifc_xmlreaderparams *params); + static void _onXmlEndElement(int object_type, const wchar_t *object_name); + +#ifdef WASABI_COMPILE_WNDMGR + static GUID *getComponentGuid(const wchar_t *id); + static int getComponentGuid(GUID *g, const wchar_t *p); +#endif + +#ifdef WASABI_COMPILE_WNDMGR + static int loadContainers(const wchar_t *skin); // todo: change name + static void startupContainers(int scriptid=-1); // todo: change name + static Container *loadContainerForWindowHolder(const wchar_t *groupid=NULL, GUID g=INVALID_GUID, int initit=1, int transcient=0, const wchar_t *containerid=NULL/*any*/, int container_flag=0/*dontcare*/); + static Container *newDynamicContainer(const wchar_t *containerid, int transcient=0); + static Container *getContainer(const wchar_t *name); + static Layout *getLayout(const wchar_t *container_layout_pair); + static Container *script_getContainer(const wchar_t *name); + static Container *instantiateDynamicContainer(SkinItem *containeritem, int initit=1); + static void componentToggled(GUID *g, int visible); + static void sendNotifyToAllContainers(int notifymsg, int param1=0, int param2=0); + static void toggleContainer(const wchar_t *); + static void toggleContainer(int); + static void showContainer(int num, int show); + static void showContainer(const wchar_t *, int show); + static PtrList containers; + //static PtrList script_containers; + static int getNumContainers(); + static Container *enumContainer(int n); + static int script_getNumContainers(); + static Container *script_enumContainer(int id); + static int isContainer(Container *c); + static int verifyContainer(Container *); + static void unloadAllContainers(); + static const wchar_t *getCurrentContainerId(); +#endif + + static void cleanupScript(int scriptid); + static void cleanUp(); +#ifdef WA3COMPATIBILITY + static void emmergencyReloadDefaultSkin(); +#endif + static void initGuiObject(GuiObject *o, Group *pgroup); + static void initXmlObject(XmlObject *x, ifc_xmlreaderparams *params, int no_id=0); + static void initLayout(Layout *l, Container *c); + + static int getAction(const wchar_t *action, const wchar_t **name=NULL); + static int getDisplay(const wchar_t *display); + static int getAlign(const wchar_t *align); + static int getOrientation(const wchar_t *orient); + static int parse(const wchar_t *str, const wchar_t *how); + static int parseResize(const wchar_t *r); + static int parseRegionOp(const wchar_t *r); + static int parseGroupInheritance(const wchar_t *str); + static ARGB32 parseColor(const wchar_t *color, int *error=NULL); // 1 for bitmap colors please + static ARGB32 parseColorAlpha(const wchar_t *color); // 1 for bitmap colors please + static const wchar_t *getXmlRootPath(); + static void pushParserState(); + static void popParserState(); + +#ifdef WASABI_COMPILE_WNDMGR + static void noCenterSkin() { centerskin=0; } +#endif + static const wchar_t *getCurrentGroupId(); + static void destroyGuiObject(GuiObject *o); + static void fillGroup(Group *group, const wchar_t *groupid, SkinItem *specific_item=NULL, int params_only=0, int no_params=0, int scripts_enabled=1); + + static int getSkinRect(RECT *r, ifc_window *exclude=NULL); + static void centerSkin(); + static void focusFirst(); + + static GuiObject *xui_new(const wchar_t *classname); + static void xui_delete(GuiObject *o); + + static double getSkinVersion(); + + static void setAllLayoutsRatio(double ra); + static void setAllLayoutsTransparency(int v); +// static void setAllLayoutsAutoOpacify(int v, int force=0); +// static void setAllLayoutsOverrideAlpha(int oa); + static Layout *getMainLayout(); + +private: + static GuiObject *createExternalGuiObject(const wchar_t *object_name, XmlObject **x, ifc_xmlreaderparams *params); + + static int getHex(const wchar_t *p,int size=-1); + + // xml parser handlers + static Group *curGroup, *lastCreatedGroup; + static int inScripts; + static int inElements, inAccelerators, inStringTable; + static int inGroupDef, inGroup; + static StringW includepath; + static int recording_container; + static int recording_groupdef; + static int staticloading; + static PtrList statusstack; + static int instantiatinggroup; + static int scriptId; + static int allowscripts; + static skin_xmlreaderparams *groupparams; + +#ifdef WASABI_COMPILE_WNDMGR + static Container *curContainer, *lastCreatedContainer; + static Layout *curLayout; + static int centerskin; + static int transcientcontainer; + static int inContainer; + static int inLayout; +#endif + static double skinversion; + static int loading_main_skinfile; + + static PtrListQuickSorted quickxmltaglist; + static SvcCacheT *xuiCache; +}; + +#endif \ No newline at end of file diff --git a/Src/Wasabi/api/skin/widgets.cpp b/Src/Wasabi/api/skin/widgets.cpp new file mode 100644 index 00000000..86fe0f05 --- /dev/null +++ b/Src/Wasabi/api/skin/widgets.cpp @@ -0,0 +1,451 @@ +#include +#include + +#include + +#ifdef WASABI_WIDGETS_LAYER +#include +#endif + +#ifdef WASABI_WIDGETS_ANIMLAYER +#include +#endif + +#ifdef WASABI_WIDGETS_BUTTON +#include +#endif + +#ifdef WASABI_WIDGETS_TGBUTTON +#include +#endif + +#ifdef WASABI_WIDGETS_GUIOBJECT +#include +#endif + +#ifdef WASABI_WIDGETS_GROUPLIST +#include +#endif + +#ifdef WASABI_WIDGETS_MOUSEREDIR +#include +#endif + +#ifdef WASABI_WIDGETS_SLIDER +#include +#endif + +#ifdef WASABI_WIDGETS_MEDIASLIDERS +#include +#include +#include +#include +#include +#endif + +#ifdef WASABI_WIDGETS_MEDIAVIS +#include +#endif + +#ifdef WASABI_WIDGETS_MEDIAEQCURVE +#include +#endif + +#ifdef WASABI_WIDGETS_MEDIASTATUS +#include +#endif + +#ifdef _WIN32 +#include +#endif + +#ifdef WASABI_WIDGETS_SVCWND +#include +#endif + +#ifdef WASABI_WIDGETS_TEXT +#include +#endif + +#ifdef WASABI_WIDGETS_EDIT +#include +#endif + +#ifdef WASABI_WIDGETS_TITLEBAR +#include +#endif + +#ifdef WASABI_WIDGETS_COMPBUCK +#include +#endif + +#ifdef WASABI_WIDGETS_BROWSER +#include +#ifdef WASABI_WIDGETS_BROWSERSVC +#include +#include +#endif +#endif + +#ifdef WASABI_WIDGETS_FRAME +#include +#endif + +#ifdef WASABI_WIDGETS_GRID +#include +#endif + +#ifdef WASABI_WIDGETS_QUERYDRAG +#include +#endif + +#ifdef WASABI_WIDGETS_QUERYLIST +#include +#endif + +#ifdef WASABI_WIDGETS_FILTERLIST +#include +#endif + +#ifdef WASABI_WIDGETS_QUERYLINE +#include +#endif + +#ifdef WASABI_WIDGETS_WNDHOLDER +#include +#endif + +#ifdef WASABI_COMPILE_WNDMGR + +#ifdef WASABI_WIDGETS_LAYOUTSTATUS +#include +#endif + +#endif // wndmgr + +#ifdef WASABI_WIDGETS_TABSHEET +#include +#endif + +#ifdef WASABI_WIDGETS_CHECKBOX +#include +#endif + +#ifdef WASABI_WIDGETS_TITLEBOX +#include +#endif + +#ifdef WASABI_WIDGETS_CUSTOMOBJECT +#include +#endif + +#ifdef WASABI_WIDGETS_OSWNDHOST +#include +#endif + +#ifdef WASABI_WIDGETS_RADIOGROUP +#include +#endif + +#ifdef WASABI_TOOLOBJECT_HIDEOBJECT +#include +#endif + +#ifdef WASABI_TOOLOBJECT_SENDPARAMS +#include +#endif + +#ifdef WASABI_TOOLOBJECT_ADDPARAMS +#include +#endif + +#ifdef WASABI_WIDGETS_LIST +#include +#endif + +#ifdef WASABI_WIDGETS_TREE +#include +#endif + +#ifdef WASABI_WIDGETS_DROPDOWNLIST +#include +#endif + +#ifdef WASABI_WIDGETS_COMBOBOX +#include +#endif + +#ifdef WASABI_WIDGETS_HISTORYEDITBOX +#include +#endif + +#ifdef WASABI_WIDGETS_OBJECTDIRECTORY +#include +#endif + +#ifdef WASABI_WIDGETS_RECTANGLE +#include +#endif + +#ifdef WASABI_WIDGETS_PATHPICKER +#include +#endif + +#ifdef WASABI_WIDGETS_GRADIENT +#include +#endif + +#ifdef WASABI_WIDGETS_MENU +#include +#endif + +#include + +#ifdef WASABI_COMPILE_STATSWND +#include +#include +#endif + +extern StringW g_resourcepath; + +Widgets::Widgets() { + count = 0; + + registerService(new XuiObjectCreator); + + #ifdef WASABI_WIDGETS_LAYER + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_ANIMLAYER + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_BUTTON + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_TGBUTTON + registerService(new XuiObjectCreator); + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_GROUPLIST + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_MOUSEREDIR + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_SLIDER + registerService(new XuiObjectCreator); + #endif +#ifdef _WIN32 + registerService(new XuiObjectCreator); +#endif + #ifdef WASABI_WIDGETS_MEDIASLIDERS + registerService(new XuiObjectCreator); + registerService(new XuiObjectCreator); + registerService(new XuiObjectCreator); + registerService(new XuiObjectCreator); + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_MEDIAVIS + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_MEDIAEQCURVE + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_MEDIASTATUS + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_SVCWND + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_TEXT + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_EDIT + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_TITLEBAR + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_COMPBUCK + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_BROWSER + registerService(new XuiObjectCreator); + #ifdef WASABI_WIDGETS_BROWSERSVC + registerService(new waServiceFactoryT); + #endif + #endif + #ifdef WASABI_WIDGETS_FRAME + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_GRID + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_QUERYDRAG + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_COMPILE_METADB + #ifdef WASABI_WIDGETS_QUERYLIST + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_FILTERLIST + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_QUERYLINE + registerService(new XuiObjectCreator); + #endif + #endif // metadb + #ifdef WASABI_WIDGETS_WNDHOLDER + registerService(new XuiObjectCreator); + registerService(new XuiObjectCreator); + #endif // components + #ifdef WASABI_COMPILE_WNDMGR + #ifdef WASABI_WIDGETS_LAYOUTSTATUS + registerService(new XuiObjectCreator); + #endif + #endif // wndmgr + #ifdef WASABI_WIDGETS_TABSHEET + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_CHECKBOX + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_TITLEBOX + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_CUSTOMOBJECT + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_OSWNDHOST + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_RADIOGROUP + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_TOOLOBJECT_HIDEOBJECT + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_TOOLOBJECT_SENDPARAMS + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_TOOLOBJECT_ADDPARAMS + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_LIST + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_TREE + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_DROPDOWNLIST + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_COMBOBOX + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_HISTORYEDITBOX + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_OBJECTDIRECTORY + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_RECTANGLE + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_PATHPICKER + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_GRADIENT + registerService(new XuiObjectCreator); + #endif + #ifdef WASABI_WIDGETS_MENU + registerService(new XuiObjectCreator); + #endif + + //registerService(new XuiObjectCreator); + + #ifdef WASABI_COMPILE_WNDMGR + //registerSkinFile("xml/msgbox/msgbox.xml"); + #endif + + #ifdef WASABI_WIDGETS_TOOLTIPS + //registerSkinFile("xml/tooltips/tooltips.xml"); + #endif + + #ifdef WASABI_COMPILE_STATSWND + registerService(new XuiObjectCreator); + statswnd = new StatsWnd(); + #endif + + //loadResources(); + WASABI_API_SYSCB->syscb_registerCallback(static_cast(this)); +} + +Widgets::~Widgets() { +#ifdef WASABI_COMPILE_STATSWND + delete statswnd; +#endif + WASABI_API_SYSCB->syscb_deregisterCallback(static_cast(this)); + if (WASABI_API_SVC != NULL) + { + int i=factories.getNumItems(); + while (i--) + WASABI_API_SVC->service_deregister(factories[i]); + } + factories.deleteAll(); +} + + +void Widgets::registerService(waServiceFactoryI *f) +{ + WASABI_API_SVC->service_register(f); + factories.addItem(f); +} + +int Widgets::skincb_onBeforeLoadingElements() { + if (count++ > 0) // if 0, we're already loaded so that the lib is usable without 'a skin' + loadResources(); + return 1; +} + +void Widgets::loadResources() +{ + // TODO: benski> want to put this into gen_ff somewhere, instead. + WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\winamp\\cover\\cover.xml")); + WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\winamp\\thinger\\thinger.xml")); + + #ifndef WA3COMPATIBILITY // ifNdef + WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\wasabi\\wasabi.xml")); + #endif + #ifdef WASABI_WIDGETS_PATHPICKER + WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\pathpicker\\pathpicker.xml")); + #endif + #ifdef WASABI_WIDGETS_LAYOUTSTATUS + WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\statusbar\\statusbar.xml")); + #endif + #ifdef WASABI_WIDGETS_TABSHEET + WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\tabsheet\\tabsheet.xml")); + #endif + #ifdef WASABI_WIDGETS_CHECKBOX + WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\checkbox\\checkbox.xml")); + #endif + #ifdef WASABI_WIDGETS_TITLEBOX + WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\titlebox\\titlebox.xml")); + #endif + #ifdef WASABI_WIDGETS_DROPDOWNLIST + WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\dropdownlist\\dropdownlist.xml")); + #endif + #ifdef WASABI_WIDGETS_COMBOBOX + WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\combobox\\combobox.xml")); + #endif + #ifdef WASABI_WIDGETS_HISTORYEDITBOX + WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\historyeditbox\\historyeditbox.xml")); + #endif + #ifdef WASABI_WIDGETS_TOOLTIPS + WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\tooltips\\tooltips.xml")); + #endif + #ifdef WASABI_COMPILE_WNDMGR + //WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,"xml\\msgbox\\msgbox.xml")); + #endif + WASABI_API_SKIN->loadSkinFile(StringPathCombine(g_resourcepath,L"xml\\about\\about.xml")); +} diff --git a/Src/Wasabi/api/skin/widgets.h b/Src/Wasabi/api/skin/widgets.h new file mode 100644 index 00000000..0089dfd2 --- /dev/null +++ b/Src/Wasabi/api/skin/widgets.h @@ -0,0 +1,35 @@ +#ifndef __WIDGETS_H +#define __WIDGETS_H + +#include +#include +#include + +class waServiceFactoryI; + +#ifdef WASABI_COMPILE_STATSWND +class StatsWnd; +#endif + +class Widgets : public SkinCallbackI { + public: + Widgets(); + virtual ~Widgets(); + + void registerService(waServiceFactoryI *f); + int skincb_onBeforeLoadingElements(); + + void loadResources(); + private: + + + PtrList factories; + int count; +#ifdef WASABI_COMPILE_STATSWND + StatsWnd *statswnd; +#endif +}; + + + +#endif diff --git a/Src/Wasabi/api/skin/widgets/animlayer.cpp b/Src/Wasabi/api/skin/widgets/animlayer.cpp new file mode 100644 index 00000000..10c7da1a --- /dev/null +++ b/Src/Wasabi/api/skin/widgets/animlayer.cpp @@ -0,0 +1,880 @@ +#include "precomp.h" +#include +#include +#include +#include + +const wchar_t animLayerXuiObjectStr[] = L"AnimatedLayer"; // This is the xml tag +char animLayerXuiSvcName[] = "Animated Layer xui object"; // this is the name of the xuiservice + +AnimLayerScriptController _animlayerController; +AnimLayerScriptController *animlayerController = &_animlayerController; + +// -- Functions table ------------------------------------- +function_descriptor_struct AnimLayerScriptController::exportedFunction[] = { + {L"setSpeed", 1, (void*)AnimatedLayer::script_vcpu_setSpeed }, + {L"gotoFrame", 1, (void*)AnimatedLayer::script_vcpu_gotoFrame }, + {L"setStartFrame", 1, (void*)AnimatedLayer::script_vcpu_setStartFrame }, + {L"setEndFrame", 1, (void*)AnimatedLayer::script_vcpu_setEndFrame }, + {L"setAutoReplay", 1, (void*)AnimatedLayer::script_vcpu_setAutoReplay }, + {L"play", 0, (void*)AnimatedLayer::script_vcpu_play }, + {L"togglePause", 0, (void*)AnimatedLayer::script_vcpu_pause }, + {L"stop", 0, (void*)AnimatedLayer::script_vcpu_stop }, + {L"pause", 0, (void*)AnimatedLayer::script_vcpu_pause }, + {L"isPlaying", 0, (void*)AnimatedLayer::script_vcpu_isPlaying }, + {L"isPaused", 0, (void*)AnimatedLayer::script_vcpu_isPaused }, + {L"isStopped", 0, (void*)AnimatedLayer::script_vcpu_isStopped }, + {L"getStartFrame", 0, (void*)AnimatedLayer::script_vcpu_getStartFrame }, + {L"getEndFrame", 0, (void*)AnimatedLayer::script_vcpu_getEndFrame }, + {L"getLength", 0, (void*)AnimatedLayer::script_vcpu_getLength }, + {L"getDirection", 0, (void*)AnimatedLayer::script_vcpu_getDirection }, + {L"getAutoReplay", 0, (void*)AnimatedLayer::script_vcpu_getAutoReplay }, + {L"getCurFrame", 0, (void*)AnimatedLayer::script_vcpu_getCurFrame }, + {L"onPlay", 0, (void*)AnimatedLayer::script_vcpu_onPlay }, + {L"onPause", 0, (void*)AnimatedLayer::script_vcpu_onPause }, + {L"onResume", 0, (void*)AnimatedLayer::script_vcpu_onResume }, + {L"onStop", 0, (void*)AnimatedLayer::script_vcpu_onStop }, + {L"onFrame", 1, (void*)AnimatedLayer::script_vcpu_onFrame }, + {L"setRealtime", 1, (void*)AnimatedLayer::script_vcpu_setRealtime }, + }; +// -------------------------------------------------------- + +const wchar_t *AnimLayerScriptController::getClassName() +{ + return L"AnimatedLayer"; +} + +const wchar_t *AnimLayerScriptController::getAncestorClassName() +{ + return L"Layer"; +} + +ScriptObject *AnimLayerScriptController::instantiate() +{ + AnimatedLayer *a = new AnimatedLayer; + ASSERT(a != NULL); + return a->getScriptObject(); +} + +void AnimLayerScriptController::destroy(ScriptObject *o) +{ + AnimatedLayer *a = static_cast(o->vcpu_getInterface(animLayerGuid)); + ASSERT(a != NULL); + delete a; +} + +void *AnimLayerScriptController::encapsulate(ScriptObject *o) +{ + return NULL; // no encapsulation for animatedlayer yet +} + +void AnimLayerScriptController::deencapsulate(void *o) +{} + +int AnimLayerScriptController::getNumFunctions() +{ + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *AnimLayerScriptController::getExportedFunctions() +{ + return exportedFunction; +} + +GUID AnimLayerScriptController::getClassGuid() +{ + return animLayerGuid; +} +XMLParamPair AnimatedLayer::params[] = + { + {ANIMLAYER_AUTOPLAY, L"AUTOPLAY"}, + {ANIMLAYER_AUTOREPLAY, L"AUTOREPLAY"}, + {ANIMLAYER_DEBUG, L"DEBUG"}, + {ANIMLAYER_ELEMENTFRAMES, L"ELEMENTFRAMES"}, + {ANIMLAYER_END, L"END"}, + {ANIMLAYER_FRAMEHEIGHT, L"FRAMEHEIGHT"}, + {ANIMLAYER_FRAMEWIDTH, L"FRAMEWIDTH"}, + {ANIMLAYER_REALTIME, L"REALTIME"}, + {ANIMLAYER_SPEED, L"SPEED"}, + {ANIMLAYER_START, L"START"}, + }; + +AnimatedLayer::AnimatedLayer() +{ + getScriptObject()->vcpu_setInterface(animLayerGuid, (void *)static_cast(this)); + getScriptObject()->vcpu_setClassName(L"AnimatedLayer"); + getScriptObject()->vcpu_setController(animlayerController); + autoplay = 0; + startframe = -1; + endframe = -1; + curframe = 0; + autoreplay = 1; + speed = 200; + timerset = 0; + status = ANIM_STOPPED; + realtime = 0; + debug = 0; + style = ANIM_UNKNOWN; + oldstyle = ANIM_UNKNOWN; + frameHeight = AUTOWH; + frameWidth = AUTOWH; + multiple_elements_frames = 0; + + xuihandle = newXuiHandle(); + CreateXMLParameters(xuihandle); +} + +void AnimatedLayer::CreateXMLParameters(int master_handle) +{ + //ANIMLAYER_PARENT::CreateXMLParameters(master_handle); + int numParams = sizeof(params) / sizeof(params[0]); + hintNumberOfParams(xuihandle, numParams); + for (int i = 0;i < numParams;i++) + addParam(xuihandle, params[i], XUI_ATTRIBUTE_IMPLIED); +} + +AnimatedLayer::~AnimatedLayer() +{ + bitmap_elements.deleteAll(); + regionlist.deleteAll(); +} + +int AnimatedLayer::onInit() +{ + ANIMLAYER_PARENT::onInit(); + + int w, h; + getGuiObject()->guiobject_getGuiPosition(NULL, NULL, &w, &h, NULL, NULL, NULL, NULL); + if (frameWidth == AUTOWH && w != AUTOWH) setWidth(w, 1); + if (frameHeight == AUTOWH && h != AUTOWH) setHeight(h, 1); + if (style == 0) + { + SkinBitmap *bm = getBitmap(); + if (bm) + { + if (bm->getWidth() != w) style = ANIM_HORZ; + else if (bm->getHeight() != h) style = ANIM_VERT; + } + } + + if (getRegionOp()) + makeRegion(); + reloadMultipleElements(); + + if (autoplay) + { + if (startframe == -1) + setStartFrame(0); + if (endframe == -1) + setEndFrame(getLength() - 1); + play(); + } + return 1; +} + +int AnimatedLayer::setXuiParam(int _xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *strvalue) +{ + if (xuihandle == _xuihandle) + { + switch (xmlattributeid) + { + case ANIMLAYER_AUTOREPLAY: setAutoReplay(WTOI(strvalue)); return 1; + case ANIMLAYER_AUTOPLAY: setAutoPlay(WTOI(strvalue)); return 1; + case ANIMLAYER_SPEED: setSpeed(WTOI(strvalue)); return 1; + case ANIMLAYER_FRAMEHEIGHT: setHeight(WTOI(strvalue)); return 1; + case ANIMLAYER_FRAMEWIDTH: setWidth(WTOI(strvalue)); return 1; + case ANIMLAYER_REALTIME: setRealtime(WTOI(strvalue)); return 1; + case ANIMLAYER_ELEMENTFRAMES: setElementFrames(WTOI(strvalue)); return 1; + case ANIMLAYER_START: setStartFrame(WTOI(strvalue)); return 1; + case ANIMLAYER_END: setEndFrame(WTOI(strvalue)); return 1; + case ANIMLAYER_DEBUG: debug = WTOI(strvalue); return 1; + } + } + return ANIMLAYER_PARENT::setXuiParam(_xuihandle, xmlattributeid, xmlattributename, strvalue); +} + +void AnimatedLayer::_invalidate() +{ + if (realtime) + { + if (isVisible() && !isMinimized()) cascadeRepaint(); + } + else + invalidate(); +} + +void AnimatedLayer::setElementFrames(int n) +{ + if (multiple_elements_frames == n) return ; + multiple_elements_frames = n; + if (n > 0) + { + if (style != ANIM_MULTI) + oldstyle = style; + style = ANIM_MULTI; + } + else + { + style = oldstyle; + oldstyle = ANIM_UNKNOWN; + } + invalidateRegionCache(); +} + +void AnimatedLayer::setHeight(int h, int selfset) +{ + ASSERTPR(selfset || style == ANIM_UNKNOWN, "can't set frameHeight if frameWidth has already been set"); + frameHeight = h; + if (!selfset) style = ANIM_VERT; +} + +int AnimatedLayer::getHeight() +{ + if (style == ANIM_MULTI) + { + SkinBitmap *bm0 = getElementBitmap(0); + if (bm0 == NULL) return AUTOWH; + return bm0->getHeight(); + } + if (style == ANIM_HORZ) + return ANIMLAYER_PARENT::getHeight(); + return frameHeight; +} + +void AnimatedLayer::setWidth(int w, int selfset) +{ + ASSERTPR(selfset || style == ANIM_UNKNOWN, "can't set frameWidth if frameHeight has already been set"); + frameWidth = w; + if (!selfset) style = ANIM_HORZ; +} + +int AnimatedLayer::getWidth() +{ + if (style == ANIM_MULTI) + { + SkinBitmap *bm0 = getElementBitmap(0); + if (bm0 == NULL) return AUTOWH; + return bm0->getWidth(); + } + if (style == ANIM_VERT) + return ANIMLAYER_PARENT::getWidth(); + return frameWidth; +} + +void AnimatedLayer::setRealtime(int r) +{ + realtime = r; +} + +int AnimatedLayer::getLength() +{ + if (style == ANIM_VERT && frameHeight < 0) return 0; + if (style == ANIM_HORZ && frameWidth < 0) return 0; + ASSERT(getBitmap() != NULL); + if (style == ANIM_VERT) + return ANIMLAYER_PARENT::getHeight() / frameHeight; + else if (style == ANIM_HORZ) + return ANIMLAYER_PARENT::getWidth() / frameWidth; + else if (style == ANIM_MULTI) + return multiple_elements_frames; + return 0; +} + +void AnimatedLayer::timerCallback(int id) +{ + switch (id) + { + case TIMER_ANIM: + { + int oldframe = curframe; + for (int i = 0;i < timerclient_getSkipped() + 1;i++) + { + if (curframe == getEndFrame()) + { + if (!autoreplay) + { + stop(); + break; + } + else + curframe = getStartFrame(); + } + else + { + curframe += getDirection(); + if (curframe != oldframe) + script_onFrame(curframe); + } + } + if (curframe != oldframe) + _invalidate(); + break; + } + default: + ANIMLAYER_PARENT::timerCallback(id); + break; + } +} + +int AnimatedLayer::getSourceOffsetY() +{ + if (style == ANIM_MULTI) return 0; + if (style == ANIM_HORZ) return 0; + if (curframe > getLength() - 1) return 0; + return curframe * getHeight(); +} + +int AnimatedLayer::getSourceOffsetX() +{ + if (style == ANIM_MULTI) return 0; + if (style == ANIM_VERT) return 0; + if (curframe > getLength() - 1) return 0; + return curframe * getWidth(); +} + +void AnimatedLayer::setSpeed(int s) +{ + speed = s; + if (status == ANIM_PLAYING) + { + stopTimer(); + startTimer(); + } +} + +void AnimatedLayer::stopTimer() +{ + if (timerset) + { + killTimer(TIMER_ANIM); + timerset = 0; + } +} + +void AnimatedLayer::startTimer() +{ + if (!timerset) + { + setTimer(TIMER_ANIM, speed); + timerset = 1; + } +} + +void AnimatedLayer::play() +{ + gotoFrame(startframe); + startTimer(); + status = ANIM_PLAYING; + script_onPlay(); +} + +void AnimatedLayer::stop() +{ + stopTimer(); + status = ANIM_STOPPED; + script_onStop(); +} + +void AnimatedLayer::pause() +{ + if (status == ANIM_PAUSED) + { + startTimer(); + status = ANIM_PLAYING; + script_onResume(); + } + else + if (status == ANIM_PLAYING) + { + stopTimer(); + status = ANIM_PAUSED; + script_onPause(); + } +} + +int AnimatedLayer::getCurFrame() +{ + return curframe; +} + +void AnimatedLayer::setStartFrame(int s) +{ + if (s < 0) return ; + startframe = s; +} + +void AnimatedLayer::setEndFrame(int e) +{ + if (e < 0) return ; + endframe = e; +} + +void AnimatedLayer::setAutoReplay(int r) +{ + autoreplay = r; +} + +void AnimatedLayer::setAutoPlay(int r) +{ + autoplay = r; + // no need to trigger an event here, we can't be in a script if we + // need to autoplay at xml loading +} + +int AnimatedLayer::getStartFrame() +{ + return startframe == -1 ? 0 : startframe; +} + +int AnimatedLayer::getEndFrame() +{ + return endframe == -1 ? getLength() - 1 : endframe; +} + +int AnimatedLayer::getSpeed() +{ + return speed; +} + +int AnimatedLayer::isPlaying() +{ + return status == ANIM_PLAYING; +} + +int AnimatedLayer::isStopped() +{ + return status == ANIM_STOPPED; +} + +int AnimatedLayer::isPaused() +{ + return status == ANIM_PAUSED; +} + +int AnimatedLayer::getAutoReplay() +{ + return autoreplay; +} + +int AnimatedLayer::getDirection() +{ + return getStartFrame() < getEndFrame() ? 1 : -1; +} + +void AnimatedLayer::gotoFrame(int n) +{ + if (n != curframe) + { + curframe = n; + _invalidate(); + script_onFrame(n); + } +} + +api_region *AnimatedLayer::getBitmapRegion() +{ + if (curframe > getLength() - 1) return NULL; + return regionlist.enumItem(getCurFrame()); +} + +void AnimatedLayer::makeRegion() +{ + if (!isInited()) return ; + regionlist.deleteAll(); + for (int i = 0;i < getLength();i++) + { + RegionI *rg; + if (style == ANIM_VERT) + { + RECT g = {0, i * getHeight(), getWidth(), i * getHeight() + getHeight()}; + rg = new RegionI(getBitmap(), &g, 0, -i * getHeight(), FALSE); + } + else if (style == ANIM_HORZ) + { + RECT g = {i * getWidth(), 0, i * getWidth() + getWidth(), getHeight()}; + rg = new RegionI(getBitmap(), &g, -i * getWidth(), 0, FALSE); + } + else if (style == ANIM_MULTI) + { + RECT g = {0, 0, getWidth(), getHeight()}; + rg = new RegionI(getElementBitmap(i), &g, 0, 0, FALSE); + } + else + return; + regionlist.addItem(rg); + } +} + +void AnimatedLayer::deleteRegion() +{ + regionlist.deleteAll(); +} + +SkinBitmap *AnimatedLayer::getBitmap() +{ + if (style != ANIM_MULTI) + return layer_getBitmap(); + return getElementBitmap(getCurFrame()); +} + +SkinBitmap *AnimatedLayer::getElementBitmap(int n) +{ + return bitmap_elements.enumItem(n); +} + +void AnimatedLayer::reloadMultipleElements() +{ + bitmap_elements.deleteAll(); + if (style != ANIM_MULTI) return ; + // basically blah$$$$.png becomes blah0000.png, blah0001.png etc + for (int i = 0;i < multiple_elements_frames;i++) + { + StringW elementname(layer_getBitmapName()); + elementname.replaceNumericField(i); + bitmap_elements.addItem(new SkinBitmap(elementname)); + } +} + +void AnimatedLayer::setBitmap(const wchar_t *name) +{ + ANIMLAYER_PARENT::setBitmap(name); + reloadMultipleElements(); +} + +// Script virtuals + +int AnimatedLayer::script_getStartFrame() +{ + return getStartFrame(); +} + +int AnimatedLayer::script_getEndFrame() +{ + return getEndFrame(); +} + +int AnimatedLayer::script_getSpeed() +{ + return getSpeed(); +} + +int AnimatedLayer::script_getCurFrame() +{ + return getCurFrame(); +} + +int AnimatedLayer::script_getDirection() +{ + return getDirection(); +} + +int AnimatedLayer::script_getAutoReplay() +{ + return getAutoReplay(); +} + +int AnimatedLayer::script_getLength() +{ + return getLength(); +} + +int AnimatedLayer::script_isPlaying() +{ + return isPlaying(); +} + +int AnimatedLayer::script_isStopped() +{ + return isStopped(); +} + +int AnimatedLayer::script_isPaused() +{ + return isPaused(); +} + +void AnimatedLayer::script_play() +{ + play(); +} + +void AnimatedLayer::script_pause() +{ + pause(); +} + +void AnimatedLayer::script_stop() +{ + stop(); +} + +void AnimatedLayer::script_setStartFrame(int s) +{ + setStartFrame(s); +} + +void AnimatedLayer::script_setEndFrame(int e) +{ + setEndFrame(e); +} + +void AnimatedLayer::script_setRealtime(int r) +{ + setRealtime(r); +} + +void AnimatedLayer::script_setAutoReplay(int r) +{ + setAutoReplay(r); +} +/* +void AnimatedLayer::script_gotoFrame(int n) { + gotoFrame(n); +}*/ + +void AnimatedLayer::script_setSpeed(int n) +{ + setSpeed(n); +} + +void AnimatedLayer::script_onPause() +{ + script_vcpu_onPause(SCRIPT_CALL, getScriptObject()); +} + +void AnimatedLayer::script_onResume() +{ + script_vcpu_onResume(SCRIPT_CALL, getScriptObject()); +} + +void AnimatedLayer::script_onStop() +{ + script_vcpu_onStop(SCRIPT_CALL, getScriptObject()); +} + +void AnimatedLayer::script_onPlay() +{ + script_vcpu_onPlay(SCRIPT_CALL, getScriptObject()); +} + +void AnimatedLayer::script_onFrame(int n) +{ + if (getRegionOp()) { invalidateRegionCache(); getParent()->invalidateWindowRegion(); } + scriptVar _n = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_n, n); + script_vcpu_onFrame(SCRIPT_CALL, getScriptObject(), _n); +} + +// end virtuals + +// VCPU + +scriptVar AnimatedLayer::script_vcpu_gotoFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar f) +{ + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&f)); + AnimatedLayer *a = static_cast(o->vcpu_getInterface(animLayerGuid)); + if (a) a-> /*script_*/gotoFrame(SOM::makeInt(&f)); + RETURN_SCRIPT_VOID; +} + +scriptVar AnimatedLayer::script_vcpu_getLength(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + AnimatedLayer *a = static_cast(o->vcpu_getInterface(animLayerGuid)); + if (a) return MAKE_SCRIPT_INT(a->script_getLength()); + RETURN_SCRIPT_ZERO; +} + +scriptVar AnimatedLayer::script_vcpu_setStartFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s) +{ + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&s)); + AnimatedLayer *a = static_cast(o->vcpu_getInterface(animLayerGuid)); + if (a) a->script_setStartFrame(SOM::makeInt(&s)); + RETURN_SCRIPT_VOID; +} + +scriptVar AnimatedLayer::script_vcpu_setEndFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar e) +{ + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&e)); + AnimatedLayer *a = static_cast(o->vcpu_getInterface(animLayerGuid)); + if (a) a->script_setEndFrame(SOM::makeInt(&e)); + RETURN_SCRIPT_VOID; +} + +scriptVar AnimatedLayer::script_vcpu_setAutoReplay(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar rp) +{ + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&rp)); + AnimatedLayer *a = static_cast(o->vcpu_getInterface(animLayerGuid)); + if (a) a->script_setAutoReplay(SOM::makeBoolean(&rp)); + RETURN_SCRIPT_VOID; +} + +scriptVar AnimatedLayer::script_vcpu_play(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + AnimatedLayer *a = static_cast(o->vcpu_getInterface(animLayerGuid)); + if (a) a->script_play(); + RETURN_SCRIPT_VOID; +} + +scriptVar AnimatedLayer::script_vcpu_pause(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + AnimatedLayer *a = static_cast(o->vcpu_getInterface(animLayerGuid)); + if (a) a->script_pause(); + RETURN_SCRIPT_VOID; +} + +scriptVar AnimatedLayer::script_vcpu_stop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + AnimatedLayer *a = static_cast(o->vcpu_getInterface(animLayerGuid)); + if (a) a->script_stop(); + RETURN_SCRIPT_VOID; +} + +scriptVar AnimatedLayer::script_vcpu_onPlay(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, animlayerController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar AnimatedLayer::script_vcpu_onStop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, animlayerController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar AnimatedLayer::script_vcpu_onPause(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, animlayerController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar AnimatedLayer::script_vcpu_onResume(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, animlayerController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar AnimatedLayer::script_vcpu_onFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar f) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1(o, animlayerController, f); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, f); +} + +scriptVar AnimatedLayer::script_vcpu_getAutoReplay(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + AnimatedLayer *a = static_cast(o->vcpu_getInterface(animLayerGuid)); + if (a) return MAKE_SCRIPT_INT(a->script_getAutoReplay()); + RETURN_SCRIPT_ZERO; +} + +scriptVar AnimatedLayer::script_vcpu_getDirection(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + AnimatedLayer *a = static_cast(o->vcpu_getInterface(animLayerGuid)); + if (a) return MAKE_SCRIPT_INT(a->script_getDirection()); + RETURN_SCRIPT_ZERO; +} + +scriptVar AnimatedLayer::script_vcpu_getStartFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + AnimatedLayer *a = static_cast(o->vcpu_getInterface(animLayerGuid)); + if (a) return MAKE_SCRIPT_INT(a->script_getStartFrame()); + RETURN_SCRIPT_ZERO; +} + +scriptVar AnimatedLayer::script_vcpu_getEndFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + AnimatedLayer *a = static_cast(o->vcpu_getInterface(animLayerGuid)); + if (a) return MAKE_SCRIPT_INT(a->script_getEndFrame()); + RETURN_SCRIPT_ZERO; +} + +scriptVar AnimatedLayer::script_vcpu_isPlaying(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + AnimatedLayer *a = static_cast(o->vcpu_getInterface(animLayerGuid)); + if (a) return MAKE_SCRIPT_BOOLEAN(a->script_isPlaying()); + RETURN_SCRIPT_ZERO; +} + +scriptVar AnimatedLayer::script_vcpu_isPaused(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + AnimatedLayer *a = static_cast(o->vcpu_getInterface(animLayerGuid)); + if (a) return MAKE_SCRIPT_BOOLEAN(a->script_isPaused()); + RETURN_SCRIPT_ZERO; +} + +scriptVar AnimatedLayer::script_vcpu_isStopped(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + AnimatedLayer *a = static_cast(o->vcpu_getInterface(animLayerGuid)); + if (a) return MAKE_SCRIPT_BOOLEAN(a->script_isStopped()); + RETURN_SCRIPT_ZERO; +} + +scriptVar AnimatedLayer::script_vcpu_getSpeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + AnimatedLayer *a = static_cast(o->vcpu_getInterface(animLayerGuid)); + if (a) return MAKE_SCRIPT_INT(a->script_getSpeed()); + RETURN_SCRIPT_ZERO; +} + +scriptVar AnimatedLayer::script_vcpu_getCurFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + AnimatedLayer *a = static_cast(o->vcpu_getInterface(animLayerGuid)); + if (a) return MAKE_SCRIPT_INT(a->script_getCurFrame()); + RETURN_SCRIPT_ZERO; +} + +scriptVar AnimatedLayer::script_vcpu_setSpeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s) +{ + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&s)); + AnimatedLayer *a = static_cast(o->vcpu_getInterface(animLayerGuid)); + if (a) a->script_setSpeed(SOM::makeInt(&s)); + RETURN_SCRIPT_VOID; +} + +scriptVar AnimatedLayer::script_vcpu_setRealtime(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r) +{ + SCRIPT_FUNCTION_INIT; + AnimatedLayer *a = static_cast(o->vcpu_getInterface(animLayerGuid)); + if (a) a->script_setRealtime(SOM::makeInt(&r)); + RETURN_SCRIPT_VOID; +} + + +int AnimatedLayer::onPaint(Canvas *canvas) +{ + int r = ANIMLAYER_PARENT::onPaint(canvas); + if (debug && canvas != NULL) + { + Wasabi::FontInfo fontInfo; + fontInfo.pointSize = 14; + canvas->textOut(0, 0, StringPrintfW(L"%d", curframe), &fontInfo); + } + return r; +} diff --git a/Src/Wasabi/api/skin/widgets/animlayer.h b/Src/Wasabi/api/skin/widgets/animlayer.h new file mode 100644 index 00000000..94c45606 --- /dev/null +++ b/Src/Wasabi/api/skin/widgets/animlayer.h @@ -0,0 +1,214 @@ +#ifndef _ANIMLAYER_H +#define _ANIMLAYER_H + +#include "layer.h" + +// {6B64CD27-5A26-4c4b-8C59-E6A70CF6493A} +static const GUID animLayerGuid = +{ 0x6b64cd27, 0x5a26, 0x4c4b, { 0x8c, 0x59, 0xe6, 0xa7, 0xc, 0xf6, 0x49, 0x3a } }; + +#define ANIMLAYER_SCRIPTPARENT Layer + +class AnimLayerScriptController : public LayerScriptController { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController() { return layerController; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern AnimLayerScriptController *animlayerController; + + +#ifndef _NOSTUDIO + +#define TIMER_ANIM 872 + +#define ANIM_STOPPED 0 +#define ANIM_PLAYING 1 +#define ANIM_PAUSED 2 + +#define ANIMLAYER_PARENT Layer + +#define ANIM_UNKNOWN 0 +#define ANIM_VERT 1 +#define ANIM_HORZ 2 +#define ANIM_MULTI 3 + +class AnimatedLayer : public ANIMLAYER_SCRIPTPARENT { +public: + AnimatedLayer(); + virtual ~AnimatedLayer(); + + virtual int onInit(); + virtual int getHeight(); + virtual int getWidth(); + virtual void timerCallback(int id); + virtual int getSourceOffsetY(); + virtual int getSourceOffsetX(); + virtual void setAutoPlay(int p); + virtual int setXuiParam(int _xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *value); + + virtual void setHeight(int h, int selfset=0); + virtual void setWidth(int w, int selfset=0); + virtual SkinBitmap *getBitmap(); + + void play(); + void pause(); + void stop(); + int getLength(); + void setStartFrame(int s); + void setEndFrame(int e); + void setAutoReplay(int r); + int getStartFrame(); + int getEndFrame(); + int isPlaying(); + int isPaused(); + int isStopped(); + int getSpeed(); + int getDirection(); + void gotoFrame(int n); + void setSpeed(int s); + int getAutoReplay(); + int getCurFrame(); + void setRealtime(int r); + + virtual api_region *getBitmapRegion(); + SkinBitmap *getElementBitmap(int n); + virtual void makeRegion(); + virtual void deleteRegion(); + void reloadMultipleElements(); + virtual void setElementFrames(int n); + virtual void setBitmap(const wchar_t *name); + + virtual int onPaint(Canvas *canvas); + +protected: + /*static */void CreateXMLParameters(int master_handle); + enum { + ANIMLAYER_AUTOREPLAY=0, + ANIMLAYER_AUTOPLAY, + ANIMLAYER_SPEED, + ANIMLAYER_FRAMEHEIGHT, + ANIMLAYER_FRAMEWIDTH, + ANIMLAYER_REALTIME, + ANIMLAYER_ELEMENTFRAMES, + ANIMLAYER_START, + ANIMLAYER_END, + ANIMLAYER_DEBUG, + }; + +private: + int frameHeight, frameWidth; + int startframe; + int endframe; + int status; + int curframe; + int autoreplay; + int speed; + int timerset; + int realtime; + int style; + int autoplay; + PtrList bitmap_elements; + int multiple_elements_frames; + int debug; + int xuihandle; + + void _invalidate(); + + void stopTimer(); + void startTimer(); + + PtrList regionlist; + int oldstyle; + static XMLParamPair params[]; + +// FG> +// -- SCRIPT ----------------------------------------------------- + +public: + + // virtuals + + virtual void script_play(); + virtual void script_pause(); + virtual void script_stop(); + virtual int script_getLength(); + virtual void script_setStartFrame(int s); + virtual void script_setEndFrame(int e); + virtual void script_setAutoReplay(int r); + virtual void script_setSpeed(int a); + virtual int script_getStartFrame(); + virtual int script_getEndFrame(); + virtual int script_getSpeed(); + virtual int script_getDirection(); + virtual int script_getAutoReplay(); + virtual int script_isPlaying(); + virtual int script_isStopped(); + virtual int script_isPaused(); + //virtual void script_gotoFrame(int f); + virtual void script_onFrame(int n); + virtual void script_onStop(); + virtual void script_onPlay(); + virtual void script_onPause(); + virtual void script_onResume(); + virtual int script_getCurFrame(); + virtual void script_setRealtime(int r); + + static scriptVar script_vcpu_setSpeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s); + static scriptVar script_vcpu_gotoFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar f); + static scriptVar script_vcpu_setStartFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s); + static scriptVar script_vcpu_setEndFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar e); + static scriptVar script_vcpu_setAutoReplay(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar ar); + static scriptVar script_vcpu_play(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_pause(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_stop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + + static scriptVar script_vcpu_isPlaying(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_isPaused(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_isStopped(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getStartFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getEndFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getLength(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getDirection(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getAutoReplay(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getSpeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getCurFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_setRealtime(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r); + static scriptVar script_vcpu_onPlay(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_onStop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_onPause(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_onResume(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_onFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar f); + + +#else +class AnimatedLayer : public ANIMLAYER_SCRIPTPARENT { + +public: + +#endif + +// INSERT_SCRIPT_OBJECT_CONTROL + +}; + +extern const wchar_t animLayerXuiObjectStr[]; +extern char animLayerXuiSvcName[]; +class AnimLayerXuiSvc : public XuiObjectSvc {}; + + +#endif diff --git a/Src/Wasabi/api/skin/widgets/button.cpp b/Src/Wasabi/api/skin/widgets/button.cpp new file mode 100644 index 00000000..639443bc --- /dev/null +++ b/Src/Wasabi/api/skin/widgets/button.cpp @@ -0,0 +1,508 @@ +#include +#include +#include "button.h" +#include + +#include + +#ifdef WASABI_WIDGETS_COMPBUCK +#include +#endif + +#ifdef WASABI_COMPILE_MEDIACORE +#include +#endif + +#include + +const wchar_t buttonXuiObjectStr[] = L"Button"; // This is the xml tag +char buttonXuiSvcName[] = "Button xui object"; // this is the name of the xuiservice + + +ButtonScriptController _buttonController; +ButtonScriptController *buttonController = &_buttonController; + +// -- Functions table ------------------------------------- +function_descriptor_struct ButtonScriptController::exportedFunction[] = { +{L"onActivate", 1, (void*)Wasabi::Button::script_vcpu_onActivate }, + {L"setActivated", 1, (void*)Wasabi::Button::script_vcpu_setActivated }, + {L"getActivated", 0, (void*)Wasabi::Button::script_vcpu_getActivated }, + {L"onLeftClick", 0, (void*)Wasabi::Button::script_vcpu_onLeftClick }, + {L"onRightClick", 0, (void*)Wasabi::Button::script_vcpu_onRightClick }, + {L"leftClick", 0, (void*)Wasabi::Button::script_vcpu_leftClick }, + {L"rightClick", 0, (void*)Wasabi::Button::script_vcpu_rightClick }, + {L"setActivatedNoCallback", 1, (void*)Wasabi::Button::script_vcpu_setActivatedNoCallback }, + +}; +// -------------------------------------------------------- + +const wchar_t *ButtonScriptController::getClassName() { + return L"Button"; +} + +const wchar_t *ButtonScriptController::getAncestorClassName() { + return L"GuiObject"; +} + +ScriptObject *ButtonScriptController::instantiate() { + Wasabi::Button *b = new Wasabi::Button; + ASSERT(b != NULL); + return b->getScriptObject(); +} + +void ButtonScriptController::destroy(ScriptObject *o) { + Wasabi::Button *b = static_cast(o->vcpu_getInterface(buttonGuid)); + ASSERT(b != NULL); + delete b; +} + +void *ButtonScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for buttojn yet +} + +void ButtonScriptController::deencapsulate(void *o) { +} + +int ButtonScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *ButtonScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID ButtonScriptController::getClassGuid() { + return buttonGuid; +} + +XMLParamPair Wasabi::Button::params[] = +{ + {BUTTON_ACTION, L"ACTION"}, + {BUTTON_ACTIONTARGET, L"ACTION_TARGET"}, + {BUTTON_ACTIVEIMAGE, L"ACTIVEIMAGE"}, + {BUTTON_BORDERS, L"BORDERS"}, + #ifdef WASABI_WIDGETS_COMPBUCK + {BUTTON_CBTARGET, L"CBTARGET"}, +#endif + {BUTTON_CENTER_IMAGE, L"CENTER_IMAGE"}, + {BUTTON_DOWNIMAGE, L"DOWNIMAGE"}, + {BUTTON_HOVERIMAGE, L"HOVERIMAGE"}, + {BUTTON_IMAGE, L"IMAGE"}, + {BUTTON_PARAM, L"PARAM"}, + // {BUTTON_RECTRGN, "RECTRGN"}, + {BUTTON_RETCODE, L"RETCODE"}, + {BUTTON_BORDERSTYLE, L"STYLE"}, + {BUTTON_TEXT, L"TEXT"}, + {BUTTON_TEXTCOLOR, L"TEXTCOLOR"}, + {BUTTON_TEXTHOVERCOLOR, L"TEXTDIMMEDCOLOR"}, + {BUTTON_TEXTHOVERCOLOR, L"TEXTHOVERCOLOR"}, +}; +// ----------------------------------------------------------------------- + +Wasabi::Button::Button() { + disablenextcontextmenu = 0; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_addCallback(0, this); +#endif + getScriptObject()->vcpu_setInterface(buttonGuid, (void *)static_cast(this)); + getScriptObject()->vcpu_setClassName(L"Button"); + getScriptObject()->vcpu_setController(buttonController); + cbtarget = NULL; + setBorders(FALSE); + xuihandle = newXuiHandle(); + CreateXMLParameters(xuihandle); +} + +void Wasabi::Button::CreateXMLParameters(int master_handle) +{ + //BUTTON_PARENT::CreateXMLParameters(master_handle); + int numParams = sizeof(params) / sizeof(params[0]); + hintNumberOfParams(xuihandle, numParams); + for (int i = 0;i < numParams;i++) + addParam(xuihandle, params[i], XUI_ATTRIBUTE_IMPLIED); +} + +Wasabi::Button::~Button() { + //int c=getNotifyId(); +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_delCallback(0, this); +#endif + WASABI_API_SYSCB->syscb_deregisterCallback(static_cast(this)); +} + +int Wasabi::Button::onInit() +{ + BUTTON_PARENT::onInit(); + if (!action.isempty()) + setAction(action); + //FG> this is retarded, and yes, i'm the one who coded it in + //if (s_normal.isempty() && s_down.isempty() && s_hover.isempty() && s_active.isempty()) + // setRectRgn(1); + setupBitmaps(); + //int c=getNotifyId(); + setHandleRightClick(TRUE); +#ifdef WASABI_COMPILE_MEDIACORE + if (WCSCASEEQLSAFE(actionstr, L"eq_toggle") + || WCSCASEEQLSAFE(actionstr, L"eq_auto")) + { + if (WCSCASEEQLSAFE(actionstr, L"eq_toggle")) + corecb_onEQStatusChange(WASABI_API_MEDIACORE->core_getEqStatus(0)); + else corecb_onEQAutoChange(WASABI_API_MEDIACORE->core_getEqAuto(0)); + } +#endif + WASABI_API_SYSCB->syscb_registerCallback(static_cast(this)); + return 1; +} + +void Wasabi::Button::setupBitmaps() +{ + setBitmaps(s_normal, s_down, s_hover, s_active); +} + +void Wasabi::Button::setParam(const wchar_t *p) +{ + param=p; +} + +void Wasabi::Button::setAction(const wchar_t *_action) +{ + actionstr = _action; + const wchar_t *name; + int id = SkinParser::getAction(_action, &name); + actionname = name; + if (id == ACTION_NONE || !action_target.isempty()) + action = _action; + else { + setNotifyId(id); + action = L""; + } +} + +int Wasabi::Button::setXuiParam(int _xuihandle, int xmlattributeid, const wchar_t *paramname, const wchar_t *strvalue) { + if (xuihandle == _xuihandle) { + switch (xmlattributeid) { + case BUTTON_TEXT: setButtonText(strvalue); return 1; + case BUTTON_ACTION: action = strvalue; if (isInited()) { setAction(action); } return 1; + case BUTTON_IMAGE: s_normal = strvalue; if (isInited()) { setBitmaps(s_normal, s_down, s_hover, s_active); } return 1; + case BUTTON_DOWNIMAGE: s_down = strvalue; if (isInited()) { setBitmaps(s_normal, s_down, s_hover, s_active); } return 1; + case BUTTON_HOVERIMAGE: s_hover = strvalue; if (isInited()) { setBitmaps(s_normal, s_down, s_hover, s_active); } return 1; + case BUTTON_ACTIVEIMAGE: s_active = strvalue; if (isInited()) { setBitmaps(s_normal, s_down, s_hover, s_active); }return 1; + case BUTTON_PARAM: setParam(strvalue); return 1; + //case BUTTON_RECTRGN: setRectRgn(WTOI(strvalue)); return 1; +#ifdef WASABI_WIDGETS_COMPBUCK + case BUTTON_CBTARGET: setCBTarget(strvalue); return 1; +#endif + case BUTTON_BORDERS: setBorders(WTOI(strvalue)); return 1; + case BUTTON_BORDERSTYLE: setBorderStyle(strvalue); return 1; + case BUTTON_RETCODE: setModalRetCode(WTOI(strvalue)); return 1; + case BUTTON_ACTIONTARGET: { + action_target = strvalue; + if (!actionstr.isempty()) { + action = actionstr; + setAction(action); + } + return 1; + } + case BUTTON_CENTER_IMAGE: setBitmapCenter(WTOI(strvalue)); return 1; + case BUTTON_TEXTCOLOR: setTextColor(strvalue); return 1; + case BUTTON_TEXTHOVERCOLOR: setTextHoverColor(strvalue); return 1; + case BUTTON_TEXTDIMMEDCOLOR: setTextDimmedColor(strvalue); return 1; + } + } + return BUTTON_PARENT::setXuiParam(_xuihandle, xmlattributeid, paramname, strvalue); +} + +#ifdef WASABI_WIDGETS_COMPBUCK +void Wasabi::Button::setCBTarget(const wchar_t *t) { + cbtarget = ComponentBucket2::getComponentBucket(t); +} +#endif + +const wchar_t *Wasabi::Button::getParam() +{ + return param; +} + +int Wasabi::Button::childNotify(ifc_window *child, int msg, intptr_t param1, intptr_t param2) { +#ifdef WASABI_COMPILE_WNDMGR + switch(msg) + { +#ifdef _WIN32 + case WM_WA_CONTAINER_TOGGLED: + if(!param) break; + if(!WCSICMP((const wchar_t *)param1,param)) setActivatedButton(param2); + break; +#else +#warning port me +#endif +#ifdef WASABI_COMPILE_COMPONENTS + case WM_WA_COMPONENT_TOGGLED: + if(!param) break; + GUID *g; + if(g=SkinParser::getComponentGuid(param)) { + if(!MEMCMP((GUID *)param1,g,sizeof(GUID))) setActivatedButton(param2); + } + break; +#endif + } +#endif + return BUTTON_PARENT::childNotify(child, msg, param1, param2); +} + +#ifdef WASABI_COMPILE_MEDIACORE +int Wasabi::Button::corecb_onEQStatusChange(int newval) { + if(WCSCASEEQLSAFE(actionstr, L"eq_toggle")) setActivatedButton(newval); + return 0; +} + +int Wasabi::Button::corecb_onEQAutoChange(int newval) { + if(WCSCASEEQLSAFE(actionstr,L"eq_auto")) setActivatedButton(newval); + return 0; +} +#endif + +int Wasabi::Button::onLeftButtonUp(int x, int y) { + BUTTON_PARENT::onLeftButtonUp(x, y); + if (!WASABI_API_MAKI->vcpu_getComplete()) { +#ifdef WASABI_WIDGETS_COMPBUCK + if (getNotifyId() == ACTION_CB_NEXT) { + if (cbtarget) + cbtarget->ComponentBucket2::next_up(); + else + ComponentBucket2::next_up(getGuiObject()->guiobject_getParentGroup()); + } else if (getNotifyId() == ACTION_CB_PREV) { + if (cbtarget) + cbtarget->ComponentBucket2::prev_up(); + else + ComponentBucket2::prev_up(getGuiObject()->guiobject_getParentGroup()); + } else if (getNotifyId() == ACTION_CB_NEXTPAGE) { + if (cbtarget) + cbtarget->ComponentBucket2::next_page(); + else + ComponentBucket2::next_page(getGuiObject()->guiobject_getParentGroup()); + } else if (getNotifyId() == ACTION_CB_PREVPAGE) { + if (cbtarget) + cbtarget->ComponentBucket2::prev_page(); + else + ComponentBucket2::prev_page(getGuiObject()->guiobject_getParentGroup()); + } +#endif + } + return 1; +} + +int Wasabi::Button::onLeftButtonDown(int x, int y) { + BUTTON_PARENT::onLeftButtonDown(x, y); + if (!WASABI_API_MAKI->vcpu_getComplete()) { +#ifdef WASABI_WIDGETS_COMPBUCK + if (getNotifyId() == ACTION_CB_NEXT) { + if (cbtarget) + cbtarget->ComponentBucket2::next_down(); + else + ComponentBucket2::next_down(getGuiObject()->guiobject_getParentGroup()); + } else if (getNotifyId() == ACTION_CB_PREV) { + if (cbtarget) + cbtarget->ComponentBucket2::prev_down(); + else + ComponentBucket2::prev_down(getGuiObject()->guiobject_getParentGroup()); + } +#endif + } + return 1; +} + +void Wasabi::Button::onLeftPush(int x, int y) { + BUTTON_PARENT::onLeftPush(x, y); + script_vcpu_onLeftClick(SCRIPT_CALL, getScriptObject()); + if (!WASABI_API_MAKI->vcpu_getComplete()) { + if (!action.isempty()) { + if (!action_target.isempty()) + { + GuiObject *go = getGuiObject()->guiobject_findObject(action_target); + if (!go) + { + ScriptObject *so = WASABI_API_MAKI->maki_findObject(action_target); + if (so != NULL) + go = static_cast(so->vcpu_getInterface(guiObjectGuid)); + } + if (go) { + ifc_window *w = go->guiobject_getRootWnd(); + if (w) { + int _x = x; + int _y = y; + clientToScreen(&_x, &_y); + sendAction(w, actionstr, getParam(), _x, _y); + } + } + } else { + svc_action *act = ActionEnum(actionstr).getNext(); + if (act) { + int _x = x; + int _y = y; + clientToScreen(&_x, &_y); + act->onAction(actionstr, getParam(), _x, _y, NULL, 0, this); + SvcEnum::release(act); + } + } + } + } +} + +int Wasabi::Button::wantAutoContextMenu() { + int a = disablenextcontextmenu; + disablenextcontextmenu = 0; + return !a; +} + +void Wasabi::Button::onRightPush(int x, int y) { + BUTTON_PARENT::onRightPush(x, y); + script_vcpu_onRightClick(SCRIPT_CALL, getScriptObject()); + if (!WASABI_API_MAKI->vcpu_getComplete()) { + if (!action.isempty()) { + if (!action_target.isempty()) + { + GuiObject *go = getGuiObject()->guiobject_findObject(action_target); + if (!go) { + ScriptObject *so = WASABI_API_MAKI->maki_findObject(action_target); + if (so != NULL) + go = static_cast(so->vcpu_getInterface(guiObjectGuid)); + } + if (go) { + ifc_window *w = go->guiobject_getRootWnd(); + if (w) { + int _x = x; + int _y = y; + clientToScreen(&_x, &_y); + sendAction(w, actionstr, getParam(), _x, _y); + disablenextcontextmenu = 1; + } + } + } else { + svc_action *act = ActionEnum(actionstr).getNext(); + if (act) { + const wchar_t *par = getParam(); + if (par == NULL || *par == 0) par = L"1"; + int _x = x; + int _y = y; + clientToScreen(&_x, &_y); + disablenextcontextmenu = act->onAction(actionstr, par, _x, _y, NULL, 0, this); + SvcEnum::release(act); + } + } + } + } +} + +int Wasabi::Button::onActivateButton(int is) { + BUTTON_PARENT::onActivateButton(is); + scriptVar _is = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_is, is); + script_vcpu_onActivate(SCRIPT_CALL, getScriptObject(), _is); + return 1; +} + +int Wasabi::Button::getPreferences(int what) { + if (what == SUGGESTED_W) return getWidth(); + if (what == SUGGESTED_H) return getHeight(); + return BUTTON_PARENT::getPreferences(what); +} + +int Wasabi::Button::onShowWindow(Container *c, GUID guid, const wchar_t *groupid) +{ + if(!param) return 1; + if (groupid != NULL && !WCSICMP(groupid, param)) + { + setActivatedButton(1); + return 1; + } +#ifdef WASABI_COMPILE_WNDMGR + GUID *g; + if (g=SkinParser::getComponentGuid(param)) + { + if(*g != INVALID_GUID && guid == *g) setActivatedButton(1); + } +#endif + return 1; +} + +int Wasabi::Button::onHideWindow(Container *c, GUID guid, const wchar_t *groupid) { + if(!param) return 1; + if (groupid != NULL && !WCSICMP(groupid, param)) { + setActivatedButton(0); + return 1; + } +#ifdef WASABI_COMPILE_WNDMGR + GUID *g; + if (g=SkinParser::getComponentGuid(param)) { + if(guid == *g) setActivatedButton(0); + } +#endif + return 1; +} + +scriptVar Wasabi::Button::script_vcpu_setActivatedNoCallback(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) { + SCRIPT_FUNCTION_INIT + ASSERT(SOM::isNumeric(&v)); + Button *b = static_cast