hi
attached patch
 1. set up single line for drawing caption without multi line
 2. much faster drawText to single line option
 3.for tComboBox change is called twice
4. added {$IFNDEF gtk_no_set_modal} because I want disable gtk_window_set_modal(GtkWindow, true);




for me GetTextHeight(DCTextMetric) has bug - it not add at descend

Darek

Index: interfaces/gtk/gtkwinapi.inc
===================================================================
--- interfaces/gtk/gtkwinapi.inc        (wersja 9085)
+++ interfaces/gtk/gtkwinapi.inc        (kopia robocza)
@@ -2782,7 +2782,10 @@
     If (Flags and DT_SingleLine) > 0 then begin
       // ignore word and line breaks
       GetTextExtentPoint(DC, Str, Count, AP);
-      theRect.Right := theRect.Left + Min(MaxLength, AP.cX);
+      if (Flags and DT_CalcRect)<>0 then
+        theRect.Right := theRect.Left +  AP.cX
+      else
+        theRect.Right := theRect.Left + Min(MaxLength, AP.cX);
       theRect.Bottom := theRect.Top + TM.tmHeight;
     end
     else begin
@@ -2825,6 +2828,34 @@
       end;
   end;
 
+  Procedure DrawLineRaw(theLine : PChar; LineLength, TopPos : Longint);
+  var
+    Points : Array[0..1] of TSize;
+    LeftPos : Longint;
+  begin
+    If LeftOffset <> DT_Left then
+      GetTextExtentPoint(DC, theLine, LineLength, Points[0]);
+
+    If TempBrush = -1 then
+      TempBrush := SelectObject(DC, GetStockObject(NULL_BRUSH));
+    Case LeftOffset of
+      DT_Left:
+        LeftPos := theRect.Left;
+      DT_Center:
+        LeftPos := theRect.Left + (theRect.Right - theRect.Left) div 2
+                 - Points[0].cX div 2;
+      DT_Right:
+        LeftPos := theRect.Right - Points[0].cX;
+    end;
+
+    {Draw line of Text}
+    TextUtf8Out(DC, LeftPos, TopPos, theLine, lineLength);
+  end;
+
+
+
+
+
   Procedure DrawLine(theLine : PChar; LineLength, TopPos : Longint);
   var
     Points : Array[0..1] of TSize;
@@ -2905,6 +2936,12 @@
       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);
@@ -3807,7 +3844,7 @@
     if UseFont<>nil then begin
       LineLen := FindChar(#10,Str,Count);
       UpdateDCTextMetric(TDeviceContext(DC));
-      LineHeight:=GetTextHeight(DCTextMetric);
+      LineHeight:=DCTextMetric.TextMetric.tmHeight;
       if Buffered then begin
         TxtPt.X := 0;
         TxtPt.Y := LineHeight;
Index: interfaces/gtk/gtkwscontrols.pp
===================================================================
--- interfaces/gtk/gtkwscontrols.pp     (wersja 9085)
+++ interfaces/gtk/gtkwscontrols.pp     (kopia robocza)
@@ -659,8 +659,9 @@
 
   if ModalWindows=nil then ModalWindows:=TFPList.Create;
   ModalWindows.Add(GtkWindow);
-
+  {$IFNDEF gtk_no_set_modal}
   gtk_window_set_modal(GtkWindow, true);
+  {$ENDIF}
   gtk_widget_show(PGtkWidget(GtkWindow));
   {$IFDEF Gtk1}
   GDK_WINDOW_ACTIVATE(PGdkWindowPrivate(PGtkWidget(GtkWindow)^.window));
@@ -672,6 +673,7 @@
   TGtkWidgetSet(WidgetSet).UpdateTransientWindows;
 end;
 
+
 { TGtkWSBaseScrollingWinControl }
 
 function GtkWSBaseScrollingWinControl_HValueChanged(AAdjustment: 
PGTKAdjustment; AInfo: PWidgetInfo): GBoolean; cdecl;
Index: include/customlabel.inc
===================================================================
--- include/customlabel.inc     (wersja 9085)
+++ include/customlabel.inc     (kopia robocza)
@@ -39,7 +39,9 @@
     R := Rect(0,0, Width, Height);
     OldFont:=SelectObject(DC, Font.Handle);
     Flags:=DT_CalcRect;
-    if WordWrap then inc(Flags,DT_WordBreak);
+    if WordWrap then inc(Flags,DT_WordBreak)
+    else if not HasMultiLine then inc(Flags,DT_SingleLine);
+    
     DrawText(DC, PChar(Caption), Length(Caption), R, Flags);
     SelectObject(DC, OldFont);
     // add one to be able to display disabled label
@@ -50,6 +52,12 @@
   end;
 end;
 
+function tCustomLabel.HasMultiLine : boolean;
+
+begin
+  result:=(pos(#10,caption)>0) {$IFDEF WIN32}or (pos(#13,caption)>0) {$ENDIF};
+end;
+
 Procedure TCustomLabel.DoAutoSize;
 var
   NewWidth, NewHeight: integer;
@@ -153,8 +161,7 @@
   inherited Create(TheOwner);
   Font.OnChange := @FontChange;
   ControlStyle := [csSetCaption, csClickEvents, csDoubleClicks, 
csReplicatable];
-  Width := 65;
-  Height := 17;
+  setInitialBounds(0,0,65,17);
   FShowAccelChar := True;
   Color := clNone;
   AutoSize:=true;
@@ -366,7 +373,7 @@
     With TR do begin
       Alignment := Self.Alignment;
       WordBreak := wordWrap;
-      SingleLine:=false;
+      SingleLine:= not WordWrap and not HasMultiLine;
       Clipping := True;
       ShowPrefix := ShowAccelChar;
       SystemFont:=false;
Index: include/customcombobox.inc
===================================================================
--- include/customcombobox.inc  (wersja 9085)
+++ include/customcombobox.inc  (kopia robocza)
@@ -177,10 +177,7 @@
  
------------------------------------------------------------------------------}
 procedure TCustomComboBox.Select;
 begin
-  if Assigned(FOnSelect) then
-    FOnSelect(Self)
-  else
-    Change;
+  if Assigned(FOnSelect) then  FOnSelect(Self);
 end;
 
 {------------------------------------------------------------------------------
@@ -753,7 +750,7 @@
  
------------------------------------------------------------------------------}
 function TCustomComboBox.GetItemIndex : integer;
 begin
-  if not (csDestroying in ComponentState){and     not  (csDestroyingHandle in 
ControlState) } and HandleAllocated then
+  if not (csDestroying in ComponentState) and     not  (csDestroyingHandle in 
ControlState)  and HandleAllocated then
     FItemIndex:= TWSCustomComboBoxClass(WidgetSetClass).GetItemIndex(Self);
   Result:=FItemIndex;
 end;
@@ -789,8 +786,8 @@
 begin
   //if CompareText(Name,'TextToFindComboBox')=0 then
   //  debugln('TCustomComboBox.SetItemIndex A ',DbgSName(Self),' 
Text="',Text,'"');
-  if Val = GetItemIndex then exit;
   if Val < -1 then Exit;
+  if Val = GetItemIndex then exit;
   if (Val >= Items.Count) and (not (csLoading in ComponentState)) then exit;
 
   FItemIndex:= Val;
@@ -798,7 +795,6 @@
   
   if HandleAllocated then begin
     TWSCustomComboBoxClass(WidgetSetClass).SetItemIndex(Self, FItemIndex);
-    Select;
   end else begin
     // remember text, in case one reads text without creating handle
     if Val = -1
Index: stdctrls.pp
===================================================================
--- stdctrls.pp (wersja 9085)
+++ stdctrls.pp (kopia robocza)
@@ -1146,6 +1146,7 @@
     procedure SetOptimalFill(const AValue: Boolean);
   protected
     function  CanTab: boolean; override;
+    function  HasMultiLine : boolean;
     procedure CalcSize(var AWidth, AHeight: integer);
     procedure DoAutoSize; override;
     function  DialogChar(var Message: TLMKey): boolean; override;

Reply via email to