Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

987 lines
35 KiB

  1. /***************************************************************************\
  2. *
  3. * File: DUserCore.h
  4. *
  5. * Description:
  6. * DUserCore.h defines the DirectUser/Core, the low-level composition engine.
  7. *
  8. * Copyright (C) 2000 by Microsoft Corporation. All rights reserved.
  9. *
  10. \***************************************************************************/
  11. #if !defined(INC__DUserCore_h__INCLUDED)
  12. #define INC__DUserCore_h__INCLUDED
  13. /*
  14. * Include dependencies
  15. */
  16. #include <limits.h> // Standard constants
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #ifdef DUSER_EXPORTS
  21. #define DUSER_API
  22. #else
  23. #define DUSER_API __declspec(dllimport)
  24. #endif
  25. /***************************************************************************\
  26. *
  27. * Basics
  28. *
  29. \***************************************************************************/
  30. DECLARE_HANDLE(HGADGET);
  31. DECLARE_HANDLE(HDCONTEXT);
  32. DECLARE_HANDLE(HCLASS);
  33. DUSER_API BOOL WINAPI DeleteHandle(HANDLE h);
  34. DUSER_API BOOL WINAPI IsStartDelete(HANDLE h, BOOL * pfStarted);
  35. #define IGTM_MIN (0) // +
  36. #define IGTM_NONE (0) // | No special threading model
  37. #define IGTM_SINGLE (1) // | Single threaded application
  38. #define IGTM_SEPARATE (2) // | MT with single thread per context
  39. #define IGTM_MULTIPLE (3) // | MT with multiple threads per context
  40. #define IGTM_MAX (3) // +
  41. #define IGMM_MIN (1) // +
  42. #define IGMM_COMPATIBLE (1) // | Core running in Compatible mode
  43. #define IGMM_ADVANCED (2) // | Core running in Advanced mode
  44. #define IGMM_STANDARD (3) // | Standard mode on Whistler
  45. #define IGMM_MAX (3) // +
  46. #define IGPM_MIN (0) // +
  47. #define IGPM_BLEND (0) // | Optimize for blend between speed / size
  48. #define IGPM_SPEED (1) // | Optimize for pure speed
  49. #define IGPM_SIZE (2) // | Optimize for minimum working set
  50. #define IGPM_MAX (2) // +
  51. typedef struct tagINITGADGET
  52. {
  53. DWORD cbSize; // Size of structure
  54. UINT nThreadMode; // Threading model
  55. UINT nMsgMode; // DirectUser/Core messaging subsystem mode
  56. UINT nPerfMode; // Performance tuning mode
  57. HDCONTEXT hctxShare; // Existing context to share with
  58. } INITGADGET;
  59. DUSER_API HDCONTEXT WINAPI InitGadgets(INITGADGET * pInit);
  60. #define IGC_MIN (1)
  61. #define IGC_DXTRANSFORM (1) // DirectX Transforms
  62. #define IGC_GDIPLUS (2) // GDI+
  63. #define IGC_MAX (2)
  64. DUSER_API BOOL WINAPI InitGadgetComponent(UINT nOptionalComponent);
  65. DUSER_API BOOL WINAPI UninitGadgetComponent(UINT nOptionalComponent);
  66. DUSER_API HDCONTEXT WINAPI GetContext(HANDLE h);
  67. DUSER_API BOOL WINAPI IsInsideContext(HANDLE h);
  68. #ifdef __cplusplus
  69. #define BEGIN_STRUCT(name, baseclass) \
  70. struct name : baseclass {
  71. #define END_STRUCT(name) \
  72. };
  73. #define FORWARD_STRUCT(name) \
  74. struct name;
  75. #else
  76. #define BEGIN_STRUCT(name, baseclass) \
  77. typedef struct tag##name { \
  78. baseclass;
  79. #define END_STRUCT(name) \
  80. } name;
  81. #define FORWARD_STRUCT(name) \
  82. typedef struct name;
  83. #endif
  84. /***************************************************************************\
  85. *
  86. * Messaging and Events
  87. *
  88. \***************************************************************************/
  89. #define GMF_DIRECT 0x00000000 // + When message reaches hgadMsg
  90. #define GMF_ROUTED 0x00000001 // | Before message reaches hgadMsg
  91. #define GMF_BUBBLED 0x00000002 // | After message reaches hgadMsg
  92. #define GMF_EVENT 0x00000003 // | After message becomes an event
  93. #define GMF_DESTINATION 0x00000003 // + Destination of message
  94. typedef int MSGID;
  95. typedef int PRID;
  96. // New Messages
  97. typedef struct tagGMSG
  98. {
  99. DWORD cbSize; // (REQUIRED) Size of message in bytes
  100. MSGID nMsg; // (REQUIRED) Gadget message
  101. HGADGET hgadMsg; // (REQUIRED) Gadget that message is "about"
  102. } GMSG;
  103. BEGIN_STRUCT(MethodMsg, GMSG)
  104. END_STRUCT(MethodMsg)
  105. BEGIN_STRUCT(EventMsg, MethodMsg)
  106. UINT nMsgFlags; // Flags about message
  107. END_STRUCT(EventMsg)
  108. #define GET_EVENT_DEST(pmsg) \
  109. (pmsg->nMsgFlags & GMF_DESTINATION)
  110. #define SET_EVENT_DEST(pmsg, dest) \
  111. (pmsg->nMsgFlags = ((pmsg->nMsgFlags & ~GMF_DESTINATION) | (dest & GMF_DESTINATION)))
  112. #define DEFINE_EVENT(event, guid) \
  113. struct __declspec(uuid(guid)) event
  114. /***************************************************************************\
  115. *
  116. * Gadget Classes
  117. *
  118. \***************************************************************************/
  119. #ifndef __cplusplus
  120. #error Requires C++ to compile
  121. #endif
  122. }; // extern "C"
  123. namespace DUser
  124. {
  125. // Forward declarations
  126. class Gadget;
  127. class SGadget;
  128. struct MessageInfoStub;
  129. };
  130. DUSER_API HRESULT WINAPI DUserDeleteGadget(DUser::Gadget * pg);
  131. DUSER_API HGADGET WINAPI DUserCastHandle(DUser::Gadget * pg);
  132. namespace DUser
  133. {
  134. #define dapi
  135. #define devent
  136. //
  137. // Core Classes
  138. //
  139. class Gadget
  140. {
  141. public:
  142. void * m_pDummy;
  143. inline HGADGET GetHandle() const
  144. {
  145. return DUserCastHandle(const_cast<Gadget *> (this));
  146. }
  147. inline void Delete()
  148. {
  149. DUserDeleteGadget(this);
  150. }
  151. HRESULT CallStubMethod(MethodMsg * pmsg);
  152. HRESULT CallSuperMethod(MethodMsg * pmsg, void * pMT);
  153. UINT CallStubEvent(EventMsg * pmsg, int nEventMsg);
  154. UINT CallSuperEvent(EventMsg * pmsg, void * pMT, int nEventMsg);
  155. enum ConstructCommand
  156. {
  157. ccSuper = 0, // Construct the super-class
  158. ccSetThis = 1, // Set this pointer
  159. };
  160. struct ConstructInfo
  161. {
  162. };
  163. };
  164. class SGadget
  165. {
  166. public:
  167. Gadget * m_pgad;
  168. static HCLASS s_hclSuper;
  169. inline HGADGET GetHandle() const
  170. {
  171. return DUserCastHandle(const_cast<Gadget *> (m_pgad));
  172. }
  173. inline void Delete()
  174. {
  175. DUserDeleteGadget(m_pgad);
  176. }
  177. };
  178. typedef HRESULT (SGadget::*MethodProc)(MethodMsg * pmsg);
  179. typedef HRESULT (SGadget::*EventProc)(EventMsg * pmsg);
  180. //
  181. // Delegate support
  182. //
  183. class EventDelegate
  184. {
  185. public:
  186. typedef HRESULT (CALLBACK Gadget::*Proc)(EventMsg * p1);
  187. static inline EventDelegate
  188. Build(Gadget * pvThis, Proc pfn)
  189. {
  190. EventDelegate ed;
  191. ed.m_pvThis = pvThis;
  192. ed.m_pfn = pfn;
  193. return ed;
  194. }
  195. inline HRESULT Invoke(EventMsg * p1)
  196. {
  197. return (m_pvThis->*m_pfn)(p1);
  198. }
  199. Gadget * m_pvThis;
  200. Proc m_pfn;
  201. };
  202. #define EVENT_DELEGATE(instance, function) \
  203. DUser::EventDelegate::Build(reinterpret_cast<DUser::Gadget *>(reinterpret_cast<void *>(instance)), \
  204. reinterpret_cast<DUser::EventDelegate::Proc>(function))
  205. //
  206. // Typedef's
  207. //
  208. typedef HRESULT (CALLBACK * ConstructProc)(DUser::Gadget::ConstructCommand cmd, HCLASS hclCur, DUser::Gadget * pg, void * pvData);
  209. typedef HRESULT (CALLBACK * PromoteProc)(ConstructProc pfnCS, HCLASS hclCur, DUser::Gadget * pg, DUser::Gadget::ConstructInfo * pmicData);
  210. typedef HCLASS (CALLBACK * DemoteProc)(HCLASS hclCur, DUser::Gadget * pg, void * pvData);
  211. //
  212. // Message information and class structures
  213. //
  214. template<class t, class m>
  215. inline void *
  216. Method(HRESULT (t::*pfn)(m * pmsg))
  217. {
  218. union
  219. {
  220. HRESULT (t::*in)(m * pmsg);
  221. void * out;
  222. };
  223. in = pfn;
  224. return out;
  225. }
  226. template<class t, class m>
  227. inline void *
  228. Event(HRESULT (t::*pfn)(m * pmsg))
  229. {
  230. union
  231. {
  232. HRESULT (t::*in)(m * pmsg);
  233. void * out;
  234. };
  235. in = pfn;
  236. return out;
  237. }
  238. struct MessageInfoGuts
  239. {
  240. void * pfn; // IN: Implementation function
  241. LPCWSTR pszMsgName; // IN: Name
  242. };
  243. struct MessageClassGuts
  244. {
  245. DWORD cbSize; // IN: Structure size
  246. DWORD nClassVersion; // IN: This class's version
  247. LPCWSTR pszClassName; // IN: Name of new class
  248. LPCWSTR pszSuperName; // IN: Name of super-class
  249. MessageInfoGuts * // IN: Message information
  250. rgMsgInfo;
  251. int cMsgs; // IN: Number of messages being registered
  252. PromoteProc pfnPromote; // IN: Promotion function
  253. DemoteProc pfnDemote; // IN: Demotion function
  254. HCLASS hclNew; // OUT: Newly created class
  255. HCLASS hclSuper; // OUT: Newly created class's super
  256. };
  257. struct MessageInfoStub
  258. {
  259. int cbSlotOffset; // OUT: Message slot offset
  260. LPCWSTR pszMsgName; // IN: Name
  261. };
  262. struct MessageClassStub
  263. {
  264. DWORD cbSize;
  265. DWORD nClassVersion;
  266. LPCWSTR pszClassName;
  267. DUser::MessageInfoStub *
  268. rgMsgInfo;
  269. int cMsgs;
  270. };
  271. struct MessageClassSuper
  272. {
  273. DWORD cbSize;
  274. DWORD nClassVersion;
  275. LPCWSTR pszClassName;
  276. void * pmt;
  277. };
  278. }; // namespace DUser
  279. extern "C" {
  280. DUSER_API HCLASS WINAPI DUserRegisterGuts(DUser::MessageClassGuts * pmc);
  281. DUSER_API HCLASS WINAPI DUserRegisterStub(DUser::MessageClassStub * pmc);
  282. DUSER_API HCLASS WINAPI DUserRegisterSuper(DUser::MessageClassSuper * pmc);
  283. DUSER_API HCLASS WINAPI DUserFindClass(LPCWSTR pszName, DWORD nVersion);
  284. DUSER_API DUser::Gadget *
  285. WINAPI DUserBuildGadget(HCLASS hcl, DUser::Gadget::ConstructInfo * pmicData);
  286. DUSER_API BOOL WINAPI DUserInstanceOf(DUser::Gadget * pg, HCLASS hclTest);
  287. DUSER_API DUser::Gadget *
  288. WINAPI DUserCastClass(DUser::Gadget * pg, HCLASS hclTest);
  289. DUSER_API DUser::Gadget *
  290. WINAPI DUserCastDirect(HGADGET hgad);
  291. DUSER_API void * WINAPI DUserGetGutsData(DUser::Gadget * pg, HCLASS hclData);
  292. /***************************************************************************\
  293. *
  294. * Messages
  295. *
  296. \***************************************************************************/
  297. // Core messages
  298. #define GM_EVENT 32768
  299. #define GM_DESTROY (1 + GM_EVENT)
  300. #define GM_PAINT (2 + GM_EVENT)
  301. #define GM_INPUT (3 + GM_EVENT)
  302. #define GM_CHANGESTATE (4 + GM_EVENT)
  303. #define GM_CHANGERECT (5 + GM_EVENT)
  304. #define GM_CHANGESTYLE (6 + GM_EVENT)
  305. #define GM_QUERY (7 + GM_EVENT)
  306. #define GM_SYNCADAPTOR (8 + GM_EVENT)
  307. #define GM_PAINTCACHE (9 + GM_EVENT) // TODO: Move into GM_PAINT message
  308. #define GM_USER (1024 + GM_EVENT) // Starting point for user messages
  309. #define GM_REGISTER (1000000 + GM_EVENT) // Starting point for registered messages
  310. // Win32 Messages
  311. // TODO: Move these to winuser.h
  312. #define WM_GETROOTGADGET (WM_USER - 1)
  313. // Message filtering
  314. #define GMFI_PAINT 0x00000001
  315. #define GMFI_INPUTKEYBOARD 0x00000002
  316. #define GMFI_INPUTMOUSE 0x00000004
  317. #define GMFI_INPUTMOUSEMOVE 0x00000008
  318. #define GMFI_CHANGESTATE 0x00000010
  319. #define GMFI_CHANGERECT 0x00000020
  320. #define GMFI_CHANGESTYLE 0x00000040
  321. #define GMFI_ALL 0xFFFFFFFF
  322. #define GMFI_VALID (GMFI_PAINT | \
  323. GMFI_INPUTKEYBOARD | GMFI_INPUTMOUSE | GMFI_INPUTMOUSEMOVE | \
  324. GMFI_CHANGESTATE | GMFI_CHANGERECT | GMFI_CHANGESTYLE)
  325. #define GDESTROY_START 1 // Gadget has started the destruction process
  326. #define GDESTROY_FINAL 2 // Gadget has been fully destroyed
  327. BEGIN_STRUCT(GMSG_DESTROY, EventMsg)
  328. UINT nCode; // Destruction code
  329. END_STRUCT(GMSG_DESTROY)
  330. #define GINPUT_MOUSE 0
  331. #define GINPUT_KEYBOARD 1
  332. #define GINPUT_JOYSTICK 2
  333. BEGIN_STRUCT(GMSG_INPUT, EventMsg)
  334. UINT nDevice; // Input device
  335. UINT nCode; // Specific action
  336. UINT nModifiers; // ctrl, alt, shift, leftbutton, middlebutton, rightbutton
  337. LONG lTime; // Time when message was sent
  338. END_STRUCT(GMSG_INPUT)
  339. #define GMOUSE_MOVE 0
  340. #define GMOUSE_DOWN 1
  341. #define GMOUSE_UP 2
  342. #define GMOUSE_DRAG 3
  343. #define GMOUSE_HOVER 4
  344. #define GMOUSE_WHEEL 5
  345. #define GMOUSE_MAX 5
  346. #define GBUTTON_NONE 0
  347. #define GBUTTON_LEFT 1
  348. #define GBUTTON_RIGHT 2
  349. #define GBUTTON_MIDDLE 3
  350. #define GBUTTON_MAX 3
  351. #define GMODIFIER_LCONTROL 0x00000001
  352. #define GMODIFIER_RCONTROL 0x00000002
  353. #define GMODIFIER_LSHIFT 0x00000004
  354. #define GMODIFIER_RSHIFT 0x00000008
  355. #define GMODIFIER_LALT 0x00000010
  356. #define GMODIFIER_RALT 0x00000020
  357. #define GMODIFIER_LBUTTON 0x00000040
  358. #define GMODIFIER_RBUTTON 0x00000080
  359. #define GMODIFIER_MBUTTON 0x00000100
  360. #define GMODIFIER_CONTROL (GMODIFIER_LCONTROL | GMODIFIER_RCONTROL)
  361. #define GMODIFIER_SHIFT (GMODIFIER_LSHIFT | GMODIFIER_RSHIFT)
  362. #define GMODIFIER_ALT (GMODIFIER_LALT | GMODIFIER_RALT)
  363. BEGIN_STRUCT(GMSG_MOUSE, GMSG_INPUT)
  364. POINT ptClientPxl; // Mouse location in client coordinates
  365. BYTE bButton; // Mouse button
  366. UINT nFlags; // Misc. flags
  367. END_STRUCT(GMSG_MOUSE)
  368. BEGIN_STRUCT(GMSG_MOUSEDRAG, GMSG_MOUSE)
  369. SIZE sizeDelta; // Mouse drag distance
  370. BOOL fWithin; // Mouse within gadget's bounds
  371. END_STRUCT(GMSG_MOUSEDRAG)
  372. BEGIN_STRUCT(GMSG_MOUSECLICK, GMSG_MOUSE)
  373. UINT cClicks; // number of clicks in "quick" succession
  374. END_STRUCT(GMSG_MOUSECLICK)
  375. BEGIN_STRUCT(GMSG_MOUSEWHEEL, GMSG_MOUSE)
  376. short sWheel; // Wheel position
  377. END_STRUCT(GMSG_MOUSEWHEEL)
  378. #define GKEY_DOWN 0
  379. #define GKEY_UP 1
  380. #define GKEY_CHAR 2
  381. #define GKEY_SYSDOWN 3
  382. #define GKEY_SYSUP 4
  383. #define GKEY_SYSCHAR 5
  384. BEGIN_STRUCT(GMSG_KEYBOARD, GMSG_INPUT)
  385. WCHAR ch; // Character
  386. WORD cRep; // Repeat count
  387. WORD wFlags; // Misc. flags
  388. END_STRUCT(GMSG_KEYBOARD)
  389. #define GPAINT_RENDER 0 // Render this Gadget into the buffer
  390. #define GPAINT_CACHE 1 // Post-render step for Cached drawing
  391. BEGIN_STRUCT(GMSG_PAINT, EventMsg)
  392. UINT nCmd; // Painting command
  393. UINT nSurfaceType; // Surface type
  394. END_STRUCT(GMSG_PAINT)
  395. BEGIN_STRUCT(GMSG_PAINTRENDERI, GMSG_PAINT)
  396. LPCRECT prcGadgetPxl; // Logical position of gadget
  397. LPCRECT prcInvalidPxl; // Invalid rectangle in container coordinates
  398. HDC hdc; // DC to draw into
  399. END_STRUCT(GMSG_PAINT)
  400. #ifdef GADGET_ENABLE_GDIPLUS
  401. BEGIN_STRUCT(GMSG_PAINTRENDERF, GMSG_PAINT)
  402. const Gdiplus::RectF *
  403. prcGadgetPxl; // Logical position of gadget
  404. const Gdiplus::RectF *
  405. prcInvalidPxl; // Invalid rectangle in container coordinates
  406. Gdiplus::Graphics *
  407. pgpgr; // Graphics to draw into
  408. END_STRUCT(GMSG_PAINT)
  409. #endif // GADGET_ENABLE_GDIPLUS
  410. BEGIN_STRUCT(GMSG_PAINTCACHE, EventMsg)
  411. LPCRECT prcGadgetPxl; // Logical position of gadget
  412. HDC hdc; // DC to draw into
  413. BYTE bAlphaLevel; // General alpha level when copying to destination
  414. BYTE bAlphaFormat; // Alpha format
  415. END_STRUCT(GMSG_PAINTCACHE)
  416. #define GSTATE_KEYBOARDFOCUS 0
  417. #define GSTATE_MOUSEFOCUS 1
  418. #define GSTATE_ACTIVE 2
  419. #define GSTATE_CAPTURE 3
  420. #define GSC_SET 0
  421. #define GSC_LOST 1
  422. BEGIN_STRUCT(GMSG_CHANGESTATE, EventMsg)
  423. UINT nCode; // Change command
  424. HGADGET hgadSet; // Gadget that is receiving the "state"
  425. HGADGET hgadLost; // Gadget that is loosing the "state"
  426. UINT nCmd; // Action that occurred
  427. END_STRUCT(GMSG_CHANGESTATE)
  428. BEGIN_STRUCT(GMSG_CHANGESTYLE, EventMsg)
  429. UINT nNewStyle; // New style
  430. UINT nOldStyle; // Old style
  431. END_STRUCT(GMSG_CHANGESTYLE)
  432. BEGIN_STRUCT(GMSG_CHANGERECT, EventMsg)
  433. RECT rcNewRect;
  434. UINT nFlags;
  435. END_STRUCT(GMSG_CHANGERECT)
  436. #ifdef GADGET_ENABLE_COM
  437. #define GQUERY_INTERFACE 0
  438. #define GQUERY_OBJECT 1
  439. #endif
  440. #define GQUERY_RECT 2
  441. #define GQUERY_DESCRIPTION 3
  442. #define GQUERY_DETAILS 4
  443. #define GQUERY_HITTEST 5
  444. #define GQUERY_PADDING 6
  445. #ifdef GADGET_ENABLE_OLE
  446. #define GQUERY_DROPTARGET 7
  447. #endif // GADGET_ENABLE_OLE
  448. BEGIN_STRUCT(GMSG_QUERY, EventMsg)
  449. UINT nCode; // Query command
  450. END_STRUCT(GMSG_QUERY)
  451. #ifdef GADGET_ENABLE_COM
  452. BEGIN_STRUCT(GMSG_QUERYINTERFACE, EventMsg)
  453. IUnknown * punk;
  454. END_STRUCT(GMSG_QUERYINTERFACE)
  455. #endif
  456. #define GQR_FIXED 0 // Should fix inside bounging box
  457. #define GQR_PRIVERT 1 // Vertical size is priority
  458. #define GQR_PRIHORZ 2 // Horizontal size is priority
  459. BEGIN_STRUCT(GMSG_QUERYRECT, GMSG_QUERY)
  460. SIZE sizeBound; // Rectangle to fit inside
  461. SIZE sizeResult; // Computed rectange
  462. UINT nFlags; // Flags to use in computation
  463. END_STRUCT(GMSG_QUERYRECT)
  464. BEGIN_STRUCT(GMSG_QUERYDESC, GMSG_QUERY)
  465. WCHAR szName[128];
  466. WCHAR szType[128];
  467. END_STRUCT(GMSG_QUERYDESC)
  468. #define GQDT_HWND 0 // Provided handle refers to parent HWND
  469. BEGIN_STRUCT(GMSG_QUERYDETAILS, GMSG_QUERY)
  470. UINT nType;
  471. HANDLE hOwner;
  472. END_STRUCT(GMSG_QUERYDETAILS)
  473. #define GQHT_NOWHERE 0 // Location is not "inside"
  474. #define GQHT_INSIDE 1 // Location is generically "inside"
  475. #define GQHT_CHILD 2 // Location is inside child specified by pvResultData
  476. // (NOT YET IMPLEMENTED)
  477. BEGIN_STRUCT(GMSG_QUERYHITTEST, GMSG_QUERY)
  478. POINT ptClientPxl; // Location in client pixels
  479. UINT nResultCode; // Result code
  480. void * pvResultData; // Extra result information
  481. END_STRUCT(GMSG_QUERYHITTEST)
  482. BEGIN_STRUCT(GMSG_QUERYPADDING, GMSG_QUERY)
  483. RECT rcPadding; // Extra padding around content
  484. END_STRUCT(GMSG_QUERYPADDING)
  485. #ifdef GADGET_ENABLE_OLE
  486. BEGIN_STRUCT(GMSG_QUERYDROPTARGET, GMSG_QUERY)
  487. HGADGET hgadDrop; // Gadget actually specifying the DropTarget
  488. IDropTarget *
  489. pdt; // DropTarget of Gadget
  490. END_STRUCT(GMSG_QUERYDROPTARGET)
  491. #endif // GADGET_ENABLE_OLE
  492. #define GSYNC_RECT (1)
  493. #define GSYNC_XFORM (2)
  494. #define GSYNC_STYLE (3)
  495. #define GSYNC_PARENT (4)
  496. BEGIN_STRUCT(GMSG_SYNCADAPTOR, EventMsg)
  497. UINT nCode; // Change code
  498. END_STRUCT(GMSG_SYNCADAPTOR)
  499. typedef HRESULT (CALLBACK * GADGETPROC)(HGADGET hgadCur, void * pvCur, EventMsg * pMsg);
  500. #define SGM_FULL 0x00000001 // Route and bubble the message
  501. #define SGM_RECEIVECONTEXT 0x00000002 // Use the receiving Gadget's Context
  502. #define SGM_VALID (SGM_FULL | SGM_RECEIVECONTEXT)
  503. typedef struct tagFGM_INFO
  504. {
  505. EventMsg* pmsg; // Message to fire
  506. UINT nFlags; // Flags modifying message being fired
  507. HRESULT hr; // Result of message (if send)
  508. void * pvReserved; // Reserved
  509. } FGM_INFO;
  510. #define FGMQ_SEND 1 // Standard "Send" message queue
  511. #define FGMQ_POST 2 // Standard "Post" message queue
  512. DUSER_API HRESULT WINAPI DUserSendMethod(MethodMsg * pmsg);
  513. DUSER_API HRESULT WINAPI DUserPostMethod(MethodMsg * pmsg);
  514. DUSER_API HRESULT WINAPI DUserSendEvent(EventMsg * pmsg, UINT nFlags);
  515. DUSER_API HRESULT WINAPI DUserPostEvent(EventMsg * pmsg, UINT nFlags);
  516. DUSER_API BOOL WINAPI FireGadgetMessages(FGM_INFO * rgFGM, int cMsgs, UINT idQueue);
  517. DUSER_API UINT WINAPI GetGadgetMessageFilter(HGADGET hgad, void * pvCookie);
  518. DUSER_API BOOL WINAPI SetGadgetMessageFilter(HGADGET hgad, void * pvCookie, UINT nNewFilter, UINT nMask);
  519. DUSER_API MSGID WINAPI RegisterGadgetMessage(const GUID * pguid);
  520. DUSER_API MSGID WINAPI RegisterGadgetMessageString(LPCWSTR pszName);
  521. DUSER_API BOOL WINAPI UnregisterGadgetMessage(const GUID * pguid);
  522. DUSER_API BOOL WINAPI UnregisterGadgetMessageString(LPCWSTR pszName);
  523. DUSER_API BOOL WINAPI FindGadgetMessages(const GUID ** rgpguid, MSGID * rgnMsg, int cMsgs);
  524. DUSER_API BOOL WINAPI AddGadgetMessageHandler(HGADGET hgadMsg, MSGID nMsg, HGADGET hgadHandler);
  525. DUSER_API BOOL WINAPI RemoveGadgetMessageHandler(HGADGET hgadMsg, MSGID nMsg, HGADGET hgadHandler);
  526. DUSER_API BOOL WINAPI GetMessageExA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax);
  527. DUSER_API BOOL WINAPI GetMessageExW(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax);
  528. DUSER_API BOOL WINAPI PeekMessageExA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg);
  529. DUSER_API BOOL WINAPI PeekMessageExW(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg);
  530. DUSER_API BOOL WINAPI WaitMessageEx();
  531. #ifdef UNICODE
  532. #define GetMessageEx GetMessageExW
  533. #define PeekMessageEx PeekMessageExW
  534. #else
  535. #define GetMessageEx GetMessageExA
  536. #define PeekMessageEx PeekMessageExA
  537. #endif
  538. /***************************************************************************\
  539. *
  540. * Construction, Tree management
  541. *
  542. \***************************************************************************/
  543. #define GC_HWNDHOST 0x00000001 // + Host inside an HWND
  544. #define GC_NCHOST 0x00000002 // | Host inside Non-client of HWND
  545. #define GC_DXHOST 0x00000003 // | Host inside DirectX Surface
  546. #define GC_COMPLEX 0x00000004 // | Complex TreeGadget
  547. #define GC_SIMPLE 0x00000005 // | Simple TreeGadget
  548. #define GC_DETACHED 0x00000006 // | Detached TreeGadget
  549. #define GC_MESSAGE 0x00000007 // | Message-only Gadget
  550. #define GC_TYPE 0x0000000F // + Type of Gadget to create
  551. #define GC_VALID (GC_TYPE)
  552. DUSER_API HGADGET WINAPI CreateGadget(HANDLE hParent, UINT nFlags, GADGETPROC pfnProc, void * pvGadgetData);
  553. #define GENUM_CURRENT 0x00000001 // Starting node in enumeration
  554. #define GENUM_SIBLINGS 0x00000002 // Siblings of starting node in enumeration
  555. // + Type of enumeration (exclusive)
  556. #define GENUM_PARENTSUP 0x00000004 // | Parents of this node going up
  557. #define GENUM_PARENTSDOWN 0x00000008 // | Parents of this node going down
  558. #define GENUM_SHALLOWCHILD 0x0000000C // | Shallow children
  559. #define GENUM_DEEPCHILD 0x00000010 // + Deep children
  560. #define GENUM_TYPE (GENUM_PARENTSUP | GENUM_PARENTSDOWN | \
  561. GENUM_SHALLOWCHILD | GENUM_DEEPCHILD)
  562. #define GENUM_MODIFYTREE 0x00000020 // Allow modifying the Tree during enumeration
  563. #define GENUM_VALID (GENUM_CURRENT | GENUM_SIBLINGS | GENUM_TYPE | GENUM_MODIFYTREE)
  564. typedef BOOL (CALLBACK * GADGETENUMPROC)(HGADGET hgad, void * pvData);
  565. DUSER_API BOOL WINAPI EnumGadgets(HGADGET hgadEnum, GADGETENUMPROC pfnProc, void * pvData, UINT nFlags);
  566. #define GORDER_MIN 0
  567. #define GORDER_ANY 0 // Order does not matter
  568. #define GORDER_BEFORE 1 // Move this gadget in-front of sibling
  569. #define GORDER_BEHIND 2 // Move this gadget behind sibling
  570. #define GORDER_TOP 3 // Move to front of sibling z-order
  571. #define GORDER_BOTTOM 4 // Move to bottom of sibling z-order
  572. #define GORDER_FORWARD 5 // Move forward in z-order
  573. #define GORDER_BACKWARD 6 // Move backward in z-order
  574. #define GORDER_MAX 6
  575. DUSER_API BOOL WINAPI SetGadgetOrder(HGADGET hgadMove, HGADGET hgadOther, UINT nCmd);
  576. DUSER_API BOOL WINAPI SetGadgetParent(HGADGET hgadMove, HGADGET hgadParent, HGADGET hgadOther, UINT nCmd);
  577. #define GG_MIN 0
  578. #define GG_PARENT 0
  579. #define GG_NEXT 1
  580. #define GG_PREV 2
  581. #define GG_TOPCHILD 3
  582. #define GG_BOTTOMCHILD 4
  583. #define GG_ROOT 5
  584. #define GG_MAX 5
  585. DUSER_API HGADGET WINAPI GetGadget(HGADGET hgad, UINT nCmd);
  586. /***************************************************************************\
  587. *
  588. * Styles and properties
  589. *
  590. \***************************************************************************/
  591. #define GS_RELATIVE 0x00000001 // Positioning is relative to parent
  592. #define GS_VISIBLE 0x00000002 // Drawing is visible
  593. #define GS_ENABLED 0x00000004 // Input in "enabled"
  594. #define GS_BUFFERED 0x00000008 // Drawing is double-buffered
  595. #define GS_ALLOWSUBCLASS 0x00000010 // Gadget can be subclassed
  596. #define GS_KEYBOARDFOCUS 0x00000020 // Gadget can receive keyboard focus
  597. #define GS_MOUSEFOCUS 0x00000040 // Gadget can receive mouse focus
  598. #define GS_CLIPINSIDE 0x00000080 // Clip drawing inside this Gadget
  599. #define GS_CLIPSIBLINGS 0x00000100 // Clip siblings of this Gadget
  600. #define GS_HREDRAW 0x00000200 // Redraw entire Gadget if resized horizontally
  601. #define GS_VREDRAW 0x00000400 // Redraw entire Gadget if resized vertically
  602. #define GS_OPAQUE 0x00000800 // HINT: Drawing is composited
  603. #define GS_ZEROORIGIN 0x00001000 // Set origin to (0,0)
  604. #define GS_CUSTOMHITTEST 0x00002000 // Requires custom hit-testing
  605. #define GS_ADAPTOR 0x00004000 // Requires extra notifications to host
  606. #define GS_CACHED 0x00008000 // Drawing is cached
  607. #define GS_DEEPPAINTSTATE 0x00010000 // Sub-tree inherits paint state
  608. #define GS_VALID (GS_RELATIVE | GS_VISIBLE | GS_ENABLED | GS_BUFFERED | \
  609. GS_ALLOWSUBCLASS | GS_KEYBOARDFOCUS | GS_MOUSEFOCUS | \
  610. GS_CLIPINSIDE | GS_CLIPSIBLINGS | GS_HREDRAW | GS_VREDRAW | \
  611. GS_OPAQUE | GS_ZEROORIGIN | GS_CUSTOMHITTEST | \
  612. GS_ADAPTOR | GS_CACHED | GS_DEEPPAINTSTATE)
  613. DUSER_API UINT WINAPI GetGadgetStyle(HGADGET hgad);
  614. DUSER_API BOOL WINAPI SetGadgetStyle(HGADGET hgadChange, UINT nNewStyle, UINT nMask);
  615. DUSER_API HGADGET WINAPI GetGadgetFocus();
  616. DUSER_API BOOL WINAPI SetGadgetFocus(HGADGET hgadFocus);
  617. DUSER_API BOOL WINAPI IsGadgetParentChainStyle(HGADGET hgad, UINT nStyle, BOOL * pfVisible, UINT nFlags);
  618. inline BOOL IsGadgetVisible(HGADGET hgad, BOOL * pfVisible, UINT nFlags) {
  619. return IsGadgetParentChainStyle(hgad, GS_VISIBLE, pfVisible, nFlags); }
  620. inline BOOL IsGadgetEnabled(HGADGET hgad, BOOL * pfEnabled, UINT nFlags) {
  621. return IsGadgetParentChainStyle(hgad, GS_ENABLED, pfEnabled, nFlags); }
  622. DUSER_API PRID WINAPI RegisterGadgetProperty(const GUID * pguid);
  623. DUSER_API BOOL WINAPI UnregisterGadgetProperty(const GUID * pguid);
  624. DUSER_API BOOL WINAPI GetGadgetProperty(HGADGET hgad, PRID id, void ** ppvValue);
  625. DUSER_API BOOL WINAPI SetGadgetProperty(HGADGET hgad, PRID id, void * pvValue);
  626. DUSER_API BOOL WINAPI RemoveGadgetProperty(HGADGET hgad, PRID id);
  627. /***************************************************************************\
  628. *
  629. * Painting, Transforms
  630. *
  631. \***************************************************************************/
  632. #define BLEND_OPAQUE 255
  633. #define BLEND_TRANSPARENT 0
  634. #define PI 3.14159265359
  635. DUSER_API BOOL WINAPI InvalidateGadget(HGADGET hgad);
  636. DUSER_API BOOL WINAPI SetGadgetFillI(HGADGET hgadChange, HBRUSH hbrFill, BYTE bAlpha, int w, int h);
  637. #ifdef GADGET_ENABLE_GDIPLUS
  638. DUSER_API BOOL WINAPI SetGadgetFillF(HGADGET hgadChange, Gdiplus::Brush * pgpbr);
  639. #endif // GADGET_ENABLE_GDIPLUS
  640. DUSER_API BOOL WINAPI GetGadgetScale(HGADGET hgad, float * pflX, float * pflY);
  641. DUSER_API BOOL WINAPI SetGadgetScale(HGADGET hgadChange, float flX, float flY);
  642. DUSER_API BOOL WINAPI GetGadgetRotation(HGADGET hgad, float * pflRotationRad);
  643. DUSER_API BOOL WINAPI SetGadgetRotation(HGADGET hgadChange, float flRotationRad);
  644. DUSER_API BOOL WINAPI GetGadgetCenterPoint(HGADGET hgad, float * pflX, float * pflY);
  645. DUSER_API BOOL WINAPI SetGadgetCenterPoint(HGADGET hgadChange, float flX, float flY);
  646. #define GBIM_STYLE 0x00000001
  647. #define GBIM_ALPHA 0x00000002
  648. #define GBIM_FILL 0x00000004
  649. #define GBIM_VALID (GBIM_STYLE | GBIM_ALPHA | GBIM_FILL)
  650. #define GBIS_FILL 0x00000001
  651. #define GBIS_VALID (GBIS_FILL)
  652. typedef struct tagBUFFER_INFO
  653. {
  654. DWORD cbSize;
  655. UINT nMask;
  656. UINT nStyle;
  657. BYTE bAlpha;
  658. COLORREF crFill;
  659. } BUFFER_INFO;
  660. DUSER_API BOOL WINAPI GetGadgetBufferInfo(HGADGET hgad, BUFFER_INFO * pbi);
  661. DUSER_API BOOL WINAPI SetGadgetBufferInfo(HGADGET hgadChange, const BUFFER_INFO * pbi);
  662. #define GRT_VISRGN 0 // VisRgn in container coordinates
  663. #define GRT_MIN 0
  664. #define GRT_MAX 0
  665. DUSER_API BOOL WINAPI GetGadgetRgn(HGADGET hgad, UINT nRgnType, HRGN hrgn, UINT nFlags);
  666. #define GRIM_OPTIONS 0x00000001 // nOptions is valid
  667. #define GRIM_SURFACE 0x00000002 // nSurface is valid
  668. #define GRIM_PALETTE 0x00000004 // Palette is valid
  669. #define GRIM_DROPTARGET 0x00000008 // nDropTarget is valid
  670. #define GRIM_VALID (GRIM_OPTIONS | GRIM_SURFACE | GRIM_PALETTE | GRIM_DROPTARGET)
  671. #define GSURFACE_MIN 0
  672. #define GSURFACE_HDC 0 // HDC
  673. #define GSURFACE_GPGRAPHICS 1 // Gdiplus::Graphics
  674. #define GSURFACE_MAX 1
  675. #define GRIO_MANUALDRAW 0x00000001 // Call DrawGadgetTree() to draw.
  676. #define GRIO_VALID (GRIO_MANUALDRAW)
  677. #define GRIDT_MIN 0
  678. #define GRIDT_NONE 0 // Not a drop target
  679. #define GRIDT_FAST 1 // Using OLE2 polling DnD
  680. #define GRIDT_PRECISE 2 // Rescan for positional changes
  681. #define GRIDT_MAX 2
  682. typedef struct tagROOT_INFO
  683. {
  684. DWORD cbSize;
  685. UINT nMask;
  686. UINT nOptions;
  687. UINT nSurface;
  688. UINT nDropTarget;
  689. union {
  690. void * pvData;
  691. HPALETTE hpal;
  692. #ifdef GADGET_ENABLE_GDIPLUS
  693. Gdiplus::ColorPalette *
  694. pgppal;
  695. #endif // GADGET_ENABLE_GDIPLUS
  696. };
  697. } ROOT_INFO;
  698. DUSER_API BOOL WINAPI GetGadgetRootInfo(HGADGET hgadRoot, ROOT_INFO * pri);
  699. DUSER_API BOOL WINAPI SetGadgetRootInfo(HGADGET hgadRoot, const ROOT_INFO * pri);
  700. #define GAIO_MOUSESTATE 0x00000001 // Synchronize mouse state
  701. #define GAIO_KEYBOARDSTATE 0x00000002 // Synchronize keyboard state
  702. #define GAIO_ENABLECAPTURE 0x00000004 // Synchronize mouse capture state
  703. #define GAIM_OPTIONS 0x00000001 // nOptions is valid
  704. typedef struct tagADAPTOR_INFO
  705. {
  706. DWORD cbSize;
  707. UINT nMask;
  708. UINT nOptions;
  709. } ADAPTOR_INFO;
  710. DUSER_API BOOL WINAPI GetGadgetAdaptorInfo(HGADGET hgadAdaptor, ADAPTOR_INFO * pai);
  711. DUSER_API BOOL WINAPI SetGadgetAdaptorInfo(HGADGET hgadAdaptor, const ADAPTOR_INFO * pai);
  712. /***************************************************************************\
  713. *
  714. * Position
  715. *
  716. \***************************************************************************/
  717. #define SGR_MOVE 0x00000001 // Gadget is being moved
  718. #define SGR_SIZE 0x00000002 // Gadget is being resized
  719. #define SGR_CHANGEMASK (SGR_MOVE | SGR_SIZE)
  720. #define SGR_CLIENT 0x00000004 // Relative to itself
  721. #define SGR_PARENT 0x00000008 // Relative to parent
  722. #define SGR_CONTAINER 0x0000000c // Relative to root container
  723. #define SGR_DESKTOP 0x00000010 // Relative to virtual desktop
  724. #define SGR_OFFSET 0x00000014 // Relative to current position
  725. #define SGR_RECTMASK (SGR_CLIENT | SGR_PARENT | SGR_CONTAINER | \
  726. SGR_DESKTOP | SGR_OFFSET)
  727. #define SGR_ACTUAL 0x00000100 // Actual (non-XForm) rectangle
  728. #define SGR_NOINVALIDATE 0x00000200 // Don't automatically invalidate
  729. #define SGR_VALID_GET (SGR_RECTMASK | SGR_ACTUAL)
  730. #define SGR_VALID_SET (SGR_CHANGEMASK | SGR_RECTMASK | SGR_ACTUAL | SGR_NOINVALIDATE)
  731. DUSER_API BOOL WINAPI GetGadgetSize(HGADGET hgad, SIZE * psizeLogicalPxl);
  732. DUSER_API BOOL WINAPI GetGadgetRect(HGADGET hgad, RECT * prcPxl, UINT nFlags);
  733. DUSER_API BOOL WINAPI SetGadgetRect(HGADGET hgadChange, int x, int y, int w, int h, UINT nFlags);
  734. DUSER_API HGADGET WINAPI FindGadgetFromPoint(HGADGET hgadRoot, POINT ptContainerPxl, UINT nStyle, POINT * pptClientPxl);
  735. DUSER_API BOOL WINAPI MapGadgetPoints(HGADGET hgadFrom, HGADGET hgadTo, POINT * rgptClientPxl, int cPts);
  736. /***************************************************************************\
  737. *
  738. * Tickets
  739. *
  740. \***************************************************************************/
  741. DUSER_API DWORD WINAPI GetGadgetTicket(HGADGET hgad);
  742. DUSER_API HGADGET WINAPI LookupGadgetTicket(DWORD dwTicket);
  743. /***************************************************************************\
  744. *
  745. * Special hooks for different containers
  746. *
  747. \***************************************************************************/
  748. DUSER_API BOOL WINAPI ForwardGadgetMessage(HGADGET hgadRoot, UINT nMsg, WPARAM wParam, LPARAM lParam, LRESULT * pr);
  749. #define GDRAW_SHOW 0x00000001
  750. #define GDRAW_VALID (GDRAW_SHOW)
  751. DUSER_API BOOL WINAPI DrawGadgetTree(HGADGET hgadDraw, HDC hdcDraw, const RECT * prcDraw, UINT nFlags);
  752. typedef BOOL (CALLBACK* ATTACHWNDPROC)(void * pvThis, HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM lParam, LRESULT * plRet);
  753. DUSER_API BOOL WINAPI AttachWndProcA(HWND hwnd, ATTACHWNDPROC pfn, void * pvThis);
  754. DUSER_API BOOL WINAPI AttachWndProcW(HWND hwnd, ATTACHWNDPROC pfn, void * pvThis);
  755. DUSER_API BOOL WINAPI DetachWndProc(HWND hwnd, ATTACHWNDPROC pfn, void * pvThis);
  756. #ifdef UNICODE
  757. #define AttachWndProc AttachWndProcW
  758. #else
  759. #define AttachWndProc AttachWndProcA
  760. #endif
  761. #ifdef __cplusplus
  762. }; // extern "C"
  763. #endif
  764. #endif // INC__DUserCore_h__INCLUDED