aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2012-03-16 09:38:08 +0100
committerDan Gudmundsson <[email protected]>2012-03-16 09:38:08 +0100
commit37fb668457fd4d98540c8fc08ab3041d9f3f08cf (patch)
treead5aa5e9b14fd8d56af5186aaf8174a12d988169 /lib
parent2738f881102a6c291c8fb1f2305677dba57fa87d (diff)
downloadotp-37fb668457fd4d98540c8fc08ab3041d9f3f08cf.tar.gz
otp-37fb668457fd4d98540c8fc08ab3041d9f3f08cf.tar.bz2
otp-37fb668457fd4d98540c8fc08ab3041d9f3f08cf.zip
[wx] Fix listctrl issues
Wrong arguments / return values in: hitTest getItemPosition and getItemRect
Diffstat (limited to 'lib')
-rw-r--r--lib/wx/api_gen/wx_gen_cpp.erl15
-rw-r--r--lib/wx/api_gen/wx_gen_erl.erl9
-rw-r--r--lib/wx/api_gen/wxapi.conf8
-rw-r--r--lib/wx/c_src/gen/wxe_funcs.cpp20
-rw-r--r--lib/wx/src/gen/wxListCtrl.erl50
5 files changed, 54 insertions, 48 deletions
diff --git a/lib/wx/api_gen/wx_gen_cpp.erl b/lib/wx/api_gen/wx_gen_cpp.erl
index 69e7510a95..2209e4a53b 100644
--- a/lib/wx/api_gen/wx_gen_cpp.erl
+++ b/lib/wx/api_gen/wx_gen_cpp.erl
@@ -350,8 +350,12 @@ declare_type(N,false,_,#type{name="wxDateTime"}) ->
w(" wxDateTime ~s;~n", [N]);
declare_type(N,false,_,#type{name="wxColour"}) ->
w(" wxColour ~s;~n", [N]);
+declare_type(N,false,_,#type{name=Type, base=int, ref=reference}) ->
+ w(" ~s ~s;~n", [Type,N]);
declare_type(N,false,_,#type{name=Type, base=int64, ref=reference}) ->
w(" ~s ~s;~n", [Type,N]);
+declare_type(N,false,_,#type{base={comp,_,_},single=true,name=Type,ref=reference}) ->
+ w(" ~s ~s;~n", [Type,N]);
declare_type(N,true,Def,#type{base=Base,single=true,name=Type,by_val=true})
when Base =:= int; Base =:= long; Base =:= float; Base =:= double; Base =:= bool ->
w(" ~s ~s=~s;~n", [Type,N,Def]);
@@ -812,6 +816,7 @@ call_arg(#param{name=N,in=false,type=#type{by_val=false, single=true}}) -> "&" +
call_arg(#param{name=N,def=Def,type=#type{base={comp,_,_},ref={pointer,1},single=true}})
when Def =:= none ->
"&" ++N;
+call_arg(#param{name=N,type=#type{base=int, ref=reference, single=true}}) -> "*" ++ N;
call_arg(#param{name=N,type=#type{by_val=false}}) -> N;
call_arg(#param{name=N,type={merged,_,#type{base={class,_},single=true,
by_val=ByVal,
@@ -888,7 +893,7 @@ build_return_vals(Type,Ps) ->
build_ret_types(void,Ps) ->
Calc = fun(#param{name=N,in=False,type=T}, Free) when False =/= true ->
- case build_ret(N, False, T) of
+ case build_ret(N, {arg, False}, T) of
ok -> Free;
Other -> [Other|Free]
end;
@@ -896,12 +901,12 @@ build_ret_types(void,Ps) ->
end,
lists:foldl(Calc, [], Ps);
build_ret_types(Type,Ps) ->
- Free = case build_ret("Result", out, Type) of
+ Free = case build_ret("Result", {ret, out}, Type) of
ok -> [];
FreeStr -> [FreeStr]
end,
Calc = fun(#param{name=N,in=False,type=T}, FreeAcc) when False =/= true ->
- case build_ret(N, False, T) of
+ case build_ret(N, {arg, False}, T) of
ok -> FreeAcc;
FreeMe -> [FreeMe|FreeAcc]
end;
@@ -927,13 +932,13 @@ build_ret(Name,_,#type{base={enum,_Type},single=true}) ->
w(" rt.addInt(~s);~n",[Name]);
build_ret(Name,_,#type{base={comp,_,{record, _}},single=true}) ->
w(" rt.add(~s);~n", [Name]);
-build_ret(Name,_,#type{base={comp,_,_},single=true, ref=reference}) ->
+build_ret(Name,{ret,_},#type{base={comp,_,_},single=true, ref=reference}) ->
w(" rt.add((*~s));~n",[Name]);
build_ret(Name,_,#type{base={comp,_,_},single=true}) ->
w(" rt.add(~s);~n",[Name]);
build_ret(Name,_,#type{base=bool,single=true,by_val=true}) ->
w(" rt.addBool(~s);~n",[Name]);
-build_ret(Name,both,#type{base=int,single=true,mod=M}) ->
+build_ret(Name,{arg, both},#type{base=int,single=true,mod=M}) ->
case lists:member(unsigned, M) of
true -> w(" rt.addUint(*~s);~n",[Name]);
false -> w(" rt.addInt(*~s);~n",[Name])
diff --git a/lib/wx/api_gen/wx_gen_erl.erl b/lib/wx/api_gen/wx_gen_erl.erl
index 1a616ed876..6159b7c4bd 100644
--- a/lib/wx/api_gen/wx_gen_erl.erl
+++ b/lib/wx/api_gen/wx_gen_erl.erl
@@ -1024,12 +1024,13 @@ enum_name(Name) ->
gen_enums_ints() ->
%% open_write("../include/wx.hrl"), opened in gen_event_recs
w("~n%% Hardcoded Records~n", []),
- w("-record(wxMouseState, {x, y, %% integer()~n"
- " leftDown, middleDown, rightDown, %% bool()~n"
- " controlDown, shiftDown, altDown, metaDown, cmdDown %% bool()~n"
+ w("-record(wxMouseState, {x :: integer(), y :: integer(),~n"
+ " leftDown :: boolean(), middleDown :: boolean, rightDown :: boolean, ~n"
+ " controlDown :: boolean(), shiftDown :: boolean(),~n"
+ " altDown :: boolean(), metaDown :: boolean(), cmdDown :: boolean()~n"
" }).~n", []),
w("-record(wxHtmlLinkInfo, {~n"
- " href, target %% unicode:chardata()~n"
+ " href :: unicode:chardata(), target :: unicode:chardata()~n"
" }).~n", []),
w("~n%% Hardcoded Defines~n", []),
Enums = [E || {{enum,_},E = #enum{as_atom=false}} <- get()],
diff --git a/lib/wx/api_gen/wxapi.conf b/lib/wx/api_gen/wxapi.conf
index 383addfe3f..1f6225ce60 100644
--- a/lib/wx/api_gen/wxapi.conf
+++ b/lib/wx/api_gen/wxapi.conf
@@ -776,10 +776,12 @@
'GetEditControl',
'GetImageList','GetItem','GetItemBackgroundColour',
'GetItemCount',{'GetItemData', [{return, {base,int}}]},
- 'GetItemFont','GetItemPosition','GetItemRect',
- 'GetItemSpacing','GetItemState','GetItemText','GetItemTextColour',
+ 'GetItemFont', {'GetItemPosition', [{"pos", out}]},{'GetItemRect',[{"rect", out}]},
+ 'GetItemSpacing','GetItemState',
+ 'GetItemText','GetItemTextColour',
'GetNextItem','GetSelectedItemCount','GetTextColour','GetTopItem',
- 'GetViewRect',{'HitTest',[{"pSubItem",nowhere}]},'InsertColumn','InsertItem',
+ 'GetViewRect',{'HitTest',[{"pSubItem",nowhere}, {"flags", in}]},
+ 'InsertColumn','InsertItem',
%%'OnGetItemAttr', 'OnGetItemImage','OnGetItemText',
'RefreshItem','RefreshItems','ScrollList',
'SetBackgroundColour','SetColumn','SetColumnWidth','SetImageList','SetItem',
diff --git a/lib/wx/c_src/gen/wxe_funcs.cpp b/lib/wx/c_src/gen/wxe_funcs.cpp
index c81b3c88c0..15012011ed 100644
--- a/lib/wx/c_src/gen/wxe_funcs.cpp
+++ b/lib/wx/c_src/gen/wxe_funcs.cpp
@@ -15420,25 +15420,21 @@ case wxListCtrl_GetItemFont: { // wxListCtrl::GetItemFont
break;
}
case wxListCtrl_GetItemPosition: { // wxListCtrl::GetItemPosition
+ wxPoint pos;
wxListCtrl *This = (wxListCtrl *) getPtr(bp,memenv); bp += 4;
int * item = (int *) bp; bp += 4;
- int * posX = (int *) bp; bp += 4;
- int * posY = (int *) bp; bp += 4;
- wxPoint pos = wxPoint(*posX,*posY);
if(!This) throw wxe_badarg(0);
bool Result = This->GetItemPosition((long) *item,pos);
rt.addBool(Result);
+ rt.add(pos);
+ rt.addTupleCount(2);
break;
}
case wxListCtrl_GetItemRect: { // wxListCtrl::GetItemRect
+ wxRect rect;
int code=wxLIST_RECT_BOUNDS;
wxListCtrl *This = (wxListCtrl *) getPtr(bp,memenv); bp += 4;
int * item = (int *) bp; bp += 4;
- int * rectX = (int *) bp; bp += 4;
- int * rectY = (int *) bp; bp += 4;
- int * rectW = (int *) bp; bp += 4;
- int * rectH = (int *) bp; bp += 4;
- wxRect rect = wxRect(*rectX,*rectY,*rectW,*rectH);
while( * (int*) bp) { switch (* (int*) bp) {
case 1: {bp += 4;
code = (int)*(int *) bp; bp += 4;
@@ -15447,6 +15443,8 @@ case wxListCtrl_GetItemRect: { // wxListCtrl::GetItemRect
if(!This) throw wxe_badarg(0);
bool Result = This->GetItemRect((long) *item,rect,code);
rt.addBool(Result);
+ rt.add(rect);
+ rt.addTupleCount(2);
break;
}
case wxListCtrl_GetItemSpacing: { // wxListCtrl::GetItemSpacing
@@ -15528,16 +15526,14 @@ case wxListCtrl_GetViewRect: { // wxListCtrl::GetViewRect
break;
}
case wxListCtrl_HitTest: { // wxListCtrl::HitTest
- int flags;
wxListCtrl *This = (wxListCtrl *) getPtr(bp,memenv); bp += 4;
int * pointX = (int *) bp; bp += 4;
int * pointY = (int *) bp; bp += 4;
wxPoint point = wxPoint(*pointX,*pointY);
+ int * flags = (int *) bp; bp += 4;
if(!This) throw wxe_badarg(0);
- long Result = This->HitTest(point,flags);
+ long Result = This->HitTest(point,*flags);
rt.addInt(Result);
- rt.addInt(flags);
- rt.addTupleCount(2);
break;
}
case wxListCtrl_InsertColumn_2: { // wxListCtrl::InsertColumn
diff --git a/lib/wx/src/gen/wxListCtrl.erl b/lib/wx/src/gen/wxListCtrl.erl
index 16e8ae4508..a6288fc02a 100644
--- a/lib/wx/src/gen/wxListCtrl.erl
+++ b/lib/wx/src/gen/wxListCtrl.erl
@@ -34,10 +34,10 @@
deleteItem/2,destroy/1,editLabel/2,ensureVisible/2,findItem/3,findItem/4,
getColumn/3,getColumnCount/1,getColumnWidth/2,getCountPerPage/1,getEditControl/1,
getImageList/2,getItem/2,getItemBackgroundColour/2,getItemCount/1,
- getItemData/2,getItemFont/2,getItemPosition/3,getItemRect/3,getItemRect/4,
+ getItemData/2,getItemFont/2,getItemPosition/2,getItemRect/2,getItemRect/3,
getItemSpacing/1,getItemState/3,getItemText/2,getItemTextColour/2,
getNextItem/2,getNextItem/3,getSelectedItemCount/1,getTextColour/1,
- getTopItem/1,getViewRect/1,hitTest/2,insertColumn/3,insertColumn/4,
+ getTopItem/1,getViewRect/1,hitTest/3,insertColumn/3,insertColumn/4,
insertItem/2,insertItem/3,insertItem/4,refreshItem/2,refreshItems/3,
scrollList/3,setBackgroundColour/2,setColumn/3,setColumnWidth/3,setImageList/3,
setItem/2,setItem/4,setItem/5,setItemBackgroundColour/3,setItemColumnImage/4,
@@ -391,34 +391,37 @@ getItemFont(#wx_ref{type=ThisT,ref=ThisRef},Item)
<<ThisRef:32/?UI,Item:32/?UI>>).
%% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxlistctrl.html#wxlistctrlgetitemposition">external documentation</a>.
--spec getItemPosition(This, Item, Pos) -> boolean() when
- This::wxListCtrl(), Item::integer(), Pos::{X::integer(), Y::integer()}.
-getItemPosition(#wx_ref{type=ThisT,ref=ThisRef},Item,{PosX,PosY})
- when is_integer(Item),is_integer(PosX),is_integer(PosY) ->
+-spec getItemPosition(This, Item) -> Result when
+ Result ::{Res ::boolean(), Pos::{X::integer(), Y::integer()}},
+ This::wxListCtrl(), Item::integer().
+getItemPosition(#wx_ref{type=ThisT,ref=ThisRef},Item)
+ when is_integer(Item) ->
?CLASS(ThisT,wxListCtrl),
wxe_util:call(?wxListCtrl_GetItemPosition,
- <<ThisRef:32/?UI,Item:32/?UI,PosX:32/?UI,PosY:32/?UI>>).
+ <<ThisRef:32/?UI,Item:32/?UI>>).
-%% @equiv getItemRect(This,Item,Rect, [])
--spec getItemRect(This, Item, Rect) -> boolean() when
- This::wxListCtrl(), Item::integer(), Rect::{X::integer(), Y::integer(), W::integer(), H::integer()}.
+%% @equiv getItemRect(This,Item, [])
+-spec getItemRect(This, Item) -> Result when
+ Result ::{Res ::boolean(), Rect::{X::integer(), Y::integer(), W::integer(), H::integer()}},
+ This::wxListCtrl(), Item::integer().
-getItemRect(This,Item,Rect={RectX,RectY,RectW,RectH})
- when is_record(This, wx_ref),is_integer(Item),is_integer(RectX),is_integer(RectY),is_integer(RectW),is_integer(RectH) ->
- getItemRect(This,Item,Rect, []).
+getItemRect(This,Item)
+ when is_record(This, wx_ref),is_integer(Item) ->
+ getItemRect(This,Item, []).
%% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxlistctrl.html#wxlistctrlgetitemrect">external documentation</a>.
--spec getItemRect(This, Item, Rect, [Option]) -> boolean() when
- This::wxListCtrl(), Item::integer(), Rect::{X::integer(), Y::integer(), W::integer(), H::integer()},
+-spec getItemRect(This, Item, [Option]) -> Result when
+ Result :: {Res ::boolean(), Rect::{X::integer(), Y::integer(), W::integer(), H::integer()}},
+ This::wxListCtrl(), Item::integer(),
Option :: {code, integer()}.
-getItemRect(#wx_ref{type=ThisT,ref=ThisRef},Item,{RectX,RectY,RectW,RectH}, Options)
- when is_integer(Item),is_integer(RectX),is_integer(RectY),is_integer(RectW),is_integer(RectH),is_list(Options) ->
+getItemRect(#wx_ref{type=ThisT,ref=ThisRef},Item, Options)
+ when is_integer(Item),is_list(Options) ->
?CLASS(ThisT,wxListCtrl),
MOpts = fun({code, Code}, Acc) -> [<<1:32/?UI,Code:32/?UI>>|Acc];
(BadOpt, _) -> erlang:error({badoption, BadOpt}) end,
BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
wxe_util:call(?wxListCtrl_GetItemRect,
- <<ThisRef:32/?UI,Item:32/?UI,RectX:32/?UI,RectY:32/?UI,RectW:32/?UI,RectH:32/?UI, BinOpt/binary>>).
+ <<ThisRef:32/?UI,Item:32/?UI, BinOpt/binary>>).
%% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxlistctrl.html#wxlistctrlgetitemspacing">external documentation</a>.
-spec getItemSpacing(This) -> {W::integer(), H::integer()} when
@@ -511,14 +514,13 @@ getViewRect(#wx_ref{type=ThisT,ref=ThisRef}) ->
<<ThisRef:32/?UI>>).
%% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxlistctrl.html#wxlistctrlhittest">external documentation</a>.
--spec hitTest(This, Point) -> Result when
- Result ::{Res ::integer(), Flags::integer()},
- This::wxListCtrl(), Point::{X::integer(), Y::integer()}.
-hitTest(#wx_ref{type=ThisT,ref=ThisRef},{PointX,PointY})
- when is_integer(PointX),is_integer(PointY) ->
+-spec hitTest(This, Point, Flags) -> integer() when
+ This::wxListCtrl(), Point::{X::integer(), Y::integer()}, Flags::integer().
+hitTest(#wx_ref{type=ThisT,ref=ThisRef},{PointX,PointY},Flags)
+ when is_integer(PointX),is_integer(PointY),is_integer(Flags) ->
?CLASS(ThisT,wxListCtrl),
wxe_util:call(?wxListCtrl_HitTest,
- <<ThisRef:32/?UI,PointX:32/?UI,PointY:32/?UI>>).
+ <<ThisRef:32/?UI,PointX:32/?UI,PointY:32/?UI,Flags:32/?UI>>).
%% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxlistctrl.html#wxlistctrlinsertcolumn">external documentation</a>.
%% <br /> Also:<br />