diff options
-rw-r--r-- | lib/reltool/src/reltool_app_win.erl | 4 | ||||
-rw-r--r-- | lib/reltool/src/reltool_sys_win.erl | 83 | ||||
-rw-r--r-- | lib/reltool/src/reltool_utils.erl | 21 | ||||
-rw-r--r-- | lib/reltool/test/reltool_manual_gui_SUITE.erl | 13 |
4 files changed, 82 insertions, 39 deletions
diff --git a/lib/reltool/src/reltool_app_win.erl b/lib/reltool/src/reltool_app_win.erl index 70bd72b258..eddb37ea11 100644 --- a/lib/reltool/src/reltool_app_win.erl +++ b/lib/reltool/src/reltool_app_win.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2009-2010. All Rights Reserved. +%% Copyright Ericsson AB 2009-2012. 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 @@ -271,8 +271,8 @@ create_apps_list_ctrl(Panel, Sizer, Text) -> ListItem = wxListItem:new(), wxListItem:setAlign(ListItem, ?wxLIST_FORMAT_LEFT), wxListItem:setText(ListItem, Text), + wxListItem:setWidth(ListItem, reltool_utils:get_column_width(ListCtrl)), wxListCtrl:insertColumn(ListCtrl, ?APPS_APP_COL, ListItem), - %% wxListCtrl:setColumnWidth(ListCtrl, ?APPS_APP_COL, ?APPS_APP_COL_WIDTH), wxListItem:destroy(ListItem), wxSizer:add(Sizer, ListCtrl, diff --git a/lib/reltool/src/reltool_sys_win.erl b/lib/reltool/src/reltool_sys_win.erl index 29a01b63d8..912a47ec39 100644 --- a/lib/reltool/src/reltool_sys_win.erl +++ b/lib/reltool/src/reltool_sys_win.erl @@ -458,6 +458,7 @@ create_app_list_ctrl(Panel, OuterSz, Title, Tick, Cross) -> ListItem = wxListItem:new(), wxListItem:setAlign(ListItem, ?wxLIST_FORMAT_LEFT), wxListItem:setText(ListItem, Title), + wxListItem:setWidth(ListItem, reltool_utils:get_column_width(ListCtrl)), wxListCtrl:insertColumn(ListCtrl, ?APPS_APP_COL, ListItem), wxListItem:destroy(ListItem), @@ -665,7 +666,8 @@ create_warning_list(#state{panel = Panel} = S) -> {size, {?WIN_WIDTH,80}}]), reltool_utils:assign_image_list(ListCtrl), wxListCtrl:insertColumn(ListCtrl, ?WARNING_COL, "Warnings", - [{format,?wxLIST_FORMAT_LEFT}]), + [{format,?wxLIST_FORMAT_LEFT}, + {width,reltool_utils:get_column_width(ListCtrl)}]), wxListCtrl:setToolTip(ListCtrl, ?DEFAULT_WARNING_TIP), wxEvtHandler:connect(ListCtrl, size, [{skip, true}, {userData, warnings}]), @@ -907,7 +909,9 @@ handle_event(S, #wx{id = Id, obj= ObjRef, userData = UserData, event = Event} = when S#state.popup_menu =/= undefined -> handle_popup_event(S, Type, Id, ObjRef, UserData, Str); #wxMouse{type = enter_window} -> - wxWindow:setFocus(ObjRef), + %% The following is commented out because it raises the + %% main system window on top of popup windows. + %% wxWindow:setFocus(ObjRef), S; _ -> case wxNotebook:getPageText(S#state.book, @@ -920,21 +924,12 @@ handle_event(S, #wx{id = Id, obj= ObjRef, userData = UserData, event = Event} = end. handle_warning_event(S, ObjRef, _, #wxSize{type = size}) -> - {Total, _} = wxWindow:getClientSize(ObjRef), - SBSize = scroll_size(ObjRef), - wxListCtrl:setColumnWidth(ObjRef, ?WARNING_COL, Total-SBSize), + ColumnWidth = reltool_utils:get_column_width(ObjRef), + wxListCtrl:setColumnWidth(ObjRef, ?WARNING_COL, ColumnWidth), S; handle_warning_event(S, ObjRef, _, #wxMouse{type = motion, x=X, y=Y}) -> Pos = reltool_utils:wait_for_stop_motion(ObjRef, {X,Y}), - Index = wxListCtrl:findItem(ObjRef,-1,Pos,0), - Tip = - case wxListCtrl:getItemText(ObjRef,Index) of - "" -> - ?DEFAULT_WARNING_TIP; - Text -> - "WARNING:\n" ++ Text - end, - wxListCtrl:setToolTip(ObjRef, Tip), + warning_list_set_tool_tip(os:type(),ObjRef,Pos), S; handle_warning_event(S, ObjRef, _, #wxList{type = command_list_item_activated, itemIndex = Pos}) -> @@ -945,6 +940,49 @@ handle_warning_event(S, _ObjRef, {warning,Frame}, wxFrame:destroy(Frame), S#state{warning_wins = lists:delete(Frame,S#state.warning_wins)}. +warning_list_set_tool_tip({win32,_},ListCtrl,{_X,Y}) -> + case win_find_item(ListCtrl,Y,0) of + -1 -> + wxListCtrl:setToolTip(ListCtrl,?DEFAULT_WARNING_TIP); + _Index -> + %% The following is commented out because there seems to + %% be an utomatic tooltip under Windows that shows the + %% expanded list item in case it is truncated because it + %% is too long for column width. + %% Tip = + %% case wxListCtrl:getItemText(ListCtrl,Index) of + %% "" -> + %% ?DEFAULT_WARNING_TIP; + %% Text -> + %% "WARNING:\n" ++ Text + %% end, + %% wxListCtrl:setToolTip(ListCtrl,Tip), + ok + end; +warning_list_set_tool_tip(_,ListCtrl,Pos) -> + case wxListCtrl:findItem(ListCtrl,-1,Pos,0) of + Index when Index >= 0 -> + Tip = + case wxListCtrl:getItemText(ListCtrl,Index) of + "" -> + ?DEFAULT_WARNING_TIP; + Text -> + "WARNING:\n" ++ Text + end, + wxListCtrl:setToolTip(ListCtrl, Tip); + _ -> + ok + end. + +win_find_item(ListCtrl,YPos,Index) -> + case wxListCtrl:getItemRect(ListCtrl,Index) of + {true,{_,Y,_,H}} when YPos>=Y, YPos=<Y+H -> + Index; + {true,_} -> + win_find_item(ListCtrl,YPos,Index+1); + {false,_} -> + -1 + end. display_warning(S,Warning) -> Pos = warning_popup_position(S,?WARNING_POPUP_SIZE), @@ -954,8 +992,6 @@ display_warning(S,Warning) -> Text = wxTextCtrl:new(Panel, ?wxID_ANY, [{value, Warning}, {style, TextStyle}, {size, ?WARNING_POPUP_SIZE}]), - Color = wxWindow:getBackgroundColour(Frame), - wxTextCtrl:setBackgroundColour(Text,Color), Attr = wxTextAttr:new(), wxTextAttr:setLeftIndent(Attr,10), wxTextAttr:setRightIndent(Attr,10), @@ -1608,21 +1644,6 @@ add_text(_,_,[]) -> ok. -scroll_size(ObjRef) -> - case os:type() of - {win32, nt} -> 0; - {unix, darwin} -> - %% I can't figure out is there is a visible scrollbar - %% Always make room for it - wxSystemSettings:getMetric(?wxSYS_VSCROLL_X); - _ -> - case wxWindow:hasScrollbar(ObjRef, ?wxVERTICAL) of - true -> wxSystemSettings:getMetric(?wxSYS_VSCROLL_X); - false -> 0 - end - end. - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% sys callbacks diff --git a/lib/reltool/src/reltool_utils.erl b/lib/reltool/src/reltool_utils.erl index 3e50324011..b0def45213 100644 --- a/lib/reltool/src/reltool_utils.erl +++ b/lib/reltool/src/reltool_utils.erl @@ -29,6 +29,7 @@ app_dir_test/2, split_app_dir/1, get_item/1, get_items/1, get_selected_items/3, select_items/3, select_item/2, + get_column_width/1, safe_keysearch/5, print/4, add_warning/3, @@ -383,6 +384,26 @@ select_item(ListCtrl, [{ItemNo, Text} | Items]) -> select_item(_ListCtrl, []) -> ok. +get_column_width(ListCtrl) -> + wx:batch(fun() -> + {Total, _} = wxWindow:getClientSize(ListCtrl), + Total - scroll_size(ListCtrl) + end). + +scroll_size(ObjRef) -> + case os:type() of + {win32, nt} -> 0; + {unix, darwin} -> + %% I can't figure out is there is a visible scrollbar + %% Always make room for it + wxSystemSettings:getMetric(?wxSYS_VSCROLL_X); + _ -> + case wxWindow:hasScrollbar(ObjRef, ?wxVERTICAL) of + true -> wxSystemSettings:getMetric(?wxSYS_VSCROLL_X); + false -> 0 + end + end. + safe_keysearch(Key, Pos, List, Mod, Line) -> case lists:keysearch(Key, Pos, List) of false -> diff --git a/lib/reltool/test/reltool_manual_gui_SUITE.erl b/lib/reltool/test/reltool_manual_gui_SUITE.erl index 1ebee9fae1..0dcc5cbf15 100644 --- a/lib/reltool/test/reltool_manual_gui_SUITE.erl +++ b/lib/reltool/test/reltool_manual_gui_SUITE.erl @@ -97,14 +97,14 @@ config(Config) -> break("the warning text can be marked, copied and pasted", "close the popup with the close box on the top frame"), break("it disappears", - "select application a from 'Included' column and click red cross to " - "exclude it"), + "select application a from 'Included' column and click 'cross'-button " + "with to exclude it"), break("application a is moved to 'Excluded' column", - "select application tools from 'Excluded' column and click green V to " - "include it"), + "select application tools from 'Excluded' column and click " + "'tick'-button to include it"), break("application tools is moved to 'Included' column", "select application runtime_tools from 'Excluded' column and click " - "green V to include it"), + "'tick'-button to include it"), break("application runtime_tools is moved to 'Included' column", "undo"), @@ -171,7 +171,8 @@ config(Config) -> {ok,ServerPid} = reltool:get_server(SysPid), unlink(SysPid), break("the system window is still alive", - "terminate reltool by hitting 'Ctrl-q' when system window is active"), + "terminate reltool by hitting 'Ctrl-q' (linux) or clicking the " + "close box on the top fram when system window is active"), false = erlang:is_process_alive(SysPid), false = erlang:is_process_alive(ServerPid), |