gtk intf: added minimum size for TTrackBar

git-svn-id: trunk@9506 -
This commit is contained in:
mattias 2006-06-27 22:08:49 +00:00
parent 5c48364563
commit 8027a9738d
8 changed files with 112 additions and 81 deletions

View File

@ -964,7 +964,7 @@ var
fRect : TRect;
DCIndex: Integer;
begin
//debugln('TCanvas.TextRect A Text="',Text,'" ',dbgs(ARect));
//debugln(['TCanvas.TextRect ',DbgSName(Self),' Text="',Text,'" ',dbgs(ARect),' X=',X,',Y=',Y]);
Changing;
Options := 0;
case Style.Alignment of

View File

@ -400,7 +400,7 @@ begin
//debugln('TCustomLabel.Paint ',dbgs(Alignment=tacenter),' ',dbgs(Layout=tlCenter),' ',dbgs(TextLeft),' TextTop=',dbgs(TextTop),' ',dbgs(R));
if not Enabled then begin
Font.Color := clBtnHighlight;
textRect(R, TextLeft + 1, TextTop + 1, Caption, TR);
TextRect(R, TextLeft + 1, TextTop + 1, Caption, TR);
Font.color := clBtnShadow;
end;
TextRect(R, TextLeft, TextTop, Caption, TR)

View File

@ -108,6 +108,8 @@ type
lgsHorizontalPaned,
lgsNotebook,
lgsStatusBar,
lgsHScale,
lgsVScale,
// user defined
lgsUserDefined
);
@ -131,6 +133,8 @@ const
'horizontal paned',
'statusbar',
'notebook',
'hscale',
'vscale',
''
);

View File

@ -261,6 +261,7 @@ 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;
@ -281,7 +282,6 @@ begin
end;
end;
{------------------------------------------------------------------------------
function TGTKWidgetSet.FontCanUTF8(Font: HFont): boolean;
@ -370,9 +370,18 @@ begin
MinHeight:=Widget^.requisition.Height+20;
Widget:=GetStyleWidget(lgsVerticalScrollbar);
MinWidth:=Widget^.requisition.Width+20;
SizeConstraints.SetInterfaceConstraints(MinWidth,MinHeight,
MaxWidth,MaxHeight);
exit;
end
else if SizeConstraints.Control is TCustomTrackBar then begin
// TCustomTrackBar
if TCustomTrackBar(SizeConstraints.Control).Orientation=trHorizontal then
begin
Widget:=GetStyleWidget(lgsHScale);
MinHeight:=Widget^.requisition.height;
end else begin
Widget:=GetStyleWidget(lgsVScale);
MinWidth:=Widget^.requisition.width;
end;
DebugLn(['TGtkWidgetSet.GetControlConstraints ',DbgSName(SizeConstraints.Control),' ',MinWidth,',',MinHeight]);
end;
SizeConstraints.SetInterfaceConstraints(MinWidth,MinHeight,

View File

@ -5628,7 +5628,8 @@ begin
csTrackBar:
with (TCustomTrackBar (Sender)) do
begin
TempWidget := PGtkWidget( gtk_adjustment_new (Position, Min, Max, linesize, pagesize, 0));
TempWidget := PGtkWidget( gtk_adjustment_new (Position, Min, Max,
linesize, pagesize, 0));
if (Orientation = trHorizontal) then
P := gtk_hscale_new (PGTKADJUSTMENT (TempWidget))
else

View File

@ -7011,6 +7011,20 @@ begin
gtk_widget_ensure_style(PGTKTooltips(TP)^.Tip_Window);
StyleObject^.Style:=gtk_widget_get_style(PGTKTooltips(TP)^.Tip_Window);
end
else
If CompareText(WName,LazGtkStyleNames[lgsHScale])=0 then begin
lgs:=lgsHScale;
AddToStyleWindow:=true;
TP := PGtkWidget( gtk_adjustment_new (0, 0, 100, 1, 10, 0));
StyleObject^.Widget := gtk_hscale_new (PGTKADJUSTMENT (TP));
end
else
If CompareText(WName,LazGtkStyleNames[lgsVScale])=0 then begin
lgs:=lgsVScale;
AddToStyleWindow:=true;
TP := PGtkWidget( gtk_adjustment_new (0, 0, 100, 1, 10, 0));
StyleObject^.Widget := gtk_vscale_new (PGTKADJUSTMENT (TP));
end
else
If CompareText(WName,LazGtkStyleNames[lgsGTK_Default])=0 then begin
lgs:=lgsGTK_Default;

View File

@ -2937,9 +2937,6 @@ var
end;
Procedure DrawLine(theLine : PChar; LineLength, TopPos : Longint);
var
Points : Array[0..1] of TSize;
@ -3007,80 +3004,84 @@ begin
if Boolean(Result)
then with TDeviceContext(DC) do
begin
if GC = nil
then begin
if GC = nil then begin
DebugLn('WARNING: [TGtkWidgetSet.DrawText] Uninitialized GC');
Result := 0;
end
else begin
Result := 0;
Lines := nil;
NumLines := 0;
TempDC := -1;
TempPen := -1;
TempBrush := -1;
try
if (Flags and (DT_SingleLine+DT_CalcRect+Dt_NoPrefix+DT_NOClip))=(DT_SingleLine+Dt_NoPrefix+Dt_NoClip) then begin
CopyRect(theRect, Rect);
DrawLineRaw(Str, Count, Rect.Top);
exit;
end;
Count := Min(StrLen(Str), Count);
GetTextMetrics(DC, TM);
DoCalcRect;
If (Flags and DT_CalcRect) = DT_CalcRect then begin
CopyRect(Rect, theRect);
Result := 1;
exit;
end else begin
TempDC := SaveDC(DC);
end;
If (Flags and DT_NOCLIP) <> DT_NOCLIP then begin
If theRect.Right > Rect.Right then
theRect.Right := Rect.Right;
If theRect.Bottom > Rect.Bottom then
theRect.Bottom := Rect.Bottom;
IntersectClipRect(DC, theRect.Left, theRect.Top,
theRect.Right, theRect.Bottom);
end;
If (Flags and DT_SingleLine) = DT_SingleLine then begin
DrawLine(Str, Count, theRect.Top);
Result := 1;
end
else If (Lines <> nil) and (NumLines <> 0) then begin
For I := 0 to NumLines - 1 do begin
if I>0 then
Inc(theRect.Top, TM.tmDescent);// space between lines
If (((Flags and DT_EditControl) = DT_EditControl) and
(tm.tmHeight > (theRect.Bottom - theRect.Top))) or
(theRect.Top > theRect.Bottom)
then
break;
If Lines[I] <> nil then
DrawLine(Lines[I], StrLen(Lines[I]), theRect.Top);
Inc(theRect.Top, TM.tmHeight);
end;
Result := 1;
end;
finally
Reallocmem(Lines, 0);
If TempBrush <> -1 then
SelectObject(DC, TempBrush);
If TempPen <> -1 then
DeleteObject(SelectObject(DC, TempPen));
If TempDC <> -1 then
RestoreDC(DC, TempDC);
exit;
end;
Result := 0;
Lines := nil;
NumLines := 0;
TempDC := -1;
TempPen := -1;
TempBrush := -1;
try
if (Flags and (DT_SingleLine+DT_CalcRect+Dt_NoPrefix+DT_NOClip))
=(DT_SingleLine+Dt_NoPrefix+Dt_NoClip)
then begin
//DebugLn(['TGtkWidgetSet.DrawText Calc single line']);
CopyRect(theRect, Rect);
DrawLineRaw(Str, Count, Rect.Top);
exit;
end;
Count := Min(StrLen(Str), Count);
GetTextMetrics(DC, TM);
DoCalcRect;
If (Flags and DT_CalcRect) = DT_CalcRect then begin
//DebugLn(['TGtkWidgetSet.DrawText Complex Calc']);
CopyRect(Rect, theRect);
Result := 1;
exit;
end else begin
TempDC := SaveDC(DC);
end;
If (Flags and DT_NOCLIP) <> DT_NOCLIP then begin
If theRect.Right > Rect.Right then
theRect.Right := Rect.Right;
If theRect.Bottom > Rect.Bottom then
theRect.Bottom := Rect.Bottom;
IntersectClipRect(DC, theRect.Left, theRect.Top,
theRect.Right, theRect.Bottom);
end;
If (Flags and DT_SingleLine) = DT_SingleLine then begin
//DebugLn(['TGtkWidgetSet.DrawText Draw single line']);
DrawLine(Str, Count, theRect.Top);
Result := 1;
end
else If (Lines <> nil) and (NumLines <> 0) then begin
//DebugLn(['TGtkWidgetSet.DrawText Draw multiline']);
For I := 0 to NumLines - 1 do begin
if I>0 then
Inc(theRect.Top, TM.tmDescent);// space between lines
If (((Flags and DT_EditControl) = DT_EditControl) and
(tm.tmHeight > (theRect.Bottom - theRect.Top))) or
(theRect.Top > theRect.Bottom)
then
break;
If Lines[I] <> nil then
DrawLine(Lines[I], StrLen(Lines[I]), theRect.Top);
Inc(theRect.Top, TM.tmHeight);
end;
Result := 1;
end;
finally
Reallocmem(Lines, 0);
If TempBrush <> -1 then
SelectObject(DC, TempBrush);
If TempPen <> -1 then
DeleteObject(SelectObject(DC, TempPen));
If TempDC <> -1 then
RestoreDC(DC, TempDC);
end;
end;
Assert(False, Format('trace:> [TGtkWidgetSet.DrawText] DC:0x%x, Str:''%s'', Count: %d, Rect = %d,%d,%d,%d, Flags:%d',

View File

@ -529,8 +529,10 @@ begin
pango_layout_set_text(UseFont, Str, Count);
EnsureGCColor(DC, dccCurrentTextColor, True, False);
//DebugLn(['TGtk2WidgetSet.TextOut Str="',copy(Str,1,Count),'" X=',X+DCOrigin.X,',',Y+DCOrigin.Y+yOffset]);
gdk_draw_layout_with_colors(drawable, GC,
X+DCOrigin.X, Y+DCOrigin.Y+yOffset, UseFont, nil, nil);
Result := True;
end;
end;