Mattias Gaertner wrote:

On Sat, 15 Apr 2006 21:44:52 +0200
darekm <[EMAIL PROTECTED]> wrote:

Hi
 attached patch repair
  calculation of visibility scrollbar
  Clicked on tButton now work for scrolled window

all under GTK+

Note: DisableAlign/EnableAlign needs try..finally, otherwise you can run
into very hard to track down bugs.

added try finally


and small comment:
 -  bugfix for enabled scrollbar for  tscrollbox
- small optimization for invoked FindControlAtPosition when mouse make no move (it need many time for huge window, with many controls)
 - optimizations for Align (its invoked too many times)

Darek


Mattias

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Index: forms.pp
===================================================================
--- forms.pp    (wersja 9143)
+++ forms.pp    (kopia robocza)
@@ -915,6 +915,8 @@
     FAsyncCallQueue: PAsyncCallQueueItem;
     FShowHint: Boolean;
     FShowMainForm: Boolean;
+    FLastMousePos : TPoint;
+    FLastMouseControl : tControl;
     procedure DoOnIdleEnd;
     function GetCurrentHelpFile: string;
     function GetExename: String;
Index: include/wincontrol.inc
===================================================================
--- include/wincontrol.inc      (wersja 9143)
+++ include/wincontrol.inc      (kopia robocza)
@@ -1675,6 +1675,8 @@
   AWinControl: TWinControl;
 begin
   if AutoSizeDelayed then exit;
+  DisableAlign;
+  try
   for i:=0 to ControlCount-1 do begin
     Child:=Controls[i];
     if Child.AutoSizeDelayed then continue;
@@ -1691,6 +1693,9 @@
         AWinControl.ReAlign;
     end;
   end;
+  finally
+    EnableAlign;
+  end;
 end;
 
 
{-------------------------------------------------------------------------------
@@ -2797,6 +2802,7 @@
 function TWinControl.IsControlMouseMsg(var TheMessage: TLMMouse) : Boolean;
 var
   Control : TControl;
+  ScrolledOffset,
   P : TPoint;
   ClientBounds: TRect;
 begin
@@ -2817,8 +2823,10 @@
   if Control <> nil then
   begin
     // map mouse coordinates to control
-    P.X := TheMessage.XPos - Control.Left;
-    P.Y := TheMessage.YPos - Control.Top;
+    ScrolledOffset:=GetClientScrollOffset;
+
+    P.X := TheMessage.XPos - Control.Left + ScrolledOffset.X;
+    P.Y := TheMessage.YPos - Control.Top + ScrolledOffset.Y;
     if (Control is TWinControl) and TWinControl(Control).HandleAllocated then
     begin
       // map coordinates to client area of control
@@ -2950,7 +2958,7 @@
   P: TPoint;
   {$ENDIF}
 begin
-//DebugLn('[TWinControl.PaintControls] ',Name,':',ClassName,'  
DC=',DbgS(DC,8));
+  //DebugLn('[TWinControl.PaintControls] ',Name,':',ClassName,'  
DC=',DbgS(DC,8));
   if (csDestroying in ComponentState)
   or ((DC=0) and (not HandleAllocated)) then
     exit;
@@ -4584,7 +4592,7 @@
   PS : TPaintStruct;
   ClientBoundRect: TRect;
 begin
-  //DebugLn('[TWinControl.WMPaint] ',Name,':',ClassName,'  ',DbgS(Msg.DC,8));
+  DebugLn('[TWinControl.WMPaint] ',Name,':',ClassName,'  ',DbgS(Msg.DC,8));
   if ([csDestroying,csLoading]*ComponentState<>[]) or (not HandleAllocated) 
then
     exit;
 
Index: include/controlscrollbar.inc
===================================================================
--- include/controlscrollbar.inc        (wersja 9143)
+++ include/controlscrollbar.inc        (kopia robocza)
@@ -230,7 +230,6 @@
       AutoCalcVRange
     else
       AutoCalcHRange;
-    ControlUpdateScrollBars;
   end;
 end;
 
@@ -264,12 +263,13 @@
         SBSize := OtherScrollbar.Size
       else
         SBSize := 0;
-      if Kind=sbVertical then
-        FAutoRange := (FRange - ClientHeight)
-                      *Shortint(FRange >= ClientHeight + SBSize)
-      else
-        FAutoRange := (FRange - ClientWidth)
-                      *Shortint(FRange >= ClientWidth + SBSize);
+      if Kind=sbVertical then begin
+        SBSize:=ClientHeight - SBSize;
+      end else begin
+        SBSize:=ClientWidth - SBSize;
+      end;
+      if (fRange>SBSize) and (SBSize>0) then   FAutoRange := (FRange - SBSize)
+                                        else   FAutoRange := 0;
       ScrollInfo.nMax := FRange;
 
       // visible
Index: include/checkbox.inc
===================================================================
--- include/checkbox.inc        (wersja 9143)
+++ include/checkbox.inc        (kopia robocza)
@@ -144,7 +144,7 @@
 
 Procedure TCheckbox.WMKeyDown(var Message : TLMKeyDown);
 begin
-  ControlState := ControlState -  [csClicked];
+  Exclude(FControlState, csClicked);
   Case Message.CharCode of
     32:
       begin
Index: include/control.inc
===================================================================
--- include/control.inc (wersja 9143)
+++ include/control.inc (kopia robocza)
@@ -1805,7 +1805,7 @@
   if csClicked in ControlState then
   begin
     Exclude(FControlState, csClicked);
-    //DebugLn('TControl.WMLButtonUp B 
',ClientRect.Left,',',ClientRect.Top,',',ClientRect.Right,',',ClientRect.Bottom,'
 ',Message.Pos.X,',',Message.Pos.Y);
+    //DebugLn('TControl.WMLButtonUp B 
',dbgs(ClientRect.Left),',',dbgs(ClientRect.Top),',',dbgs(ClientRect.Right),',',dbgs(ClientRect.Bottom),'
 ',dbgs(Message.Pos.X),',',dbgs(Message.Pos.Y));
     if PtInRect(ClientRect, SmallPointToPoint(Message.Pos))
     then begin
       //DebugLn('TControl.WMLButtonUp C');
Index: include/application.inc
===================================================================
--- include/application.inc     (wersja 9143)
+++ include/application.inc     (kopia robocza)
@@ -407,9 +407,15 @@
   P: TPoint;
 begin
   GetCursorPos(P);
-  Result := FindControlAtPosition(P, True);
+  if (P.X=FLastMousePos.x) and (P.Y=FLastMousePos.Y) then 
Result:=FLastMouseControl
+  else    Result := FindControlAtPosition(P, True);
+  
   if (Result <> nil) and (csDesigning in Result.ComponentState) then
     Result := nil;
+  if Result<> nil then begin
+    FLastMousePos:=p;
+    FLastMouseControl:=Result;
+  end;
 end;
 
 procedure TApplication.SetNavigation(const AValue: 
TApplicationNavigationOptions

Reply via email to