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.

224 lines
6.5 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: winstl/window/gdi_functions.h (originally MWGdi.h / MWWinCmn, ::SynesisWin)
  3. *
  4. * Purpose: Error functions.
  5. *
  6. * Created: 20th October 1994
  7. * Updated: 10th August 2009
  8. *
  9. * Home: http://stlsoft.org/
  10. *
  11. * Copyright (c) 1994-2009, Matthew Wilson and Synesis Software
  12. * All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions are met:
  16. *
  17. * - Redistributions of source code must retain the above copyright notice, this
  18. * list of conditions and the following disclaimer.
  19. * - Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
  23. * any contributors may be used to endorse or promote products derived from
  24. * this software without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  27. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  30. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  31. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  32. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  33. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  34. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  35. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. * ////////////////////////////////////////////////////////////////////// */
  39. /** \file winstl/window/gdi_functions.h
  40. *
  41. * \brief [C, C++] GDI functions
  42. * (\ref group__library__windows_window "Windows Window" Library).
  43. */
  44. #ifndef WINSTL_INCL_WINSTL_WINDOW_H_GDI_FUNCTIONS
  45. #define WINSTL_INCL_WINSTL_WINDOW_H_GDI_FUNCTIONS
  46. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  47. # define WINSTL_VER_WINSTL_WINDOW_H_GDI_FUNCTIONS_MAJOR 4
  48. # define WINSTL_VER_WINSTL_WINDOW_H_GDI_FUNCTIONS_MINOR 0
  49. # define WINSTL_VER_WINSTL_WINDOW_H_GDI_FUNCTIONS_REVISION 2
  50. # define WINSTL_VER_WINSTL_WINDOW_H_GDI_FUNCTIONS_EDIT 136
  51. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  52. /* /////////////////////////////////////////////////////////////////////////
  53. * Includes
  54. */
  55. #ifndef WINSTL_INCL_WINSTL_H_WINSTL
  56. # include <winstl/winstl.h>
  57. #endif /* !WINSTL_INCL_WINSTL_H_WINSTL */
  58. /* /////////////////////////////////////////////////////////////////////////
  59. * Namespace
  60. */
  61. #if !defined(_WINSTL_NO_NAMESPACE) && \
  62. !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  63. # if defined(_STLSOFT_NO_NAMESPACE)
  64. /* There is no stlsoft namespace, so must define ::winstl */
  65. namespace winstl
  66. {
  67. # else
  68. /* Define stlsoft::winstl_project */
  69. namespace stlsoft
  70. {
  71. namespace winstl_project
  72. {
  73. # endif /* _STLSOFT_NO_NAMESPACE */
  74. #endif /* !_WINSTL_NO_NAMESPACE */
  75. /* /////////////////////////////////////////////////////////////////////////
  76. * C functions
  77. */
  78. STLSOFT_INLINE ws_size_t winstl__get_BITMAP(HBITMAP hbmp, BITMAP *pbmp)
  79. {
  80. return stlsoft_static_cast(ws_size_t, STLSOFT_NS_GLOBAL(GetObject)(hbmp, sizeof(BITMAP), pbmp));
  81. }
  82. STLSOFT_INLINE ws_size_t winstl__get_DIBSECTION(HBITMAP hbmp, DIBSECTION *pds)
  83. {
  84. return stlsoft_static_cast(ws_size_t, STLSOFT_NS_GLOBAL(GetObject)(hbmp, sizeof(DIBSECTION), pds));
  85. }
  86. STLSOFT_INLINE ws_size_t winstl__get_LOGPEN(HPEN hpen, LOGPEN *plp)
  87. {
  88. return stlsoft_static_cast(ws_size_t, STLSOFT_NS_GLOBAL(GetObject)(hpen, sizeof(LOGPEN), plp));
  89. }
  90. STLSOFT_INLINE ws_size_t winstl__get_EXTLOGPEN(HPEN hpen, EXTLOGPEN *pxlp)
  91. {
  92. return stlsoft_static_cast(ws_size_t, STLSOFT_NS_GLOBAL(GetObject)(hpen, sizeof(EXTLOGPEN), pxlp));
  93. }
  94. STLSOFT_INLINE ws_size_t winstl__get_LOGBRUSH(HBRUSH hpal, LOGBRUSH *pbr)
  95. {
  96. return stlsoft_static_cast(ws_size_t, STLSOFT_NS_GLOBAL(GetObject)(hpal, sizeof(LOGBRUSH), pbr));
  97. }
  98. STLSOFT_INLINE ws_size_t winstl__get_LOGFONT(HFONT hpal, LOGFONT *pfnt)
  99. {
  100. return stlsoft_static_cast(ws_size_t, STLSOFT_NS_GLOBAL(GetObject)(hpal, sizeof(LOGFONT), pfnt));
  101. }
  102. /* /////////////////////////////////////////////////////////////////////////
  103. * Namespace
  104. */
  105. #ifdef STLSOFT_DOCUMENTATION_SKIP_SECTION
  106. namespace winstl
  107. {
  108. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  109. /* /////////////////////////////////////////////////////////////////////////
  110. * C++ functions
  111. */
  112. #if defined(__cplusplus)
  113. inline ws_size_t get_object(HBITMAP h, BITMAP &desc)
  114. {
  115. return winstl__get_BITMAP(h, &desc);
  116. }
  117. inline ws_size_t get_object(HBITMAP h, DIBSECTION &desc)
  118. {
  119. return winstl__get_DIBSECTION(h, &desc);
  120. }
  121. inline ws_size_t get_object(HPEN h, EXTLOGPEN &desc)
  122. {
  123. return winstl__get_EXTLOGPEN(h, &desc);
  124. }
  125. inline ws_size_t get_object(HPEN h, LOGPEN &desc)
  126. {
  127. return winstl__get_LOGPEN(h, &desc);
  128. }
  129. inline ws_size_t get_object(HBRUSH h, LOGBRUSH &desc)
  130. {
  131. return winstl__get_LOGBRUSH(h, &desc);
  132. }
  133. inline ws_size_t get_object(HFONT h, LOGFONT &desc)
  134. {
  135. return winstl__get_LOGFONT(h, &desc);
  136. }
  137. template< ss_typename_param_k D
  138. , ss_typename_param_k H
  139. >
  140. inline D get_object_helper(H h)
  141. {
  142. D d;
  143. return get_object(h, d) ? d : D();
  144. }
  145. inline BITMAP get_BITMAP(HBITMAP h)
  146. {
  147. return get_object_helper<BITMAP>(h);
  148. }
  149. inline DIBSECTION get_DIBSECTION(HBITMAP h)
  150. {
  151. return get_object_helper<DIBSECTION>(h);
  152. }
  153. inline EXTLOGPEN get_EXTLOGPEN(HPEN h)
  154. {
  155. return get_object_helper<EXTLOGPEN>(h);
  156. }
  157. inline LOGPEN get_LOGPEN(HPEN h)
  158. {
  159. return get_object_helper<LOGPEN>(h);
  160. }
  161. inline LOGBRUSH get_LOGBRUSH(HBRUSH h)
  162. {
  163. return get_object_helper<LOGBRUSH>(h);
  164. }
  165. inline LOGFONT get_LOGFONT(HFONT h)
  166. {
  167. return get_object_helper<LOGFONT>(h);
  168. }
  169. #endif /* __cplusplus */
  170. /* ////////////////////////////////////////////////////////////////////// */
  171. #ifndef _WINSTL_NO_NAMESPACE
  172. # if defined(_STLSOFT_NO_NAMESPACE) || \
  173. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  174. } /* namespace winstl */
  175. # else
  176. } /* namespace winstl_project */
  177. } /* namespace stlsoft */
  178. # endif /* _STLSOFT_NO_NAMESPACE */
  179. #endif /* !_WINSTL_NO_NAMESPACE */
  180. /* ////////////////////////////////////////////////////////////////////// */
  181. #endif /* WINSTL_INCL_WINSTL_WINDOW_H_GDI_FUNCTIONS */
  182. /* ///////////////////////////// end of file //////////////////////////// */