Skip to content

Commit

Permalink
Added TSizingPanel
Browse files Browse the repository at this point in the history
  • Loading branch information
sysrpl committed Mar 14, 2015
1 parent 4de8219 commit da061ae
Show file tree
Hide file tree
Showing 27 changed files with 1,233 additions and 401 deletions.
Binary file added palette/TBanner.bmp
Binary file not shown.
File renamed without changes.
Binary file added palette/TThinButton.bmp
Binary file not shown.
4 changes: 3 additions & 1 deletion palette/make.bat
@@ -1,12 +1,14 @@
..\..\..\..\FreePascal\lazarus\tools\lazres.exe ..\source\palette_icons.res ^
TIndeterminateProgress.bmp ^
TThinButton.bmp ^
TRenderBox.bmp ^
TRenderImage.bmp ^
TBorderContainer.bmp ^
TSizingPanel.bmp ^
TImageStrip.bmp ^
TContentGrid.bmp ^
TDrawList.bmp ^
TDrawTextList.bmp ^
THuePicker.bmp ^
TSaturationPicker.bmp ^
TBanner.bmp ^
TSlideBar.bmp
Binary file modified resources/Help.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/progress_status.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/progress_status_alt.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 62 additions & 14 deletions source/codebot.controls.buttons.pas
Expand Up @@ -22,17 +22,22 @@ interface

{ TCustomThinButton }

type
TButtonKind = (bkButton, skDropDown, bkSplitter);

type
TCustomThinButton = class(TRenderGraphicControl)
private
FKind: TButtonKind;
FImages: TImageStrip;
FImageIndex: Integer;
FDown: Boolean;
FOnDrawButton: TDrawStateEvent;
procedure SetKind(Value: TButtonKind);
procedure SetDown(Value: Boolean);
procedure SetImages(Value: TImageStrip);
procedure SetImageIndex(Value: Integer);
procedure ImagesChanged(Sender: TObject);
procedure SetDown(Value: Boolean);
protected
function ThemeAware: Boolean; override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
Expand All @@ -46,10 +51,12 @@ TCustomThinButton = class(TRenderGraphicControl)
procedure MouseLeave; override;
procedure Render; override;
property Down: Boolean read FDown write SetDown;
property Kind: TButtonKind read FKind write SetKind default bkButton;
property OnDrawButton: TDrawStateEvent read FOnDrawButton write FOnDrawButton;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Click;
end;

{ TThinButton }
Expand All @@ -69,6 +76,7 @@ TThinButton = class(TCustomThinButton)
property Enabled;
property Images;
property ImageIndex;
property Kind;
property Visible;
property OnClick;
property OnDblClick;
Expand Down Expand Up @@ -109,6 +117,12 @@ destructor TCustomThinButton.Destroy;
inherited Destroy;
end;

procedure TCustomThinButton.Click;
begin
if Assigned(OnClick) then
OnClick(Self);
end;

procedure TCustomThinButton.ImagesChanged(Sender: TObject);
begin
Invalidate;
Expand Down Expand Up @@ -148,6 +162,31 @@ procedure TCustomThinButton.SetImages(Value: TImageStrip);
end;
end;

procedure TCustomThinButton.SetKind(Value: TButtonKind);
begin
if FKind = Value then Exit;
FKind := Value;
FDown := False;
if FKind = bkSplitter then
Width := 16
else
Width := 32;
DrawState := [];
Invalidate;
end;

procedure TCustomThinButton.SetDown(Value: Boolean);
begin
if FKind <> bkButton then
Value := False;
if FDown = Value then Exit;
FDown := Value;
if FDown then
DrawState := [dsHot, dsPressed]
else
DrawState := [];
end;

function TCustomThinButton.ThemeAware: Boolean;
begin
Result := True;
Expand All @@ -157,6 +196,8 @@ procedure TCustomThinButton.MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
begin
inherited MouseDown(Button, Shift, X, Y);
if FKind = bkSplitter then
Exit;
if not FDown then
if Button = mbLeft then
DrawState := DrawState + [dsPressed];
Expand All @@ -169,6 +210,8 @@ procedure TCustomThinButton.MouseMove(Shift: TShiftState; X, Y: Integer);
inherited MouseMove(Shift, X, Y);
if FDown then
Exit;
if FKind = bkSplitter then
Exit;
R := ClientRect;
if R.Contains(X, Y) then
DrawState := DrawState + [dsHot]
Expand All @@ -180,6 +223,8 @@ procedure TCustomThinButton.MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
begin
inherited MouseUp(Button, Shift, X, Y);
if FKind = bkSplitter then
Exit;
if not FDown then
if Button = mbLeft then
DrawState := DrawState - [dsPressed];
Expand All @@ -188,20 +233,25 @@ procedure TCustomThinButton.MouseUp(Button: TMouseButton; Shift: TShiftState;
procedure TCustomThinButton.MouseEnter;
begin
inherited MouseEnter;
if FKind = bkSplitter then
Exit;
if not FDown then
DrawState := DrawState + [dsHot];
end;

procedure TCustomThinButton.MouseLeave;
begin
inherited MouseLeave;
if FKind = bkSplitter then
Exit;
if not FDown then
DrawState := DrawState - [dsHot];
end;

procedure TCustomThinButton.Render;
var
D: TDrawState;
R: TRectI;
begin
inherited Render;
if csDesigning in ComponentState then
Expand All @@ -212,10 +262,18 @@ procedure TCustomThinButton.Render;
D := [dsHot];
Theme.Select(D);
end;
if Assigned(FOnDrawButton) then
FOnDrawButton(Self, Surface, ClientRect, DrawState)
R := ClientRect;
if FKind = bkSplitter then
begin
if csDesigning in ComponentState then
Surface.StrokeRoundRect(NewPen(CurrentColor.Darken(0.05)), R, 3);
R.Inflate(0, -2);
Theme.DrawSplit(R, toVertical);
end
else if Assigned(FOnDrawButton) then
FOnDrawButton(Self, Surface, R, DrawState)
else
Theme.DrawButtonThin(ClientRect);
Theme.DrawButtonThin(R);
if FImages <> nil then
begin
FImages.Draw(Surface, FImageIndex,
Expand All @@ -224,15 +282,5 @@ procedure TCustomThinButton.Render;
end;
end;

procedure TCustomThinButton.SetDown(Value: Boolean);
begin
if FDown = Value then Exit;
FDown := Value;
if FDown then
DrawState := [dsHot, dsPressed]
else
DrawState := [];
end;

end.

0 comments on commit da061ae

Please sign in to comment.