Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uses
- Vcl.RibbonStyleActnCtrls;
- type
- TRibbonGroup = class(Vcl.Ribbon.TRibbonGroup)
- private
- FMouseInControl: Boolean;
- function GetCaptionRect: TRect;
- function GetRibbonStyle: TRibbonStyleActionBars;
- procedure CMMouseEnter(var AMessage: TMessage); message CM_MOUSEENTER;
- procedure CMMouseLeave(var AMessage: TMessage); message CM_MOUSELEAVE;
- protected
- procedure Paint; override;
- end;
- implementation
- { TCustomRibbonGroup }
- function TRibbonGroup.GetCaptionRect: TRect;
- begin
- Result := Rect(1, Height - GetCaptionHeight - 1, Width - 2, Height - 2);
- end;
- function TRibbonGroup.GetRibbonStyle: TRibbonStyleActionBars;
- begin
- if Style is TRibbonStyleActionBars then
- Result := TRibbonStyleActionBars(Style)
- else
- Result := RibbonLunaStyle;
- end;
- procedure TRibbonGroup.CMMouseEnter(var AMessage: TMessage);
- begin
- FMouseInControl := True;
- inherited;
- end;
- procedure TRibbonGroup.CMMouseLeave(var AMessage: TMessage);
- begin
- FMouseInControl := False;
- inherited;
- end;
- procedure TRibbonGroup.Paint;
- var
- LRect: TRect;
- LCaptionRect: TRect;
- LFlags: Cardinal;
- LStyle: TRibbonStyleActionBars;
- begin
- LRect := ClientRect;
- LRect.Left := LRect.Left - 10;
- LRect.Top := LRect.Top - Top;
- LRect.Right := LRect.Right + 10;
- LRect.Bottom := LRect.Top + Parent.Height;
- LStyle := GetRibbonStyle;
- LStyle.DrawElement(srPage, Canvas, LRect, Page.Ribbon.GetRibbonMetric(rmCaption));
- LRect := ClientRect;
- LCaptionRect := GetCaptionRect;
- if not Enabled then
- begin
- LStyle.DrawElement(srgBackgroundDisabled, Canvas, LRect);
- LStyle.DrawElement(srgCaptionDisabled, Canvas, LCaptionRect);
- end
- else if FMouseInControl then
- begin
- LStyle.DrawElement(srgBackgroundHover, Canvas, LRect);
- LStyle.DrawElement(srgCaptionHover, Canvas, LCaptionRect);
- end
- else
- begin
- LStyle.DrawElement(srgBackground, Canvas, LRect);
- LStyle.DrawElement(srgCaption, Canvas, LCaptionRect);
- end;
- // Adjust caption rect for text
- if (DialogAction <> nil) then
- LCaptionRect.Right := LCaptionRect.Right - 15;
- Canvas.Brush.Style := bsClear;
- Canvas.Font.Assign(Font);
- // Canvas.Font.Color := TCustomRibbonColorMap(ColorMap).GroupFontColor; <- this must go away
- LCaptionRect.Left := LCaptionRect.Left + 3;
- LFlags := DT_CENTER or DT_NOPREFIX or DT_SINGLELINE or DT_END_ELLIPSIS or DT_VCENTER;
- DrawText(Canvas.Handle, Caption, -1, LCaptionRect, LFlags);
- if (DialogAction <> nil) then
- DrawShowDialogButton;
- end;
Advertisement
Add Comment
Please, Sign In to add comment