mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 14:59:30 +02:00
Merged revision(s) 62641 #72551f3c1e, 62646 #e51bb976a4 from trunk:
LCL: WinCE: align implementation of TWinCEWSCustomEdit.GetPreferredSize with Win32. Does not use AWinControl.Caption. In WinCE7 GetTextExtentPoint32() for empty string returns 0 height (In WinCE6 returns non-zero height), which causes empty TEdit controls to shrink in height. ........ LCL: WinCE: in WinCE7 TBitBtn changes font when focused. So set font explicitly before painting Caption. Hot fix inspired by Win32 implementation. ........ git-svn-id: branches/fixes_2_0@62824 -
This commit is contained in:
parent
43998ec941
commit
8f5c8b8fae
@ -59,7 +59,8 @@ procedure DrawBitBtnImage(BitBtn: TCustomBitBtn; DrawStruct: PDrawItemStruct);
|
||||
|
||||
implementation
|
||||
|
||||
uses ImgList, WinCEInt, WinCEExtra;
|
||||
uses
|
||||
ImgList, WinCEInt, WinCEExtra;
|
||||
|
||||
type
|
||||
TBitBtnAceess = class(TCustomBitBtn)
|
||||
@ -91,7 +92,6 @@ var
|
||||
XDestText, YDestText: integer; // X,Y coordinates of destination rectangle for caption
|
||||
newWidth, newHeight: integer; // dimensions of new combined bitmap
|
||||
srcWidth, srcHeight: integer; // width of glyph to use, bitmap may have multiple glyphs
|
||||
ButtonCaption: PWideChar;
|
||||
ButtonState: TButtonState;
|
||||
AIndex: Integer;
|
||||
AImageRes: TScaledImageListResolution;
|
||||
@ -100,13 +100,13 @@ var
|
||||
procedure DrawBitmap;
|
||||
var
|
||||
TextFlags: integer; // flags for caption (enabled or disabled)
|
||||
OldFontHandle: HFONT; // handle of previous font
|
||||
ButtonCaptionW: WideString;
|
||||
begin
|
||||
TextFlags := DST_PREFIXTEXT;
|
||||
if ButtonState = bsDisabled then
|
||||
TextFlags := TextFlags or DSS_DISABLED;
|
||||
|
||||
// fill with background color
|
||||
|
||||
if (srcWidth <> 0) and (srcHeight <> 0) then
|
||||
begin
|
||||
TBitBtnAceess(BitBtn).FButtonGlyph.GetImageIndexAndEffect(ButtonState, BitBtn.Font.PixelsPerInch, 1,
|
||||
@ -124,7 +124,11 @@ var
|
||||
SetTextColor(DrawStruct^._hDC, $FFFFFF)
|
||||
else
|
||||
SetTextColor(DrawStruct^._hDC, 0);
|
||||
DrawState(DrawStruct^._hDC, 0, nil, LPARAM(ButtonCaption), 0, XDestText, YDestText, 0, 0, TextFlags);
|
||||
|
||||
OldFontHandle := SelectObject(DrawStruct^._hDC, BitBtn.Font.Reference.Handle);
|
||||
ButtonCaptionW := UTF8ToUTF16(BitBtn.Caption);
|
||||
DrawState(DrawStruct^._hDC, 0, nil, LPARAM(ButtonCaptionW), 0, XDestText, YDestText, 0, 0, TextFlags);
|
||||
SelectObject(DrawStruct^._hDC, OldFontHandle);
|
||||
end;
|
||||
|
||||
var
|
||||
@ -151,8 +155,6 @@ begin
|
||||
// DFCS_ADJUSTRECT doesnot work
|
||||
InflateRect(DrawRect, -4, -4);
|
||||
|
||||
ButtonCaption := PWideChar(UTF8Decode(BitBtn.Caption));
|
||||
|
||||
// gather info about bitbtn
|
||||
if BitBtn.CanShowGlyph(True) then
|
||||
begin
|
||||
@ -172,7 +174,7 @@ begin
|
||||
|
||||
BitBtnLayout := BitBtn.Layout;
|
||||
|
||||
MeasureText(BitBtn, ButtonCaption, TextSize.cx, TextSize.cy);
|
||||
MeasureText(BitBtn, BitBtn.Caption, TextSize.cx, TextSize.cy);
|
||||
// calculate size of new bitmap
|
||||
case BitBtnLayout of
|
||||
blGlyphLeft, blGlyphRight:
|
||||
|
@ -27,11 +27,11 @@ uses
|
||||
// Compatibility
|
||||
{$ifdef Win32}win32compat,{$endif}
|
||||
// RTL, FCL, LCL
|
||||
SysUtils, LCLType, Classes, StdCtrls, Controls, Graphics, Forms, WinCEProc,
|
||||
SysUtils, LCLType, Classes, StdCtrls, Controls, Graphics, Forms, LCLProc,
|
||||
InterfaceBase, LMessages, LCLMessageGlue, LazUTF8, LazUtf8Classes,
|
||||
// Widgetset
|
||||
WSControls, WSStdCtrls, WSLCLClasses, WinCEInt, WinCEWSControls, WinCEExtra,
|
||||
WSProc;
|
||||
WSProc, WinCEProc;
|
||||
|
||||
type
|
||||
|
||||
@ -1022,11 +1022,13 @@ class procedure TWinCEWSCustomEdit.GetPreferredSize(
|
||||
const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer;
|
||||
WithThemeSpace: Boolean);
|
||||
begin
|
||||
if MeasureText(AWinControl, AWinControl.Caption, PreferredWidth, PreferredHeight) then
|
||||
if MeasureText(AWinControl, 'Fj', PreferredWidth, PreferredHeight) then
|
||||
begin
|
||||
Inc(PreferredWidth, 5);
|
||||
Inc(PreferredHeight, 5);
|
||||
PreferredWidth := 0;
|
||||
if TCustomEdit(AWinControl).BorderStyle <> bsNone then
|
||||
Inc(PreferredHeight, 5);
|
||||
end;
|
||||
{$ifdef VerboseSizeMsg}DebugLn(Format('[TWinCEWSCustomEdit.GetPreferredSize] %s: CX %d CY %d',[AWinControl.Name, PreferredWidth, PreferredHeight]));{$endif}
|
||||
end;
|
||||
|
||||
{ TWinCEWSCustomMemo }
|
||||
|
Loading…
Reference in New Issue
Block a user