1
0

api_wnd.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. #ifndef __API_WND_H
  2. #define __API_WND_H
  3. #include <wasabicfg.h>
  4. #include <bfc/dispatch.h>
  5. #include <bfc/platform/platform.h>
  6. class ifc_window;
  7. class PopupExitCallback; // see ../bfc/popexitcb.h
  8. class ifc_canvas; // see ../common/canvas.h
  9. class CfgItem;
  10. #ifndef MODALWND_DEF
  11. #define MODALWND_DEF
  12. ifc_window *const MODALWND_NOWND = reinterpret_cast<ifc_window*>(-1);
  13. #endif
  14. class wnd_api : public Dispatchable
  15. {
  16. public:
  17. // the master window
  18. /**
  19. Get the main root window.
  20. @ret Main root window.
  21. */
  22. ifc_window *main_getRootWnd();
  23. void main_setRootWnd(ifc_window *w);
  24. /**
  25. Get the modal window on top of the
  26. modal window stack.
  27. @ret Window that's currently modal.
  28. */
  29. ifc_window *getModalWnd();
  30. /**
  31. Push a window onto the modal stack. If
  32. the window is on top of the stack, it's
  33. currently modal.
  34. @param w Window to push onto the modal stack.
  35. */
  36. void pushModalWnd(ifc_window *w=MODALWND_NOWND);
  37. /**
  38. Pop a window from the modal stack. If
  39. the window is on top of the stack, it
  40. will no longer be modal after this call.
  41. @param w Window to pop from the modal stack.
  42. */
  43. void popModalWnd(ifc_window *w=MODALWND_NOWND);
  44. ifc_window *rootWndFromPoint(POINT *pt);
  45. ifc_window *rootWndFromOSHandle(OSWINDOWHANDLE wnd);
  46. void registerRootWnd(ifc_window *wnd);
  47. void unregisterRootWnd(ifc_window *wnd);
  48. int rootwndIsValid(ifc_window *wnd);
  49. void hookKeyboard(ifc_window *hooker);
  50. void unhookKeyboard(ifc_window *hooker);
  51. void kbdReset();
  52. int interceptOnChar(unsigned int c);
  53. int interceptOnKeyDown(int k);
  54. int interceptOnKeyUp(int k);
  55. int interceptOnSysKeyDown(int k, int kd);
  56. int interceptOnSysKeyUp(int k, int kd);
  57. int forwardOnChar(ifc_window *from, unsigned int c, int kd);
  58. int forwardOnKeyDown(ifc_window *from, int k, int kd);
  59. int forwardOnKeyUp(ifc_window *from, int k, int kd);
  60. int forwardOnSysKeyDown(ifc_window *from, int k, int kd);
  61. int forwardOnSysKeyUp(ifc_window *from, int k, int kd);
  62. int forwardOnKillFocus();
  63. int pushKeyboardLock();
  64. int popKeyboardLock();
  65. int isKeyboardLocked();
  66. void popupexit_deregister(PopupExitCallback *cb);
  67. void popupexit_register(PopupExitCallback *cb, ifc_window *watched);
  68. int popupexit_check(ifc_window *w);
  69. void popupexit_signal();
  70. #define RenderBaseTexture renderBaseTexture //CUT
  71. void skin_renderBaseTexture(ifc_window *base, ifc_canvas *c, const RECT &r, ifc_window *destWnd, int alpha=255);
  72. void skin_registerBaseTextureWindow(ifc_window *window, const wchar_t *bmp=NULL);
  73. void skin_unregisterBaseTextureWindow(ifc_window *window);
  74. void appdeactivation_push_disallow(ifc_window *w);
  75. void appdeactivation_pop_disallow(ifc_window *w);
  76. int appdeactivation_isallowed(ifc_window *w);
  77. void appdeactivation_setbypass(int i);
  78. int paintset_present(int set);
  79. void paintset_render(int set, ifc_canvas *c, const RECT *r, int alpha=255);
  80. void paintset_renderTitle(const wchar_t *t, ifc_canvas *c, const RECT *r, int alpha=255);
  81. int forwardOnMouseWheel(int l, int a);
  82. void setDefaultDropTarget(void *dt);
  83. void *getDefaultDropTarget();
  84. enum {
  85. API_WND_GETROOTWND = 10,
  86. API_WND_SETROOTWND = 20,
  87. API_WND_GETMODALWND = 30,
  88. API_WND_PUSHMODALWND = 40,
  89. API_WND_POPMODALWND = 50,
  90. API_WND_ROOTWNDFROMPOINT = 60,
  91. API_WND_ROOTWNDFROMOSHANDLE = 65,
  92. API_WND_REGISTERROOTWND = 70,
  93. API_WND_UNREGISTERROOTWND = 80,
  94. API_WND_ROOTWNDISVALID = 90,
  95. API_WND_INTERCEPTONCHAR = 100,
  96. API_WND_INTERCEPTONKEYDOWN = 110,
  97. API_WND_INTERCEPTONKEYUP = 120,
  98. API_WND_INTERCEPTONSYSKEYDOWN = 130,
  99. API_WND_INTERCEPTONSYSKEYUP = 140,
  100. API_WND_HOOKKEYBOARD = 150,
  101. API_WND_UNHOOKKEYBOARD = 160,
  102. API_WND_KBDRESET = 165,
  103. API_WND_FORWARDONCHAR = 170,
  104. API_WND_FORWARDONKEYDOWN = 180,
  105. API_WND_FORWARDONKEYUP = 190,
  106. API_WND_FORWARDONSYSKEYDOWN = 200,
  107. API_WND_FORWARDONSYSKEYUP = 210,
  108. API_WND_FORWARDONKILLFOCUS = 220,
  109. API_WND_POPUPEXIT_CHECK = 230,
  110. API_WND_POPUPEXIT_SIGNAL = 240,
  111. API_WND_POPUPEXIT_REGISTER = 250,
  112. API_WND_POPUPEXIT_DEREGISTER = 260,
  113. API_WND_RENDERBASETEXTURE = 270,
  114. API_WND_REGISTERBASETEXTUREWINDOW = 280,
  115. API_WND_UNREGISTERBASETEXTUREWINDOW = 290,
  116. API_WND_APPDEACTIVATION_PUSH_DISALLOW = 300,
  117. API_WND_APPDEACTIVATION_POP_DISALLOW = 310,
  118. API_WND_APPDEACTIVATION_ISALLOWED = 320,
  119. API_WND_APPDEACTIVATION_SETBYPASS = 330,
  120. API_WND_PAINTSET_PRESENT = 335,
  121. API_WND_PAINTSET_RENDER = 340,
  122. API_WND_PAINTSET_RENDERTITLE = 350,
  123. API_WND_FORWARDONMOUSEWHEEL = 360,
  124. // fg> this may need to go away eventually but i need it _right now_
  125. API_WND_SETDEFAULTDROPTARGET = 370,
  126. API_WND_GETDEFAULTDROPTARGET = 380,
  127. API_WND_PUSHKBDLOCK = 390,
  128. API_WND_POPKBDLOCK = 400,
  129. API_WND_ISKBDLOCKED = 410,
  130. };
  131. };
  132. inline ifc_window *wnd_api::main_getRootWnd() {
  133. return _call(API_WND_GETROOTWND, (ifc_window *)0 );
  134. }
  135. inline void wnd_api::main_setRootWnd(ifc_window *w) {
  136. _voidcall(API_WND_SETROOTWND, w );
  137. }
  138. inline ifc_window *wnd_api::getModalWnd() {
  139. return _call(API_WND_GETMODALWND, (ifc_window *)0 );
  140. }
  141. inline void wnd_api::pushModalWnd(ifc_window *w) {
  142. _voidcall(API_WND_PUSHMODALWND, w);
  143. }
  144. inline void wnd_api::popModalWnd(ifc_window *w) {
  145. _voidcall(API_WND_POPMODALWND, w);
  146. }
  147. inline ifc_window *wnd_api::rootWndFromPoint(POINT *pt) {
  148. return _call(API_WND_ROOTWNDFROMPOINT, (ifc_window *)0, pt );
  149. }
  150. inline ifc_window *wnd_api::rootWndFromOSHandle(OSWINDOWHANDLE wnd) {
  151. return _call(API_WND_ROOTWNDFROMOSHANDLE, (ifc_window *)0, wnd);
  152. }
  153. inline void wnd_api::registerRootWnd(ifc_window *wnd) {
  154. _voidcall(API_WND_REGISTERROOTWND, wnd );
  155. }
  156. inline void wnd_api::unregisterRootWnd(ifc_window *wnd) {
  157. _voidcall(API_WND_UNREGISTERROOTWND, wnd );
  158. }
  159. inline int wnd_api::rootwndIsValid(ifc_window *wnd) {
  160. return _call(API_WND_ROOTWNDISVALID, (int)0, wnd );
  161. }
  162. inline int wnd_api::interceptOnChar(unsigned int c) {
  163. return _call(API_WND_INTERCEPTONCHAR, (int)0, c );
  164. }
  165. inline int wnd_api::interceptOnKeyDown(int k) {
  166. return _call(API_WND_INTERCEPTONKEYDOWN, (int)0, k );
  167. }
  168. inline int wnd_api::interceptOnKeyUp(int k) {
  169. return _call(API_WND_INTERCEPTONKEYUP, (int)0, k );
  170. }
  171. inline int wnd_api::interceptOnSysKeyDown(int k, int kd) {
  172. return _call(API_WND_INTERCEPTONSYSKEYDOWN, (int)0, k , kd );
  173. }
  174. inline int wnd_api::interceptOnSysKeyUp(int k, int kd) {
  175. return _call(API_WND_INTERCEPTONSYSKEYUP, (int)0, k , kd );
  176. }
  177. inline void wnd_api::hookKeyboard(ifc_window *hooker) {
  178. _voidcall(API_WND_HOOKKEYBOARD, hooker);
  179. }
  180. inline void wnd_api::unhookKeyboard(ifc_window *hooker) {
  181. _voidcall(API_WND_UNHOOKKEYBOARD, hooker);
  182. }
  183. inline void wnd_api::kbdReset() {
  184. _voidcall(API_WND_KBDRESET);
  185. }
  186. inline int wnd_api::forwardOnChar(ifc_window *from, unsigned int c, int kd) {
  187. return _call(API_WND_FORWARDONCHAR, (int)0, from, c, kd );
  188. }
  189. inline int wnd_api::forwardOnKeyDown(ifc_window *from, int k, int kd) {
  190. return _call(API_WND_FORWARDONKEYDOWN, (int)0, from, k, kd);
  191. }
  192. inline int wnd_api::forwardOnKeyUp(ifc_window *from, int k, int kd) {
  193. return _call(API_WND_FORWARDONKEYUP, (int)0, from, k, kd );
  194. }
  195. inline int wnd_api::forwardOnSysKeyDown(ifc_window *from, int k, int kd) {
  196. return _call(API_WND_FORWARDONSYSKEYDOWN, (int)0, from, k , kd );
  197. }
  198. inline int wnd_api::forwardOnSysKeyUp(ifc_window *from, int k, int kd) {
  199. return _call(API_WND_FORWARDONSYSKEYUP, (int)0, from, k , kd );
  200. }
  201. inline int wnd_api::forwardOnKillFocus() {
  202. return _call(API_WND_FORWARDONKILLFOCUS, (int)0 );
  203. }
  204. inline int wnd_api::popupexit_check(ifc_window *w) {
  205. return _call(API_WND_POPUPEXIT_CHECK, 0, w);
  206. }
  207. inline void wnd_api::popupexit_signal() {
  208. _voidcall(API_WND_POPUPEXIT_SIGNAL);
  209. }
  210. inline void wnd_api::popupexit_register(PopupExitCallback *cb, ifc_window *watched) {
  211. _voidcall(API_WND_POPUPEXIT_REGISTER, cb, watched);
  212. }
  213. inline void wnd_api::popupexit_deregister(PopupExitCallback *cb) {
  214. _voidcall(API_WND_POPUPEXIT_DEREGISTER, cb);
  215. }
  216. #define RenderBaseTexture renderBaseTexture //CUT
  217. inline void wnd_api::skin_renderBaseTexture(ifc_window *base, ifc_canvas *c, const RECT &r, ifc_window *destWnd, int alpha) {
  218. _voidcall(API_WND_RENDERBASETEXTURE, base, c, &r, destWnd, alpha );
  219. }
  220. inline void wnd_api::skin_registerBaseTextureWindow(ifc_window *window, const wchar_t *bmp) {
  221. _voidcall(API_WND_REGISTERBASETEXTUREWINDOW, window, bmp);
  222. }
  223. inline void wnd_api::skin_unregisterBaseTextureWindow(ifc_window *window) {
  224. _voidcall(API_WND_UNREGISTERBASETEXTUREWINDOW, window );
  225. }
  226. inline void wnd_api::appdeactivation_push_disallow(ifc_window *w) {
  227. _voidcall(API_WND_APPDEACTIVATION_PUSH_DISALLOW, w);
  228. }
  229. inline void wnd_api::appdeactivation_pop_disallow(ifc_window *w) {
  230. _voidcall(API_WND_APPDEACTIVATION_POP_DISALLOW, w);
  231. }
  232. inline int wnd_api::appdeactivation_isallowed(ifc_window *w) {
  233. return _call(API_WND_APPDEACTIVATION_ISALLOWED, 0, w);
  234. }
  235. inline void wnd_api::appdeactivation_setbypass(int i) {
  236. _voidcall(API_WND_APPDEACTIVATION_SETBYPASS, i);
  237. }
  238. inline int wnd_api::paintset_present(int set)
  239. {
  240. return _call(API_WND_PAINTSET_PRESENT, 0, set);
  241. }
  242. inline void wnd_api::paintset_render(int set, ifc_canvas *c, const RECT *r, int alpha)
  243. {
  244. _voidcall(API_WND_PAINTSET_RENDER, set, c, r, alpha);
  245. }
  246. inline void wnd_api::paintset_renderTitle(const wchar_t *t, ifc_canvas *c, const RECT *r, int alpha)
  247. {
  248. _voidcall(API_WND_PAINTSET_RENDERTITLE, t, c, r, alpha);
  249. }
  250. inline int wnd_api::forwardOnMouseWheel(int l, int a) {
  251. return _call(API_WND_FORWARDONMOUSEWHEEL, 0, l, a);
  252. }
  253. // fg> this may need to go away eventually but i need it _right now_
  254. inline void wnd_api::setDefaultDropTarget(void *dt) {
  255. _voidcall(API_WND_SETDEFAULTDROPTARGET, dt);
  256. }
  257. inline void *wnd_api::getDefaultDropTarget() {
  258. return _call(API_WND_GETDEFAULTDROPTARGET, (void*)NULL);
  259. }
  260. inline int wnd_api::pushKeyboardLock() {
  261. return _call(API_WND_PUSHKBDLOCK, 0);
  262. }
  263. inline int wnd_api::popKeyboardLock() {
  264. return _call(API_WND_POPKBDLOCK, 0);
  265. }
  266. inline int wnd_api::isKeyboardLocked() {
  267. return _call(API_WND_ISKBDLOCKED, 0);
  268. }
  269. class wnd_apiI : public wnd_api {
  270. public:
  271. virtual void main_setRootWnd(ifc_window *w)=0;
  272. virtual ifc_window *main_getRootWnd()=0;
  273. virtual ifc_window *getModalWnd()=0;
  274. virtual void pushModalWnd(ifc_window *w=MODALWND_NOWND)=0;
  275. virtual void popModalWnd(ifc_window *w=MODALWND_NOWND)=0;
  276. virtual ifc_window *rootWndFromPoint(POINT *pt)=0;
  277. virtual ifc_window *rootWndFromOSHandle(OSWINDOWHANDLE wnd)=0;
  278. virtual void registerRootWnd(ifc_window *wnd)=0;
  279. virtual void unregisterRootWnd(ifc_window *wnd)=0;
  280. virtual int rootwndIsValid(ifc_window *wnd)=0;
  281. virtual void hookKeyboard(ifc_window *hooker)=0;
  282. virtual void unhookKeyboard(ifc_window *hooker)=0;
  283. virtual void kbdReset()=0;
  284. virtual int interceptOnChar(unsigned int c)=0;
  285. virtual int interceptOnKeyDown(int k)=0;
  286. virtual int interceptOnKeyUp(int k)=0;
  287. virtual int interceptOnSysKeyDown(int k, int kd)=0;
  288. virtual int interceptOnSysKeyUp(int k, int kd)=0;
  289. virtual int forwardOnChar(ifc_window *from, unsigned int c, int kd)=0;
  290. virtual int forwardOnKeyDown(ifc_window *from, int k, int kd)=0;
  291. virtual int forwardOnKeyUp(ifc_window *from, int k, int kd)=0;
  292. virtual int forwardOnSysKeyDown(ifc_window *from, int k, int kd)=0;
  293. virtual int forwardOnSysKeyUp(ifc_window *from, int k, int kd)=0;
  294. virtual int forwardOnKillFocus()=0;
  295. virtual void popupexit_deregister(PopupExitCallback *cb)=0;
  296. virtual void popupexit_register(PopupExitCallback *cb, ifc_window *watched)=0;
  297. virtual int popupexit_check(ifc_window *w)=0;
  298. virtual void popupexit_signal()=0;
  299. virtual void skin_renderBaseTexture(ifc_window *base, ifc_canvas *c, const RECT *r, ifc_window *destWnd, int alpha=255)=0;
  300. virtual void skin_registerBaseTextureWindow(ifc_window *window, const wchar_t *bmp=NULL)=0;
  301. virtual void skin_unregisterBaseTextureWindow(ifc_window *window)=0;
  302. virtual void appdeactivation_push_disallow(ifc_window *w)=0;
  303. virtual void appdeactivation_pop_disallow(ifc_window *w)=0;
  304. virtual int appdeactivation_isallowed(ifc_window *w)=0;
  305. virtual void appdeactivation_setbypass(int i)=0;
  306. #ifdef WASABI_COMPILE_PAINTSETS
  307. virtual int paintset_present(int set)=0;
  308. #ifdef WASABI_COMPILE_IMGLDR
  309. virtual void paintset_render(int set, ifc_canvas *c, const RECT *r, int alpha=255)=0;
  310. #ifdef WASABI_COMPILE_FONTS
  311. virtual void paintset_renderTitle(const wchar_t *t, ifc_canvas *c, const RECT *r, int alpha=255)=0;
  312. #endif // fonts
  313. #endif // imgldr
  314. #endif // paintsets
  315. virtual int forwardOnMouseWheel(int l, int a)=0;
  316. // fg> this may need to go away eventually but i need it _right now_
  317. virtual void setDefaultDropTarget(void *dt)=0;
  318. virtual void *getDefaultDropTarget()=0;
  319. virtual int pushKeyboardLock()=0;
  320. virtual int popKeyboardLock()=0;
  321. virtual int isKeyboardLocked()=0;
  322. protected:
  323. RECVS_DISPATCH;
  324. };
  325. // {ABB8FBC7-6255-4d41-ACAB-D3D61DDD74EE}
  326. static const GUID wndApiServiceGuid =
  327. { 0xabb8fbc7, 0x6255, 0x4d41, { 0xac, 0xab, 0xd3, 0xd6, 0x1d, 0xdd, 0x74, 0xee } };
  328. extern wnd_api *wndApi;
  329. #endif