- This topic has 4 replies, 3 voices, and was last updated 9 years, 5 months ago by
Jimy.
-
AuthorPosts
-
May 5, 2011 at 9:11 am #45584
QStorm
ParticipantNo ideas?
I would like to hightlight the selected / focused item using the current Alpha Skin properties.
Thanks 🙂
May 6, 2011 at 9:02 am #45581QStorm
ParticipantHi again,
Does anybody know how to get the styling properties (color, transparence etc.) from the current Alpha Skin?
It's very urgent, I need a solution as soon as possible.
Thanks 🙂
Best regards
QStorm
May 11, 2011 at 6:46 am #45653Support
KeymasterHello and I'm sorry for a delay.
Why you not uses the TsFontComboBox component? Some features are not exists there?
Here is a code of items drawing from TsFontComboBox :
Code:procedure TsFontComboBox.DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState);
var
Bmp, fBmp : TBitmap;
aRect, BRect : TRect;
TmpColor : TColor;
TmpFontClass : TFontClass;
ts : TSize;
sNdx : integer;
CI : TCacheInfo;
DrawStyle : longint;
begin
TmpFontClass := nil;
Bmp := nil;
if (Index >= 0) and (Index < Items.Count) and (Items.Objects[Index] nil) then begin
TmpFontClass := TFontClass(Items.Objects[Index]);
fBmp := FBitmaps[ord(TmpFontClass.FntType)];
fBmp.Transparent := True;
aRect := Classes.Rect(0, 0, fBmp.Height, fBmp.Width);
end
else fBmp := nil;
if SkinData.Skinned then begin
Bmp := CreateBmp32(WidthOf(Rect), HeightOf(Rect));
Bmp.Canvas.Font.Assign(Font);
if odComboBoxEdit in State then CI := MakeCacheInfo(SkinData.FCacheBmp, Rect.Left, Rect.Top) else begin
CI.Bmp := nil;
CI.Ready := False;
CI.FillColor := Color;
end;
if (odSelected in State) then begin
CI.Bmp := nil;
CI.Ready := False;
CI.FillColor := Color;
sNdx := SkinData.SkinManager.GetSkinIndex(s_Selection);
if sNdx < 0
then FillDC(Bmp.Canvas.Handle, Classes.Rect(0, 0, Bmp.Width, Bmp.Height), SkinData.SkinManager.GetHighLightColor(odFocused in State))
else PaintItem(sNdx, s_Selection, CI, True, integer(odFocused in State), Classes.Rect(0, 0, Bmp.Width, Bmp.Height), Point(0, 0), Bmp, SkinData.SkinManager)
end
else begin
sNdx := -1;
if CI.Ready
then BitBlt(Bmp.Canvas.Handle, 0, 0, Bmp.Width, Bmp.Height, CI.Bmp.Canvas.Handle, CI.X, CI.Y, SRCCOPY)
else FillDC(Bmp.Canvas.Handle, Classes.Rect(0, 0, Bmp.Width, Bmp.Height), Color);
end;
if Assigned(TmpFontClass) then begin
brect := classes.Rect(0, 0, Bmp.Height, Bmp.Height);
Bmp.Canvas.Draw(bRect.Left, bRect.Top, fBmp);
aRect.Right := Bmp.Width;
aRect.Left := brect.right;
if DrawFont then Bmp.Canvas.Font.Name := TmpFontClass.FntName;
DrawStyle := DT_NOPREFIX or DT_EXPANDTABS or DT_SINGLELINE or DT_VCENTER or DT_NOCLIP;
InflateRect(aRect, -1, 0);
if sNdx = -1 then begin
if odSelected in State then Bmp.Canvas.Font.Color := SkinData.SkinManager.GetHighLightFontColor(odFocused in State) else begin
if ControlIsActive(SkinData) and (SkinData.SkinManager.gd[SkinData.SkinIndex].States > 1)
then Bmp.Canvas.Font.Color := SkinData.SkinManager.gd[SkinData.SkinIndex].HotFontColor[1]
else Bmp.Canvas.Font.Color := SkinData.SkinManager.gd[SkinData.SkinIndex].FontColor[1];
end;
Bmp.Canvas.Brush.Style := bsClear;
AcDrawText(Bmp.Canvas.Handle, TmpFontClass.FntName, aRect, DrawStyle);
end
else WriteTextEx(Bmp.Canvas, PChar(TmpFontClass.FntName), True, aRect, DrawStyle, sNdx, (odFocused in State), SkinData.SkinManager);
end;
BitBlt(Canvas.Handle, Rect.Left, Rect.Top, Bmp.Width, Bmp.Height, Bmp.Canvas.Handle, 0, 0, SRCCOPY);
FreeAndNil(Bmp);
end
else begin
if odSelected in State then TmpColor := ColorToRGB(clHighLight) else TmpColor := ColorToRGB(Color);
FillDC(Canvas.Handle, Rect, TmpColor);
if Assigned(TmpFontClass) then begin
brect := classes.Rect(rect.left, rect.top, rect.bottom – rect.top + rect.left, rect.bottom);
Canvas.Draw(bRect.Left, bRect.Top, fBmp);
Rect.Left := Rect.Left + brect.right;
if DrawFont then Canvas.Font.Name := TmpFontClass.FntName;
if odSelected in State then Canvas.Font.Color := ColorToRGB(clHighlightText) else Canvas.Font.Color := Font.Color;GetTextExtentPoint32(Canvas.Handle, PChar(TmpFontClass.FntName), Length(TmpFontClass.FntName), ts);
Canvas.Brush.Style := bsClear;
Canvas.TextRect(Rect, Rect.Left + 1, Rect.Top + (HeightOf(Rect) – ts.cy) div 2, TmpFontClass.FntName);
end;
end;
end;November 19, 2015 at 6:17 am #54348Jimy
Participantvery thanks! 😐
-
AuthorPosts
- You must be logged in to reply to this topic.