00001 /* ///////////////////////////////////////////////////////////////////////// 00002 * File: winstl/controls/dialog_functionals.hpp 00003 * 00004 * Purpose: Functionals for application to controls. 00005 * 00006 * Created: 2nd August 2006 00007 * Updated: 10th August 2009 00008 * 00009 * Home: http://stlsoft.org/ 00010 * 00011 * Copyright (c) 2002-2009, Matthew Wilson and Synesis Software 00012 * All rights reserved. 00013 * 00014 * Redistribution and use in source and binary forms, with or without 00015 * modification, are permitted provided that the following conditions are met: 00016 * 00017 * - Redistributions of source code must retain the above copyright notice, this 00018 * list of conditions and the following disclaimer. 00019 * - Redistributions in binary form must reproduce the above copyright notice, 00020 * this list of conditions and the following disclaimer in the documentation 00021 * and/or other materials provided with the distribution. 00022 * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of 00023 * any contributors may be used to endorse or promote products derived from 00024 * this software without specific prior written permission. 00025 * 00026 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00027 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00028 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00029 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00030 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00031 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00032 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00033 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00034 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00035 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00036 * POSSIBILITY OF SUCH DAMAGE. 00037 * 00038 * ////////////////////////////////////////////////////////////////////// */ 00039 00040 00047 #ifndef WINSTL_INCL_WINSTL_CONTROL_HPP_DIALOG_FUNCTIONALS 00048 #define WINSTL_INCL_WINSTL_CONTROL_HPP_DIALOG_FUNCTIONALS 00049 00050 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION 00051 # define WINSTL_VER_WINSTL_CONTROL_HPP_DIALOG_FUNCTIONALS_MAJOR 1 00052 # define WINSTL_VER_WINSTL_CONTROL_HPP_DIALOG_FUNCTIONALS_MINOR 0 00053 # define WINSTL_VER_WINSTL_CONTROL_HPP_DIALOG_FUNCTIONALS_REVISION 2 00054 # define WINSTL_VER_WINSTL_CONTROL_HPP_DIALOG_FUNCTIONALS_EDIT 8 00055 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ 00056 00057 /* ///////////////////////////////////////////////////////////////////////// 00058 * Compatibility 00059 */ 00060 00061 /* 00062 [Incompatibilies-start] 00063 STLSOFT_COMPILER_IS_GCC: __GNUC__<3 00064 STLSOFT_COMPILER_IS_MSVC: _MSC_VER<1100 00065 [Incompatibilies-end] 00066 */ 00067 00068 /* ///////////////////////////////////////////////////////////////////////// 00069 * Includes 00070 */ 00071 00072 #ifndef WINSTL_INCL_WINSTL_H_WINSTL 00073 # include <winstl/winstl.h> 00074 #endif /* !WINSTL_INCL_WINSTL_H_WINSTL */ 00075 00076 #if defined(STLSOFT_COMPILER_IS_GCC) && \ 00077 __GNUC__ < 3 00078 # error winstl/controls/dialog_functionals.hpp is not compatible with GNU C++ prior to 3.0 00079 #endif /* compiler */ 00080 #if defined(STLSOFT_COMPILER_IS_MSVC) && \ 00081 _MSC_VER < 1100 00082 # error winstl/controls/dialog_functionals.hpp is not compatible with Visual C++ 4.2 or earlier 00083 #endif /* compiler */ 00084 00085 #ifndef WINSTL_INCL_SHIMS_ATTRIBUTE_HPP_GET_HWND 00086 # include <winstl/shims/attribute/get_HWND.hpp> 00087 #endif /* !WINSTL_INCL_SHIMS_ATTRIBUTE_HPP_GET_HWND */ 00088 #ifndef _WINSTL_CONTROL_FUNCTIONALS_NO_STD 00089 # include <functional> 00090 #else /* ? _WINSTL_CONTROL_FUNCTIONALS_NO_STD */ 00091 # error Now need to write that std_binary_function stuff!! 00092 #endif /* _WINSTL_CONTROL_FUNCTIONALS_NO_STD */ 00093 00094 /* ///////////////////////////////////////////////////////////////////////// 00095 * Namespace 00096 */ 00097 00098 #ifndef _WINSTL_NO_NAMESPACE 00099 # if defined(_STLSOFT_NO_NAMESPACE) || \ 00100 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) 00101 /* There is no stlsoft namespace, so must define ::winstl */ 00102 namespace winstl 00103 { 00104 # else 00105 /* Define stlsoft::winstl_project */ 00106 00107 namespace stlsoft 00108 { 00109 00110 namespace winstl_project 00111 { 00112 00113 # endif /* _STLSOFT_NO_NAMESPACE */ 00114 #endif /* !_WINSTL_NO_NAMESPACE */ 00115 00116 /* ///////////////////////////////////////////////////////////////////////// 00117 * Classes 00118 */ 00119 00124 // [[synesis:class:unary-functor: dialog_button_id_check]] 00125 class dialog_button_id_check 00126 : public stlsoft_ns_qual_std(unary_function)<HWND, void> 00127 { 00128 public: 00130 typedef dialog_button_id_check class_type; 00131 public: 00132 ss_explicit_k dialog_button_id_check(HWND hwndDlg, UINT nCheck = BST_CHECKED) 00133 : m_hwndDlg(hwndDlg) 00134 , m_nCheck(nCheck) 00135 {} 00136 dialog_button_id_check(dialog_button_id_check const& rhs) 00137 : m_hwndDlg(rhs.m_hwndDlg) 00138 , m_nCheck(rhs.m_nCheck) 00139 {} 00140 00141 public: 00142 void operator ()(int id) const 00143 { 00144 check_(id, m_nCheck); 00145 } 00146 private: 00147 void check_(int id, UINT nCheck) const 00148 { 00149 ::CheckDlgButton(m_hwndDlg, id, nCheck); 00150 } 00151 00152 private: 00153 HWND m_hwndDlg; 00154 const UINT m_nCheck; 00155 00156 private: 00157 class_type& operator =(class_type const&); 00158 }; 00159 00160 00162 // Unit-testing 00163 00164 #ifdef STLSOFT_UNITTEST 00165 # include "./unittest/dialog_functionals_unittest_.h" 00166 #endif /* STLSOFT_UNITTEST */ 00167 00168 /* ////////////////////////////////////////////////////////////////////// */ 00169 00170 #ifndef _WINSTL_NO_NAMESPACE 00171 # if defined(_STLSOFT_NO_NAMESPACE) || \ 00172 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) 00173 } // namespace winstl 00174 # else 00175 } // namespace winstl_project 00176 } // namespace stlsoft 00177 # endif /* _STLSOFT_NO_NAMESPACE */ 00178 #endif /* !_WINSTL_NO_NAMESPACE */ 00179 00180 /* ////////////////////////////////////////////////////////////////////// */ 00181 00182 #endif /* WINSTL_INCL_WINSTL_CONTROL_HPP_DIALOG_FUNCTIONALS */ 00183 00184 /* ///////////////////////////// end of file //////////////////////////// */