Skip to content

Commit

Permalink
Added windows openssl libs
Browse files Browse the repository at this point in the history
  • Loading branch information
sysrpl committed Apr 7, 2015
1 parent faec3e9 commit dff8899
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 23 deletions.
Binary file added libs/i386-win32/libeay32.dll
Binary file not shown.
Binary file added libs/i386-win32/libssl32.dll
Binary file not shown.
46 changes: 33 additions & 13 deletions source/codebot.controls.highlighter.pas
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ interface
Codebot.Graphics.Types,
Codebot.Animation;

type

{ TControlHighlighter }
{ TControlHighlighter }

type
TControlHighlighter = class(TComponent)
private
FOnRender: TDrawRectEvent;
FSplash: ISplash;
FTimer: TAnimationTimer;
FControl: TControl;
Expand All @@ -46,6 +46,7 @@ TControlHighlighter = class(TComponent)
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure Animate(Sender: TObject);
procedure Loaded; override;
procedure Render(Surface: ISurface; Rect: TRectI); virtual;
procedure Update;
public
constructor Create(AOwner: TComponent); override;
Expand All @@ -58,6 +59,7 @@ TControlHighlighter = class(TComponent)
property Radius: Float read FRadius write SetRadius default 8;
property Thickness: Float read FThickness write SetThickness default 4;
property Visible: Boolean read FVisible write SetVisible;
property OnRender: TDrawRectEvent read FOnRender write FOnRender;
end;

implementation
Expand Down Expand Up @@ -104,6 +106,29 @@ procedure TControlHighlighter.Loaded;
Update;
end;

procedure TControlHighlighter.Render(Surface: ISurface; Rect: TRectI);
var
R: TRectF;
C: TColorB;
P: IPen;
begin
if Assigned(FOnRender) then
FOnRender(Self, Surface, Rect)
else
begin
R := Rect;
R.Inflate(FThickness / -2 - 1, FThickness / -2 - 1);
Surface.RoundRectangle(R, FRadius);
C := Color;
C.Alpha := FOpacity;
P := NewPen(C, FThickness);
P.LinePattern := pnDash;
P.LineCap := cpRound;
P.LinePatternOffset := TimeQuery * 4;
Surface.Stroke(P);
end;
end;

procedure TControlHighlighter.Update;

function IsVisible: Boolean;
Expand All @@ -119,6 +144,8 @@ procedure TControlHighlighter.Update;
if not FVisible then
Exit;
C := FControl;
if C.Parent = nil then
Exit;
F := nil;
while C <> nil do
begin
Expand All @@ -139,9 +166,7 @@ procedure TControlHighlighter.Update;
end;

var
R: TRectF;
S: ISurface;
C: TColorB;
P: TPointI;
I: Integer;
begin
Expand All @@ -154,16 +179,11 @@ procedure TControlHighlighter.Update;
end;
FSplash.Bitmap.SetSize(Round(Control.Width + FThickness * 2 + FOffset * 2) + 2,
Round(Control.Height + FThickness * 2 + FOffset * 2) + 2);
R := FSplash.Bitmap.ClientRect;
R.Inflate(FThickness / -2 - 1, FThickness / -2 - 1);
S := FSplash.Bitmap.Surface;
S.Clear(clTransparent);
S.RoundRectangle(R, FRadius);
C := Color;
C.Alpha := FOpacity;
S.Stroke(NewPen(C, FThickness));
P := TPointI.Create;
P := Control.ClientToScreen(P);
Render(S, FSplash.Bitmap.ClientRect);
P := TPointI.Create(Control.Left, Control.Top);
P := Control.Parent.ClientToScreen(P);
I := Round(FThickness + FOffset + 1);
P.Offset(-I, -I);
FSplash.Move(P.X, P.Y);
Expand Down
20 changes: 10 additions & 10 deletions source/codebot.networking.pas
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ function TSocket.Connect(const Address: TAddressName; Port: Word): Boolean;
if FSecure then
if not OpenSSLInit then
Exit(False);
FAddress := Address;
FAddress := Address;
FPort := Port;
if not FAddress.Resolve then
Exit(False);
Expand All @@ -330,15 +330,6 @@ function TSocket.Connect(const Address: TAddressName; Port: Word): Boolean;
Exit(False);
end;
FState := ssClient;
if not FBlocking then
begin
{$ifdef windows}
Mode := 1;
ioctlsocket(FHandle, FIONBIO, Mode);
{$else}
fcntl(FHandle, F_SETFL, O_NONBLOCK);
{$endif}
end;
if FSecure then
begin
FSSLContext := SSL_CTX_new(SSLv23_client_method);
Expand All @@ -364,6 +355,15 @@ function TSocket.Connect(const Address: TAddressName; Port: Word): Boolean;
Exit(False);
end;
end;
if not FBlocking then
begin
{$ifdef windows}
Mode := 1;
ioctlsocket(FHandle, FIONBIO, Mode);
{$else}
fcntl(FHandle, F_SETFL, O_NONBLOCK);
{$endif}
end;
Result := True;
end;

Expand Down

0 comments on commit dff8899

Please sign in to comment.