diff options
author | Dan Gudmundsson <dgud@erlang.org> | 2013-01-23 13:41:09 +0100 |
---|---|---|
committer | Dan Gudmundsson <dgud@erlang.org> | 2013-01-23 13:41:09 +0100 |
commit | 694513b8297e09e22fdf47d63772b5044ef50164 (patch) | |
tree | a00fa938a80e352dfe0731e3b3d628653d0d18d7 | |
parent | 47de15b52c46bce34c9e0a172e54411622eb08f1 (diff) | |
download | otp-694513b8297e09e22fdf47d63772b5044ef50164.tar.gz otp-694513b8297e09e22fdf47d63772b5044ef50164.tar.bz2 otp-694513b8297e09e22fdf47d63772b5044ef50164.zip |
wx: Fix wxTreeCtrl return values
Fixes wxTreeCtrl:getBoundingRect/2 and wxTreeCtrl:hitTest/1.
wxTreeCtrl:hitTest now returns a tuple, i.e. not bug compatible with previous
releases but needed to know if the returned wxTreeItemId is valid or not.
-rw-r--r-- | lib/wx/api_gen/wxapi.conf | 6 | ||||
-rw-r--r-- | lib/wx/c_src/gen/wxe_funcs.cpp | 15 | ||||
-rw-r--r-- | lib/wx/src/gen/wxTreeCtrl.erl | 33 | ||||
-rw-r--r-- | lib/wx/src/gen/wxe_debug.hrl | 4 | ||||
-rw-r--r-- | lib/wx/test/wx_class_SUITE.erl | 8 |
5 files changed, 38 insertions, 28 deletions
diff --git a/lib/wx/api_gen/wxapi.conf b/lib/wx/api_gen/wxapi.conf index 94142ff6ba..ff38fb8529 100644 --- a/lib/wx/api_gen/wxapi.conf +++ b/lib/wx/api_gen/wxapi.conf @@ -2,7 +2,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2012. All Rights Reserved. +%% Copyright Ericsson AB 2008-2013. 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 @@ -975,7 +975,7 @@ 'AssignImageList','AssignStateImageList','Collapse','CollapseAndReset', 'Create','Delete','DeleteAllItems','DeleteChildren', {'EditLabel', [{"textCtrlClass", [nowhere]}]}, %'EndEditLabel', - 'EnsureVisible','Expand','GetBoundingRect', + 'EnsureVisible','Expand',{'GetBoundingRect', [{"rect", [out]}]}, 'GetChildrenCount','GetCount','GetEditControl', {'GetFirstChild',[{"cookie", out}]}, {'GetNextChild',[{"cookie", [both]}]}, 'GetFirstVisibleItem',{'GetImageList',0},'GetIndent', @@ -984,7 +984,7 @@ 'GetNextSibling','GetNextVisible','GetItemParent',%'GetParent', 'GetPrevSibling','GetPrevVisible','GetRootItem', 'GetSelection',{'GetSelections', [{return, nowhere},{"val",out}]}, - 'GetStateImageList',{'HitTest', 1}, + 'GetStateImageList', {{'HitTest', 2}, [{"flags", out}]}, {'InsertItem',[{"insertAfter", skip_member}]}, 'IsBold','IsExpanded','IsSelected','IsVisible','ItemHasChildren', %%'OnCompareItems', diff --git a/lib/wx/c_src/gen/wxe_funcs.cpp b/lib/wx/c_src/gen/wxe_funcs.cpp index 5fbe8a2a9e..73111b3528 100644 --- a/lib/wx/c_src/gen/wxe_funcs.cpp +++ b/lib/wx/c_src/gen/wxe_funcs.cpp @@ -1,7 +1,7 @@ /* * %CopyrightBegin% * - * Copyright Ericsson AB 2008-2012. All Rights Reserved. + * Copyright Ericsson AB 2008-2013. 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 @@ -18687,15 +18687,11 @@ case wxTreeCtrl_Expand: { // wxTreeCtrl::Expand break; } case wxTreeCtrl_GetBoundingRect: { // wxTreeCtrl::GetBoundingRect + wxRect rect; bool textOnly=false; wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; bp += 4; /* Align */ wxTreeItemId item = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8; - 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; textOnly = *(bool *) bp; bp += 4; @@ -18704,6 +18700,8 @@ case wxTreeCtrl_GetBoundingRect: { // wxTreeCtrl::GetBoundingRect if(!This) throw wxe_badarg(0); bool Result = This->GetBoundingRect(item,rect,textOnly); rt.addBool(Result); + rt.add(rect); + rt.addTupleCount(2); break; } case wxTreeCtrl_GetChildrenCount: { // wxTreeCtrl::GetChildrenCount @@ -18937,13 +18935,16 @@ case wxTreeCtrl_GetStateImageList: { // wxTreeCtrl::GetStateImageList break; } case wxTreeCtrl_HitTest: { // wxTreeCtrl::HitTest + int flags; wxTreeCtrl *This = (wxTreeCtrl *) getPtr(bp,memenv); bp += 4; int * pointX = (int *) bp; bp += 4; int * pointY = (int *) bp; bp += 4; wxPoint point = wxPoint(*pointX,*pointY); if(!This) throw wxe_badarg(0); - wxTreeItemId Result = This->HitTest(point); + wxTreeItemId Result = This->HitTest(point,flags); rt.add((wxUIntPtr *) Result.m_pItem); + rt.addInt(flags); + rt.addTupleCount(2); break; } case wxTreeCtrl_InsertItem: { // wxTreeCtrl::InsertItem diff --git a/lib/wx/src/gen/wxTreeCtrl.erl b/lib/wx/src/gen/wxTreeCtrl.erl index dfa9e691ce..8f9f2b172c 100644 --- a/lib/wx/src/gen/wxTreeCtrl.erl +++ b/lib/wx/src/gen/wxTreeCtrl.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2012. All Rights Reserved. +%% Copyright Ericsson AB 2008-2013. 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 @@ -35,8 +35,8 @@ -include("wxe.hrl"). -export([addRoot/2,addRoot/3,appendItem/3,appendItem/4,assignImageList/2,assignStateImageList/2, collapse/2,collapseAndReset/2,create/2,create/3,delete/2,deleteAllItems/1, - deleteChildren/2,destroy/1,editLabel/2,ensureVisible/2,expand/2,getBoundingRect/3, - getBoundingRect/4,getChildrenCount/2,getChildrenCount/3,getCount/1, + deleteChildren/2,destroy/1,editLabel/2,ensureVisible/2,expand/2,getBoundingRect/2, + getBoundingRect/3,getChildrenCount/2,getChildrenCount/3,getCount/1, getEditControl/1,getFirstChild/2,getFirstVisibleItem/1,getImageList/1, getIndent/1,getItemBackgroundColour/2,getItemData/2,getItemFont/2, getItemImage/2,getItemImage/3,getItemParent/2,getItemText/2,getItemTextColour/2, @@ -303,26 +303,28 @@ expand(#wx_ref{type=ThisT,ref=ThisRef},Item) wxe_util:cast(?wxTreeCtrl_Expand, <<ThisRef:32/?UI,0:32,Item:64/?UI>>). -%% @equiv getBoundingRect(This,Item,Rect, []) --spec getBoundingRect(This, Item, Rect) -> boolean() when - This::wxTreeCtrl(), Item::integer(), Rect::{X::integer(), Y::integer(), W::integer(), H::integer()}. +%% @equiv getBoundingRect(This,Item, []) +-spec getBoundingRect(This, Item) -> Result when + Result ::{Res ::boolean(), Rect::{X::integer(), Y::integer(), W::integer(), H::integer()}}, + This::wxTreeCtrl(), Item::integer(). -getBoundingRect(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) -> - getBoundingRect(This,Item,Rect, []). +getBoundingRect(This,Item) + when is_record(This, wx_ref),is_integer(Item) -> + getBoundingRect(This,Item, []). %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlgetboundingrect">external documentation</a>. --spec getBoundingRect(This, Item, Rect, [Option]) -> boolean() when - This::wxTreeCtrl(), Item::integer(), Rect::{X::integer(), Y::integer(), W::integer(), H::integer()}, +-spec getBoundingRect(This, Item, [Option]) -> Result when + Result :: {Res ::boolean(), Rect::{X::integer(), Y::integer(), W::integer(), H::integer()}}, + This::wxTreeCtrl(), Item::integer(), Option :: {textOnly, boolean()}. -getBoundingRect(#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) -> +getBoundingRect(#wx_ref{type=ThisT,ref=ThisRef},Item, Options) + when is_integer(Item),is_list(Options) -> ?CLASS(ThisT,wxTreeCtrl), MOpts = fun({textOnly, TextOnly}, Acc) -> [<<1:32/?UI,(wxe_util:from_bool(TextOnly)):32/?UI>>|Acc]; (BadOpt, _) -> erlang:error({badoption, BadOpt}) end, BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)), wxe_util:call(?wxTreeCtrl_GetBoundingRect, - <<ThisRef:32/?UI,0:32,Item:64/?UI,RectX:32/?UI,RectY:32/?UI,RectW:32/?UI,RectH:32/?UI, BinOpt/binary>>). + <<ThisRef:32/?UI,0:32,Item:64/?UI, BinOpt/binary>>). %% @equiv getChildrenCount(This,Item, []) -spec getChildrenCount(This, Item) -> integer() when @@ -561,7 +563,8 @@ getStateImageList(#wx_ref{type=ThisT,ref=ThisRef}) -> <<ThisRef:32/?UI>>). %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxtreectrl.html#wxtreectrlhittest">external documentation</a>. --spec hitTest(This, Point) -> integer() when +-spec hitTest(This, Point) -> Result when + Result ::{Res ::integer(), Flags::integer()}, This::wxTreeCtrl(), Point::{X::integer(), Y::integer()}. hitTest(#wx_ref{type=ThisT,ref=ThisRef},{PointX,PointY}) when is_integer(PointX),is_integer(PointY) -> diff --git a/lib/wx/src/gen/wxe_debug.hrl b/lib/wx/src/gen/wxe_debug.hrl index 6f4fa3fe34..e4d7062ef6 100644 --- a/lib/wx/src/gen/wxe_debug.hrl +++ b/lib/wx/src/gen/wxe_debug.hrl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2012. All Rights Reserved. +%% Copyright Ericsson AB 2008-2013. 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 @@ -1877,7 +1877,7 @@ wxdebug_table() -> {2050, {wxTreeCtrl, getSelection, 0}}, {2051, {wxTreeCtrl, getSelections, 1}}, {2052, {wxTreeCtrl, getStateImageList, 0}}, - {2053, {wxTreeCtrl, hitTest, 1}}, + {2053, {wxTreeCtrl, hitTest, 2}}, {2055, {wxTreeCtrl, insertItem, 4}}, {2056, {wxTreeCtrl, isBold, 1}}, {2057, {wxTreeCtrl, isExpanded, 1}}, diff --git a/lib/wx/test/wx_class_SUITE.erl b/lib/wx/test/wx_class_SUITE.erl index 22bfa53e0a..3e4d9cd528 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-2012. All Rights Reserved. +%% Copyright Ericsson AB 2008-2013. 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 @@ -130,11 +130,17 @@ treeCtrl(Config) -> wxWindow:setSizerAndFit(Panel, Sizer), wxFrame:show(Frame), + ok = wxTreeCtrl:expand(Tree, Root), ?m([], wxTreeCtrl:getItemData(Tree, Root)), ?m({data,item1}, wxTreeCtrl:getItemData(Tree, Item1)), ?m({data,item2}, wxTreeCtrl:getItemData(Tree, Item2)), ?m({data,item3}, wxTreeCtrl:getItemData(Tree, Item3)), + {true, {X0,Y0,W0,H0}} = ?m({_,_},wxTreeCtrl:getBoundingRect(Tree, Item1, [{textOnly, true}])), + ?m({true, {_,Y1,_,_}} when Y1 > Y0, wxTreeCtrl:getBoundingRect(Tree, Item2)), + ?m({Item1, _}, wxTreeCtrl:hitTest(Tree, {X0+W0 div 2, Y0+H0 div 2})), + ?m({0, _}, wxTreeCtrl:hitTest(Tree, {X0+W0 div 2, Y0+H0+H0})), + wxFrame:connect(Tree, command_tree_item_expanded), wxFrame:connect(Tree, command_tree_item_collapsed), wxFrame:connect(Frame, close_window), |