/binding/win32/gdiplusinit.d

http://github.com/wilkie/djehuty · D · 144 lines · 65 code · 25 blank · 54 comment · 0 complexity · a12c6427a696c5d8794a47f290072006 MD5 · raw file

  1. /*
  2. * gdiplusinit.d
  3. *
  4. * This module binds GdiPlusInit.h to D. The original copyright
  5. * notice is preserved below.
  6. *
  7. * Author: Dave Wilkinson
  8. * Originated: November 25th, 2009
  9. *
  10. */
  11. module binding.win32.gdiplusinit;
  12. import binding.win32.windef;
  13. import binding.win32.winbase;
  14. import binding.win32.winnt;
  15. import binding.win32.gdiplustypes;
  16. extern(System):
  17. /**************************************************************************
  18. *
  19. * Copyright (c) 2000-2003 Microsoft Corporation
  20. *
  21. * Module Name:
  22. *
  23. * Gdiplus initialization
  24. *
  25. * Abstract:
  26. *
  27. * GDI+ Startup and Shutdown APIs
  28. *
  29. **************************************************************************/
  30. enum DebugEventLevel {
  31. DebugEventLevelFatal,
  32. DebugEventLevelWarning
  33. }
  34. // Callback function that GDI+ can call, on debug builds, for assertions
  35. // and warnings.
  36. alias VOID function(DebugEventLevel level, CHAR* message) DebugEventProc;
  37. // Notification functions which the user must call appropriately if
  38. // "SuppressBackgroundThread" (below) is set.
  39. alias Status function(ULONG_PTR* token) NotificationHookProc;
  40. alias VOID function(ULONG_PTR token) NotificationUnhookProc;
  41. // Input structure for GdiplusStartup()
  42. struct GdiplusStartupInput {
  43. UINT32 GdiplusVersion = 1; // Must be 1 (or 2 for the Ex version)
  44. DebugEventProc DebugEventCallback = null; // Ignored on free builds
  45. BOOL SuppressBackgroundThread = FALSE; // FALSE unless you're prepared to call
  46. // the hook/unhook functions properly
  47. BOOL SuppressExternalCodecs = FALSE; // FALSE unless you want GDI+ only to use
  48. // its internal image codecs.
  49. GdiplusStartupInput init(
  50. DebugEventProc debugEventCallback = null,
  51. BOOL suppressBackgroundThread = FALSE,
  52. BOOL suppressExternalCodecs = FALSE) {
  53. GdiplusStartupInput ret;
  54. ret.GdiplusVersion = 1;
  55. ret.DebugEventCallback = debugEventCallback;
  56. ret.SuppressBackgroundThread = suppressBackgroundThread;
  57. ret.SuppressExternalCodecs = suppressExternalCodecs;
  58. return ret;
  59. }
  60. }
  61. struct GdiplusStartupInputEx {
  62. UINT32 GdiplusVersion = 2; // Must be 1 (or 2 for the Ex version)
  63. DebugEventProc DebugEventCallback = null; // Ignored on free builds
  64. BOOL SuppressBackgroundThread = FALSE; // FALSE unless you're prepared to call
  65. // the hook/unhook functions properly
  66. BOOL SuppressExternalCodecs = FALSE; // FALSE unless you want GDI+ only to use
  67. // its internal image codecs.
  68. INT StartupParameters = 0; // Do we not set the FPU rounding mode
  69. GdiplusStartupInputEx init(
  70. INT startupParameters = 0,
  71. DebugEventProc debugEventCallback = null,
  72. BOOL suppressBackgroundThread = FALSE,
  73. BOOL suppressExternalCodecs = FALSE) {
  74. GdiplusStartupInputEx ret;
  75. ret.GdiplusVersion = 2;
  76. ret.DebugEventCallback = debugEventCallback;
  77. ret.SuppressBackgroundThread = suppressBackgroundThread;
  78. ret.SuppressExternalCodecs = suppressExternalCodecs;
  79. ret.StartupParameters = startupParameters;
  80. return ret;
  81. }
  82. }
  83. enum GdiplusStartupParams {
  84. GdiplusStartupDefault = 0,
  85. GdiplusStartupNoSetRound = 1,
  86. GdiplusStartupSetPSValue = 2,
  87. GdiplusStartupTransparencyMask = 0xFF000000
  88. }
  89. // Output structure for GdiplusStartup()
  90. struct GdiplusStartupOutput {
  91. // The following 2 fields are NULL if SuppressBackgroundThread is FALSE.
  92. // Otherwise, they are functions which must be called appropriately to
  93. // replace the background thread.
  94. //
  95. // These should be called on the application's main message loop - i.e.
  96. // a message loop which is active for the lifetime of GDI+.
  97. // "NotificationHook" should be called before starting the loop,
  98. // and "NotificationUnhook" should be called after the loop ends.
  99. NotificationHookProc NotificationHook;
  100. NotificationUnhookProc NotificationUnhook;
  101. }
  102. // GDI+ initialization. Must not be called from DllMain - can cause deadlock.
  103. //
  104. // Must be called before GDI+ API's or constructors are used.
  105. //
  106. // token - may not be NULL - accepts a token to be passed in the corresponding
  107. // GdiplusShutdown call.
  108. // input - may not be NULL
  109. // output - may be NULL only if input->SuppressBackgroundThread is FALSE.
  110. Status GdiplusStartup(
  111. ULONG_PTR *token,
  112. GdiplusStartupInput *input,
  113. GdiplusStartupOutput *output);
  114. // GDI+ termination. Must be called before GDI+ is unloaded.
  115. // Must not be called from DllMain - can cause deadlock.
  116. //
  117. // GDI+ API's may not be called after GdiplusShutdown. Pay careful attention
  118. // to GDI+ object destructors.
  119. VOID GdiplusShutdown(ULONG_PTR token);