wxAuiは画面?をドッキングする機能みたい。
以下を参照。
にょろぷにらん | wxPythonのwx.aui : http://mag.matrix.jp/mag/queen/log/soft/eid358.html
「One」の部分をクリックしたまま移動させると、画面がポッと出てきて、他の部分に移動させることができる。すげーな。
ソース:
-module(auiTest).
-include_lib("wx.hrl").
-export([start/0]).
-define(pi, wxAuiPaneInfo).
start()->
Wx = wx:new(),
Frame = wx:batch(fun() -> create_window(Wx) end),
wxWindow:show(Frame),
loop(Frame),
wx:destroy(),
ok.
create_window(Wx)->
%% Create Frame
Frame = wxFrame:new(Wx,
-1,
"Aui Example",
%%[{size,{300,200}}]),
[{size,{-1,-1}}]),
%% Create Panel
%%Panel1 = wxPanel:new(Frame),
Panel = wxPanel:new(Frame, []),
%% Setup sizers
MainSizer = wxBoxSizer:new(?wxVERTICAL),
%% Create AuiManager
Manager = wxAuiManager:new([{managed_wnd, Panel}
]),
%% Create wxAuiPaneInfo
Pane = ?pi:new(),
?pi:closeButton(Pane),
?pi:right(Pane),
?pi:dockable(Pane, [{b, true}]),
?pi:floatingSize(Pane, 300,200),
?pi:minSize(Pane, {50,50}),
?pi:paneBorder(Pane),
?pi:floatable(Pane, [{b, true}]),
%% Create Pane Clone?
create_pane(Panel, Manager, Pane),
create_pane(Panel, Manager,
?pi:caption(?pi:top(?pi:new(Pane)), "One")),
create_pane(Panel, Manager,
?pi:caption(?pi:left(?pi:new(Pane)), "two")),
create_pane(Panel, Manager,
?pi:caption(?pi:bottom(?pi:new(Pane)), "Three")),
Pane2 = wxAuiPaneInfo:new(Pane),
?pi:centrePane(Pane2),
%% Create Pane2 Clone?
create_notebook(Panel, Manager, ?pi:new(Pane2)),
wxPanel:setSizer(Panel, MainSizer),
wxAuiManager:connect(Manager, aui_pane_button, [{skip,true}]),
wxAuiManager:connect(Manager, aui_pane_maximize, [{skip,true}]),
wxAuiManager:update(Manager),
%% Set Connect Close
wxFrame:connect(Frame, close_window),
Frame.
loop(Frame) ->
receive
% Window Close Event
#wx{event=#wxClose{}} ->
io:format("~p Closing window ~n",[self()]),
wxWindow:destroy(Frame),
ok
end.
create_notebook(Parent, Manager, Pane) ->
Style = (0
bor ?wxAUI_NB_DEFAULT_STYLE
bor ?wxAUI_NB_TOP
bor ?wxAUI_NB_WINDOWLIST_BUTTON
bor ?wxAUI_NB_CLOSE_ON_ACTIVE_TAB
bor ?wxAUI_NB_TAB_MOVE
bor ?wxAUI_NB_SCROLL_BUTTONS
),
Notebook = wxAuiNotebook:new(Parent, [{style, Style}]),
Tab1 = wxPanel:new(Notebook, []),
wxPanel:setBackgroundColour(Tab1, ?wxBLACK),
wxButton:new(Tab1, ?wxID_ANY, [{label,"New tab"}]),
wxAuiNotebook:addPage(Notebook, Tab1, "You can", []),
Tab2 = wxPanel:new(Notebook, []),
wxPanel:setBackgroundColour(Tab2, ?wxRED),
wxButton:new(Tab2, ?wxID_ANY, [{label,"New tab"}]),
wxAuiNotebook:addPage(Notebook, Tab2, "rearrange", []),
Tab3 = wxPanel:new(Notebook, []),
wxPanel:setBackgroundColour(Tab3, ?wxGREEN),
wxButton:new(Tab3, ?wxID_ANY, [{label,"New tab"}]),
wxAuiNotebook:addPage(Notebook, Tab3, "these tabs", []),
wxAuiManager:addPane(Manager, Notebook, Pane),
wxAuiNotebook:connect(Notebook, command_button_clicked),
wxAuiNotebook:connect(Notebook, command_auinotebook_page_close, [{skip, false}]),
wxAuiNotebook:connect(Notebook, command_auinotebook_page_changed),
Notebook.
create_pane(Parent, Manager, Pane) ->
TextCtrl = wxTextCtrl:new(Parent, ?wxID_ANY, [{size, {300,200}},
{value, "An empty pane"},
{style, 0
bor ?wxDEFAULT
bor ?wxTE_MULTILINE}]),
wxAuiManager:addPane(Manager, TextCtrl, Pane),
TextCtrl.
wx.hrlはErlangのインストールディレクトリ内にあるものを使用。本ソースと同一ディレクトリに配置。
ソースをブログに貼ると長いな。
0 件のコメント:
コメントを投稿