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/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 + 225 files changed, 41573 insertions(+) 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 (limited to 'Src/Wasabi/api/skin') 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