fixed interface constraints, fixed syncompletion colors

git-svn-id: trunk@5354 -
This commit is contained in:
mattias 2004-03-30 20:38:14 +00:00
parent 3b4effd0ac
commit 1ad1a10321
7 changed files with 63 additions and 24 deletions

View File

@ -78,6 +78,7 @@ type
FClSelect: TColor;
FAnsi: boolean;
{$IFDEF SYN_LAZARUS}
FBackgroundColor: TColor;
FOnSearchPosition:TSynBaseCompletionSearchPosition;
FOnKeyCompletePrefix: TNotifyEvent;
FTextColor: TColor;
@ -127,6 +128,7 @@ type
property OnSearchPosition:TSynBaseCompletionSearchPosition
read FOnSearchPosition write FOnSearchPosition;
property OnKeyCompletePrefix: TNotifyEvent read FOnKeyCompletePrefix write FOnKeyCompletePrefix;
property BackgroundColor: TColor read FBackgroundColor write FBackgroundColor;
property TextColor: TColor read FTextColor write FTextColor;
property TextSelectedColor: TColor
read FTextSelectedColor write FTextSelectedColor;
@ -311,15 +313,19 @@ begin
Scroll.Width := 10;
{$IFDEF SYN_LAZARUS}
Scroll.Visible := True;
Scroll.Anchors:=[akRight];
Scroll.Anchors:=[akTop,akRight];
Scroll.Align:=alRight;
FTextColor:=clBlack;
FTextSelectedColor:=clWhite;
Caption:='Completion';
Color:=clNone;
FBackgroundColor:=clWhite;
{$ENDIF}
Visible := false;
FFontHeight := Canvas.TextHeight('Cyrille de Brebisson')+2;
{$IFNDEF SYN_LAZARUS}
Color := clWindow;
{$ENDIF}
ClSelect := clHighlight;
TStringList(FItemList).OnChange := {$IFDEF FPC}@{$ENDIF}StringListChange;
bitmap := TBitmap.Create;
@ -446,18 +452,17 @@ begin
{$ENDIF}
Scroll.LargeChange := NbLinesInWindow;
{$IFNDEF SYN_LAZARUS}
// bitmap.canvas.draw is unfinished in lcl
with bitmap do begin
canvas.pen.color := color;
{$IFNDEF SYN_LAZARUS}
canvas.pen.color := fbcolor;
canvas.brush.color := color;
canvas.Rectangle(0, 0, Width, Height);
{$ENDIF}
{$ENDIF}
for i := 0 to min(NbLinesInWindow - 1, ItemList.Count - 1) do begin
if i + Scroll.Position = Position then begin
Canvas.Brush.Color := clSelect;
Canvas.Pen.Color := clSelect;
Canvas.Rectangle(0, (FFontHeight * i)+1, width, (FFontHeight * (i + 1))+1);
Canvas.Rectangle(0, (FFontHeight * i), width, (FFontHeight * (i + 1))+1);
Canvas.Pen.Color := clBlack;
{$IFDEF SYN_LAZARUS}
Canvas.Font.Color := TextSelectedColor;
@ -468,11 +473,12 @@ begin
end
else
Begin
Canvas.Brush.Color := Color;
{$IFDEF SYN_LAZARUS}
Canvas.Brush.Color := BackgroundColor;
Canvas.Font.Color := TextColor;
Canvas.FillRect(Rect(0, (FFontHeight * i)+1, width, (FFontHeight * (i + 1))+1));
Canvas.FillRect(Rect(0, (FFontHeight * i), width, (FFontHeight * (i + 1))+1));
{$ELSE}
Canvas.Brush.Color := Color;
Canvas.Font.Color := clBlack;
{$ENDIF}
end;
@ -480,7 +486,7 @@ begin
if not Assigned(OnPaintItem)
or not OnPaintItem(ItemList[Scroll.Position + i], Canvas,
{$IFDEF SYN_LAZARUS}
1, FFontHeight * i +1, i + Scroll.Position = Position,
0, FFontHeight * i, i + Scroll.Position = Position,
i + Scroll.Position
{$ELSE}
0, FFontHeight * i
@ -499,11 +505,9 @@ begin
canvas.FillRect(Rect(0, i, Width, Height));
end;
{$ENDIF}
{$IFNDEF SYN_LAZARUS}
end;
Canvas.Draw(1, 1, bitmap);
// draw a rectangle around the window
{$ENDIF}
{$IFDEF SYN_LAZARUS}
Canvas.Pen.Color := TextColor;
{$ELSE}

View File

@ -58,21 +58,34 @@ implementation
procedure PaintCompletionItem(const AKey: string; ACanvas: TCanvas;
X, Y, MaxX: integer; ItemSelected: boolean; Index: integer;
aCompletion : TSynCompletion; CurrentCompletionType: TCompletionType);
var
BGRed: Integer;
BGGreen: Integer;
BGBlue: Integer;
function InvertColor(AColor: TColor): TColor;
var Red, Green, Blue: integer;
begin
Result:=clWhite;
Red:=(AColor shr 16) and $ff;
Green:=(AColor shr 8) and $ff;
Blue:=AColor and $ff;
if Red+Green+Blue>$180 then
Result:=clBlack;
Red:=Red+$a0;
Green:=Green+$a0;
Blue:=Blue+$a0;
Result:=((Red and $ff) shl 16)+((Green and $ff) shl 8)+(Blue and $ff);
end;
procedure SetFontColor(NewColor: TColor);
var
FGRed: Integer;
FGGreen: Integer;
FGBlue: Integer;
begin
if ItemSelected then NewColor:=InvertColor(NewColor);
FGRed:=(NewColor shr 16) and $ff;
FGGreen:=(NewColor shr 8) and $ff;
FGBlue:=NewColor and $ff;
if Abs(FGRed-BGRed)+Abs(FGGreen-BGGreen)+Abs(FGBlue-BGBlue)<$180 then
NewColor:=InvertColor(NewColor);
ACanvas.Font.Color:=NewColor;
end;
@ -82,6 +95,7 @@ var
IdentItem: TIdentifierListItem;
AColor: TColor;
ANode: TCodeTreeNode;
BackgroundColor: TColor;
begin
if CurrentCompletionType=ctIdentCompletion then begin
// draw
@ -90,6 +104,11 @@ begin
ACanvas.TextOut(x+1, y, 'PaintCompletionItem: BUG in codetools');
exit;
end;
BackgroundColor:=ACanvas.Brush.Color;
BGRed:=(BackgroundColor shr 16) and $ff;
BGGreen:=(BackgroundColor shr 8) and $ff;
BGBlue:=BackgroundColor and $ff;
// first write the type
// var, procedure, property, function, type, const
case IdentItem.GetDesc of
@ -132,7 +151,7 @@ begin
AColor:=clGray;
s:='';
end;
SetFontColor(AColor);
ACanvas.TextOut(x+1,y,s);
inc(x,ACanvas.TextWidth('procedure '));

View File

@ -1482,7 +1482,7 @@ begin
fSyntaxHighlighterType:=ASyntaxHighlighterType;
end;
EditorOpts.GetSynEditSelectedColor(FEditor);
TSourceNoteBook(FAOwner).UpdateActiveEditColors;
SourceNoteBook.UpdateActiveEditColors;
end;
procedure TSourceEditor.SetErrorLine(NewLine: integer);
@ -1501,11 +1501,12 @@ begin
EditorComponent.Invalidate;
end;
Function TSourceEditor.RefreshEditorSettings : Boolean;
Function TSourceEditor.RefreshEditorSettings: Boolean;
Begin
Result:=true;
SetSyntaxHighlighterType(fSyntaxHighlighterType);
EditorOpts.GetSynEditSettings(FEditor);
SourceNoteBook.UpdateActiveEditColors;
if EditorOpts.CtrlMouseLinks then
FEditor.Options:=FEditor.Options+[eoShowCtrlMouseLinks]
else
@ -2668,10 +2669,15 @@ Begin
// set colors
if (ActiveEditor<>nil) and (CurCompletionControl.TheForm<>nil) then begin
with CurCompletionControl.TheForm do begin
Color:=FActiveEditDefaultBGColor;
BackgroundColor:=FActiveEditDefaultBGColor;
clSelect:=FActiveEditSelectedBGColor;
TextColor:=FActiveEditDefaultFGColor;
TextSelectedColor:=FActiveEditSelectedFGColor;
//writeln('TSourceNotebook.ccExecute A Color=',HexStr(Cardinal(Color),8),
// ' clSelect=',HexStr(Cardinal(clSelect),8),
// ' TextColor=',HexStr(Cardinal(TextColor),8),
// ' TextSelectedColor=',HexStr(Cardinal(TextSelectedColor),8),
// '');
end;
end;
End;

View File

@ -86,7 +86,8 @@ begin
// switch width and height
OldWidth:=Width;
OldHeight:=Height;
RecreateWnd;
if HandleAllocated then
RecreateWnd;
SetBounds(Left,Top,OldHeight,OldWidth);
end;
end;
@ -116,7 +117,7 @@ begin
end;
if HandleAllocated then
CNSendMEssage(LM_SetProperties,Self,nil);
CNSendMessage(LM_SetProperties,Self,nil);
end;
procedure TScrollBar.SetPosition(Value: Integer);

View File

@ -2983,6 +2983,7 @@ begin
FCreatingHandle := True;
try
FHandle := WidgetSetClass.CreateHandle(Self, Params);
Constraints.UpdateInterfaceConstraints;
FFlags:=FFlags-[wcfColorChanged,wcfFontChanged];
if not HandleAllocated then
RaiseGDBException('Handle creation failed');
@ -3445,6 +3446,9 @@ end;
{ =============================================================================
$Log$
Revision 1.214 2004/03/30 20:38:14 mattias
fixed interface constraints, fixed syncompletion colors
Revision 1.213 2004/03/19 00:03:15 marc
* Moved the implementation of (GTK)ButtonCreateHandle to the new
(GTK)WSButton class

View File

@ -120,6 +120,7 @@ begin
Widget:=GetStyleWidget(lgsVerticalScrollbar);
MinWidth:=Widget^.requisition.Width;
end;
writeln('TGtkWidgetSet.GetControlConstraints A ',MinWidth,',',MinHeight,' ',TScrollBar(SizeConstraints.Control).Kind=sbHorizontal,' ',TScrollBar(SizeConstraints.Control).Name);
SizeConstraints.SetInterfaceConstraints(MinWidth,MinHeight,
MinWidth,MinHeight);
end;
@ -462,6 +463,9 @@ end;
{ =============================================================================
$Log$
Revision 1.25 2004/03/30 20:38:14 mattias
fixed interface constraints, fixed syncompletion colors
Revision 1.24 2004/03/28 12:49:22 mattias
implemented mask merge and extraction for raw images

View File

@ -4167,7 +4167,6 @@ begin
ReleaseDC(0, DC);
end;
if not IsValidDC(DC) then exit;
BeginGDKErrorTrap;
with TDeviceContext(DC) do
Case Index of
HORZRES : { Horizontal width in pixels }
@ -4225,7 +4224,6 @@ begin
else
writeln('TGtkWidgetSet.GetDeviceCaps not supported: Type=',Index);
end;
EndGDKErrorTrap;
end;
{------------------------------------------------------------------------------
@ -8748,6 +8746,9 @@ end;
{ =============================================================================
$Log$
Revision 1.343 2004/03/30 20:38:14 mattias
fixed interface constraints, fixed syncompletion colors
Revision 1.342 2004/03/28 12:49:23 mattias
implemented mask merge and extraction for raw images