From 8027a9738d66df79c3739fc97648627d80e5e75f Mon Sep 17 00:00:00 2001 From: mattias Date: Tue, 27 Jun 2006 22:08:49 +0000 Subject: [PATCH] gtk intf: added minimum size for TTrackBar git-svn-id: trunk@9506 - --- lcl/include/canvas.inc | 2 +- lcl/include/customlabel.inc | 2 +- lcl/interfaces/gtk/gtkglobals.pp | 4 + lcl/interfaces/gtk/gtklclintf.inc | 17 +++- lcl/interfaces/gtk/gtkobject.inc | 3 +- lcl/interfaces/gtk/gtkproc.inc | 14 +++ lcl/interfaces/gtk/gtkwinapi.inc | 149 +++++++++++++++-------------- lcl/interfaces/gtk2/gtk2winapi.inc | 2 + 8 files changed, 112 insertions(+), 81 deletions(-) diff --git a/lcl/include/canvas.inc b/lcl/include/canvas.inc index 58db54e1e5..f4dcdb6894 100644 --- a/lcl/include/canvas.inc +++ b/lcl/include/canvas.inc @@ -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 diff --git a/lcl/include/customlabel.inc b/lcl/include/customlabel.inc index 49e0865658..3383893093 100644 --- a/lcl/include/customlabel.inc +++ b/lcl/include/customlabel.inc @@ -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) diff --git a/lcl/interfaces/gtk/gtkglobals.pp b/lcl/interfaces/gtk/gtkglobals.pp index be371671e3..b5d661dba7 100644 --- a/lcl/interfaces/gtk/gtkglobals.pp +++ b/lcl/interfaces/gtk/gtkglobals.pp @@ -108,6 +108,8 @@ type lgsHorizontalPaned, lgsNotebook, lgsStatusBar, + lgsHScale, + lgsVScale, // user defined lgsUserDefined ); @@ -131,6 +133,8 @@ const 'horizontal paned', 'statusbar', 'notebook', + 'hscale', + 'vscale', '' ); diff --git a/lcl/interfaces/gtk/gtklclintf.inc b/lcl/interfaces/gtk/gtklclintf.inc index 67b59b55cb..e5131c9277 100644 --- a/lcl/interfaces/gtk/gtklclintf.inc +++ b/lcl/interfaces/gtk/gtklclintf.inc @@ -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, diff --git a/lcl/interfaces/gtk/gtkobject.inc b/lcl/interfaces/gtk/gtkobject.inc index d1ec25f389..9f0fa35d26 100644 --- a/lcl/interfaces/gtk/gtkobject.inc +++ b/lcl/interfaces/gtk/gtkobject.inc @@ -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 diff --git a/lcl/interfaces/gtk/gtkproc.inc b/lcl/interfaces/gtk/gtkproc.inc index 07c2ee31d0..a853ffdaae 100644 --- a/lcl/interfaces/gtk/gtkproc.inc +++ b/lcl/interfaces/gtk/gtkproc.inc @@ -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; diff --git a/lcl/interfaces/gtk/gtkwinapi.inc b/lcl/interfaces/gtk/gtkwinapi.inc index b78124dc0d..bbf49d6e97 100644 --- a/lcl/interfaces/gtk/gtkwinapi.inc +++ b/lcl/interfaces/gtk/gtkwinapi.inc @@ -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', diff --git a/lcl/interfaces/gtk2/gtk2winapi.inc b/lcl/interfaces/gtk2/gtk2winapi.inc index c77d86de17..f66c977024 100644 --- a/lcl/interfaces/gtk2/gtk2winapi.inc +++ b/lcl/interfaces/gtk2/gtk2winapi.inc @@ -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;