#16 Merged rjmills' EditOptionDialog patch with 201b

open
nobody
None
5
2005-07-18
2005-07-18
No

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?

Discussion

  • PyScripter

    PyScripter - 2005-07-20

    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;

     
  • PyScripter

    PyScripter - 2005-07-20

    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.

     
  • Ferenc Kubatovics

    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.

     
  • PyScripter

    PyScripter - 2005-07-20

    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;

     
  • Ferenc Kubatovics

    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.

     
  • Ferenc Kubatovics

    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.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks