1
0

layout.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. #ifndef __LAYOUT_H
  2. #define __LAYOUT_H
  3. class Layout;
  4. class Group;
  5. class Container;
  6. class Layer;
  7. #include <bfc/tlist.h>
  8. #include <bfc/depend.h>
  9. #include <tataki/bitmap/bitmap.h>
  10. #include <api/wnd/wndclass/buttwnd.h>
  11. #include <tataki/region/region.h>
  12. #include <api/wndmgr/container.h>
  13. #include <api/skin/group.h>
  14. #include <api/skin/widgets/layer.h>
  15. #include <api/wndmgr/guistatuscb.h>
  16. #include <api/script/script.h>
  17. #include <api/script/scriptobj.h>
  18. #ifdef WASABI_WIDGETS_GUIOBJECT
  19. #include <api/script/objects/guiobj.h>
  20. #endif
  21. #include <api/wnd/accessible.h>
  22. #include <api/wndmgr/alphamgr.h>
  23. #include <api/wnd/resizable.h>
  24. class XmlObject;
  25. class Layout;
  26. extern AlphaMgr *alphaMgr;
  27. class LayoutScriptController : public GroupScriptController {
  28. public:
  29. virtual const wchar_t *getClassName();
  30. virtual const wchar_t *getAncestorClassName();
  31. virtual ScriptObjectController *getAncestorController() { return groupController; }
  32. virtual int getNumFunctions();
  33. virtual const function_descriptor_struct *getExportedFunctions();
  34. virtual GUID getClassGuid();
  35. virtual ScriptObject *instantiate();
  36. virtual int getInstantiable();
  37. virtual void destroy(ScriptObject *o);
  38. virtual void *encapsulate(ScriptObject *o);
  39. virtual void deencapsulate(void *o);
  40. private:
  41. static function_descriptor_struct exportedFunction[];
  42. };
  43. extern LayoutScriptController *layoutController;
  44. #ifndef _NOSTUDIO
  45. class AutoOpacityLinker;
  46. #define LAYOUT_PARENT Group
  47. #define LAYOUT_SCRIPTPARENT Group
  48. class Layout : public LAYOUT_SCRIPTPARENT, public DependentViewerI, public GuiResizable
  49. {
  50. public:
  51. Layout();
  52. virtual ~Layout();
  53. #ifdef _WIN32
  54. virtual LRESULT wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  55. #else
  56. virtual OSStatus eventHandler(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData);
  57. #endif
  58. // int onPaint(Canvas *canvas);
  59. virtual int onInit();
  60. virtual int init(OSMODULEHANDLE inst, OSWINDOWHANDLE parent, int nochild);
  61. virtual int reinit(OSMODULEHANDLE inst, OSWINDOWHANDLE parent, int nochild);
  62. virtual int childNotify(ifc_window *child, int msg, intptr_t param1=0, intptr_t param2=0);
  63. virtual int onActionNotify(int action, intptr_t param=0);
  64. virtual void resize(int x, int y, int w, int h, int wantcb=1);
  65. virtual void move(int x, int y);
  66. // virtual int onRightButtonDown(int x, int y);
  67. // virtual int onLeftButtonDown(int x, int y);
  68. // virtual int onMouseMove(int x, int y);
  69. // virtual int onLeftButtonUp(int x, int y);
  70. virtual int onResize();
  71. virtual int onPostedMove();
  72. virtual int onPaint(Canvas *canvas);
  73. virtual void onSetDesktopAlpha(int a);
  74. virtual int isLayout();
  75. virtual void setAlphaBackground(const wchar_t *txture);
  76. virtual SkinBitmap *getBaseTexture();
  77. virtual void onGuiObjectSetVisible(GuiObject *o, int status); // called whenever a child shows/hide
  78. virtual ifc_window *getCustomOwner();
  79. virtual void addLockedLayout(Layout *l);
  80. virtual void removeLockedLayout(Layout *l);
  81. virtual int getNumLockedLayouts();
  82. virtual Layout *enumLockedLayout(int n);
  83. virtual int isLocked();
  84. virtual void lockTo(Layout *l);
  85. virtual Layout *getLockedTo();
  86. void updateLockedLayouts();
  87. virtual int onGetFocus();
  88. virtual int onKillFocus();
  89. virtual void snapAdjust(int left, int right, int top, int bottom);
  90. virtual void onShow(void);
  91. virtual void onHide(void);
  92. virtual void center();
  93. virtual int wantDesktopAlpha();
  94. virtual void setWantDesktopAlpha(int want);
  95. virtual int handleDesktopAlpha();
  96. virtual int setXuiParam(int _xuihandle, int attribid, const wchar_t *paramname, const wchar_t *strvalue);
  97. void setWindowRegion(api_region *reg);
  98. virtual int allowResize() {
  99. return !isLocked()
  100. #ifdef USEAPPBAR
  101. && !appbar_isDocked()
  102. #endif
  103. ;
  104. }
  105. // container/component callbacks to get notified that a container
  106. // has been set visible/invisible
  107. void containerToggled(const wchar_t *id,int visible);
  108. void componentToggled(GUID *guid, int visible);
  109. void setParentContainer(Container *c);
  110. virtual Container *getParentContainer();
  111. virtual int isClickThrough();
  112. void onSetVisible(int show);
  113. virtual void cancelCapture();
  114. virtual int onActivate();
  115. virtual int onDeactivate();
  116. virtual int forceTransparencyFlag();
  117. int x, y;
  118. #ifdef _WIN32
  119. void setForwardMsgWnd(HWND wnd) { forwardMsgWnd = wnd; }
  120. LPARAM wndHolder_getParentParam(int i=0);
  121. #endif
  122. void scaleTo(int s);
  123. virtual void setRenderRatio(double s);
  124. virtual void beginMove();
  125. virtual void beginScale();
  126. virtual void beginResize();
  127. virtual void endMove();
  128. virtual void endScale();
  129. virtual void endResize();
  130. virtual void setEndMoveResize(int w, int h) {
  131. m_w = w;
  132. m_h = h;
  133. m_endmovesize = 1;
  134. };
  135. virtual ifc_window *guiresizable_getRootWnd() { return (this); }
  136. virtual void lockScale(int locked);
  137. virtual int isScaleLocked() { return scalelocked; }
  138. virtual void onMove();
  139. virtual int isDesktopAlphaSafe();
  140. void addSubRegionLayer(Layer *l);
  141. void removeSubRegionLayer(Layer *l);
  142. virtual void setInDesktop(int a);
  143. virtual int getInDesktop();
  144. virtual void setAlpha(int a);
  145. virtual int getAlpha();
  146. virtual int getPaintingAlpha();
  147. virtual void timerCallback(int id);
  148. virtual void setLinkWidth(const wchar_t *layoutid);
  149. virtual void setLinkHeight(const wchar_t *layoutid);
  150. virtual void setBaseTexture(const wchar_t *b, int regis=1);
  151. virtual void setPaintingAlpha(int activealpha, int inactivealpha=-1);
  152. static void onGlobalEnableDesktopAlpha(int enabled);
  153. void savePosition();
  154. #ifdef USEAPPBAR
  155. void saveAppBarPosition();
  156. #endif
  157. virtual void setStatusText(const wchar_t *txt, int overlay=0);
  158. virtual void addAppCmds(AppCmds *commands);
  159. virtual void removeAppCmds(AppCmds *commands);
  160. void pushCompleted(int max=100);
  161. void incCompleted(int add=1);
  162. void setCompleted(int pos);
  163. void popCompleted();
  164. virtual void registerStatusCallback(GuiStatusCallback *lcb);
  165. virtual int viewer_onItemDeleted(api_dependent *item);
  166. virtual int wantActivation() { return wantactiv && LAYOUT_PARENT::wantActivation(); }
  167. void loadSavedState();
  168. virtual void updateOnTop();
  169. virtual int runAction(int actionid, const wchar_t *param=NULL);
  170. virtual void getSnapAdjust(RECT *r);
  171. virtual void updateTransparency();
  172. virtual int onDeferredCallback(intptr_t p1, intptr_t p2);
  173. virtual int wantRedrawOnResize() { return wantredrawonresize; }
  174. virtual void setWantRedrawOnResize(int v);
  175. #ifdef USEAPPBAR
  176. virtual int appbar_wantAutoHide() { return getAppBarAutoHide(); }
  177. virtual int appbar_wantAlwaysOnTop() { return getAppBarAlwaysOnTop(); }
  178. virtual int getAppBarAutoHide();
  179. virtual void setAppBarAutoHide(int ah);
  180. virtual int getAppBarAlwaysOnTop();
  181. virtual void setAppBarAlwaysOnTop(int aot);
  182. #endif
  183. virtual void pushForceUnlink() { m_forceunlink++; }
  184. virtual void popForceUnlink() { m_forceunlink--; }
  185. virtual int isUnlinked() {
  186. #ifdef USEAPPBAR
  187. return unlinked || appbar_isDocked() || m_forceunlink;
  188. #else
  189. return unlinked || m_forceunlink;
  190. #endif
  191. }
  192. void setAutoOpacify(int a);
  193. int getAutoOpacify() { return autoopacify; }
  194. void offscreenCheck();
  195. int isOffscreen(ifc_window *w);
  196. int getResizable();
  197. int getScalable();
  198. void setTransparencyOverride(int v);
  199. int getTransparencyOverride() { return transparencyoverride; }
  200. enum {
  201. LAYOUT_SETDESKTOPALPHA=0,
  202. LAYOUT_SETINDESKTOP,
  203. LAYOUT_SETALPHA,
  204. LAYOUT_SETLINKWIDTH,
  205. LAYOUT_SETLINKHEIGHT,
  206. LAYOUT_SETOWNER,
  207. LAYOUT_SETLOCKTO,
  208. LAYOUT_SETOSFRAME,
  209. LAYOUT_SETALPHABACKGROUND,
  210. LAYOUT_SETNOACTIVATION,
  211. LAYOUT_SETONTOP,
  212. LAYOUT_SNAPADJUSTLEFT,
  213. LAYOUT_SNAPADJUSTTOP,
  214. LAYOUT_SNAPADJUSTRIGHT,
  215. LAYOUT_SNAPADJUSTBOTTOM,
  216. LAYOUT_UNLINKED,
  217. LAYOUT_NOPARENT,
  218. LAYOUT_FORCEALPHA,
  219. LAYOUT_NODOCK,
  220. LAYOUT_NOOFFSCREENCHECK,
  221. LAYOUT_RESIZABLE,
  222. LAYOUT_SCALABLE,
  223. };
  224. void onMouseEnterLayout();
  225. void onMouseLeaveLayout();
  226. int getNoParent() { return noparent; }
  227. void setNoParent(int np) { noparent = np; }
  228. int isAlphaForced() { return forcealpha; }
  229. AlphaMgr *getAlphaMgr() { return alphaMgr; }
  230. int getNoDock() { return nodock; }
  231. void setNoDock(int nd) { nodock = nd; }
  232. int isTransparencyForcedOff() { return transparency_autooff; }
  233. void controlMenu();
  234. void setNoOffscreenCheck(int nocheck);
  235. #ifdef USEAPPBAR
  236. void onDock(int side);
  237. void onUnDock();
  238. virtual void appbar_onDock(int side);
  239. virtual void appbar_onUnDock();
  240. virtual void appbar_onSlide();
  241. #endif
  242. protected:
  243. /*static */void CreateXMLParameters(int master_handle);
  244. /* virtual int dragEnter(ifc_window *sourceWnd);
  245. virtual int dragOver(int x, int y, ifc_window *sourceWnd);
  246. virtual int dragDrop(ifc_window *sourceWnd, int x, int y);
  247. virtual int acceptExternalDrops() { return 1; }*/
  248. virtual int wantClickWndAutoInvalidate() { return 0; }
  249. private:
  250. StringW MakePrefix();
  251. static XMLParamPair params[];
  252. void fixPosition();
  253. void saveAllPositions();
  254. void activateChildren(int act);
  255. #ifdef _WIN32
  256. void getExplorerWindows(HWND *parent, HWND *listview, HWND *webserver);
  257. #endif
  258. void desktopAlpha_autoTurnOn();
  259. void desktopAlpha_autoTurnOff();
  260. void transparency_autoTurnOn();
  261. void transparency_autoTurnOff();
  262. void globalEnableDesktopAlpha(int enabled);
  263. #ifdef _WIN32
  264. HWND forwardMsgWnd;
  265. #endif
  266. int resizing;
  267. int wantactiv;
  268. int size_w,size_h;
  269. int cX,cY;
  270. int captured;
  271. POINT mousepos;
  272. #ifdef _WIN32
  273. HWND webserver;
  274. HWND listview;
  275. #endif
  276. int alphagoingon;
  277. int alphagoingoff;
  278. int scalelocked;
  279. int wantredrawonresize;
  280. int xuihandle;
  281. RegionI *reg;
  282. //PtrList<Layer> *subregionlayers;
  283. Container *p_container;
  284. StringW alphabackgroundstr;
  285. ifc_window *wndholders;
  286. int abortSaving();
  287. int transparencyoverride;
  288. int default_x;
  289. int default_y;
  290. int moving;
  291. int scaling;
  292. int mover;
  293. int indesktop;
  294. int alpha;
  295. StringW linkedheight, linkedwidth;
  296. int inlinkwidth, inlinkheight;
  297. AutoSkinBitmap alphabackground;
  298. int wantdesktopalpha;
  299. int galphadisabled;
  300. static PtrList<Layout> alllayouts;
  301. StringW owner;
  302. PtrList<Layout> locked;
  303. StringW lockto;
  304. Layout *lockedto;
  305. int inpostedmove;
  306. int osframe;
  307. PtrList<GuiStatusCallback> statuscbs;
  308. int initontop;
  309. // GarbageCollector gc;
  310. PtrList<AppCmds> appcmds;
  311. int inresize;
  312. int unlinked;
  313. int snap_adjust_left;
  314. int snap_adjust_top;
  315. int snap_adjust_right;
  316. int snap_adjust_bottom;
  317. int disable_auto_alpha;
  318. int autoopacify;
  319. int noparent;
  320. int forcealpha;
  321. redock_struct redock;
  322. static int broadcasting;
  323. int nodock;
  324. uint32_t transparency_reenabled_at;
  325. int transparency_autooff;
  326. int nooffscreencheck;
  327. int resizable;
  328. int scalable;
  329. int m_w, m_h;
  330. int m_endmovesize;
  331. int m_allowsavedock;
  332. int m_forceunlink;
  333. #ifdef USEAPPBAR
  334. int appbar_want_autohide;
  335. int appbar_want_alwaysontop;
  336. #endif
  337. // FG>
  338. // -- SCRIPT -----------------------------------------------------
  339. public:
  340. static scriptVar script_vcpu_onDock(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar side);
  341. static scriptVar script_vcpu_onUndock(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  342. static scriptVar script_vcpu_getScale(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  343. static scriptVar script_vcpu_setScale(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s);
  344. static scriptVar script_vcpu_onScale(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s);
  345. static scriptVar script_vcpu_setDesktopAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s);
  346. static scriptVar script_vcpu_getDesktopAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  347. static scriptVar script_vcpu_isTransparencySafe(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  348. static scriptVar script_vcpu_isLayoutAnimationSafe(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  349. static scriptVar script_vcpu_getContainer(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  350. static scriptVar script_vcpu_center(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  351. static scriptVar script_vcpu_onMove(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  352. static scriptVar script_vcpu_onEndMove(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  353. static scriptVar script_vcpu_onUserResize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y, scriptVar w, scriptVar h);
  354. static scriptVar script_vcpu_snapAdjust(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar left, scriptVar top, scriptVar right, scriptVar bottom);
  355. static scriptVar script_vcpu_setRedrawOnResize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v);
  356. static scriptVar script_vcpu_beforeRedock(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  357. static scriptVar script_vcpu_redock(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  358. static scriptVar script_vcpu_getSnapAdjustTop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  359. static scriptVar script_vcpu_getSnapAdjustLeft(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  360. static scriptVar script_vcpu_getSnapAdjustRight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  361. static scriptVar script_vcpu_getSnapAdjustBottom(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  362. static scriptVar script_vcpu_onMouseEnterLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  363. static scriptVar script_vcpu_onMouseLeaveLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  364. static scriptVar script_vcpu_onSnapAdjustChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  365. #else
  366. class Layout : public LAYOUT_SCRIPTPARENT {
  367. public:
  368. #endif
  369. // INSERT_SCRIPT_OBJECT_CONTROL
  370. };
  371. // END SCRIPT
  372. #endif