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.

361 lines
12 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: winstl/controls/creation_functions.h
  3. *
  4. * Purpose: Control creation functions.
  5. *
  6. * Created: 7th May 2000
  7. * Updated: 10th August 2009
  8. *
  9. * Home: http://stlsoft.org/
  10. *
  11. * Copyright (c) 2000-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/controls/creation_functions.h
  40. *
  41. * \brief [C, C++] Control creation functions
  42. * (\ref group__library__windows_controls "Windows Controls" Library).
  43. */
  44. #ifndef WINSTL_INCL_WINSTL_CONTROL_H_CREATION_FUNCTIONS
  45. #define WINSTL_INCL_WINSTL_CONTROL_H_CREATION_FUNCTIONS
  46. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  47. # define WINSTL_VER_WINSTL_CONTROL_H_CREATION_FUNCTIONS_MAJOR 2
  48. # define WINSTL_VER_WINSTL_CONTROL_H_CREATION_FUNCTIONS_MINOR 0
  49. # define WINSTL_VER_WINSTL_CONTROL_H_CREATION_FUNCTIONS_REVISION 4
  50. # define WINSTL_VER_WINSTL_CONTROL_H_CREATION_FUNCTIONS_EDIT 22
  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. #ifdef __cplusplus
  59. # ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_STRING_H_FWD
  60. # include <stlsoft/shims/access/string/fwd.h>
  61. # endif /* !STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_STRING_H_FWD */
  62. #endif /* __cplusplus */
  63. #ifndef WINSTL_INCL_WINSTL_WINDOW_H_CREATION_FUNCTIONS
  64. # include <winstl/window/creation_functions.h>
  65. #endif /* !WINSTL_INCL_WINSTL_WINDOW_H_CREATION_FUNCTIONS */
  66. /* /////////////////////////////////////////////////////////////////////////
  67. * Namespace
  68. */
  69. #if !defined(_WINSTL_NO_NAMESPACE) && \
  70. !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  71. # if defined(_STLSOFT_NO_NAMESPACE)
  72. /* There is no stlsoft namespace, so must define ::winstl */
  73. namespace winstl
  74. {
  75. # else
  76. /* Define stlsoft::winstl_project */
  77. namespace stlsoft
  78. {
  79. namespace winstl_project
  80. {
  81. # endif /* _STLSOFT_NO_NAMESPACE */
  82. #endif /* !_WINSTL_NO_NAMESPACE */
  83. /* /////////////////////////////////////////////////////////////////////////
  84. * Functions
  85. */
  86. /** \brief
  87. *
  88. * \ingroup group__library__windows_controls
  89. */
  90. STLSOFT_INLINE void winstl__setchildfont_(HWND hwnd, HWND hwndParent)
  91. {
  92. STLSOFT_SUPPRESS_UNUSED(hwnd);
  93. STLSOFT_SUPPRESS_UNUSED(hwndParent);
  94. /* ::SendMessage(hwndParent, WM_SETFONT, ::SendMessage(hwnd, WM_GETFONT, 0, 0L), 1); */
  95. }
  96. /** \brief
  97. *
  98. * \ingroup group__library__windows_controls
  99. */
  100. STLSOFT_INLINE HWND winstl__CreateStaticA(HWND hwndParent, ws_char_a_t const* name, int x, int y, int cx, int cy, int id)
  101. {
  102. HWND hwnd = winstl__CreateWindowA("STATIC", name, WS_CHILD | WS_VISIBLE, x, y, cx, cy, hwndParent, stlsoft_reinterpret_cast(HMENU, id), NULL, NULL);
  103. winstl__setchildfont_(hwnd, hwndParent);
  104. return hwnd;
  105. }
  106. /** \brief
  107. *
  108. * \ingroup group__library__windows_controls
  109. */
  110. STLSOFT_INLINE HWND winstl__CreateStaticW(HWND hwndParent, ws_char_w_t const* name, int x, int y, int cx, int cy, int id)
  111. {
  112. HWND hwnd = winstl__CreateWindowW(L"STATIC", name, WS_CHILD | WS_VISIBLE, x, y, cx, cy, hwndParent, stlsoft_reinterpret_cast(HMENU, id), NULL, NULL);
  113. winstl__setchildfont_(hwnd, hwndParent);
  114. return hwnd;
  115. }
  116. /** \brief
  117. *
  118. * \ingroup group__library__windows_controls
  119. */
  120. STLSOFT_INLINE HWND winstl__CreateStaticFrame(HWND hwndParent, DWORD frameStyle, int x, int y, int cx, int cy, int id)
  121. {
  122. HWND hwnd;
  123. WINSTL_ASSERT(SS_BLACKFRAME == frameStyle || SS_GRAYFRAME == frameStyle || SS_WHITEFRAME == frameStyle || SS_ETCHEDFRAME == frameStyle);
  124. hwnd = winstl__CreateWindowA("STATIC", "", WS_CHILD | WS_VISIBLE | frameStyle, x, y, cx, cy, hwndParent, stlsoft_reinterpret_cast(HMENU, id), NULL, NULL);
  125. winstl__setchildfont_(hwnd, hwndParent);
  126. return hwnd;
  127. }
  128. /** \brief
  129. *
  130. * \ingroup group__library__windows_controls
  131. */
  132. STLSOFT_INLINE HWND winstl__CreateEditA(HWND hwndParent, ws_char_a_t const* text, DWORD editStyle, int x, int y, int cx, int cy, int id)
  133. {
  134. return winstl__CreateWindowA("EDIT", text, WS_CHILD | WS_VISIBLE | WS_TABSTOP | (0xFFFF & editStyle), x, y, cx, cy, hwndParent, stlsoft_reinterpret_cast(HMENU, id), NULL, NULL);
  135. }
  136. /** \brief
  137. *
  138. * \ingroup group__library__windows_controls
  139. */
  140. STLSOFT_INLINE HWND winstl__CreateEditW(HWND hwndParent, ws_char_w_t const* text, DWORD editStyle, int x, int y, int cx, int cy, int id)
  141. {
  142. return winstl__CreateWindowW(L"EDIT", text, WS_CHILD | WS_VISIBLE | WS_TABSTOP | (0xFFFF & editStyle), x, y, cx, cy, hwndParent, stlsoft_reinterpret_cast(HMENU, id), NULL, NULL);
  143. }
  144. /** \brief
  145. *
  146. * \ingroup group__library__windows_controls
  147. */
  148. STLSOFT_INLINE HWND winstl__CreateCheckboxA(HWND hwndParent, ws_char_a_t const* name, DWORD buttonStyle, int x, int y, int cx, int cy, int id)
  149. {
  150. return winstl__CreateWindowA("BUTTON", name, WS_CHILD | WS_VISIBLE | WS_TABSTOP | (0xFFFF & buttonStyle), x, y, cx, cy, hwndParent, stlsoft_reinterpret_cast(HMENU, id), NULL, NULL);
  151. }
  152. /** \brief
  153. *
  154. * \ingroup group__library__windows_controls
  155. */
  156. STLSOFT_INLINE HWND winstl__CreateCheckboxW(HWND hwndParent, ws_char_w_t const* name, DWORD buttonStyle, int x, int y, int cx, int cy, int id)
  157. {
  158. return winstl__CreateWindowW(L"BUTTON", name, WS_CHILD | WS_VISIBLE | WS_TABSTOP | (0xFFFF & buttonStyle), x, y, cx, cy, hwndParent, stlsoft_reinterpret_cast(HMENU, id), NULL, NULL);
  159. }
  160. /* /////////////////////////////////////////////////////////////////////////
  161. * Namespace
  162. */
  163. #ifdef STLSOFT_DOCUMENTATION_SKIP_SECTION
  164. namespace winstl
  165. {
  166. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  167. /* /////////////////////////////////////////////////////////////////////////
  168. * C++ functions
  169. */
  170. #ifdef __cplusplus
  171. /** \brief
  172. *
  173. * \ingroup group__library__windows_controls
  174. */
  175. inline HWND winstl__CreateStatic(HWND hwndParent, ws_char_a_t const* name, int x, int y, int cx, int cy, int id)
  176. {
  177. return winstl__CreateStaticA(hwndParent, name, x, y, cx, cy, id);
  178. }
  179. /** \brief
  180. *
  181. * \ingroup group__library__windows_controls
  182. */
  183. inline HWND winstl__CreateStatic(HWND hwndParent, ws_char_w_t const* name, int x, int y, int cx, int cy, int id)
  184. {
  185. return winstl__CreateStaticW(hwndParent, name, x, y, cx, cy, id);
  186. }
  187. /** \brief
  188. *
  189. * \ingroup group__library__windows_controls
  190. */
  191. inline HWND winstl__CreateEdit(HWND hwndParent, ws_char_a_t const* text, DWORD editStyle, int x, int y, int cx, int cy, int id)
  192. {
  193. return winstl__CreateEditA(hwndParent, text, editStyle, x, y, cx, cy, id);
  194. }
  195. /** \brief
  196. *
  197. * \ingroup group__library__windows_controls
  198. */
  199. inline HWND winstl__CreateEdit(HWND hwndParent, ws_char_w_t const* text, DWORD editStyle, int x, int y, int cx, int cy, int id)
  200. {
  201. return winstl__CreateEditW(hwndParent, text, editStyle, x, y, cx, cy, id);
  202. }
  203. /** \brief
  204. *
  205. * \ingroup group__library__windows_controls
  206. */
  207. inline HWND winstl__CreateCheckbox(HWND hwndParent, ws_char_a_t const* name, DWORD buttonStyle, int x, int y, int cx, int cy, int id)
  208. {
  209. return winstl__CreateCheckboxA(hwndParent, name, buttonStyle, x, y, cx, cy, id);
  210. }
  211. /** \brief
  212. *
  213. * \ingroup group__library__windows_controls
  214. */
  215. inline HWND winstl__CreateCheckbox(HWND hwndParent, ws_char_w_t const* name, DWORD buttonStyle, int x, int y, int cx, int cy, int id)
  216. {
  217. return winstl__CreateCheckboxW(hwndParent, name, buttonStyle, x, y, cx, cy, id);
  218. }
  219. /** \brief
  220. *
  221. * \ingroup group__library__windows_controls
  222. */
  223. template <ss_typename_param_k S>
  224. inline HWND CreateStatic(HWND hwndParent, S const& name, int x, int y, int cx, int cy, int id)
  225. {
  226. return winstl__CreateStatic(hwndParent, stlsoft_ns_qual(c_str_ptr)(name), x, y, cx, cy, id);
  227. }
  228. /** \brief
  229. *
  230. * \ingroup group__library__windows_controls
  231. */
  232. template <ss_typename_param_k S>
  233. inline HWND CreateStatic(HWND hwndParent, S const& name, RECT const& rc, int id)
  234. {
  235. return winstl__CreateStatic(hwndParent, stlsoft_ns_qual(c_str_ptr)(name), rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), id);
  236. }
  237. /** \brief
  238. *
  239. * \ingroup group__library__windows_controls
  240. */
  241. template <ss_typename_param_k S>
  242. inline HWND CreateEdit(HWND hwndParent, S const& text, DWORD editStyle, int x, int y, int cx, int cy, int id)
  243. {
  244. return winstl__CreateEdit(hwndParent, stlsoft_ns_qual(c_str_ptr)(text), editStyle, x, y, cx, cy, id);
  245. }
  246. /** \brief
  247. *
  248. * \ingroup group__library__windows_controls
  249. */
  250. template <ss_typename_param_k S>
  251. inline HWND CreateEdit(HWND hwndParent, S const& text, DWORD editStyle, RECT const& rc, int id)
  252. {
  253. return winstl__CreateEdit(hwndParent, stlsoft_ns_qual(c_str_ptr)(text), editStyle, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), id);
  254. }
  255. /** \brief
  256. *
  257. * \ingroup group__library__windows_controls
  258. */
  259. inline HWND CreateStaticFrame(HWND hwndParent, DWORD frameStyle, int x, int y, int cx, int cy, int id = -1)
  260. {
  261. return winstl__CreateStaticFrame(hwndParent, frameStyle, x, y, cx, cy, id);
  262. }
  263. /** \brief
  264. *
  265. * \ingroup group__library__windows_controls
  266. */
  267. inline HWND CreateStaticFrame(HWND hwndParent, DWORD frameStyle, RECT const& rc, int id = -1)
  268. {
  269. return CreateStaticFrame(hwndParent, frameStyle, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), id);
  270. }
  271. /** \brief
  272. *
  273. * \ingroup group__library__windows_controls
  274. */
  275. template <ss_typename_param_k S>
  276. inline HWND CreateCheckbox(HWND hwndParent, S const& name, DWORD buttonStyle, int x, int y, int cx, int cy, int id)
  277. {
  278. return winstl__CreateCheckbox(hwndParent, stlsoft_ns_qual(c_str_ptr)(name), buttonStyle, x, y, cx, cy, id);
  279. }
  280. /** \brief
  281. *
  282. * \ingroup group__library__windows_controls
  283. */
  284. template <ss_typename_param_k S>
  285. inline HWND CreateCheckbox(HWND hwndParent, S const& name, DWORD buttonStyle, RECT const& rc, int id)
  286. {
  287. return winstl__CreateCheckbox(hwndParent, stlsoft_ns_qual(c_str_ptr)(name), buttonStyle, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), id);
  288. }
  289. #endif /* __cplusplus */
  290. /* ////////////////////////////////////////////////////////////////////// */
  291. #ifndef _WINSTL_NO_NAMESPACE
  292. # if defined(_STLSOFT_NO_NAMESPACE) || \
  293. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  294. } /* namespace winstl */
  295. # else
  296. } /* namespace winstl_project */
  297. } /* namespace stlsoft */
  298. # endif /* _STLSOFT_NO_NAMESPACE */
  299. #endif /* !_WINSTL_NO_NAMESPACE */
  300. /* ////////////////////////////////////////////////////////////////////// */
  301. #endif /* WINSTL_INCL_WINSTL_CONTROL_H_CREATION_FUNCTIONS */
  302. /* ///////////////////////////// end of file //////////////////////////// */