• R/O
  • SSH
  • HTTPS

akdf: Commit


Commit MetaInfo

Revision541 (tree)
Time2021-04-10 08:01:27
Authorderekwildstar

Log Message

KRKExpertsD
¯¯¯¯¯¯¯¯¯¯¯

Incluído o form para configurar o parágrafo

KX.Documentation
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

Incluídas mais ações padrão e o menu de contexto para alterar propriedades do parágrafo
Criado método para ressetar configurações do RichEdit

KRK.ExtendedActions
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

Registradas mais ações padrão

KRKLib
¯¯¯¯¯¯

Adicionado o arquivo KRK.Vcl.ComCtrls.Helpers.pas
Adicionado o arquivo KRK.Vcl.ExtActns.Helpers.pas

Change Summary

Incremental Difference

--- trunk/dtp/Experts/prj/Delphi 26 (Delphi Rio)/KRKExpertsD.dpk (revision 540)
+++ trunk/dtp/Experts/prj/Delphi 26 (Delphi Rio)/KRKExpertsD.dpk (revision 541)
@@ -30,7 +30,8 @@
3030 {$IMPLICITBUILD ON}
3131
3232 requires
33- KRKLib;
33+ KRKLib,
34+ VclSmp;
3435
3536 contains
3637 KX in '..\..\src\KX.pas',
@@ -47,6 +48,7 @@
4748 KX.About in '..\..\src\KX.About.pas' {FormAbout},
4849 KX.IDEInsightItems in '..\..\src\D21+\KX.IDEInsightItems.pas' {DAMOIDEInsightItems: TDataModule},
4950 KX.FindMyPackage in '..\..\src\FindMyPackage\KX.FindMyPackage.pas' {FormFindMyPackage},
50- KX.Documentation in '..\..\src\D14+\EditorSubViews\KX.Documentation.pas' {FRAMDocumentation: TFrame};
51+ KX.Documentation in '..\..\src\D14+\EditorSubViews\KX.Documentation.pas' {FRAMDocumentation: TFrame},
52+ KX.Documentation.ParagraphProperties in '..\..\src\D14+\EditorSubViews\KX.Documentation.ParagraphProperties.pas' {KFRMParagraphProperties: TKRKForm};
5153
5254 end.
--- trunk/dtp/Experts/prj/Delphi 26 (Delphi Rio)/KRKExpertsD.dproj (revision 540)
+++ trunk/dtp/Experts/prj/Delphi 26 (Delphi Rio)/KRKExpertsD.dproj (revision 541)
@@ -49,13 +49,13 @@
4949 <BT_BuildType>Debug</BT_BuildType>
5050 <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
5151 <VerInfo_Locale>1033</VerInfo_Locale>
52- <DCC_UsePackage>rtl;KRKCustomModulesR;KRKOTAComponentsR;PNGComponentsR;KRKLib;$(DCC_UsePackage)</DCC_UsePackage>
52+ <DCC_UsePackage>rtl;KRKCustomModulesR;KRKOTAComponentsR;PNGComponentsR;KRKLib;VclSmp;$(DCC_UsePackage)</DCC_UsePackage>
5353 <Debugger_HostApplication>C:\Program Files (x86)\Embarcadero\Studio\20.0\bin\bds.exe</Debugger_HostApplication>
5454 <Debugger_RunParams>-r KRKExperts</Debugger_RunParams>
5555 <Debugger_DebugSourcePath>D:\Desenvolvimento\Delphi\Componentes\PNGComponents\src\;$(Debugger_DebugSourcePath)</Debugger_DebugSourcePath>
5656 </PropertyGroup>
5757 <PropertyGroup Condition="'$(Base_Win64)'!=''">
58- <DCC_UsePackage>rtl;$(DCC_UsePackage)</DCC_UsePackage>
58+ <DCC_UsePackage>rtl;VclSmp;$(DCC_UsePackage)</DCC_UsePackage>
5959 </PropertyGroup>
6060 <ItemGroup>
6161 <DelphiCompile Include="$(MainSource)">
@@ -62,6 +62,7 @@
6262 <MainSource>MainSource</MainSource>
6363 </DelphiCompile>
6464 <DCCReference Include="KRKLib.dcp"/>
65+ <DCCReference Include="VclSmp.dcp"/>
6566 <DCCReference Include="..\..\src\KX.pas"/>
6667 <DCCReference Include="..\..\src\KX.Main.pas">
6768 <Form>KODMMain</Form>
@@ -117,6 +118,11 @@
117118 <FormType>dfm</FormType>
118119 <DesignClass>TFrame</DesignClass>
119120 </DCCReference>
121+ <DCCReference Include="..\..\src\D14+\EditorSubViews\KX.Documentation.ParagraphProperties.pas">
122+ <Form>KFRMParagraphProperties</Form>
123+ <FormType>dfm</FormType>
124+ <DesignClass>TKRKForm</DesignClass>
125+ </DCCReference>
120126 <BuildConfiguration Include="Base">
121127 <Key>Base</Key>
122128 </BuildConfiguration>
--- trunk/dtp/Experts/src/D14+/EditorSubViews/KX.Documentation.ParagraphProperties.pas (nonexistent)
+++ trunk/dtp/Experts/src/D14+/EditorSubViews/KX.Documentation.ParagraphProperties.pas (revision 541)
@@ -0,0 +1,91 @@
1+unit KX.Documentation.ParagraphProperties;
2+
3+{ Anak Krakatoa Form. Copyright Zetta-Ømnis Soluções Tecnológicas Ltda }
4+
5+interface
6+
7+uses
8+ Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, KRK.Vcl.Forms,
9+ Vcl.StdCtrls, Vcl.ExtCtrls, KRK.Vcl.ExtCtrls, Vcl.Samples.Spin;
10+
11+type
12+ TKFRMParagraphProperties = class(TKRKForm)
13+ GRBXLists: TGroupBox;
14+ SPEDParagraphNumberingTab: TSpinEdit;
15+ LABEParagraphNumberingTab: TLabel;
16+ GRBXParagrahSpacing: TGroupBox;
17+ SPEDSpacingBefore: TSpinEdit;
18+ SPEDSpacingAfter: TSpinEdit;
19+ LABESpacingBefore: TLabel;
20+ LABESpacingAfter: TLabel;
21+ SPEDStartIndent: TSpinEdit;
22+ LABEStartIndent: TLabel;
23+ SPEDRightIndent: TSpinEdit;
24+ LABERightIndent: TLabel;
25+ LABEOffset: TLabel;
26+ SPEDOffset: TSpinEdit;
27+ procedure KRKFormOkButtonClick(Sender: TObject);
28+ procedure KRKFormCancelButtonClick(Sender: TObject);
29+ procedure KRKFormClose(Sender: TObject; var Action: TCloseAction);
30+ procedure KRKFormShow(Sender: TObject);
31+ private
32+ { Declarações privadas }
33+ protected
34+ { Declarações protegidas }
35+ public
36+ { Declarações públicas }
37+ class procedure ShowMe(AOwner: TComponent);
38+ end;
39+
40+implementation
41+
42+uses
43+ KX.Documentation, KRK.Vcl.ComCtrls.Helpers;
44+
45+{$R *.dfm}
46+
47+{ TKFRMParagraphProperties }
48+
49+procedure TKFRMParagraphProperties.KRKFormCancelButtonClick(Sender: TObject);
50+begin
51+ ModalResult := mrCancel;
52+end;
53+
54+procedure TKFRMParagraphProperties.KRKFormClose(Sender: TObject; var Action: TCloseAction);
55+begin
56+ Action := caFree;
57+end;
58+
59+procedure TKFRMParagraphProperties.KRKFormOkButtonClick(Sender: TObject);
60+begin
61+ ModalResult := mrOk;
62+end;
63+
64+procedure TKFRMParagraphProperties.KRKFormShow(Sender: TObject);
65+begin
66+ SPEDParagraphNumberingTab.Value := TFRAMDocumentation(Owner).RIEDDocumentation.ParagraphNumberingTab;
67+ SPEDSpacingAfter.Value := TFRAMDocumentation(Owner).RIEDDocumentation.ParagraphSpacingAfter;
68+ SPEDSpacingBefore.Value := TFRAMDocumentation(Owner).RIEDDocumentation.ParagraphSpacingBefore;
69+ SPEDStartIndent.Value := TFRAMDocumentation(Owner).RIEDDocumentation.ParagraphStartIndent;
70+ SPEDRightIndent.Value := TFRAMDocumentation(Owner).RIEDDocumentation.ParagraphRightIndent;
71+ SPEDOffset.Value := TFRAMDocumentation(Owner).RIEDDocumentation.ParagraphOffset;
72+end;
73+
74+class procedure TKFRMParagraphProperties.ShowMe(AOwner: TComponent);
75+begin
76+ with Self.Create(AOwner) do
77+ if ShowModal = mrOk then
78+ begin
79+ TFRAMDocumentation(Owner).RIEDDocumentation.ParagraphNumberingTab := SPEDParagraphNumberingTab.Value;
80+ TFRAMDocumentation(Owner).RIEDDocumentation.ParagraphSpacingAfter := SPEDSpacingAfter.Value;
81+ TFRAMDocumentation(Owner).RIEDDocumentation.ParagraphSpacingBefore := SPEDSpacingBefore.Value;
82+ TFRAMDocumentation(Owner).RIEDDocumentation.ParagraphStartIndent := SPEDStartIndent.Value;
83+ TFRAMDocumentation(Owner).RIEDDocumentation.ParagraphRightIndent := SPEDRightIndent.Value;
84+ TFRAMDocumentation(Owner).RIEDDocumentation.ParagraphOffset := SPEDOffset.Value;
85+ end;
86+end;
87+
88+initialization
89+ RegisterClass(TKFRMParagraphProperties)
90+
91+end.
\ No newline at end of file
--- trunk/dtp/Experts/src/D14+/EditorSubViews/KX.Documentation.pas (revision 540)
+++ trunk/dtp/Experts/src/D14+/EditorSubViews/KX.Documentation.pas (revision 541)
@@ -9,8 +9,9 @@
99 Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
1010 Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ComCtrls,
1111 System.ImageList, Vcl.ImgList, Vcl.StdActns, System.Actions, Vcl.ActnList,
12- KRK.Vcl.ExtActns, Vcl.ExtActns, UPngImageList, Vcl.ToolWin, Vcl.ActnMan,
13- Vcl.ActnCtrls, Vcl.ExtCtrls, Contnrs, ToolsApi;
12+ Vcl.ExtActns, UPngImageList, Vcl.ToolWin, Vcl.ActnMan,
13+ Vcl.ActnCtrls, Vcl.ExtCtrls, KRK.Vcl.ExtActns, Contnrs, ToolsApi, Vcl.Menus,
14+ Vcl.ActnPopup, Vcl.PlatformDefaultStyleActnCtrls;
1415
1516 type
1617 TDocument = class
@@ -53,11 +54,11 @@
5354 REIT: TRichEditItalic;
5455 REUL: TRichEditUnderline;
5556 RESO: TRichEditStrikeOut;
56- REBU: TRichEditBullets;
57+ REBU: TRichEditPNBullets;
5758 REAL: TRichEditAlignLeft;
5859 REAR: TRichEditAlignRight;
5960 REAC: TRichEditAlignCenter;
60- REAJ: TRichEditAlignJustified;
61+ REAJ: TRichEditPAJustified;
6162 TOBUBold: TToolButton;
6263 TOBUItalic: TToolButton;
6364 TOBUSelectAll: TToolButton;
@@ -66,7 +67,6 @@
6667 TOBUSeparator2: TToolButton;
6768 TOBUStrikeOut: TToolButton;
6869 TOBUSeparator3: TToolButton;
69- TOBUBullets: TToolButton;
7070 STBU: TStatusBar;
7171 TOBUAlignLeft: TToolButton;
7272 TOBUAlignCenter: TToolButton;
@@ -79,6 +79,30 @@
7979 TOBUSeparator4: TToolButton;
8080 RERD: TRichEditRedo;
8181 TOBURedo: TToolButton;
82+ REAN: TRichEditPNArabicNumbers;
83+ TOBUList: TToolButton;
84+ PUABList: TPopupActionBar;
85+ MNUIBullets: TMenuItem;
86+ MNUIArabicNumbers: TMenuItem;
87+ RESL: TRichEditPNSmallLetters;
88+ RECL: TRichEditPNCapitalLetters;
89+ RESR: TRichEditPNSmallRomanNumbers;
90+ RECR: TRichEditPNCapitalRomanNumbers;
91+ MNUISmallLetters: TMenuItem;
92+ MNUICapitalLetters: TMenuItem;
93+ MNUISmallRomanNumbers: TMenuItem;
94+ MNUICapitalRomanNumbers: TMenuItem;
95+ RESP: TRichEditPNSParen;
96+ RESS: TRichEditPNSParens;
97+ N1: TMenuItem;
98+ MNUIARightParenthesis1: TMenuItem;
99+ MNUIEnclosedBetweenParentheses: TMenuItem;
100+ RESD: TRichEditPNSPeriod;
101+ RESA: TRichEditPNSPlain;
102+ MNUIASingleDot: TMenuItem;
103+ MNUINothing: TMenuItem;
104+ PUAB: TPopupActionBar;
105+ MNUIParagraphProperties: TMenuItem;
82106 procedure ACLIUpdate(Action: TBasicAction; var Handled: Boolean);
83107 procedure RIEDDocumentationSelectionChange(Sender: TObject);
84108 procedure COBOFontColorChange(Sender: TObject);
@@ -85,6 +109,8 @@
85109 procedure CBBXFontNameChange(Sender: TObject);
86110 procedure CBBXFontSizeChange(Sender: TObject);
87111 procedure RIEDDocumentationChange(Sender: TObject);
112+ procedure TOBAClick(Sender: TObject);
113+ procedure MNUIParagraphPropertiesClick(Sender: TObject);
88114 private
89115 { Private declarations }
90116 FDocumentation: TDocumentation;
@@ -113,12 +139,18 @@
113139 procedure ApplyAdvancedTypography;
114140 end;
115141
142+ TRichEditHelper = class helper for TRichEdit
143+ public
144+ procedure ResetToDefaults;
145+ end;
146+
116147 implementation
117148
118149 {$R *.dfm}
119150
120-uses KX.EditorSubViews
121- , RichEdit;
151+uses
152+ RichEdit, KRK.Vcl.ComCtrls.Helpers, KX.EditorSubViews,
153+ KX.Documentation.ParagraphProperties;
122154
123155 procedure TFRAMDocumentation.ACLIUpdate(Action: TBasicAction; var Handled: Boolean);
124156 begin
@@ -128,6 +160,24 @@
128160 STBU.Panels[0].Text := '';
129161
130162 STBU.Panels[2].Text := Application.Hint;
163+
164+ // Apenas quando o controle relacionado a ação é mostrado na tela o método
165+ // UpdateTarget da ação é executado e o status de checked pode ser lido. Isso
166+ // é perfeito para economizar recursos, mas impede o uso facilitado do botão
167+ // com popup, o qual precisa ficar marcado quando qualquer um de seus itens
168+ // está marcado e ter como ação padrão aquela que está marcada. Eu não achei
169+ // um meio de fazer isso a não ser como abaixo. O método update executa muitas
170+ // vezes. Isso significa que verificar ParagraphNumbering aqui vai gerar
171+ // muitas mensagens e não sei se isso é bom
172+
173+ case RIEDDocumentation.ParagraphNumbering of
174+ pnBullet: TOBUList.Action := REBU;
175+ pnArabicNumbers: TOBUList.Action := REAN;
176+ pnSmallLetters: TOBUList.Action := RESL;
177+ pnCapitalLetters: TOBUList.Action := RECL;
178+ pnSmallRomanNumbers: TOBUList.Action := RESR;
179+ pnCapitalRomanNumbers: TOBUList.Action := RECR;
180+ end;
131181 end;
132182 // Para que o alinhamento justificado seja efetivo, precisamos habilitar a
133183 // tipografia avançada. Isso habilita outras coisas também. Pesquise sobre
@@ -134,7 +184,7 @@
134184 // EM_SETTYPOGRAPHYOPTIONS no MSDN
135185 procedure TFRAMDocumentation.ApplyAdvancedTypography;
136186 begin
137- SendMessage(RIEDDocumentation.Handle, EM_SETTYPOGRAPHYOPTIONS, TO_ADVANCEDTYPOGRAPHY, TO_ADVANCEDTYPOGRAPHY);
187+ KRK.Vcl.ExtActns.ApplyAdvancedTypography(RIEDDocumentation.Handle);
138188 end;
139189
140190 procedure TFRAMDocumentation.CBBXFontNameChange(Sender: TObject);
@@ -212,7 +262,7 @@
212262 else if FileExists(AFileName) then
213263 begin
214264 LoadFromFile(AFileName);
215- FDocumentation.Add(AModule,GetContents);
265+ FCurrentDocument := FDocumentation.Add(AModule,GetContents);
216266 end
217267 // Caso não haja nem documento na lista de documentos e nem arquivo, cria
218268 // uma entrada na lista de documentos, com conteúdo vazio e limpa o conteúdo
@@ -239,6 +289,7 @@
239289 SS := TStringStream.Create(FCurrentDocument.FContents);
240290 try
241291 SS.Seek(0,soFromBeginning);
292+ RIEDDocumentation.ResetToDefaults;
242293 RIEDDocumentation.Lines.LoadFromStream(SS); // isso gera OnChange
243294 finally
244295 SS.Free;
@@ -248,9 +299,15 @@
248299
249300 procedure TFRAMDocumentation.LoadFromFile(AFileName: String);
250301 begin
302+ RIEDDocumentation.ResetToDefaults;
251303 RIEDDocumentation.Lines.LoadFromFile(AFileName);
252304 end;
253305
306+procedure TFRAMDocumentation.MNUIParagraphPropertiesClick(Sender: TObject);
307+begin
308+ TKFRMParagraphProperties.ShowMe(Self);
309+end;
310+
254311 procedure TFRAMDocumentation.PasteFromClipboard;
255312 begin
256313 RIEDDocumentation.PasteFromClipboard;
@@ -280,6 +337,9 @@
280337 CBBXFontName.ItemIndex := CBBXFontName.Items.IndexOf(RIEDDocumentation.SelAttributes.Name);
281338 COBOFontColor.Selected := RIEDDocumentation.SelAttributes.Color;
282339 CBBXFontSize.ItemIndex := CBBXFontSize.Items.IndexOf(IntToStr(RIEDDocumentation.SelAttributes.Size));
340+
341+ PUABList.UpdateAction(REBU);
342+ PUABList.UpdateAction(REAN);
283343 end;
284344
285345 procedure TFRAMDocumentation.SaveDocument(AModule: IOTAModule);
@@ -303,6 +363,11 @@
303363 RIEDDocumentation.SelectAll;
304364 end;
305365
366+procedure TFRAMDocumentation.TOBAClick(Sender: TObject);
367+begin
368+ RIEDDocumentation.Redo
369+end;
370+
306371 procedure TFRAMDocumentation.Undo;
307372 begin
308373 RIEDDocumentation.Undo;
@@ -347,4 +412,20 @@
347412 Result := TDocument(O);
348413 end;
349414
415+{ TRichEditHelper }
416+
417+procedure TRichEditHelper.ResetToDefaults;
418+begin
419+ SelAttributes.Style := [];
420+ ParagraphNumbering := pnNone;
421+ ParagraphNumberingStyle := pnsParen;
422+ ParagraphNumberingTab := 0;
423+ ParagraphAlignment := paJustified;
424+ ParagraphStartIndent := 10;
425+ ParagraphRightIndent := 0;
426+ ParagraphOffset := -10;
427+ ParagraphSpacingAfter := 10;
428+ ParagraphSpacingBefore := 0;
429+end;
430+
350431 end.
--- trunk/dtp/ExtendedActions/src/KRK.ExtendedActions.pas (revision 540)
+++ trunk/dtp/ExtendedActions/src/KRK.ExtendedActions.pas (revision 541)
@@ -42,7 +42,18 @@
4242 // parâmetro e reinstale. Após as alterações terem sido feitas em
4343 // TActionResources elas ficarão salvas no DFM e não será necessário realizar
4444 // o procedimento acima, apenas instalar normalmente
45- RegisterActions('Format',[TRichEditAlignJustified],TActionResources);
45+ RegisterActions('Format',[TRichEditPAJustified],TActionResources);
46+ RegisterActions('Format',[TRichEditPNBullets],TActionResources);
47+ RegisterActions('Format',[TRichEditPNArabicNumbers],TActionResources);
48+ RegisterActions('Format',[TRichEditPNSmallLetters],TActionResources);
49+ RegisterActions('Format',[TRichEditPNCapitalLetters],TActionResources);
50+ RegisterActions('Format',[TRichEditPNSmallRomanNumbers],TActionResources);
51+ RegisterActions('Format',[TRichEditPNCapitalRomanNumbers],TActionResources);
52+ RegisterActions('Format',[TRichEditPNSParen],TActionResources);
53+ RegisterActions('Format',[TRichEditPNSParens],TActionResources);
54+ RegisterActions('Format',[TRichEditPNSPeriod],TActionResources);
55+ RegisterActions('Format',[TRichEditPNSPlain],TActionResources);
56+
4657 RegisterActions('Edit',[TRichEditRedo],TActionResources);
4758 end;
4859
--- trunk/rtp/prj/Delphi 26 (Delphi Rio)/KRKLib.dpk (revision 540)
+++ trunk/rtp/prj/Delphi 26 (Delphi Rio)/KRKLib.dpk (revision 541)
@@ -25,7 +25,6 @@
2525 {$IMAGEBASE $400000}
2626 {$ENDIF IMPLICITBUILDING}
2727 {$DESCRIPTION 'Anak Krakatoa Library'}
28-{$LIBPREFIX ''}
2928 {$LIBSUFFIX '260'}
3029 {$RUNONLY}
3130 {$IMPLICITBUILD OFF}
@@ -148,6 +147,8 @@
148147 KRK.Xml.MsXml5 in '..\..\src\Xml\KRK.Xml.MsXml5.pas',
149148 KRK.Xml.CryptXml.Utilities in '..\..\src\Xml\KRK.Xml.CryptXml.Utilities.pas',
150149 KRK.Xml.CryptXml in '..\..\src\Xml\KRK.Xml.CryptXml.pas',
151- KRK.ToolsApi.Components.ModuleNotifier in '..\..\src\ToolsAPI\Components\KRK.ToolsApi.Components.ModuleNotifier.pas';
150+ KRK.ToolsApi.Components.ModuleNotifier in '..\..\src\ToolsAPI\Components\KRK.ToolsApi.Components.ModuleNotifier.pas',
151+ KRK.Vcl.ComCtrls.Helpers in '..\..\src\Vcl\KRK.Vcl.ComCtrls.Helpers.pas',
152+ KRK.Vcl.ExtActns.Helpers in '..\..\src\Vcl\KRK.Vcl.ExtActns.Helpers.pas';
152153
153154 end.
--- trunk/rtp/prj/Delphi 26 (Delphi Rio)/KRKLib.dproj (revision 540)
+++ trunk/rtp/prj/Delphi 26 (Delphi Rio)/KRKLib.dproj (revision 541)
@@ -31,6 +31,7 @@
3131 <SanitizedProjectName>KRKLib</SanitizedProjectName>
3232 <VerInfo_Locale>1046</VerInfo_Locale>
3333 <VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName=;CFBundleDisplayName=;UIDeviceFamily=;CFBundleIdentifier=;CFBundleVersion=;CFBundlePackageType=;CFBundleSignature=;CFBundleAllowMixedLocalizations=;UISupportedInterfaceOrientations=;CFBundleExecutable=;CFBundleResourceSpecification=;LSRequiresIPhoneOS=;CFBundleInfoDictionaryVersion=;CFBundleDevelopmentRegion=;package=;label=;versionCode=;versionName=;persistent=;restoreAnyVersion=;installLocation=;largeHeap=;theme=</VerInfo_Keys>
34+ <DCC_OutputDRCFile>true</DCC_OutputDRCFile>
3435 </PropertyGroup>
3536 <PropertyGroup Condition="'$(Base_Win32)'!=''">
3637 <BT_BuildType>Debug</BT_BuildType>
@@ -172,6 +173,8 @@
172173 <DCCReference Include="..\..\src\Xml\KRK.Xml.CryptXml.Utilities.pas"/>
173174 <DCCReference Include="..\..\src\Xml\KRK.Xml.CryptXml.pas"/>
174175 <DCCReference Include="..\..\src\ToolsAPI\Components\KRK.ToolsApi.Components.ModuleNotifier.pas"/>
176+ <DCCReference Include="..\..\src\Vcl\KRK.Vcl.ComCtrls.Helpers.pas"/>
177+ <DCCReference Include="..\..\src\Vcl\KRK.Vcl.ExtActns.Helpers.pas"/>
175178 <BuildConfiguration Include="Base">
176179 <Key>Base</Key>
177180 </BuildConfiguration>
--- trunk/rtp/src/Vcl/KRK.Vcl.ComCtrls.Helpers.pas (nonexistent)
+++ trunk/rtp/src/Vcl/KRK.Vcl.ComCtrls.Helpers.pas (revision 541)
@@ -0,0 +1,360 @@
1+unit KRK.Vcl.ComCtrls.Helpers;
2+
3+interface
4+
5+uses
6+ ComCtrls;
7+
8+type
9+ TParagraphNumbering = (pnNone, pnBullet, pnArabicNumbers, pnSmallLetters, pnCapitalLetters, pnSmallRomanNumbers, pnCapitalRomanNumbers, pnUnicodeCharacterSequence);
10+ TParagraphAlignment = (paLeft = 1, paRight = 2, paCentered = 3, paJustified = 4);
11+ TParagraphNumberingStyle = (pnsParen,pnsParens,pnsPeriod,pnsPlain);
12+
13+ TCustomRichEditHelper = class helper for TCustomRichEdit
14+ private
15+ function GetParagraphNumbering: TParagraphNumbering;
16+ procedure SetParagraphNumbering(const AValue: TParagraphNumbering);
17+ function GetParagraphAlignment: TParagraphAlignment;
18+ procedure SetParagraphAlignment(const AValue: TParagraphAlignment);
19+ function GetParagraphNumberingStyle: TParagraphNumberingStyle;
20+ procedure SetParagraphNumberingStyle(const AValue: TParagraphNumberingStyle);
21+ function GetParagraphNumberingTab: Byte;
22+ procedure SetParagraphNumberingTab(const AValue: Byte);
23+ function GetParagraphSpacingAfter: Byte;
24+ procedure SetParagraphSpacingAfter(const AValue: Byte);
25+ function GetParagraphSpacingBefore: Byte;
26+ procedure SetParagraphSpacingBefore(const AValue: Byte);
27+ function GetParagraphOffset: SmallInt;
28+ function GetParagraphRightIndent: Byte;
29+ function GetParagraphStartIndent: Byte;
30+ procedure SetParagraphOffset(const AValue: SmallInt);
31+ procedure SetParagraphRightIndent(const AValue: Byte);
32+ procedure SetParagraphStartIndent(const AValue: Byte);
33+ public
34+ function CanRedo: Boolean;
35+ procedure Redo;
36+
37+ property ParagraphAlignment: TParagraphAlignment read GetParagraphAlignment write SetParagraphAlignment;
38+ property ParagraphNumbering: TParagraphNumbering read GetParagraphNumbering write SetParagraphNumbering;
39+ property ParagraphNumberingStyle: TParagraphNumberingStyle read GetParagraphNumberingStyle write SetParagraphNumberingStyle;
40+ property ParagraphNumberingTab: Byte read GetParagraphNumberingTab write SetParagraphNumberingTab;
41+ property ParagraphSpacingAfter: Byte read GetParagraphSpacingAfter write SetParagraphSpacingAfter;
42+ property ParagraphSpacingBefore: Byte read GetParagraphSpacingBefore write SetParagraphSpacingBefore;
43+ property ParagraphStartIndent: Byte read GetParagraphStartIndent write SetParagraphStartIndent;
44+ property ParagraphRightIndent: Byte read GetParagraphRightIndent write SetParagraphRightIndent;
45+ property ParagraphOffset: SmallInt read GetParagraphOffset write SetParagraphOffset;
46+ end;
47+
48+//
49+// dxStartIndent - recuo da primeira linha do paragrafo PFM_STARTINDENT
50+// dxRightIndent - recuo da margem direita PFM_RIGHTINDENT
51+// dxOffset - recuo do restante das linhas PFM_OFFSET
52+
53+
54+implementation
55+
56+uses
57+ RichEdit, Windows;
58+
59+{ TCustomRichEditHelper }
60+
61+function TCustomRichEditHelper.GetParagraphAlignment: TParagraphAlignment;
62+var
63+ Paragraph: TParaFormat2;
64+begin
65+ ZeroMemory(@Paragraph, SizeOf(TParaFormat2));
66+ Paragraph.cbSize := SizeOf(TParaFormat2);
67+
68+ if HandleAllocated then
69+ SendMessage(Handle, EM_GETPARAFORMAT, 0, LPARAM(@Paragraph));
70+
71+ Result := TParagraphAlignment(Paragraph.wAlignment);
72+end;
73+
74+function TCustomRichEditHelper.GetParagraphNumbering: TParagraphNumbering;
75+var
76+ Paragraph: TParaFormat2;
77+begin
78+ ZeroMemory(@Paragraph, SizeOf(TParaFormat2));
79+ Paragraph.cbSize := SizeOf(TParaFormat2);
80+
81+ if HandleAllocated then
82+ SendMessage(Handle, EM_GETPARAFORMAT, 0, LPARAM(@Paragraph));
83+
84+ Result := TParagraphNumbering(Paragraph.wNumbering);
85+end;
86+
87+function TCustomRichEditHelper.GetParagraphNumberingStyle: TParagraphNumberingStyle;
88+var
89+ Paragraph: TParaFormat2;
90+begin
91+ ZeroMemory(@Paragraph, SizeOf(TParaFormat2));
92+ Paragraph.cbSize := SizeOf(TParaFormat2);
93+
94+ if HandleAllocated then
95+ SendMessage(Handle, EM_GETPARAFORMAT, 0, LPARAM(@Paragraph));
96+
97+ case Paragraph.wNumberingStyle of
98+ $100: Result := pnsParens; // PFNS_PARENS
99+ $200: Result := pnsPeriod; // PFNS_PERIOD
100+ $300: Result := pnsPlain; // PFNS_PLAIN
101+ else
102+ Result := pnsParen; // PFNS_PAREN = $000
103+ end;
104+end;
105+
106+function TCustomRichEditHelper.GetParagraphNumberingTab: Byte;
107+var
108+ Paragraph: TParaFormat2;
109+begin
110+ ZeroMemory(@Paragraph, SizeOf(TParaFormat2));
111+ Paragraph.cbSize := SizeOf(TParaFormat2);
112+
113+ if HandleAllocated then
114+ SendMessage(Handle, EM_GETPARAFORMAT, 0, LPARAM(@Paragraph));
115+
116+ // wNumberingTab é em "twips", um vinte avos de um ponto. 15 twips = 1 pixel,
117+ // e 576 twips = 1 cm. A propriedade lida com milímetros, logo, precisamos
118+ // converter tanto aqui como em SetParagraphNumberingTab
119+ Result := Paragraph.wNumberingTab * 10 div 576;
120+end;
121+
122+function TCustomRichEditHelper.GetParagraphOffset: SmallInt;
123+var
124+ Paragraph: TParaFormat2;
125+begin
126+ ZeroMemory(@Paragraph, SizeOf(TParaFormat2));
127+ Paragraph.cbSize := SizeOf(TParaFormat2);
128+
129+ if HandleAllocated then
130+ SendMessage(Handle, EM_GETPARAFORMAT, 0, LPARAM(@Paragraph));
131+
132+ // dxOffset é em "twips", mas o componente vai trabalhar em milímetros
133+ Result := Paragraph.dxOffset * 10 div 576;
134+end;
135+
136+function TCustomRichEditHelper.GetParagraphRightIndent: Byte;
137+var
138+ Paragraph: TParaFormat2;
139+begin
140+ ZeroMemory(@Paragraph, SizeOf(TParaFormat2));
141+ Paragraph.cbSize := SizeOf(TParaFormat2);
142+
143+ if HandleAllocated then
144+ SendMessage(Handle, EM_GETPARAFORMAT, 0, LPARAM(@Paragraph));
145+
146+ // dxRightIndent é em "twips", mas o componente vai trabalhar em milímetros
147+ Result := Paragraph.dxRightIndent * 10 div 576;
148+end;
149+
150+function TCustomRichEditHelper.GetParagraphSpacingAfter: Byte;
151+var
152+ Paragraph: TParaFormat2;
153+begin
154+ ZeroMemory(@Paragraph, SizeOf(TParaFormat2));
155+ Paragraph.cbSize := SizeOf(TParaFormat2);
156+
157+ if HandleAllocated then
158+ SendMessage(Handle, EM_GETPARAFORMAT, 0, LPARAM(@Paragraph));
159+
160+ // dySpaceAfter é em "twips", mas o componente vai trabalhar em milímetros
161+ Result := Paragraph.dySpaceAfter * 10 div 576;
162+end;
163+
164+function TCustomRichEditHelper.GetParagraphSpacingBefore: Byte;
165+var
166+ Paragraph: TParaFormat2;
167+begin
168+ ZeroMemory(@Paragraph, SizeOf(TParaFormat2));
169+ Paragraph.cbSize := SizeOf(TParaFormat2);
170+
171+ if HandleAllocated then
172+ SendMessage(Handle, EM_GETPARAFORMAT, 0, LPARAM(@Paragraph));
173+
174+ // dySpaceBefore é em "twips", mas o componente vai trabalhar em milímetros
175+ Result := Paragraph.dySpaceBefore * 10 div 576;
176+end;
177+
178+function TCustomRichEditHelper.GetParagraphStartIndent: Byte;
179+var
180+ Paragraph: TParaFormat2;
181+begin
182+ ZeroMemory(@Paragraph, SizeOf(TParaFormat2));
183+ Paragraph.cbSize := SizeOf(TParaFormat2);
184+
185+ if HandleAllocated then
186+ SendMessage(Handle, EM_GETPARAFORMAT, 0, LPARAM(@Paragraph));
187+
188+ // dxStartIndent é em "twips", mas o componente vai trabalhar em milímetros
189+ Result := Paragraph.dxStartIndent * 10 div 576;
190+end;
191+// Para que o alinhamento justificado seja efetivo, precisamos habilitar a
192+// tipografia avançada. Caso você implemente alguma ação que não funcione,
193+// pode ser necessário aplicar a tipografia avançada. Isso parece só
194+// precisar ser feito apenas uma vez. Use o comando abaixo para ativar a
195+// tipografia avançada
196+// SendMessage(RichEdit.Handle, EM_SETTYPOGRAPHYOPTIONS, TO_ADVANCEDTYPOGRAPHY, TO_ADVANCEDTYPOGRAPHY);
197+procedure TCustomRichEditHelper.SetParagraphAlignment(const AValue: TParagraphAlignment);
198+var
199+ Paragraph: TParaFormat2;
200+begin
201+ ZeroMemory(@Paragraph, SizeOf(TParaFormat2));
202+ Paragraph.cbSize := SizeOf(TParaFormat2);
203+ Paragraph.dwMask := PFM_ALIGNMENT;
204+
205+ Paragraph.wAlignment := Byte(AValue);
206+
207+ HandleNeeded; { We REALLY need the handle for BiDi }
208+
209+ if HandleAllocated then
210+ SendMessage(Handle, EM_SETPARAFORMAT, 0, LPARAM(@Paragraph));
211+end;
212+
213+procedure TCustomRichEditHelper.SetParagraphNumbering(const AValue: TParagraphNumbering);
214+var
215+ Paragraph: TParaFormat2;
216+begin
217+ ZeroMemory(@Paragraph, SizeOf(TParaFormat2));
218+ Paragraph.cbSize := SizeOf(TParaFormat2);
219+ Paragraph.dwMask := PFM_NUMBERING or PFM_NUMBERINGSTART;
220+
221+ Paragraph.wNumberingStart := 1;
222+ Paragraph.wNumbering := Byte(AValue);
223+
224+ HandleNeeded;
225+
226+ if HandleAllocated then
227+ SendMessage(Handle, EM_SETPARAFORMAT, 0, LPARAM(@Paragraph));
228+end;
229+
230+procedure TCustomRichEditHelper.SetParagraphNumberingStyle(const AValue: TParagraphNumberingStyle);
231+var
232+ Paragraph: TParaFormat2;
233+begin
234+ ZeroMemory(@Paragraph, SizeOf(TParaFormat2));
235+ Paragraph.cbSize := SizeOf(TParaFormat2);
236+ Paragraph.dwMask := PFM_NUMBERINGSTYLE;
237+
238+ case AValue of
239+ pnsParen: Paragraph.wNumberingStyle := 0;
240+ pnsParens: Paragraph.wNumberingStyle := $100;
241+ pnsPeriod: Paragraph.wNumberingStyle := $200;
242+ pnsPlain: Paragraph.wNumberingStyle := $300;
243+ end;
244+
245+ HandleNeeded;
246+
247+ if HandleAllocated then
248+ SendMessage(Handle, EM_SETPARAFORMAT, 0, LPARAM(@Paragraph));
249+end;
250+
251+procedure TCustomRichEditHelper.SetParagraphNumberingTab(const AValue: Byte);
252+var
253+ Paragraph: TParaFormat2;
254+begin
255+ ZeroMemory(@Paragraph, SizeOf(TParaFormat2));
256+ Paragraph.cbSize := SizeOf(TParaFormat2);
257+ Paragraph.dwMask := PFM_NUMBERINGTAB;
258+
259+ Paragraph.wNumberingTab := AValue * 576 div 10;
260+
261+ HandleNeeded;
262+
263+ if HandleAllocated then
264+ SendMessage(Handle, EM_SETPARAFORMAT, 0, LPARAM(@Paragraph));
265+end;
266+
267+procedure TCustomRichEditHelper.SetParagraphOffset(const AValue: SmallInt);
268+var
269+ Paragraph: TParaFormat2;
270+begin
271+ ZeroMemory(@Paragraph, SizeOf(TParaFormat2));
272+ Paragraph.cbSize := SizeOf(TParaFormat2);
273+ Paragraph.dwMask := PFM_OFFSET;
274+
275+ Paragraph.dxOffset := AValue * 576 div 10;
276+
277+ HandleNeeded;
278+
279+ if HandleAllocated then
280+ SendMessage(Handle, EM_SETPARAFORMAT, 0, LPARAM(@Paragraph));
281+end;
282+
283+procedure TCustomRichEditHelper.SetParagraphRightIndent(const AValue: Byte);
284+var
285+ Paragraph: TParaFormat2;
286+begin
287+ ZeroMemory(@Paragraph, SizeOf(TParaFormat2));
288+ Paragraph.cbSize := SizeOf(TParaFormat2);
289+ Paragraph.dwMask := PFM_RIGHTINDENT;
290+
291+ Paragraph.dxRightIndent := AValue * 576 div 10;
292+
293+ HandleNeeded;
294+
295+ if HandleAllocated then
296+ SendMessage(Handle, EM_SETPARAFORMAT, 0, LPARAM(@Paragraph));
297+end;
298+
299+procedure TCustomRichEditHelper.SetParagraphSpacingAfter(const AValue: Byte);
300+var
301+ Paragraph: TParaFormat2;
302+begin
303+ ZeroMemory(@Paragraph, SizeOf(TParaFormat2));
304+ Paragraph.cbSize := SizeOf(TParaFormat2);
305+ Paragraph.dwMask := PFM_SPACEAFTER;
306+
307+ Paragraph.dySpaceAfter := AValue * 576 div 10;
308+
309+ HandleNeeded;
310+
311+ if HandleAllocated then
312+ SendMessage(Handle, EM_SETPARAFORMAT, 0, LPARAM(@Paragraph));
313+end;
314+
315+procedure TCustomRichEditHelper.SetParagraphSpacingBefore(const AValue: Byte);
316+var
317+ Paragraph: TParaFormat2;
318+begin
319+ ZeroMemory(@Paragraph, SizeOf(TParaFormat2));
320+ Paragraph.cbSize := SizeOf(TParaFormat2);
321+ Paragraph.dwMask := PFM_SPACEBEFORE;
322+
323+ Paragraph.dySpaceBefore := AValue * 576 div 10;
324+
325+ HandleNeeded;
326+
327+ if HandleAllocated then
328+ SendMessage(Handle, EM_SETPARAFORMAT, 0, LPARAM(@Paragraph));
329+end;
330+
331+procedure TCustomRichEditHelper.SetParagraphStartIndent(const AValue: Byte);
332+var
333+ Paragraph: TParaFormat2;
334+begin
335+ ZeroMemory(@Paragraph, SizeOf(TParaFormat2));
336+ Paragraph.cbSize := SizeOf(TParaFormat2);
337+ Paragraph.dwMask := PFM_STARTINDENT;
338+
339+ Paragraph.dxStartIndent := AValue * 576 div 10;
340+
341+ HandleNeeded;
342+
343+ if HandleAllocated then
344+ SendMessage(Handle, EM_SETPARAFORMAT, 0, LPARAM(@Paragraph));
345+end;
346+
347+procedure TCustomRichEditHelper.Redo;
348+begin
349+ SendMessage(Handle, EM_REDO, 0, 0);
350+end;
351+
352+function TCustomRichEditHelper.CanRedo: Boolean;
353+begin
354+ Result := False;
355+
356+ if HandleAllocated then
357+ Result := SendMessage(Handle, EM_CANREDO, 0, 0) <> 0;
358+end;
359+
360+end.
--- trunk/rtp/src/Vcl/KRK.Vcl.ExtActns.ActnRes.pas (revision 540)
+++ trunk/rtp/src/Vcl/KRK.Vcl.ExtActns.ActnRes.pas (revision 541)
@@ -10,12 +10,22 @@
1010 , StdActns
1111 , ExtActns
1212 , ActnList
13- , KRK.Vcl.ExtActns;
13+ , KRK.Vcl.ExtActns, System.ImageList, System.Actions;
1414
1515 type
1616 TActionResources = class(TStandardActions)
17- RichEditAlignJustified1: TRichEditAlignJustified;
17+ RichEditPAJustified1: TRichEditPAJustified;
1818 RichEditRedo1: TRichEditRedo;
19+ RichEditPNBullets1: TRichEditPNBullets;
20+ RichEditPNArabicNumbers1: TRichEditPNArabicNumbers;
21+ RichEditPNSmallLetters1: TRichEditPNSmallLetters;
22+ RichEditPNCapitalLetters1: TRichEditPNCapitalLetters;
23+ RichEditPNSmallRomanNumbers1: TRichEditPNSmallRomanNumbers;
24+ RichEditPNCapitalRomanNumbers1: TRichEditPNCapitalRomanNumbers;
25+ RichEditPNSParen1: TRichEditPNSParen;
26+ RichEditPNSParens1: TRichEditPNSParens;
27+ RichEditPNSPeriod1: TRichEditPNSPeriod;
28+ RichEditPNSPlain1: TRichEditPNSPlain;
1929 private
2030 { Private declarations }
2131 public
--- trunk/rtp/src/Vcl/KRK.Vcl.ExtActns.Helpers.pas (nonexistent)
+++ trunk/rtp/src/Vcl/KRK.Vcl.ExtActns.Helpers.pas (revision 541)
@@ -0,0 +1,25 @@
1+unit KRK.Vcl.ExtActns.Helpers;
2+
3+interface
4+
5+uses
6+ ExtActns, ComCtrls;
7+
8+type
9+ TRichEditActionHelper = class helper for TRichEditAction
10+ protected
11+ function GetControl(ATarget: TObject): TCustomRichEdit;
12+ end;
13+
14+
15+implementation
16+
17+{ TRichEditActionHelper }
18+
19+// Essa ideia foi copiada do que já é feito para Vcl.StdActns.TCustomEdit
20+function TRichEditActionHelper.GetControl(ATarget: TObject): TCustomRichEdit;
21+begin
22+ Result := ATarget as TCustomRichEdit;
23+end;
24+
25+end.
--- trunk/rtp/src/Vcl/KRK.Vcl.ExtActns.pas (revision 540)
+++ trunk/rtp/src/Vcl/KRK.Vcl.ExtActns.pas (revision 541)
@@ -1,138 +1,328 @@
11 unit KRK.Vcl.ExtActns;
22
33 interface
4+
5+uses
6+ ExtActns;
47 // para implementar outras coisas interessantes, leia isso!
58 // http://www.functionx.com/bcb/controls/richedit.htm
6-uses ExtActns;
79
10+
811 type
9- TRichEditAlignJustified = class(TRichEditAction)
10- private
11- //: Executa o código necessário para a efetivação da ação de justificação de
12- //: texto no TRichEdit
13- procedure Justify(ATarget: TObject);
14- //: Atualiza as propriedades Checked e Enabled do TAction atual de forma que
15- //: elas reflitam o estado atual da justificação de texto no TRichEdit
16- procedure UpdateActionState(ATarget: TObject);
12+ TRichEditPAJustified = class(TRichEditAction)
1713 public
1814 procedure ExecuteTarget(ATarget: TObject); override;
1915 procedure UpdateTarget(ATarget: TObject); override;
2016 end;
2117
22- // Os métodos CanRedo e Redo, deveriam ser implementados diretamente em
23- // TRichEdit (sem o parâmetro ATarget). Eu poderia criar um interposer para
24- // simplificar a codificação de TRichEditRedo abaixo, mas isso faria com que o
25- // usuário final precisasse lidar com a colocação da unit com a interposer no
26- // local correto da cláusula uses, e isso não seria bom
27-
2818 TRichEditRedo = class(TRichEditAction)
29- private
30- function CanRedo(ATarget: TObject): Boolean;
31- procedure Redo(ATarget: TObject);
3219 public
3320 procedure ExecuteTarget(ATarget: TObject); override;
3421 procedure UpdateTarget(ATarget: TObject); override;
3522 end;
3623
24+ (***************************************************************************/)
25+ A estrutura TParaFormat2 possui um membro chamado wReserved, que no MSDN
26+ divide o mesmo espaço de memória (union) com wReserved. No MSDN a explicação
27+ para este membro está na página referente a estrutura PARAFORMAT (não
28+ PARAFORMAT2). Esta explicação consiste apenas em dizer que no RichEdit 1.0 o
29+ membro é reservado e precisa ser zero e no RichEdit 2.0 ele é nomeado como
30+ wEffects e representa "efeitos de parágrafo", mas não diz como usar e nem
31+ quais valores podem ser atribuídos nele. No site
32+ http://www.functionx.com/bcb/controls/richedit.htm existe uma referência a
33+ wEffects sendo utilizado com o valor CFE_ALLCAPS. Procurei então essa
34+ constante em WinApi.RichEdit e achei algumas outras bem interessantes.
35+ (/**************************************************************************)
36+
37+ // Já existe TRichEditBullets, mas seu comportamento de alternância entre ter
38+ // e não ter o ponto na lista é errado e interfere na forma de funcionamento
39+ // de outras classes de numeração aqui definidas, por isso eu resolvi criar
40+ // uma classe adicional só pra bullets com o comportamento correto
41+ TRichEditPNBullets = class(TRichEditBullets)
42+ public
43+ procedure ExecuteTarget(ATarget: TObject); override;
44+ end;
45+
46+ TRichEditPNArabicNumbers = class(TRichEditAction)
47+ public
48+ procedure ExecuteTarget(ATarget: TObject); override;
49+ procedure UpdateTarget(ATarget: TObject); override;
50+ end;
51+
52+ TRichEditPNSmallLetters = class(TRichEditAction)
53+ public
54+ procedure ExecuteTarget(ATarget: TObject); override;
55+ procedure UpdateTarget(ATarget: TObject); override;
56+ end;
57+
58+ TRichEditPNCapitalLetters = class(TRichEditAction)
59+ public
60+ procedure ExecuteTarget(ATarget: TObject); override;
61+ procedure UpdateTarget(ATarget: TObject); override;
62+ end;
63+
64+ TRichEditPNSmallRomanNumbers = class(TRichEditAction)
65+ public
66+ procedure ExecuteTarget(ATarget: TObject); override;
67+ procedure UpdateTarget(ATarget: TObject); override;
68+ end;
69+
70+ TRichEditPNCapitalRomanNumbers = class(TRichEditAction)
71+ public
72+ procedure ExecuteTarget(ATarget: TObject); override;
73+ procedure UpdateTarget(ATarget: TObject); override;
74+ end;
75+
76+ // Abaixo, PNS = Paragraph Numbering Style
77+ TRichEditPNSParen = class(TRichEditAction)
78+ public
79+ procedure ExecuteTarget(ATarget: TObject); override;
80+ procedure UpdateTarget(ATarget: TObject); override;
81+ end;
82+
83+ TRichEditPNSParens = class(TRichEditAction)
84+ public
85+ procedure ExecuteTarget(ATarget: TObject); override;
86+ procedure UpdateTarget(ATarget: TObject); override;
87+ end;
88+
89+ TRichEditPNSPeriod = class(TRichEditAction)
90+ public
91+ procedure ExecuteTarget(ATarget: TObject); override;
92+ procedure UpdateTarget(ATarget: TObject); override;
93+ end;
94+
95+ TRichEditPNSPlain = class(TRichEditAction)
96+ public
97+ procedure ExecuteTarget(ATarget: TObject); override;
98+ procedure UpdateTarget(ATarget: TObject); override;
99+ end;
100+
101+//: A função abaixo habilita a tipografia avançada. Pesquise sobre
102+//: EM_SETTYPOGRAPHYOPTIONS no MSDN
103+procedure ApplyAdvancedTypography(ARichEditHandle: THandle);
104+
105+implementation
106+
107+uses
108+ Windows, RichEdit, ComCtrls, KRK.Vcl.ExtActns.Helpers,
109+ KRK.Vcl.ComCtrls.Helpers;
110+
37111 const
38112 TO_ADVANCEDTYPOGRAPHY = $1;
39113
40-implementation
114+procedure ApplyAdvancedTypography(ARichEditHandle: THandle);
115+begin
116+ SendMessage(ARichEditHandle, EM_SETTYPOGRAPHYOPTIONS, TO_ADVANCEDTYPOGRAPHY, TO_ADVANCEDTYPOGRAPHY);
117+end;
41118
42-uses RichEdit
43- , Windows
44- , ComCtrls;
119+{ TRichEditPAJustified }
45120
46-{ TRichEditAlignFullyJustified }
121+procedure TRichEditPAJustified.ExecuteTarget(ATarget: TObject);
122+begin
123+ inherited;
47124
48-procedure TRichEditAlignJustified.UpdateActionState(ATarget: TObject);
49-var
50- Paragraph: TParaFormat2;
125+ if ATarget is TCustomRichEdit then
126+ GetControl(ATarget).ParagraphAlignment := paJustified;
127+end;
128+
129+procedure TRichEditPAJustified.UpdateTarget(ATarget: TObject);
51130 begin
52- // Se for um TCustomRichEdit, já deixa habilitada a ação de justificação de
53- // texto
131+ inherited;
54132 Enabled := ATarget is TCustomRichEdit;
55- Checked := False;
133+ Checked := Enabled and (GetControl(ATarget).ParagraphAlignment = paJustified);
134+end;
56135
57- if Enabled then
58- begin
59- ZeroMemory(@Paragraph, SizeOf(TParaFormat2));
60- Paragraph.cbSize := SizeOf(TParaFormat2);
136+{ TRichEditRedo }
61137
62- if TCustomRichEdit(ATarget).HandleAllocated then
63- SendMessage(TCustomRichEdit(ATarget).Handle, EM_GETPARAFORMAT, 0, LPARAM(@Paragraph));
138+procedure TRichEditRedo.ExecuteTarget(ATarget: TObject);
139+begin
140+ GetControl(ATarget).Redo;
141+end;
64142
65- // Caso o alinhamento do TRichEdit seja justificado, configura a ação como
66- // checked, de forma que controles associados a ela apareçam destacados
67- // (marcados, checados, etc)
68- Checked := Paragraph.wAlignment = PFA_JUSTIFY;
69- end;
143+procedure TRichEditRedo.UpdateTarget(ATarget: TObject);
144+begin
145+ inherited;
146+ Enabled := GetControl(ATarget).CanRedo and not GetControl(ATarget).ReadOnly;
70147 end;
71148
72-// Para que o alinhamento justificado seja efetivo, precisamos habilitar a
73-// tipografia avançada. Caso você implemente alguma ação que não funcione,
74-// pode ser necessário aplicar a tipografia avançada. Isso parece só
75-// precisar ser feito apenas uma vez. Use o comando abaixo para ativar a
76-// tipografia avançada
77-// SendMessage(RichEdit.Handle, EM_SETTYPOGRAPHYOPTIONS, TO_ADVANCEDTYPOGRAPHY, TO_ADVANCEDTYPOGRAPHY);
78-procedure TRichEditAlignJustified.Justify(ATarget: TObject);
79-var
80- Paragraph: TParaFormat2;
149+{ TRichEditPNBullets }
150+
151+procedure TRichEditPNBullets.ExecuteTarget(ATarget: TObject);
81152 begin
82- Checked := False;
153+ if ATarget is TCustomRichEdit then
154+ if GetControl(ATarget).ParagraphNumbering <> pnBullet then
155+ GetControl(ATarget).ParagraphNumbering := pnBullet
156+ else
157+ GetControl(ATarget).ParagraphNumbering := pnNone;
158+end;
83159
160+{ TRichEditArabicNumbers }
161+
162+procedure TRichEditPNArabicNumbers.ExecuteTarget(ATarget: TObject);
163+begin
164+ inherited;
165+
84166 if ATarget is TCustomRichEdit then
85- begin
86- ZeroMemory(@Paragraph, SizeOf(TParaFormat2));
87- Paragraph.cbSize := SizeOf(TParaFormat2);
88- Paragraph.dwMask := PFM_ALIGNMENT;
89- Paragraph.wAlignment := PFA_JUSTIFY;
167+ if GetControl(ATarget).ParagraphNumbering <> pnArabicNumbers then
168+ GetControl(ATarget).ParagraphNumbering := pnArabicNumbers
169+ else
170+ GetControl(ATarget).ParagraphNumbering := pnNone;
171+end;
90172
91- TCustomRichEdit(ATarget).HandleNeeded; { we REALLY need the handle for BiDi }
173+procedure TRichEditPNArabicNumbers.UpdateTarget(ATarget: TObject);
174+begin
175+ inherited;
176+ Enabled := ATarget is TCustomRichEdit;
177+ Checked := Enabled and (GetControl(ATarget).ParagraphNumbering = pnArabicNumbers);
178+end;
92179
93- if TCustomRichEdit(ATarget).HandleAllocated then
94- Checked := SendMessage(TCustomRichEdit(ATarget).Handle, EM_SETPARAFORMAT, 0, LPARAM(@Paragraph)) <> 0;
95- end;
180+{ TRichEditSmallLetters }
181+
182+procedure TRichEditPNSmallLetters.ExecuteTarget(ATarget: TObject);
183+begin
184+ inherited;
185+
186+ if ATarget is TCustomRichEdit then
187+ if GetControl(ATarget).ParagraphNumbering <> pnSmallLetters then
188+ GetControl(ATarget).ParagraphNumbering := pnSmallLetters
189+ else
190+ GetControl(ATarget).ParagraphNumbering := pnNone;
96191 end;
97192
98-procedure TRichEditAlignJustified.ExecuteTarget(ATarget: TObject);
193+procedure TRichEditPNSmallLetters.UpdateTarget(ATarget: TObject);
99194 begin
100195 inherited;
101- Justify(ATarget);
196+ Enabled := ATarget is TCustomRichEdit;
197+ Checked := Enabled and (GetControl(ATarget).ParagraphNumbering = pnSmallLetters);
102198 end;
103199
104-procedure TRichEditAlignJustified.UpdateTarget(ATarget: TObject);
200+{ TRichEditCapitalLetters }
201+
202+procedure TRichEditPNCapitalLetters.ExecuteTarget(ATarget: TObject);
105203 begin
106204 inherited;
107- UpdateActionState(ATarget);
205+
206+ if ATarget is TCustomRichEdit then
207+ if GetControl(ATarget).ParagraphNumbering <> pnCapitalLetters then
208+ GetControl(ATarget).ParagraphNumbering := pnCapitalLetters
209+ else
210+ GetControl(ATarget).ParagraphNumbering := pnNone;
108211 end;
109212
110-{ TRichEditRedo }
213+procedure TRichEditPNCapitalLetters.UpdateTarget(ATarget: TObject);
214+begin
215+ inherited;
216+ Enabled := ATarget is TCustomRichEdit;
217+ Checked := Enabled and (GetControl(ATarget).ParagraphNumbering = pnCapitalLetters);
218+end;
111219
112-function TRichEditRedo.CanRedo(ATarget: TObject): Boolean;
220+{ TRichEditSmallRomanNumbers }
221+
222+procedure TRichEditPNSmallRomanNumbers.ExecuteTarget(ATarget: TObject);
113223 begin
114- Result := False;
224+ inherited;
115225
116- if (ATarget is TCustomRichEdit) and TCustomRichEdit(ATarget).HandleAllocated then
117- Result := SendMessage(TCustomRichEdit(ATarget).Handle, EM_CANREDO, 0, 0) <> 0;
226+ if ATarget is TCustomRichEdit then
227+ if GetControl(ATarget).ParagraphNumbering <> pnSmallRomanNumbers then
228+ GetControl(ATarget).ParagraphNumbering := pnSmallRomanNumbers
229+ else
230+ GetControl(ATarget).ParagraphNumbering := pnNone;
118231 end;
119232
120-procedure TRichEditRedo.ExecuteTarget(ATarget: TObject);
233+procedure TRichEditPNSmallRomanNumbers.UpdateTarget(ATarget: TObject);
121234 begin
122235 inherited;
123- Redo(ATarget);
236+ Enabled := ATarget is TCustomRichEdit;
237+ Checked := Enabled and (GetControl(ATarget).ParagraphNumbering = pnSmallRomanNumbers);
124238 end;
125239
126-procedure TRichEditRedo.Redo(ATarget: TObject);
240+{ TRichEditCapitalRomanNumbers }
241+
242+procedure TRichEditPNCapitalRomanNumbers.ExecuteTarget(ATarget: TObject);
127243 begin
244+ inherited;
245+
128246 if ATarget is TCustomRichEdit then
129- SendMessage(TCustomRichEdit(ATarget).Handle, EM_REDO, 0, 0);
247+ if GetControl(ATarget).ParagraphNumbering <> pnCapitalRomanNumbers then
248+ GetControl(ATarget).ParagraphNumbering := pnCapitalRomanNumbers
249+ else
250+ GetControl(ATarget).ParagraphNumbering := pnNone;
130251 end;
131252
132-procedure TRichEditRedo.UpdateTarget(ATarget: TObject);
253+procedure TRichEditPNCapitalRomanNumbers.UpdateTarget(ATarget: TObject);
133254 begin
134255 inherited;
135- Enabled := CanRedo(ATarget) and not TCustomRichEdit(ATarget).ReadOnly;
256+ Enabled := ATarget is TCustomRichEdit;
257+ Checked := Enabled and (GetControl(ATarget).ParagraphNumbering = pnCapitalRomanNumbers);
136258 end;
137259
260+{ TRichEditNSParen }
261+
262+procedure TRichEditPNSParen.ExecuteTarget(ATarget: TObject);
263+begin
264+ inherited;
265+
266+ if ATarget is TCustomRichEdit then
267+ GetControl(ATarget).ParagraphNumberingStyle := pnsParen;
268+end;
269+
270+procedure TRichEditPNSParen.UpdateTarget(ATarget: TObject);
271+begin
272+ inherited;
273+ Enabled := ATarget is TCustomRichEdit;
274+ Checked := Enabled and (GetControl(ATarget).ParagraphNumberingStyle = pnsParen);
275+end;
276+
277+{ TRichEditPNSParens }
278+
279+procedure TRichEditPNSParens.ExecuteTarget(ATarget: TObject);
280+begin
281+ inherited;
282+
283+ if ATarget is TCustomRichEdit then
284+ GetControl(ATarget).ParagraphNumberingStyle := pnsParens;
285+end;
286+
287+procedure TRichEditPNSParens.UpdateTarget(ATarget: TObject);
288+begin
289+ inherited;
290+ Enabled := ATarget is TCustomRichEdit;
291+ Checked := Enabled and (GetControl(ATarget).ParagraphNumberingStyle = pnsParens);
292+end;
293+
294+{ TRichEditPNSPeriod }
295+
296+procedure TRichEditPNSPeriod.ExecuteTarget(ATarget: TObject);
297+begin
298+ inherited;
299+
300+ if ATarget is TCustomRichEdit then
301+ GetControl(ATarget).ParagraphNumberingStyle := pnsPeriod;
302+end;
303+
304+procedure TRichEditPNSPeriod.UpdateTarget(ATarget: TObject);
305+begin
306+ inherited;
307+ Enabled := ATarget is TCustomRichEdit;
308+ Checked := Enabled and (GetControl(ATarget).ParagraphNumberingStyle = pnsPeriod);
309+end;
310+
311+{ TRichEditPNSPlain }
312+
313+procedure TRichEditPNSPlain.ExecuteTarget(ATarget: TObject);
314+begin
315+ inherited;
316+
317+ if ATarget is TCustomRichEdit then
318+ GetControl(ATarget).ParagraphNumberingStyle := pnsPlain;
319+end;
320+
321+procedure TRichEditPNSPlain.UpdateTarget(ATarget: TObject);
322+begin
323+ inherited;
324+ Enabled := ATarget is TCustomRichEdit;
325+ Checked := Enabled and (GetControl(ATarget).ParagraphNumberingStyle = pnsPlain);
326+end;
327+
138328 end.
Show on old repository browser