LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: nightsuns

wxFlashget向外发布第一个版本

[复制链接]
发表于 2007-10-6 00:06:20 | 显示全部楼层
支持一下楼主,开源不开源无所谓,有得用就行了.不过老崩溃就不好了,
楼主看看可否静态编译.不过c++的动态库兼容性的问题可能会比较多.
c库这边可以使用动态库,接口都比较稳定了.

不过说实话,如果版权没问题的话,迅雷出linux版本应该能消灭其他大多的图形下载工具了.
速度做的不错,稳定性比以前也好了不少.而且资源聚合做的还算比较好,

楼主要加油
回复 支持 反对

使用道具 举报

发表于 2007-10-6 11:01:44 | 显示全部楼层
试了一下,可以在amd64上运行,界面比我想像中漂亮。

不过,不是诋毁楼主,实在是对闭源软件有很大的不信任,尤其是当多个大公司都在利用闭源软件来收集用户信息的时候。
回复 支持 反对

使用道具 举报

发表于 2007-10-6 21:17:29 | 显示全部楼层
从头看到尾,只想给搂主一个建议,闭源软件别把linux用户当回事,总结一下:

1、他们不信任你,
2、他们太高端太挑剔,
3、他们没有广告价值,
4、他们人口稀少,
5、他们只喜欢开源,虽然你开了源也没有人会看你的代码,
6、......

我开发multiget只是做练习,开发奔流兼容linux只是爱好,目前别把linux用户当回事,兼容众多的发行版只会分散注意力,只兼容一个就好了,比如ubuntu,其他版本都没几个人用,何必在意,编译也是费时间的事,闭源的话重点放在windows上吧。


还有,要么就开源要么就闭源,不要做中间派。现在闭可以,将来开欢迎,但你的半开半闭谁敢参与?做好了你一关,没别人什么事了。bitcomet就是先开后闭的典型,先闭后开的也有,但没有开源的应该都算闭源。楼主加油。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-10-6 23:59:49 | 显示全部楼层
Post by sysnotdown
从头看到尾,只想给搂主一个建议,闭源软件别把linux用户当回事,总结一下:

1、他们不信任你,
2、他们太高端太挑剔,
3、他们没有广告价值,
4、他们人口稀少,
5、他们只喜欢开源,虽然你开了源也没有人会看你的代码,
6、......

我开发multiget只是做练习,开发奔流兼容linux只是爱好,目前别把linux用户当回事,兼容众多的发行版只会分散注意力,只兼容一个就好了,比如ubuntu,其他版本都没几个人用,何必在意,编译也是费时间的事,闭源的话重点放在windows上吧。


还有,要么就开源要么就闭源,不要做中间派。现在闭可以,将来开欢迎,但你的半开半闭谁敢参与?做好了你一关,没别人什么事了。bitcomet就是先开后闭的典型,先闭后开的也有,但没有开源的应该都算闭源。楼主加油。



其实我很少和这个社群的人有沟通,这算是第一次吧。

还有jack在写wxFlashget的时候,我记得界面也有参看你的 multiget,上面的块图的图标还是用你的。

我们也正在走向开源,只是要一个过程,因为原来的代码很乱,现在还在整理之中,sourceforge上的项目已经申请好了。相信jack经过整理之后就会放上去。

http://sourceforge.net/projects/wxFlashget

还有你也加油,你的奔流我一直都在关注。
回复 支持 反对

使用道具 举报

发表于 2007-10-7 10:31:59 | 显示全部楼层
抽空试了一下windows版,有些BUG。

打开文件经常跳错误窗口,windows下窗口的嵌套看的清清楚楚,不好看。

http方面,linuxfans的下载跳转有问题,我就试了这个站,你注意一下。

BT方面,热门种子下载速度还可以,冷门点的不行,不知道你用的什么BT核心?自己写的?

BT下载占CPU太高了,见贴图。

BT的配置我没看见哪里有,监听口怎么设置,有没有UPNP支持,DHT有没有等等,界面没有显示。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

发表于 2007-10-7 10:36:39 | 显示全部楼层
请教一下:

这个控件你是怎么实现的?wxwidgets里好象自己没有?

如果自己实现的,能否发给我这部分的实现代码?呵呵,我只参考方法。或者你说下方法也行,或许我可以帮你点别的做交换。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

发表于 2007-10-7 11:51:45 | 显示全部楼层
这个名字取得,wxFlashget,如果你不是flashget公司的,可能会出问题。
gaim不就是因为这个改名的。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-10-7 14:26:54 | 显示全部楼层
Post by sysnotdown

http方面,linuxfans的下载跳转有问题,我就试了这个站,你注意一下。

谢谢,我去看看。
已修正了,下一个发布版本就会好了。
Post by sysnotdown

BT方面,热门种子下载速度还可以,冷门点的不行,不知道你用的什么BT核心?自己写的?

这个核心是全部自己写的,BT现在主要就是协议出来,算法还有待改进。
Post by sysnotdown

BT下载占CPU太高了,见贴图。

这个我早就发现了,原因是传输点一多的时候,UI的定时器里面在刷新传输点的状态,而没有显示出来的传输点也在刷,所以随着 peer 越多就越慢,jack有时间会改的。
Post by sysnotdown

BT的配置我没看见哪里有,监听口怎么设置,有没有UPNP支持,DHT有没有等等,界面没有显示。

BT的配置其实是有的,但在界面上没有,需要手动改下配置文件:
windows的是在: c:\XPPEnv\XPPMainConfig.xml
linux的是在: ~/XPPEnv/XPPMainConfig.xml

UPNP,DHT现在都没有实现。
这也是冷门不快的原因,你也知道现在的客户端都是优先公网的用户进行传输,在内网的只有象BC这些客户端是靠自己同类的客户端才能提速。
回复 支持 反对

使用道具 举报

发表于 2007-10-7 14:34:20 | 显示全部楼层
由于目前工作比较忙,所以更新的有点慢,希望大家能理解,这个项目现在正在开源,如果不是因为以前代码比较乱,我也许早都全部公开了,现在我正在利用业余时间正在整理这个项目,希望大家能理解!

sysnotdown你问的这个控件的代码我给你帖出来,如果有问题可以QQ:38604623联系我

checkedlistctrl.h

#ifndef _WX_CHECKEDLISTCTRL_H_
#define _WX_CHECKEDLISTCTRL_H_

// wxWidgets headers
//#include "wx/webupdatedef.h"                // for the WXDLLIMPEXP_WEBUPDATE macro
#include <wx/listctrl.h>
#include <wx/imaglist.h>

// image indexes (used internally by wxCheckedListCtrl)
#define wxCLC_UNCHECKED_IMGIDX                                0                // unchecked & enabled
#define wxCLC_CHECKED_IMGIDX                                1                // checked & enabled
#define wxCLC_DISABLED_UNCHECKED_IMGIDX                2                // unchecked & disabled
#define wxCLC_DISABLED_CHECKED_IMGIDX                3                // checked & disabled

// additional state flags (wx's defines should end at 0x0100; see listbase.h)
#define wxLIST_STATE_CHECKED                                0x010000
#define wxLIST_STATE_ENABLED                                0x100000

// additional wxCheckedListCtrl style flags
// (wx's defines should at 0x8000; see listbase.h)
#define wxCLC_CHECK_WHEN_SELECTING                        0x10000


//! This is the class which performs all transactions with the server.
//! It uses the wxSocket facilities.
class wxCheckedListCtrl : public wxListCtrl
{
protected:

        // we have to keep a different array to keep track of the additional
        // states we support....
        wxArrayInt m_stateList;

        // our set of checkbox images...
        wxImageList m_imageList;

public:
        wxCheckedListCtrl()
                : wxListCtrl(), m_imageList(16, 16, TRUE) {}

        wxCheckedListCtrl(wxWindow *parent, wxWindowID id = -1,
                const wxPoint& pt = wxDefaultPosition,
                const wxSize& sz = wxDefaultSize,
                long style = wxCLC_CHECK_WHEN_SELECTING,
                const wxValidator& validator = wxDefaultValidator,
                const wxString& name = wxListCtrlNameStr)
                : wxListCtrl(), m_imageList(16, 16, TRUE)
        { Create(parent, id, pt, sz, style, validator, name); }

        bool Create(wxWindow *parent, wxWindowID id = -1,
                const wxPoint& pt = wxDefaultPosition,
                const wxSize& sz = wxDefaultSize,
                long style = wxCLC_CHECK_WHEN_SELECTING,
                const wxValidator& validator = wxDefaultValidator,
                const wxString& name = wxListCtrlNameStr);

        virtual ~wxCheckedListCtrl() {}


public:                        // utilities

        // core overloads (i.e. the most generic overloads)
        bool GetItem(wxListItem& info) const;
        bool SetItem(wxListItem& info);
        long InsertItem(wxListItem& info);
        bool DeleteItem(long item);       
        bool DeleteAllItems()
        { m_stateList.Clear(); return wxListCtrl:eleteAllItems(); }

        bool SortItems(wxListCtrlCompare, long)
        { wxASSERT_MSG(0, wxT("Not implemented yet ! sorry... ")); return FALSE; }

        // shortcuts to the SetItemState function
        void Check(long item, bool checked);
        void Enable(long item, bool enable);
        void CheckAll(bool checked = true);
        void EnableAll(bool enable = true);

        // this needs to be redeclared otherwise it's hidden by our other Enable() function.
        // However you should use #EnableAll instead of this function if you want to get
        // good graphics (try to understand)
        virtual bool Enable(bool enable = true)
        { return wxListCtrl::Enable(enable); }

        // shortcuts to the GetItemState function
        bool IsChecked(long item) const
        { return GetItemState(item, wxLIST_STATE_CHECKED) != 0; }
        bool IsEnabled(long item) const
        { return GetItemState(item, wxLIST_STATE_ENABLED) != 0; }

        // this needs to be redeclared otherwise it's hidden by our other IsEnabled() function.
        bool IsEnabled() const
        { return wxWindow::IsEnabled(); }

        //! Returns the number of checked items in the control.
        int GetCheckedItemCount() const;

        // we overload these so we are sure they will use our
        // #GetItem and #SetItem functions...
        bool SetItemState(long item, long state, long stateMask);
        int GetItemState(long item, long stateMask) const;
        long InsertItem( long index, const wxString& label, int imageIndex = -1);
        long SetItem(long index, int col, const wxString& label, int imageId = -1);

        // the image associated with an element is already in used by wxCheckedListCtrl
        // itself to show the checkbox and it cannot be handled by the user !
        bool SetItemImage(long, int)
        { wxASSERT_MSG(0, wxT("This function cannot be used with wxCheckedListCtrl !")); return FALSE; }

protected:                // event handlers

        void OnMouseEvent(wxMouseEvent& event);

protected:                // internal utilities

        static int GetItemImageFromAdditionalState(int addstate);
        static int GetAndRemoveAdditionalState(long *state, int statemask);
        wxColour GetBgColourFromAdditionalState(int additionalstate);

private:
        DECLARE_CLASS(wxCheckedListCtrl)
        DECLARE_EVENT_TABLE()
};

// -------------------------
// wxCheckedListCtrl events
// -------------------------

BEGIN_DECLARE_EVENT_TYPES()       
        DECLARE_LOCAL_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_CHECKED, -1)
        DECLARE_LOCAL_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_UNCHECKED, -1)
END_DECLARE_EVENT_TYPES()

//DECLARE_EXPORTED_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_CHECKED, -1);
//DECLARE_EXPORTED_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_UNCHECKED, -1);

#define EVT_LIST_ITEM_CHECKED(id, fn) \
    DECLARE_EVENT_TABLE_ENTRY( \
        wxEVT_COMMAND_LIST_ITEM_CHECKED, id, -1, \
        (wxObjectEventFunction)(wxEventFunction)(wxListEventFunction)&fn, \
        (wxObject *) NULL \
    ),

#define EVT_LIST_ITEM_UNCHECKED(id, fn) \
    DECLARE_EVENT_TABLE_ENTRY( \
        wxEVT_COMMAND_LIST_ITEM_UNCHECKED, id, -1, \
        (wxObjectEventFunction)(wxEventFunction)(wxListEventFunction)&fn, \
        (wxObject *) NULL \
    ),


#endif        // _WX_CHECKEDLISTCTRL_H_
回复 支持 反对

使用道具 举报

发表于 2007-10-7 14:35:28 | 显示全部楼层
checkedlistctrl.cpp

#include "XPP/XPP.h"

// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

// includes
#include "wx/checkedlistctrl.h"
#include <wx/icon.h>


// resources
#include "wx/checked.xpm"
#include "wx/unchecked.xpm"
#include "wx/checked_dis.xpm"
#include "wx/unchecked_dis.xpm"
#include "wx/settings.h"

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 statemask
        if (checked && (statemask & wxLIST_STATE_CHECKED)) additionalstate |= wxLIST_STATE_CHECKED;
        if (enabled && (statemask & wxLIST_STATE_ENABLED)) additionalstate |= wxLIST_STATE_ENABLED;

        // remove them from the original state var...
        *state &= ~wxLIST_STATE_CHECKED;
        *state &= ~wxLIST_STATE_ENABLED;
        return additionalstate;
}

bool wxCheckedListCtrl::GetItem(wxListItem& info) const
{
        // wx internal wxListCtrl::GetItem remove from the state mask the
        // wxLIST_STATE_CHECKED & wxLIST_STATE_ENABLED bits since they
        // are not part of wx standard flags... so we need to check those
        // flags against the original wxListItem's statemask...
        wxListItem original(info);

#ifdef __WXDEBUG__
        // we always want to retrieve also the image state for checking purposes...
        info.m_mask |= wxLIST_MASK_IMAGE;
#endif

        if (!wxListCtrl::GetItem(info))       
                return FALSE;

        // these are our additional supported states: read them from m_stateList
        bool checked = (m_stateList[info.m_itemId] & wxLIST_STATE_CHECKED) != 0;
        bool enabled = (m_stateList[info.m_itemId] & wxLIST_STATE_ENABLED) != 0;

        // now intercept state requests about enable or check mode
        if ((original.m_mask & wxLIST_MASK_STATE) &&
                (original.m_stateMask & wxLIST_STATE_CHECKED)) {
                info.m_state |= (m_stateList[info.m_itemId] & wxLIST_STATE_CHECKED);
                info.m_stateMask |= wxLIST_STATE_CHECKED;
                info.m_mask |= wxLIST_MASK_STATE;                // contains valid info !
        }
        if ((original.m_mask & wxLIST_MASK_STATE) &&
                (original.m_stateMask & wxLIST_STATE_ENABLED)) {
                info.m_state |= (m_stateList[info.m_itemId] & wxLIST_STATE_ENABLED);
                info.m_stateMask |= wxLIST_STATE_ENABLED;
                info.m_mask |= wxLIST_MASK_STATE;                // contains valid info !
        }

        // check that state & image are synch
#ifdef __WXDEBUG__

        wxASSERT_MSG((int)m_stateList.GetCount() == (int)GetItemCount(),
                                        wxT("Something wrong ! See InsertItem()"));

        // read info by image index
        bool imagecheck = (info.m_image == wxCLC_CHECKED_IMGIDX) ||
                                                (info.m_image == wxCLC_DISABLED_CHECKED_IMGIDX);
        bool imageenabled = (info.m_image == wxCLC_CHECKED_IMGIDX) ||
                                                (info.m_image == wxCLC_UNCHECKED_IMGIDX);
        wxASSERT_MSG((checked && imagecheck) || (!checked && !imagecheck),
                wxT("This is item has checked state but it's shown as unchecked (or viceversa)"));
        wxASSERT_MSG((enabled && imageenabled) || (!enabled && !imageenabled),
                wxT("This is item has enabled state but it's shown as disabled (or viceversa)"));
#endif

        return TRUE;
}

bool wxCheckedListCtrl::SetItem(wxListItem& info)
{
        // remove the checked & enabled states from the state flag:
        // we'll store them in our separate array
        int additionalstate = GetAndRemoveAdditionalState(&info.m_state, info.m_stateMask);

        // set image index       
        // we will ignore the info.m_image field since we need
        // to overwrite it...
        if (info.m_mask & wxLIST_MASK_STATE) {

                // if some state is not included in the state mask, then get the state info
                // from our internal state array
                if (!(info.m_stateMask & wxLIST_STATE_ENABLED))
                        additionalstate |= (m_stateList[info.m_itemId] & wxLIST_STATE_ENABLED);
                if (!(info.m_stateMask & wxLIST_STATE_CHECKED))
                        additionalstate |= (m_stateList[info.m_itemId] & wxLIST_STATE_CHECKED);

                // state is valid: use it to determine the image to set...
                info.m_mask |= wxLIST_MASK_IMAGE;
                info.m_image = GetItemImageFromAdditionalState(additionalstate);

                // since when changing the background color, also the foreground color
                // and the font of the item are changed, we try to respect the user
                // choices of such attributes
                info.SetTextColour(this->GetItemTextColour(info.GetId()));
#if wxCHECK_VERSION(2, 6, 2)
                // before wx 2.6.2 the wxListCtrl::SetItemFont function is missing
                info.SetFont(this->GetItemFont(info.GetId()));
#endif
               
                // change the background color to respect the enabled/disabled status...
                info.SetBackgroundColour(GetBgColourFromAdditionalState(additionalstate));

                m_stateList[info.m_itemId] = additionalstate;

        } else {

                // state is invalid; don't change image
                info.m_mask &= ~wxLIST_MASK_IMAGE;
        }

        // save the changes
        return wxListCtrl::SetItem(info);
}

long wxCheckedListCtrl::InsertItem(wxListItem &info)
{
        int additionalstate = GetAndRemoveAdditionalState(&info.m_state, info.m_stateMask);
        if (!(info.m_mask & wxLIST_MASK_STATE) ||
                !(info.m_stateMask & wxLIST_STATE_ENABLED)) {

                // if not specified, the default additional state is ENABLED
                additionalstate = wxLIST_STATE_ENABLED;
        }

        // we always want to insert items with images...
        info.m_mask |= wxLIST_MASK_IMAGE;
        info.m_image = GetItemImageFromAdditionalState(additionalstate);
        info.SetBackgroundColour(GetBgColourFromAdditionalState(additionalstate));

        int itemcount = GetItemCount();
        wxASSERT_MSG(info.m_itemId <= itemcount, wxT("Invalid index !"));
        wxASSERT_MSG((int)m_stateList.GetCount() == (int)GetItemCount(),
                                        wxT("Something wrong !"));
        if (info.m_itemId == itemcount) {

                // we are adding a new item at the end of the list
                m_stateList.Add(additionalstate);

        } else {

                // we must shift all following items
                for (int i=itemcount; i > info.m_itemId; i++)
                        m_stateList = m_stateList[i-1];
                m_stateList[info.m_itemId] = additionalstate;
        }
       
        return wxListCtrl::InsertItem(info);
}

bool wxCheckedListCtrl::SetItemState(long item, long state, long stateMask)
{
        wxListItem li;
        li.SetId(item);
        li.SetMask(wxLIST_MASK_STATE);
        li.SetState(state);
        li.SetStateMask(stateMask);

        // so we are sure to use wxCheckedListCtrl::SetItem
        // (and not wxListCtrl::SetItem)
        return SetItem(li);
}

int wxCheckedListCtrl::GetItemState(long item, long stateMask) const
{
        wxListItem li;
        li.SetId(item);
        li.SetMask(wxLIST_MASK_STATE);
        li.SetStateMask(stateMask);
       
        // so we are sure to use wxCheckedListCtrl::GetItem
        // (and not wxListCtrl::GetItem)
        if (!GetItem(li))
                return -1;
        return li.GetState();
}

long wxCheckedListCtrl::SetItem(long index, int col, const wxString& label, int WXUNUSED(imageId))
{
        wxListItem li;
        li.SetId(index);
        li.SetColumn(col);       
        li.SetText(label);
        li.SetMask(wxLIST_MASK_TEXT);
       
        // so we are sure to use wxCheckedListCtrl::SetItem
        // (and not wxListCtrl::SetItem)
        return SetItem(li);
}

long wxCheckedListCtrl::InsertItem( long index, const wxString& label, int WXUNUSED(imageIndex) )
{
    wxListItem info;
    info.m_text = label;
    info.m_mask = wxLIST_MASK_TEXT;
    info.m_itemId = index;
    return InsertItem(info);
}

void wxCheckedListCtrl::Check(long item, bool checked)
{
        // NB: the "statemask" is not the "mask" of a list item;
        //     in the "mask" you use the wxLIST_MASK_XXXX defines;
        //     in the "statemask" you use the wxLIST_STATE_XXX defines
        //     to set a specific bit of the wxListInfo::m_state var
        if (checked)
                // the 2nd parameter says: activate the STATE bit relative to CHECK feature
                // the 3rd parameter says: set only *that* bit
                SetItemState(item, wxLIST_STATE_CHECKED, wxLIST_STATE_CHECKED);
        else
                SetItemState(item, 0, wxLIST_STATE_CHECKED);
}

void wxCheckedListCtrl::Enable(long item, bool enable)
{        
        if (enable)
                // the 2nd parameter says: activate the STATE bit relative to ENABLE feature
                // the 3rd parameter says: set only *that* bit
                SetItemState(item, wxLIST_STATE_ENABLED, wxLIST_STATE_ENABLED);
        else
                SetItemState(item, 0, wxLIST_STATE_ENABLED);
}

void wxCheckedListCtrl::EnableAll(bool enable)
{
        for (int i=0; i < GetItemCount(); i++)
                Enable(i, enable);
}

void wxCheckedListCtrl::CheckAll(bool check)
{
        for (int i=0; i < GetItemCount(); i++)
                Check(i, check);
}

bool wxCheckedListCtrl:eleteItem(long item)
{
        // shift our additional state array
        //for (int i=item,max=GetItemCount(); i < max-1; i++)
        //        m_stateList = m_stateList[i+1];
        m_stateList.RemoveAt(item, 1);

        return wxListCtrl:eleteItem(item);
}

int wxCheckedListCtrl::GetCheckedItemCount() const
{
        int res = 0;
        for (int i=0; i<GetItemCount(); i++)
                if (IsChecked(i))
                        res++;

        return res;
}

// event handlers

void wxCheckedListCtrl::OnMouseEvent(wxMouseEvent& event)
{
    if (!event.LeftDown()) {
        event.Skip();
                return;
        }
       
        int flags;
        long item = HitTest(event.GetPosition(), flags);
        if (item == wxNOT_FOUND || !IsEnabled(item)) {

                // skip this item
                event.Skip();
                return;
        }
       
        // user clicked exactly on the checkbox or on the item row ?
        bool processcheck = (flags & wxLIST_HITTEST_ONITEMICON) ||
                ((GetWindowStyle() & wxCLC_CHECK_WHEN_SELECTING) &&
                (flags & wxLIST_HITTEST_ONITEM));

        if (processcheck) {

                wxListEvent ev(wxEVT_NULL, GetId());
                ev.m_itemIndex = item;               

                // send the check event
                if (IsChecked(item)) {

                        ev.SetEventType(wxEVT_COMMAND_LIST_ITEM_UNCHECKED);
                        Check(item, FALSE);
                        AddPendingEvent(ev);

                } else {

                        ev.SetEventType(wxEVT_COMMAND_LIST_ITEM_CHECKED);
                        Check(item, TRUE);
                        AddPendingEvent(ev);
                }
        }

        event.Skip();
}
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表