text.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. //PORTABLE
  2. #ifndef _TEXT_H
  3. #define _TEXT_H
  4. #include <api/script/script.h>
  5. #include <api/script/objects/guiobj.h>
  6. #include <api/wnd/wndclass/guiobjwnd.h>
  7. #include <bfc/string/StringW.h>
  8. #include <bfc/depend.h>
  9. #include "textbase.h"
  10. #include <api/syscb/callbacks/svccbi.h>
  11. #include <api/syscb/callbacks/skincb.h>
  12. #define TEXT_PARENT TextBase
  13. class svc_textFeed;
  14. class TextScriptController : public GuiObjectScriptController {
  15. public:
  16. virtual const wchar_t *getClassName();
  17. virtual const wchar_t *getAncestorClassName();
  18. virtual ScriptObjectController *getAncestorController() { return guiController; }
  19. virtual int getNumFunctions();
  20. virtual const function_descriptor_struct *getExportedFunctions();
  21. virtual GUID getClassGuid();
  22. virtual ScriptObject *instantiate();
  23. virtual void destroy(ScriptObject *o);
  24. virtual void *encapsulate(ScriptObject *o);
  25. virtual void deencapsulate(void *o);
  26. private:
  27. static function_descriptor_struct exportedFunction[];
  28. };
  29. extern TextScriptController *textController;
  30. #include <api/wnd/wndclass/clickwnd.h>
  31. #ifdef WASABI_COMPILE_MEDIACORE
  32. #include <api/syscb/callbacks/corecbi.h>
  33. class Text : public TEXT_PARENT, public CoreCallbackI, public DependentViewerI, public SvcCallbackI{
  34. #else
  35. class Text : public TEXT_PARENT, public DependentViewerI, public SvcCallbackI {
  36. #endif
  37. public:
  38. Text();
  39. virtual ~Text();
  40. virtual int onInit();
  41. virtual int onBufferPaint(BltCanvas *canvas, int w, int h);
  42. virtual int onLeftButtonDown(int x, int y);
  43. virtual int onMouseMove(int x, int y);
  44. virtual int onLeftButtonUp(int x, int y);
  45. virtual int getPreferences(int what);
  46. virtual int setXuiParam(int xuihandle, int attribid, const wchar_t *name, const wchar_t *strval);
  47. virtual const wchar_t *vcpu_getClassName();
  48. virtual ScriptObjectController *vcpu_getController() { return textController; }
  49. virtual int getTextWidth();
  50. virtual int onDeferredCallback(intptr_t p1, intptr_t p2);
  51. virtual void getBufferPaintSize(int *w, int *h);
  52. virtual void getBufferPaintSource(RECT *r);
  53. virtual void onNewBuffer(int w, int h) { BufferPaintWnd::onNewBuffer(w, h); invalidateTextBuffer(); }
  54. int setTextSize(int newsize, int alt=0);
  55. void setTickering(int enable);
  56. void setDisplay(int disp);
  57. void setShadowColor(ARGB32 c, int alt=0);
  58. void setShadowX(int x, int alt=0); // relative offsets
  59. void setShadowY(int y, int alt=0);
  60. void setTimeTTS(int tts);
  61. void resetTicker();
  62. void setTimeColonWidth(int w);
  63. int getTimeColonWidth(int def);
  64. void setTimerOffStyle(int o);
  65. void setTimerHours(int o);
  66. void setTimerHoursRollover(int o);
  67. const wchar_t *getLastText() { return lasttxt; }
  68. void setAlternateName(const wchar_t *s);
  69. const wchar_t *getAlternateName(void);
  70. void setText(const wchar_t *t);
  71. void addCBSource(const wchar_t *cbsource);
  72. virtual void onTextChanged(const wchar_t *txt);
  73. virtual void onSetName();
  74. virtual void advanceTicker(int *upd);
  75. virtual void setTimeDisplayMode(int remaining); // will only do so if text is displaying time in the first place
  76. ARGB32 getShadowColor(int alt=0);
  77. #ifdef WASABI_COMPILE_MEDIACORE
  78. // core callbacks
  79. virtual int corecb_onStatusMsg(const wchar_t *text);
  80. virtual int corecb_onInfoChange(const wchar_t *text);
  81. virtual int corecb_onStarted();
  82. virtual int corecb_onStopped();
  83. virtual int corecb_onSeeked(int newpos);
  84. virtual int corecb_onBitrateChange(int kbps);
  85. virtual int corecb_onSampleRateChange(int hz);
  86. #endif
  87. static void textOut(Canvas *canvas, int x, int y, const wchar_t *txt, wchar_t widthchar, const Wasabi::FontInfo *fontInfo);
  88. virtual int viewer_onEvent(api_dependent *item, const GUID *classguid, int event, intptr_t param, void *ptr, size_t ptrlen);
  89. virtual int triggerEvent(int event, intptr_t p1, intptr_t p2);
  90. const wchar_t *getPrintedText();
  91. virtual void svccb_onSvcRegister(FOURCC type, waServiceFactory *svc);
  92. void initDisplay();
  93. void invalidateTextBuffer();
  94. enum {
  95. TEXT_SETDISPLAY=0,
  96. TEXT_SETTICKER,
  97. TEXT_SETTEXT,
  98. TEXT_SETSHADOWCOLOR,
  99. TEXT_SETALTSHADOWCOLOR,
  100. TEXT_SETSHADOWX,
  101. TEXT_SETSHADOWY,
  102. TEXT_SETALTSHADOWX,
  103. TEXT_SETALTSHADOWY,
  104. TEXT_SETTIMEROFFSTYLE,
  105. TEXT_SETTIMERHOURS,
  106. TEXT_SETTIMECOLONWIDTH,
  107. TEXT_SETNOGRAB,
  108. TEXT_SETSHOWLEN,
  109. TEXT_SETFORCEFIXED,
  110. TEXT_SETFORCEUPCASE,
  111. TEXT_SETFORCELOCASE,
  112. TEXT_SETCBSOURCE,
  113. TEXT_SETWRAPPED,
  114. TEXT_SETVALIGN,
  115. TEXT_SETALTVALIGN,
  116. TEXT_SETDBLCLKACTION,
  117. TEXT_SETRCLKACTION,
  118. TEXT_SETOFFSETX,
  119. TEXT_SETOFFSETY,
  120. TEXT_SETTICKERSTEP,
  121. TEXT_SETTIMERHOURSROLLOVER,
  122. TEXT_NUMPARAMS,
  123. };
  124. protected:
  125. /*static */void CreateXMLParameters(int master_handle);
  126. virtual void timerCallback(int id);
  127. private:
  128. static XMLParamPair params[];
  129. const wchar_t *parseText(const wchar_t *s);
  130. void registerToTextFeedService();
  131. int size[2];
  132. int textpos,tts,sens;
  133. int time_tts;
  134. int grab_x;
  135. int cur_len;
  136. int ticker;
  137. int display;
  138. int elapsed;
  139. int fixedTimerStyle;
  140. int nograb;
  141. int showlen;
  142. int forcefixed;
  143. int timeroffstyle;
  144. StringW displaystr;
  145. StringW alternatename;
  146. StringW lastText;
  147. FilteredColor shadowcolor[2];
  148. SkinColor sshadowcolor[2];
  149. int shadowcolor_mode[2];
  150. int shadowx[2], shadowy[2];
  151. int timecolonw;
  152. StringW deftext;
  153. PtrList<StringW> mycbid;
  154. StringW cbsource;
  155. int forceupcase, forcelocase;
  156. StringW lasttxt;
  157. int lastautowidth;
  158. svc_textFeed *textfeed;
  159. StringW feed_id;
  160. int registered_syscb;
  161. int wrapped;
  162. int valign[2];
  163. int xuihandle;
  164. int offsetx, offsety;
  165. StringW printedtxt;
  166. int tickerstep;
  167. int skipn;
  168. int skip;
  169. int skipcfgcount;
  170. int timerhours;
  171. int timerhoursRollover;
  172. int bufferinvalid;
  173. int cachedsizew;
  174. public:
  175. static scriptVar script_vcpu_setText(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar t);
  176. static scriptVar script_vcpu_setAlternateText(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar t);
  177. static scriptVar script_vcpu_getText(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  178. static scriptVar script_vcpu_getTextWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  179. static scriptVar script_vcpu_onTextChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar text);
  180. static wchar_t s_txt[WA_MAX_PATH];
  181. };
  182. extern const wchar_t textXuiObjectStr[];
  183. extern char textXuiSvcName[];
  184. class TextXuiSvc : public XuiObjectSvc<Text, textXuiObjectStr, textXuiSvcName> {};
  185. #endif