diff options
author | Dan Gudmundsson <[email protected]> | 2013-01-15 09:18:49 +0100 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2013-01-15 09:18:49 +0100 |
commit | 0e044f3525d22de4c4c471f601de50ad3acda304 (patch) | |
tree | dfbbcc31814b0890fcb7774a48cf43322b29ac94 /lib/observer/src/observer_wx.erl | |
parent | fdd0b38e2c85d897a240e5f8f79e268c6540dbfd (diff) | |
parent | c384a91846f7d0aff189fb51d1d502330d7abef4 (diff) | |
download | otp-0e044f3525d22de4c4c471f601de50ad3acda304.tar.gz otp-0e044f3525d22de4c4c471f601de50ad3acda304.tar.bz2 otp-0e044f3525d22de4c4c471f601de50ad3acda304.zip |
Merge branch 'dgud/wx/fix-wx-2.9-compat/OTP-10407'
* dgud/wx/fix-wx-2.9-compat/OTP-10407: (26 commits)
wx: Fix comments
wx: Workaround wx-2.9 bugs
wx: Mac fixes
wx: Fix demo and tests
wx: Allow 64 bits compilation on mac, requires wxWidgets-2.9
appmon: Move runtime part to runtime_tools app
reltool: fix wxWidgets-2.9 compability
debugger: Fix 2.9 compat
observer: Fix check for graphics contexts
Observer: Fix distribution dialog
observer: Fix font sizes
wx: Fix the demo
wx: Fix loading icons and cursors in Windows
wx: Remove unnecessary casts
wx: Fix changed getfunctions
wx: Depricate wxCursor new functions
wx: Fix int to enum
wx: Include correct m4 file in 2.9
wx: Update examples so they work with both wxWidgets 2.8 and 2.9
wx: Modify tests so they work on wxWidgets-2.9
...
Diffstat (limited to 'lib/observer/src/observer_wx.erl')
-rw-r--r-- | lib/observer/src/observer_wx.erl | 100 |
1 files changed, 55 insertions, 45 deletions
diff --git a/lib/observer/src/observer_wx.erl b/lib/observer/src/observer_wx.erl index e433bea8c2..47740581f0 100644 --- a/lib/observer/src/observer_wx.erl +++ b/lib/observer/src/observer_wx.erl @@ -465,41 +465,36 @@ create_connect_dialog(ping, #state{frame = Frame, prev_node=Prev}) -> cancel end; create_connect_dialog(connect, #state{frame = Frame}) -> - Dialog = wxDialog:new(Frame, ?wxID_ANY, "Distribute node "), + Dialog = wxDialog:new(Frame, ?wxID_ANY, "Distribute node", + [{style, ?wxDEFAULT_FRAME_STYLE bor ?wxRESIZE_BORDER}]), VSizer = wxBoxSizer:new(?wxVERTICAL), - RadioBoxSizer = wxBoxSizer:new(?wxHORIZONTAL), Choices = ["Short name", "Long name"], - RadioBox = wxRadioBox:new(Dialog, 1, "", - ?wxDefaultPosition, - ?wxDefaultSize, - Choices, - [{majorDim, 2}, - {style, ?wxHORIZONTAL}]), + RadioBox = wxRadioBox:new(Dialog, 1, "", ?wxDefaultPosition, ?wxDefaultSize, + Choices, [{majorDim, 2}, {style, ?wxHORIZONTAL}]), NameText = wxStaticText:new(Dialog, ?wxID_ANY, "Node name: "), - NameCtrl = wxTextCtrl:new(Dialog, ?wxID_ANY, [{size, {200, 25}}]), + NameCtrl = wxTextCtrl:new(Dialog, ?wxID_ANY, [{size, {300,-1}}]), wxTextCtrl:setValue(NameCtrl, "observer"), CookieText = wxStaticText:new(Dialog, ?wxID_ANY, "Secret cookie: "), - CookieCtrl = wxTextCtrl:new(Dialog, ?wxID_ANY, - [{size, {200, 25}}, {style, ?wxTE_PASSWORD}]), + CookieCtrl = wxTextCtrl:new(Dialog, ?wxID_ANY,[{style, ?wxTE_PASSWORD}]), - BtnSizer = wxDialog:createStdDialogButtonSizer(Dialog, ?wxID_DEFAULT), - Flags = [{flag, ?wxEXPAND bor ?wxALL}, {border, 5}], - wxSizer:add(RadioBoxSizer, RadioBox, Flags), - - wxSizer:add(VSizer, RadioBoxSizer, Flags), + BtnSizer = wxDialog:createButtonSizer(Dialog, ?wxOK bor ?wxCANCEL), + Dir = ?wxLEFT bor ?wxRIGHT bor ?wxDOWN, + Flags = [{flag, ?wxEXPAND bor Dir bor ?wxALIGN_CENTER_VERTICAL}, {border, 5}], + wxSizer:add(VSizer, RadioBox, Flags), wxSizer:addSpacer(VSizer, 10), - wxSizer:add(VSizer, NameText), + wxSizer:add(VSizer, NameText, [{flag, ?wxLEFT}, {border, 5}]), wxSizer:add(VSizer, NameCtrl, Flags), wxSizer:addSpacer(VSizer, 10), - wxSizer:add(VSizer, CookieText), + wxSizer:add(VSizer, CookieText, [{flag, ?wxLEFT}, {border, 5}]), wxSizer:add(VSizer, CookieCtrl, Flags), wxSizer:addSpacer(VSizer, 10), - wxSizer:add(VSizer, BtnSizer, [{flag, ?wxALIGN_LEFT}]), + wxSizer:add(VSizer, BtnSizer, [{proportion, 1}, {flag, ?wxEXPAND bor ?wxALL},{border, 5}]), - wxWindow:setSizer(Dialog, VSizer), + wxWindow:setSizerAndFit(Dialog, VSizer), + wxSizer:setSizeHints(VSizer, Dialog), CookiePath = filename:join(os:getenv("HOME"), ".erlang.cookie"), DefaultCookie = case filelib:is_file(CookiePath) of true -> @@ -548,28 +543,36 @@ clean_menus(Menus, MenuBar) -> remove_menu_items(Menus, MenuBar). remove_menu_items([{MenuStr = "File", Menus}|Rest], MenuBar) -> - MenuId = wxMenuBar:findMenu(MenuBar, MenuStr), - Menu = wxMenuBar:getMenu(MenuBar, MenuId), - Items = [wxMenu:findItem(Menu, Tag) || #create_menu{text=Tag} <- Menus], - [wxMenu:delete(Menu, MItem) || MItem <- Items], - case os:type() =:= {unix, darwin} of - true -> - wxMenuBar:remove(MenuBar, MenuId), - wxMenu:destroy(Menu); - false -> - ignore - end, - remove_menu_items(Rest, MenuBar); + case wxMenuBar:findMenu(MenuBar, MenuStr) of + ?wxNOT_FOUND -> + remove_menu_items(Rest, MenuBar); + MenuId -> + Menu = wxMenuBar:getMenu(MenuBar, MenuId), + Items = [wxMenu:findItem(Menu, Tag) || #create_menu{text=Tag} <- Menus], + [wxMenu:delete(Menu, MItem) || MItem <- Items], + case os:type() =:= {unix, darwin} of + true -> + wxMenuBar:remove(MenuBar, MenuId), + wxMenu:destroy(Menu); + false -> + ignore + end, + remove_menu_items(Rest, MenuBar) + end; remove_menu_items([{"Nodes", _}|_], _MB) -> ok; remove_menu_items([{Tag, _Menus}|Rest], MenuBar) -> - MenuId = wxMenuBar:findMenu(MenuBar, Tag), - Menu = wxMenuBar:getMenu(MenuBar, MenuId), - wxMenuBar:remove(MenuBar, MenuId), - Items = wxMenu:getMenuItems(Menu), - [wxMenu:'Destroy'(Menu, Item) || Item <- Items], - wxMenu:destroy(Menu), - remove_menu_items(Rest, MenuBar); + case wxMenuBar:findMenu(MenuBar, Tag) of + ?wxNOT_FOUND -> + remove_menu_items(Rest, MenuBar); + MenuId -> + Menu = wxMenuBar:getMenu(MenuBar, MenuId), + wxMenuBar:remove(MenuBar, MenuId), + Items = wxMenu:getMenuItems(Menu), + [wxMenu:'Destroy'(Menu, Item) || Item <- Items], + wxMenu:destroy(Menu), + remove_menu_items(Rest, MenuBar) + end; remove_menu_items([], _MB) -> ok. @@ -597,15 +600,22 @@ epmd_nodes(Names) -> update_node_list(State = #state{menubar=MenuBar}) -> {Nodes, NodesMenuItems} = get_nodes(), - NodeMenuId = wxMenuBar:findMenu(MenuBar, "Nodes"), - NodeMenu = wxMenuBar:getMenu(MenuBar, NodeMenuId), - wx:foreach(fun(Item) -> wxMenu:'Destroy'(NodeMenu, Item) end, - wxMenu:getMenuItems(NodeMenu)), - + NodeMenu = case wxMenuBar:findMenu(MenuBar, "Nodes") of + ?wxNOT_FOUND -> + Menu = wxMenu:new(), + wxMenuBar:append(MenuBar, Menu, "Nodes"), + Menu; + NodeMenuId -> + Menu = wxMenuBar:getMenu(MenuBar, NodeMenuId), + wx:foreach(fun(Item) -> wxMenu:'Destroy'(Menu, Item) end, + wxMenu:getMenuItems(Menu)), + Menu + end, + Index = wx:foldl(fun(Record, Index) -> observer_lib:create_menu_item(Record, NodeMenu, Index) end, 0, NodesMenuItems), - + Dist = case erlang:is_alive() of true -> #create_menu{id = ?ID_PING, text = "Connect node"}; false -> #create_menu{id = ?ID_CONNECT, text = "Enable distribution"} |