mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 05:30:45 +02:00
make flat speedbuttons nicer
git-svn-id: trunk@5586 -
This commit is contained in:
parent
2f2af5bedf
commit
69017c434d
@ -91,17 +91,17 @@ var
|
|||||||
TS : TTextStyle;
|
TS : TTextStyle;
|
||||||
begin
|
begin
|
||||||
ARect := GetClientRect;
|
ARect := GetClientRect;
|
||||||
if BorderStyle = bsSingle then begin
|
if BevelOuter <> bvNone then
|
||||||
Canvas.Rectangle(ARect);
|
begin
|
||||||
|
Canvas.Frame3d(ARect, BevelWidth, BevelOuter);
|
||||||
InflateRect(ARect, -1, -1);
|
InflateRect(ARect, -1, -1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if BevelOuter <> bvNone then
|
if BevelInner <> bvNone then
|
||||||
Canvas.Frame3d(ARect, BevelWidth, BevelOuter);
|
begin
|
||||||
|
|
||||||
if BevelInner <> bvNone then begin
|
|
||||||
if BorderWidth > 0 then InflateRect(ARect, -BorderWidth, -BorderWidth);
|
if BorderWidth > 0 then InflateRect(ARect, -BorderWidth, -BorderWidth);
|
||||||
Canvas.Frame3d(ARect, BevelWidth, BevelInner);
|
Canvas.Frame3d(ARect, BevelWidth, BevelInner);
|
||||||
|
InflateRect(ARect, -1, -1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if Caption <> '' then begin
|
if Caption <> '' then begin
|
||||||
|
@ -246,14 +246,19 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function TSpeedButton.GetDrawFlags: integer;
|
function TSpeedButton.GetDrawFlags: integer;
|
||||||
begin
|
begin
|
||||||
Result:=DFCS_BUTTONPUSH;
|
// if flat and not mouse in control and not down, don't draw anything
|
||||||
if FState in [bsDown, bsExclusive] then inc(Result,DFCS_PUSHED);
|
if FFlat and not FMouseInControl and not (FState in [bsDown, bsExclusive]) then
|
||||||
if not Enabled then inc(Result,DFCS_INACTIVE);
|
begin
|
||||||
|
Result := 0;
|
||||||
if Flat and (not (csDesigning in ComponentState)) and
|
end else begin
|
||||||
not FMouseInControl and not (FState in [bsDown, bsExclusive])
|
Result:=DFCS_BUTTONPUSH;
|
||||||
then
|
if FState in [bsDown, bsExclusive] then
|
||||||
inc(Result,DFCS_FLAT);
|
inc(Result,DFCS_PUSHED);
|
||||||
|
if not Enabled then
|
||||||
|
inc(Result,DFCS_INACTIVE);
|
||||||
|
if FFlat then
|
||||||
|
inc(Result,DFCS_FLAT);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSpeedButton.ActionChange(Sender: TObject; CheckDefaults: Boolean);
|
procedure TSpeedButton.ActionChange(Sender: TObject; CheckDefaults: Boolean);
|
||||||
@ -372,8 +377,10 @@ begin
|
|||||||
|
|
||||||
FLastDrawFlags:=GetDrawFlags;
|
FLastDrawFlags:=GetDrawFlags;
|
||||||
//DebugLn('TSpeedbutton.Paint ',Name,':',ClassName,' Parent.Name=',Parent.Name);
|
//DebugLn('TSpeedbutton.Paint ',Name,':',ClassName,' Parent.Name=',Parent.Name);
|
||||||
DrawFrameControl(Canvas.GetUpdatedHandle([csBrushValid,csPenValid]),
|
// do not draw anything if flat and mouse not in control (simplified)
|
||||||
PaintRect, DFC_BUTTON, FLastDrawFlags);
|
if FLastDrawFlags <> 0 then
|
||||||
|
DrawFrameControl(Canvas.GetUpdatedHandle([csBrushValid,csPenValid]),
|
||||||
|
PaintRect, DFC_BUTTON, FLastDrawFlags);
|
||||||
|
|
||||||
GlyphWidth:= TButtonGlyph(FGlyph).Glyph.Width;
|
GlyphWidth:= TButtonGlyph(FGlyph).Glyph.Width;
|
||||||
if TButtonGlyph(FGlyph).NumGlyphs > 1 then
|
if TButtonGlyph(FGlyph).NumGlyphs > 1 then
|
||||||
@ -772,6 +779,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.55 2004/06/20 12:29:26 micha
|
||||||
|
make flat speedbuttons nicer
|
||||||
|
|
||||||
Revision 1.54 2004/06/19 15:36:29 micha
|
Revision 1.54 2004/06/19 15:36:29 micha
|
||||||
fix speedbutton group in design mode
|
fix speedbutton group in design mode
|
||||||
|
|
||||||
|
@ -1008,10 +1008,20 @@ End;
|
|||||||
Draws a frame control of the specified type and style.
|
Draws a frame control of the specified type and style.
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
Function TWin32WidgetSet.DrawFrameControl(DC: HDC; Var Rect: TRect; UType, UState: Cardinal): Boolean;
|
Function TWin32WidgetSet.DrawFrameControl(DC: HDC; Var Rect: TRect; UType, UState: Cardinal): Boolean;
|
||||||
|
var
|
||||||
|
Flags: dword;
|
||||||
Begin
|
Begin
|
||||||
// flat button border: ignore
|
// flat button border cannot be drawn by DrawFrameControl, draw ourselves
|
||||||
if (UType <> DFC_BUTTON) or ((UState and DFCS_FLAT) = 0) then
|
if (UType = DFC_BUTTON) or ((UState and DFCS_FLAT) <> 0) then
|
||||||
|
begin
|
||||||
|
if (UState and DFCS_PUSHED) <> 0 then
|
||||||
|
Flags := BDR_SUNKENOUTER
|
||||||
|
else
|
||||||
|
Flags := BDR_RAISEDOUTER;
|
||||||
|
Result := Boolean(Windows.DrawEdge(DC, @Rect, Flags, BF_RECT));
|
||||||
|
end else begin
|
||||||
Result := Boolean(Windows.DrawFrameControl(DC, @Rect, UType, UState));
|
Result := Boolean(Windows.DrawFrameControl(DC, @Rect, UType, UState));
|
||||||
|
end;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -1238,7 +1248,7 @@ End;
|
|||||||
Function TWin32WidgetSet.Frame3D(DC: HDC; var Rect: TRect;
|
Function TWin32WidgetSet.Frame3D(DC: HDC; var Rect: TRect;
|
||||||
Const FrameWidth: Integer; Const Style: TBevelCut): Boolean;
|
Const FrameWidth: Integer; Const Style: TBevelCut): Boolean;
|
||||||
Const
|
Const
|
||||||
Edge: Array[TBevelCut] Of Integer = (0, EDGE_ETCHED, EDGE_RAISED);
|
Edge: Array[TBevelCut] Of Integer = (0, BDR_SUNKENOUTER, BDR_RAISEDOUTER);
|
||||||
Begin
|
Begin
|
||||||
Result := Boolean(DrawEdge(DC, Rect, Edge[Style], BF_RECT));
|
Result := Boolean(DrawEdge(DC, Rect, Edge[Style], BF_RECT));
|
||||||
End;
|
End;
|
||||||
@ -2987,6 +2997,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.121 2004/06/20 12:29:26 micha
|
||||||
|
make flat speedbuttons nicer
|
||||||
|
|
||||||
Revision 1.120 2004/06/18 20:47:34 vincents
|
Revision 1.120 2004/06/18 20:47:34 vincents
|
||||||
fixed pasting from clipboard
|
fixed pasting from clipboard
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user