-
Notifications
You must be signed in to change notification settings - Fork 3
/
ChatPage.pas
1663 lines (1513 loc) · 45.4 KB
/
ChatPage.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{ Ïðè èñïîëüçîâàíèè äàííûõ èñõîäíèêîâ èëè èõ ôðàãìåíòîâ, ññûëêà íà èñòî÷íèê
îáÿçàòåëüíà.
http://irchat.ru
TChatFrame - ñòðàíèöà ÷àòà. Ñîäåðæèò îñíîâíîå ïîëå ÷àòà, ñïèñîê þçåðîâ, ïàíåëü
êíîïîê, ïîëå ââîäà òåêñòà è (îïöèîíàëüíî) ïàíåëü ñ àâàòàðîì.
TODO: èçáàâèòüñÿ îò Main (íàïðèìåð, Main.ParseIRCTextToRV )
}
//{$DEFINE AVATARS}
unit ChatPage;
interface
uses StdCtrls, ComCtrls, ExtCtrls, Main, RVScroll, RichView, RVStyle, CRVFData,
Classes, Controls, Forms, Graphics, Smiles, Types, Windows,
SysUtils, Misc, ShellAPI, AdvPicture, ToolWin, Menus, ActnPopupCtrl,
Dialogs, ImgList, RVTable, Core, Contnrs, ActnList;
type
TChatFrame = class(TFrame)
MesText: TRichView;
UserList: TTreeView;
SplitterV: TSplitter;
SplitterH: TSplitter;
RightPanel: TPanel;
LeftPanel: TPanel;
MessPanel: TPanel;
TxtToolBar: TToolBar;
TxtToSend: TMemo;
btnSmiles: TToolButton;
btnColor: TToolButton;
tbtnSeparator1: TToolButton;
btnUnderline: TToolButton;
btnItalic: TToolButton;
btnBold: TToolButton;
{$IFDEF AVATARS}
AvatarSplitter: TSplitter;
AvatarPanel: TPanel;
{$ENDIF}
TextWindowPopUp: TPopupMenu;
mCtrlC: TMenuItem;
mFreezeScrolling: TMenuItem;
mHScroll: TMenuItem;
UserListContextMenu: TPopupMenu;
mInsertName: TMenuItem;
mInsertPrivate: TMenuItem;
mPrivateAll: TMenuItem;
mPrivateWith: TMenuItem;
mInfoAboutUser: TMenuItem;
N4: TMenuItem;
mSendFile: TMenuItem;
mCreateLine: TMenuItem;
mRefreshUserList: TMenuItem;
N6: TMenuItem;
mIgnorePersonal: TMenuItem;
mIgnoreAll: TMenuItem;
mIgnoreForTime: TMenuItem;
N8: TMenuItem;
mTemplates: TMenuItem;
mActionsSubmenu: TMenuItem;
mCreateUsersGroup: TMenuItem;
mDeleteUsersGroup: TMenuItem;
mRenameUsersGroup: TMenuItem;
mDefineUserColor: TMenuItem;
AvatarPopup: TPopupMenu;
mGetAvatarFromFile: TMenuItem;
mGetAvatarFromURL: TMenuItem;
mCheckCurrentUserAvatar: TMenuItem;
mCheckAllUsersAvatar: TMenuItem;
tbtnSeparator2: TToolButton;
btnClearText: TToolButton;
btnFreezeScrolling: TToolButton;
actlstChatFrame: TActionList;
actCopy: TAction;
actFreezeScrolling: TAction;
actHScroll: TAction;
actBold: TAction;
actItalic: TAction;
actUnderline: TAction;
actColor: TAction;
actSmiles: TAction;
actClearText: TAction;
actTranslit: TAction;
btnTranslit: TToolButton;
procedure TextWindowPopUpPopup(Sender: TObject);
procedure UserListPopupClick(Sender: TObject);
procedure mInsertNameClick(Sender: TObject);
procedure UserListContext(Sender: TObject; MousePos: TPoint; var Handled: Boolean);
procedure mTemplatesClick(Sender: TObject);
procedure AvatarPopupClick(Sender: TObject);
procedure actlstChatFrameExecute(Action: TBasicAction;
var Handled: Boolean);
procedure actDummyExecute(Sender: TObject);
procedure TxtToSendKeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
//slUserList: TStringList;
CheckChanged: boolean; // ïðèçíàê ñìåíû ïîìåòêè íàïðîòèâ íèêà ïîëüçîâàòåëÿ
DragNode: TTreeNode;
procedure CopyRusChar(Sender: TObject);
procedure SendMultiPrivate(sText: string);
procedure LoadLanguage();
procedure OnActivateHandler(Sender: TObject);
procedure OnDeactivateHandler(Sender: TObject);
procedure OnUpdateStyleHandler(Sender: TObject);
procedure OnClearHandler(Sender: TObject);
procedure OnCompareHandler(Sender: TObject; Node1, Node2: TTreeNode; Data: Integer; var Compare: Integer);
public
{ Public declarations }
Page: TChatPage;
TranslitMode: Boolean;
{$IFDEF AVATARS}
AvatarUser: String;
AvatarPicture: TAdvPicture;
procedure UserListMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure AvatarPictureContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean);
procedure CheckAvatar(CheckAll:boolean=true);
{$ENDIF}
constructor Create(APage: TChatPage); reintroduce;
procedure DownKeySend(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure InsertPrivate();
procedure CopyOnSelect(Sender: TObject);
procedure onHLink(Sender: TObject; id: Integer);
procedure ShowMemo(i: integer);
//procedure ShowMemoDown(snd: integer; i: integer);
procedure EditInsertSymbol(CSymbol: Char);
procedure UserListMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure UserListDragDrop(Sender, Source: TObject; X, Y: Integer);
procedure UserListDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
procedure UserListClick(Sender: TObject);
procedure UserListDblClick(Sender: TObject);
procedure ToggleVScrollStop();
procedure SetNewFont();
procedure ShowTable(InfoList: TInfoList);
procedure AddNote(sUserName, sNoteText: string);
procedure ClearMesText();
procedure InsertText(InsText: string);
procedure AddNick(sNick: String; ImgIndex: integer = -1; Color: integer = 0);
procedure AddNicks(sNickList: String; ImgIndex: integer = -1; Color: integer = 0;
ClearList: boolean = false);
function ChangeNick(sNick, sNewNick: string; ImgIndex: integer = -1; Color: integer = 0): boolean;
procedure RemoveNick(sNick: string; RemoveAll: boolean = false);
procedure SetUserlistStyle(sStyle: string);
procedure CycleUserNamesByFirstLetters();
end;
{TNickList = class(TObjectList)
public
procedure AddNick(sNick: String; ImgIndex: integer = 0; Color: integer = 0);
procedure AddNicks(sNickList: String; ImgIndex: integer = 0; Color: integer = 0;
ClearList: boolean = false);
function ChangeNick(sNick, sNewNick: string; ImgIndex: integer = -1): boolean;
procedure RemoveNick(sNick: string; RemoveAll: boolean = false);
end; }
procedure AddMemoCmd(sMemo :String);
var
sUserListIns:string = 'Âñòàâèòü "%s" â ìåññàãó';
sUserListMsg:string = 'Ìåññàãà äëÿ %s';
sUserListPvt:string = 'Ïðèâàò ñ %s';
sUserListInf:string = 'Èíôà î %s';
sUserListIgP:string = 'Èãíîðèòü ëè÷êó îò %s';
sUserListIgA:string = 'Èãíîðèòü âñå ìåññàãè îò %s';
sDlgAddGroupCaption:string = 'Íàçâàíèå ãðóïïû';
sDlgAddGroupText:string = 'Ãðóïïà';
implementation
{$R *.dfm}
uses EnterCmd;
///////////////////////////////////////////////////////////////////////////////
// Ìåòîäû ôðåéìà ÷àòà
///////////////////////////////////////////////////////////////////////////////
constructor TChatFrame.Create(APage: TChatPage);
begin
inherited Create(APage.TabSheet);
//self.Parent:=TWinControl(APage.TabSheet);
self.Page:=APage;
APage.OnActivate:=OnActivateHandler;
APage.OnDeactivate:=OnDeactivateHandler;
APage.OnUpdateStyle:=OnUpdateStyleHandler;
APage.OnClear:=OnClearHandler;
self.Align:=alClient;
self.DoubleBuffered:=true;
{//RightPanel := TPanel.Create(Self);
with RightPanel do
begin
Parent := Self;
Width := 150;
Align := alRight;
BorderStyle := bsNone;
BevelInner := bvNone;
BevelOuter := bvNone;
DoubleBuffered:=true;
end;}
RightPanel.DoubleBuffered:=True;
//UserList := TTreeView.Create(Self); // Ñïèñîê þçåðîâ
with UserList do
begin
Parent := RightPanel;
Align := alClient;
//Width := 150;
//Images := Core.MainForm.UserListImages;
//StateImages := Core.MainForm.UserListImages;
Images := Core.MainForm.ImageList16;
StateImages := Core.MainForm.ImageList16;
ReadOnly := True;
HotTrack:=true;
SortType := stText;
OnClick := UserListClick;
OnDblClick := UserListDblClick;
OnMouseDown := UserListMouseDown;
OnDragDrop := UserListDragDrop;
OnDragOver := UserListDragOver;
{$IFDEF AVATARS}
OnMouseMove := UserListMouseMove;
{$ENDIF}
//Tag := i;
OnContextPopup := UserListContext;
OnCompare:=OnCompareHandler;
ShowLines:=false;
ShowRoot:=false;
DoubleBuffered:=true;
end;
{//SplitterV := TSplitter.Create(Self); // Ðàçäåëèòåëü
with SplitterV do
begin
Parent := Self;
Align := alRight;
Width := 3;
ResizeStyle := rsUpdate;
end;}
{//LeftPanel := TPanel.Create(Self);
with LeftPanel do
begin
Parent := Self;
Align := alClient;
BorderStyle := bsNone;
BevelInner := bvNone;
BevelOuter := bvNone;
DoubleBuffered:=true;
end;}
//MessPanel := TPanel.Create(Self);
{with MessPanel do
begin
Parent := LeftPanel;
Align := alBottom;
Height := 48;
BorderStyle := bsNone;
BevelInner := bvNone;
BevelOuter := bvNone;
DoubleBuffered:=true;
end; }
//MessPanel.DoubleBuffered:=True;
{//TxtToolBar := TToolBar.Create(Self);
with TxtToolBar do
begin
Parent := MessPanel;
Align := alTop;
//Align := alBottom;
//Anchors := [akLeft,akTop,akRight,akBottom];
//EdgeBorders := [ebTop,ebBottom];
EdgeBorders := [];
Height := 24;
//Images := BottomToolBar;
DoubleBuffered:=true;
end;}
TxtToolBar.DoubleBuffered:=True;
//TxtToSend := TMemo.Create(Self); // Ïîëå ââîäà òåêñòà
with TxtToSend do
begin
Parent := MessPanel;
//Top := 28;
Anchors := [akLeft,akTop,akRight,akBottom];
Align := alClient;
Font.Name := 'Tahoma';
Font.Color := clNavy;
//Tag := i;
ScrollBars := ssVertical;
WantReturns := false;
WordWrap := false;
OnKeyDown := DownKeySend;
end;
{//SplitterH := TSplitter.Create(Self); // Ðàçäåëèòåëü
with SplitterH do
begin
Parent := LeftPanel;
Align := alBottom;
Width := 1;
MinSize := 48;
AutoSnap := false;
ResizeStyle := rsUpdate;
end; }
//MesText := TRichView.Create(Self); // Òàáëî ÷àòà
with MesText do
begin
Parent := LeftPanel;
Align := alClient;
Style := Core.MainForm.MessStyle;
BottomMargin := 2;
LeftMargin := 2;
RightMargin := 2;
TopMargin := 2;
PopupMenu := TextWindowPopUp;
AnimationMode := rvaniOnFormat;
HScrollVisible:=false;
//tag := i;
OnSelect := CopyOnSelect;
OnCopy := CopyRusChar;
OnJump := OnHLink;
Format;
end;
{$IFDEF AVATARS}
{//AvatarSplitter:=TSplitter.Create(RightPanel); // Ðàçäåëèòåëü îêíà àâàòàðà
with AvatarSplitter do
begin
Parent := RightPanel;
Align := alBottom;
Width := 2;
end; }
{//AvatarPanel:=TPanel.Create(RightPanel);
with AvatarPanel do
begin
Parent := RightPanel;
Align := alBottom;
Height := 108;
BorderStyle := bsNone;
BevelInner := bvLowered;
BevelOuter := bvNone;
DoubleBuffered:=true;
end; }
AvatarPicture:=TAdvPicture.Create(AvatarPanel);
with AvatarPicture do
begin
Parent := AvatarPanel;
Animate := True;
Picture.Stretch := False;
Picture.Frame := 0;
PicturePosition := bpCenter;
Align := alClient;
OnContextPopup:=AvatarPictureContextPopup;
//DoubleBuffered := True;
end;
if not MainConf.GetBool('UseAvatars') then AvatarPanel.Height:=0;
{$ENDIF}
SetNewFont();
LoadLanguage();
end;
///////////////////////////////////////////////////////////////////////////////
// Çàãðóçêà è îáðàáîòêà àâàòàðîâ
///////////////////////////////////////////////////////////////////////////////
{$IFDEF AVATARS}
{procedure AddAvatar(FileName: string);
var
bmp: TBitmap;
rect: TRect;
begin
with rect do
begin
Left:=0;
Top:=0;
Right:=24;
Bottom:=24;
end;
bmp:=TBitmap.Create;
bmp.LoadFromFile(FileName);
bmp.Canvas.StretchDraw(rect, bmp);
bmp.Height:=24;
bmp.Width:=24;
Avatars24.AddMasked(bmp, $00000000);
end;}
{procedure LoadAvatars;
begin
Avatars24 := TCustomImageList.Create(Core.MainForm);
Avatars24.Height:=24;
Avatars24.Width:=24;
AddAvatar('Avatars/normal.bmp');
AddAvatar('Avatars/op.bmp');
AddAvatar('Avatars/voiced.bmp');
AddAvatar('Avatars/hidden.bmp');
end;}
procedure TChatFrame.CheckAvatar(CheckAll:boolean=true);
var
i, n, Delay: integer;
begin
n:=0;
Delay:=MainConf.GetInteger('AvatarQueryDelay')*1000;
begin
if CheckAll then
for i:=UserList.Items.Count-1 downto 0 do
begin
Core.ModTimerEvent(1, self.Page.PageID, Delay*n, '/CTCP '+Norm(UserList.Items[i].Text)+' AVATAR');
Inc(n);
end
else
end;
end;
procedure TChatFrame.UserListMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
Node: TTreeNode;
AvatarName, AvatarsPath, FileName: string;
ExtStr, str1: string;
i: integer;
FileFound: boolean;
begin
if not MainConf.GetBool('UseAvatars') then Exit;
if AvatarPanel.Height<=AvatarSplitter.MinSize then Exit;
Node:=UserList.GetNodeAt(X,Y);
if Node=nil then Exit;
if AvatarUser<>Node.Text then AvatarUser:=Node.Text else Exit;
// Ïîêàç àâàòàðà
ExtStr:='gif,jpg,bmp,';
AvatarName:=Node.Text+'.gif';
AvatarsPath:=IncludeTrailingPathDelimiter(glUserPath+MainConf['AvatarsPath']);
FileFound:=false;
while (Length(ExtStr)>0) and (not FileFound) do
begin
i:=pos(',', ExtStr);
str1:=copy(ExtStr, 1, i-1);
Delete(ExtStr, 1, i);
AvatarName:=AvatarUser+'.'+str1;
FileFound:=FileExists(AvatarsPath+AvatarName);
end;
if not FileFound then
begin
AvatarName:='default.gif';
case Node.ImageIndex of
ciIconNormal: AvatarName:='normal.bmp';
ciIconOper: AvatarName:='op.bmp';
ciIconHidden: AvatarName:='hidden.bmp';
ciIconVoiced: AvatarName:='voiced.bmp';
end;
AvatarsPath:=IncludeTrailingPathDelimiter(glHomePath+MainConf['AvatarsPath']);
end;
if FileExists(AvatarsPath+AvatarName) then
begin
try
AvatarPicture.Picture.LoadFromFile(AvatarsPath+AvatarName);
except
End;
end;
AvatarPanel.Repaint;
end;
procedure TChatFrame.AvatarPictureContextPopup(Sender: TObject; MousePos: TPoint;
var Handled: Boolean);
begin
AvatarPopup.Popup(AvatarPicture.ClientOrigin.X+MousePos.X+5, AvatarPicture.ClientOrigin.Y+MousePos.Y+5);
end;
{$ENDIF}
procedure TChatFrame.SendMultiPrivate(sText: string);
// ðàññûëêà ïðèâàòîâ ïîìå÷åíûì íèêàì
var i: integer;
begin
if (not Page.PageInfo.bUseStateImages) then Exit;
for i:=0 to UserList.Items.Count-1 do
begin
if UserList.Items[i].StateIndex = ciCheckedIndex then
Say('/MSG '+Norm(UserList.Items[i].Text)+' '+sText, Page.PageID);
end;
end;
procedure AddMemoCmd(sMemo :String);
begin
with (slLastTyped) do
begin
if Count>0 then
if Trim(sMemo)=Trim(Strings[Count-1]) then Exit;
Add(sMemo);
if Count > 20 then Delete(0);
Current := Count;
end;
end;
procedure TChatFrame.CycleUserNamesByFirstLetters();
var
s, sName, curInput: string;
i, SelStart, NameStartPos: Integer;
begin
SelStart := TxtToSend.SelStart;
curInput := TxtToSend.Text;
s:='';
NameStartPos:=1;
// Get current entered word
for i := SelStart downto 1 do
begin
if curInput[i]=' ' then
begin
NameStartPos:=i+1;
Break;
end
else s:=curInput[i]+s;
end;
if s='' then Exit;
s:=AnsiLowerCase(s);
// Get corresponding user name
sName:='';
for i:=0 to UserList.Items.Count-1 do
begin
sName:=UserList.Items[i].Text;
if AnsiLowerCase(Copy(sName, 1, Length(s)))=s then
begin
Break;
end;
sName:='';
end;
if sName<>'' then
begin
Delete(curInput, NameStartPos, Length(s));
Insert(sName, curInput, NameStartPos);
TxtToSend.Text:=curInput;
TxtToSend.SelStart:=NameStartPos+Length(sName);
end;
end;
function Translit(s: string): string;
begin
if Length(s)=0 then Exit;
if s[1]='/' then
begin
Result:=s;
Exit;
end;
Result:=TranslitAuto(s);
end;
procedure TChatFrame.DownKeySend(Sender: TObject; var Key: Word; Shift: TShiftState);
var
i, n: integer;
snd: String;
Cpos: TPoint;
//TxtToSend :TMemo;
SelStart :Integer;
begin
//i := Core.MainForm.PageControl1.ActivePageIndex;
SelStart := TxtToSend.SelStart;
case Key of
VK_RETURN: // Enter
begin
if TranslitMode then TxtToSend.Text:=Translit(TxtToSend.Text);
//AddMemoCmd(TxtToSend.Text);
if Shift = [ssAlt] then
SendMultiPrivate(snd)
else
begin
if (ssCtrl in Shift) and (not MainConf.GetBool('SendMsgOnCtrlEnter')) then Exit;
if (not (ssCtrl in Shift)) and MainConf.GetBool('SendMsgOnCtrlEnter') then
begin
TxtToSend.Lines.Add('');
Exit;
end;
//Core.MainForm.Say(TxtToSend.Text);
for i:=0 to TxtToSend.Lines.Count-1 do
Say(TxtToSend.Lines[i], Page.PageID, true);
end;
TxtToSend.Text := '';
end;
VK_TAB: // Tab
begin
CycleUserNamesByFirstLetters();
end;
VK_UP: // Ctrl-Up arrow
begin
if Shift = [ssCtrl] then
begin
if (Length(Trim(TxtToSend.Text)) > 0) And Not Added then
begin
AddMemoCmd(TxtToSend.Text);
Added := true;
end;
ShowMemo(-1);
end;
end;
VK_DOWN: // Ctrl-Down arrow
begin
if Shift = [ssCtrl] then
ShowMemo(1);
end;
75: // Ctrl-K (âûáîð öâåòà)
begin
if Shift = [ssCtrl] then
begin
Core.ShowColors();
TxtToSend.SetFocus;
//ParseIRCText(IntToStr(Cpos.X) + '==' + IntToStr(Cpos.Y), 0);
end;
end;
66: // Ctrl-B (bold)
begin
if Shift = [ssCtrl] then
//if ((GetKeyState(VK_CONTROL) And 128)=128) then
begin
EditInsertSymbol(#2);
end;
end;
73: // Ctrl-I (italic)
begin
if Shift = [ssCtrl] then
begin
EditInsertSymbol(#22);
end;
end;
85: // Ctrl-U (underlined)
begin
if Shift = [ssCtrl] then
begin
EditInsertSymbol(#31);
end;
end;
VK_F11: //122 = F11 (input translit)
begin
snd := Trim(TxtToSend.Text);
if Pos('/', snd) = 1 then
begin
n := TailPos(snd, ' ', Pos(' ', snd) + 1);
if n = 0 then n := Pos(' ', snd);
TxtToSend.Text := Copy(snd, 1, n) + TranslitRus2Lat(Copy(snd, n+1, length(snd)-n));
end
else
begin
TxtToSend.Text := TranslitRus2Lat(snd);
end;
TxtToSend.SelStart := SelStart;
end;
else // case
begin
Core.HideColors();
end;
end;
end;
/////////////////////////////////////////////////////////
// Ðàáîòà ñî ñïèñêîì ïîñëåäíèõ íàáðàííûõ ñîîáùåíèé
/////////////////////////////////////////////////////////
procedure TChatFrame.ShowMemo(i: integer);
// i - index offset from end
var
Cur: integer;
maxCur: integer;
begin
begin
begin
Cur:=slLastTyped.Current+i;
maxCur:=slLastTyped.Count-1;
//if (Cur) > maxCur then Cur := maxCur;
if (Cur) > maxCur then Exit;
if ((Cur)<0) then Exit;
slLastTyped.Current := Cur;
TxtToSend.Text := slLastTyped.Strings[Cur];
//if (i>0) and (Cur=maxCur) then slLastTyped.Current:=Cur+1;
end;
TxtToSend.SelStart := Length(TxtToSend.Text);
end;
end;
procedure TChatFrame.InsertPrivate();
var
sName: string;
begin
with UserList do
begin
if Selected = nil then Exit;
sName := Selected.Text;
end;
with TxtToSend do
begin
Text := '/msg '+Norm(sName)+' ';
SetFocus;
SelStart := Length(Text);
end;
end;
procedure TChatFrame.CopyOnSelect(Sender: TObject);
begin
if not MainConf.GetBool('CopySelected') then Exit;
with MesText do
begin
if SelectionExists then
begin
CopyDef;
Deselect;
Invalidate;
end;
end;
end;
procedure TChatFrame.onHLink(Sender: TObject; id: Integer);
var
RVData: TCustomRVFormattedData;
ItemNo: integer;
s: string;
begin
begin
MesText.GetJumpPointLocation(id, RVData, ItemNo);
s := MesText.GetItemTextA(ItemNo);
if Copy(s, 0, 7) = 'http://' then
begin
ShellExecute(0, nil, PChar(s), '', '', SW_NORMAL);
Exit;
end;
if Copy(s, 0, 1) = '#' then
begin
Say('/JOIN '+s, Page.PageID);
Exit;
end;
begin
TxtToSend.SetFocus;
TxtToSend.Text:=s+': '+TxtToSend.Text;
TxtToSend.SelStart:=Length(TxtToSend.Text);
end;
end;
end;
Procedure TChatFrame.EditInsertSymbol(CSymbol: Char);
var
iSelStart, iSelLength: Integer;
ColorText :String;
StartText :String;
begin
begin
StartText := TxtToSend.text;
iSelStart := TxtToSend.SelStart;
iSelLength := TxtToSend.SelLength;
if iSelLength = 0 then
begin
Insert(CSymbol, StartText, iSelStart+1);
TxtToSend.text := StartText;
TxtToSend.SelStart := iSelStart + 1;
end
else
begin
ColorText := copy(StartText, 1, iSelStart) + CSymbol;
ColorText := ColorText + copy(StartText, iSelStart+1, iSelLength) + CSymbol;
ColorText := ColorText + copy(StartText, (iSelStart + iSelLength + 1), (Length(StartText) - iSelStart - iSelLength));
Self.TxtToSend.Text := ColorText;
TxtToSend.SelStart := iSelStart + iSelLength + 1;
end;
end;
end;
procedure TChatFrame.ShowTable(InfoList: TInfoList);
var table: TRVTableItemInfo;
r,c: Integer;
begin
with MesText do
begin
table := TRVTableItemInfo.CreateEx(InfoList.Count, 2, RVData);
end;
table.Color := clSkyBlue;
table.BorderStyle := rvtbColor;
table.CellBorderStyle := rvtbColor;
table.BorderColor := $002E1234;
table.CellBorderColor := $002E1234;
table.BorderWidth := 0;
table.CellBorderWidth := 1;
table.CellPadding := 1;
table.CellVSpacing := 0;
table.CellHSpacing := 0;
table.Cells[0,0].BestWidth := 120;
table.Cells[0,0].VisibleBorders.Right := False;
for r:=0 to InfoList.Count-1 do
begin
table.Cells[r,0].AddNL(' '+InfoList.Items[r].Name, 6, -1);
table.Cells[r,1].AddNL(' '+InfoList.Items[r].Data, 0, -1);
end;
for r := 0 to table.Rows.Count-1 do
begin
for c := 1 to table.Rows[r].Count-1 do
begin
table.Cells[r,c].Color := $00A5CCE7;
if c>1 then
table.Cells[r,c].VisibleBorders.Left := False;
if c<table.Rows[r].Count-1 then
table.Cells[r,c].VisibleBorders.Right := False;
end;
if r=0 then Continue;
table.Cells[r,1].VisibleBorders.Top := False;
table.Cells[r,0].VisibleBorders.Right := False;
table.Cells[r,0].VisibleBorders.Top := False;
end;
with MesText do
begin
AddNL('', 0, 0);
AddItem('', table);
//AddNL('', 0, 0);
Format;
VScrollPos := VScrollMax;
end;
end;
//===========================
// Drag'n'drop
//===========================
procedure TChatFrame.UserListMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
nn: TTreeNode;
begin
nn:=self.UserList.GetNodeAt(X, Y);
if (nn = nil) then Exit;
if Button = mbRight then self.UserList.Selected := nn;
if (Button = mbLeft) and (ssShift in Shift) then
begin
self.DragNode := nn;
//self.UserList.BeginDrag(false, 2);
self.UserList.BeginDrag(false);
CheckChanged:=true; // Äëÿ îòêëþ÷åíèÿ îáðàáîòêè OnClick
Exit;
end;
if Button<>mbLeft then Exit;
if not Page.PageInfo.bUseStateImages then Exit;
if (X > 0) and (X < 18) then
begin
CheckChanged:=true;
with nn do
begin
if StateIndex=ciCheckedIndex then StateIndex:=ciUncheckedIndex
else StateIndex:=ciCheckedIndex;
end;
end;
end;
function CanDrop(dst, src: TObject; X, Y: integer): boolean;
//var
//dst_node: TTreeNode;
begin
result:=false;
if (src is TTreeView) and (dst is TTreeView) then
begin
if src <> dst then Exit;
//dst_node:=((dst as TTreeView).GetNodeAt(X, Y) as TTreeNode);
//if dst_node = nil then Exit;
//if dst_node.ImageIndex <> 8 then Exit;
////if not dst_node.IsGroup then Exit;
result:=true;
end;
end;
procedure TChatFrame.UserListDragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
//if State = dsDragMove then
Accept := CanDrop(Sender, Source, X, Y);
//Accept:=true;
end;
procedure TChatFrame.UserListDragDrop(Sender, Source: TObject; X, Y: Integer);
var
dst_node: TTreeNode;
stv: TTreeView;
begin
if CanDrop(Sender, Source, X, Y) then
begin
stv:=(Sender as TTreeView);
dst_node:=stv.GetNodeAt(X,Y);
if dst_node = nil then
begin
DragNode.MoveTo(stv.Items.GetFirstNode(), naAdd);
end
else
begin
if dst_node.ImageIndex = ciGroupIndex then
DragNode.MoveTo(dst_node, naAddChild)
else
DragNode.MoveTo(dst_node, naInsert);
end;
stv.AlphaSort();
end;
end;
procedure TChatFrame.UserListClick(Sender: TObject);
var
dst_node: TTreeNode;
begin
dst_node:=(Sender as TTreeView).Selected;
if dst_node = nil then Exit;
if dst_node.ImageIndex = ciGroupIndex then Exit;
mInsertNameClick(Sender);
end;
procedure TChatFrame.UserListDblClick(Sender: TObject);
var
dst_node: TTreeNode;
begin
dst_node:=(Sender as TTreeView).Selected;
if dst_node = nil then Exit;
if dst_node.ImageIndex = ciGroupIndex then Exit;
InsertPrivate();
end;
procedure TChatFrame.SetNewFont();
begin
// óñòàíîâêà íîâûõ øðèôòîâ
MesText.Reformat();
with UserList do
begin
Font.Name:=MainConf['fntUserList_Name'];
Font.Size:=StrToIntDef(MainConf['fntUserList_Size'], Font.Size);
Repaint();
//Name:=MainConf.fntArray[2].Name;
//Size:=MainConf.fntArray[2].Size;
end;
with TxtToSend do
begin
Font.Name:=MainConf['fntTxtToSend_Name'];
Font.Size:=StrToIntDef(MainConf['fntTxtToSend_Size'], Font.Size);
Repaint();
//Name:=MainConf.fntArray[3].Name;
//Size:=MainConf.fntArray[3].Size;
end;
end;
procedure TChatFrame.CopyRusChar(Sender: TObject);
begin
MesText.CopyTextW;
{
RusChars.SelectAll;
RusChars.ClearSelection;
RusChars.Lines.Add(Clipboard.AsText);
RusChars.SelectAll;
RusChars.Font.Name := 'Tahoma';
RusChars.Font.Size := 8;
RusChars.SelAttributes.Charset := RUSSIAN_CHARSET;
RusChars.CopyToClipboard;
}
end;
procedure TChatFrame.TextWindowPopUpPopup(Sender: TObject);
begin
{ with MesText do
begin
mFreezeScrolling.Checked := not (rvoScrollToEnd in Options);
mHScroll.Checked := HScrollVisible;
end;}
end;
procedure TChatFrame.ToggleVScrollStop();
begin
with MesText do
begin
if actFreezeScrolling.Checked then
Options := Options-[rvoScrollToEnd]
else
Options := Options+[rvoScrollToEnd];
{if (rvoScrollToEnd in Options) then
Options := Options-[rvoScrollToEnd]
else
Options := Options+[rvoScrollToEnd];
mFreezeScrolling.Checked := not (rvoScrollToEnd in Options);
tbtnVScrollStop.Down := not (rvoScrollToEnd in Options);}
end;
end;