unit dayel;
{$ifdef FPC}{$mode objfpc}{$h+}{$endif}
interface
uses
 msetypes,mseglob,mseguiglob,mseguiintf,mseapplication,sysutils,msestat,msemenus,msegui,
 msegraphics,msegraphutils,mseevent,mseclasses,msewidgets,mseforms,msedragglob,
 msegrids,msegridsglob,msekeyboard;
type
 tdayelfo = class(tmseform)
   tstringgrid1: tstringgrid;
   procedure Display;
   procedure oncreate(const sender: TObject);
   procedure keyup(const sender: twidget; var ainfo: keyeventinfoty);
   procedure onclose(const sender: TObject);
   procedure onloadlang();
 end;
var
 dayelfo: tdayelfo;
 efdayelfo : boolean = false;
implementation
uses
 dayel_mfm, ee, time, algor, lng;
 
procedure tdayelfo.onloadlang();
begin
caption := str_eventlist;
end; 
 
procedure tdayelfo.Display;
const MAX_EVENT_FIELDS = 10;
var
//a : array of msestring;
a : array of Int64;
f, ff : int64;
h:Int64=-1;
 i, i2 : integer;
 str, s: msestring;
begin
SetLength(a, 0);
for f := 0 to High(org.w) do
 if org.w[f].ActivateInDay(gev) then begin SetLength(a, Length(a)+1); a[High(a)] := f; end;

{
for ff := 0 to MAX_EVENT_FIELDS do begin
  case ff of
    0: s := '№';
    1: s := 'Сообщение';
    2: s := 'Дата';
    3: s := 'Время';
    4: s := 'Файлы';
    else continue;
  end;
  tstringgrid1.rows[0][ff] := s; // Устанавливаем заголовок в первую строку (фиксированную)
end;
}

tstringgrid1.rowcount := Length(a);
for f := 0 to High(a) do begin
for ff := 0 to MAX_EVENT_FIELDS do begin
case ff of
0: s:=IntToStr(f+1);
1: s:= org.w[a[f]].mess;
2: s:=IntToStr(org.w[a[f]].year) + '/' + IntToStr(org.w[a[f]].month) + '/' + IntToStr(org.w[a[f]].day);
3: s:=IntToStr(org.w[a[f]].hour) + ':' + IntToFix2Str(org.w[a[f]].minute);
4: s:=org.w[a[f]].AllFilesString;
else continue;
end; {end select}
tstringgrid1[ff].items[f] := s;
//tstringgrid1.fixrows[0].captionsfix[0].caption := '*';
//tstringgrid1.fixrows[0].captions[0].caption := '*';
end; {next ff}
end; {next f}
end;

procedure tdayelfo.oncreate(const sender: TObject);
begin
Display;
onloadlang();
end;

procedure tdayelfo.keyup(const sender: twidget; var ainfo: keyeventinfoty);
begin
  if ainfo.key = key_Escape then Close;
end;

procedure tdayelfo.onclose(const sender: TObject);
begin
efdayelfo := false;
end;

end.