mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 20:21:04 +02:00
Merged revision(s) 59383 #9ceb5203c9 from trunk:
LCL: wince: partialy fix problem with spacing between glyph and button caption, when glyph is placed left or right to caption. (there is no space between glyph and caption) ........ git-svn-id: branches/fixes_2_0@61652 -
This commit is contained in:
parent
5b1b022b41
commit
36ddc4233b
@ -87,14 +87,10 @@ const
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure DrawBitBtnImage(BitBtn: TCustomBitBtn; DrawStruct: PDrawItemStruct);
|
procedure DrawBitBtnImage(BitBtn: TCustomBitBtn; DrawStruct: PDrawItemStruct);
|
||||||
var
|
var
|
||||||
BitBtnLayout: TButtonLayout; // Layout of button and glyph
|
|
||||||
OldFontHandle: HFONT; // Handle of previous font in hdcNewBitmap
|
|
||||||
TextSize: Windows.SIZE; // For computing the length of button caption in pixels
|
|
||||||
XDestBitmap, YDestBitmap: integer; // X,Y coordinate of destination rectangle for bitmap
|
XDestBitmap, YDestBitmap: integer; // X,Y coordinate of destination rectangle for bitmap
|
||||||
XDestText, YDestText: integer; // X,Y coordinates of destination rectangle for caption
|
XDestText, YDestText: integer; // X,Y coordinates of destination rectangle for caption
|
||||||
newWidth, newHeight: integer; // dimensions of new combined bitmap
|
newWidth, newHeight: integer; // dimensions of new combined bitmap
|
||||||
srcWidth, srcHeight: integer; // width of glyph to use, bitmap may have multiple glyphs
|
srcWidth, srcHeight: integer; // width of glyph to use, bitmap may have multiple glyphs
|
||||||
DrawRect: TRect;
|
|
||||||
ButtonCaption: PWideChar;
|
ButtonCaption: PWideChar;
|
||||||
ButtonState: TButtonState;
|
ButtonState: TButtonState;
|
||||||
AIndex: Integer;
|
AIndex: Integer;
|
||||||
@ -131,6 +127,11 @@ var
|
|||||||
DrawState(DrawStruct^._hDC, 0, nil, LPARAM(ButtonCaption), 0, XDestText, YDestText, 0, 0, TextFlags);
|
DrawState(DrawStruct^._hDC, 0, nil, LPARAM(ButtonCaption), 0, XDestText, YDestText, 0, 0, TextFlags);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
BitBtnLayout: TButtonLayout; // Layout of button and glyph
|
||||||
|
TextSize: Windows.SIZE; // For computing the length of button caption in pixels
|
||||||
|
DrawRect: TRect;
|
||||||
|
ASpacing: integer;
|
||||||
begin
|
begin
|
||||||
DrawRect := DrawStruct^.rcItem;
|
DrawRect := DrawStruct^.rcItem;
|
||||||
|
|
||||||
@ -164,10 +165,14 @@ begin
|
|||||||
srcWidth := 0;
|
srcWidth := 0;
|
||||||
srcHeight := 0;
|
srcHeight := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
ASpacing := BitBtn.Spacing;
|
||||||
|
if (srcWidth = 0) or (srcHeight = 0) then
|
||||||
|
ASpacing := 0;
|
||||||
|
|
||||||
BitBtnLayout := BitBtn.Layout;
|
BitBtnLayout := BitBtn.Layout;
|
||||||
|
|
||||||
OldFontHandle := SelectObject(DrawStruct^._hDC, BitBtn.Font.Reference.Handle);
|
MeasureText(BitBtn, ButtonCaption, TextSize.cx, TextSize.cy);
|
||||||
GetTextExtentPoint32W(DrawStruct^._hDC, ButtonCaption, Length(BitBtn.Caption), TextSize);
|
|
||||||
// calculate size of new bitmap
|
// calculate size of new bitmap
|
||||||
case BitBtnLayout of
|
case BitBtnLayout of
|
||||||
blGlyphLeft, blGlyphRight:
|
blGlyphLeft, blGlyphRight:
|
||||||
@ -175,24 +180,21 @@ begin
|
|||||||
YDestBitmap := (DrawRect.Bottom + DrawRect.Top - srcHeight) div 2;
|
YDestBitmap := (DrawRect.Bottom + DrawRect.Top - srcHeight) div 2;
|
||||||
YDestText := (DrawRect.Bottom + DrawRect.Top - TextSize.cy) div 2;
|
YDestText := (DrawRect.Bottom + DrawRect.Top - TextSize.cy) div 2;
|
||||||
|
|
||||||
newWidth := TextSize.cx + srcWidth;
|
if ASpacing = -1 then
|
||||||
|
ASpacing := (BitBtn.Width - srcWidth - TextSize.cx) div 3;
|
||||||
|
|
||||||
|
newWidth := TextSize.cx + srcWidth + ASpacing;
|
||||||
|
|
||||||
if BitBtn.Spacing <> -1 then
|
|
||||||
newWidth := newWidth + BitBtn.Spacing;
|
|
||||||
|
|
||||||
if srcWidth <> 0 then
|
|
||||||
inc(newWidth, 2);
|
|
||||||
|
|
||||||
case BitBtnLayout of
|
case BitBtnLayout of
|
||||||
blGlyphLeft:
|
blGlyphLeft:
|
||||||
begin
|
begin
|
||||||
XDestBitmap := (DrawRect.Right + DrawRect.Left - newWidth) div 2;
|
XDestBitmap := (DrawRect.Right + DrawRect.Left - newWidth) div 2;
|
||||||
XDestText := XDestBitmap + srcWidth;
|
XDestText := XDestBitmap + srcWidth + ASpacing;
|
||||||
end;
|
end;
|
||||||
blGlyphRight:
|
blGlyphRight:
|
||||||
begin
|
begin
|
||||||
XDestText := (DrawRect.Right + DrawRect.Left - newWidth) div 2;
|
XDestText := (DrawRect.Right + DrawRect.Left - newWidth) div 2;
|
||||||
XDestBitmap := XDestText + TextSize.cx;
|
XDestBitmap := XDestText + TextSize.cx + ASpacing;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -225,8 +227,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
DrawBitmap;
|
DrawBitmap;
|
||||||
|
|
||||||
SelectObject(DrawStruct^._hDC, OldFontHandle);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user