forked from Sharlikran/xEdit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JvRichEdit.pas
7805 lines (7075 loc) · 227 KB
/
JvRichEdit.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
{-----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1.1.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: JvRichEd.PAS, released on 2002-07-04.
The Initial Developers of the Original Code are: Fedor Koshevnikov, Igor Pavluk and Serge Korolev
Copyright (c) 1997, 1998 Fedor Koshevnikov, Igor Pavluk and Serge Korolev
Copyright (c) 2001,2002 SGB Software
Portions created by Sébastien Buysse are Copyright (C) 2001 Sébastien Buysse.
All Rights Reserved.
Contributor(s):
Polaris Software
Sébastien Buysse [sbuysse att buypin dott com] (original code in JvRichEdit.pas)
Michael Beck [mbeck att bigfoot dott com] (contributor to JvRichEdit.pas)
Roman Kovbasiouk [roko att users dott sourceforge dott net] (merging JvRichEdit.pas)
Remko Bonte [remkobonte att myrealbox dott com] (insert image procedures, MS Text converters)
Jacob Boerema [jgboerema att hotmail dott com] (indentation style, zoom, tab styles)
You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.delphi-jedi.org
Known Issues:
-----------------------------------------------------------------------------}
// $Id$
unit JvRichEdit;
{$I jvcl.inc}
{$I windowsonly.inc}
{$RANGECHECKS OFF}
interface
{$HPPEMIT '#define CHARFORMAT2A Richedit::CHARFORMAT2A'}
uses
{$IFDEF UNITVERSIONING}
JclUnitVersioning,
{$ENDIF UNITVERSIONING}
Windows, ActiveX, ComObj, CommCtrl, Messages, SysUtils, Classes, Controls,
OleCtnrs,
Forms, Graphics, StdCtrls, Dialogs, RichEdit, Menus, ComCtrls, SyncObjs,
JvExStdCtrls, JvTypes;
type
TJvCustomRichEdit = class;
TJvAttributeType = (atDefaultText, atSelected, atWord);
TJvConsistentAttribute = (caBold, caColor, caFace, caItalic, caSize,
caStrikeOut, caUnderline, caProtected, caOffset, caHidden, caCharset,
caLink, caBackColor, caDisabled, caWeight, caSubscript, caRevAuthor);
TJvConsistentAttributes = set of TJvConsistentAttribute;
TSubscriptStyle = (ssNone, ssSubscript, ssSuperscript);
TUnderlineType = (utNone, utSolid, utWord, utDouble, utDotted, utDash,
utDashDot, utDashDotDot, utWave, utThick);
TUnderlineColor = (ucBlack, ucBlue, ucAqua, ucLime, ucFuchsia, ucRed,
ucYellow, ucWhite, ucNavy, ucTeal, ucGreen, ucPurple, ucMaroon, ucOlive,
ucGray, ucSilver);
TJvTextAttributes = class(TPersistent)
private
FRichEdit: TJvCustomRichEdit;
FType: TJvAttributeType;
procedure AssignFont(Font: TFont);
procedure GetAttributes(var Format: TCharFormat2);
procedure SetAttributes(var Format: RichEdit.TCharFormat2);
function GetAttribute(const Flag: Integer): Boolean;
function GetBackColor: TColor;
function GetCharset: TFontCharset;
function GetColor: TColor;
function GetConsistentAttributes: TJvConsistentAttributes;
function GetDisabled: Boolean;
function GetHeight: Integer;
function GetHidden: Boolean;
function GetLink: Boolean;
function GetName: TFontName;
function GetOffset: Integer;
function GetPitch: TFontPitch;
function GetProtected: Boolean;
function GetRevAuthorIndex: Byte;
function GetSize: Integer;
function GetStyle: TFontStyles;
function GetSubscriptStyle: TSubscriptStyle;
function GetUnderlineColor: TUnderlineColor;
function GetUnderlineType: TUnderlineType;
procedure SetAttribute(const Flag: Integer; const Value: Boolean);
procedure SetBackColor(Value: TColor);
procedure SetCharset(Value: TFontCharset);
procedure SetColor(Value: TColor);
procedure SetDisabled(Value: Boolean);
procedure SetHeight(Value: Integer);
procedure SetHidden(Value: Boolean);
procedure SetLink(Value: Boolean);
procedure SetName(Value: TFontName);
procedure SetOffset(Value: Integer);
procedure SetPitch(Value: TFontPitch);
procedure SetProtected(Value: Boolean);
procedure SetRevAuthorIndex(Value: Byte);
procedure SetSize(Value: Integer);
procedure SetStyle(Value: TFontStyles);
procedure SetSubscriptStyle(Value: TSubscriptStyle);
procedure SetUnderlineColor(const Value: TUnderlineColor);
procedure SetUnderlineType(Value: TUnderlineType);
protected
procedure InitFormat(var Format: RichEdit.TCharFormat2);
procedure AssignTo(Dest: TPersistent); override;
public
constructor Create(AOwner: TJvCustomRichEdit; AttributeType: TJvAttributeType);
procedure Assign(Source: TPersistent); override;
property BackColor: TColor read GetBackColor write SetBackColor;
property Charset: TFontCharset read GetCharset write SetCharset;
property Color: TColor read GetColor write SetColor;
property ConsistentAttributes: TJvConsistentAttributes read GetConsistentAttributes;
property Disabled: Boolean read GetDisabled write SetDisabled;
property Height: Integer read GetHeight write SetHeight;
property Hidden: Boolean read GetHidden write SetHidden;
property Link: Boolean read GetLink write SetLink;
property Name: TFontName read GetName write SetName;
property Offset: Integer read GetOffset write SetOffset;
property Pitch: TFontPitch read GetPitch write SetPitch;
property Protected: Boolean read GetProtected write SetProtected;
property RevAuthorIndex: Byte read GetRevAuthorIndex write SetRevAuthorIndex;
property Size: Integer read GetSize write SetSize;
property Style: TFontStyles read GetStyle write SetStyle;
property SubscriptStyle: TSubscriptStyle read GetSubscriptStyle write SetSubscriptStyle;
property UnderlineColor: TUnderlineColor read GetUnderlineColor write SetUnderlineColor;
property UnderlineType: TUnderlineType read GetUnderlineType write SetUnderlineType;
property Bold: Boolean index CFE_BOLD read GetAttribute write SetAttribute;
property Italic: Boolean index CFE_ITALIC read GetAttribute write SetAttribute;
property Underline: Boolean index CFE_UNDERLINE read GetAttribute write SetAttribute;
property StrikeOut: Boolean index CFE_STRIKEOUT read GetAttribute write SetAttribute;
end;
TJvNumbering = (nsNone, nsBullet, nsArabicNumbers, nsLoCaseLetter,
nsUpCaseLetter, nsLoCaseRoman, nsUpCaseRoman);
TJvNumberingStyle = (nsParenthesis, nsPeriod, nsEnclosed, nsSimple);
TParaAlignment = (paLeftJustify, paRightJustify, paCenter, paJustify);
TLineSpacingRule = (lsSingle, lsOneAndHalf, lsDouble, lsSpecifiedOrMore,
lsSpecified, lsMultiple);
THeadingStyle = 0..9;
TParaTableStyle = (tsNone, tsTableRow, tsTableCellEnd, tsTableCell);
TJvIndentationStyle = (isRichEdit, isOffice); // added by J.G. Boerema
// TJvIndentationStyle: default is isRichEdit
// - isRichEdit: LefIndent relative to FirstIndent
// - isOffice: FirstIndent relative to LeftIndent (like MsWord and WordPad)
// For example when FirstIndent=2 and LeftIndent=1 the effect is:
// isRichEdit: first line starts at 2 and following lines at 3
// isOffice: first line starts at 3 and following lines at 1
// From Msdn PARAFORMAT info:
{
Rich Edit 2.0: For compatibility with TOM interfaces, you can use the eight
high-order bits to store additional information about each tab stop.
Bits 24-27 can specify one of the following values to indicate the tab alignment.
These bits do not affect the rich edit control display for versions earlier
than Rich Edit 3.0. [Note J.G.Boerema: This information is incorrect! At
least, my version of Rich Edit 3 shows all tabs as ordinary tabs.]
0 Ordinary tab
1 Center tab
2 Right-aligned tab
3 Decimal tab
4 Word bar tab (vertical bar)
Bits 28-31 can specify one of the following values to indicate the type of tab leader.
These bits do not affect the rich edit control display.
0 No leader
1 Dotted leader
2 Dashed leader
3 Underlined leader
4 Thick line leader
5 Double line leader
}
TJvTabAlignment =
(taOrdinary, taCenter, taRight, taDecimal, taVertical); // added by J.G. Boerema
// Note: if taVertical then tableader should be disabled according to Word
TJvTabLeader =
(tlNone, tlDotted, tlDashed, tlUnderlined, tlThick, tlDouble); // added by J.G. Boerema
TJvParaAttributes = class(TPersistent)
private
FRichEdit: TJvCustomRichEdit;
FIndentationStyle: TJvIndentationStyle; // added by J.G. Boerema
procedure GetAttributes(var Paragraph: TParaFormat2);
function GetAlignment: TParaAlignment;
function GetFirstIndent: Longint;
function GetHeadingStyle: THeadingStyle;
function GetLeftIndent: Longint;
function GetLineSpacing: Longint;
function GetLineSpacingRule: TLineSpacingRule;
function GetNumbering: TJvNumbering;
function GetNumberingStart: Integer;
function GetNumberingStyle: TJvNumberingStyle;
function GetNumberingTab: Word;
function GetRightIndent: Longint;
function GetSpaceAfter: Longint;
function GetSpaceBefore: Longint;
function GetTab(Index: Byte): Longint;
function GetTabCount: Integer;
function GetTableStyle: TParaTableStyle;
function GetTabAlignment(Index: Byte): TJvTabAlignment;
function GetTabLeader(Index: Byte): TJvTabLeader;
procedure SetAlignment(Value: TParaAlignment);
procedure SetAttributes(var Paragraph: TParaFormat2);
procedure SetFirstIndent(Value: Longint);
procedure SetHeadingStyle(Value: THeadingStyle);
procedure SetLeftIndent(Value: Longint);
procedure SetLineSpacing(Value: Longint);
procedure SetLineSpacingRule(Value: TLineSpacingRule);
procedure SetNumbering(Value: TJvNumbering);
procedure SetNumberingStart(const Value: Integer);
procedure SetNumberingStyle(Value: TJvNumberingStyle);
procedure SetNumberingTab(Value: Word);
procedure SetRightIndent(Value: Longint);
procedure SetSpaceAfter(Value: Longint);
procedure SetSpaceBefore(Value: Longint);
procedure SetTab(Index: Byte; Value: Longint);
procedure SetTabCount(Value: Integer);
procedure SetTableStyle(Value: TParaTableStyle);
procedure SetTabAlignment(Index: Byte; Value: TJvTabAlignment);
procedure SetTabLeader(Index: Byte; Value: TJvTabLeader);
protected
procedure InitPara(var Paragraph: TParaFormat2);
procedure AssignTo(Dest: TPersistent); override;
public
constructor Create(AOwner: TJvCustomRichEdit);
procedure Assign(Source: TPersistent); override;
property Alignment: TParaAlignment read GetAlignment write SetAlignment;
property FirstIndent: Longint read GetFirstIndent write SetFirstIndent;
property HeadingStyle: THeadingStyle read GetHeadingStyle write SetHeadingStyle;
property IndentationStyle: TJvIndentationStyle read FIndentationStyle write FIndentationStyle;
property LeftIndent: Longint read GetLeftIndent write SetLeftIndent;
property LineSpacing: Longint read GetLineSpacing write SetLineSpacing;
property LineSpacingRule: TLineSpacingRule read GetLineSpacingRule write SetLineSpacingRule;
property Numbering: TJvNumbering read GetNumbering write SetNumbering;
property NumberingStart: Integer read GetNumberingStart write SetNumberingStart;
property NumberingStyle: TJvNumberingStyle read GetNumberingStyle write SetNumberingStyle;
property NumberingTab: Word read GetNumberingTab write SetNumberingTab;
property RightIndent: Longint read GetRightIndent write SetRightIndent;
property SpaceAfter: Longint read GetSpaceAfter write SetSpaceAfter;
property SpaceBefore: Longint read GetSpaceBefore write SetSpaceBefore;
property Tab[Index: Byte]: Longint read GetTab write SetTab;
property TabCount: Integer read GetTabCount write SetTabCount;
property TableStyle: TParaTableStyle read GetTableStyle write SetTableStyle;
property TabAlignment[Index: Byte]: TJvTabAlignment read GetTabAlignment write SetTabAlignment;
property TabLeader[Index: Byte]: TJvTabLeader read GetTabLeader write SetTabLeader;
end;
TJvConversionKind = (ckImport, ckExport);
TJvConversionTextKind = (ctkText, ctkRTF, ctkBothPreferText, ctkBothPreferRTF);
{ (rb) Name TJvConverter is already taken, thus: }
TJvConversion = class(TObject)
private
FOnProgress: TNotifyEvent;
FParentWindow: THandle;
protected
FPercentDone: Integer;
procedure DoProgress(APercentDone: Integer);
public
function CanHandle(const AExtension: string; const AKind: TJvConversionKind): Boolean; overload; virtual;
function CanHandle(const AKind: TJvConversionKind): Boolean; overload; virtual;
function Filter: string; virtual;
function TextKind: TJvConversionTextKind; virtual;
function IsFormatCorrect(const AFileName: string): Boolean; overload; virtual;
function IsFormatCorrect(AStream: TStream): Boolean; overload; virtual;
function Open(const AFileName: string; const AKind: TJvConversionKind): Boolean; overload; virtual;
function Open(Stream: TStream; const AKind: TJvConversionKind): Boolean; overload; virtual;
procedure Init(AParentWindow: THandle); virtual;
procedure Done; virtual;
function Retry: Boolean; virtual;
function ConvertRead(Buffer: {$IFDEF COMPILER12_UP}PByte{$ELSE}PAnsiChar{$ENDIF COMPILER12_UP}; BufSize: Integer): Integer; virtual;
function ConvertWrite(Buffer: {$IFDEF COMPILER12_UP}PByte{$ELSE}PAnsiChar{$ENDIF COMPILER12_UP}; BufSize: Integer): Integer; virtual;
function UserCancel: Boolean; virtual;
function Error: Boolean; virtual;
function ErrorStr: string; virtual;
property OnProgress: TNotifyEvent read FOnProgress write FOnProgress;
property PercentDone: Integer read FPercentDone;
property ParentWindow: THandle read FParentWindow;
end;
TJvStreamConversion = class(TJvConversion)
private
FStream: TStream;
FSavedPosition: Int64;
FStreamSize: Integer;
FFreeStream: Boolean;
FBytesConverted: Integer;
public
function Open(const AFileName: string; const AKind: TJvConversionKind): Boolean; override;
function Open(Stream: TStream; const AKind: TJvConversionKind): Boolean; override;
procedure Done; override;
function Retry: Boolean; override;
function ConvertRead(Buffer: {$IFDEF COMPILER12_UP}PByte{$ELSE}PAnsiChar{$ENDIF COMPILER12_UP}; BufSize: Integer): Integer; override;
function ConvertWrite(Buffer: {$IFDEF COMPILER12_UP}PByte{$ELSE}PAnsiChar{$ENDIF COMPILER12_UP}; BufSize: Integer): Integer; override;
property Stream: TStream read FStream;
end;
TJvTextConversion = class(TJvStreamConversion)
public
function CanHandle(const AExtension: string; const AKind: TJvConversionKind): Boolean; override;
function Filter: string; override;
function TextKind: TJvConversionTextKind; override;
end;
TJvRTFConversion = class(TJvStreamConversion)
public
function CanHandle(const AExtension: string; const AKind: TJvConversionKind): Boolean; override;
function Filter: string; override;
function TextKind: TJvConversionTextKind; override;
function IsFormatCorrect(const AFileName: string): Boolean; override;
function IsFormatCorrect(AStream: TStream): Boolean; override;
end;
TJvOEMConversion = class(TJvStreamConversion)
public
function ConvertRead(Buffer: {$IFDEF COMPILER12_UP}PByte{$ELSE}PAnsiChar{$ENDIF COMPILER12_UP}; BufSize: Integer): Integer; override;
function ConvertWrite(Buffer: {$IFDEF COMPILER12_UP}PByte{$ELSE}PAnsiChar{$ENDIF COMPILER12_UP}; BufSize: Integer): Integer; override;
function TextKind: TJvConversionTextKind; override;
end;
FCE = Smallint; // File Conversion Error
{ typedef long (PASCAL *PFN_RTF)(long, long); }
PFN_RTF = function(I1, I2: Longint): Longint; stdcall;
{ long PASCAL InitConverter32(HANDLE hWnd, char *szModule); }
TInitConverter32 = function(hWnd: THandle; szModule: PAnsiChar): LongBool; stdcall;
{ void PASCAL UninitConverter(void); }
TUninitConverter = procedure; stdcall;
{ void PASCAL GetReadNames(HANDLE haszClass, HANDLE haszDescrip, HANDLE haszExt); }
TGetReadNames = procedure(haszClass, haszDescrip, haszExt: THandle); stdcall;
{ void PASCAL GetWriteNames(HANDLE haszClass, HANDLE haszDescrip, HANDLE haszExt); }
TGetWriteNames = procedure(haszClass, haszDescrip, haszExt: THandle); stdcall;
{ HGLOBAL PASCAL RegisterApp(unsigned long lFlags, void FAR *lpFuture); }
TRegisterApp = function(lFlags: DWORD; lpFuture: Pointer): HGLOBAL; stdcall;
{ FCE PASCAL IsFormatCorrect32(HANDLE ghszFile, HANDLE ghszClass); }
TIsFormatCorrect32 = function(ghszFile, ghszClass: THandle): FCE; stdcall;
{ FCE PASCAL ForeignToRtf32(HANDLE ghszFile, void *pstgForeign, HANDLE ghBuff, HANDLE ghszClass, HANDLE ghszSubset, PFN_RTF lpfnOut); }
TForeignToRtf32 = function(ghszFile: THandle; pstgForeign: Pointer; ghBuff, ghszClass, ghszSubset: THandle;
lpfnOut: PFN_RTF): FCE; stdcall;
{ FCE PASCAL RtfToForeign32(HANDLE ghszFile, void *pstgForeign, HANDLE ghBuff, HANDLE ghshClass, PFN_RTF lpfnIn); }
TRtfToForeign32 = function(ghszFile: THandle; pstgForeign: Pointer; ghBuff, ghshClass: THandle;
lpfnIn: PFN_RTF): FCE; stdcall;
{ long PASCAL CchFetchLpszError(long fce, char FAR *lpszError, long cb); }
TCchFetchLpszError = function(fce: Longint; lpszError: PAnsiChar; cb: Longint): Longint; stdcall;
{ long PASCAL FRegisterConverter(HANDLE hkeyRoot); }
TFRegisterConverter = function(hkeyRoot: THandle): Longint; stdcall;
TJvMSTextConversion = class(TJvConversion)
private
FConverterFileName: string;
FExtensions: TStringList;
FDescription: string;
FConverterKind: TJvConversionKind;
FConverter: HMODULE;
FInitConverter32: TInitConverter32;
FUninitConverter: TUninitConverter;
FIsFormatCorrect32: TIsFormatCorrect32;
FForeignToRtf32: TForeignToRtf32;
FRtfToForeign32: TRtfToForeign32;
FCchFetchLpszError: TCchFetchLpszError;
{ Indicates whether the thread is done }
FThreadDone: Boolean;
{ Indicates whether the conversion process has been cancelled by the
main thread }
FCancel: Boolean;
FBytesAvailable: Integer;
{ Buffer accessable by the converter dll }
FBuffer: HGLOBAL;
FBufferPtr: PAnsiChar;
FTempProgress: Integer;
{ Thread synchronization based on the source of Wordpad, see
http://cvs.wndtabs.com/cgi-bin/viewcvs/viewcvs.cgi/BCG/WordPad/
Import works as follows
Thread RichEdit
------ --------
loop: loop:
@@ Converter converts buffer1 @@ Copy buffer1 to buffer2
richedit processes buffer2
The @@ parts may not happen simultaneously, thus this is converted to:
Thread RichEdit
------ --------
loop: loop:
@@ Converter converts buffer1 [wait until thread ready]
[thread ready] @@ Copy buffer1 to buffer2
[wait until richedit ready] [richedit ready]
richedit retrieves data from buffer2
Export works as follows:
Thread RichEdit
------ --------
loop: loop:
@@ Converter converts buffer1 richedit puts data in buffer2
@@ Copy buffer2 to buffer1
The @@ parts may not happen simultaneously, thus this is converted to:
Thread RichEdit
------ --------
loop: loop:
[thread ready] richedit puts data in buffer2
[wait until richedit ready] [wait until thread ready]
@@ Converter converts buffer1 @@ Copy buffer2 to buffer1
[richedit ready]
- buffer1 is FBuffer
- buffer2 is the Buffer param from ConvertRead or ConvertWrite
}
FRichEditReady: TEvent;
FThreadReady: TEvent;
FConversionError: FCE;
FFileName: HMODULE;
FInitDone: Boolean;
protected
procedure LoadConverter;
procedure FreeConverter;
procedure Check(Result: FCE);
procedure DoError(ErrorCode: FCE);
{ Handled in the context of the thread: }
procedure DoConversion;
function HandleExportCallback(cchBuff, nPercent: Longint): Longint;
function HandleImportCallback(cchBuff, nPercent: Longint): Longint;
procedure WaitUntilThreadReady;
procedure WaitUntilRichEditReady;
procedure Lock;
procedure Unlock;
procedure InitConverter;
public
constructor Create(const AConverterFileName, AExtensions, ADescription: string;
const AKind: TJvConversionKind); virtual;
destructor Destroy; override;
function CanHandle(const AExtension: string; const AKind: TJvConversionKind): Boolean; override;
function CanHandle(const AKind: TJvConversionKind): Boolean; override;
function Open(const AFileName: string; const AKind: TJvConversionKind): Boolean; override;
procedure Done; override;
function TextKind: TJvConversionTextKind; override;
function Filter: string; override;
function IsFormatCorrect(const AFileName: string): Boolean; override;
function TranslateError(ErrorCode: FCE): string;
function ConvertRead(Buffer: {$IFDEF COMPILER12_UP}PByte{$ELSE}PAnsiChar{$ENDIF COMPILER12_UP}; BufSize: Integer): Integer; override;
function ConvertWrite(Buffer: {$IFDEF COMPILER12_UP}PByte{$ELSE}PAnsiChar{$ENDIF COMPILER12_UP}; BufSize: Integer): Integer; override;
function UserCancel: Boolean; override;
function Error: Boolean; override;
function ErrorStr: string; override;
end;
TUndoName = (unUnknown, unTyping, unDelete, unDragDrop, unCut, unPaste);
TRichSearchType = (stWholeWord, stMatchCase, stBackward, stSetSelection);
TRichSearchTypes = set of TRichSearchType;
TRichSelection = (stText, stObject, stMultiChar, stMultiObject);
TRichSelectionType = set of TRichSelection;
TRichLangOption = (rlAutoKeyboard, rlAutoFont, rlImeCancelComplete, rlImeAlwaysSendNotify);
TRichLangOptions = set of TRichLangOption;
TRichStreamFormat = (sfDefault, sfRichText, sfPlainText);
TRichStreamMode = (smSelection, smPlainRtf, smNoObjects, smUnicode);
TRichStreamModes = set of TRichStreamMode;
TRichDropEffect = (rdeCopy, rdeMove, rdeLink, rdeScroll);
TRichDropEffects = set of TRichDropEffect;
TRichEditURLClickEvent = procedure(Sender: TObject; const URLText: string;
Button: TMouseButton) of object;
TRichEditURLHoverEvent = procedure(Sender: TObject; const URLText: string) of object;
TRichEditProtectChangeEx = procedure(Sender: TObject; const Msg: TMessage;
StartPos, EndPos: Integer; var AllowChange: Boolean) of object;
TRichEditFindErrorEvent = procedure(Sender: TObject; const TextToFind: string) of object;
TRichEditFindCloseEvent = procedure(Sender: TObject; Dialog: TFindDialog) of object;
TRichEditProgressEvent = procedure(Sender: TObject; PercentDone: Integer) of object;
TRichEditDragAllowedEvent = procedure(Sender: TObject; ShiftState: TShiftState;
var AllowedEffects: TRichDropEffects; var Handled: Boolean) of object;
TRichEditGetDragDropEffectEvent = procedure(Sender: TObject; ShiftState: TShiftState;
var AllowedEffects: TRichDropEffects; var Handled: Boolean) of object;
TRichEditQueryAcceptData = procedure(Sender: TObject; const ADataObject: IDataObject;
var AFormat: TClipFormat; ClipboardOperationKind: Cardinal; Really: Boolean;
IconMetaPict: HGLOBAL; var Handled: Boolean) of object;
TJvCustomRichEdit = class(TJvExCustomMemo)
private
FHideScrollBars: Boolean;
FSelectionBar: Boolean;
FAutoURLDetect: Boolean;
FWordSelection: Boolean;
FPlainText: Boolean;
FSelAttributes: TJvTextAttributes;
FDefAttributes: TJvTextAttributes;
FWordAttributes: TJvTextAttributes;
FParagraph: TJvParaAttributes;
FOldParaAlignment: TParaAlignment;
FScreenLogPixels: Integer;
FUndoLimit: Integer;
FLines: TStrings;
FState: TObject;
FHideSelection: Boolean;
FLangOptions: TRichLangOptions;
FLinesUpdating: Boolean;
FPageRect: TRect;
FClickRange: TCharRange;
FClickBtn: TMouseButton;
FFindDialog: TFindDialog;
FReplaceDialog: TReplaceDialog;
FLastFind: TFindDialog;
FAllowObjects: Boolean;
FCallback: TObject;
FRichEditOle: IUnknown;
FPopupVerbMenu: TPopupMenu;
FTitle: string;
FAutoVerbMenu: Boolean;
FAllowInPlace: Boolean;
FDefaultConverter: TJvConversion;
FImageRect: TRect;
FAutoAdvancedTypography: Boolean;
FAdvancedTypography: Boolean;
FOLEDragDrop: Boolean;
FOnSelChange: TNotifyEvent;
FOnResizeRequest: TRichEditResizeEvent;
FOnProtectChange: TRichEditProtectChange;
FOnProtectChangeEx: TRichEditProtectChangeEx;
FOnSaveClipboard: TRichEditSaveClipboard;
FOnURLClick: TRichEditURLClickEvent;
FOnURLHover: TRichEditURLHoverEvent;
FOnTextNotFound: TRichEditFindErrorEvent;
FOnCloseFindDialog: TRichEditFindCloseEvent;
// From JvRichEdit.pas by Sébastien Buysse
FOnHorizontalScroll: TNotifyEvent;
FOnVerticalScroll: TNotifyEvent;
FOnConversionProgress: TRichEditProgressEvent;
FForceUndo: Boolean;
FUseFixedPopup: Boolean;
// From CCR
FOnInPlaceActivate: TNotifyEvent;
FOnInPlaceDeactivate: TNotifyEvent;
FOnDragAllowed: TRichEditDragAllowedEvent;
FOnGetDragDropEffect: TRichEditGetDragDropEffectEvent;
FOnQueryAcceptData: TRichEditQueryAcceptData;
function GetAdvancedTypography: Boolean;
function GetAutoURLDetect: Boolean;
function GetWordSelection: Boolean;
function GetLangOptions: TRichLangOptions;
function GetCanRedo: Boolean;
function GetCanPaste: Boolean;
function GetRedoName: TUndoName;
function GetUndoName: TUndoName;
function GetStreamFormat: TRichStreamFormat;
function GetStreamMode: TRichStreamModes;
function GetSelectionType: TRichSelectionType;
function GetZoom: Integer; // Added by J.G. Boerema
function IsAdvancedTypographyStored: Boolean;
procedure PopupVerbClick(Sender: TObject);
procedure ObjectPropsClick(Sender: TObject);
procedure CloseObjects;
procedure UpdateHostNames;
procedure SetAdvancedTypography(const Value: Boolean);
procedure SetAllowObjects(Value: Boolean);
procedure SetStreamFormat(Value: TRichStreamFormat);
procedure SetStreamMode(Value: TRichStreamModes);
procedure SetAutoURLDetect(Value: Boolean);
procedure SetWordSelection(Value: Boolean);
procedure SetHideScrollBars(Value: Boolean);
procedure SetHideSelection(Value: Boolean);
procedure SetTitle(const Value: string);
procedure SetLangOptions(Value: TRichLangOptions);
procedure SetRichEditStrings(Value: TStrings);
procedure SetDefAttributes(Value: TJvTextAttributes);
procedure SetSelAttributes(Value: TJvTextAttributes);
procedure SetWordAttributes(Value: TJvTextAttributes);
procedure SetSelectionBar(Value: Boolean);
procedure SetOLEDragDrop(const Value: Boolean);
procedure SetUndoLimit(Value: Integer);
procedure SetZoom(Value: Integer); // Added by J.G. Boerema
procedure UpdateTextModes(Plain: Boolean);
procedure UpdateTypographyOptions(const Advanced: Boolean);
procedure AdjustFindDialogPosition(Dialog: TFindDialog);
procedure SetupFindDialog(Dialog: TFindDialog; const SearchStr, ReplaceStr: string);
function FindEditText(Dialog: TFindDialog; AdjustPos, Events: Boolean): Boolean;
function GetCanFindNext: Boolean;
procedure FindDialogFind(Sender: TObject);
procedure NeedAdvancedTypography;
procedure ReplaceDialogReplace(Sender: TObject);
procedure SetSelText(const Value: string);
procedure FindDialogClose(Sender: TObject);
procedure SetUIActive(Active: Boolean);
procedure CMBiDiModeChanged(var Msg: TMessage); message CM_BIDIMODECHANGED;
procedure CMDocWindowActivate(var Msg: TMessage); message CM_DOCWINDOWACTIVATE;
procedure CMUIDeactivate(var Msg: TMessage); message CM_UIDEACTIVATE;
procedure CNNotify(var Msg: TWMNotify); message CN_NOTIFY;
procedure EMReplaceSel(var Msg: TMessage); message EM_REPLACESEL;
procedure WMDestroy(var Msg: TWMDestroy); message WM_DESTROY;
procedure WMMouseMove(var Msg: TMessage); message WM_MOUSEMOVE;
procedure WMPaint(var Msg: TWMPaint); message WM_PAINT;
procedure WMRButtonUp(var Msg: TMessage); message WM_RBUTTONUP;
procedure WMSetCursor(var Msg: TWMSetCursor); message WM_SETCURSOR;
procedure WMSetFont(var Msg: TWMSetFont); message WM_SETFONT;
procedure WMSetText(var Msg: TMessage); message WM_SETTEXT;
// From JvRichEdit.pas by Sébastien Buysse
procedure WMHScroll(var Msg: TWMHScroll); message WM_HSCROLL;
procedure WMVScroll(var Msg: TWMVScroll); message WM_VSCROLL;
function GetFlat: Boolean;
procedure SetFlat(const Value: Boolean);
function GetParentFlat: Boolean;
procedure SetParentFlat(const Value: Boolean);
protected
procedure ColorChanged; override;
procedure FontChanged; override;
function GetConverter(const AFileName: string; const Kind: TJvConversionKind): TJvConversion; overload;
function GetConverter(AStream: TStream; const Kind: TJvConversionKind): TJvConversion; overload;
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWindowHandle(const Params: TCreateParams); override;
procedure CreateWnd; override;
procedure DestroyWnd; override;
function GetPopupMenu: TPopupMenu; override;
{$IFDEF RTL220_UP}
procedure DoContextPopup(MousePos: TPoint; var Handled: Boolean); override;
{$ENDIF RTL220_UP}
procedure TextNotFound(Dialog: TFindDialog); virtual;
procedure RequestSize(const Rect: TRect); virtual;
procedure SelectionChange; dynamic;
function ProtectChange(const Msg: TMessage; StartPos, EndPos: Integer): Boolean; dynamic;
function SaveClipboard(NumObj, NumChars: Integer): Boolean; dynamic;
procedure URLClick(const URLText: string; Button: TMouseButton); dynamic;
procedure URLHover(const URLText: string); dynamic;
function DoDragAllowed(const ShiftState: TShiftState; var AllowedEffects: TRichDropEffects): Boolean; dynamic;
function DoGetDragDropEffect(const ShiftState: TShiftState; var Effects: TRichDropEffects): Boolean; dynamic;
function DoQueryAcceptData(const ADataObject: IDataObject; var AFormat: TClipFormat;
ClipboardOperationKind: Cardinal; Really: Boolean; IconMetaPict: HGLOBAL): Boolean; dynamic;
procedure SetPlainText(Value: Boolean); virtual;
procedure CloseFindDialog(Dialog: TFindDialog); virtual;
procedure DoSetMaxLength(Value: Integer); override;
procedure DoConversionProgress(const AProgress: Integer);
function GetSelLength: Integer; override;
function GetSelStart: Integer; override;
function GetSelText: string; override;
procedure SetSelLength(Value: Integer); override;
procedure SetSelStart(Value: Integer); override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
property AllowInPlace: Boolean read FAllowInPlace write FAllowInPlace default True;
property AutoAdvancedTypography: Boolean read FAutoAdvancedTypography write FAutoAdvancedTypography default True;
property AdvancedTypography: Boolean read GetAdvancedTypography write SetAdvancedTypography stored
IsAdvancedTypographyStored;
property AllowObjects: Boolean read FAllowObjects write SetAllowObjects default True;
property AutoURLDetect: Boolean read GetAutoURLDetect write SetAutoURLDetect default True;
property AutoVerbMenu: Boolean read FAutoVerbMenu write FAutoVerbMenu default True;
property HideSelection: Boolean read FHideSelection write SetHideSelection default True;
property HideScrollBars: Boolean read FHideScrollBars write SetHideScrollBars default True;
property Title: string read FTitle write SetTitle;
property LangOptions: TRichLangOptions read GetLangOptions write SetLangOptions default [rlAutoFont];
property Lines: TStrings read FLines write SetRichEditStrings;
property OLEDragDrop: Boolean read FOLEDragDrop write SetOLEDragDrop default True;
property PlainText: Boolean read FPlainText write SetPlainText default False;
property SelectionBar: Boolean read FSelectionBar write SetSelectionBar default True;
property StreamFormat: TRichStreamFormat read GetStreamFormat write SetStreamFormat default sfDefault;
property StreamMode: TRichStreamModes read GetStreamMode write SetStreamMode default [];
property UndoLimit: Integer read FUndoLimit write SetUndoLimit default 100;
property WordSelection: Boolean read GetWordSelection write SetWordSelection default True;
property ScrollBars default ssBoth;
property TabStop default True;
property SelText: string read GetSelText write SetSelText;
// Zoom: zoom in/out percentage (100=normal) note: no need to set default (100) in constructor.
property Zoom: Integer read GetZoom write SetZoom default 100;
property OnSaveClipboard: TRichEditSaveClipboard read FOnSaveClipboard
write FOnSaveClipboard;
property OnSelectionChange: TNotifyEvent read FOnSelChange write FOnSelChange;
property OnProtectChange: TRichEditProtectChange read FOnProtectChange
write FOnProtectChange; { obsolete }
property OnProtectChangeEx: TRichEditProtectChangeEx read FOnProtectChangeEx
write FOnProtectChangeEx;
property OnResizeRequest: TRichEditResizeEvent read FOnResizeRequest
write FOnResizeRequest;
property OnURLClick: TRichEditURLClickEvent read FOnURLClick write FOnURLClick;
// This event this is called as long as the Mouse moves over a link.
// To handle the first call only, check the current cursor handle.
// The RichEdit control 2.0 or higher sets the cursor to "HandPoint" when
// the Mouse is over a link and resets the cursor handle to the previous
// cursor on exit.
// so basically, you do this in your event handler:
//
// if HandpointCursorHandle = 0 then
// begin
// // Remember the handle of the "HandPoint" cursor (set by RichEdit 2.0 or higher)
// // Must be reset to 0 in JvRichEdit1MouseMove() after handle has changed.
// HandpointCursorHandle := Windows.GetCursor;
//
// // Do what you need when Mouse is the first time over a link
// end;
//
// then in OnMouseMove you do this to reset the global variable
//
// // "URLHover" event has been called then this value is <> 0
// if HandpointCursorHandle <> 0 then
// begin
// // Mouse is not over a link anymore than the cursor handle has changed
// if Windows.GetCursor <> HandpointCursorHandle then
// begin
// // Reset the cursor handle
// HandpointCursorHandle := 0;
//
// // Do what you need when Mouse is not over the link anymore
// end;
// end;
//
property OnURLHover: TRichEditURLHoverEvent read FOnURLHover write FOnURLHover;
property OnTextNotFound: TRichEditFindErrorEvent read FOnTextNotFound write FOnTextNotFound;
property OnCloseFindDialog: TRichEditFindCloseEvent read FOnCloseFindDialog
write FOnCloseFindDialog;
property OnConversionProgress: TRichEditProgressEvent read FOnConversionProgress write FOnConversionProgress;
// From JvRichEdit.pas by Sébastien Buysse
property OnVerticalScroll: TNotifyEvent read FOnVerticalScroll write FOnVerticalScroll;
property OnHorizontalScroll: TNotifyEvent read FOnHorizontalScroll write FOnHorizontalScroll;
property OnDragAllowed: TRichEditDragAllowedEvent read FOnDragAllowed write FOnDragAllowed;
property OnGetDragDropEffect: TRichEditGetDragDropEffectEvent read FOnGetDragDropEffect write FOnGetDragDropEffect;
property OnQueryAcceptData: TRichEditQueryAcceptData read FOnQueryAcceptData write FOnQueryAcceptData;
property ForceUndo: Boolean read FForceUndo write FForceUndo default True;
property UseFixedPopup: Boolean read FUseFixedPopup write FUseFixedPopup default True;
// from CCR
property OnInPlaceActivate: TNotifyEvent read FOnInPlaceActivate write FOnInPlaceActivate;
property OnInPlaceDeactivate: TNotifyEvent read FOnInPlaceDeactivate write FOnInPlaceDeactivate;
property Flat: Boolean read GetFlat write SetFlat default False;
property ParentFlat: Boolean read GetParentFlat write SetParentFlat default True;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Clear; override;
procedure SaveToImage(Picture: TPicture);
procedure InsertGraphic(AGraphic: TGraphic; const Sizeable: Boolean);
{ Same interface as TOleContainer }
procedure InsertLinkToFile(const FileName: string; Iconic: Boolean);
procedure InsertObject(const OleClassName: string; Iconic: Boolean);
procedure InsertObjectFromFile(const FileName: string; Iconic: Boolean);
procedure InsertObjectFromInfo(const Info: TCreateInfo);
// InsertFormatText inserts formatted text at the cursor position given by Index.
// If Index < 0, the text is inserted at the current SelStart position.
// S is the string to insert
// AFont is the font to use. If AFont = nil, then the current attributes at the insertion point are used.
// NOTE: this procedure does not reset the attributes after the call, i.e if you change the text color
// it will remain that color until you change it again.
procedure InsertFormatText(Index: Integer; const S: string; const AFont: TFont = nil); overload;
procedure InsertFormatText(Index: Integer; const S: string;
FontStyle: TFontStyles; const FontName: string = ''; const FontColor: TColor = clDefault; FontHeight: Integer = 0); overload;
// AddFormatText works just like InsertFormatText but always moves the insertion
// point to the end of the available text
procedure AddFormatText(const S: string; const AFont: TFont = nil); overload;
procedure AddFormatText(const S: string; FontStyle: TFontStyles; const FontName: string = ''; const FontColor: TColor = clDefault; FontHeight: Integer = 0); overload;
procedure SetSelection(StartPos, EndPos: Longint; ScrollCaret: Boolean);
function GetSelection: TCharRange;
function GetTextRange(StartPos, EndPos: Longint): string;
// GetTextLenEx is to be used when printing the RichEdit using EM_FORMATRANGE
// because GetTextLen is unreliable in this case.
// See Mantis 4782 and http://edn.embarcadero.com/article/26772 for details
function GetTextLenEx: Integer;
function CharFromPos(X, Y: Integer): Integer;
function LineFromChar(CharIndex: Integer): Integer;
function GetLineIndex(LineNo: Integer): Integer;
function GetLineLength(CharIndex: Integer): Integer;
function WordAtCursor: string;
function FindText(const SearchStr: string;
StartPos, Length: Integer; Options: TRichSearchTypes): Integer;
function GetSelTextBuf(Buffer: PChar; BufSize: Integer): Integer; override;
function GetCaretPos: TPoint; override;
function GetCharPos(CharIndex: Integer): TPoint;
function InsertObjectDialog: Boolean;
function ObjectPropertiesDialog: Boolean;
function PasteSpecialDialog: Boolean;
function FindDialog(const SearchStr: string): TFindDialog;
function ReplaceDialog(const SearchStr, ReplaceStr: string): TReplaceDialog;
function FindNext: Boolean;
procedure Print(const Caption: string); virtual;
class procedure RegisterConversionFormat(AConverter: TJvConversion);
class procedure RegisterMSTextConverters;
class function Filter(const AKind: TJvConversionKind): string;
procedure ClearUndo;
procedure Redo;
procedure StopGroupTyping;
procedure CloseActiveObject; // from CCR
procedure SetSelectionLink;
property CanFindNext: Boolean read GetCanFindNext;
property CanRedo: Boolean read GetCanRedo;
property CanPaste: Boolean read GetCanPaste;
property RedoName: TUndoName read GetRedoName;
property UndoName: TUndoName read GetUndoName;
property DefaultConverter: TJvConversion read FDefaultConverter write FDefaultConverter;
property DefAttributes: TJvTextAttributes read FDefAttributes write SetDefAttributes;
property SelAttributes: TJvTextAttributes read FSelAttributes write SetSelAttributes;
property WordAttributes: TJvTextAttributes read FWordAttributes write SetWordAttributes;
property PageRect: TRect read FPageRect write FPageRect;
property Paragraph: TJvParaAttributes read FParagraph;
property SelectionType: TRichSelectionType read GetSelectionType;
{>>>}
property RichEditOle: IUnknown
read FRichEditOle;
{<<<}
end;
{$IFDEF RTL230_UP}
[ComponentPlatformsAttribute(pidWin32 or pidWin64)]
{$ENDIF RTL230_UP}
TJvRichEdit = class(TJvCustomRichEdit)
published
property AdvancedTypography;
property Align;
property Alignment;
property AutoAdvancedTypography;
property AutoSize default False;
property AutoURLDetect;
property AutoVerbMenu;
property AllowObjects;
property AllowInPlace;
property Anchors;
property BevelEdges;
property BevelInner;
property BevelKind default bkNone;
property BevelOuter;
property BiDiMode;
property BorderWidth;
property DragKind;
property BorderStyle;
property ClipboardCommands;
property Color;
property DragCursor;
property DragMode;
property Enabled;
property Flat;
property Font;
property ForceUndo;
property HideSelection;
property HideScrollBars;
property HintColor;
property Title;
property ImeMode;
property ImeName;
property Constraints;
property ParentBiDiMode;
property LangOptions;
property Lines;
property MaxLength;
property OLEDragDrop;
property ParentColor;
property ParentFlat;
property ParentFont;
property ParentShowHint;
property PlainText;
property PopupMenu;
property ReadOnly;
property ScrollBars;
property SelectionBar;
property SelText;
property ShowHint;
property StreamFormat;
property StreamMode;
property TabOrder;
property TabStop;
property UndoLimit;
property UseFixedPopup;
property Visible;
property WantTabs;
property WantReturns;
property WordSelection;
property WordWrap;
property Zoom; // added by J.G. Boerema
property OnChange;
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnContextPopup;
property OnConversionProgress;
property OnEndDock;
property OnStartDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnMouseWheel;
property OnMouseWheelDown;
property OnMouseWheelUp;
property OnProtectChange; { obsolete }
property OnProtectChangeEx;
property OnResizeRequest;
property OnSaveClipboard;
property OnSelectionChange;
property OnStartDrag;
property OnTextNotFound;
property OnCloseFindDialog;
property OnDragAllowed;
property OnGetDragDropEffect;
property OnQueryAcceptData;
property OnURLClick;
property OnURLHover;
property OnMouseEnter;
property OnMouseLeave;
property OnParentColorChange;
property OnVerticalScroll;
property OnHorizontalScroll;
// From CCR
property OnInPlaceActivate;
property OnInPlaceDeactivate;
end;
var
RichEditVersion: Integer;
{ Two procedures to construct RTF from a bitmap. You can use this to
insert bitmaps in the rich edit control, for example:
Stream := TMemoryStream.Create;
try
BitmapToRTF(SomeBitmap, Stream);
Stream.Position := 0;
JvRichEdit1.StreamFormat := sfRichText;
JvRichEdit1.StreamMode := [smSelection, smPlainRtf];
JvRichEdit1.Lines.LoadFromStream(Stream);
finally
Stream.Free;
end;
But:
* if you stream out the RTF content of the rich edit control, the bitmaps
are *not* included. Use TJvRichEdit.InsertGraphic if you want the bitmaps
to be included in the RTF.
* TJvRichEdit.AllowObjects must be set to True.
* BitmapToRTF is the fastest, TJvRichEdit.InsertGraphic the slowest.
}
{ uses the \dibitmap identifier }
procedure BitmapToRTF(ABitmap: TBitmap; AStream: TStream);
{ uses the \wmetafile identifier }
function BitmapToRTF2(ABitmap: TBitmap; AStream: TStream): Boolean;
{$IFDEF UNITVERSIONING}
const
UnitVersioning: TUnitVersionInfo = (
RCSfile: '$URL$';
Revision: '$Revision$';
Date: '$Date$';
LogPath: 'JVCL\run'
);
{$ENDIF UNITVERSIONING}
implementation
uses
{$IFDEF HAS_UNIT_SYSTEM_UITYPES}
System.UITypes,
{$ENDIF HAS_UNIT_SYSTEM_UITYPES}
Types,
Printers, ComStrs, OleConst, OleDlg, Math, Registry, Contnrs,
{$IFDEF RTL200_UP}
CommDlg,
{$ENDIF RTL200_UP}
JclAnsiStrings, JclSysInfo,
JvThemes, JvConsts, JvResources, JvFixedEditPopUp;