From 98a0a3a7c3d24144c773629dd827bb06ea6cf5c1 Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson Date: Thu, 7 Jul 2011 10:33:56 +0200 Subject: Add support for virtual listctrls --- lib/wx/api_gen/wx_extra/wxListCtrl.c_src | 101 +++++++++++++++++++++++++++++++ lib/wx/api_gen/wx_extra/wxListCtrl.erl | 70 ++++++++++++++++++--- 2 files changed, 164 insertions(+), 7 deletions(-) (limited to 'lib/wx/api_gen/wx_extra') diff --git a/lib/wx/api_gen/wx_extra/wxListCtrl.c_src b/lib/wx/api_gen/wx_extra/wxListCtrl.c_src index cd3074e481..6443c02be2 100644 --- a/lib/wx/api_gen/wx_extra/wxListCtrl.c_src +++ b/lib/wx/api_gen/wx_extra/wxListCtrl.c_src @@ -1,3 +1,22 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2011. 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 +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + <> + +<> + +<onGetItemText = onGetItemText; + Result->onGetItemAttr = onGetItemAttr; + Result->onGetItemColumnImage = onGetItemColumnImage; + Result->port = Ecmd.port; + newPtr((void *) Result, 0, memenv); + rt.addRef(getRef((void *)Result,memenv), "wxListCtrl"); + break; +} +wxListCtrl_new_2>> + +<> \ No newline at end of file diff --git a/lib/wx/api_gen/wx_extra/wxListCtrl.erl b/lib/wx/api_gen/wx_extra/wxListCtrl.erl index e6470182cb..e6a77fef59 100644 --- a/lib/wx/api_gen/wx_extra/wxListCtrl.erl +++ b/lib/wx/api_gen/wx_extra/wxListCtrl.erl @@ -1,32 +1,33 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2011. 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 %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% + <> < boolean() %% @doc Sort the items in the list control
-%%
SortCalBack(Item1,Item2) -> integer()
+%%
SortCallBack(Item1,Item2) -> integer()
%%
SortCallBack receives the client data associated with two items %% to compare, and should return 0 if the items are equal, a negative %% value if the first item is less than the second one and a positive %% value if the first item is greater than the second one. -%%
NOTE: The callback may not call other processes. +%%
NOTE: The callback may not call other (wx) processes. sortItems(#wx_ref{type=ThisT,ref=ThisRef}, SortCallBack) when is_function(SortCallBack, 2) -> ?CLASS(ThisT,wxListCtrl), @@ -37,3 +38,58 @@ sortItems(#wx_ref{type=ThisT,ref=ThisRef}, SortCallBack) SortId = wxe_util:get_cbId(Sort), wxe_util:call(~s, <>). SortItems>> + +<> + +< wxListCtrl() +%% @doc See external documentation. +new() -> + wxe_util:construct(~s, <<>>). +wxListCtrl_new_0>> + +< wxListCtrl() +%% @equiv new(Parent, []) +new(Parent) + when is_record(Parent, wx_ref) -> + new(Parent, []). + +%% @spec (Parent::wxWindow:wxWindow(), [Option]) -> wxListCtrl() +%% Option = {winid, integer()} | +%% {pos, {X::integer(),Y::integer()}} | +%% {size, {W::integer(),H::integer()}} | +%% {style, integer()} | {validator, wx:wx()} +%% {VirtualCallback, Callback::function()} +%% +%% VirtualCallback = onGetItemText | onGetItemAttr | onGetItemImage | onGetItemColumnImage +%% Callback = fun OnGetItemText(This, Item, Column) -> wxString() | +%% fun OnGetItemAttr(This, Item) -> wxListItemAttr() | +%% fun OnGetItemColumnImage(This, Item, Column) -> integer() +%% @doc See external documentation. +new(#wx_ref{type=ParentT,ref=ParentRef}, Options) + when is_list(Options)-> + ?CLASS(ParentT,wxWindow), + MOpts = fun({winid, Winid}, Acc) -> [<<1:32/?UI,Winid:32/?UI>>|Acc]; + ({pos, {PosX,PosY}}, Acc) -> [<<2:32/?UI,PosX:32/?UI,PosY:32/?UI,0:32>>|Acc]; + ({size, {SizeW,SizeH}}, Acc) -> [<<3:32/?UI,SizeW:32/?UI,SizeH:32/?UI,0:32>>|Acc]; + ({style, Style}, Acc) -> [<<4:32/?UI,Style:32/?UI>>|Acc]; + ({validator, #wx_ref{type=ValidatorT,ref=ValidatorRef}}, Acc) -> + ?CLASS(ValidatorT,wx),[<<5:32/?UI,ValidatorRef:32/?UI>>|Acc]; + ({onGetItemText, F}, Acc) when is_function(F) -> + Fun = fun([This,Item,Col]) -> unicode:characters_to_binary([F(This,Item,Col),0]) end, + [<<6:32/?UI,(wxe_util:get_cbId(Fun)):32/?UI>>|Acc]; + ({onGetItemAttr, F}, Acc) when is_function(F) -> + Fun = fun([This,Item]) -> + #wx_ref{type=wxListItemAttr,ref=ThisRef} = F(This,Item), + <> + end, + [<<7:32/?UI,(wxe_util:get_cbId(Fun)):32/?UI>>|Acc]; + ({onGetItemColumnImage, F}, Acc) when is_function(F) -> + Fun = fun([This,Item, Col]) -> <<(F(This,Item,Col)):32/?I>> end, + [<<8:32/?UI,(wxe_util:get_cbId(Fun)):32/?UI>>|Acc]; + (BadOpt, _) -> erlang:error({badoption, BadOpt}) end, + BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)), + wxe_util:construct(~s, <>). + +wxListCtrl_new_2>> -- cgit v1.2.3