⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 toolbar_toolconfig.erl

📁 OTP是开放电信平台的简称
💻 ERL
📖 第 1 页 / 共 2 页
字号:
			       {keypress,true}]),    %% Tool name    gs:create(label,Mid,[{x,10},{y,10},{width,80},{height,30},{align,e},			 {keypress,true},			 {label,{text,"Tool name:"}}]),    Tool = gs:create(entry,Mid,[{x,110},{y,10},{width,280},{height,30},				{keypress,true},{data,tool}]),        %% Start function    gs:create(label,Mid,[{x,10},{y,60},{width,80},{height,30},{align,e},			 {keypress,true},			 {label,{text,"Start:"}}]),    Mod = gs:create(entry,Mid,[{x,110},{y,60},{width,135},{height,30},			       {keypress,true},{data,module}]),    Fun = gs:create(entry,Mid,[{x,245},{y,60},{width,135},{height,30},			       {keypress,true},{data,function}]),        %% Icon file    gs:create(label,Mid,[{x,10},{y,110},{width,80},{height,30},{align,e},			 {keypress,true},			 {label,{text,"Icon file:"}}]),    Icon = gs:create(entry,Mid,[{x,110},{y,110},{width,280},{height,30},				{keypress,true},{data,icon}]),        %% Message    gs:create(label,Mid,[{x,10},{y,160},{width,80},{height,30},{align,e},			 {keypress,true},			 {label,{text,"Message:"}}]),    Msg = gs:create(entry,Mid,[{x,110},{y,160},{width,280},{height,30},			       {keypress,true},{data,message}]),        %% HTML file    gs:create(label,Mid,[{x,10},{y,210},{width,80},{height,30},{align,e},			 {keypress,true},			 {label,{text,"HTML:"}}]),    Html = gs:create(entry,Mid,[{x,110},{y,210},{width,280},{height,30},				{keypress,true},{data,html}]),    %% -----   Bottom frame containing the buttons   -----    Bot = gs:create(frame,Win,[{x,0},{y,310},{width,400},{height,50},			       {bw,2},{keypress,true}]),    gs:create(button,Bot,[{x,75},{y,10},{width,50},{height,30},			  {keypress,true},			  {label,{text,"Clear"}}]),    gs:create(button,Bot,[{x,175},{y,10},{width,50},{height,30},			  {keypress,true},			  {label,{text,"Save"}}]),    gs:create(button,Bot,[{x,275},{y,10},{width,50},{height,30},			  {keypress,true},			  {label,{text,"Stop"}}]),    %% -----   Label for displaying help messages   -----    Lbl = gs:create(label,Win,[{x,0},{y,360},{width,400},{height,30},{bw,2},			       {relief,raised},			       {keypress,true},			       {align,c},{label,{text,""}}]),    gs:config(Win,{map,true}),    gs:config(File,{setfocus,true}),    #tfwindow{window=Win,	      fileentry=File,	      toolentry=Tool,	      moduleentry=Mod,	      functionentry=Fun,	      iconentry=Icon,	      messageentry=Msg,	      htmlentry=Html,	      label=Lbl}.%----------------------------------------% move_focus(Window,Focus)%   Window - tfwindow()%   Focus - file | tool | module | function | icon | message | html | none% Move the input focus to the entry following Focus%----------------------------------------move_focus(Window,file) ->    gs:config(Window#tfwindow.toolentry,{setfocus,true});move_focus(Window,tool) ->    gs:config(Window#tfwindow.moduleentry,{setfocus,true});move_focus(Window,module) ->    gs:config(Window#tfwindow.functionentry,{setfocus,true});move_focus(Window,function) ->    gs:config(Window#tfwindow.iconentry,{setfocus,true});move_focus(Window,icon) ->    gs:config(Window#tfwindow.messageentry,{setfocus,true});move_focus(Window,message) ->    gs:config(Window#tfwindow.htmlentry,{setfocus,true});move_focus(Window,html) ->    gs:config(Window#tfwindow.htmlentry,{setfocus,false});move_focus(_Window,none) ->    true.%----------------------------------------% display(Window,Text)%   Window - tfwindow()%   Text - string()% Display a help message in the window%----------------------------------------display(Window,Text) ->    gs:config(Window#tfwindow.label,{label,{text,Text}}).    %----------------------------------------% display_clear(Window)%   Window - tfwindow()% Clear the help message display%----------------------------------------display_clear(Window) ->    display(Window,"").%----------------------------------------% clear_info(Window)%   Window - tfwindow()% Clear the entries of Window (except the file entry)%----------------------------------------clear_info(Window) ->    gs:config(Window#tfwindow.toolentry,{text,""}),    gs:config(Window#tfwindow.moduleentry,{text,""}),    gs:config(Window#tfwindow.functionentry,{text,""}),    gs:config(Window#tfwindow.iconentry,{text,""}),    gs:config(Window#tfwindow.messageentry,{text,""}),    gs:config(Window#tfwindow.htmlentry,{text,""}).%----------------------------------------% show_info(Window,List)%   Window - tfwindow()%   List - [{Key,Val}]%     Key - tool,     Val - string()%     Key - start,    Val - {atom(),atom(),_}%     Key - icon,     Val - string()%     Key - message,  Val - string()%     Key - html,     Val - string()% Display the different Val's in the appropriate entries of Window%----------------------------------------show_info(_Window,[]) ->    ok;show_info(Window,[{tool,Tool}|Rest]) ->    gs:config(Window#tfwindow.toolentry,{text,Tool}),    show_info(Window,Rest);show_info(Window,[{start,{M,F,_}}|Rest]) ->    gs:config(Window#tfwindow.moduleentry,{text,M}),    gs:config(Window#tfwindow.functionentry,{text,F}),    show_info(Window,Rest);show_info(Window,[{icon,Icon}|Rest]) ->    gs:config(Window#tfwindow.iconentry,{text,Icon}),    show_info(Window,Rest);show_info(Window,[{message,Message}|Rest]) ->    gs:config(Window#tfwindow.messageentry,{text,Message}),    show_info(Window,Rest);show_info(Window,[{html,Html}|Rest]) ->    gs:config(Window#tfwindow.htmlentry,{text,Html}),    show_info(Window,Rest).%=============================================================================% Retrieve user specified information%=============================================================================    %----------------------------------------% check_info(Window) => {ok,ToolInfo} | {error,Reason}%   Window - tfwindow()%   ToolInfo - toolinfo()%   Reason - noname | nostart% Check the information given in the entries and insert it into ToolInfo% if all mandatory information is given.%----------------------------------------check_info(Window) ->    %% First check mandatory elements: name and start function    Tool = gs:read(Window#tfwindow.toolentry,text),    M = gs:read(Window#tfwindow.moduleentry,text),    F = gs:read(Window#tfwindow.functionentry,text),        if	Tool/="",M/="",F/="" ->	    ToolInfo =		#toolinfo{tool=Tool,			  start={list_to_atom(M),list_to_atom(F),[]},			  icon=gs:read(Window#tfwindow.iconentry,text),			  message=gs:read(Window#tfwindow.messageentry,text),			  html=gs:read(Window#tfwindow.htmlentry,text)},	    {ok,ToolInfo};	Tool=="" ->	    {error,noname};			true ->	    {error,nostart}    end.%=============================================================================% Save information to file%=============================================================================%----------------------------------------% save_info(Win,File,ToolInfo) => ok | cancel | {error,waccess}%   Win - GS object%   File - string()%   ToolInfo - toolinfo()% Saves the information in ToolInfo to File on a predefined format.%----------------------------------------save_info(Win,File,ToolInfo) ->    %% First check if file already exists    case file:read_file_info(File) of	{ok,_FileInfo} ->	    %% Request the user to confirm that the file should	    %% be overwritten	    case tool_utils:confirm(Win,[File,					 "exists, will be overwritten"]) of		ok ->		    save_info2(File,ToolInfo);		cancel ->		    cancel	    end;	{error,_Reason} -> % _Reason = "No such file or directory"	    save_info2(File,ToolInfo)    end.%----------------------------------------% save_info2(File,ToolInfo) => ok | {error,waccess}%   File - string() File name%   ToolInfo - toolinfo record% Called by save_info/3%----------------------------------------save_info2(File,ToolInfo) ->    case file:open(File,write) of	{ok,Fd} ->	    io:format(Fd,"{version,\"~s\"}.~n",[toolbar:version()]),	    io:format(Fd,"{{tool,\"~s\"},~n",[ToolInfo#toolinfo.tool]),	    io:format(Fd," {start,~w}",[ToolInfo#toolinfo.start]),	    case ToolInfo#toolinfo.icon of		"" -> ignore;		Icon -> io:format(Fd,",~n {icon,\"~s\"}",[Icon])	    end,	    case ToolInfo#toolinfo.message of		"" -> ignore;		Message -> io:format(Fd,",~n {message,\"~s\"}",[Message])	    end,	    case ToolInfo#toolinfo.html of		"" -> ignore;		Html -> io:format(Fd,",~n {html,\"~s\"}",[Html])	    end,	    io:format(Fd,"}.~n",[]),	    file:close(Fd),	    ok;	_Error ->	    {error,waccess}    end.%=============================================================================% Auxiliary functions%=============================================================================%----------------------------------------% tool_file(File) => string()%   File - string()% Return a file name consisting of File with the suffix .tool added,% if File does not already have this suffix.%----------------------------------------tool_file(File) ->    case filename:extension(File) of	".tool" -> File;	_ -> File ++ ".tool"    end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -