tv_pb.erl

来自「OTP是开放电信平台的简称」· ERL 代码 · 共 688 行 · 第 1/2 页

ERL
688
字号
%% ``The contents of this file are subject to the Erlang Public License,%% Version 1.1, (the "License"); you may not use this file except in%% compliance with the License. You should have received a copy of the%% Erlang Public License along with this software. If not, it can be%% retrieved via the world wide web at http://www.erlang.org/.%% %% Software distributed under the License is distributed on an "AS IS"%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See%% the License for the specific language governing rights and limitations%% under the License.%% %% The Initial Developer of the Original Code is Ericsson Utvecklings AB.%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings%% AB. All Rights Reserved.''%% %%     $Id$%%-module(tv_pb).-export([pb/1]).-include("tv_int_def.hrl").-include("tv_pd_int_msg.hrl").-include("tv_pb_int_def.hrl").%%%*********************************************************************%%% EXTERNAL FUNCTIONS%%%*********************************************************************%%======================================================================%% Function:      pb.%%%% Return Value:  None.%%%% Description:   Process controlling the grid buttons on the display.%%%% Parameters:    None.%%======================================================================pb(ParentPid) ->    process_flag(trap_exit, true),    ProcVars = #process_variables{parent_pid = ParentPid},    loop(ProcVars).%%%********************************************************************%%% INTERNAL FUNCTIONS%%%********************************************************************%%======================================================================%% Function:      loop.%%%% Return Value:  None.%%%% Description:   Eternal (well, almost) loop, receiving messages and %%                handling them.%%%% Parameters:    %%======================================================================loop(ProcVars) ->    receive	Msg ->	    case Msg of				#pb_update_vbtns{} ->		    NewProcVars = update_vbtns(Msg, ProcVars),		    loop(NewProcVars);		#pb_key_info{} ->		    NewProcVars = update_keys(Msg, ProcVars),		    loop(NewProcVars);		#pb_update_hbtns{} ->		    NewProcVars = update_hbtns(Msg, ProcVars),		    loop(NewProcVars);		#pb_set_sort_col{} ->		    NewProcVars = set_sort_col(Msg, ProcVars),		    loop(NewProcVars);		#pb_remove_marks{} ->		    NewProcVars = remove_marks(ProcVars),		    loop(NewProcVars);		#pb_init_btns{} ->		    NewProcVars = init_btns(Msg, ProcVars),		    loop(NewProcVars);		{gs, Id, Event, Data, Args} ->		    NewProcVars = gs_messages({Id, Event, Data, Args}, ProcVars),		    loop(NewProcVars);		{'EXIT', Pid, Reason} ->		    ParentPid = ProcVars#process_variables.parent_pid,		    exit_signals({Pid, Reason}, ParentPid, ProcVars),		    loop(ProcVars);		_Other ->		    loop(ProcVars)	    end    end.%%======================================================================%% Function:      %%%% Return Value:  %%%% Description:   %%%% Parameters:    %%======================================================================exit_signals(ExitInfo, ParentPid, _ProcVars) ->    case ExitInfo of	{ParentPid, _Reason} ->	    exit(normal);	_Other ->	    done    end.%%======================================================================%% Function:      %%%% Return Value:  %%%% Description:   %%%% Parameters:    %%======================================================================gs_messages(Msg, ProcVars) ->    case Msg of	{Id, click, {hbtn, RealCol, VirtualCol}, _Args} ->	    handle_col_marking(Id, RealCol, VirtualCol, ProcVars);	{Id, buttonpress, {resbtn, RealCol, VirtualCol, Xpos}, [1 | _Tail]} ->	    handle_col_resizing(Id, RealCol, VirtualCol, Xpos, ProcVars),	    ProcVars;	{_Id, click, {vbtn, RealRow, VirtualRow}, _Args} ->	    handle_row_marking(RealRow, VirtualRow, ProcVars);	_OtherMessage ->	    ProcVars    end.	    %%======================================================================%% Function:      %%%% Return Value:  %%%% Description:   %%%% Parameters:    %%======================================================================remove_marks(ProcVars) ->    #process_variables{col_mark_params = ColMarkP,		       row_mark_params = RowMarkP}  = ProcVars,    #col_mark_params{col_btn_id          = BtnId,		     virtual_col_marked  = VirtualCol,		     virtual_sort_col    = SortCol}  = ColMarkP,        case BtnId of 	undefined ->	    done;	_AnyId ->	    case VirtualCol of		SortCol ->		    gs:config(BtnId, [{bg, ?SORT_MARK_COLOR},				      {fg, {0, 0, 0}}				     ]);		_Other ->		    gs:config(BtnId, [{bg, ?DEFAULT_BG_COLOR},				      {fg, {0, 0, 0}}				     ])	    end    end,        NewRowMarkP = RowMarkP#row_mark_params{virtual_row_marked = undefined,					   real_row_marked    = undefined					  },    NewColMarkP = ColMarkP#col_mark_params{col_btn_id         = undefined,					   virtual_col_marked = undefined					  },    ProcVars#process_variables{col_mark_params = NewColMarkP,			       row_mark_params = NewRowMarkP			      }.    				   		    		    		                %%======================================================================%% Function:      %%%% Return Value:  %%%% Description:   %%%% Parameters:    %%======================================================================handle_col_marking(BtnId, RealCol, VirtualCol, ProcVars) ->    #process_variables{parent_pid      = PdPid,		       col_mark_params = ColMarkP,		       row_mark_params = RowMarkP}  = ProcVars,    #col_mark_params{col_btn_id          = OldBtnId,		     virtual_col_marked  = OldVirtualCol,		     virtual_sort_col    = SortCol}  = ColMarkP,    {ColMarked, NewColMarkP} = mark_col_btn(BtnId, OldBtnId, VirtualCol, 					    OldVirtualCol, RealCol, SortCol, 					    ColMarkP),    PdPid ! #pb_col_marked{sender      = self(),			   col_marked  = ColMarked,			   real_col    = RealCol,			   virtual_col = VirtualCol			  },    NewRowMarkP = RowMarkP#row_mark_params{virtual_row_marked = undefined,					   real_row_marked    = undefined					  },    ProcVars#process_variables{col_mark_params = NewColMarkP,			       row_mark_params = NewRowMarkP			      }.    %%======================================================================%% Function:      %%%% Return Value:  %%%% Description:   %%%% Parameters:    %%======================================================================handle_row_marking(RealRow, VirtualRow, ProcVars) ->    #process_variables{parent_pid      = PdPid,		       col_mark_params = ColMarkP,		       row_mark_params = RowMarkP}  = ProcVars,    #col_mark_params{col_btn_id          = OldBtnId,		     virtual_col_marked  = OldVirtualCol,		     virtual_sort_col    = SortCol}  = ColMarkP,    {_ColMarked, NewColMarkP} = mark_col_btn(OldBtnId, OldBtnId, OldVirtualCol, 					     OldVirtualCol, undefined, SortCol, 					     ColMarkP),    #row_mark_params{virtual_row_marked = OldVirtualRow} = RowMarkP,       % Check if row shall be marked or unmarked!    {RowMarked, NewRowMarkP} = check_marked_row(VirtualRow, OldVirtualRow, RealRow,						RowMarkP),    PdPid ! #pb_row_marked{sender      = self(),			   row_marked  = RowMarked,			   real_row    = RealRow,			   virtual_row = VirtualRow			  },        ProcVars#process_variables{row_mark_params = NewRowMarkP,			       col_mark_params = NewColMarkP}.

⌨️ 快捷键说明

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