diff options
author | Dan Gudmundsson <[email protected]> | 2011-11-24 13:33:24 +0100 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2011-11-25 10:40:20 +0100 |
commit | e7a2f0d7228d8933ee55bdb18fb01a1b19c078a7 (patch) | |
tree | 033e64da4a0b42e7665b1bb55f9e711ce5b56d0b | |
parent | d7eaea0d44fac1f0c67d67c188d6a635b0a4da4c (diff) | |
download | otp-e7a2f0d7228d8933ee55bdb18fb01a1b19c078a7.tar.gz otp-e7a2f0d7228d8933ee55bdb18fb01a1b19c078a7.tar.bz2 otp-e7a2f0d7228d8933ee55bdb18fb01a1b19c078a7.zip |
[observer] Fix listctrl colum size calculation
-rw-r--r-- | lib/observer/src/observer_lib.erl | 31 | ||||
-rw-r--r-- | lib/observer/src/observer_pro_wx.erl | 10 | ||||
-rw-r--r-- | lib/observer/src/observer_trace_wx.erl | 21 | ||||
-rw-r--r-- | lib/observer/src/observer_tv_table.erl | 9 | ||||
-rw-r--r-- | lib/observer/src/observer_tv_wx.erl | 9 |
5 files changed, 39 insertions, 41 deletions
diff --git a/lib/observer/src/observer_lib.erl b/lib/observer/src/observer_lib.erl index 3096741c6f..7763e8c60a 100644 --- a/lib/observer/src/observer_lib.erl +++ b/lib/observer/src/observer_lib.erl @@ -23,7 +23,8 @@ interval_dialog/4, start_timer/1, stop_timer/1, display_info/2, fill_info/2, update_info/2, to_str/1, create_menus/3, create_menu_item/3, - create_attrs/0 + create_attrs/0, + set_listctrl_col_size/2 ]). -include_lib("wx/include/wx.hrl"). @@ -301,3 +302,31 @@ create_box(Panel, Data) -> wxSizer:add(Box, Right), wxSizer:addSpacer(Box, 30), {Box, InfoFields}. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +set_listctrl_col_size(LCtrl, Total) -> + wx:batch(fun() -> calc_last(LCtrl, Total) end). + +calc_last(LCtrl, _Total) -> + Cols = wxListCtrl:getColumnCount(LCtrl), + {Total, _} = wxWindow:getClientSize(LCtrl), + SBSize = scroll_size(LCtrl), + Last = lists:foldl(fun(I, Last) -> + Last - wxListCtrl:getColumnWidth(LCtrl, I) + end, Total-SBSize, lists:seq(0, Cols - 2)), + Size = max(150, Last), + wxListCtrl:setColumnWidth(LCtrl, Cols-1, Size). + +scroll_size(LCtrl) -> + 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(LCtrl, ?wxVERTICAL) of + true -> wxSystemSettings:getMetric(?wxSYS_VSCROLL_X); + false -> 0 + end + end. diff --git a/lib/observer/src/observer_pro_wx.erl b/lib/observer/src/observer_pro_wx.erl index 77f454ab21..e14cdc070c 100644 --- a/lib/observer/src/observer_pro_wx.erl +++ b/lib/observer/src/observer_pro_wx.erl @@ -335,14 +335,7 @@ handle_event(#wx{id=?ID_TRACE_NEW, event=#wxCommand{type=command_menu_selected}} handle_event(#wx{event=#wxSize{size={W,_}}}, #state{grid=Grid}=State) -> - wx:batch(fun() -> - Cols = wxListCtrl:getColumnCount(Grid), - Last = lists:foldl(fun(I, Last) -> - Last - wxListCtrl:getColumnWidth(Grid, I) - end, W-Cols*3-?LCTRL_WDECR, lists:seq(0, Cols - 2)), - Size = max(200, Last), - wxListCtrl:setColumnWidth(Grid, Cols-1, Size) - end), + observer_lib:set_listctrl_col_size(Grid, W), {noreply, State}; handle_event(#wx{event=#wxList{type=command_list_item_right_click, @@ -435,7 +428,6 @@ set_focus([Old|_], [New|_], Grid) -> wxListCtrl:setItemState(Grid, Old, 0, ?wxLIST_STATE_FOCUSED), wxListCtrl:setItemState(Grid, New, 16#FFFF, ?wxLIST_STATE_FOCUSED). - %%%%%%%%%%%%%%%%%%%%%%%%%%%TABLE HOLDER%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% init_table_holder(Parent, Attrs) -> diff --git a/lib/observer/src/observer_trace_wx.erl b/lib/observer/src/observer_trace_wx.erl index 31c57bd9d3..ef46030cc7 100644 --- a/lib/observer/src/observer_trace_wx.erl +++ b/lib/observer/src/observer_trace_wx.erl @@ -94,7 +94,7 @@ create_window(Notebook, ParentPid) -> %% Buttons Buttons = wxBoxSizer:new(?wxHORIZONTAL), ToggleButton = wxToggleButton:new(Panel, ?TOGGLE_TRACE, "Start Trace", []), - wxSizer:add(Buttons, ToggleButton), + wxSizer:add(Buttons, ToggleButton, [{flag, ?wxALIGN_CENTER_VERTICAL}]), wxSizer:addSpacer(Buttons, 15), wxSizer:add(Buttons, wxButton:new(Panel, ?ADD_NODES, [{label, "Add Nodes"}])), wxSizer:add(Buttons, wxButton:new(Panel, ?ADD_NEW, [{label, "Add 'new' Process"}])), @@ -141,7 +141,7 @@ create_process_view(Parent) -> wxSplitterWindow:setSashGravity(Splitter, 0.0), wxSplitterWindow:setMinimumPaneSize(Splitter,50), - wxSplitterWindow:splitVertically(Splitter, Nodes, Procs, [{sashPosition, 150}]), + wxSplitterWindow:splitVertically(Splitter, Nodes, Procs, [{sashPosition, 155}]), wxSizer:add(MainSz, Splitter, [{flag, ?wxEXPAND}, {proportion, 1}]), wxListCtrl:connect(Procs, command_list_item_right_click), @@ -174,7 +174,7 @@ create_matchspec_view(Parent) -> wxSplitterWindow:setSashGravity(Splitter, 0.0), wxSplitterWindow:setMinimumPaneSize(Splitter,50), - wxSplitterWindow:splitVertically(Splitter, Modules, Funcs, [{sashPosition, 150}]), + wxSplitterWindow:splitVertically(Splitter, Modules, Funcs, [{sashPosition, 155}]), wxSizer:add(MainSz, Splitter, [{flag, ?wxEXPAND}, {proportion, 1}]), wxListCtrl:connect(Modules, size, [{skip, true}]), @@ -199,17 +199,8 @@ create_menues(Parent) -> %%Main window handle_event(#wx{obj=Obj, event=#wxSize{size={W,_}}}, State) -> case wx:getObjectType(Obj) =:= wxListCtrl of - true -> - wx:batch(fun() -> - Cols = wxListCtrl:getColumnCount(Obj), - Last = lists:foldl(fun(I, Last) -> - Last - wxListCtrl:getColumnWidth(Obj, I) - end, W-?LCTRL_WDECR, lists:seq(0, Cols - 2)), - Size = max(150, Last), - wxListCtrl:setColumnWidth(Obj, Cols-1, Size) - end); - false -> - ok + true -> observer_lib:set_listctrl_col_size(Obj, W); + false -> ok end, {noreply, State}; @@ -290,7 +281,7 @@ handle_event(#wx{id=Id, obj=LogWin, event=Ev}, {noreply, State} end; -handle_event(Ev = #wx{id=?LOG_CLEAR, userData=TCtrl}, State) -> +handle_event(#wx{id=?LOG_CLEAR, userData=TCtrl}, State) -> wxTextCtrl:clear(TCtrl), {noreply, State}; diff --git a/lib/observer/src/observer_tv_table.erl b/lib/observer/src/observer_tv_table.erl index 7b5cdb44b9..dea3526a8b 100644 --- a/lib/observer/src/observer_tv_table.erl +++ b/lib/observer/src/observer_tv_table.erl @@ -260,14 +260,7 @@ handle_event(#wx{event=#wxList{type=command_list_col_click, col=Col}}, {noreply, State}; handle_event(#wx{event=#wxSize{size={W,_}}}, State=#state{grid=Grid}) -> - wx:batch(fun() -> - Cols = wxListCtrl:getColumnCount(Grid), - Last = lists:foldl(fun(I, Last) -> - Last - wxListCtrl:getColumnWidth(Grid, I) - end, W-?LCTRL_WDECR, lists:seq(0, Cols - 2)), - Size = max(?DEFAULT_COL_WIDTH, Last), - wxListCtrl:setColumnWidth(Grid, Cols-1, Size) - end), + observer_lib:set_listctrl_col_size(Grid, W), {noreply, State}; handle_event(#wx{event=#wxList{type=command_list_item_selected, itemIndex=Index}}, diff --git a/lib/observer/src/observer_tv_wx.erl b/lib/observer/src/observer_tv_wx.erl index ded03fadb1..d0b07d5018 100644 --- a/lib/observer/src/observer_tv_wx.erl +++ b/lib/observer/src/observer_tv_wx.erl @@ -127,14 +127,7 @@ handle_event(#wx{id=Id}, State = #state{node=Node, grid=Grid, opt=Opt0}) {noreply, State#state{opt=Opt, tabs=Tabs}}; handle_event(#wx{event=#wxSize{size={W,_}}}, State=#state{grid=Grid}) -> - wx:batch(fun() -> - Cols = wxListCtrl:getColumnCount(Grid), - Last = lists:foldl(fun(I, Last) -> - Last - wxListCtrl:getColumnWidth(Grid, I) - end, W-?LCTRL_WDECR, lists:seq(0, Cols - 2)), - Size = max(200, Last), - wxListCtrl:setColumnWidth(Grid, Cols-1, Size) - end), + observer_lib:set_listctrl_col_size(Grid, W), {noreply, State}; handle_event(#wx{obj=Grid, event=#wxList{type=command_list_item_activated, |