mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 21:18:01 +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;
|
||||
begin
|
||||
ARect := GetClientRect;
|
||||
if BorderStyle = bsSingle then begin
|
||||
Canvas.Rectangle(ARect);
|
||||
if BevelOuter <> bvNone then
|
||||
begin
|
||||
Canvas.Frame3d(ARect, BevelWidth, BevelOuter);
|
||||
InflateRect(ARect, -1, -1);
|
||||
end;
|
||||
|
||||
if BevelOuter <> bvNone then
|
||||
Canvas.Frame3d(ARect, BevelWidth, BevelOuter);
|
||||
|
||||
if BevelInner <> bvNone then begin
|
||||
if BevelInner <> bvNone then
|
||||
begin
|
||||
if BorderWidth > 0 then InflateRect(ARect, -BorderWidth, -BorderWidth);
|
||||
Canvas.Frame3d(ARect, BevelWidth, BevelInner);
|
||||
InflateRect(ARect, -1, -1);
|
||||
end;
|
||||
|
||||
if Caption <> '' then begin
|
||||
|
@ -246,14 +246,19 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
function TSpeedButton.GetDrawFlags: integer;
|
||||
begin
|
||||
Result:=DFCS_BUTTONPUSH;
|
||||
if FState in [bsDown, bsExclusive] then inc(Result,DFCS_PUSHED);
|
||||
if not Enabled then inc(Result,DFCS_INACTIVE);
|
||||
|
||||
if Flat and (not (csDesigning in ComponentState)) and
|
||||
not FMouseInControl and not (FState in [bsDown, bsExclusive])
|
||||
then
|
||||
inc(Result,DFCS_FLAT);
|
||||
// if flat and not mouse in control and not down, don't draw anything
|
||||
if FFlat and not FMouseInControl and not (FState in [bsDown, bsExclusive]) then
|
||||
begin
|
||||
Result := 0;
|
||||
end else begin
|
||||
Result:=DFCS_BUTTONPUSH;
|
||||
if FState in [bsDown, bsExclusive] then
|
||||
inc(Result,DFCS_PUSHED);
|
||||
if not Enabled then
|
||||
inc(Result,DFCS_INACTIVE);
|
||||
if FFlat then
|
||||
inc(Result,DFCS_FLAT);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSpeedButton.ActionChange(Sender: TObject; CheckDefaults: Boolean);
|
||||
@ -372,8 +377,10 @@ begin
|
||||
|
||||
FLastDrawFlags:=GetDrawFlags;
|
||||
//DebugLn('TSpeedbutton.Paint ',Name,':',ClassName,' Parent.Name=',Parent.Name);
|
||||
DrawFrameControl(Canvas.GetUpdatedHandle([csBrushValid,csPenValid]),
|
||||
PaintRect, DFC_BUTTON, FLastDrawFlags);
|
||||
// do not draw anything if flat and mouse not in control (simplified)
|
||||
if FLastDrawFlags <> 0 then
|
||||
DrawFrameControl(Canvas.GetUpdatedHandle([csBrushValid,csPenValid]),
|
||||
PaintRect, DFC_BUTTON, FLastDrawFlags);
|
||||
|
||||
GlyphWidth:= TButtonGlyph(FGlyph).Glyph.Width;
|
||||
if TButtonGlyph(FGlyph).NumGlyphs > 1 then
|
||||
@ -772,6 +779,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$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
|
||||
fix speedbutton group in design mode
|
||||
|
||||
|
@ -1008,10 +1008,20 @@ End;
|
||||
Draws a frame control of the specified type and style.
|
||||
------------------------------------------------------------------------------}
|
||||
Function TWin32WidgetSet.DrawFrameControl(DC: HDC; Var Rect: TRect; UType, UState: Cardinal): Boolean;
|
||||
var
|
||||
Flags: dword;
|
||||
Begin
|
||||
// flat button border: ignore
|
||||
if (UType <> DFC_BUTTON) or ((UState and DFCS_FLAT) = 0) then
|
||||
// flat button border cannot be drawn by DrawFrameControl, draw ourselves
|
||||
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));
|
||||
end;
|
||||
End;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -1238,7 +1248,7 @@ End;
|
||||
Function TWin32WidgetSet.Frame3D(DC: HDC; var Rect: TRect;
|
||||
Const FrameWidth: Integer; Const Style: TBevelCut): Boolean;
|
||||
Const
|
||||
Edge: Array[TBevelCut] Of Integer = (0, EDGE_ETCHED, EDGE_RAISED);
|
||||
Edge: Array[TBevelCut] Of Integer = (0, BDR_SUNKENOUTER, BDR_RAISEDOUTER);
|
||||
Begin
|
||||
Result := Boolean(DrawEdge(DC, Rect, Edge[Style], BF_RECT));
|
||||
End;
|
||||
@ -2987,6 +2997,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$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
|
||||
fixed pasting from clipboard
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user