mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 20:21:04 +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
|
implementation
|
||||||
|
|
||||||
uses ImgList, WinCEInt, WinCEExtra;
|
uses
|
||||||
|
ImgList, WinCEInt, WinCEExtra;
|
||||||
|
|
||||||
type
|
type
|
||||||
TBitBtnAceess = class(TCustomBitBtn)
|
TBitBtnAceess = class(TCustomBitBtn)
|
||||||
@ -91,7 +92,6 @@ var
|
|||||||
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
|
||||||
ButtonCaption: PWideChar;
|
|
||||||
ButtonState: TButtonState;
|
ButtonState: TButtonState;
|
||||||
AIndex: Integer;
|
AIndex: Integer;
|
||||||
AImageRes: TScaledImageListResolution;
|
AImageRes: TScaledImageListResolution;
|
||||||
@ -100,13 +100,13 @@ var
|
|||||||
procedure DrawBitmap;
|
procedure DrawBitmap;
|
||||||
var
|
var
|
||||||
TextFlags: integer; // flags for caption (enabled or disabled)
|
TextFlags: integer; // flags for caption (enabled or disabled)
|
||||||
|
OldFontHandle: HFONT; // handle of previous font
|
||||||
|
ButtonCaptionW: WideString;
|
||||||
begin
|
begin
|
||||||
TextFlags := DST_PREFIXTEXT;
|
TextFlags := DST_PREFIXTEXT;
|
||||||
if ButtonState = bsDisabled then
|
if ButtonState = bsDisabled then
|
||||||
TextFlags := TextFlags or DSS_DISABLED;
|
TextFlags := TextFlags or DSS_DISABLED;
|
||||||
|
|
||||||
// fill with background color
|
|
||||||
|
|
||||||
if (srcWidth <> 0) and (srcHeight <> 0) then
|
if (srcWidth <> 0) and (srcHeight <> 0) then
|
||||||
begin
|
begin
|
||||||
TBitBtnAceess(BitBtn).FButtonGlyph.GetImageIndexAndEffect(ButtonState, BitBtn.Font.PixelsPerInch, 1,
|
TBitBtnAceess(BitBtn).FButtonGlyph.GetImageIndexAndEffect(ButtonState, BitBtn.Font.PixelsPerInch, 1,
|
||||||
@ -124,7 +124,11 @@ var
|
|||||||
SetTextColor(DrawStruct^._hDC, $FFFFFF)
|
SetTextColor(DrawStruct^._hDC, $FFFFFF)
|
||||||
else
|
else
|
||||||
SetTextColor(DrawStruct^._hDC, 0);
|
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;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -151,8 +155,6 @@ begin
|
|||||||
// DFCS_ADJUSTRECT doesnot work
|
// DFCS_ADJUSTRECT doesnot work
|
||||||
InflateRect(DrawRect, -4, -4);
|
InflateRect(DrawRect, -4, -4);
|
||||||
|
|
||||||
ButtonCaption := PWideChar(UTF8Decode(BitBtn.Caption));
|
|
||||||
|
|
||||||
// gather info about bitbtn
|
// gather info about bitbtn
|
||||||
if BitBtn.CanShowGlyph(True) then
|
if BitBtn.CanShowGlyph(True) then
|
||||||
begin
|
begin
|
||||||
@ -172,7 +174,7 @@ begin
|
|||||||
|
|
||||||
BitBtnLayout := BitBtn.Layout;
|
BitBtnLayout := BitBtn.Layout;
|
||||||
|
|
||||||
MeasureText(BitBtn, ButtonCaption, TextSize.cx, TextSize.cy);
|
MeasureText(BitBtn, BitBtn.Caption, TextSize.cx, TextSize.cy);
|
||||||
// calculate size of new bitmap
|
// calculate size of new bitmap
|
||||||
case BitBtnLayout of
|
case BitBtnLayout of
|
||||||
blGlyphLeft, blGlyphRight:
|
blGlyphLeft, blGlyphRight:
|
||||||
|
@ -27,11 +27,11 @@ uses
|
|||||||
// Compatibility
|
// Compatibility
|
||||||
{$ifdef Win32}win32compat,{$endif}
|
{$ifdef Win32}win32compat,{$endif}
|
||||||
// RTL, FCL, LCL
|
// RTL, FCL, LCL
|
||||||
SysUtils, LCLType, Classes, StdCtrls, Controls, Graphics, Forms, WinCEProc,
|
SysUtils, LCLType, Classes, StdCtrls, Controls, Graphics, Forms, LCLProc,
|
||||||
InterfaceBase, LMessages, LCLMessageGlue, LazUTF8, LazUtf8Classes,
|
InterfaceBase, LMessages, LCLMessageGlue, LazUTF8, LazUtf8Classes,
|
||||||
// Widgetset
|
// Widgetset
|
||||||
WSControls, WSStdCtrls, WSLCLClasses, WinCEInt, WinCEWSControls, WinCEExtra,
|
WSControls, WSStdCtrls, WSLCLClasses, WinCEInt, WinCEWSControls, WinCEExtra,
|
||||||
WSProc;
|
WSProc, WinCEProc;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -1022,11 +1022,13 @@ class procedure TWinCEWSCustomEdit.GetPreferredSize(
|
|||||||
const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer;
|
const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer;
|
||||||
WithThemeSpace: Boolean);
|
WithThemeSpace: Boolean);
|
||||||
begin
|
begin
|
||||||
if MeasureText(AWinControl, AWinControl.Caption, PreferredWidth, PreferredHeight) then
|
if MeasureText(AWinControl, 'Fj', PreferredWidth, PreferredHeight) then
|
||||||
begin
|
begin
|
||||||
Inc(PreferredWidth, 5);
|
PreferredWidth := 0;
|
||||||
Inc(PreferredHeight, 5);
|
if TCustomEdit(AWinControl).BorderStyle <> bsNone then
|
||||||
|
Inc(PreferredHeight, 5);
|
||||||
end;
|
end;
|
||||||
|
{$ifdef VerboseSizeMsg}DebugLn(Format('[TWinCEWSCustomEdit.GetPreferredSize] %s: CX %d CY %d',[AWinControl.Name, PreferredWidth, PreferredHeight]));{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TWinCEWSCustomMemo }
|
{ TWinCEWSCustomMemo }
|
||||||
|
Loading…
Reference in New Issue
Block a user