cmbStyles appears empty
cmbStyles appears empty
Hi.
I'm using ActionTestUni as a base. I've managed to generate several tabs so I can use multiple files at the same time. I've also managed to get many of the editor's functions working.
I need help with two issues:
1. I can't get the predefined styles to appear in the cmbStyles combo box.
2. I'd like to know how to add my own styles, if possible.
Thanks in advance.
I'm using ActionTestUni as a base. I've managed to generate several tabs so I can use multiple files at the same time. I've also managed to get many of the editor's functions working.
I need help with two issues:
1. I can't get the predefined styles to appear in the cmbStyles combo box.
2. I'd like to know how to add my own styles, if possible.
Thanks in advance.
Re: cmbStyles appears empty
I am using this code:
But it does not solve the problem.
Code: Select all
TabSheet := TTabSheet.Create(Self);
TabSheet.PageControl := PageControl1;
RichEdit := TRichViewEdit.Create(self);
RichEdit.Style:=TRVStyle.Create(self);
RichEdit.Style.StyleTemplates:=RichViewEdit1.Style.StyleTemplates;
RichEdit.UseStyleTemplates:=True;
-
- Site Admin
- Posts: 17836
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: cmbStyles appears empty
Did you assign RichViewEdit.UseStyleTemplates = True?
When do you want to add styles?
If you want to define collections of styles for new documents, edit rvActionNew.StyleTemplates collection.
A general information about named styles in TRichView is here: viewtopic.php?t=8804
(you can ignore information about applying styletemplates to text and paragraph styles in code: it is not needed when using RichViewActions)
When do you want to add styles?
If you want to define collections of styles for new documents, edit rvActionNew.StyleTemplates collection.
A general information about named styles in TRichView is here: viewtopic.php?t=8804
(you can ignore information about applying styletemplates to text and paragraph styles in code: it is not needed when using RichViewActions)
-
- Site Admin
- Posts: 17836
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: cmbStyles appears empty
As for the initial display, when the application starts, call
rvActionNew.ExecuteTarget(RichViewEdit);
This command associates the editor with an unsaved file, and (if RichViewEdit.UseStyleTemplates = True) applies rvActionNew.StyleTemplates to the empty document, and updates cmbStyles.
Please note that you need to assign
cmbStyles.Editor = RichViewEdit;
rvActionNew.ExecuteTarget(RichViewEdit);
This command associates the editor with an unsaved file, and (if RichViewEdit.UseStyleTemplates = True) applies rvActionNew.StyleTemplates to the empty document, and updates cmbStyles.
Please note that you need to assign
cmbStyles.Editor = RichViewEdit;
Re: cmbStyles appears empty
Very well. Thank you.
I've managed to get the cmbStyles Combobox to list the styles.
But not the entire collection, it only lists 5.
I'm wondering, wouldn't it be possible to transfer the entire collection and any new ones to TRVSyle1 and use them from there?
Best regards.
I've managed to get the cmbStyles Combobox to list the styles.
But not the entire collection, it only lists 5.
I'm wondering, wouldn't it be possible to transfer the entire collection and any new ones to TRVSyle1 and use them from there?
Best regards.
-
- Site Admin
- Posts: 17836
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: cmbStyles appears empty
TRVStyleTemplateComboBox must include all styles.
But some of them may be hidden initially.
See https://www.trichview.com/help-actions/ ... styles.htm
But some of them may be hidden initially.
See https://www.trichview.com/help-actions/ ... styles.htm
Re: cmbStyles appears empty
Yes, it's true that only 5 styles appear initially when you open a new file. This happens even in the ActionTestUni test app.
When you read a file, cmbStyles incorporates all the styles used in that file.
But this has a limitation: you can't use more than 5 styles when you want to write a new file.
Isn't it possible to access the collection of styles to use them while you're writing a new file?
If this is the case, it doesn't make sense to have a collection of styles you can't use.
I'm sure there's something I'm not understanding... This can't possibly be the way I'm explaining it.
Please tell me I'm wrong and there must be a way to display all the available styles in the combo box...
And show me how to access the collection of styles that are already predefined.
Thank you very much.
Best regards.
When you read a file, cmbStyles incorporates all the styles used in that file.
But this has a limitation: you can't use more than 5 styles when you want to write a new file.
Isn't it possible to access the collection of styles to use them while you're writing a new file?
If this is the case, it doesn't make sense to have a collection of styles you can't use.
I'm sure there's something I'm not understanding... This can't possibly be the way I'm explaining it.
Please tell me I'm wrong and there must be a way to display all the available styles in the combo box...
And show me how to access the collection of styles that are already predefined.
Thank you very much.
Best regards.
-
- Site Admin
- Posts: 17836
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: cmbStyles appears empty
There is no "5 styles" limitation.
But not all styles are displayed in the cmbobox by default.
With the default settings, the combobox displays:
- styles that have QuickAccess property = True
- used heading level styles + one extra heading level style (but not less than 3 heading level styles).
If there is at least one hidden style, "All styles" item must appear. It shows all styles temporarily.
If you want to display all styles always, assign cmbStyles.ShowAllStyles = True.
The styles used in the document are accessible as RichViewEdit.Style.StyleTemplates.
But not all styles are displayed in the cmbobox by default.
With the default settings, the combobox displays:
- styles that have QuickAccess property = True
- used heading level styles + one extra heading level style (but not less than 3 heading level styles).
If there is at least one hidden style, "All styles" item must appear. It shows all styles temporarily.
If you want to display all styles always, assign cmbStyles.ShowAllStyles = True.
The styles used in the document are accessible as RichViewEdit.Style.StyleTemplates.
Re: cmbStyles appears empty
Yes, I'm using cmbStyles.ShowAllStyles = True.
But I can only see 5. I've even created a procedure for the cmbStyles.onClickAllStyles event. The code is attached:
At design time, the showAllStyles property is also checked.
As I mentioned earlier, in the ActionTestUni demo, it only shows the same 5 Styles when you try to open a new file.
There should be a way to show the user all the styles they can use when writing the document, I think.
But I can only see 5. I've even created a procedure for the cmbStyles.onClickAllStyles event. The code is attached:
Code: Select all
procedure TFormUnidad1.FormShow(Sender: TObject);
begin
rvActionNew1.ExecuteTarget(RichViewEdit1);
cmbFont.Font.Name := RVAControlPanel1.DialogFontName;
cmbFontSize.Font.Name := RVAControlPanel1.DialogFontName;
cmbUnits.Font.Name := RVAControlPanel1.DialogFontName;
cmbStyles.Font.Name := RVAControlPanel1.DialogFontName;
cmbStyles.ShowAllStyles := True;
RichViewEdit1.RTFReadProperties.UnicodeMode := rvruOnlyUnicode;
.....
procedure TFormUnidad1.cmbStylesClickAllStyles(Sender: TObject);
begin
// cmbStyles.ShowClearFormat := False;
cmbStyles.ShowAllStyles := True;
end;
There should be a way to show the user all the styles they can use when writing the document, I think.
-
- Site Admin
- Posts: 17836
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: cmbStyles appears empty
Sorry, I cannot reproduce the problem.
With the default settings, with the default readme.rvf, the combobox shows 16 out of 17 styles:
With the default settings, with the default readme.rvf, the combobox shows 16 out of 17 styles:
Re: cmbStyles appears empty
If you want to reproduce the problem, you'll need to create a new document. The readme.rvf document lists the styles the document uses (as I mentioned earlier).
To reproduce the error, you'll need to create a new, blank document.
Regards.
To reproduce the error, you'll need to create a new, blank document.
Regards.
-
- Site Admin
- Posts: 17836
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: cmbStyles appears empty
As I said in the very beginning, RichViewActions applies the collection of rvActionNew.StyleTemplates to new documents.
This collection has 5 styles in this demo. But you can edit this collection - add and delete style (although, I do not recommend deleting the initial styles).
In the ActionTest demo, double click ActionList1 at design time.
In the action list editor, select "RVE File" category, then rvActionNew1.
Then in the Object Inspector, double click "StyleTemplates" property.
In the collection editor, you can add new styles.
This collection has 5 styles in this demo. But you can edit this collection - add and delete style (although, I do not recommend deleting the initial styles).
In the ActionTest demo, double click ActionList1 at design time.
In the action list editor, select "RVE File" category, then rvActionNew1.
Then in the Object Inspector, double click "StyleTemplates" property.
In the collection editor, you can add new styles.
Re: cmbStyles appears empty
Well, I understand that I don't have permission to use the full list of predefined styles.
If I want to use more than five styles, I have to define them myself, using the method you indicated in your last post. Isn't it?
How can I get the right to use the entire collection?
Thank you so much.
If I want to use more than five styles, I have to define them myself, using the method you indicated in your last post. Isn't it?
How can I get the right to use the entire collection?
Thank you so much.
-
- Site Admin
- Posts: 17836
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: cmbStyles appears empty
There are no predefined styles.
Each document has its own list of styles.
But there are some reserved names of styles, such as "Normal", "heading 1", "Hyperlink", etc. They may have special meaning; and RichViewActions display their names translated.
But documents do not necessary include these styles. Actually, only one style - "Normal" - is absolutely necessary.
At design time, in the Object Inspector, when you edit Name property of a style (styletemplate), you can see a list of predefined names. However, when you assign Name, other properties are not changed, you need to define them yourself (well, there are some exceptions: for some styles, values of Kind and ParentId properties are adjusted depending on names).
Probably, it would be simpler to fill rvActionNew.StyleTemplates in code than at design time.
For this task, you can use the function from RVStyleFuncs.pas from RichViewActions:
This function sets default properties for the specified style according to StyleType and Level.
StyleType value is one of:
Level is a heading level, used only if StyleType = rvssnHeadingN.
Example of use (adding "Title" style and setting its default properties):
RVSetStandardStyleDefaults is used internally in RichViewActions in the style management dialog (when the user adds a standard style).
You can use this function to add all standard styles:
Each document has its own list of styles.
But there are some reserved names of styles, such as "Normal", "heading 1", "Hyperlink", etc. They may have special meaning; and RichViewActions display their names translated.
But documents do not necessary include these styles. Actually, only one style - "Normal" - is absolutely necessary.
At design time, in the Object Inspector, when you edit Name property of a style (styletemplate), you can see a list of predefined names. However, when you assign Name, other properties are not changed, you need to define them yourself (well, there are some exceptions: for some styles, values of Kind and ParentId properties are adjusted depending on names).
Probably, it would be simpler to fill rvActionNew.StyleTemplates in code than at design time.
For this task, you can use the function from RVStyleFuncs.pas from RichViewActions:
Code: Select all
procedure RVSetStandardStyleDefaults(StyleType: TRVStandardStyle;
Level: Integer; StyleTemplate: TRVStyleTemplate; RVStyle: TRVStyle;
StyleTemplates, StandardStyleTemplates: TRVStyleTemplateCollection;
ControlPanel: TComponent);
StyleType value is one of:
Code: Select all
TRVStandardStyle = (rvssnNormal, rvssnNormalIndent, rvssnNoSpacing,
rvssnHeadingN, rvssnListParagraph, rvssnHyperlink, rvssnTitle,
rvssnSubtitle, rvssnEmphasis, rvssnSubtleEmphasis, rvssnIntenseEmphasis,
rvssnStrong, rvssnQuote, rvssnIntenseQuote, rvssnSubtleReference,
rvssnIntenseReference, rvssnBlockText, rvssnHTMLVariable, rvssnHTMLCode,
rvssnHTMLAcronym, rvssnHTMLDefinition, rvssnHTMLKeyboard, rvssnHTMLSample,
rvssnHTMLTypewriter, rvssnHTMLPreformatted, rvssnHTMLCite, rvssnHeader,
rvssnFooter, rvssnPageNumber, rvssnCaption, rvssnEndnoteReference,
rvssnFootnoteReference, rvssnEndnoteText, rvssnFootnoteText,
rvssnSidenoteReference, rvssnSidenoteText);
Example of use (adding "Title" style and setting its default properties):
Code: Select all
var
ST: TRVStyleTemplate;
ST := rvActionNew1.StyleTemplates.Add;
RVSetStandardStyleDefaults(rvssnTitle, 0, ST, nil, rvActionNew1.StyleTemplates, nil, RVAControlPanel1);
You can use this function to add all standard styles:
Code: Select all
var
SType: TRVStandardStyle;
Level: Integer;
rvActionNew1.StyleTemplates.Clear;
for SType := Low(TRVStandardStyle) to High(TRVStandardStyle) do
RVSetStandardStyleDefaults(SType, 1, rvActionNew1.StyleTemplates.Add, nil, rvActionNew1.StyleTemplates, nil, RVAControlPanel1);
for Level := 2 to 6 do
RVSetStandardStyleDefaults(rvssnHeadingN, Level, rvActionNew1.StyleTemplates.Add, nil, rvActionNew1.StyleTemplates, nil, RVAControlPanel1);
Re: cmbStyles appears empty
Oh, yes.
This is what I was looking for!
Thank you so much, Sergey.
This is what I was looking for!
Thank you so much, Sergey.