mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-05 15:02:12 +02:00
added TextUTF8Out
git-svn-id: trunk@8928 -
This commit is contained in:
parent
a220d6ec82
commit
542ca69199
@ -370,12 +370,15 @@ begin
|
||||
ShowPrefix := ShowAccelChar;
|
||||
SystemFont:=false;
|
||||
end;
|
||||
CalcSize(lTextWidth, lTextHeight);
|
||||
TextLeft := R.Left;
|
||||
case Layout of
|
||||
tlTop: TextTop := R.Top;
|
||||
tlCenter: TextTop := (R.Bottom - R.Top - lTextHeight) div 2;
|
||||
tlBottom: TextTop := R.Bottom - R.Top - lTextHeight;
|
||||
if layout = tlTop then begin
|
||||
TextTop := R.Top;
|
||||
end else begin
|
||||
CalcSize(lTextWidth, lTextHeight);
|
||||
case Layout of
|
||||
tlCenter: TextTop := (R.Bottom - R.Top - lTextHeight) div 2;
|
||||
tlBottom: TextTop := R.Bottom - R.Top - lTextHeight;
|
||||
end;
|
||||
end;
|
||||
//debugln('TCustomLabel.Paint ',dbgs(Alignment=tacenter),' ',dbgs(Layout=tlCenter),' ',dbgs(TextLeft),' TextTop=',dbgs(TextTop),' ',dbgs(R));
|
||||
if not Enabled then begin
|
||||
|
@ -139,6 +139,12 @@ begin
|
||||
Result:=ExtTextOut(DC,X,Y,Options,Rect,Str,Count,Dx);
|
||||
end;
|
||||
|
||||
function TWidgetSet.TextUTF8Out(DC: HDC; X, Y: Integer; Str: PChar; Count: Longint): Boolean;
|
||||
begin
|
||||
Result:=TextOut(DC,X,Y,Str,Count);
|
||||
end;
|
||||
|
||||
|
||||
function TWidgetSet.FontCanUTF8(Font: HFont): boolean;
|
||||
begin
|
||||
Result:=false;
|
||||
|
@ -136,6 +136,12 @@ begin
|
||||
Result := WidgetSet.ExtUTF8Out(DC,X,Y,Options,Rect,Str,Count,Dx);
|
||||
end;
|
||||
|
||||
|
||||
function TextUTF8Out(DC: HDC; X, Y: Integer; Str: PChar; Count: Longint): Boolean;
|
||||
begin
|
||||
Result := WidgetSet.TextUTF8Out(DC,X,Y,Str,Count);
|
||||
end;
|
||||
|
||||
function FontCanUTF8(Font: HFont): boolean;
|
||||
begin
|
||||
Result := WidgetSet.FontCanUTF8(Font);
|
||||
|
@ -63,6 +63,7 @@ function DCClipRegionValid(DC: HDC): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$E
|
||||
procedure DrawArrow(Arrow: TComponent; Canvas: TPersistent); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
|
||||
function ExtUTF8Out(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function TextUTF8Out(DC: HDC; X, Y: Integer; Str: PChar; Count: Longint): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
|
||||
function FontCanUTF8(Font: HFont): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function Frame(DC: HDC; const ARect: TRect): Integer; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
|
@ -259,6 +259,26 @@ begin
|
||||
Result:=ExtTextOut(DC,X,Y,Options,Rect,Str,Count,Dx);
|
||||
end;
|
||||
end;
|
||||
function TGtkWidgetSet.TextUTF8Out(DC: HDC; X, Y: Integer; Str: PChar; Count: Longint): Boolean;
|
||||
var
|
||||
IsDBCSFont: Boolean;
|
||||
NewCount: Integer;
|
||||
begin
|
||||
UpdateDCTextMetric(TDeviceContext(DC));
|
||||
IsDBCSFont:=TDeviceContext(DC).DCTextMetric.IsDoubleByteChar;
|
||||
if IsDBCSFont then begin
|
||||
NewCount:=Count*2;
|
||||
if FExtUTF8OutCacheSize<NewCount then begin
|
||||
ReAllocMem(FExtUTF8OutCache,NewCount);
|
||||
FExtUTF8OutCacheSize:=NewCount;
|
||||
end;
|
||||
NewCount:=UTF8ToDoubleByte(Str,Count,FExtUTF8OutCache)*2;
|
||||
Result:=TextOut(DC,X,Y,FExtUTF8OutCache,NewCount);
|
||||
end else begin
|
||||
Result:=TextOut(DC,X,Y,Str,Count);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
function TGTKWidgetSet.FontCanUTF8(Font: HFont): boolean;
|
||||
|
@ -39,6 +39,7 @@ function DrawSplitter(DC: HDC; const ARect: TRect; Horizontal: boolean): boolean
|
||||
|
||||
function ExtUTF8Out(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect;
|
||||
Str: PChar; Count: Longint; Dx: PInteger): Boolean; override;
|
||||
function TextUTF8Out(DC: HDC; X, Y: Integer; Str: PChar; Count: Longint): Boolean; override;
|
||||
|
||||
function FontCanUTF8(Font: HFont): boolean; override;
|
||||
|
||||
|
@ -2785,13 +2785,6 @@ var
|
||||
theRect.Right := theRect.Left + Min(MaxLength, AP.cX);
|
||||
theRect.Bottom := theRect.Top + TM.tmHeight;
|
||||
|
||||
If not CalcRect then
|
||||
Case TopOffset of
|
||||
DT_VCENTER :
|
||||
OffsetRect(theRect, 0, (Rect.Bottom - theRect.Bottom) div 2);
|
||||
DT_Bottom :
|
||||
OffsetRect(theRect, 0, Rect.Bottom - theRect.Bottom);
|
||||
end;
|
||||
end
|
||||
else begin
|
||||
// consider line breaks
|
||||
@ -2802,17 +2795,17 @@ var
|
||||
end;
|
||||
Self.WordWrap(DC, Str, MaxLength, Lines, NumLines);
|
||||
|
||||
LineWidth := 0;
|
||||
|
||||
If (Lines <> nil) then begin
|
||||
If (Lines <> nil) and (NumLines>1) then begin
|
||||
LineWidth := 0;
|
||||
For J := 0 to NumLines - 1 do begin
|
||||
GetTextExtentPoint(DC, Lines[J], StrLen(Lines[J]), AP);
|
||||
LineWidth := Max(LineWidth, AP.cX);
|
||||
end;
|
||||
end;
|
||||
|
||||
end else LineWidth:=10000;
|
||||
LineWidth := Min(MaxLength, LineWidth);
|
||||
|
||||
|
||||
theRect.Right := theRect.Left + LineWidth;
|
||||
theRect.Bottom := theRect.Top + NumLines*TM.tmHeight;
|
||||
if NumLines>1 then
|
||||
@ -2862,7 +2855,7 @@ var
|
||||
end;
|
||||
|
||||
{Draw line of Text}
|
||||
TextOut(DC, LeftPos, TopPos, PChar(aStr), Length(aStr));
|
||||
TextUtf8Out(DC, LeftPos, TopPos, PChar(aStr), Length(aStr));
|
||||
|
||||
{Draw Prefix}
|
||||
If pIndex > 0 then begin
|
||||
@ -3694,7 +3687,7 @@ var
|
||||
with TDeviceContext(DC) do begin
|
||||
if (Dx=nil) then begin
|
||||
// no dist array -> write as one block
|
||||
//debugln('TGtkWidgetSet.ExtTextOut.DrawTextLine Dx=nil ',dbgs(LineLen),' DCTextMetric.IsDoubleByteChar=',dbgs(DCTextMetric.IsDoubleByteChar));
|
||||
|
||||
gdk_draw_text(Buffer, UseFont, GC, TxtPt.X, TxtPt.Y,
|
||||
LineStart, LineLen);
|
||||
end else begin
|
||||
@ -5940,6 +5933,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
Assert(False, 'trace:< [TGtkWidgetSet.GetTextExtentPoint]');
|
||||
|
||||
end;
|
||||
{$EndIf}
|
||||
|
||||
@ -9330,6 +9324,9 @@ var
|
||||
TempPen : hPen;
|
||||
LogP : TLogPen;
|
||||
Points : array[0..1] of TSize;
|
||||
|
||||
lbearing, rbearing, width, ascent,descent: LongInt;
|
||||
|
||||
begin
|
||||
Result := IsValidDC(DC);
|
||||
if Result and (Count>0)
|
||||
@ -9357,7 +9354,18 @@ begin
|
||||
DebugLn('WARNING: [TGtkWidgetSet.TextOut] Missing Font')
|
||||
else begin
|
||||
DCOrigin:=GetDCOffset(TDeviceContext(DC));
|
||||
GetTextExtentPoint(DC, Str, Count, Sz);
|
||||
descent:=0;
|
||||
gdk_text_extents(UseFont, Str, Count,
|
||||
@lbearing, @rBearing, @width, @ascent, @descent);
|
||||
sz.cx:=width;
|
||||
Sz.cY :={$IFDEF Win32}
|
||||
GDK_String_Height(UseFont, Str)
|
||||
{$ELSE}
|
||||
ascent+descent;
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
|
||||
aRect := Rect(X+DCOrigin.X,Y+DCOrigin.Y,X + Sz.CX, Sz.CY);
|
||||
//DebugLn('TGtkWidgetSet.TextOut ',ARect.Left,',',ARect.Top,',',ARect.RIght,',',ARect.Bottom);
|
||||
FillRect(DC,aRect,hBrush(CurrentBrush));
|
||||
|
Loading…
Reference in New Issue
Block a user