sprint 1-alpha
sprint/gtl/TabCtrl.hpp
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_TABCTRL_H
00023 #define _SPRINT_TABCTRL_H
00024 
00025 #include <commctrl.h>
00026 #include <sprint/gtl/Window.h>
00027 #include <sprint/gtl/detail/commctrl.h>
00028 
00029 // TODO: unirla con TabCtrl.h
00030 
00031 namespace sprint {
00032         namespace gtl {
00033           
00035 class TabCtrl : public CWindow
00036 {
00037 public:
00038 // Constructors
00039         TabCtrl(HWND hWnd = NULL)  : CWindow(hWnd)
00040         { }
00041 
00042         TabCtrl(CWindow hWnd)  : CWindow(hWnd)
00043         { }
00044 /*
00045         HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
00046                         DWORD dwStyle = 0, DWORD dwExStyle = 0,
00047                         ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
00048         {
00049                 return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
00050         }
00051 */
00052 // Attributes
00053         static LPCTSTR GetWndClassName()
00054         {
00055                 return WC_TABCONTROL;
00056         }
00057 
00058         HIMAGELIST GetImageList() const
00059         {
00060                 return ((HIMAGELIST)::SendMessage(m_hwnd, TCM_GETIMAGELIST, 0, 0L));
00061         }
00062 
00063         HIMAGELIST SetImageList(HIMAGELIST hImageList)
00064         {
00065                 return ((HIMAGELIST)::SendMessage(m_hwnd, TCM_SETIMAGELIST, 0, (LPARAM)hImageList));
00066         }
00067 
00068         int GetItemCount() const
00069         {
00070                 return (int)::SendMessage(m_hwnd, TCM_GETITEMCOUNT, 0, 0L);
00071         }
00072 
00073         BOOL GetItem(int nItem, LPTCITEM pTabCtrlItem) const
00074         {
00075                 return (BOOL)::SendMessage(m_hwnd, TCM_GETITEM, nItem, (LPARAM)pTabCtrlItem);
00076         }
00077 
00078         BOOL SetItem(int nItem, LPTCITEM pTabCtrlItem)
00079         {
00080                 return (BOOL)::SendMessage(m_hwnd, TCM_SETITEM, nItem, (LPARAM)pTabCtrlItem);
00081         }
00082 
00083         int SetItem(int nItem, UINT mask, LPCTSTR lpszItem, DWORD dwState, DWORD dwStateMask, int iImage, LPARAM lParam)
00084         {
00085                 TCITEM tci = { 0 };
00086                 tci.mask = mask;
00087                 tci.pszText = (LPTSTR) lpszItem;
00088                 tci.dwState = dwState;
00089                 tci.dwStateMask = dwStateMask;
00090                 tci.iImage = iImage;
00091                 tci.lParam = lParam;
00092                 return (int)::SendMessage(m_hwnd, TCM_SETITEM, nItem, (LPARAM)&tci);
00093         }
00094 
00095         BOOL GetItemRect(int nItem, LPRECT lpRect) const
00096         {
00097                 return (BOOL)::SendMessage(m_hwnd, TCM_GETITEMRECT, nItem, (LPARAM)lpRect);
00098         }
00099 
00100         int GetCurSel() const
00101         {
00102                 return (int)::SendMessage(m_hwnd, TCM_GETCURSEL, 0, 0L);
00103         }
00104 
00105         int SetCurSel(int nItem)
00106         {
00107                 return (int)::SendMessage(m_hwnd, TCM_SETCURSEL, nItem, 0L);
00108         }
00109 /*
00110         SIZE SetItemSize(SIZE size)
00111         {
00112                 DWORD dwSize = (DWORD)::SendMessage(m_hwnd, TCM_SETITEMSIZE, 0, MAKELPARAM(size.cx, size.cy));
00113                 SIZE sizeRet = { GET_X_LPARAM(dwSize), GET_Y_LPARAM(dwSize) };
00114                 return sizeRet;
00115         }
00116 */
00117         void SetItemSize(int cx, int cy)
00118         {
00119                 ::SendMessage(m_hwnd, TCM_SETITEMSIZE, 0, MAKELPARAM(cx, cy));
00120         }
00121 
00122         void SetPadding(SIZE size)
00123         {
00124                 ::SendMessage(m_hwnd, TCM_SETPADDING, 0, MAKELPARAM(size.cx, size.cy));
00125         }
00126 
00127         int GetRowCount() const
00128         {
00129                 return (int)::SendMessage(m_hwnd, TCM_GETROWCOUNT, 0, 0L);
00130         }
00131 
00132 #ifndef _WIN32_WCE
00133         HWND GetTooltips() const
00134         {
00135                 return ((HWND)::SendMessage(m_hwnd, TCM_GETTOOLTIPS, 0, 0L));
00136         }
00137 
00138         void SetTooltips(HWND hWndToolTip)
00139         {
00140                 ::SendMessage(m_hwnd, TCM_SETTOOLTIPS, (WPARAM)hWndToolTip, 0L);
00141         }
00142 #endif // !_WIN32_WCE
00143 
00144         int GetCurFocus() const
00145         {
00146                 return (int)::SendMessage(m_hwnd, TCM_GETCURFOCUS, 0, 0L);
00147         }
00148 
00149         void SetCurFocus(int nItem)
00150         {
00151                 ::SendMessage(m_hwnd, TCM_SETCURFOCUS, nItem, 0L);
00152         }
00153 
00154         BOOL SetItemExtra(int cbExtra)
00155         {
00156                 return (BOOL)::SendMessage(m_hwnd, TCM_SETITEMEXTRA, cbExtra, 0L);
00157         }
00158 
00159         int SetMinTabWidth(int nWidth = -1)
00160         {
00161                 return (int)::SendMessage(m_hwnd, TCM_SETMINTABWIDTH, 0, nWidth);
00162         }
00163 
00164 #if (_WIN32_IE >= 0x0400)
00165         DWORD GetExtendedStyle() const
00166         {
00167                 return (DWORD)::SendMessage(m_hwnd, TCM_GETEXTENDEDSTYLE, 0, 0L);
00168         }
00169 
00170         DWORD SetExtendedStyle(DWORD dwExMask, DWORD dwExStyle)
00171         {
00172                 return (DWORD)::SendMessage(m_hwnd, TCM_SETEXTENDEDSTYLE, dwExMask, dwExStyle);
00173         }
00174 
00175 #ifndef _WIN32_WCE
00176         BOOL GetUnicodeFormat() const
00177         {
00178                 return (BOOL)::SendMessage(m_hwnd, TCM_GETUNICODEFORMAT, 0, 0L);
00179         }
00180 
00181         BOOL SetUnicodeFormat(BOOL bUnicode = TRUE)
00182         {
00183                 return (BOOL)::SendMessage(m_hwnd, TCM_SETUNICODEFORMAT, bUnicode, 0L);
00184         }
00185 #endif // !_WIN32_WCE
00186 #endif // (_WIN32_IE >= 0x0400)
00187 
00188 // Operations
00189         int InsertItem(int nItem, LPTCITEM pTabCtrlItem)
00190         {
00191                 return (int)::SendMessage(m_hwnd, TCM_INSERTITEM, nItem, (LPARAM)pTabCtrlItem);
00192         }
00193 
00194         int InsertItem(int nItem, UINT mask, LPCTSTR lpszItem, int iImage, LPARAM lParam)
00195         {
00196                 TCITEM tci = { 0 };
00197                 tci.mask = mask;
00198                 tci.pszText = (LPTSTR) lpszItem;
00199                 tci.iImage = iImage;
00200                 tci.lParam = lParam;
00201                 return (int)::SendMessage(m_hwnd, TCM_INSERTITEM, nItem, (LPARAM)&tci);
00202         }
00203 
00204         int InsertItem(int nItem, LPCTSTR lpszItem)
00205         {
00206                 TCITEM tci = { 0 };
00207                 tci.mask = TCIF_TEXT;
00208                 tci.pszText = (LPTSTR) lpszItem;
00209                 return (int)::SendMessage(m_hwnd, TCM_INSERTITEM, nItem, (LPARAM)&tci);
00210         }
00211 
00212         int AddItem(LPTCITEM pTabCtrlItem)
00213         {
00214                 return InsertItem(GetItemCount(), pTabCtrlItem);
00215         }
00216 
00217         int AddItem(UINT mask, LPCTSTR lpszItem, int iImage, LPARAM lParam)
00218         {
00219                 return InsertItem(GetItemCount(), mask, lpszItem, iImage, lParam);
00220         }
00221 
00222         int AddItem(LPCTSTR lpszItem)
00223         {
00224                 return InsertItem(GetItemCount(), lpszItem);
00225         }
00226 
00227         BOOL DeleteItem(int nItem)
00228         {
00229                 return (BOOL)::SendMessage(m_hwnd, TCM_DELETEITEM, nItem, 0L);
00230         }
00231 
00232         BOOL DeleteAllItems()
00233         {
00234                 return (BOOL)::SendMessage(m_hwnd, TCM_DELETEALLITEMS, 0, 0L);
00235         }
00236 
00237         void AdjustRect(BOOL bLarger, LPRECT lpRect)
00238         {
00239                 ::SendMessage(m_hwnd, TCM_ADJUSTRECT, bLarger, (LPARAM)lpRect);
00240         }
00241 
00242         void RemoveImage(int nImage)
00243         {
00244                 ::SendMessage(m_hwnd, TCM_REMOVEIMAGE, nImage, 0L);
00245         }
00246 
00247         int HitTest(TC_HITTESTINFO* pHitTestInfo) const
00248         {
00249                 return (int)::SendMessage(m_hwnd, TCM_HITTEST, 0, (LPARAM)pHitTestInfo);
00250         }
00251 
00252         void DeselectAll(BOOL bExcludeFocus = TRUE)
00253         {
00254                 ::SendMessage(m_hwnd, TCM_DESELECTALL, bExcludeFocus, 0L);
00255         }
00256 
00257 #if (_WIN32_IE >= 0x0400)
00258         BOOL HighlightItem(int nIndex, BOOL bHighlight = TRUE)
00259         {
00260                 return (BOOL)::SendMessage(m_hwnd, TCM_HIGHLIGHTITEM, nIndex, MAKELPARAM(bHighlight, 0));
00261         }
00262 #endif // (_WIN32_IE >= 0x0400)
00263 };
00264 
00265 }
00266 }
00267 
00268 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines