diff options
author | Dan Gudmundsson <[email protected]> | 2011-11-10 11:12:48 +0100 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2011-11-11 14:59:18 +0100 |
commit | 3caa688c5522b8f0f039b9375cf6377b1bd88f0e (patch) | |
tree | 3a5fb27501f1a3e729683fc29b47df9aa14d9189 /lib/observer/src/observer_wx.erl | |
parent | b7b88933672591d7f7c2a71a4c1643b6ca486f23 (diff) | |
download | otp-3caa688c5522b8f0f039b9375cf6377b1bd88f0e.tar.gz otp-3caa688c5522b8f0f039b9375cf6377b1bd88f0e.tar.bz2 otp-3caa688c5522b8f0f039b9375cf6377b1bd88f0e.zip |
[observer] Fix portability bugs
Turn on generic listctrl implementation on Mac,
the native doesn't work in wx-2.8.
Fix listctrl colours on mac
Turn on wxSystemMenu for miniFrame to get a close box on Windows.
Direct observer help to a browser.
Cleanups
Diffstat (limited to 'lib/observer/src/observer_wx.erl')
-rw-r--r-- | lib/observer/src/observer_wx.erl | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/observer/src/observer_wx.erl b/lib/observer/src/observer_wx.erl index b39b34c240..45725f03b5 100644 --- a/lib/observer/src/observer_wx.erl +++ b/lib/observer/src/observer_wx.erl @@ -70,8 +70,9 @@ get_attrib(What) -> init(_Args) -> wx:new(), - Frame = wxFrame:new(wx:null(), ?wxID_ANY, "Observer", [{size, {1000, 500}}, - {style, ?wxDEFAULT_FRAME_STYLE}]), + catch wxSystemOptions:setOption("mac.listctrl.always_use_generic", 1), + Frame = wxFrame:new(wx:null(), ?wxID_ANY, "Observer", + [{size, {1000, 500}}, {style, ?wxDEFAULT_FRAME_STYLE}]), IconFile = filename:join(code:priv_dir(observer), "erlang_observer.png"), Icon = wxIcon:new(IconFile, [{type,?wxBITMAP_TYPE_PNG}]), wxFrame:setIcon(Frame, Icon), @@ -162,7 +163,15 @@ handle_event(#wx{id = ?wxID_EXIT, event = #wxCommand{type = command_menu_selecte {stop, normal, State}; handle_event(#wx{id = ?wxID_HELP, event = #wxCommand{type = command_menu_selected}}, State) -> - io:format("~p ~p, you clicked help", [?MODULE, ?LINE]), + External = "http://www.erlang.org/doc/apps/observer/index.html", + Internal = filename:join([code:lib_dir(observer),"doc", "html", "index.html"]), + Help = case filelib:is_file(Internal) of + true -> Internal; + false -> External + end, + wx_misc:launchDefaultBrowser(Help) orelse + create_txt_dialog(State#state.frame, "Could not launch browser: ~n " ++ Help, + "Error", ?wxICON_ERROR), {noreply, State}; handle_event(#wx{id = ?wxID_ABOUT, event = #wxCommand{type = command_menu_selected}}, @@ -483,11 +492,9 @@ get_nodes() -> Nodes = [node()| nodes()], {_, Menues} = lists:foldl(fun(Node, {Id, Acc}) when Id < ?LAST_NODES_MENU_ID -> - {Id + 1, [#create_menu{id = Id + ?FIRST_NODES_MENU_ID, - text = atom_to_list(Node)} | Acc]} - end, - {1, []}, - Nodes), + {Id + 1, [#create_menu{id=Id + ?FIRST_NODES_MENU_ID, + text=atom_to_list(Node)} | Acc]} + end, {1, []}, Nodes), {Nodes, lists:reverse(Menues)}. update_node_list(State = #state{menubar=MenuBar}) -> |