From 8bf9ec0cb4d4f15bbc2e0e6ccadb43284bcfaa7a Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson Date: Thu, 20 Mar 2014 11:40:58 +0100 Subject: wx: Fix listCtrl sort callback --- lib/wx/api_gen/wx_extra/wxListCtrl.c_src | 4 ++-- lib/wx/c_src/gen/wxe_funcs.cpp | 2 +- lib/wx/c_src/wxe_callback_impl.cpp | 2 +- lib/wx/c_src/wxe_callback_impl.h | 9 ++++++++- lib/wx/test/wx_class_SUITE.erl | 17 +++++++++-------- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/lib/wx/api_gen/wx_extra/wxListCtrl.c_src b/lib/wx/api_gen/wx_extra/wxListCtrl.c_src index 8fa31e512e..d6196d11a2 100644 --- a/lib/wx/api_gen/wx_extra/wxListCtrl.c_src +++ b/lib/wx/api_gen/wx_extra/wxListCtrl.c_src @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2011-2013. All Rights Reserved. +%% Copyright Ericsson AB 2011-2014. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -165,7 +165,7 @@ case ~s: { // wxListCtrl::SortItems taylormade callbackInfo* cb = new callbackInfo(); cb->port = Ecmd.port; cb->callbackID = sortCallback; - bool Result = This->SortItems(wxEListCtrlCompare, (long)cb); + bool Result = This->SortItems(wxEListCtrlCompare, (wxeIntPtr)cb); delete cb; /* Destroy the callback, see wxEPrintout::clear_cb */ diff --git a/lib/wx/c_src/gen/wxe_funcs.cpp b/lib/wx/c_src/gen/wxe_funcs.cpp index 3f5cb4c0f5..8da517ee64 100644 --- a/lib/wx/c_src/gen/wxe_funcs.cpp +++ b/lib/wx/c_src/gen/wxe_funcs.cpp @@ -15875,7 +15875,7 @@ case wxListCtrl_SortItems: { // wxListCtrl::SortItems taylormade callbackInfo* cb = new callbackInfo(); cb->port = Ecmd.port; cb->callbackID = sortCallback; - bool Result = This->SortItems(wxEListCtrlCompare, (long)cb); + bool Result = This->SortItems(wxEListCtrlCompare, (wxeIntPtr)cb); delete cb; /* Destroy the callback, see wxEPrintout::clear_cb */ diff --git a/lib/wx/c_src/wxe_callback_impl.cpp b/lib/wx/c_src/wxe_callback_impl.cpp index e06f68dcbf..3a59004eb0 100644 --- a/lib/wx/c_src/wxe_callback_impl.cpp +++ b/lib/wx/c_src/wxe_callback_impl.cpp @@ -284,7 +284,7 @@ EwxListCtrl::~EwxListCtrl() { * wxListCtrlCompare wrapper * ****************************************************************************/ -int wxCALLBACK wxEListCtrlCompare(long item1, long item2, long callbackInfoPtr) +int wxCALLBACK wxEListCtrlCompare(wxeIntPtr item1, wxeIntPtr item2, wxeIntPtr callbackInfoPtr) { callbackInfo * cb = (callbackInfo *)callbackInfoPtr; wxeMemEnv * memenv = ((WxeApp *) wxTheApp)->getMemEnv(cb->port); diff --git a/lib/wx/c_src/wxe_callback_impl.h b/lib/wx/c_src/wxe_callback_impl.h index 1c355e4d38..ecfcd3db41 100644 --- a/lib/wx/c_src/wxe_callback_impl.h +++ b/lib/wx/c_src/wxe_callback_impl.h @@ -23,6 +23,13 @@ void pre_callback(); void handle_event_callback(ErlDrvPort port, ErlDrvTermData process); +#if wxCHECK_VERSION(2,9,0) + #define wxeIntPtr wxIntPtr +#else + // This is bad but how it was in wx-2.8 + #define wxeIntPtr long +#endif + /* Fun Callback id */ class wxeEvtListener : public wxEvtHandler { @@ -88,6 +95,6 @@ struct callbackInfo { int callbackID; }; -int wxCALLBACK wxEListCtrlCompare(long item1, long item2, long callbackInfoPtr); +int wxCALLBACK wxEListCtrlCompare(wxeIntPtr item1, wxeIntPtr item2, wxeIntPtr callbackInfoPtr); #endif diff --git a/lib/wx/test/wx_class_SUITE.erl b/lib/wx/test/wx_class_SUITE.erl index 0e151ccc9b..b375c9d515 100644 --- a/lib/wx/test/wx_class_SUITE.erl +++ b/lib/wx/test/wx_class_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2013. All Rights Reserved. +%% Copyright Ericsson AB 2008-2014. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -344,21 +344,21 @@ listCtrlSort(Config) -> Wx = wx:new(), Frame = wxFrame:new(Wx, ?wxID_ANY, "Frame"), - LC = wxListCtrl:new(Frame, [{style, ?wxLC_REPORT bor ?wxLC_SORT_ASCENDING}]), + LC = wxListCtrl:new(Frame, [{style, ?wxLC_REPORT}]), %% must be done crashes in wxwidgets otherwise. wxListCtrl:insertColumn(LC, 0, "Column"), Add = fun(Int) -> - wxListCtrl:insertItem(LC, Int, integer_to_list(Int)), + wxListCtrl:insertItem(LC, Int, "ABC " ++ integer_to_list(Int)), %% ItemData Can only be integers currently - wxListCtrl:setItemData(LC, Int, abs(2500-Int)) + wxListCtrl:setItemData(LC, Int, abs(50-Int)) end, - wx:foreach(Add, lists:seq(0,5000)), + wx:foreach(Add, lists:seq(0,50)), wxWindow:show(Frame), - timer:sleep(200), + timer:sleep(2000), Sort = fun() -> wxListCtrl:sortItems(LC, fun(A, B) -> @@ -374,11 +374,12 @@ listCtrlSort(Config) -> io:format("Sorted ~p ~n",[Time]), Item = wxListItem:new(), + wxListItem:setMask(Item, ?wxLIST_MASK_TEXT), _List = wx:map(fun(Int) -> wxListItem:setId(Item, Int), ?m(true, wxListCtrl:getItem(LC, Item)), - io:format("~s~n",[wxListItem:getText(Item)]) - end, lists:seq(0,100)), + io:format("~p: ~s~n",[Int, wxListItem:getText(Item)]) + end, lists:seq(0,10)), wxListItem:destroy(Item), wx_test_lib:wx_destroy(Frame,Config). -- cgit v1.2.3