diff --git a/components/spktoolbar/SpkGUITools/SpkGUITools.pas b/components/spktoolbar/SpkGUITools/SpkGUITools.pas index 57b250cd2..1ae9dd0a2 100644 --- a/components/spktoolbar/SpkGUITools/SpkGUITools.pas +++ b/components/spktoolbar/SpkGUITools/SpkGUITools.pas @@ -2218,37 +2218,36 @@ class procedure TGUITools.DrawRoundRect(ACanvas: TCanvas; Rect: T2DIntRect; Radius: integer; ColorFrom, ColorTo: TColor; GradientKind: TBackgroundKind; ClipRect: T2DIntRect; LeftTopRound, RightTopRound, LeftBottomRound, RightBottomRound: boolean); - -var UseOrgClipRgn : boolean; - ClipRgn : HRGN; - OrgRgn : HRGN; - +var + UseOrgClipRgn: boolean; + ClipRgn: HRGN; + OrgRgn: HRGN; begin -// Zapamiêtywanie oryginalnego ClipRgn i ustawianie nowego -SaveClipRgn(ACanvas.Handle, UseOrgClipRgn, OrgRgn); + // Zapamiêtywanie oryginalnego ClipRgn i ustawianie nowego + SaveClipRgn(ACanvas.Handle, UseOrgClipRgn, OrgRgn); -ClipRgn:=CreateRectRgn(ClipRect.left, ClipRect.Top, ClipRect.Right+1, ClipRect.Bottom+1); -if UseOrgClipRgn then - CombineRgn(ClipRgn, ClipRgn, OrgRgn, RGN_AND); + ClipRgn := CreateRectRgn(ClipRect.left, ClipRect.Top, ClipRect.Right+1, ClipRect.Bottom+1); + if UseOrgClipRgn then + CombineRgn(ClipRgn, ClipRgn, OrgRgn, RGN_AND); -SelectClipRgn(ACanvas.Handle, ClipRgn); + SelectClipRgn(ACanvas.Handle, ClipRgn); -DrawRoundRect(ACanvas, Rect, Radius, ColorFrom, ColorTo, GradientKind, LeftTopRound, RightTopRound, LeftBottomRound, RightBottomRound); + DrawRoundRect(ACanvas, Rect, Radius, ColorFrom, ColorTo, GradientKind, LeftTopRound, RightTopRound, LeftBottomRound, RightBottomRound); -// Przywracanie poprzedniego ClipRgn i usuwanie wykorzystanych regionów -RestoreClipRgn(ACanvas.Handle, UseOrgClipRgn, OrgRgn); -DeleteObject(ClipRgn); + // Przywracanie poprzedniego ClipRgn i usuwanie wykorzystanych regionów + RestoreClipRgn(ACanvas.Handle, UseOrgClipRgn, OrgRgn); + DeleteObject(ClipRgn); end; class procedure TGUITools.DrawText(ACanvas: TCanvas; x, y: integer; - const AText: string; TextColor: TColor); + const AText: string; TextColor: TColor); begin -with Acanvas do - begin - brush.style:=bsClear; - font.color:=TextColor; - TextOut(x, y, AText); - end; + with ACanvas do + begin + Brush.Style := bsClear; + Font.Color := TextColor; + TextOut(x, y, AText); + end; end; class procedure TGUITools.DrawText(ACanvas: TCanvas; x, y: integer; @@ -2269,81 +2268,89 @@ end; class procedure TGUITools.DrawRoundRect(ACanvas: TCanvas; Rect: T2DIntRect; Radius: integer; ColorFrom, ColorTo: TColor; GradientKind: TBackgroundKind; LeftTopRound, RightTopRound, LeftBottomRound, RightBottomRound: boolean); - -var RoundRgn : HRGN; - TmpRgn : HRGN; - OrgRgn : HRGN; - UseOrgClipRgn: Boolean; - +var + RoundRgn: HRGN; + TmpRgn: HRGN; + OrgRgn: HRGN; + UseOrgClipRgn: Boolean; begin -if Radius<1 then - exit; + if Radius < 0 then + exit; -//WriteLn('Radius: ', Radius, ' Rect.Width: ', Rect.Width, ' Rect.Height: ', Rect.Height); + if Radius > 0 then + begin + //WriteLn('Radius: ', Radius, ' Rect.Width: ', Rect.Width, ' Rect.Height: ', Rect.Height); -//there's a bug in fpc that evaluates the expression below erroneous when using inline -// Radius = 3 and Rect.Width >=128 and <= 261 will evaluate to true -{$ifdef FpcBugWorkAround} -if (CompareValue(Radius*2, Rect.width) > 0) and (CompareValue(Radius*2, Rect.Height) > 0) then - exit; -{$else} -if (Radius*2>Rect.width) or (Radius*2>Rect.height) then - exit; -{$endif} + // There's a bug in fpc that evaluates the expression below erroneous when using inline + // Radius = 3 and Rect.Width >= 128 and <= 261 will evaluate to true + {$ifdef FpcBugWorkAround} + if (CompareValue(Radius*2, Rect.width) > 0) and (CompareValue(Radius*2, Rect.Height) > 0) then + exit; + {$else} + if (Radius*2 > Rect.Width) or (Radius*2 > Rect.Height) then + exit; + {$endif} -// Zapamiêtywanie oryginalnego ClipRgn i ustawianie nowego -SaveClipRgn(ACanvas.Handle, UseOrgClipRgn, OrgRgn); + // Zapamiêtywanie oryginalnego ClipRgn i ustawianie nowego + SaveClipRgn(ACanvas.Handle, UseOrgClipRgn, OrgRgn); -if not(LeftTopRound) and not(RightTopRound) and not(LeftBottomRound) and not (RightBottomRound) then - begin - RoundRgn:=CreateRectRgn(Rect.Left, Rect.Top, Rect.Right + 1, Rect.Bottom + 1); - end -else - begin - RoundRgn:=CreateRoundRectRgn(Rect.Left, Rect.Top, Rect.Right +2, Rect.Bottom + 2, Radius*2, Radius*2); + if not(LeftTopRound) and + not(RightTopRound) and + not(LeftBottomRound) and + not (RightBottomRound) then + begin + RoundRgn := CreateRectRgn(Rect.Left, Rect.Top, Rect.Right + 1, Rect.Bottom + 1); + end + else + begin + RoundRgn := CreateRoundRectRgn(Rect.Left, Rect.Top, Rect.Right +2, Rect.Bottom + 2, Radius*2, Radius*2); - if not(LeftTopRound) then + if not(LeftTopRound) then begin - TmpRgn:=CreateRectRgn(Rect.left, Rect.Top, Rect.left + Radius, Rect.Top + Radius); - CombineRgn(RoundRgn, RoundRgn, TmpRgn, RGN_OR); - DeleteObject(TmpRgn); + TmpRgn := CreateRectRgn(Rect.Left, Rect.Top, Rect.Left + Radius, Rect.Top + Radius); + CombineRgn(RoundRgn, RoundRgn, TmpRgn, RGN_OR); + DeleteObject(TmpRgn); end; - if not(RightTopRound) then + if not(RightTopRound) then begin - TmpRgn:=CreateRectRgn(Rect.right - Radius + 1, Rect.Top, Rect.Right + 1, Rect.Top + Radius); - CombineRgn(RoundRgn, RoundRgn, TmpRgn, RGN_OR); - DeleteObject(TmpRgn); + TmpRgn := CreateRectRgn(Rect.Right - Radius + 1, Rect.Top, Rect.Right + 1, Rect.Top + Radius); + CombineRgn(RoundRgn, RoundRgn, TmpRgn, RGN_OR); + DeleteObject(TmpRgn); end; - if not(LeftBottomRound) then + if not(LeftBottomRound) then begin - TmpRgn:=CreateRectRgn(Rect.left, Rect.Bottom - Radius + 1, Rect.Left + Radius, Rect.Bottom + 1); - CombineRgn(RoundRgn, RoundRgn, TmpRgn, RGN_OR); - DeleteObject(TmpRgn); + TmpRgn := CreateRectRgn(Rect.Left, Rect.Bottom - Radius + 1, Rect.Left + Radius, Rect.Bottom + 1); + CombineRgn(RoundRgn, RoundRgn, TmpRgn, RGN_OR); + DeleteObject(TmpRgn); end; - if not(RightBottomRound) then + if not(RightBottomRound) then begin - TmpRgn:=CreateRectRgn(Rect.right - Radius + 1, Rect.Bottom - Radius + 1, Rect.Right + 1, Rect.Bottom + 1); - CombineRgn(RoundRgn, RoundRgn, TmpRgn, RGN_OR); - DeleteObject(TmpRgn); + TmpRgn := CreateRectRgn(Rect.Right - Radius + 1, Rect.Bottom - Radius + 1, Rect.Right + 1, Rect.Bottom + 1); + CombineRgn(RoundRgn, RoundRgn, TmpRgn, RGN_OR); + DeleteObject(TmpRgn); end; - end; + end; -if UseOrgClipRgn then - CombineRgn(RoundRgn, RoundRgn, OrgRgn, RGN_AND); + if UseOrgClipRgn then + CombineRgn(RoundRgn, RoundRgn, OrgRgn, RGN_AND); -SelectClipRgn(ACanvas.Handle, RoundRgn); + SelectClipRgn(ACanvas.Handle, RoundRgn); + end; // if Radius > 0 -ColorFrom:=ColorToRGB(ColorFrom); -ColorTo:=ColorToRGB(ColorTo); + ColorFrom := ColorToRGB(ColorFrom); + ColorTo := ColorToRGB(ColorTo); -FillGradientRectangle(ACanvas, Rect, ColorFrom, ColorTo, GradientKind); + FillGradientRectangle(ACanvas, Rect, ColorFrom, ColorTo, GradientKind); -// Przywracanie poprzedniego ClipRgn i usuwanie wykorzystanych regionów -RestoreClipRgn(ACanvas.Handle, UseOrgClipRgn, OrgRgn); -DeleteObject(RoundRgn); + if Radius > 0 then + begin + // Przywracanie poprzedniego ClipRgn i usuwanie wykorzystanych regionów + RestoreClipRgn(ACanvas.Handle, UseOrgClipRgn, OrgRgn); + DeleteObject(RoundRgn); + end; end; class procedure TGUITools.DrawOutlinedText(ABitmap: TBitmap; x, y: integer; diff --git a/components/spktoolbar/SpkToolbar/spkt_Appearance.pas b/components/spktoolbar/SpkToolbar/spkt_Appearance.pas index c95a802c1..ba1cb91cd 100644 --- a/components/spktoolbar/SpkToolbar/spkt_Appearance.pas +++ b/components/spktoolbar/SpkToolbar/spkt_Appearance.pas @@ -22,6 +22,8 @@ type TSpkPaneStyle = (psRectangleFlat, psRectangleEtched, psRectangleRaised, psDividerFlat, psDividerEtched, psDividerRaised); + TSpkElementStyle = (esRounded, esRectangle); + type TSpkTabAppearance = class(TPersistent) private FDispatch: TSpkBaseAppearanceDispatch; @@ -104,7 +106,6 @@ type TSpkPaneAppearance = class(TPersistent) type TSpkElementAppearance = class(TPersistent) private FDispatch: TSpkBaseAppearanceDispatch; - protected FCaptionFont: TFont; FIdleFrameColor: TColor; FIdleGradientFromColor: TColor; @@ -127,7 +128,7 @@ type TSpkElementAppearance = class(TPersistent) FActiveInnerLightColor: TColor; FActiveInnerDarkColor: TColor; FActiveCaptionColor: TColor; - + FStyle: TSpkElementStyle; procedure SetActiveCaptionColor(const Value: TColor); procedure SetActiveFrameColor(const Value: TColor); procedure SetActiveGradientFromColor(const Value: TColor); @@ -150,6 +151,7 @@ type TSpkElementAppearance = class(TPersistent) procedure SetIdleGradientType(const Value: TBackgroundKind); procedure SetIdleInnerDarkColor(const Value: TColor); procedure SetIdleInnerLightColor(const Value: TColor); + procedure SetStyle(const Value: TSpkElementStyle); public constructor Create(ADispatch: TSpkBaseAppearanceDispatch); destructor Destroy; override; @@ -181,6 +183,7 @@ type TSpkElementAppearance = class(TPersistent) property ActiveInnerLightColor: TColor read FActiveInnerLightColor write SetActiveInnerLightColor; property ActiveInnerDarkColor: TColor read FActiveInnerDarkColor write SetActiveInnerDarkColor; property ActiveCaptionColor: TColor read FActiveCaptionColor write SetActiveCaptionColor; + property Style: TSpkElementStyle read FStyle write SetStyle; end; type TSpkToolbarAppearance = class; @@ -220,6 +223,7 @@ type TSpkToolbarAppearance = class; property Element: TSpkElementAppearance read FElement write SetElementAppearance; end; + procedure SetDefaultFont(AFont: TFont); implementation @@ -317,36 +321,8 @@ end; procedure TSpkTabAppearance.Reset; begin - if screen.fonts.IndexOf('Calibri') >= 0 then - begin - FTabHeaderFont.Charset := DEFAULT_CHARSET; - FTabHeaderFont.Color := rgb(21, 66, 139); - FTabHeaderFont.Name := 'Calibri'; - FTabHeaderFont.Orientation := 0; - FTabHeaderFont.Pitch := fpDefault; - FTabHeaderFont.Size := 10; - FTabHeaderFont.Style := []; - end - else if screen.fonts.IndexOf('Verdana') >= 0 then - begin - FTabHeaderFont.Charset := DEFAULT_CHARSET; - FTabHeaderFont.Color := rgb(21, 66, 139); - FTabHeaderFont.Name := 'Verdana'; - FTabHeaderFont.Orientation := 0; - FTabHeaderFont.Pitch := fpDefault; - FTabHeaderFont.Size := 10; - FTabHeaderFont.Style := []; - end - else - begin - FTabHeaderFont.Charset := DEFAULT_CHARSET; - FTabHeaderFont.Color := rgb(21, 66, 139); - FTabHeaderFont.Name := 'Arial'; - FTabHeaderFont.Orientation := 0; - FTabHeaderFont.Pitch := fpDefault; - FTabHeaderFont.Size := 10; - FTabHeaderFont.Style := []; - end; + SetDefaultFont(FTabHeaderFont); + FTabHeaderFont.Size := FTabHeaderFont.Size + 1; FBorderColor := rgb(141, 178, 227); FGradientFromColor := rgb(222, 232, 245); FGradientToColor := rgb(199, 216, 237); @@ -520,36 +496,7 @@ end; procedure TSpkPaneAppearance.Reset; begin - if screen.fonts.IndexOf('Calibri') >= 0 then - begin - FCaptionFont.Name := 'Calibri'; - FCaptionFont.Size := 9; - FCaptionFont.color := rgb(62, 106, 170); - FCaptionFont.Style := []; - FCaptionFont.Charset := DEFAULT_CHARSET; - FCaptionFont.Orientation := 0; - FCaptionFont.Pitch := fpDefault; - end - else if screen.fonts.IndexOf('Verdana') >= 0 then - begin - FCaptionFont.Name := 'Verdana'; - FCaptionFont.Size := 9; - FCaptionFont.color := rgb(62, 106, 170); - FCaptionFont.Style := []; - FCaptionFont.Charset := DEFAULT_CHARSET; - FCaptionFont.Orientation := 0; - FCaptionFont.Pitch := fpDefault; - end - else - begin - FCaptionFont.Name := 'Arial'; - FCaptionFont.Size := 9; - FCaptionFont.color := rgb(62, 106, 170); - FCaptionFont.Style := []; - FCaptionFont.Charset := DEFAULT_CHARSET; - FCaptionFont.Orientation := 0; - FCaptionFont.Pitch := fpDefault; - end; + SetDefaultFont(FCaptionFont); FBorderDarkColor := rgb(158, 190, 218); FBorderLightColor := rgb(237, 242, 248); FCaptionBgColor := rgb(194, 217, 241); @@ -667,51 +614,48 @@ end; { TSpkElementAppearance } procedure TSpkElementAppearance.Assign(Source: TPersistent); - -var SrcAppearance : TSpkElementAppearance; - +var + SrcAppearance: TSpkElementAppearance; begin if Source is TSpkElementAppearance then - begin - SrcAppearance:=TSpkElementAppearance(Source); + begin + SrcAppearance := TSpkElementAppearance(Source); - FCaptionFont.assign(SrcAppearance.CaptionFont); - FIdleFrameColor := SrcAppearance.IdleFrameColor; - FIdleGradientFromColor := SrcAppearance.IdleGradientFromColor; - FIdleGradientToColor := SrcAppearance.IdleGradientToColor; - FIdleGradientType := SrcAppearance.IdleGradientType; - FIdleInnerLightColor := SrcAppearance.IdleInnerLightColor; - FIdleInnerDarkColor := SrcAppearance.IdleInnerDarkColor; - FIdleCaptionColor := SrcAppearance.IdleCaptionColor; - FHotTrackFrameColor := SrcAppearance.HotTrackFrameColor; - FHotTrackGradientFromColor := SrcAppearance.HotTrackGradientFromColor; - FHotTrackGradientToColor := SrcAppearance.HotTrackGradientToColor; - FHotTrackGradientType := SrcAppearance.HotTrackGradientType; - FHotTrackInnerLightColor := SrcAppearance.HotTrackInnerLightColor; - FHotTrackInnerDarkColor := SrcAppearance.HotTrackInnerDarkColor; - FHotTrackCaptionColor := SrcAppearance.HotTrackCaptionColor; - FActiveFrameColor := SrcAppearance.ActiveFrameColor; - FActiveGradientFromColor := SrcAppearance.ActiveGradientFromColor; - FActiveGradientToColor := SrcAppearance.ActiveGradientToColor; - FActiveGradientType := SrcAppearance.ActiveGradientType; - FActiveInnerLightColor := SrcAppearance.ActiveInnerLightColor; - FActiveInnerDarkColor := SrcAppearance.ActiveInnerDarkColor; - FActiveCaptionColor := SrcAppearance.ActiveCaptionColor; + FCaptionFont.Assign(SrcAppearance.CaptionFont); + FIdleFrameColor := SrcAppearance.IdleFrameColor; + FIdleGradientFromColor := SrcAppearance.IdleGradientFromColor; + FIdleGradientToColor := SrcAppearance.IdleGradientToColor; + FIdleGradientType := SrcAppearance.IdleGradientType; + FIdleInnerLightColor := SrcAppearance.IdleInnerLightColor; + FIdleInnerDarkColor := SrcAppearance.IdleInnerDarkColor; + FIdleCaptionColor := SrcAppearance.IdleCaptionColor; + FHotTrackFrameColor := SrcAppearance.HotTrackFrameColor; + FHotTrackGradientFromColor := SrcAppearance.HotTrackGradientFromColor; + FHotTrackGradientToColor := SrcAppearance.HotTrackGradientToColor; + FHotTrackGradientType := SrcAppearance.HotTrackGradientType; + FHotTrackInnerLightColor := SrcAppearance.HotTrackInnerLightColor; + FHotTrackInnerDarkColor := SrcAppearance.HotTrackInnerDarkColor; + FHotTrackCaptionColor := SrcAppearance.HotTrackCaptionColor; + FActiveFrameColor := SrcAppearance.ActiveFrameColor; + FActiveGradientFromColor := SrcAppearance.ActiveGradientFromColor; + FActiveGradientToColor := SrcAppearance.ActiveGradientToColor; + FActiveGradientType := SrcAppearance.ActiveGradientType; + FActiveInnerLightColor := SrcAppearance.ActiveInnerLightColor; + FActiveInnerDarkColor := SrcAppearance.ActiveInnerDarkColor; + FActiveCaptionColor := SrcAppearance.ActiveCaptionColor; + FStyle := SrcAppearance.Style; - if FDispatch<>nil then - FDispatch.NotifyAppearanceChanged; - end else - raise AssignException.create('TSpkElementAppearance.Assign: Nie mogê przypisaæ obiektu '+Source.ClassName+' do TSpkElementAppearance!'); + if FDispatch <> nil then + FDispatch.NotifyAppearanceChanged; + end else + raise AssignException.create('TSpkElementAppearance.Assign: Nie mogê przypisaæ obiektu '+Source.ClassName+' do TSpkElementAppearance!'); end; constructor TSpkElementAppearance.Create(ADispatch: TSpkBaseAppearanceDispatch); begin inherited Create; - - FDispatch:=ADispatch; - - FCaptionFont:=TFont.Create; - + FDispatch := ADispatch; + FCaptionFont := TFont.Create; Reset; end; @@ -722,141 +666,113 @@ begin end; procedure TSpkElementAppearance.LoadFromXML(Node: TSpkXMLNode); - -var Subnode : TSpkXMLNode; - +var + Subnode: TSpkXMLNode; begin -if not(assigned(Node)) then - exit; + if not Assigned(Node) then + exit; -Subnode:=Node['CaptionFont',false]; -if assigned(Subnode) then - TSpkXMLTools.Load(Subnode, FCaptionFont); + Subnode := Node['CaptionFont', false]; + if Assigned(Subnode) then + TSpkXMLTools.Load(Subnode, FCaptionFont); -// *** Idle *** + // Idle + Subnode := Node['IdleFrameColor', false]; + if Assigned(Subnode) then + FIdleFrameColor := Subnode.TextAsColor; -Subnode:=Node['IdleFrameColor',false]; -if assigned(Subnode) then - FIdleFrameColor:=Subnode.TextAsColor; + Subnode := Node['IdleGradientFromColor', false]; + if Assigned(Subnode) then + FIdleGradientFromColor := Subnode.TextAsColor; -Subnode:=Node['IdleGradientFromColor',false]; -if assigned(Subnode) then - FIdleGradientFromColor:=Subnode.TextAsColor; + Subnode := Node['IdleGradientToColor', false]; + if Assigned(Subnode) then + FIdleGradientToColor := Subnode.TextAsColor; -Subnode:=Node['IdleGradientToColor',false]; -if assigned(Subnode) then - FIdleGradientToColor:=Subnode.TextAsColor; + Subnode := Node['IdleGradientType', false]; + if Assigned(Subnode) then + FIdleGradientType := TBackgroundKind(Subnode.TextAsInteger); -Subnode:=Node['IdleGradientType',false]; -if assigned(Subnode) then - FIdleGradientType:=TBackgroundKind(Subnode.TextAsInteger); + Subnode := Node['IdleInnerLightColor', false]; + if Assigned(Subnode) then + FIdleInnerLightColor := Subnode.TextAsColor; -Subnode:=Node['IdleInnerLightColor',false]; -if assigned(Subnode) then - FIdleInnerLightColor:=Subnode.TextAsColor; + Subnode := Node['IdleInnerDarkColor', false]; + if Assigned(Subnode) then + FIdleInnerDarkColor := Subnode.TextAsColor; -Subnode:=Node['IdleInnerDarkColor',false]; -if assigned(Subnode) then - FIdleInnerDarkColor:=Subnode.TextAsColor; + Subnode := Node['IdleCaptionColor', false]; + if Assigned(Subnode) then + FIdleCaptionColor := Subnode.TextAsColor; -Subnode:=Node['IdleCaptionColor',false]; -if assigned(Subnode) then - FIdleCaptionColor:=Subnode.TextAsColor; + // Hottrack + Subnode := Node['HottrackFrameColor', false]; + if Assigned(Subnode) then + FHottrackFrameColor := Subnode.TextAsColor; -// *** Hottrack *** + Subnode := Node['HottrackGradientFromColor', false]; + if Assigned(Subnode) then + FHottrackGradientFromColor := Subnode.TextAsColor; -Subnode:=Node['HottrackFrameColor',false]; -if assigned(Subnode) then - FHottrackFrameColor:=Subnode.TextAsColor; + Subnode := Node['HottrackGradientToColor', false]; + if Assigned(Subnode) then + FHottrackGradientToColor := Subnode.TextAsColor; -Subnode:=Node['HottrackGradientFromColor',false]; -if assigned(Subnode) then - FHottrackGradientFromColor:=Subnode.TextAsColor; + Subnode := Node['HottrackGradientType', false]; + if Assigned(Subnode) then + FHottrackGradientType := TBackgroundKind(Subnode.TextAsInteger); -Subnode:=Node['HottrackGradientToColor',false]; -if assigned(Subnode) then - FHottrackGradientToColor:=Subnode.TextAsColor; + Subnode := Node['HottrackInnerLightColor', false]; + if Assigned(Subnode) then + FHottrackInnerLightColor := Subnode.TextAsColor; -Subnode:=Node['HottrackGradientType',false]; -if assigned(Subnode) then - FHottrackGradientType:=TBackgroundKind(Subnode.TextAsInteger); + Subnode := Node['HottrackInnerDarkColor', false]; + if Assigned(Subnode) then + FHottrackInnerDarkColor := Subnode.TextAsColor; -Subnode:=Node['HottrackInnerLightColor',false]; -if assigned(Subnode) then - FHottrackInnerLightColor:=Subnode.TextAsColor; + Subnode := Node['HottrackCaptionColor', false]; + if Assigned(Subnode) then + FHottrackCaptionColor := Subnode.TextAsColor; -Subnode:=Node['HottrackInnerDarkColor',false]; -if assigned(Subnode) then - FHottrackInnerDarkColor:=Subnode.TextAsColor; + // Active + Subnode := Node['ActiveFrameColor', false]; + if Assigned(Subnode) then + FActiveFrameColor := Subnode.TextAsColor; -Subnode:=Node['HottrackCaptionColor',false]; -if assigned(Subnode) then - FHottrackCaptionColor:=Subnode.TextAsColor; + Subnode := Node['ActiveGradientFromColor', false]; + if Assigned(Subnode) then + FActiveGradientFromColor := Subnode.TextAsColor; -// *** Active *** + Subnode := Node['ActiveGradientToColor', false]; + if Assigned(Subnode) then + FActiveGradientToColor := Subnode.TextAsColor; -Subnode:=Node['ActiveFrameColor',false]; -if assigned(Subnode) then - FActiveFrameColor:=Subnode.TextAsColor; + Subnode := Node['ActiveGradientType', false]; + if Assigned(Subnode) then + FActiveGradientType := TBackgroundKind(Subnode.TextAsInteger); -Subnode:=Node['ActiveGradientFromColor',false]; -if assigned(Subnode) then - FActiveGradientFromColor:=Subnode.TextAsColor; + Subnode := Node['ActiveInnerLightColor', false]; + if Assigned(Subnode) then + FActiveInnerLightColor := Subnode.TextAsColor; -Subnode:=Node['ActiveGradientToColor',false]; -if assigned(Subnode) then - FActiveGradientToColor:=Subnode.TextAsColor; + Subnode := Node['ActiveInnerDarkColor', false]; + if Assigned(Subnode) then + FActiveInnerDarkColor := Subnode.TextAsColor; -Subnode:=Node['ActiveGradientType',false]; -if assigned(Subnode) then - FActiveGradientType:=TBackgroundKind(Subnode.TextAsInteger); + Subnode := Node['ActiveCaptionColor', false]; + if Assigned(Subnode) then + FActiveCaptionColor := Subnode.TextAsColor; -Subnode:=Node['ActiveInnerLightColor',false]; -if assigned(Subnode) then - FActiveInnerLightColor:=Subnode.TextAsColor; - -Subnode:=Node['ActiveInnerDarkColor',false]; -if assigned(Subnode) then - FActiveInnerDarkColor:=Subnode.TextAsColor; - -Subnode:=Node['ActiveCaptionColor',false]; -if assigned(Subnode) then - FActiveCaptionColor:=Subnode.TextAsColor; + // Other + Subnode := Node['Style', false]; + if Assigned(SubNode) then + FStyle := TSpkElementStyle(Subnode.TextAsInteger); end; procedure TSpkElementAppearance.Reset; begin - if screen.fonts.IndexOf('Calibri') >= 0 then - begin - FCaptionFont.Name := 'Calibri'; - FCaptionFont.Size := 9; - FCaptionFont.Style := []; - FCaptionFont.Charset := DEFAULT_CHARSET; - FCaptionFont.Orientation := 0; - FCaptionFont.Pitch := fpDefault; - FCaptionFont.Color := rgb(21, 66, 139); - end - else if screen.fonts.IndexOf('Verdana') >= 0 then - begin - FCaptionFont.Name := 'Verdana'; - FCaptionFont.Size := 8; - FCaptionFont.Style := []; - FCaptionFont.Charset := DEFAULT_CHARSET; - FCaptionFont.Orientation := 0; - FCaptionFont.Pitch := fpDefault; - FCaptionFont.Color := rgb(21, 66, 139); - end - else - begin - FCaptionFont.Name := 'Arial'; - FCaptionFont.Size := 8; - FCaptionFont.Style := []; - FCaptionFont.Charset := DEFAULT_CHARSET; - FCaptionFont.Orientation := 0; - FCaptionFont.Pitch := fpDefault; - FCaptionFont.Color := rgb(21, 66, 139); - end; - + SetDefaultFont(FCaptionFont); + FCaptionFont.Size := FCaptionFont.Size - 1; FIdleFrameColor := rgb(155, 183, 224); FIdleGradientFromColor := rgb(200, 219, 238); FIdleGradientToColor := rgb(188, 208, 233); @@ -878,6 +794,7 @@ begin FActiveInnerLightColor := rgb(252, 169, 14); FActiveInnerDarkColor := rgb(252, 169, 14); FActiveCaptionColor := rgb(110, 66, 128); + FStyle := esRounded; end; procedure TSpkElementAppearance.SaveToPascal(AList: TStrings); @@ -909,6 +826,8 @@ begin Add(' ActiveInnerDarkColor := $' + IntToHex(FActiveInnerDarkColor, 8) + ';'); Add(' ActiveInnerLightColor := $' + IntToHex(FActiveInnerLightColor, 8) + ';'); Add(' ActiveCaptionColor := $' + IntToHex(FActiveCaptionColor, 8) + ';'); + + Add(' Style := ' + GetEnumName(TypeInfo(TSpkElementStyle), ord(FStyle)) + ';'); Add(' end;'); end; end; @@ -920,78 +839,80 @@ begin if not Assigned(Node) then exit; - Subnode := Node['CaptionFont',true]; + Subnode := Node['CaptionFont', true]; TSpkXMLTools.Save(Subnode, FCaptionFont); // *** Idle *** - Subnode := Node['IdleFrameColor',true]; - Subnode.TextAsColor:=FIdleFrameColor; + Subnode := Node['IdleFrameColor', true]; + Subnode.TextAsColor := FIdleFrameColor; - Subnode := Node['IdleGradientFromColor',true]; - Subnode.TextAsColor:=FIdleGradientFromColor; + Subnode := Node['IdleGradientFromColor', true]; + Subnode.TextAsColor := FIdleGradientFromColor; - Subnode := Node['IdleGradientToColor',true]; - Subnode.TextAsColor:=FIdleGradientToColor; + Subnode := Node['IdleGradientToColor', true]; + Subnode.TextAsColor := FIdleGradientToColor; - Subnode := Node['IdleGradientType',true]; - Subnode.TextAsInteger:=integer(FIdleGradientType); + Subnode := Node['IdleGradientType', true]; + Subnode.TextAsInteger := integer(FIdleGradientType); - Subnode := Node['IdleInnerLightColor',true]; - Subnode.TextAsColor:=FIdleInnerLightColor; + Subnode := Node['IdleInnerLightColor', true]; + Subnode.TextAsColor := FIdleInnerLightColor; - Subnode := Node['IdleInnerDarkColor',true]; - Subnode.TextAsColor:=FIdleInnerDarkColor; + Subnode := Node['IdleInnerDarkColor', true]; + Subnode.TextAsColor := FIdleInnerDarkColor; - Subnode := Node['IdleCaptionColor',true]; - Subnode.TextAsColor:=FIdleCaptionColor; + Subnode := Node['IdleCaptionColor', true]; + Subnode.TextAsColor := FIdleCaptionColor; // *** Hottrack *** - Subnode := Node['HottrackFrameColor',true]; - Subnode.TextAsColor:=FHottrackFrameColor; + Subnode := Node['HottrackFrameColor', true]; + Subnode.TextAsColor := FHottrackFrameColor; - Subnode := Node['HottrackGradientFromColor',true]; - Subnode.TextAsColor:=FHottrackGradientFromColor; + Subnode := Node['HottrackGradientFromColor', true]; + Subnode.TextAsColor := FHottrackGradientFromColor; - Subnode := Node['HottrackGradientToColor',true]; - Subnode.TextAsColor:=FHottrackGradientToColor; + Subnode := Node['HottrackGradientToColor', true]; + Subnode.TextAsColor := FHottrackGradientToColor; - Subnode := Node['HottrackGradientType',true]; - Subnode.TextAsInteger:=integer(FHottrackGradientType); + Subnode := Node['HottrackGradientType', true]; + Subnode.TextAsInteger := integer(FHottrackGradientType); - Subnode := Node['HottrackInnerLightColor',true]; - Subnode.TextAsColor:=FHottrackInnerLightColor; + Subnode := Node['HottrackInnerLightColor', true]; + Subnode.TextAsColor := FHottrackInnerLightColor; - Subnode := Node['HottrackInnerDarkColor',true]; - Subnode.TextAsColor:=FHottrackInnerDarkColor; + Subnode := Node['HottrackInnerDarkColor', true]; + Subnode.TextAsColor := FHottrackInnerDarkColor; - Subnode := Node['HottrackCaptionColor',true]; - Subnode.TextAsColor:=FHottrackCaptionColor; + Subnode := Node['HottrackCaptionColor', true]; + Subnode.TextAsColor := FHottrackCaptionColor; // *** Active *** - Subnode := Node['ActiveFrameColor',true]; - Subnode.TextAsColor:=FActiveFrameColor; + Subnode := Node['ActiveFrameColor', true]; + Subnode.TextAsColor := FActiveFrameColor; - Subnode := Node['ActiveGradientFromColor',true]; - Subnode.TextAsColor:=FActiveGradientFromColor; + Subnode := Node['ActiveGradientFromColor', true]; + Subnode.TextAsColor := FActiveGradientFromColor; - Subnode := Node['ActiveGradientToColor',true]; - Subnode.TextAsColor:=FActiveGradientToColor; + Subnode := Node['ActiveGradientToColor', true]; + Subnode.TextAsColor := FActiveGradientToColor; - Subnode := Node['ActiveGradientType',true]; - Subnode.TextAsInteger:=integer(FActiveGradientType); + Subnode := Node['ActiveGradientType', true]; + Subnode.TextAsInteger := integer(FActiveGradientType); - Subnode := Node['ActiveInnerLightColor',true]; - Subnode.TextAsColor:=FActiveInnerLightColor; + Subnode := Node['ActiveInnerLightColor', true]; + Subnode.TextAsColor := FActiveInnerLightColor; - Subnode := Node['ActiveInnerDarkColor',true]; - Subnode.TextAsColor:=FActiveInnerDarkColor; + Subnode := Node['ActiveInnerDarkColor', true]; + Subnode.TextAsColor := FActiveInnerDarkColor; - Subnode := Node['ActiveCaptionColor',true]; - Subnode.TextAsColor:=FActiveCaptionColor; + Subnode := Node['ActiveCaptionColor', true]; + Subnode.TextAsColor := FActiveCaptionColor; + + Subnode := Node['Style', true]; + Subnode.TextAsInteger := integer(FStyle); end; -procedure TSpkElementAppearance.SetActiveCaptionColor( - const Value: TColor); +procedure TSpkElementAppearance.SetActiveCaptionColor(const Value: TColor); begin FActiveCaptionColor := Value; if FDispatch<>nil then @@ -1005,40 +926,35 @@ begin FDispatch.NotifyAppearanceChanged; end; -procedure TSpkElementAppearance.SetActiveGradientFromColor( - const Value: TColor); +procedure TSpkElementAppearance.SetActiveGradientFromColor(const Value: TColor); begin FActiveGradientFromColor := Value; if FDispatch<>nil then FDispatch.NotifyAppearanceChanged; end; -procedure TSpkElementAppearance.SetActiveGradientToColor( - const Value: TColor); +procedure TSpkElementAppearance.SetActiveGradientToColor(const Value: TColor); begin FActiveGradientToColor := Value; if FDispatch<>nil then FDispatch.NotifyAppearanceChanged; end; -procedure TSpkElementAppearance.SetActiveGradientType( - const Value: TBackgroundKind); +procedure TSpkElementAppearance.SetActiveGradientType(const Value: TBackgroundKind); begin FActiveGradientType := Value; if FDispatch<>nil then FDispatch.NotifyAppearanceChanged; end; -procedure TSpkElementAppearance.SetActiveInnerDarkColor( - const Value: TColor); +procedure TSpkElementAppearance.SetActiveInnerDarkColor(const Value: TColor); begin FActiveInnerDarkColor := Value; if FDispatch<>nil then FDispatch.NotifyAppearanceChanged; end; -procedure TSpkElementAppearance.SetActiveInnerLightColor( - const Value: TColor); +procedure TSpkElementAppearance.SetActiveInnerLightColor(const Value: TColor); begin FActiveInnerLightColor := Value; if FDispatch<>nil then @@ -1052,56 +968,49 @@ begin FDispatch.NotifyAppearanceChanged; end; -procedure TSpkElementAppearance.SetHotTrackCaptionColor( - const Value: TColor); +procedure TSpkElementAppearance.SetHotTrackCaptionColor(const Value: TColor); begin FHotTrackCaptionColor := Value; if FDispatch<>nil then FDispatch.NotifyAppearanceChanged; end; -procedure TSpkElementAppearance.SetHotTrackFrameColor( - const Value: TColor); +procedure TSpkElementAppearance.SetHotTrackFrameColor(const Value: TColor); begin FHotTrackFrameColor := Value; if FDispatch<>nil then FDispatch.NotifyAppearanceChanged; end; -procedure TSpkElementAppearance.SetHotTrackGradientFromColor( - const Value: TColor); +procedure TSpkElementAppearance.SetHotTrackGradientFromColor(const Value: TColor); begin FHotTrackGradientFromColor := Value; if FDispatch<>nil then FDispatch.NotifyAppearanceChanged; end; -procedure TSpkElementAppearance.SetHotTrackGradientToColor( - const Value: TColor); +procedure TSpkElementAppearance.SetHotTrackGradientToColor(const Value: TColor); begin FHotTrackGradientToColor := Value; if FDispatch<>nil then FDispatch.NotifyAppearanceChanged; end; -procedure TSpkElementAppearance.SetHotTrackGradientType( - const Value: TBackgroundKind); +procedure TSpkElementAppearance.SetHotTrackGradientType(const Value: TBackgroundKind); begin FHotTrackGradientType := Value; if FDispatch<>nil then FDispatch.NotifyAppearanceChanged; end; -procedure TSpkElementAppearance.SetHotTrackInnerDarkColor( - const Value: TColor); +procedure TSpkElementAppearance.SetHotTrackInnerDarkColor(const Value: TColor); begin FHotTrackInnerDarkColor := Value; if FDispatch<>nil then FDispatch.NotifyAppearanceChanged; end; -procedure TSpkElementAppearance.SetHotTrackInnerLightColor( - const Value: TColor); +procedure TSpkElementAppearance.SetHotTrackInnerLightColor(const Value: TColor); begin FHotTrackInnerLightColor := Value; if FDispatch<>nil then @@ -1122,46 +1031,48 @@ begin FDispatch.NotifyAppearanceChanged; end; -procedure TSpkElementAppearance.SetIdleGradientFromColor( - const Value: TColor); +procedure TSpkElementAppearance.SetIdleGradientFromColor(const Value: TColor); begin FIdleGradientFromColor := Value; if FDispatch<>nil then FDispatch.NotifyAppearanceChanged; end; -procedure TSpkElementAppearance.SetIdleGradientToColor( - const Value: TColor); +procedure TSpkElementAppearance.SetIdleGradientToColor(const Value: TColor); begin FIdleGradientToColor := Value; if FDispatch<>nil then FDispatch.NotifyAppearanceChanged; end; -procedure TSpkElementAppearance.SetIdleGradientType( - const Value: TBackgroundKind); +procedure TSpkElementAppearance.SetIdleGradientType(const Value: TBackgroundKind); begin FIdleGradientType := Value; if FDispatch<>nil then FDispatch.NotifyAppearanceChanged; end; -procedure TSpkElementAppearance.SetIdleInnerDarkColor( - const Value: TColor); +procedure TSpkElementAppearance.SetIdleInnerDarkColor(const Value: TColor); begin FIdleInnerDarkColor := Value; if FDispatch<>nil then FDispatch.NotifyAppearanceChanged; end; -procedure TSpkElementAppearance.SetIdleInnerLightColor( - const Value: TColor); +procedure TSpkElementAppearance.SetIdleInnerLightColor(const Value: TColor); begin FIdleInnerLightColor := Value; if FDispatch<>nil then FDispatch.NotifyAppearanceChanged; end; +procedure TSpkElementAppearance.SetStyle(const Value: TSpkElementStyle); +begin + FStyle := Value; + if FDispatch <> nil then + FDispatch.NotifyAppearanceChanged; +end; + { TSpkToolbarAppearanceDispatch } constructor TSpkToolbarAppearanceDispatch.Create( @@ -1296,4 +1207,30 @@ begin FTab.assign(Value); end; +procedure SetDefaultFont(AFont: TFont); +begin + AFont.Assign(Screen.MenuFont); + { + if Screen.Fonts.IndexOf('Calibri') >= 0 then + begin + AFont.Name := 'Calibri'; + AFont.Size := 9; + end + else if Screen.Fonts.IndexOf('Verdana') >= 0 then + begin + AFont.Name := 'Verdana'; + AFont.Size := 8; + end else + begin + AFont.Name := 'Arial'; + AFont.Size := 8; + end; + AFont.Style := []; + AFont.Charset := DEFAULT_CHARSET; + AFont.Orientation := 0; + AFont.Pitch := fpDefault; + } + AFont.Color := rgb(21, 66, 139); +end; + end. diff --git a/components/spktoolbar/SpkToolbar/spkt_Buttons.pas b/components/spktoolbar/SpkToolbar/spkt_Buttons.pas index a9c1de1ef..0a9752f4e 100644 --- a/components/spktoolbar/SpkToolbar/spkt_Buttons.pas +++ b/components/spktoolbar/SpkToolbar/spkt_Buttons.pas @@ -117,20 +117,19 @@ type TSpkBaseButton = class; type TSpkLargeButton = class(TSpkBaseButton) private - procedure FindBreakPlace(s : string; out Position : integer; out Width : integer); - protected FLargeImageIndex: TImageIndex; - + procedure FindBreakPlace(s: string; out Position: integer; out Width: integer); + procedure SetLargeImageIndex(const Value: TImageIndex); + protected procedure CalcRects; override; function GetDropdownPoint : T2DIntPoint; override; - procedure SetLargeImageIndex(const Value: TImageIndex); public - constructor Create(AOwner : TComponent); override; - function GetWidth : integer; override; - function GetTableBehaviour : TSpkItemTableBehaviour; override; - function GetGroupBehaviour : TSpkItemGroupBehaviour; override; - function GetSize : TSpkItemSize; override; - procedure Draw(ABuffer : TBitmap; ClipRect : T2DIntRect); override; + constructor Create(AOwner: TComponent); override; + procedure Draw(ABuffer: TBitmap; ClipRect: T2DIntRect); override; + function GetWidth: integer; override; + function GetTableBehaviour: TSpkItemTableBehaviour; override; + function GetGroupBehaviour: TSpkItemGroupBehaviour; override; + function GetSize: TSpkItemSize; override; published property LargeImageIndex: TImageIndex read FLargeImageIndex write SetLargeImageIndex default -1; property ButtonKind; @@ -139,36 +138,33 @@ type TSpkLargeButton = class(TSpkBaseButton) type TSpkSmallButton = class(TSpkBaseButton) private - protected - FImageIndex : TImageIndex; - - FTableBehaviour : TSpkItemTableBehaviour; - FGroupBehaviour : TSPkItemGroupBehaviour; - FHideFrameWhenIdle : boolean; - FShowCaption : boolean; - - procedure CalcRects; override; - function GetDropdownPoint : T2DIntPoint; override; - procedure ConstructRects(var BtnRect, DropRect : T2DIntRect); - procedure SetImageIndex(const Value : TImageIndex); + FImageIndex: TImageIndex; + FTableBehaviour: TSpkItemTableBehaviour; + FGroupBehaviour: TSPkItemGroupBehaviour; + FHideFrameWhenIdle: boolean; + FShowCaption: boolean; + procedure ConstructRects(out BtnRect, DropRect: T2DIntRect); + procedure SetImageIndex(const Value: TImageIndex); procedure SetGroupBehaviour(const Value: TSpkItemGroupBehaviour); procedure SetHideFrameWhenIdle(const Value: boolean); procedure SetTableBehaviour(const Value: TSpkItemTableBehaviour); procedure SetShowCaption(const Value: boolean); + protected + procedure CalcRects; override; + function GetDropdownPoint: T2DIntPoint; override; public - constructor Create(AOwner : TComponent); override; - - function GetWidth : integer; override; - function GetTableBehaviour : TSpkItemTableBehaviour; override; - function GetGroupBehaviour : TSpkItemGroupBehaviour; override; - function GetSize : TSpkItemSize; override; - procedure Draw(ABuffer : TBitmap; ClipRect : T2DIntRect); override; + constructor Create(AOwner: TComponent); override; + procedure Draw(ABuffer: TBitmap; ClipRect: T2DIntRect); override; + function GetWidth: integer; override; + function GetTableBehaviour: TSpkItemTableBehaviour; override; + function GetGroupBehaviour: TSpkItemGroupBehaviour; override; + function GetSize: TSpkItemSize; override; published - property ShowCaption : boolean read FShowCaption write SetShowCaption; - property TableBehaviour : TSpkItemTableBehaviour read FTableBehaviour write SetTableBehaviour; - property GroupBehaviour : TSpkItemGroupBehaviour read FGroupBehaviour write SetGroupBehaviour; - property HideFrameWhenIdle : boolean read FHideFrameWhenIdle write SetHideFrameWhenIdle; - property ImageIndex : TImageIndex read FImageIndex write SetImageIndex default -1; + property ShowCaption: boolean read FShowCaption write SetShowCaption; + property TableBehaviour: TSpkItemTableBehaviour read FTableBehaviour write SetTableBehaviour; + property GroupBehaviour: TSpkItemGroupBehaviour read FGroupBehaviour write SetGroupBehaviour; + property HideFrameWhenIdle: boolean read FHideFrameWhenIdle write SetHideFrameWhenIdle; + property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default -1; property ButtonKind; property DropdownMenu; end; @@ -176,28 +172,28 @@ type TSpkSmallButton = class(TSpkBaseButton) implementation uses - LCLType, LCLIntf, LCLProc, SysUtils, spkt_Pane; + LCLType, LCLIntf, LCLProc, SysUtils, spkt_Pane, spkt_Appearance; { TSpkButtonActionLink } procedure TSpkButtonActionLink.AssignClient(AClient: TObject); begin inherited AssignClient(AClient); - FClient:=TSpkBaseButton(AClient); + FClient := TSpkBaseButton(AClient); end; function TSpkButtonActionLink.IsCaptionLinked: Boolean; begin -result:=(inherited IsCaptionLinked) and - (assigned(FClient)) and - (FClient.Caption = (Action as TCustomAction).Caption); + Result := inherited IsCaptionLinked and + Assigned(FClient) and + (FClient.Caption = (Action as TCustomAction).Caption); end; function TSpkButtonActionLink.IsEnabledLinked: Boolean; begin -result:=(inherited IsEnabledLinked) and - (assigned(FClient)) and - (FClient.Enabled = (Action as TCustomAction).Enabled); + Result := inherited IsEnabledLinked and + Assigned(FClient) and + (FClient.Enabled = (Action as TCustomAction).Enabled); end; function TSpkButtonActionLink.IsOnExecuteLinked: Boolean; @@ -220,9 +216,9 @@ end; function TSpkButtonActionLink.IsVisibleLinked: Boolean; begin -result:=(inherited IsVisibleLinked) and - (assigned(FClient)) and - (FClient.Visible = (Action as TCustomAction).Visible); + Result := inherited IsVisibleLinked and + Assigned(FClient) and + (FClient.Visible = (Action as TCustomAction).Visible); end; procedure TSpkButtonActionLink.SetCaption(const Value: string); @@ -673,45 +669,44 @@ end; procedure TSpkBaseButton.SetButtonKind(const Value: TSpkButtonKind); begin - FButtonKind:=Value; - if assigned(FToolbarDispatch) then + FButtonKind := Value; + if Assigned(FToolbarDispatch) then FToolbarDispatch.NotifyMetricsChanged; end; procedure TSpkBaseButton.SetCaption(const Value: string); begin - FCaption:=Value; - if assigned(FToolbarDispatch) then + FCaption := Value; + if Assigned(FToolbarDispatch) then FToolbarDispatch.NotifyMetricsChanged; end; procedure TSpkBaseButton.SetDropdownMenu(const Value: TPopupMenu); begin - FDropdownMenu:=Value; - if assigned(FToolbarDispatch) then + FDropdownMenu := Value; + if Assigned(FToolbarDispatch) then FToolbarDispatch.NotifyMetricsChanged; end; procedure TSpkBaseButton.SetEnabled(const Value: boolean); begin inherited; - if not(FEnabled) then - begin - // Jeœli przycisk zosta³ wy³¹czony, zostaje natychmiast prze³¹czony - // w stan Idle i zerowane s¹ elementy aktywne i pod mysz¹. Jeœli zosta³ - // w³¹czony, jego stan zmieni siê podczas pierwszej akcji myszy. + if not FEnabled then + begin + // Jeœli przycisk zosta³ wy³¹czony, zostaje natychmiast prze³¹czony + // w stan Idle i zerowane s¹ elementy aktywne i pod mysz¹. Jeœli zosta³ + // w³¹czony, jego stan zmieni siê podczas pierwszej akcji myszy. - FMouseHoverElement:=beNone; - FMouseActiveElement:=beNone; + FMouseHoverElement := beNone; + FMouseActiveElement := beNone; - if FButtonState<>bsIdle then - begin - FButtonState:=bsIdle; - - if assigned(FToolbarDispatch) then - FToolbarDispatch.NotifyVisualsChanged; - end; - end; + if FButtonState <> bsIdle then + begin + FButtonState := bsIdle; + if Assigned(FToolbarDispatch) then + FToolbarDispatch.NotifyVisualsChanged; + end; + end; end; procedure TSpkBaseButton.SetRect(const Value: T2DIntRect); @@ -724,955 +719,422 @@ end; procedure TSpkLargeButton.CalcRects; begin -{$IFDEF EnhancedRecordSupport} -if FButtonKind = bkButtonDropdown then - begin - FButtonRect:=T2DIntRect.Create(FRect.Left, FRect.Top, FRect.Right, FRect.Bottom - SpkLayoutSizes.LARGEBUTTON_DROPDOWN_FIELD_SIZE); - FDropdownRect:=T2DIntRect.Create(FRect.Left, FRect.Bottom - SpkLayoutSizes.LARGEBUTTON_DROPDOWN_FIELD_SIZE + 1, FRect.Right, FRect.Bottom); - end -else - begin - FButtonRect:=FRect; - FDropdownRect:=T2DIntRect.Create(0, 0, 0, 0); - end; -{$ELSE} -if FButtonKind = bkButtonDropdown then - begin - FButtonRect.Create(FRect.Left, FRect.Top, FRect.Right, FRect.Bottom - LargeButtonDropdownFieldSize); - FDropdownRect.Create(FRect.Left, FRect.Bottom - LargeButtonDropdownFieldSize + 1, FRect.Right, FRect.Bottom); - end -else - begin - FButtonRect:=FRect; - FDropdownRect.Create(0, 0, 0, 0); - end; -{$ENDIF} + {$IFDEF EnhancedRecordSupport} + if FButtonKind = bkButtonDropdown then + begin + FButtonRect := T2DIntRect.Create(FRect.Left, FRect.Top, FRect.Right, FRect.Bottom - LargeButtonDropdownFieldSize); + FDropdownRect := T2DIntRect.Create(FRect.Left, FRect.Bottom - LargeButtonDropdownFieldSize, FRect.Right, FRect.Bottom); + //FDropdownRect := T2DIntRect.Create(FRect.Left, FRect.Bottom - LargeButtonDropdownFieldSize + 1, FRect.Right, FRect.Bottom); + end else + begin + FButtonRect := FRect; + FDropdownRect := T2DIntRect.Create(0, 0, 0, 0); + end; + {$ELSE} + if FButtonKind = bkButtonDropdown then + begin + FButtonRect.Create(FRect.Left, FRect.Top, FRect.Right, FRect.Bottom - LargeButtonDropdownFieldSize); + FDropdownRect.Create(FRect.Left, FRect.Bottom - LargeButtonDropdownFieldSize, FRect.Right, FRect.Bottom); +// FDropdownRect.Create(FRect.Left, FRect.Bottom - LargeButtonDropdownFieldSize + 1, FRect.Right, FRect.Bottom); + end else + begin + FButtonRect := FRect; + FDropdownRect.Create(0, 0, 0, 0); + end; + {$ENDIF} end; constructor TSpkLargeButton.Create(AOwner: TComponent); begin inherited; - FLargeImageIndex:=-1; + FLargeImageIndex := -1; end; procedure TSpkLargeButton.Draw(ABuffer: TBitmap; ClipRect: T2DIntRect); - -var FrameColor: TColor; - InnerLightColor: TColor; - InnerDarkColor: TColor; - GradientFromColor: TColor; - GradientToColor: TColor; - GradientKind : TBackgroundKind; - DrawRgn, TmpRgn : HRGN; - x: Integer; - y: Integer; - - FontColor: TColor; - BreakPos: Integer; - BreakWidth: Integer; - s: string; - TextHeight: Integer; - +var + fontColor, frameColor: TColor; + gradientFromColor, gradientToColor: TColor; + innerLightColor, innerDarkColor: TColor; + gradientKind: TBackgroundKind; + x: Integer; + y: Integer; + cornerRadius: Integer; + imgList: TImageList; + txtHeight: Integer; + breakPos, breakWidth: Integer; + s: String; + P: T2DIntPoint; + drawBtn: Boolean; begin -if FToolbarDispatch=nil then - exit; -if FAppearance=nil then - exit; + if FToolbarDispatch = nil then + exit; + if FAppearance = nil then + exit; -if (FRect.width<2*LargeButtonRadius) or (FRect.Height<2*LargeButtonRadius) then - exit; + if (FRect.Width < 2*LargeButtonRadius) or (FRect.Height < 2*LargeButtonRadius) then + exit; -if FButtonKind in [bkButton, bkDropdown] then - begin - {$REGION 'Tryb bez dodatkowego przycisku z rozwijanym menu'} - // *** T³o *** - if not(FEnabled) then - begin - {$REGION 'T³o dla disabled'} - // Brak t³a - {$ENDREGION} - end else - if FButtonState = bsIdle then - begin - {$REGION 'T³o dla Idle'} - // Brak t³a - {$ENDREGION} - end else - if FButtonState = bsBtnHottrack then - begin - {$REGION 'T³o dla HotTrack'} - TGuiTools.DrawRoundRect(ABuffer.Canvas, - {$IFDEF EnhancedRecordSupport} - T2DIntRect.Create(FButtonRect.left, - FButtonRect.Top, - FButtonRect.Right, - FButtonRect.Bottom), - {$ELSE} - Create2DIntRect(FButtonRect.left, - FButtonRect.Top, - FButtonRect.Right, - FButtonRect.Bottom), - {$ENDIF} - LargeButtonRadius, - FAppearance.Element.HotTrackGradientFromColor, - FAppearance.Element.HotTrackGradientToColor, - FAppearance.Element.HotTrackGradientType, - ClipRect); + case FAppearance.Element.Style of + esRounded: + cornerRadius := LargeButtonRadius; + esRectangle: + cornerRadius := 0; + end; - TGuiTools.DrawAARoundFrame(ABuffer, - {$IFDEF EnhancedRecordSupport} - T2DIntRect.Create(FButtonRect.left+1, - FButtonRect.top+1, - FButtonRect.right-1, - FButtonRect.Bottom-1), - {$ELSE} - Create2DIntRect(FButtonRect.left+1, - FButtonRect.top+1, - FButtonRect.right-1, - FButtonRect.Bottom-1), - {$ENDIF} - LargeButtonRadius, - FAppearance.Element.HotTrackInnerLightColor, - ClipRect); - TGuiTools.DrawAARoundFrame(ABuffer, - FButtonRect, - LargeButtonRadius, - FAppearance.Element.HotTrackFrameColor, - ClipRect); - {$ENDREGION} - end else - if FButtonState = bsBtnPressed then - begin - {$REGION 'T³o dla Pressed'} - TGuiTools.DrawRoundRect(ABuffer.Canvas, - {$IFDEF EnhancedRecordSupport} - T2DIntRect.Create(FButtonRect.left, - FButtonRect.Top, - FButtonRect.Right, - FButtonRect.Bottom), - {$ELSE} - Create2DIntRect(FButtonRect.left, - FButtonRect.Top, - FButtonRect.Right, - FButtonRect.Bottom), - {$ENDIF} - LargeButtonRadius, - FAppearance.Element.ActiveGradientFromColor, - FAppearance.Element.ActiveGradientToColor, - FAppearance.Element.ActiveGradientType, - ClipRect); + // Prepare text color + fontColor := clNone; + case FButtonState of + bsIdle: + fontColor := FAppearance.Element.IdleCaptionColor; + bsBtnHottrack, + bsDropdownHottrack: + fontColor := FAppearance.Element.HotTrackCaptionColor; + bsBtnPressed, + bsDropdownPressed: + fontColor := FAppearance.ELement.ActiveCaptionColor; + end; + if not FEnabled then + fontColor := TColorTools.ColorToGrayscale(fontColor); + // Dropdown button + // Draw full rect, otherwise the DropDownRect will contain the full gradient + if FButtonKind = bkButtonDropdown then + begin + drawBtn := true; + if (FButtonState in [bsBtnHottrack, bsBtnPressed]) then + begin + frameColor := TColorTools.Brighten(FAppearance.Element.HotTrackFrameColor, 40); + innerLightColor := TColorTools.Brighten(FAppearance.Element.HotTrackInnerLightColor, 40); + innerDarkColor := TColorTools.Brighten(FAppearance.Element.HotTrackInnerDarkColor, 40); + gradientFromColor := TColorTools.Brighten(FAppearance.Element.HotTrackGradientFromColor, 40); + gradientToColor := TColorTools.Brighten(FAppearance.Element.HotTrackGradientToColor, 40); + gradientKind := FAppearance.Element.HotTrackGradientType; + end else + if (FButtonState = bsDropdownHottrack) then + begin + frameColor := FAppearance.Element.HotTrackFrameColor; + innerLightColor := FAppearance.Element.HotTrackInnerLightColor; + innerDarkColor := FAppearance.Element.HotTrackInnerDarkColor; + gradientFromColor := FAppearance.Element.HotTrackGradientFromColor; + gradientToColor := FAppearance.Element.HotTrackGradientToColor; + gradientKind := FAppearance.Element.HotTrackGradientType; + end else + if (FButtonState = bsDropdownPressed) then + begin + frameColor := FAppearance.Element.ActiveFrameColor; + innerlightColor := FAppearance.Element.ActiveInnerLightColor; + innerDarkColor := FAppearance.Element.ActiveInnerDarkColor; + gradientFromColor := FAppearance.Element.ActiveGradientFromColor; + gradientToColor := FAppearance.Element.ActiveGradientToColor; + gradientKind := FAppearance.Element.ActiveGradientType; + end else + drawBtn := false; - TGuiTools.DrawAARoundFrame(ABuffer, - {$IFDEF EnhancedRecordSupport} - T2DIntRect.Create(FButtonRect.left+1, - FButtonRect.top+1, - FButtonRect.right-1, - FButtonRect.Bottom-1), - {$ELSE} - Create2DIntRect(FButtonRect.left+1, - FButtonRect.top+1, - FButtonRect.right-1, - FButtonRect.Bottom-1), - {$ENDIF} - LargeButtonRadius, - FAppearance.Element.ActiveInnerLightColor, - ClipRect); - TGuiTools.DrawAARoundFrame(ABuffer, - FButtonRect, - LargeButtonRadius, - FAppearance.Element.ActiveFrameColor, - ClipRect); - {$ENDREGION} - end else - raise InternalException.create('TSpkLargeButton.Draw: Nieprawid³owa wartoœæ FButtonState!'); + if drawBtn then begin + TButtonTools.DrawButton( + ABuffer, + FRect, + frameColor, + innerLightColor, + innerDarkColor, + gradientFromColor, + gradientToColor, + gradientKind, + false, + false, + false, + false, + cornerRadius, + ClipRect + ); + end; + end; - // *** Ikona *** - if not(FEnabled) then - begin - {$REGION 'Ikona wy³¹czona'} - if (FLargeImageIndex>=0) and - (FDisabledLargeImages<>nil) and - (FLargeImageIndex=0) and - (FLargeImages<>nil) and - (FLargeImageIndex=0) and - (FLargeImages<>nil) and - (FLargeImageIndex nil) then + imgList := FDisabledLargeImages + else + imgList := FLargeImages; - // *** Tekst *** + if (imgList <> nil) and (FLargeImageIndex >= 0) and (FLargeImageIndex < imgList.Count) then + begin + P := {$IFDEF EnhancedRecordSupport}T2DIntPoint.Create{$ELSE}Create2DIntPoint{$ENDIF}( + FButtonRect.Left + (FButtonRect.Width - imgList.Width) div 2, + FButtonRect.Top + LargeButtonBorderSize + LargeButtonGlyphMargin + ); + TGUITools.DrawImage( + ABuffer.Canvas, + imgList, + FLargeImageIndex, + P, + ClipRect + ); + end; - if not(FEnabled) then - begin - FontColor:=clNone; - case FButtonState of - bsIdle: FontColor:=TColorTools.ColorToGrayscale(FAppearance.Element.IdleCaptionColor); - bsBtnHottrack, - bsDropdownHottrack : FontColor:=TColorTools.ColorToGrayscale(FAppearance.Element.HotTrackCaptionColor); - bsBtnPressed, - bsDropdownPressed: FontColor:=TColorTools.ColorToGrayscale(FAppearance.ELement.ActiveCaptionColor); - end; - end - else - begin - FontColor:=clNone; - case FButtonState of - bsIdle: FontColor:=FAppearance.Element.IdleCaptionColor; - bsBtnHottrack, - bsDropdownHottrack : FontColor:=FAppearance.Element.HotTrackCaptionColor; - bsBtnPressed, - bsDropdownPressed: FontColor:=FAppearance.ELement.ActiveCaptionColor; - end; - end; + // Text + ABuffer.Canvas.Font.Assign(FAppearance.Element.CaptionFont); + ABuffer.Canvas.Font.Height := SpkScaleY(ABuffer.Canvas.Font.Height, 96); + ABuffer.Canvas.Font.Color := fontColor; - ABuffer.Canvas.Font.assign(FAppearance.Element.CaptionFont); - ABuffer.Canvas.Font.Color:=FontColor; + if FButtonKind = bkButton then + FindBreakPlace(FCaption, breakPos, breakWidth) + else + breakPos := 0; + txtHeight := ABuffer.Canvas.TextHeight('Wy'); - if FButtonKind = bkButton then - FindBreakPlace(FCaption, BreakPos, BreakWidth) else - BreakPos:=0; + if breakPos > 0 then + begin + s := Copy(FCaption, 1, breakPos - 1); + x := FRect.Left + (FRect.Width - ABuffer.Canvas.Textwidth(s)) div 2; + y := FRect.Top + LargeButtonCaptionTopRail - txtHeight div 2; + TGUITools.DrawText(ABuffer.Canvas, x, y, s, fontColor, ClipRect); - if BreakPos>0 then - begin - // Tekst z³amany - TextHeight:=ABuffer.Canvas.Textheight('Wy'); + s := Copy(FCaption, breakPos+1, Length(FCaption) - breakPos); + x := FRect.Left + (FRect.Width - ABuffer.Canvas.Textwidth(s)) div 2; + y := FRect.Top + LargeButtonCaptionButtomRail - txtHeight div 2; + TGUITools.DrawText(ABuffer.Canvas, x, y, s, fontColor, ClipRect); + end else + begin + // Tekst nie z³amany + x := FButtonRect.Left + (FButtonRect.Width - ABuffer.Canvas.Textwidth(FCaption)) div 2; + y := FRect.Top + LargeButtonCaptionTopRail - txtHeight div 2; + TGUITools.DrawText(ABuffer.Canvas, x, y, FCaption, FontColor, ClipRect); + end; - s:=copy(FCaption, 1, BreakPos-1); - x:=FRect.Left + (FRect.width - ABuffer.Canvas.Textwidth(s)) div 2; - y:=FRect.Top + LargeButtonCaptionTopRail - TextHeight div 2; - TGUITools.DrawText(ABuffer.Canvas, x, y, s, FontColor, ClipRect); + // Chevron + ABuffer.Canvas.Font.Charset := DEFAULT_CHARSET; + ABuffer.Canvas.Font.Name := 'Marlett'; + ABuffer.Canvas.Font.Style := []; + ABuffer.Canvas.Font.Orientation := 0; - s:=copy(FCaption, BreakPos+1, length(FCaption) - BreakPos); - x:=FRect.Left + (FRect.width - ABuffer.Canvas.Textwidth(s)) div 2; - y:=FRect.Top + LargeButtonCaptionButtomRail - TextHeight div 2; - TGUITools.DrawText(ABuffer.Canvas, x, y, s, FontColor, ClipRect); - end - else - begin - // Tekst nie z³amany - TextHeight:=ABuffer.Canvas.Textheight('Wy'); - - x:=FButtonRect.Left + (FButtonRect.width - ABuffer.Canvas.Textwidth(FCaption)) div 2; - y:=FRect.Top + LargeButtonCaptionTopRail - TextHeight div 2; - TGUITools.DrawText(ABuffer.Canvas, x, y, FCaption, FontColor, ClipRect); - end; - - if FButtonKind = bkDropdown then - begin - // Chevron strza³ki w dó³ - - if not(FEnabled) then - begin - case FButtonState of - bsIdle: FontColor:=TColorTools.ColorToGrayscale(FAppearance.Element.IdleCaptionColor); - bsBtnHottrack, - bsDropdownHottrack : FontColor:=TColorTools.ColorToGrayscale(FAppearance.Element.HotTrackCaptionColor); - bsBtnPressed, - bsDropdownPressed: FontColor:=TColorTools.ColorToGrayscale(FAppearance.ELement.ActiveCaptionColor); - end; - end - else - begin - case FButtonState of - bsIdle: FontColor:=FAppearance.Element.IdleCaptionColor; - bsBtnHottrack, - bsDropdownHottrack : FontColor:=FAppearance.Element.HotTrackCaptionColor; - bsBtnPressed, - bsDropdownPressed: FontColor:=FAppearance.ELement.ActiveCaptionColor; - end; - end; - - ABuffer.Canvas.Font.Charset:=DEFAULT_CHARSET; - ABuffer.Canvas.Font.Name:='Marlett'; - ABuffer.Canvas.Font.Size:=8; - ABuffer.Canvas.Font.Style:=[]; - ABuffer.Canvas.Font.Orientation:=0; - - x:=FButtonRect.Left + (FButtonRect.width - ABuffer.Canvas.Textwidth('u')) div 2; - y:=FButtonRect.bottom - ABuffer.Canvas.Textheight('u') - LargeButtonChevronHMargin; - TGUITools.DrawText(ABuffer.Canvas, x, y, 'u', FontColor, ClipRect); - end; - - {$ENDREGION} - end -else - begin - {$REGION 'Tryb z rozwijanym menu'} - // *** T³o *** - if not(FEnabled) then - begin - {$REGION 'T³o dla Disabled'} - // - {$ENDREGION} - end else - if FButtonState = bsIdle then - begin - {$REGION 'T³o dla Idle'} - // - {$ENDREGION} - end else - if (FButtonState = bsBtnHottrack) or (FButtonState = bsDropdownHottrack) or - (FButtonState = bsBtnPressed) or (FButtonState = bsDropdownPressed) then - begin - {$REGION 'T³o dla aktywnego'} - - // *** Przycisk *** - - {$REGION 'Ustalanie kolorów'} - if FButtonState = bsBtnHottrack then - begin - FrameColor:=FAppearance.Element.HotTrackFrameColor; - InnerLightColor:=FAppearance.Element.HotTrackInnerLightColor; - GradientFromColor:=FAppearance.Element.HotTrackGradientFromColor; - GradientToColor:=FAppearance.Element.HotTrackGradientToColor; - GradientKind:=FAppearance.Element.HotTrackGradientType; - end else - if FButtonState = bsBtnPressed then - begin - FrameColor:=FAppearance.Element.ActiveFrameColor; - InnerLightColor:=FAppearance.Element.ActiveInnerLightColor; - GradientFromColor:=FAppearance.Element.ActiveGradientFromColor; - GradientToColor:=FAppearance.Element.ActiveGradientToColor; - GradientKind:=FAppearance.Element.ActiveGradientType; - end - else - begin - FrameColor:=TColorTools.Brighten(FAppearance.Element.HotTrackFrameColor,40); - InnerLightColor:=TColorTools.Brighten(FAppearance.Element.HotTrackInnerLightColor,40); - GradientFromColor:=TColorTools.Brighten(FAppearance.Element.HotTrackGradientFromColor,40); - GradientToColor:=TColorTools.Brighten(FAppearance.Element.HotTrackGradientToColor,40); - GradientKind:=FAppearance.Element.HotTrackGradientType; - end; - {$ENDREGION} - - {$REGION 'T³o przycisku'} - DrawRgn:=CreateRectRgn(FButtonRect.Left, - FButtonRect.Top + LargeButtonRadius, - FButtonRect.Right + 1, - FButtonRect.Bottom); - - TmpRgn:=CreateRectRgn(FButtonRect.left + LargeButtonRadius, - FButtonRect.Top, - FButtonRect.right - LargeButtonRadius + 1, - FButtonRect.Top + LargeButtonRadius); - CombineRgn(DrawRgn, DrawRgn, TmpRgn, RGN_OR); - DeleteObject(TmpRgn); - - TmpRgn:=CreateEllipticRgn(FButtonRect.Left, - FButtonRect.Top, - FButtonRect.Left + 2 * LargeButtonRadius + 1, - FButtonRect.Top + 2 * LargeButtonRadius + 1); - CombineRgn(DrawRgn, DrawRgn, TmpRgn, RGN_OR); - DeleteObject(TmpRgn); - - TmpRgn:=CreateEllipticRgn(FButtonRect.Right - 2 * LargeButtonRadius + 1, - FButtonRect.Top, - FButtonRect.Right + 2, - FButtonRect.Top + 2 * LargeButtonRadius + 1); - CombineRgn(DrawRgn, DrawRgn, TmpRgn, RGN_OR); - DeleteObject(TmpRgn); - - TGuiTools.DrawRegion(ABuffer.Canvas, - DrawRgn, - FRect, - GradientFromColor, - GradientToColor, - GradientKind, - ClipRect); - DeleteObject(DrawRgn); - {$ENDREGION} - - {$REGION 'Ramka przycisku'} - // Wewnêtrzna ramka - TGuiTools.DrawAARoundCorner(ABuffer, - {$IFDEF EnhancedRecordSupport} - T2DIntPoint.Create(FButtonRect.Left + 1, FButtonRect.Top + 1), - {$ELSE} - Create2DIntPoint(FButtonRect.Left + 1, FButtonRect.Top + 1), - {$ENDIF} - LargeButtonRadius, - cpLeftTop, - InnerLightColor, - ClipRect); - TGuiTools.DrawAARoundCorner(ABuffer, - {$IFDEF EnhancedRecordSupport} - T2DIntPoint.Create(FButtonRect.Right - SpkLayoutSizes.LARGEBUTTON_RADIUS, FButtonRect.Top + 1), - {$ELSE} - Create2DIntPoint(FButtonRect.Right - LargeButtonRadius, FButtonRect.Top + 1), - {$ENDIF} - LargeButtonRadius, - cpRightTop, - InnerLightColor, - ClipRect); - TGuiTools.DrawHLine(ABuffer, - FButtonRect.Left + LargeButtonRadius + 1, - FButtonRect.Right - LargeButtonRadius - 1, - FButtonRect.Top + 1, - InnerLightColor, - ClipRect); - TGuiTools.DrawVLine(ABuffer, - FButtonRect.Left + 1, - FButtonRect.Top + LargeButtonRadius + 1, - FButtonRect.Bottom, - InnerLightColor, - ClipRect); - TGuiTools.DrawVLine(ABuffer, - FButtonRect.Right - 1, - FButtonRect.Top + LargeButtonRadius + 1, - FButtonRect.Bottom, - InnerLightColor, - ClipRect); - - if FButtonState = bsBtnPressed then - TGuiTools.DrawHLine(ABuffer, - FButtonRect.Left + 1, - FButtonRect.Right - 1, - FButtonRect.Bottom, - FrameColor, - ClipRect) else - TGuiTools.DrawHLine(ABuffer, - FButtonRect.Left + 1, - FButtonRect.Right - 1, - FButtonRect.Bottom, - InnerLightColor, - ClipRect); - - // Zewnêtrzna ramka - TGuiTools.DrawAARoundCorner(ABuffer, - {$IFDEF EnhancedRecordSupport} - T2DIntPoint.Create(FButtonRect.Left, FButtonRect.Top), - {$ELSE} - Create2DIntPoint(FButtonRect.Left, FButtonRect.Top), - {$ENDIF} - LargeButtonRadius, - cpLeftTop, - FrameColor, - ClipRect); - TGuiTools.DrawAARoundCorner(ABuffer, - {$IFDEF EnhancedRecordSupport} - T2DIntPoint.Create(FButtonRect.Right - LargeButtonRadius + 1, FButtonRect.Top), - {$ELSE} - Create2DIntPoint(FButtonRect.Right - LargeButtonRadius + 1, FButtonRect.Top), - {$ENDIF} - LargeButtonRadius, - cpRightTop, - FrameColor, - ClipRect); - TGuiTools.DrawHLine(ABuffer, - FButtonRect.Left + LargeButtonRadius, - FButtonRect.Right - LargeButtonRadius, - FButtonRect.Top, - FrameColor, - ClipRect); - TGuiTools.DrawVLine(ABuffer, - FButtonRect.Left, - FButtonRect.Top + LargeButtonRadius, - FButtonRect.Bottom, - FrameColor, - ClipRect); - TGuiTools.DrawVLine(ABuffer, - FButtonRect.Right, - FButtonRect.Top + LargeButtonRadius, - FButtonRect.Bottom, - FrameColor, - ClipRect); - {$ENDREGION} - - // *** Dropdown *** - - {$REGION 'Ustalanie kolorów'} - if FButtonState = bsDropdownHottrack then - begin - FrameColor:=FAppearance.Element.HotTrackFrameColor; - InnerLightColor:=FAppearance.Element.HotTrackInnerLightColor; - InnerDarkColor:=FAppearance.Element.HotTrackInnerDarkColor; - GradientFromColor:=FAppearance.Element.HotTrackGradientFromColor; - GradientToColor:=FAppearance.Element.HotTrackGradientToColor; - GradientKind:=FAppearance.Element.HotTrackGradientType; - end else - if FButtonState = bsDropdownPressed then - begin - FrameColor:=FAppearance.Element.ActiveFrameColor; - InnerLightColor:=FAppearance.Element.ActiveInnerLightColor; - InnerDarkColor:=FAppearance.Element.ActiveInnerDarkColor; - GradientFromColor:=FAppearance.Element.ActiveGradientFromColor; - GradientToColor:=FAppearance.Element.ActiveGradientToColor; - GradientKind:=FAppearance.Element.ActiveGradientType; - end - else - begin - FrameColor:=TColorTools.Brighten(FAppearance.Element.HotTrackFrameColor,20); - InnerLightColor:=TColorTools.Brighten(FAppearance.Element.HotTrackInnerLightColor,20); - InnerDarkColor:=TColorTools.Brighten(FAppearance.Element.HotTrackInnerDarkColor,20); - GradientFromColor:=TColorTools.Brighten(FAppearance.Element.HotTrackGradientFromColor,20); - GradientToColor:=TColorTools.Brighten(FAppearance.Element.HotTrackGradientToColor,20); - GradientKind:=FAppearance.Element.HotTrackGradientType; - end; - {$ENDREGION} - - {$REGION 'T³o dropdown'} - DrawRgn:=CreateRectRgn(FDropdownRect.left, - FDropdownRect.Top, - FDropdownRect.Right + 1, - FDropdownRect.Bottom - LargeButtonRadius + 1); - - TmpRgn:=CreateRectRgn(FDropdownRect.left + LargeButtonRadius, - FDropdownRect.Bottom - LargeButtonRadius + 1, - FDropdownRect.Right - LargeButtonRadius + 1, - FDropdownRect.Bottom + 1); - CombineRgn(DrawRgn, DrawRgn, TmpRgn, RGN_OR); - DeleteObject(TmpRgn); - - TmpRgn:=CreateEllipticRgn(FDropdownRect.Left, - FDropdownRect.bottom - 2 * LargeButtonRadius + 1, - FDropdownRect.left + 2 * LargeButtonRadius + 1, - FDropdownRect.Bottom + 2); - CombineRgn(DrawRgn, DrawRgn, TmpRgn, RGN_OR); - DeleteObject(TmpRgn); - - TmpRgn:=CreateEllipticRgn(FDropdownRect.Right - 2 * LargeButtonRadius + 1, - FDropdownRect.Bottom - 2 * LargeButtonRadius + 1, - FDropdownRect.Right + 2, - FDropdownRect.Bottom + 2); - CombineRgn(DrawRgn, DrawRgn, TmpRgn, RGN_OR); - DeleteObject(TmpRgn); - - TGuiTools.DrawRegion(ABuffer.Canvas, - DrawRgn, - FRect, - GradientFromColor, - GradientToColor, - GradientKind, - ClipRect); - DeleteObject(DrawRgn); - {$ENDREGION} - - {$REGION 'Ramka dropdown'} - // Wewnêtrzna ramka - - TGuiTools.DrawAARoundCorner(ABuffer, - {$IFDEF EnhancedRecordSupport} - T2DIntPoint.Create(FDropdownRect.Left + 1, FDropdownRect.Bottom - SpkLayoutSizes.LARGEBUTTON_RADIUS), - {$ELSE} - Create2DIntPoint(FDropdownRect.Left + 1, FDropdownRect.Bottom - LargeButtonRadius), - {$ENDIF} - LargeButtonRadius, - cpLeftBottom, - InnerLightColor); - TGuiTools.DrawAARoundCorner(ABuffer, - {$IFDEF EnhancedRecordSupport} - T2DIntPoint.Create(FDropdownRect.right - LargeButtonRadius, FDropdownRect.Bottom - LargeButtonRadius), - {$ELSE} - Create2DIntPoint(FDropdownRect.right - LargeButtonRadius, FDropdownRect.Bottom - LargeButtonRadius), - {$ENDIF} - LargeButtonRadius, - cpRightBottom, - InnerLightColor); - TGuiTools.DrawHLine(ABuffer, - FDropdownRect.Left + LargeButtonRadius + 1, - FDropdownRect.Right - LargeButtonRadius - 1, - FDropdownRect.Bottom - 1, - InnerLightColor, - ClipRect); - TGuiTools.DrawVLine(ABuffer, - FDropdownRect.Left + 1, - FDropDownRect.Top + 1, - FDropDownRect.Bottom - LargeButtonRadius - 1, - InnerLightColor, - ClipRect); - TGuiTools.DrawVLine(ABuffer, - FDropdownRect.Right - 1, - FDropDownRect.Top + 1, - FDropDownRect.Bottom - LargeButtonRadius - 1, - InnerLightColor, - ClipRect); - - if FButtonState = bsDropdownPressed then - TGuiTools.DrawHLine(ABuffer, - FDropdownRect.Left + 1, - FDropdownRect.Right - 1, - FDropdownRect.Top, - FrameColor, - ClipRect) - else - TGuiTools.DrawHLine(ABuffer, - FDropdownRect.Left + 1, - FDropdownRect.Right - 1, - FDropdownRect.Top, - InnerDarkColor, - ClipRect); - - - // Zewnêtrzna ramka - TGuiTools.DrawAARoundCorner(ABuffer, - {$IFDEF EnhancedRecordSupport} - T2DIntPoint.Create(FDropdownRect.Left, FDropdownRect.Bottom - LargeButtonRadius + 1), - {$ELSE} - Create2DIntPoint(FDropdownRect.Left, FDropdownRect.Bottom - LargeButtonRadius + 1), - {$ENDIF} - LargeButtonRadius, - cpLeftBottom, - FrameColor); - TGuiTools.DrawAARoundCorner(ABuffer, - {$IFDEF EnhancedRecordSupport} - T2DIntPoint.Create(FDropdownRect.right - LargeButtonRadius + 1, FDropdownRect.Bottom - LargeButtonRadius + 1), - {$ELSE} - Create2DIntPoint(FDropdownRect.right - LargeButtonRadius + 1, FDropdownRect.Bottom - LargeButtonRadius + 1), - {$ENDIF} - LargeButtonRadius, - cpRightBottom, - FrameColor); - TGuiTools.DrawHLine(ABuffer, - FDropdownRect.Left + LargeButtonRadius, - FDropdownRect.Right - LargeButtonRadius, - FDropdownRect.Bottom, - FrameColor, - ClipRect); - TGuiTools.DrawVLine(ABuffer, - FDropdownRect.Left, - FDropDownRect.Top, - FDropDownRect.Bottom - LargeButtonRadius, - FrameColor, - ClipRect); - TGuiTools.DrawVLine(ABuffer, - FDropdownRect.Right, - FDropDownRect.Top, - FDropDownRect.Bottom - LargeButtonRadius, - FrameColor, - ClipRect); - {$ENDREGION} - - {$ENDREGION} - end else - raise InternalException.create('TSpkLargeButton.Draw: Nieprawid³owa wartoœæ FButtonState!'); - - // *** Ikona *** - if not(FEnabled) then - begin - {$REGION 'Ikona wy³¹czona'} - if (FLargeImageIndex>=0) and - (FDisabledLargeImages<>nil) and - (FLargeImageIndex=0) and - (FLargeImages<>nil) and - (FLargeImageIndex=0) and - (FLargeImages<>nil) and - (FLargeImageIndex0 then - for i := 1 to length(s) do - if s[i]=' ' then - begin - if i>1 then - BeforeWidth:=Bitmap.Canvas.TextWidth(copy(s,1,i-1)) else - BeforeWidth:=0; + for i := 1 to Length(s) do + if s[i] = ' ' then + begin + if i > 1 then + BeforeWidth := Bitmap.Canvas.TextWidth(Copy(s, 1, i-1)) + else + BeforeWidth := 0; - if inil then - GlyphWidth:=2 * LargeButtonGlyphMargin + FLargeImages.Width else - GlyphWidth:=0; + // Glyph + if FLargeImages <> nil then + GlyphWidth := 2 * LargeButtonGlyphMargin + FLargeImages.Width + else + GlyphWidth := 0; -// *** Tekst *** -if FButtonKind = bkButton then - begin - // £amiemy etykietê - FindBreakPlace(FCaption,BreakPos,RowWidth); - TextWidth:=2 * LargeButtonCaptionHMargin + RowWidth; - end -else - begin - // Nie ³amiemy etykiety - Bitmap.canvas.font.assign(FAppearance.Element.CaptionFont); - TextWidth:=2 * LargeButtonCaptionHMargin + Bitmap.Canvas.TextWidth(FCaption); - end; + // Text + if FButtonKind = bkButton then + begin + // £amiemy etykietê + FindBreakPlace(FCaption,BreakPos,RowWidth); + TextWidth := 2 * LargeButtonCaptionHMargin + RowWidth; + end else + begin + // Nie ³amiemy etykiety + Bitmap.Canvas.Font.Assign(FAppearance.Element.CaptionFont); + TextWidth := 2 * LargeButtonCaptionHMargin + Bitmap.Canvas.TextWidth(FCaption); + end; -result := Max(LargeButtonMinWidth, max(GlyphWidth, TextWidth)); + Result := Max(LargeButtonMinWidth, Max(GlyphWidth, TextWidth)); end; procedure TSpkLargeButton.SetLargeImageIndex(const Value: TImageIndex); begin -FLargeImageIndex:=Value; - -if assigned(FToolbarDispatch) then - FToolbarDispatch.NotifyMetricsChanged; + FLargeImageIndex := Value; + if Assigned(FToolbarDispatch) then + FToolbarDispatch.NotifyMetricsChanged; end; { TSpkSmallButton } procedure TSpkSmallButton.CalcRects; - -var RectVector : T2DIntVector; - +var + RectVector: T2DIntVector; begin -ConstructRects(FButtonRect, FDropdownRect); -{$IFDEF EnhancedRecordSupport} -RectVector:=T2DIntVector.Create(FRect.Left, FRect.Top); -{$ELSE} -RectVector.Create(FRect.Left, FRect.Top); -{$ENDIF} -FButtonRect:=FButtonRect + RectVector; -FDropdownRect:=FDropdownRect + RectVector; + ConstructRects(FButtonRect, FDropdownRect); + {$IFDEF EnhancedRecordSupport} + RectVector := T2DIntVector.Create(FRect.Left, FRect.Top); + {$ELSE} + RectVector.Create(FRect.Left, FRect.Top); + {$ENDIF} + FButtonRect := FButtonRect + RectVector; + FDropdownRect := FDropdownRect + RectVector; end; -procedure TSpkSmallButton.ConstructRects(var BtnRect, DropRect: T2DIntRect); +procedure TSpkSmallButton.ConstructRects(out BtnRect, DropRect: T2DIntRect); var BtnWidth : integer; DropdownWidth: Integer; @@ -1806,469 +1268,389 @@ end; constructor TSpkSmallButton.Create(AOwner: TComponent); begin inherited Create(AOwner); - FImageIndex:=-1; - FTableBehaviour:=tbContinuesRow; - FGroupBehaviour:=gbSingleItem; - FHideFrameWhenIdle:=false; - FShowCaption:=true; + FImageIndex := -1; + FTableBehaviour := tbContinuesRow; + FGroupBehaviour := gbSingleItem; + FHideFrameWhenIdle := false; + FShowCaption := true; end; procedure TSpkSmallButton.Draw(ABuffer: TBitmap; ClipRect: T2DIntRect); var - FontColor: TColor; + fontColor: TColor; x: Integer; y: Integer; + cornerRadius: Integer; + imgList: TImageList; begin -if FToolbarDispatch=nil then - exit; -if FAppearance=nil then - exit; + if FToolbarDispatch = nil then + exit; + if FAppearance = nil then + exit; -if (FRect.width < 2*LargeButtonRadius) or (FRect.Height < 2*LargeButtonRadius) then - exit; + if (FRect.Width < 2*SmallButtonRadius) or (FRect.Height < 2*SmallButtonRadius) then + exit; -// *** Przycisk *** + case FAppearance.Element.Style of + esRounded: + cornerRadius := SmallButtonRadius; + esRectangle: + cornerRadius := 0; + end; -// T³o i ramka -{$REGION 'Rysowanie przycisku'} -if (FButtonState = bsIdle) and (not(FHideFrameWhenIdle)) then - begin - with FAppearance.Element do - TButtonTools.DrawButton(ABuffer, - FButtonRect, - IdleFrameColor, - IdleInnerLightColor, - IdleInnerDarkColor, - IdleGradientFromColor, - IdleGradientToColor, - IdleGradientType, - (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]), - (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown), - false, - false, - SmallButtonRadius, - ClipRect); - end else -if (FButtonState=bsBtnHottrack) then - begin - with FAppearance.Element do - TButtonTools.DrawButton(ABuffer, - FButtonRect, - HotTrackFrameColor, - HotTrackInnerLightColor, - HotTrackInnerDarkColor, - HotTrackGradientFromColor, - HotTrackGradientToColor, - HotTrackGradientType, - (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]), - (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown), - false, - false, - SmallButtonRadius, - ClipRect); - end else -if (FButtonState = bsBtnPressed) then - begin - with FAppearance.Element do - TButtonTools.DrawButton(ABuffer, - FButtonRect, - ActiveFrameColor, - ActiveInnerLightColor, - ActiveInnerDarkColor, - ActiveGradientFromColor, - ActiveGradientToColor, - ActiveGradientType, - (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]), - (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown), - false, - false, - SmallButtonRadius, - ClipRect); - end else -if (FButtonState in [bsDropdownHottrack, bsDropdownPressed]) then - begin - with FAppearance.Element do - TButtonTools.DrawButton(ABuffer, - FButtonRect, - TColorTools.Brighten(HotTrackFrameColor,40), - TColorTools.Brighten(HotTrackInnerLightColor,40), - TColorTools.Brighten(HotTrackInnerDarkColor,40), - TColorTools.Brighten(HotTrackGradientFromColor,40), - TColorTools.Brighten(HotTrackGradientToColor,40), - HotTrackGradientType, - (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]), - (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown), - false, - false, - SmallButtonRadius, - ClipRect); + fontColor := clNone; + case FButtonState of + bsIdle: + fontColor := FAppearance.Element.IdleCaptionColor; + bsBtnHottrack, + bsDropdownHottrack: + fontColor := FAppearance.Element.HotTrackCaptionColor; + bsBtnPressed, + bsDropdownPressed: + fontColor := FAppearance.ELement.ActiveCaptionColor; + end; + if not FEnabled then + fontColor := TColorTools.ColorToGrayscale(fontColor); + + // *** Przycisk *** + + // T³o i ramka + + {$REGION 'Rysowanie przycisku'} + if (FButtonState = bsIdle) and (not(FHideFrameWhenIdle)) then + begin + with FAppearance.Element do + TButtonTools.DrawButton( + ABuffer, + FButtonRect, + IdleFrameColor, + IdleInnerLightColor, + IdleInnerDarkColor, + IdleGradientFromColor, + IdleGradientToColor, + IdleGradientType, + (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]), + (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown), + false, + false, + cornerRadius, + ClipRect + ); + end + else if (FButtonState = bsBtnHottrack) then + begin + with FAppearance.Element do + TButtonTools.DrawButton( + ABuffer, + FButtonRect, + HotTrackFrameColor, + HotTrackInnerLightColor, + HotTrackInnerDarkColor, + HotTrackGradientFromColor, + HotTrackGradientToColor, + HotTrackGradientType, + (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]), + (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown), + false, + false, + cornerRadius, + ClipRect + ); + end else + if (FButtonState = bsBtnPressed) then + begin + with FAppearance.Element do + TButtonTools.DrawButton(ABuffer, + FButtonRect, + ActiveFrameColor, + ActiveInnerLightColor, + ActiveInnerDarkColor, + ActiveGradientFromColor, + ActiveGradientToColor, + ActiveGradientType, + (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]), + (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown), + false, + false, + cornerRadius, + ClipRect + ); + end else + if (FButtonState in [bsDropdownHotTrack, bsDropdownPressed]) then + begin + with FAppearance.Element do + TButtonTools.DrawButton( + ABuffer, + FButtonRect, + TColorTools.Brighten(HotTrackFrameColor, 40), + TColorTools.Brighten(HotTrackInnerLightColor, 40), + TColorTools.Brighten(HotTrackInnerDarkColor, 40), + TColorTools.Brighten(HotTrackGradientFromColor, 40), + TColorTools.Brighten(HotTrackGradientToColor, 40), + HotTrackGradientType, + (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]), + (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown), + false, + false, + cornerRadius, + ClipRect + ); end; -{$ENDREGION} + {$ENDREGION} -// Ikona -if not(FEnabled) then - begin - {$REGION 'Ikona wy³¹czona'} - if (FImageIndex>=0) and - (FDisabledImages<>nil) and - (FImageIndex nil) then + imgList := FDisabledImages + else + imgList := FImages; - TGuiTools.DrawImage(ABuffer.Canvas, - FDisabledImages, - FImageIndex, - {$IFDEF EnhancedRecordSupport} - T2DIntPoint.Create(x, y), - {$ELSE} - Create2DIntPoint(x, y), - {$ENDIF} - ClipRect); - end else - if (FImageIndex>=0) and - (FImages<>nil) and - (FImageIndex nil) and (FImageIndex >= 0) and (FImageIndex < imgList.Count) then + begin + if (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]) then + x := FButtonRect.Left + SmallButtonHalfBorderWidth + SmallButtonPadding + else + x := FButtonRect.Left + SmallButtonBorderWidth + SmallButtonPadding; + y := FButtonRect.top + (FButtonRect.height - imgList.Height) div 2; - TGuiTools.DrawDisabledImage(ABuffer.Canvas, - FImages, - FImageIndex, - {$IFDEF EnhancedRecordSupport} - T2DIntPoint.Create(x, y), - {$ELSE} - Create2DIntPoint(x, y), - {$ENDIF} - ClipRect); - end; - {$ENDREGION} - end -else - begin - {$REGION 'Ikona zwyk³a'} - if (FImageIndex>=0) and - (FImages<>nil) and - (FImageIndex -1 then + x := x + 2 * SmallButtonPadding + SmallButtonGlyphWidth + else + x := x + SmallButtonPadding; + y := FButtonRect.Top + (FButtonRect.Height - ABuffer.Canvas.TextHeight('Wy')) div 2; - if (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]) then - x:=FButtonRect.Left + SmallButtonHalfBorderWidth else - x:=FButtonRect.Left + SmallButtonBorderWidth; + TGUITools.DrawText(ABuffer.Canvas, x, y, FCaption, fontColor, ClipRect); + end; - if FImageIndex<>-1 then - x:=x + 2 * SmallButtonPadding + SmallButtonGlyphWidth else - x:=x + SmallButtonPadding; - y:=FButtonRect.Top + (FButtonRect.Height - ABuffer.Canvas.TextHeight('Wy')) div 2; - - TGUITools.DrawText(ABuffer.Canvas, - x, - y, - FCaption, - FontColor, - ClipRect); - end; - -// *** Dropdown *** -if FButtonKind = bkButton then - begin - // Nic dodatkowego do rysowania - end else -if FButtonKind = bkButtonDropdown then - begin - // T³o i ramka - {$REGION 'Rysowanie dropdowna'} - if (FButtonState = bsIdle) and (not(FHideFrameWhenIdle)) then - begin + // Dropdown + if FButtonKind = bkButton then + begin + // Nic dodatkowego do rysowania + end else + if FButtonKind = bkButtonDropdown then + begin + // T³o i ramka + {$REGION 'Rysowanie dropdowna'} + if (FButtonState = bsIdle) and (not FHideFrameWhenIdle) then + begin with FAppearance.Element do - TButtonTools.DrawButton(ABuffer, - FDropdownRect, - IdleFrameColor, - IdleInnerLightColor, - IdleInnerDarkColor, - IdleGradientFromColor, - IdleGradientToColor, - IdleGradientType, - true, - (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]), - false, - false, - SmallButtonRadius, - ClipRect); - end else - if (FButtonState in [bsBtnHottrack, bsBtnPressed]) then - begin + TButtonTools.DrawButton( + ABuffer, + FDropdownRect, + IdleFrameColor, + IdleInnerLightColor, + IdleInnerDarkColor, + IdleGradientFromColor, + IdleGradientToColor, + IdleGradientType, + true, + (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]), + false, + false, + cornerRadius, + ClipRect + ); + end else + if (FButtonState in [bsBtnHotTrack, bsBtnPressed]) then + begin with FAppearance.Element do - TButtonTools.DrawButton(ABuffer, - FDropdownRect, - TColorTools.Brighten(HottrackFrameColor, 40), - TColorTools.Brighten(HottrackInnerLightColor, 40), - TColorTools.Brighten(HottrackInnerDarkColor, 40), - TColorTools.Brighten(HottrackGradientFromColor, 40), - TColorTools.Brighten(HottrackGradientToColor, 40), - HottrackGradientType, - true, - (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]), - false, - false, - SmallButtonRadius, - ClipRect); - - end else - if (FButtonState = bsDropdownHottrack) then - begin + TButtonTools.DrawButton( + ABuffer, + FDropdownRect, + TColorTools.Brighten(HotTrackFrameColor, 40), + TColorTools.Brighten(HotTrackInnerLightColor, 40), + TColorTools.Brighten(HotTrackInnerDarkColor, 40), + TColorTools.Brighten(HotTrackGradientFromColor, 40), + TColorTools.Brighten(HotTrackGradientToColor, 40), + HotTrackGradientType, + true, + (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]), + false, + false, + cornerRadius, + ClipRect + ); + end else + if (FButtonState = bsDropdownHottrack) then + begin with FAppearance.Element do - TButtonTools.DrawButton(ABuffer, - FDropdownRect, - HottrackFrameColor, - HottrackInnerLightColor, - HottrackInnerDarkColor, - HottrackGradientFromColor, - HottrackGradientToColor, - HottrackGradientType, - true, - (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]), - false, - false, - SmallButtonRadius, - ClipRect); - end else - if (FButtonState = bsDropdownPressed) then - begin + TButtonTools.DrawButton( + ABuffer, + FDropdownRect, + HotTrackFrameColor, + HotTrackInnerLightColor, + HotTrackInnerDarkColor, + HotTrackGradientFromColor, + HotTrackGradientToColor, + HotTrackGradientType, + true, + (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]), + false, + false, + cornerRadius, + ClipRect + ); + end else + if (FButtonState = bsDropdownPressed) then + begin with FAppearance.Element do - TButtonTools.DrawButton(ABuffer, - FDropdownRect, - ActiveFrameColor, - ActiveInnerLightColor, - ActiveInnerDarkColor, - ActiveGradientFromColor, - ActiveGradientToColor, - ActiveGradientType, - true, - (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]), - false, - false, - SmallButtonRadius, - ClipRect); - end; + TButtonTools.DrawButton( + ABuffer, + FDropdownRect, + ActiveFrameColor, + ActiveInnerLightColor, + ActiveInnerDarkColor, + ActiveGradientFromColor, + ActiveGradientToColor, + ActiveGradientType, + true, + (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]), + false, + false, + cornerRadius, + ClipRect + ); + end; - // Chevron - if not(FEnabled) then - begin - FontColor:=clNone; - case FButtonState of - bsIdle: FontColor:=TColorTools.ColorToGrayscale(FAppearance.Element.IdleCaptionColor); - bsBtnHottrack, - bsDropdownHottrack : FontColor:=TColorTools.ColorToGrayscale(FAppearance.Element.HotTrackCaptionColor); - bsBtnPressed, - bsDropdownPressed: FontColor:=TColorTools.ColorToGrayscale(FAppearance.ELement.ActiveCaptionColor); - end; - end - else - begin - FontColor:=clNone; - case FButtonState of - bsIdle: FontColor:=FAppearance.Element.IdleCaptionColor; - bsBtnHottrack, - bsDropdownHottrack : FontColor:=FAppearance.Element.HotTrackCaptionColor; - bsBtnPressed, - bsDropdownPressed: FontColor:=FAppearance.ELement.ActiveCaptionColor; - end; - end; + // Chevron + // to do: what if font 'Marlett' does not exist? + ABuffer.Canvas.Font.Charset := DEFAULT_CHARSET; + ABuffer.Canvas.Font.Name := 'Marlett'; + ABuffer.Canvas.Font.Style := []; + ABuffer.Canvas.Font.Orientation := 0; - ABuffer.Canvas.Font.Charset:=DEFAULT_CHARSET; - ABuffer.Canvas.Font.Name:='Marlett'; - ABuffer.Canvas.Font.Size:=8; - ABuffer.Canvas.Font.Style:=[]; - ABuffer.Canvas.Font.Orientation:=0; + if FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup] then + x := FDropdownRect.Right - SmallButtonHalfBorderWidth - (SmallButtonDropdownWidth + ABuffer.Canvas.Textwidth('u')) div 2 + 1 + else + x := FDropdownRect.Right - SmallButtonBorderWidth - (SmallButtonDropdownWidth + ABuffer.Canvas.Textwidth('u')) div 2 + 1; + y := FDropdownRect.top + (FDropdownRect.Height - ABuffer.Canvas.Textheight('u')) div 2; + TGUITools.DrawText(ABuffer.Canvas, x, y, 'u', fontColor, ClipRect); + {$ENDREGION} + end else + if FButtonKind = bkDropdown then + begin + // Chevron dropdown + // to do: what if font 'Marlett' does not exist? + ABuffer.Canvas.Font.Charset := DEFAULT_CHARSET; + ABuffer.Canvas.Font.Name := 'Marlett'; + ABuffer.Canvas.Font.Style := []; + ABuffer.Canvas.Font.Orientation := 0; - if FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup] then - x:=FDropdownRect.Right - SmallButtonHalfBorderWidth - (SmallButtonDropdownWidth + ABuffer.Canvas.Textwidth('u')) div 2 + 1 else - x:=FDropdownRect.Right - SmallButtonBorderWidth - (SmallButtonDropdownWidth + ABuffer.Canvas.Textwidth('u')) div 2 + 1; - y:=FDropdownRect.top + (FDropdownRect.height - ABuffer.Canvas.Textheight('u')) div 2; - TGUITools.DrawText(ABuffer.Canvas, x, y, 'u', FontColor, ClipRect); - {$ENDREGION} - end else -if FButtonKind = bkDropdown then - begin - // Chevron dropdown - - if not(FEnabled) then - begin - FontColor:=clNone; - case FButtonState of - bsIdle: FontColor:=TColorTools.ColorToGrayscale(FAppearance.Element.IdleCaptionColor); - bsBtnHottrack, - bsDropdownHottrack : FontColor:=TColorTools.ColorToGrayscale(FAppearance.Element.HotTrackCaptionColor); - bsBtnPressed, - bsDropdownPressed: FontColor:=TColorTools.ColorToGrayscale(FAppearance.ELement.ActiveCaptionColor); - end; - end - else - begin - FontColor:=clNone; - case FButtonState of - bsIdle: FontColor:=FAppearance.Element.IdleCaptionColor; - bsBtnHottrack, - bsDropdownHottrack : FontColor:=FAppearance.Element.HotTrackCaptionColor; - bsBtnPressed, - bsDropdownPressed: FontColor:=FAppearance.ELement.ActiveCaptionColor; - end; - end; - - ABuffer.Canvas.Font.Charset:=DEFAULT_CHARSET; - ABuffer.Canvas.Font.Name:='Marlett'; - ABuffer.Canvas.Font.Size:=8; - ABuffer.Canvas.Font.Style:=[]; - ABuffer.Canvas.Font.Orientation:=0; - - if FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup] then - x:=FButtonRect.Right - SmallButtonHalfBorderWidth - (SmallButtonDropdownWidth + ABuffer.Canvas.Textwidth('u')) div 2 + 1 else - x:=FButtonRect.Right - SmallButtonBorderWidth - (SmallButtonDropdownWidth + ABuffer.Canvas.Textwidth('u')) div 2 + 1; - y:=FButtonRect.top + (FButtonRect.height - ABuffer.Canvas.Textheight('u')) div 2; - TGUITools.DrawText(ABuffer.Canvas, x, y, 'u', FontColor, ClipRect); - end; - -{$ENDREGION} + if FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup] then + x := FButtonRect.Right - SmallButtonHalfBorderWidth - (SmallButtonDropdownWidth + ABuffer.Canvas.Textwidth('u')) div 2 + 1 + else + x := FButtonRect.Right - SmallButtonBorderWidth - (SmallButtonDropdownWidth + ABuffer.Canvas.Textwidth('u')) div 2 + 1; + y := FButtonRect.top + (FButtonRect.height - ABuffer.Canvas.Textheight('u')) div 2; + TGUITools.DrawText(ABuffer.Canvas, x, y, 'u', fontColor, ClipRect); + end; + {$ENDREGION} end; function TSpkSmallButton.GetDropdownPoint: T2DIntPoint; begin -{$IFDEF EnhancedRecordSupport} -if FButtonKind in [bkButtonDropdown, bkDropdown] then - result:=T2DIntPoint.Create(FButtonRect.left, FButtonRect.bottom+1) else - result:=T2DIntPoint.Create(0,0); -{$ELSE} -if FButtonKind in [bkButtonDropdown, bkDropdown] then - result.Create(FButtonRect.left, FButtonRect.bottom+1) else - result.Create(0,0); -{$ENDIF} + {$IFDEF EnhancedRecordSupport} + if FButtonKind in [bkButtonDropdown, bkDropdown] then + Result := T2DIntPoint.Create(FButtonRect.Left, FButtonRect.Bottom+1) + else + Result := T2DIntPoint.Create(0,0); + {$ELSE} + if FButtonKind in [bkButtonDropdown, bkDropdown] then + Result.Create(FButtonRect.Left, FButtonRect.Bottom+1) + else + Result.Create(0,0); + {$ENDIF} end; function TSpkSmallButton.GetGroupBehaviour: TSpkItemGroupBehaviour; begin - result:=FGroupBehaviour; + Result := FGroupBehaviour; end; function TSpkSmallButton.GetSize: TSpkItemSize; begin - result:=isNormal; + Result := isNormal; end; function TSpkSmallButton.GetTableBehaviour: TSpkItemTableBehaviour; begin - result:=FTableBehaviour; + Result := FTableBehaviour; end; function TSpkSmallButton.GetWidth: integer; - -var BtnRect, DropRect : T2DIntRect; - +var + BtnRect, DropRect: T2DIntRect; begin -result:=-1; + Result := -1; -if FToolbarDispatch=nil then - exit; -if FAppearance=nil then - exit; + if FToolbarDispatch = nil then + exit; + if FAppearance = nil then + exit; -ConstructRects(BtnRect, DropRect); + ConstructRects(BtnRect, DropRect); -if FButtonKind = bkButtonDropdown then - result:=DropRect.Right+1 else - result:=BtnRect.Right+1; + if FButtonKind = bkButtonDropdown then + Result := DropRect.Right+1 + else + Result := BtnRect.Right+1; end; -procedure TSpkSmallButton.SetGroupBehaviour( - const Value: TSpkItemGroupBehaviour); +procedure TSpkSmallButton.SetGroupBehaviour(const Value: TSpkItemGroupBehaviour); begin FGroupBehaviour := Value; - - if assigned(FToolbarDispatch) then - FToolbarDispatch.NotifyMetricsChanged; + if Assigned(FToolbarDispatch) then + FToolbarDispatch.NotifyMetricsChanged; end; procedure TSpkSmallButton.SetHideFrameWhenIdle(const Value: boolean); begin FHideFrameWhenIdle := Value; - - if assigned(FToolbarDispatch) then - FToolbarDispatch.NotifyVisualsChanged; + if Assigned(FToolbarDispatch) then + FToolbarDispatch.NotifyVisualsChanged; end; procedure TSpkSmallButton.SetImageIndex(const Value: TImageIndex); begin FImageIndex:=Value; - - if assigned(FToolbarDispatch) then - FToolbarDispatch.NotifyMetricsChanged; + if Assigned(FToolbarDispatch) then + FToolbarDispatch.NotifyMetricsChanged; end; procedure TSpkSmallButton.SetShowCaption(const Value: boolean); begin FShowCaption := Value; - - if assigned(FToolbarDispatch) then - FToolbarDispatch.NotifyMetricsChanged; + if Assigned(FToolbarDispatch) then + FToolbarDispatch.NotifyMetricsChanged; end; -procedure TSpkSmallButton.SetTableBehaviour( - const Value: TSpkItemTableBehaviour); +procedure TSpkSmallButton.SetTableBehaviour(const Value: TSpkItemTableBehaviour); begin FTableBehaviour := Value; - - if assigned(FToolbarDispatch) then - FToolbarDispatch.NotifyMetricsChanged; + if Assigned(FToolbarDispatch) then + FToolbarDispatch.NotifyMetricsChanged; end; diff --git a/components/spktoolbar/SpkToolbar/spkt_Const.pas b/components/spktoolbar/SpkToolbar/spkt_Const.pas index 841bd7ae8..2e02dbdc7 100644 --- a/components/spktoolbar/SpkToolbar/spkt_Const.pas +++ b/components/spktoolbar/SpkToolbar/spkt_Const.pas @@ -355,7 +355,7 @@ begin if ToDPI = 0 then ToDPI := ScreenInfo.PixelsPerInchX; - if not(DPI_AWARE) or (ToDPI = FromDPI) then + if (not DPI_AWARE) or (ToDPI = FromDPI) then Result := Size else begin @@ -372,7 +372,7 @@ begin if ToDPI = 0 then ToDPI := ScreenInfo.PixelsPerInchY; - if not(DPI_AWARE) or (ToDPI = FromDPI) then + if (not DPI_AWARE) or (ToDPI = FromDPI) then Result := Size else begin diff --git a/components/spktoolbar/SpkToolbar/spkt_Tools.pas b/components/spktoolbar/SpkToolbar/spkt_Tools.pas index 9a687c87b..291566c38 100644 --- a/components/spktoolbar/SpkToolbar/spkt_Tools.pas +++ b/components/spktoolbar/SpkToolbar/spkt_Tools.pas @@ -22,20 +22,20 @@ type TButtonTools = class sealed(TObject) private protected public - class procedure DrawButton(Bitmap : TBitmap; - Rect : T2DIntRect; + class procedure DrawButton(Bitmap: TBitmap; + Rect: T2DIntRect; FrameColor, InnerLightColor, InnerDarkColor, GradientFrom, - GradientTo : TColor; - GradientKind : TBackgroundKind; + GradientTo: TColor; + GradientKind: TBackgroundKind; LeftEdgeOpen, RightEdgeOpen, TopEdgeOpen, - BottomEdgeOpen : boolean; - Radius : integer; - ClipRect : T2DIntRect); + BottomEdgeOpen: boolean; + Radius: integer; + ClipRect: T2DIntRect); end; implementation @@ -48,184 +48,206 @@ class procedure TButtonTools.DrawButton(Bitmap: TBitmap; RightEdgeOpen, TopEdgeOpen, BottomEdgeOpen: boolean; Radius: integer; ClipRect : T2DIntRect); -var x1, x2, y1, y2 : integer; - LeftClosed, TopClosed, RightClosed, BottomClosed : byte; - +var + x1, x2, y1, y2: integer; + LeftClosed, TopClosed, RightClosed, BottomClosed: byte; begin -if (Rect.Width<6) or (Rect.Height<6) or - (Rect.Width < 2*radius) or (Rect.Height < 2*Radius) then - exit; + if (Rect.Width <6 ) or (Rect.Height < 6) or + (Rect.Width < 2*Radius) or (Rect.Height < 2*Radius) then exit; -if LeftEdgeOpen then LeftClosed:=0 else LeftClosed:=1; -if RightEdgeOpen then RightClosed:=0 else RightClosed:=1; -if TopEdgeOpen then TopClosed:=0 else TopClosed:=1; -if BottomEdgeOpen then BottomClosed:=0 else BottomClosed:=1; + if LeftEdgeOpen then LeftClosed := 0 else LeftClosed := 1; + if RightEdgeOpen then RightClosed := 0 else RightClosed := 1; + if TopEdgeOpen then TopClosed := 0 else TopClosed := 1; + if BottomEdgeOpen then BottomClosed := 0 else BottomClosed := 1; -TGuiTools.DrawRoundRect(Bitmap.Canvas, - Rect, - Radius, - GradientFrom, - GradientTo, - GradientKind, - ClipRect, - not(LeftEdgeOpen or TopEdgeOpen), - not(RightEdgeOpen or TopEdgeOpen), - not(LeftEdgeOpen or BottomEdgeOpen), - not(RightEdgeOpen or BottomEdgeOpen)); + TGuiTools.DrawRoundRect( + Bitmap.Canvas, + Rect, + Radius, + GradientFrom, + GradientTo, + GradientKind, + ClipRect, + not (LeftEdgeOpen or TopEdgeOpen), + not (RightEdgeOpen or TopEdgeOpen), + not (LeftEdgeOpen or BottomEdgeOpen), + not (RightEdgeOpen or BottomEdgeOpen) + ); -// Wewnêtrzna krawêdŸ -// *** Góra *** -x1:=Rect.Left + radius * TopClosed * LeftClosed + LeftClosed; -x2:=Rect.Right - radius * TopClosed * RightClosed - RightClosed; -y1:=Rect.Top + TopClosed; -TGuiTools.DrawHLine(Bitmap, x1, x2, y1, InnerLightColor, ClipRect); + // Wewnêtrzna krawêdŸ + // *** Góra *** + x1 := Rect.Left + radius * TopClosed * LeftClosed + LeftClosed; + x2 := Rect.Right - radius * TopClosed * RightClosed - RightClosed; + y1 := Rect.Top + TopClosed; + TGuiTools.DrawHLine(Bitmap, x1, x2, y1, InnerLightColor, ClipRect); -// *** Dó³ *** -x1:=Rect.Left + radius * BottomClosed * LeftClosed + LeftClosed; -x2:=Rect.Right - radius * BottomClosed * RightClosed - RightClosed; -y1:=Rect.Bottom - BottomClosed; -if BottomEdgeOpen then - TGuiTools.DrawHLine(Bitmap, x1, x2, y1, InnerDarkColor, ClipRect) else - TGuiTools.DrawHLine(Bitmap, x1, x2, y1, InnerLightColor, ClipRect); + // *** Dó³ *** + x1 := Rect.Left + radius * BottomClosed * LeftClosed + LeftClosed; + x2 := Rect.Right - radius * BottomClosed * RightClosed - RightClosed; + y1 := Rect.Bottom - BottomClosed; + if BottomEdgeOpen then + TGuiTools.DrawHLine(Bitmap, x1, x2, y1, InnerDarkColor, ClipRect) + else + TGuiTools.DrawHLine(Bitmap, x1, x2, y1, InnerLightColor, ClipRect); -// *** Lewo *** -y1:=Rect.Top + Radius * LeftClosed * TopClosed + TopClosed; -y2:=Rect.Bottom - Radius * LeftClosed * BottomClosed - BottomClosed; -x1:=Rect.Left + LeftClosed; -TGuiTools.DrawVLine(Bitmap, x1, y1, y2, InnerLightColor, ClipRect); + // *** Lewo *** + y1 := Rect.Top + Radius * LeftClosed * TopClosed + TopClosed; + y2 := Rect.Bottom - Radius * LeftClosed * BottomClosed - BottomClosed; + x1 := Rect.Left + LeftClosed; + TGuiTools.DrawVLine(Bitmap, x1, y1, y2, InnerLightColor, ClipRect); -// *** Prawo *** -y1:=Rect.Top + Radius * RightClosed * TopClosed + TopClosed; -y2:=Rect.Bottom - Radius * RightClosed * BottomClosed - BottomClosed; -x1:=Rect.Right - RightClosed; -if RightEdgeOpen then - TGuiTools.DrawVLine(Bitmap, x1, y1, y2, InnerDarkColor, ClipRect) else - TGuiTools.DrawVLine(Bitmap, x1, y1, y2, InnerLightColor, ClipRect); + // *** Prawo *** + y1 := Rect.Top + Radius * RightClosed * TopClosed + TopClosed; + y2 := Rect.Bottom - Radius * RightClosed * BottomClosed - BottomClosed; + x1 := Rect.Right - RightClosed; + if RightEdgeOpen then + TGuiTools.DrawVLine(Bitmap, x1, y1, y2, InnerDarkColor, ClipRect) + else + TGuiTools.DrawVLine(Bitmap, x1, y1, y2, InnerLightColor, ClipRect); -// Zaokr¹glone naro¿niki -if not(LeftEdgeOpen or TopEdgeOpen) then - TGuiTools.DrawAARoundCorner(Bitmap, - {$IFDEF EnhancedRecordSupport} - T2DIntPoint.create(Rect.left + 1, Rect.Top + 1), - {$ELSE} - Create2DIntPoint(Rect.left + 1, Rect.Top + 1), - {$ENDIF} - Radius, - cpLeftTop, - InnerLightColor, - ClipRect); -if not(RightEdgeOpen or TopEdgeOpen) then - TGuiTools.DrawAARoundCorner(Bitmap, - {$IFDEF EnhancedRecordSupport} - T2DIntPoint.create(Rect.right - radius, Rect.Top + 1), - {$ELSE} - Create2DIntPoint(Rect.right - radius, Rect.Top + 1), - {$ENDIF} - Radius, - cpRightTop, - InnerLightColor, - ClipRect); -if not(LeftEdgeOpen or BottomEdgeOpen) then - TGuiTools.DrawAARoundCorner(Bitmap, - {$IFDEF EnhancedRecordSupport} - T2DIntPoint.create(Rect.left + 1, Rect.bottom - radius), - {$ELSE} - Create2DIntPoint(Rect.left + 1, Rect.bottom - radius), - {$ENDIF} - Radius, - cpLeftBottom, - InnerLightColor, - ClipRect); -if not(RightEdgeOpen or BottomEdgeOpen) then - TGuiTools.DrawAARoundCorner(Bitmap, - {$IFDEF EnhancedRecordSupport} - T2DIntPoint.create(Rect.right - radius, Rect.bottom - radius), - {$ELSE} - Create2DIntPoint(Rect.right - radius, Rect.bottom - radius), - {$ENDIF} - Radius, - cpRightBottom, - InnerLightColor, - ClipRect); + // Zaokr¹glone naro¿niki + if not(LeftEdgeOpen or TopEdgeOpen) then + TGuiTools.DrawAARoundCorner( + Bitmap, + {$IFDEF EnhancedRecordSupport} + T2DIntPoint.create(Rect.left + 1, Rect.Top + 1), + {$ELSE} + Create2DIntPoint(Rect.left + 1, Rect.Top + 1), + {$ENDIF} + Radius, + cpLeftTop, + InnerLightColor, + ClipRect + ); + if not(RightEdgeOpen or TopEdgeOpen) then + TGuiTools.DrawAARoundCorner( + Bitmap, + {$IFDEF EnhancedRecordSupport} + T2DIntPoint.Create(Rect.right - radius, Rect.Top + 1), + {$ELSE} + Create2DIntPoint(Rect.right - radius, Rect.Top + 1), + {$ENDIF} + Radius, + cpRightTop, + InnerLightColor, + ClipRect + ); + if not(LeftEdgeOpen or BottomEdgeOpen) then + TGuiTools.DrawAARoundCorner( + Bitmap, + {$IFDEF EnhancedRecordSupport} + T2DIntPoint.create(Rect.left + 1, Rect.bottom - Radius), + {$ELSE} + Create2DIntPoint(Rect.left + 1, Rect.bottom - Radius), + {$ENDIF} + Radius, + cpLeftBottom, + InnerLightColor, + ClipRect + ); + if not(RightEdgeOpen or BottomEdgeOpen) then + TGuiTools.DrawAARoundCorner( + Bitmap, + {$IFDEF EnhancedRecordSupport} + T2DIntPoint.create(Rect.right - Radius, Rect.bottom - Radius), + {$ELSE} + Create2DIntPoint(Rect.right - Radius, Rect.bottom - Radius), + {$ENDIF} + Radius, + cpRightBottom, + InnerLightColor, + ClipRect + ); -// Zewnêtrzna krawêdŸ -// Zaokr¹glone naro¿niki -if not(TopEdgeOpen) then - begin - x1:=Rect.Left + Radius * LeftClosed; - x2:=Rect.Right - Radius * RightClosed; - y1:=Rect.Top; - TGuiTools.DrawHLine(Bitmap, x1, x2, y1, FrameColor, ClipRect); - end; + // Zewnêtrzna krawêdŸ + // Zaokr¹glone naro¿niki + if not TopEdgeOpen then + begin + x1 := Rect.Left + Radius * LeftClosed; + x2 := Rect.Right - Radius * RightClosed; + y1 := Rect.Top; + TGuiTools.DrawHLine(Bitmap, x1, x2, y1, FrameColor, ClipRect); + end; -if not(BottomEdgeOpen) then - begin - x1:=Rect.Left + Radius * LeftClosed; - x2:=Rect.Right - Radius * RightClosed; - y1:=Rect.Bottom; - TGuiTools.DrawHLine(Bitmap, x1, x2, y1, FrameColor, ClipRect); - end; + if not BottomEdgeOpen then + begin + x1 := Rect.Left + Radius * LeftClosed; + x2 := Rect.Right - Radius * RightClosed; + y1 := Rect.Bottom; + TGuiTools.DrawHLine(Bitmap, x1, x2, y1, FrameColor, ClipRect); + end; -if not(LeftEdgeOpen) then - begin - y1:=Rect.Top + Radius * TopClosed; - y2:=Rect.Bottom - Radius * BottomClosed; - x1:=Rect.Left; - TGuiTools.DrawVLine(Bitmap, x1, y1, y2, FrameColor, ClipRect); - end; + if not LeftEdgeOpen then + begin + y1 := Rect.Top + Radius * TopClosed; + y2 := Rect.Bottom - Radius * BottomClosed; + x1 := Rect.Left; + TGuiTools.DrawVLine(Bitmap, x1, y1, y2, FrameColor, ClipRect); + end; -if not(RightEdgeOpen) then - begin - y1:=Rect.Top + Radius * TopClosed; - y2:=Rect.Bottom - Radius * BottomClosed; - x1:=Rect.Right; - TGuiTools.DrawVLine(Bitmap, x1, y1, y2, FrameColor, ClipRect); - end; + if not(RightEdgeOpen) then + begin + y1 := Rect.Top + Radius * TopClosed; + y2 := Rect.Bottom - Radius * BottomClosed; + x1 := Rect.Right; + TGuiTools.DrawVLine(Bitmap, x1, y1, y2, FrameColor, ClipRect); + end; -if not(LeftEdgeOpen or TopEdgeOpen) then - TGuiTools.DrawAARoundCorner(Bitmap, - {$IFDEF EnhancedRecordSupport} - T2DIntPoint.create(Rect.left, Rect.Top), - {$ELSE} - Create2DIntPoint(Rect.left, Rect.Top), - {$ENDIF} - Radius, - cpLeftTop, - FrameColor, - ClipRect); -if not(RightEdgeOpen or TopEdgeOpen) then - TGuiTools.DrawAARoundCorner(Bitmap, - {$IFDEF EnhancedRecordSupport} - T2DIntPoint.create(Rect.right - radius + 1, Rect.Top), - {$ELSE} - Create2DIntPoint(Rect.right - radius + 1, Rect.Top), - {$ENDIF} - Radius, - cpRightTop, - FrameColor, - ClipRect); -if not(LeftEdgeOpen or BottomEdgeOpen) then - TGuiTools.DrawAARoundCorner(Bitmap, - {$IFDEF EnhancedRecordSupport} - T2DIntPoint.create(Rect.left, Rect.bottom - radius + 1), - {$ELSE} - Create2DIntPoint(Rect.left, Rect.bottom - radius + 1), - {$ENDIF} - Radius, - cpLeftBottom, - FrameColor, - ClipRect); -if not(RightEdgeOpen or BottomEdgeOpen) then - TGuiTools.DrawAARoundCorner(Bitmap, - {$IFDEF EnhancedRecordSupport} - T2DIntPoint.create(Rect.right - radius + 1, Rect.bottom - radius + 1), - {$ELSE} - Create2DIntPoint(Rect.right - radius + 1, Rect.bottom - radius + 1), - {$ENDIF} - Radius, - cpRightBottom, - FrameColor, - ClipRect); + if not(LeftEdgeOpen or TopEdgeOpen) then + TGuiTools.DrawAARoundCorner( + Bitmap, + {$IFDEF EnhancedRecordSupport} + T2DIntPoint.create(Rect.left, Rect.Top), + {$ELSE} + Create2DIntPoint(Rect.left, Rect.Top), + {$ENDIF} + Radius, + cpLeftTop, + FrameColor, + ClipRect + ); + + if not(RightEdgeOpen or TopEdgeOpen) then + TGuiTools.DrawAARoundCorner( + Bitmap, + {$IFDEF EnhancedRecordSupport} + T2DIntPoint.create(Rect.right - radius + 1, Rect.Top), + {$ELSE} + Create2DIntPoint(Rect.right - radius + 1, Rect.Top), + {$ENDIF} + Radius, + cpRightTop, + FrameColor, + ClipRect + ); + + if not(LeftEdgeOpen or BottomEdgeOpen) then + TGuiTools.DrawAARoundCorner( + Bitmap, + {$IFDEF EnhancedRecordSupport} + T2DIntPoint.create(Rect.left, Rect.bottom - radius + 1), + {$ELSE} + Create2DIntPoint(Rect.left, Rect.bottom - radius + 1), + {$ENDIF} + Radius, + cpLeftBottom, + FrameColor, + ClipRect + ); + + if not(RightEdgeOpen or BottomEdgeOpen) then + TGuiTools.DrawAARoundCorner( + Bitmap, + {$IFDEF EnhancedRecordSupport} + T2DIntPoint.create(Rect.right - radius + 1, Rect.bottom - radius + 1), + {$ELSE} + Create2DIntPoint(Rect.right - Radius + 1, Rect.bottom - radius + 1), + {$ENDIF} + Radius, + cpRightBottom, + FrameColor, + ClipRect + ); end; end. diff --git a/components/spktoolbar/designtime/spkte_AppearanceEditor.lfm b/components/spktoolbar/designtime/spkte_AppearanceEditor.lfm index 89c33db0a..97715c261 100644 --- a/components/spktoolbar/designtime/spkte_AppearanceEditor.lfm +++ b/components/spktoolbar/designtime/spkte_AppearanceEditor.lfm @@ -1,10 +1,10 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow Left = 617 - Height = 540 + Height = 561 Top = 138 Width = 562 Caption = 'Toolbar appearance editor' - ClientHeight = 540 + ClientHeight = 561 ClientWidth = 562 Color = clBtnFace Font.Color = clWindowText @@ -318,7 +318,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow end object PageControl1: TPageControl Left = 0 - Height = 368 + Height = 389 Top = 132 Width = 562 ActivePage = TabSheet3 @@ -1096,7 +1096,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow end object TabSheet3: TTabSheet Caption = 'Item' - ClientHeight = 340 + ClientHeight = 361 ClientWidth = 554 ImageIndex = 2 object sItemRectangle: TShape @@ -1254,10 +1254,13 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow AnchorSideLeft.Control = pItemIdleInnerLight AnchorSideTop.Control = pItemIdleInnerLight AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = pItemIdleInnerLight + AnchorSideRight.Side = asrBottom Left = 116 Height = 25 Top = 279 - Width = 121 + Width = 100 + Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 20 BorderSpacing.Bottom = 4 BevelInner = bvRaised @@ -1982,6 +1985,42 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow GroupIndex = 1 OnClick = bItemActiveInnerLightColorClick end + object cbItemStyle: TComboBox + AnchorSideLeft.Control = pItemIdleGradientFrom + AnchorSideTop.Control = pItemFont + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = pItemIdleGradientTo + AnchorSideRight.Side = asrBottom + Left = 116 + Height = 23 + Top = 310 + Width = 100 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 6 + ItemHeight = 15 + ItemIndex = 0 + Items.Strings = ( + 'Rounded' + 'Rectangle' + ) + OnChange = cbItemStyleChange + Style = csDropDownList + TabOrder = 23 + Text = 'Rounded' + end + object Label27: TLabel + AnchorSideTop.Control = cbItemStyle + AnchorSideTop.Side = asrCenter + AnchorSideRight.Control = LblInnerLightColor + AnchorSideRight.Side = asrBottom + Left = 71 + Height = 15 + Top = 314 + Width = 25 + Anchors = [akTop, akRight] + Caption = 'Style' + ParentColor = False + end end object TabSheet4: TTabSheet Caption = 'Import / export' @@ -2105,7 +2144,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow object ButtonPanel: TPanel Left = 8 Height = 24 - Top = 508 + Top = 529 Width = 546 Align = alBottom BorderSpacing.Around = 8 @@ -2191,8 +2230,8 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow 'ColorS=F0FBFF' 'ColorT=A4A0A0' ) - left = 216 - top = 464 + left = 280 + top = 512 end object fdFontDialog: TFontDialog Font.Color = clWindowText @@ -2200,18 +2239,18 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow Font.Name = 'Tahoma' MinFontSize = 0 MaxFontSize = 0 - left = 312 - top = 464 + left = 376 + top = 512 end object LargeImages: TImageList Height = 32 Width = 32 - left = 48 - top = 464 + left = 112 + top = 512 end object SmallImages: TImageList - left = 128 - top = 464 + left = 192 + top = 512 Bitmap = { 4C69010000001000000010000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000005BA36C7380C4 diff --git a/components/spktoolbar/designtime/spkte_AppearanceEditor.pas b/components/spktoolbar/designtime/spkte_AppearanceEditor.pas index 8698ee291..aea0a55ce 100644 --- a/components/spktoolbar/designtime/spkte_AppearanceEditor.pas +++ b/components/spktoolbar/designtime/spkte_AppearanceEditor.pas @@ -46,10 +46,12 @@ type bActiveTabHeaderFontColor: TSpeedButton; bExportToPascal: TButton; bCopyToClipboard: TButton; + cbItemStyle: TComboBox; cbPaneStyle: TComboBox; ColorView: TShape; gbPreview: TGroupBox; Label12: TLabel; + Label27: TLabel; LblCaptionBackground1: TLabel; LblRGB: TLabel; SmallImages: TImageList; @@ -195,6 +197,7 @@ type procedure cbItemActiveGradientKindChange(Sender: TObject); procedure cbItemHottrackGradientKindChange(Sender: TObject); procedure cbItemIdleGradientKindChange(Sender: TObject); + procedure cbItemStyleChange(Sender: TObject); procedure cbPaneGradientKindChange(Sender: TObject); procedure cbPaneStyleChange(Sender: TObject); procedure cbTabGradientKindChange(Sender: TObject); @@ -736,6 +739,12 @@ begin SetLinkedGradientKind((Sender as TComboBox).ItemIndex); end; +procedure TfrmAppearanceEditWindow.cbItemStyleChange(Sender: TObject); +begin + with tbPreview.Appearance.Element do + Style := TSpkElementStyle((Sender as TCombobox).ItemIndex); +end; + procedure TfrmAppearanceEditWindow.cbLinkItemClick(Sender: TObject); begin SwitchAttributesLink(cbLinkItem.Checked); @@ -899,6 +908,8 @@ begin SetPanelColor(pItemActiveCaptionColor, ActiveCaptionColor); SetPanelColor(pItemActiveInnerDark, ActiveInnerDarkColor); SetPanelColor(pItemActiveInnerLight, ActiveInnerLightColor); + + cbItemStyle.ItemIndex := ord(Style); end; end; end;