SynBaseCompletion: Remove a redundant Min() function. Formatting.

git-svn-id: trunk@46024 -
This commit is contained in:
juha 2014-08-09 12:07:00 +00:00
parent 47d83c7efd
commit 458472a65e

View File

@ -877,17 +877,9 @@ end;
procedure TSynBaseCompletionForm.Paint; procedure TSynBaseCompletionForm.Paint;
var var
i: integer; i, Ind: integer;
PaintWidth: Integer; PaintWidth, YYY, RightC, BottomC: Integer;
Capt: String;
function Min(a, b: integer): integer;
begin
if a < b then
Result := a
else
Result := b;
end;
begin begin
//Writeln('[TSynBaseCompletionForm.Paint]'); //Writeln('[TSynBaseCompletionForm.Paint]');
@ -907,18 +899,18 @@ begin
Scroll.Max := 0; Scroll.Max := 0;
end; end;
PaintWidth:=Width-Scroll.Width; PaintWidth := Width - Scroll.Width;
RightC := PaintWidth - 2 * DrawBorderWidth;
//DebugLn(['TSynBaseCompletionForm.Paint NbLinesInWindow=',NbLinesInWindow,' ItemList.Count=',ItemList.Count]); //DebugLn(['TSynBaseCompletionForm.Paint NbLinesInWindow=',NbLinesInWindow,' ItemList.Count=',ItemList.Count]);
for i := 0 to min(NbLinesInWindow - 1, ItemList.Count - Scroll.Position - 1) do for i := 0 to Min(NbLinesInWindow - 1, ItemList.Count - Scroll.Position - 1) do
begin begin
YYY := DrawBorderWidth + FFontHeight * i;
BottomC := (FFontHeight * (i + 1))+1;
if i + Scroll.Position = Position then if i + Scroll.Position = Position then
begin begin
Canvas.Brush.Color := clSelect; Canvas.Brush.Color := clSelect;
Canvas.Pen.Color := clSelect; Canvas.Pen.Color := clSelect;
Canvas.Rectangle(DrawBorderWidth, DrawBorderWidth+(FFontHeight * i), Canvas.Rectangle(DrawBorderWidth, YYY, RightC, BottomC);
PaintWidth-2*DrawBorderWidth,
(FFontHeight * (i + 1))+1);
Canvas.Pen.Color := clBlack; Canvas.Pen.Color := clBlack;
Canvas.Font.Color := TextSelectedColor; Canvas.Font.Color := TextSelectedColor;
Hint := ItemList[Position]; Hint := ItemList[Position];
@ -927,20 +919,15 @@ begin
begin begin
Canvas.Brush.Color := BackgroundColor; Canvas.Brush.Color := BackgroundColor;
Canvas.Font.Color := TextColor; Canvas.Font.Color := TextColor;
Canvas.FillRect(Rect(DrawBorderWidth, DrawBorderWidth+(FFontHeight * i), Canvas.FillRect(Rect(DrawBorderWidth, YYY, RightC, BottomC));
PaintWidth-2*DrawBorderWidth,
(FFontHeight * (i + 1))+1));
end; end;
//DebugLn(['TSynBaseCompletionForm.Paint ',i,' ',ItemList[Scroll.Position + i]]); //DebugLn(['TSynBaseCompletionForm.Paint ',i,' ',ItemList[Scroll.Position + i]]);
if not Assigned(OnPaintItem) or Ind := i + Scroll.Position;
not OnPaintItem(ItemList[Scroll.Position + i], Canvas, Capt := ItemList[Scroll.Position + i];
DrawBorderWidth, DrawBorderWidth+FFontHeight * i, i + Scroll.Position = Position, if not Assigned(OnPaintItem)
i + Scroll.Position or not OnPaintItem(Capt, Canvas, DrawBorderWidth, YYY, Ind = Position, Ind)
) then then
begin Canvas.TextOut(DrawBorderWidth+2, YYY, Capt);
Canvas.TextOut(DrawBorderWidth+2, DrawBorderWidth+FFontHeight * i, ItemList[Scroll.Position + i]);
end;
end; end;
// paint the rest of the background // paint the rest of the background
if NbLinesInWindow > ItemList.Count - Scroll.Position then if NbLinesInWindow > ItemList.Count - Scroll.Position then
@ -950,7 +937,8 @@ begin
Canvas.FillRect(Rect(0, i, PaintWidth, Height)); Canvas.FillRect(Rect(0, i, PaintWidth, Height));
end; end;
// draw a rectangle around the window // draw a rectangle around the window
if DrawBorderWidth > 0 then begin if DrawBorderWidth > 0 then
begin
Canvas.Pen.Color := TextColor; Canvas.Pen.Color := TextColor;
Canvas.Pen.Width := DrawBorderWidth; Canvas.Pen.Width := DrawBorderWidth;
Canvas.Moveto(0, 0); Canvas.Moveto(0, 0);
@ -1307,7 +1295,6 @@ begin
if Assigned(OnPositionChanged) then OnPositionChanged(Self); if Assigned(OnPositionChanged) then OnPositionChanged(Self);
end; end;
end; end;
// ToDo by Juha: Fix THintWindow to show long completion lines again. Disabled temporarily.
if Showing then if Showing then
ShowItemHint(Position); ShowItemHint(Position);
end; end;
@ -1560,8 +1547,7 @@ begin
Form.OnPositionChanged := AValue; Form.OnPositionChanged := AValue;
end; end;
procedure TSynBaseCompletion.SetOnPaintItem(const Value: procedure TSynBaseCompletion.SetOnPaintItem(const Value: TSynBaseCompletionPaintItem);
TSynBaseCompletionPaintItem);
begin begin
form.OnPaintItem := Value; form.OnPaintItem := Value;
end; end;
@ -2134,15 +2120,13 @@ begin
R := ClientRect; R := ClientRect;
Canvas.FillRect(R); Canvas.FillRect(R);
DrawEdge(Canvas.Handle, R, BDR_RAISEDOUTER, BF_RECT); DrawEdge(Canvas.Handle, R, BDR_RAISEDOUTER, BF_RECT);
Canvas.Font.Color := FCompletionForm.TextColor; Canvas.Font.Color := FCompletionForm.TextColor;
if not Assigned(FCompletionForm.OnPaintItem) if not Assigned(FCompletionForm.OnPaintItem)
or not FCompletionForm.OnPaintItem(Caption, Canvas, 1, 1, or not FCompletionForm.OnPaintItem(Caption, Canvas, 1, 1,
FCompletionForm.Position = FIndex, FIndex) FCompletionForm.Position = FIndex, FIndex)
then begin then
Canvas.TextOut(2, 2, Caption); Canvas.TextOut(2, 2, Caption);
end;
end; end;
constructor TSynBaseCompletionHint.Create(AOwner: TComponent); constructor TSynBaseCompletionHint.Create(AOwner: TComponent);