EControl Ltd. Forum Index EControl Ltd.
VCL libraries and software support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Curious drawing anomaly

 
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Syntax Editor
View previous topic :: View next topic  
Author Message
itsatomic



Joined: 12 Jun 2006
Posts: 38

PostPosted: Wed Jul 19, 2006 1:05 am    Post subject: Curious drawing anomaly Reply with quote

Hi Michael

I am playing with the editor control, finally!

One thing I have noticed, using a dotted line (top and bottom) for currentline style:

As you move the cursor to the right, over existing text, it looks like the current line is being redrawn from the cursor to EOL. The dotted lines are slightly offset for each redraw, so if you hold down the --> right arrow key, it looks like the dotted lines are moving as you move the cursor.

It is not an annoyance or even really a bug, but it does look a little strange.

Hope I have described the situation clearly enough!

Aaron
Back to top
View user's profile Send private message
econtrol
Site Admin


Joined: 09 Jun 2006
Posts: 202

PostPosted: Wed Jul 19, 2006 8:53 pm    Post subject: Reply with quote

Hi Aaron,

Fixing (ecSyntMemo.pas, corrected implementation of internal procedure DrawBounds in ProcessLine):

Code:
procedure DrawBounds(SPos, EPos: integer; Rt: TRect);
  var i, dw, x, ls: integer;
      SmartBound, Valid: Boolean;
      p, ps, pe: TPoint;
  begin
    for i := 0 to StlList.Count - 1 do
     with TStyleEntry(StlList[i]) do
      if Assigned(Style) and Style.HasBorder then
      begin
        SmartBound := Style.MultiLineBorder;
        // Left border
        if (Style.BorderTypeLeft <> blNone) and (StartPos = SPos) or
           SmartBound and (Rt.Left = R.Left) then
         begin
          Canvas.Pen.Color := Style.BorderColorLeft;
          dw := GetBorderLineWidth(Style.BorderTypeLeft) div 2;
          DrawBorder(Canvas, Style.BorderTypeLeft, Point(Rt.Left + dw, Rt.Top), Point(Rt.Left + dw, Rt.Bottom));
         end;
        // right border
        if (Style.BorderTypeRight <> blNone) and (EndPos = EPos) or
           SmartBound and (Rt.Right = R.Right) then
         begin
          Canvas.Pen.Color := Style.BorderColorRight;
          dw := (GetBorderLineWidth(Style.BorderTypeRight) + 1) div 2;
          DrawBorder(Canvas, Style.BorderTypeRight, Point(Rt.Right - dw, Rt.Top), Point(Rt.Right - dw, Rt.Bottom));
         end;

        if (Style.BorderTypeTop = blNone) and
           (Style.BorderTypeBottom = blNone) or
           (EPos < EndPos) and not LineEnd then Exit;

        if BasePos > StartPos then ls := FMargine.Left
         else ls := CaretToMouse(StartPos - BasePos, Line).X;

        if SmartBound then
         begin
          ps := StrPosToCaretPos(StartPos);
          pe := StrPosToCaretPos(EndPos);
          SmartBound := ps.Y < pe.Y;
         end;

        // Bottom
        if Style.BorderTypeBottom <> blNone then
         begin
          x := ls;
          Valid := True;
          if SmartBound then
           if pe.Y > Line + 1 then Valid := False else
            if pe.Y = Line + 1 then
             begin
              p := CaretToMouse(pe.X, pe.Y);
              if (Rt.Top < p.Y) then
               begin
                if (Rt.Right <= p.X) or (p.Y - Rt.Bottom - 1 >= FLineSpacing) then Valid := False;
                if x < p.X then x := p.X;
               end;
             end;
          if Valid then
           begin
            Canvas.Pen.Color := Style.BorderColorBottom;
            dw := (GetBorderLineWidth(Style.BorderTypeBottom) + 1) div 2;
            DrawBorder(Canvas, Style.BorderTypeBottom, Point(x, Rt.Bottom - dw), Point(Rt.Right, Rt.Bottom - dw));
           end;
         end;

        // Top
        if Style.BorderTypeTop <> blNone then
         begin
          x := Rt.Right;
          Valid := True;
          if SmartBound then
           if ps.Y < Line - 1 then Valid := False else
            if ps.Y = Line - 1 then
             begin
              p := CaretToMouse(ps.X, ps.Y);
              if (Rt.Top > p.Y) then
               begin
                dw := SingleLineHeight(ps.Y) + FLineSpacing;
                if (ls >= p.X) or (Rt.Top - p.Y > dw) then Valid := False;
                if Rt.Right > p.X then x := p.X;
                ls := FMargine.Left;
               end;
             end;
          if Valid then
           begin
            Canvas.Pen.Color := Style.BorderColorTop;
            dw := GetBorderLineWidth(Style.BorderTypeTop) div 2;
            DrawBorder(Canvas, Style.BorderTypeTop, Point(ls, Rt.Top + dw), Point(x, Rt.Top + dw));
           end;
         end;
      end;
  end;
Back to top
View user's profile Send private message Send e-mail
itsatomic



Joined: 12 Jun 2006
Posts: 38

PostPosted: Fri Jul 21, 2006 7:55 am    Post subject: Reply with quote

wow, ok, i'll look into that when i can.

Thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Syntax Editor All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group