-
大小: 8KB文件类型: .zip金币: 1下载: 0 次发布日期: 2021-06-01
- 语言: 其他
- 标签:
资源简介
wxCheckedListCtrl类
.h/.cpp
带checkbox 的wxListCtrl,从wxListCtrl继承来,声明了
wxEVT_COMMAND_LIST_ITEM_CHECKED / wxEVT_COMMAND_LIST_ITEM_UNCHECKED
选种和取消勾选事件,事件手柄类型为 wxListEvent& event.
经过测试,可以使用。
代码片段和文件信息
/////////////////////////////////////////////////////////////////////////////
// Name: checkedlistctrl.cpp
// Purpose: wxCheckedListCtrl
// Author: Uknown ? (found at http://wiki.wxwidgets.org/wiki.pl?WxListCtrl)
// Modified by: Francesco Montorsi
// Created: 2005/06/29
// RCS-ID: $Id: checkedlistctrl.cppv 1.15 2005/10/20 16:06:01 frm Exp $
// Copyright: (c) 2005 Francesco Montorsi
// Licence: wxWidgets licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation includes “wx.h“.
#include “wx/wxprec.h“
#ifdef __BORLANDC__
#pragma hdrstop
#endif
// includes
#include “checkedlistctrl.h“
#include
#if wxUSE_CHECKEDLISTCTRL
// resources
#include “./images/checked.xpm“
#include “./images/unchecked.xpm“
#include “./images/checked_dis.xpm“
#include “./images/unchecked_dis.xpm“
IMPLEMENT_CLASS(wxCheckedListCtrl wxListCtrl)
BEGIN_EVENT_TABLE(wxCheckedListCtrl wxListCtrl)
EVT_LEFT_DOWN(wxCheckedListCtrl::OnMouseEvent)
END_EVENT_TABLE()
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_CHECKED);
DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_UNCHECKED);
// ------------------
// wxCHECKEDLISTCTRL
// ------------------
bool wxCheckedListCtrl::Create(wxWindow* parent wxWindowID id const wxPoint& pt
const wxSize& sz long style const wxValidator& validator const wxString& name)
{
if (!wxListCtrl::Create(parent id pt sz style validator name))
return FALSE;
SetImageList(&m_imageList wxIMAGE_LIST_SMALL);
// the add order must respect the wxCLC_XXX_IMGIDX defines in the headers !
m_imageList.Add(wxIcon(unchecked_xpm));
m_imageList.Add(wxIcon(checked_xpm));
m_imageList.Add(wxIcon(unchecked_dis_xpm));
m_imageList.Add(wxIcon(checked_dis_xpm));
return TRUE;
}
/* static */
int wxCheckedListCtrl::GetItemImageFromAdditionalState(int addstate)
{
bool checked = (addstate & wxLIST_STATE_CHECKED) != 0;
bool enabled = (addstate & wxLIST_STATE_ENABLED) != 0;
if (checked && enabled)
return wxCLC_CHECKED_IMGIDX;
else if (checked && !enabled)
return wxCLC_DISABLED_CHECKED_IMGIDX;
else if (!checked && enabled)
return wxCLC_UNCHECKED_IMGIDX;
wxASSERT(!checked && !enabled); // this is the last possibility
return wxCLC_DISABLED_UNCHECKED_IMGIDX;
}
wxColour wxCheckedListCtrl::GetBgColourFromAdditionalState(int additionalstate)
{
if ((additionalstate & wxLIST_STATE_ENABLED) &&
this->IsEnabled())
return *wxWHITE;
#ifdef __WXMSW__
return wxColour(212 208 200);
#else
return wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
#endif
}
/* static */
int wxCheckedListCtrl::GetAndRemoveAdditionalState(long *state int statemask)
{
int additionalstate = 0;
if (!state) return -1;
// extract the bits we are interested in
bool checked = (*state & wxLIST_STATE_CHECKED) != 0;
bool enabled = (*state & wxLIST_STATE_ENABLED) != 0;
// and set them in a different variable if they are included in the st
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-07-30 14:10 wxCheckedListCtrl\
文件 445 2005-08-22 06:04 wxCheckedListCtrl\checked.xpm
文件 11916 2014-07-30 13:18 wxCheckedListCtrl\checkedlistctrl.cpp
文件 5925 2014-07-29 17:58 wxCheckedListCtrl\checkedlistctrl.h
文件 435 2005-06-30 18:20 wxCheckedListCtrl\checked_dis.xpm
文件 226 2014-07-30 14:13 wxCheckedListCtrl\readme.txt
文件 447 2005-08-22 06:04 wxCheckedListCtrl\unchecked.xpm
文件 437 2005-06-30 18:20 wxCheckedListCtrl\unchecked_dis.xpm
- 上一篇:车辆vin校验码生成器.xls
- 下一篇:投影转换工具—Albers等面积.
评论
共有 条评论