aboutsummaryrefslogtreecommitdiffstats
path: root/lib/reltool/src
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2012-03-19 15:54:30 +0100
committerSiri Hansen <[email protected]>2012-03-19 15:54:30 +0100
commit844afaf366ad7a4f668a60e896d0ae3b9e5d850b (patch)
tree05838abebbb3c998abc41ff5f3430313fb23da7b /lib/reltool/src
parent20ef6a7d381b37d7c620f303a981a3a8b4e227a8 (diff)
downloadotp-844afaf366ad7a4f668a60e896d0ae3b9e5d850b.tar.gz
otp-844afaf366ad7a4f668a60e896d0ae3b9e5d850b.tar.bz2
otp-844afaf366ad7a4f668a60e896d0ae3b9e5d850b.zip
[reltool] Fix GUI problems on Windows
The new warning list did not work on Windows. It could not display tooltips for each warning and the popup window would always disappear behind the main system window. Also, column width did not occur well initially in list controls.
Diffstat (limited to 'lib/reltool/src')
-rw-r--r--lib/reltool/src/reltool_app_win.erl4
-rw-r--r--lib/reltool/src/reltool_sys_win.erl83
-rw-r--r--lib/reltool/src/reltool_utils.erl21
3 files changed, 75 insertions, 33 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 ->