1
0

layer.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. //PORTABLE
  2. #ifndef _LAYER_H
  3. #define _LAYER_H
  4. #ifndef _NOSTUDIO
  5. #include <api/script/objects/smap.h>
  6. #ifdef WASABI_WIDGETS_GUIOBJECT
  7. #include <api/script/objects/guiobj.h>
  8. #endif
  9. #include <api/wnd/basewnd.h>
  10. #include <tataki/bitmap/bitmap.h>
  11. #include <api/wnd/virtualwnd.h>
  12. #include <tataki/region/region.h>
  13. #include <tataki/bitmap/autobitmap.h>
  14. #include <api/wnd/wndclass/qpaintwnd.h>
  15. #endif
  16. #include <api/script/script.h>
  17. #ifdef WASABI_WIDGETS_GUIOBJECT
  18. #include <api/script/objects/guiobj.h>
  19. #endif
  20. // {5AB9FA15-9A7D-4557-ABC8-6557A6C67CA9}
  21. static const GUID layerGuid =
  22. { 0x5ab9fa15, 0x9a7d, 0x4557, { 0xab, 0xc8, 0x65, 0x57, 0xa6, 0xc6, 0x7c, 0xa9 } };
  23. #define LAYER_PARENT GuiObjectWnd
  24. #ifdef WASABI_WIDGETS_GUIOBJECT
  25. class LayerScriptController : public GuiObjectScriptController {
  26. public:
  27. virtual const wchar_t *getClassName();
  28. virtual const wchar_t *getAncestorClassName();
  29. virtual ScriptObjectController *getAncestorController() { return guiController; }
  30. virtual int getNumFunctions();
  31. virtual const function_descriptor_struct *getExportedFunctions();
  32. virtual GUID getClassGuid();
  33. virtual ScriptObject *instantiate();
  34. virtual void destroy(ScriptObject *o);
  35. virtual void *encapsulate(ScriptObject *o);
  36. virtual void deencapsulate(void *o);
  37. private:
  38. static function_descriptor_struct exportedFunction[];
  39. };
  40. extern LayerScriptController *layerController;
  41. #endif
  42. #ifndef _NOSTUDIO
  43. #define RESIZE_NONE 0
  44. #define RESIZE_TOP 1
  45. #define RESIZE_BOTTOM 2
  46. #define RESIZE_LEFT 4
  47. #define RESIZE_RIGHT 8
  48. #define RESIZE_TOPLEFT RESIZE_TOP | RESIZE_LEFT
  49. #define RESIZE_TOPRIGHT RESIZE_TOP | RESIZE_RIGHT
  50. #define RESIZE_BOTTOMLEFT RESIZE_BOTTOM | RESIZE_LEFT
  51. #define RESIZE_BOTTOMRIGHT RESIZE_BOTTOM | RESIZE_RIGHT
  52. class FxDynamicMove;
  53. class Layer : public LAYER_PARENT, public SkinCallbackI
  54. {
  55. public:
  56. Layer();
  57. virtual ~Layer();
  58. virtual int onInit();
  59. virtual int onPaint(Canvas *canvas);
  60. virtual int onLeftButtonDown(int x, int y);
  61. virtual int onLeftButtonUp(int x, int y);
  62. virtual int onMouseMove(int x, int y);
  63. virtual int onLeftButtonDblClk(int x, int y);
  64. virtual int getCursorType(int x, int y);
  65. virtual int onResize();
  66. virtual int onActivate();
  67. virtual int onDeactivate();
  68. virtual int getPreferences(int what);
  69. virtual void setDblClickParam(const wchar_t *p);
  70. virtual const wchar_t *getDblClickParam();
  71. virtual void timerCallback(int id);
  72. virtual void setRegionFromBitmap(const wchar_t *bmpid);
  73. virtual void setRegionFromMap(SMap *map, int byte, int inversed);
  74. virtual void setRegion(SRegion *reg);
  75. virtual int onSiblingInvalidateRgn(api_region *r, ifc_window *who, int who_idx, int my_idx);
  76. virtual int wantSiblingInvalidations();
  77. virtual int getSourceOffsetX();
  78. virtual int getSourceOffsetY();
  79. virtual void layer_adjustDest(RECT *r) {}
  80. virtual void onBeginResize(RECT r);
  81. virtual void onEndResize(RECT r);
  82. virtual SkinBitmap *getBitmap();
  83. virtual void onSetVisible(int show);
  84. void setResize(int r);
  85. void setScaler(int m);
  86. virtual void invalidateRegionCache();
  87. virtual api_region *getRegion(); // stretched and tiled as needed
  88. virtual api_region *getBitmapRegion(); // not stretched or tiled
  89. virtual void makeRegion();
  90. virtual void deleteRegion();
  91. virtual void setTiling(int t);
  92. virtual int getTiling();
  93. virtual void setBitmap(const wchar_t *name);
  94. virtual int getWidth();
  95. virtual int getHeight();
  96. virtual int setXuiParam(int _xuihandle, int id, const wchar_t *paramname, const wchar_t *strvalue);
  97. virtual void setRegionOp(int i);
  98. virtual void setInactiveBitmap(const wchar_t *name);
  99. virtual void onCancelCapture();
  100. virtual int applyResizeRestrictions(int way, int *side=NULL);
  101. virtual bool layer_isInvalid();
  102. //FG> fx
  103. #if defined(WA3COMPATIBILITY) || defined(GEN_FF)
  104. virtual void fx_setEnabled(int i);
  105. virtual int fx_getEnabled(void);
  106. virtual void fx_setWrap(int i);
  107. virtual int fx_getWrap(void);
  108. virtual void fx_setRect(int i);
  109. virtual int fx_getRect(void);
  110. virtual void fx_setBilinear(int i);
  111. virtual int fx_getBilinear(void);
  112. virtual void fx_setAlphaMode(int i);
  113. virtual int fx_getAlphaMode(void);
  114. virtual void fx_setBgFx(int i);
  115. virtual int fx_getBgFx(void);
  116. virtual void fx_setClear(int i);
  117. virtual int fx_getClear(void);
  118. virtual void fx_setLocalized(int i);
  119. virtual int fx_getLocalized(void);
  120. virtual void fx_setGridSize(int x, int y);
  121. virtual void fx_update(void);
  122. virtual void fx_restart(void);
  123. virtual void fx_onInit(void);
  124. virtual void fx_onFrame(void);
  125. virtual void fx_setSpeed(int d);
  126. virtual int fx_getSpeed(void);
  127. virtual void fx_setRealtime(int r);
  128. virtual int fx_getRealtime(void);
  129. virtual double fx_onGetPixelA(double r, double d, double x, double y);
  130. virtual double fx_onGetPixelX(double r, double d, double x, double y);
  131. virtual double fx_onGetPixelY(double r, double d, double x, double y);
  132. virtual double fx_onGetPixelR(double r, double d, double x, double y);
  133. virtual double fx_onGetPixelD(double r, double d, double x, double y);
  134. #endif
  135. virtual int skincb_onColorThemeChanged(const wchar_t *newcolortheme);
  136. enum {
  137. LAYER_SETIMAGE=0,
  138. LAYER_SETRESIZE,
  139. LAYER_SETSCALE,
  140. LAYER_SETREGION,
  141. LAYER_SETTILE,
  142. LAYER_SETDBLCLICKACTION,
  143. LAYER_DBLCLICKPARAM,
  144. LAYER_SETINACTIVEIMAGE,
  145. LAYER_SETMYCURSOR,
  146. LAYER_SETQUALITY,
  147. // LAYER_NUMPARAMS, // martin> there is no reference for this elsewhere in gen_ff, so CUT
  148. };
  149. int l_customcursor;
  150. protected:
  151. /*static */void CreateXMLParameters(int master_handle);
  152. const wchar_t *layer_getBitmapName();
  153. SkinBitmap *layer_getBitmap();
  154. private:
  155. static XMLParamPair params[];
  156. AutoSkinBitmap bitmap;
  157. int resizer, resizeway, resizing, resizerect;
  158. int cap, scaler, scalerway, scaling;
  159. POINT anchor;
  160. int clickthrough;
  161. RegionI *rgn, *secrgn, *rgnclone;
  162. int tiling;
  163. StringW bitmapname;
  164. int hasInactiveImage;
  165. StringW inactiveImageName;
  166. AutoSkinBitmap inactiveBitmap;
  167. int xuihandle;
  168. StringW dblclickparam;
  169. int fx_on;
  170. int fx_wrap;
  171. int fx_rect;
  172. int fx_grid_x;
  173. int fx_grid_y;
  174. int fx_bilinear;
  175. int fx_alphamode;
  176. int fx_alphaonce;
  177. int fx_bgfx;
  178. int fx_clear;
  179. int fx_delay;
  180. int fx_timeron;
  181. int fx_local;
  182. int fx_realtime;
  183. int last_w, last_h;
  184. FxDynamicMove *fx_dmove;
  185. StringW dblClickAction;
  186. StringW statustext;
  187. // FG>
  188. // -- SCRIPT -----------------------------------------------------
  189. public:
  190. static scriptVar script_vcpu_onBeginResize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar l, scriptVar t, scriptVar w, scriptVar h);
  191. static scriptVar script_vcpu_onEndResize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar l, scriptVar t, scriptVar w, scriptVar h);
  192. static scriptVar script_vcpu_setRegionFromMap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar map, scriptVar byte, scriptVar inversed);
  193. static scriptVar script_vcpu_setRegion(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar reg);
  194. static scriptVar script_vcpu_isInvalid(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  195. static scriptVar script_vcpu_fx_setEnabled(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a);
  196. static scriptVar script_vcpu_fx_getEnabled(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  197. static scriptVar script_vcpu_fx_setWrap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a);
  198. static scriptVar script_vcpu_fx_getWrap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  199. static scriptVar script_vcpu_fx_setRect(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a);
  200. static scriptVar script_vcpu_fx_getRect(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  201. static scriptVar script_vcpu_fx_setBgFx(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a);
  202. static scriptVar script_vcpu_fx_getBgFx(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  203. static scriptVar script_vcpu_fx_setClear(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a);
  204. static scriptVar script_vcpu_fx_getClear(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  205. static scriptVar script_vcpu_fx_setRealtime(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a);
  206. static scriptVar script_vcpu_fx_getRealtime(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  207. static scriptVar script_vcpu_fx_setLocalized(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a);
  208. static scriptVar script_vcpu_fx_getLocalized(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  209. static scriptVar script_vcpu_fx_setBilinear(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a);
  210. static scriptVar script_vcpu_fx_getBilinear(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  211. static scriptVar script_vcpu_fx_setAlphaMode(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a);
  212. static scriptVar script_vcpu_fx_getAlphaMode(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  213. static scriptVar script_vcpu_fx_setGridSize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y);
  214. static scriptVar script_vcpu_fx_update(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  215. static scriptVar script_vcpu_fx_restart(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  216. static scriptVar script_vcpu_fx_onInit(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  217. static scriptVar script_vcpu_fx_onFrame(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  218. static scriptVar script_vcpu_fx_setSpeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s);
  219. static scriptVar script_vcpu_fx_getSpeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  220. static scriptVar script_vcpu_fx_onGetPixelA(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r, scriptVar d, scriptVar x, scriptVar y);
  221. static scriptVar script_vcpu_fx_onGetPixelX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r, scriptVar d, scriptVar x, scriptVar y);
  222. static scriptVar script_vcpu_fx_onGetPixelY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r, scriptVar d, scriptVar x, scriptVar y);
  223. static scriptVar script_vcpu_fx_onGetPixelR(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r, scriptVar d, scriptVar x, scriptVar y);
  224. static scriptVar script_vcpu_fx_onGetPixelD(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r, scriptVar d, scriptVar x, scriptVar y);
  225. #else
  226. class Layer : public LAYER_SCRIPTPARENT {
  227. #endif
  228. public:
  229. // INSERT_SCRIPT_OBJECT_CONTROL
  230. };
  231. #ifdef WASABI_WIDGETS_GUIOBJECT
  232. extern const wchar_t layerXuiObjectStr[];
  233. extern char layerXuiSvcName[];
  234. class LayerXuiSvc : public XuiObjectSvc<Layer, layerXuiObjectStr, layerXuiSvcName> {};
  235. #endif
  236. #endif