sprint 1-alpha
|
00001 /****************************************************************************** 00002 * GTL: GUI Template Library 00003 * A Cross Platform C++ Wrapper for Win32 users 00004 * Copyright (C) 2007-2011 Paolo Medici (www.pmx.it) 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 * 00020 *******************************************************************************/ 00021 00022 #ifndef _SPRINT_BUTTON_H 00023 #define _SPRINT_BUTTON_H 00024 00029 #include <sprint/gtl/Window.h> 00030 00031 namespace sprint { 00032 namespace gtl { 00033 00035 class Button : public CWindow 00036 { 00037 public: 00038 // Constructors 00039 00045 Button(HWND hWnd = NULL) : CWindow(hWnd) 00046 { } 00047 00048 Button(CWindow hWnd) : CWindow(hWnd) 00049 { } 00050 00051 00052 static LPCTSTR GetWndClassName() 00053 { 00054 return _T("BUTTON"); 00055 } 00056 00057 UINT GetState() const 00058 { 00059 return (UINT)::SendMessage(m_hwnd, BM_GETSTATE, 0, 0L); 00060 } 00061 00062 void SetState(BOOL bHighlight) 00063 { 00064 ::SendMessage(m_hwnd, BM_SETSTATE, bHighlight, 0L); 00065 } 00066 00072 bool IsChecked() const 00073 { 00074 return (int)::SendMessage(m_hwnd, BM_GETCHECK, 0, 0L) == BST_CHECKED; 00075 } 00076 00078 void Check(bool bCheck) 00079 { 00080 ::SendMessage(m_hwnd, BM_SETCHECK, bCheck ? BST_CHECKED : BST_UNCHECKED, 0L); 00081 } 00082 00083 UINT GetButtonStyle() const 00084 { 00085 return (UINT)::GetWindowLong(m_hwnd, GWL_STYLE) & 0xFFFF; 00086 } 00087 00088 void SetButtonStyle(UINT nStyle, BOOL bRedraw = TRUE) 00089 { 00090 ::SendMessage(m_hwnd, BM_SETSTYLE, nStyle, (LPARAM)bRedraw); 00091 } 00092 00093 #ifndef _WIN32_WCE 00094 HICON GetIcon() const 00095 { 00096 return (HICON)::SendMessage(m_hwnd, BM_GETIMAGE, IMAGE_ICON, 0L); 00097 } 00098 00099 HICON SetIcon(HICON hIcon) 00100 { 00101 return (HICON)::SendMessage(m_hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); 00102 } 00103 00104 #endif // !_WIN32_WCE 00105 00106 #if (WINVER >= 0x0600) 00107 void SetDontClick(BOOL bDontClick) 00108 { 00109 ::SendMessage(m_hwnd, BM_SETDONTCLICK, (WPARAM)bDontClick, 0L); 00110 } 00111 #endif // (WINVER >= 0x0600) 00112 00113 // Operations 00114 void Click() 00115 { 00116 ::SendMessage(m_hwnd, BM_CLICK, 0, 0L); 00117 } 00118 00119 }; 00120 00121 } 00122 } 00123 00124 #endif