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.

163 lines
5.3 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: winstl/window/font_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/font_functions.h
  40. *
  41. * \brief [C, C++] Error functions
  42. * (\ref group__library__windows_window "Windows Window" Library).
  43. */
  44. #ifndef WINSTL_INCL_WINSTL_WINDOW_H_FONT_FUNCTIONS
  45. #define WINSTL_INCL_WINSTL_WINDOW_H_FONT_FUNCTIONS
  46. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  47. # define WINSTL_VER_WINSTL_WINDOW_H_FONT_FUNCTIONS_MAJOR 4
  48. # define WINSTL_VER_WINSTL_WINDOW_H_FONT_FUNCTIONS_MINOR 0
  49. # define WINSTL_VER_WINSTL_WINDOW_H_FONT_FUNCTIONS_REVISION 1
  50. # define WINSTL_VER_WINSTL_WINDOW_H_FONT_FUNCTIONS_EDIT 137
  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. #ifndef WINSTL_INCL_WINSTL_WINDOW_H_MESSAGE_FUNCTIONS
  59. # include <winstl/window/message_functions.h>
  60. #endif /* !WINSTL_INCL_WINSTL_WINDOW_H_MESSAGE_FUNCTIONS */
  61. /* /////////////////////////////////////////////////////////////////////////
  62. * Namespace
  63. */
  64. #if !defined(_WINSTL_NO_NAMESPACE) && \
  65. !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  66. # if defined(_STLSOFT_NO_NAMESPACE)
  67. /* There is no stlsoft namespace, so must define ::winstl */
  68. namespace winstl
  69. {
  70. # else
  71. /* Define stlsoft::winstl_project */
  72. namespace stlsoft
  73. {
  74. namespace winstl_project
  75. {
  76. # endif /* _STLSOFT_NO_NAMESPACE */
  77. #endif /* !_WINSTL_NO_NAMESPACE */
  78. /* /////////////////////////////////////////////////////////////////////////
  79. * Functions
  80. */
  81. /** \brief Gets the font associated with the window.
  82. *
  83. * \ingroup group__library__windows_window
  84. */
  85. STLSOFT_INLINE HFONT winstl__get_window_font(HWND hwnd)
  86. {
  87. return stlsoft_reinterpret_cast(HFONT, winstl__SendMessage(hwnd, WM_GETFONT, 0, 0L));
  88. }
  89. /** \brief Sets the window's font.
  90. *
  91. * \ingroup group__library__windows_window
  92. */
  93. STLSOFT_INLINE void winstl__set_window_font(HWND hwnd, HFONT hfont, ws_int_t bRedraw)
  94. {
  95. stlsoft_static_cast(void, winstl__SendMessage(hwnd, WM_SETFONT, stlsoft_reinterpret_cast(WPARAM, hfont), bRedraw));
  96. }
  97. /* /////////////////////////////////////////////////////////////////////////
  98. * Namespace
  99. */
  100. #ifdef STLSOFT_DOCUMENTATION_SKIP_SECTION
  101. namespace winstl
  102. {
  103. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  104. /* /////////////////////////////////////////////////////////////////////////
  105. * C++ functions
  106. */
  107. #if defined(__cplusplus)
  108. /** \brief Gets the font associated with the window.
  109. *
  110. * \ingroup group__library__windows_window
  111. */
  112. inline HFONT get_window_font(HWND hwnd)
  113. {
  114. return winstl__get_window_font(hwnd);
  115. }
  116. /** \brief Sets the window's font.
  117. *
  118. * \ingroup group__library__windows_window
  119. */
  120. inline void set_window_font(HWND hwnd, HFONT hfont, ws_bool_t bRedraw = true)
  121. {
  122. winstl__set_window_font(hwnd, hfont, bRedraw);
  123. }
  124. #endif /* __cplusplus */
  125. /* ////////////////////////////////////////////////////////////////////// */
  126. #ifndef _WINSTL_NO_NAMESPACE
  127. # if defined(_STLSOFT_NO_NAMESPACE) || \
  128. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  129. } /* namespace winstl */
  130. # else
  131. } /* namespace winstl_project */
  132. } /* namespace stlsoft */
  133. # endif /* _STLSOFT_NO_NAMESPACE */
  134. #endif /* !_WINSTL_NO_NAMESPACE */
  135. /* ////////////////////////////////////////////////////////////////////// */
  136. #endif /* WINSTL_INCL_WINSTL_WINDOW_H_FONT_FUNCTIONS */
  137. /* ///////////////////////////// end of file //////////////////////////// */