Hi!
I merged the EditOptionDialog patch of Ryan J. Mills
(rjmills) with the 201b version.
Original patch: [1037809] Modifications to the
SynEditOptions Dialog
Its description:
"Modifications to the SynEditOptions Dialog
This modified SynEditOptions Dialog component add
support for turning pages on or off programmatically.
As well as adding a page for customizing the colors of
the specified SynHighlighters."
The original patch uses TColorBox as the color picker
which is in my opinion is a good choice, however it
might not be available below D6 or D7 (see known
issues).
I made some modifications to the original patch:
- Changed the new control's names to make them a
little bit more consistent with the other controls on the
dialog.
- Removed the internal FHighlighters list as the
combobox already holds references to the temporary
highlighter instances. I think it was necessary as the
combobox is sorted alphabetically and this might cause
bugs as the order of items in the two list might be
different
- Changed ColorBox properties to handle custom and
system colors better.
Known Issues:
- TColorBox most probably is not available below D7
(or D6?)
- The same color picker "Combo" should be used on
each sheet.
Do we really want to support older Delphi versions?
Logged In: YES
user_id=714426
No attachment in this and the other patch you submitted.
Also the original patch of Ryan J. Mills contained another
nasty bug. All the checkboxes of the "Text Attributes"
group box in the Syntax Colors tab (cbxElementBold,
cbxElementItalic, cbxElementUnderline,
cbxElementStrikeout) have the same OnClick event handler
(cbxElementBoldClick) which is unfortunately triggered many
times in lbElementsClick after a new Syntax element is
selected and messes up the element attributes.
It is a known problem with checkboxes whereby the OnClick
method is triggered when you programmatically change the
value of the Checked property, even when the check box is
disabled!
My workaround is as follows:
a) Change lbElementsClick. Added the line
EnableColorItems(false);
procedure TfmEditorOptionsDialog.lbElementsClick(Sender:
TObject);
var
wSynH : TSynCustomHighlighter;
wSynAttr : TSynHighlighterAttributes;
begin
if lbElements.itemindex <> -1 then
begin
EnableColorItems(false);
wSynH := SelectedHighlighter;
wSynAttr := wSynH.Attribute[lbElements.ItemIndex];
cbxElementBold.Checked := (fsBold in wSynAttr.Style);
cbxElementItalic.Checked := (fsItalic in wSynAttr.Style);
cbxElementUnderline.Checked := (fsUnderline in
wSynAttr.Style);
cbxElementStrikeout.Checked := (fsStrikeOut in
wSynAttr.Style);
cbElementForeground.Selected := wSynAttr.Foreground;
cbElementBackground.Selected := wSynAttr.Background;
EnableColorItems(true);
end
else
EnableColorItems(false);
end;
b) Changed cbxElementBoldClick to
procedure TfmEditorOptionsDialog.cbxElementBoldClick(Sender:
TObject);
begin
// fixing a hard to find bug whereby
// when you clicked on style the UpdateColorFontStyle
// was called messing things up
if cbxElementBold.Enabled then
UpdateColorFontStyle;
end;
Logged In: YES
user_id=714426
Another problem with the SynEdit Options Dialog is that the
TSynEditorOptionsContainer.Assign cannot assign values to
another instance of TSynEditorOptionsContainer (just works
with TSynEdit instances). Sometimes you need to have more
than one instances of TSynEditorOptionsContainer and assign
values between them. Would it be possible to extend
TSynEditorOptionsContainer.Assign to deal with other
instances of TSynEditorOptionsContainer?
It's a trivial change but if your patch is accepted we might
as well get this feature in the CVS.
Logged In: YES
user_id=1256155
I remeber attaching the fixes and I even downloaded them
because I wanted to make sure that everything is OK. Now
they gone.. ;-) I have already attached the other bugfix, but I
want to fix those CheckBox bug before resubmitting this
patch. Hope I could do it tomorrow. Sorry for the trouble.
The Assign/AssignTo thing is simple task to do, I will do it if I
had a little time.
Does anybody know why it was necessary to code AssignTo
as well. My intuition tells me that AssignTo can be quite
easily converted to an Assign call.
To fix this CheckBox bug I took a little different approach: I
added a new FHandleChanges field to the class, which is
True most of the time. It only gets a False when I explicitly
want to avoid execution of event handlers, eg. in
lbElementsClick. I can check the value if this field in event
handlers. I think this is a little bit more direct way to achive
the goal, and the code is more understandable.
I started to add another functionality to the Option dialog: in
my application, I have to show application level options (eg.
Code completion options, and so on.). So I added some
events with which it is possible to customize the dialog in
runtime.
Logged In: YES
user_id=714426
Here is the modified Assign method. No need to touch the
AssignTo method. It is needed if one wants to do:
SynEdit.Assign(SynEditorOptionsContainer)
Look at TPersistent.Assign if you want to understand why.
procedure TSynEditorOptionsContainer.Assign(Source:
TPersistent);
begin
if Assigned(Source) and (Source is TCustomSynEdit) then
begin
Self.Font.Assign(TCustomSynEdit(Source).Font);
Self.BookmarkOptions.Assign(TCustomSynEdit(Source).BookmarkOptions);
Self.Gutter.Assign(TCustomSynEdit(Source).Gutter);
Self.Keystrokes.Assign(TCustomSynEdit(Source).Keystrokes);
Self.SelectedColor.Assign(TCustomSynEdit(Source).SelectedColor);
Self.Color := TCustomSynEdit(Source).Color;
Self.Options := TCustomSynEdit(Source).Options;
Self.ExtraLineSpacing :=
TCustomSynEdit(Source).ExtraLineSpacing;
Self.HideSelection := TCustomSynEdit(Source).HideSelection;
Self.InsertCaret := TCustomSynEdit(Source).InsertCaret;
Self.OverwriteCaret :=
TCustomSynEdit(Source).OverwriteCaret;
Self.MaxScrollWidth :=
TCustomSynEdit(Source).MaxScrollWidth;
Self.MaxUndo := TCustomSynEdit(Source).MaxUndo;
Self.RightEdge := TCustomSynEdit(Source).RightEdge;
Self.RightEdgeColor :=
TCustomSynEdit(Source).RightEdgeColor;
Self.TabWidth := TCustomSynEdit(Source).TabWidth;
Self.WantTabs := TCustomSynEdit(Source).WantTabs;
//!! Self.WordBreakChars := TSynEdit(Source).WordBreakChars;
end else if Assigned(Source) and (Source is
TSynEditorOptionsContainer) then
begin
Self.Font.Assign(TSynEditorOptionsContainer(Source).Font);
Self.BookmarkOptions.Assign(TSynEditorOptionsContainer(Source).BookmarkOptions);
Self.Gutter.Assign(TSynEditorOptionsContainer(Source).Gutter);
Self.Keystrokes.Assign(TSynEditorOptionsContainer(Source).Keystrokes);
Self.SelectedColor.Assign(TSynEditorOptionsContainer(Source).SelectedColor);
Self.Color := TSynEditorOptionsContainer(Source).Color;
Self.Options := TSynEditorOptionsContainer(Source).Options;
Self.ExtraLineSpacing :=
TSynEditorOptionsContainer(Source).ExtraLineSpacing;
Self.HideSelection :=
TSynEditorOptionsContainer(Source).HideSelection;
Self.InsertCaret :=
TSynEditorOptionsContainer(Source).InsertCaret;
Self.OverwriteCaret :=
TSynEditorOptionsContainer(Source).OverwriteCaret;
Self.MaxScrollWidth :=
TSynEditorOptionsContainer(Source).MaxScrollWidth;
Self.MaxUndo := TSynEditorOptionsContainer(Source).MaxUndo;
Self.RightEdge :=
TSynEditorOptionsContainer(Source).RightEdge;
Self.RightEdgeColor :=
TSynEditorOptionsContainer(Source).RightEdgeColor;
Self.TabWidth :=
TSynEditorOptionsContainer(Source).TabWidth;
Self.WantTabs :=
TSynEditorOptionsContainer(Source).WantTabs;
end else
inherited;
end;
Logged In: YES
user_id=1256155
Checkbox bug and Assig RFE included, however TColorBox
has a serious bug if an uninitialized custom color is selected
(see details in source). I have already fixed it and it involves a
descended TColorBox class (this fix is not in this patch).
Please let me know if there are more known bugs or feature
request for OptionDialog.
Logged In: YES
user_id=1256155
fixed a tricky bug which occured only during design-time.
Delphi do not load dfm resources during design time and
ClearHighlighters tried to use a non-existing component.
EditOptionDlg v201b_3.zip