mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-11-04 05:59:49 +01:00 
			
		
		
		
	gtk intf: improved listbox SetTopIndex for newly added items
git-svn-id: trunk@10344 -
This commit is contained in:
		
							parent
							
								
									0fc3bea335
								
							
						
					
					
						commit
						6da5267421
					
				@ -3183,9 +3183,9 @@ var
 | 
			
		||||
                  if (UnitName='libc')
 | 
			
		||||
                  and (System.Pos(AppendPathDelim(FPCSrcDir)+'packages'+PathDelim,ADirPath)>0)
 | 
			
		||||
                  then begin
 | 
			
		||||
                    // <FPCSrcDir>/rtl/netwlibc/libc.pp
 | 
			
		||||
                    // <FPCSrcDir>/packages/base/libc/libc.pp
 | 
			
		||||
                    Priority:=2;
 | 
			
		||||
                    DebugLn(['BrowseDirectory OldFilename=',OldUnitLink.Filename,' Old.UsedMacroCount=',OldUnitLink.UsedMacroCount,' Old.MacroCount=',OldUnitLink.MacroCount,' Old.Priority=',OldUnitLink.Priority,
 | 
			
		||||
                      ' New=',AFilename,' New.MacroCount=',MacroCount,' New.UsedMacroCount=',UsedMacroCount,' New.Priority=',Priority]);
 | 
			
		||||
                  end;
 | 
			
		||||
                  if (UsedMacroCount>OldUnitLink.UsedMacroCount)
 | 
			
		||||
                  or ((UsedMacroCount=OldUnitLink.UsedMacroCount)
 | 
			
		||||
 | 
			
		||||
@ -9354,6 +9354,7 @@ var MaxMessages: integer;
 | 
			
		||||
  NewFilename: String;
 | 
			
		||||
begin
 | 
			
		||||
  Result:=false;
 | 
			
		||||
  
 | 
			
		||||
  MaxMessages:=MessagesView.VisibleItemCount;
 | 
			
		||||
  if Index>=MaxMessages then exit;
 | 
			
		||||
  if (Index<0) then begin
 | 
			
		||||
 | 
			
		||||
@ -279,8 +279,9 @@ begin
 | 
			
		||||
  FLastSelectedIndex := -1;
 | 
			
		||||
 | 
			
		||||
  Caption := lisMenuViewMessages;
 | 
			
		||||
  MessageListBox.Style       := lbOwnerDrawFixed;
 | 
			
		||||
  MessageListBox.OnDrawItem  := @MessageViewDrawItem;
 | 
			
		||||
  MessageListBox.Style := lbOwnerDrawFixed;
 | 
			
		||||
  MessageListBox.OnDrawItem := @MessageViewDrawItem;
 | 
			
		||||
  MessageListBox.ClickOnSelChange := false;
 | 
			
		||||
 | 
			
		||||
  // assign the root TMenuItem to the registered menu root.
 | 
			
		||||
  // This will automatically create all registered items
 | 
			
		||||
@ -397,6 +398,7 @@ begin
 | 
			
		||||
    FVisibleItems.Add(NewMsg);
 | 
			
		||||
    FLastLineIsProgress  := ProgressLine;
 | 
			
		||||
    MessageListBox.TopIndex := MessageListBox.Items.Count - 1;
 | 
			
		||||
    //DebugLn(['TMessagesView.Add ',MessageListBox.TopIndex]);
 | 
			
		||||
  end;
 | 
			
		||||
  //ConsistencyCheck;
 | 
			
		||||
end;
 | 
			
		||||
@ -525,8 +527,10 @@ end;
 | 
			
		||||
 | 
			
		||||
procedure TMessagesView.ShowTopMessage;
 | 
			
		||||
begin
 | 
			
		||||
  if MessageListBox.Items.Count > 0 then
 | 
			
		||||
  if MessageListBox.Items.Count > 0 then begin
 | 
			
		||||
    MessageListBox.TopIndex := 0;
 | 
			
		||||
    //DebugLn(['TMessagesView.ShowTopMessage ']);
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function TMessagesView.MsgCount: integer;
 | 
			
		||||
 | 
			
		||||
@ -568,7 +568,6 @@ var
 | 
			
		||||
  ListItemWidget: PGtkWidget;
 | 
			
		||||
  i: Integer;
 | 
			
		||||
begin
 | 
			
		||||
  DebugLn(['TGtkWSCustomListBox.SetTopIndex ',DbgSName(ACustomListBox),' NewTopIndex=',NewTopIndex,' ',GetWidgetDebugReport(PGtkWidget(ACustomListBox.Handle))]);
 | 
			
		||||
  AWidget:=PGtkWidget(ACustomListBox.Handle);
 | 
			
		||||
  ListWidget:=PGtkList(GetWidgetInfo(AWidget, True)^.CoreWidget);
 | 
			
		||||
  ScrolledWindow:=PGtkScrolledWindow(AWidget);
 | 
			
		||||
@ -597,6 +596,7 @@ var
 | 
			
		||||
  GListItem: PGList;
 | 
			
		||||
  ListItemWidget: PGtkWidget;
 | 
			
		||||
  i: Integer;
 | 
			
		||||
  requisition: TGtkRequisition;
 | 
			
		||||
begin
 | 
			
		||||
  //if CompareText(ACustomListBox.Name,'LBProperties')=0 then
 | 
			
		||||
  //  debugln('TGtkWSCustomListBox.SetTopIndex ',DbgSName(ACustomListBox));
 | 
			
		||||
@ -609,13 +609,16 @@ begin
 | 
			
		||||
  while GListItem<>nil do begin
 | 
			
		||||
    ListItemWidget:=PGtkWidget(GListItem^.data);
 | 
			
		||||
    if i>=NewTopIndex then break;
 | 
			
		||||
    inc(AdjValue,ListItemWidget^.Allocation.Height);
 | 
			
		||||
    gtk_widget_size_request(ListItemWidget,@requisition);
 | 
			
		||||
    inc(AdjValue,requisition.height);
 | 
			
		||||
    //DebugLn(['TGtkWSCustomListBox.SetTopIndex ',i,' AdjValue=',AdjValue,' Flags=',WidgetFlagsToString(ListItemWidget)]);
 | 
			
		||||
    inc(i);
 | 
			
		||||
    GListItem:=GListItem^.next;
 | 
			
		||||
  end;
 | 
			
		||||
  VertAdj:=gtk_scrolled_window_get_vadjustment(ScrolledWindow);
 | 
			
		||||
  MaxAdjValue:=RoundToInt(VertAdj^.upper-VertAdj^.page_size);
 | 
			
		||||
  MaxAdjValue:=RoundToInt(VertAdj^.upper);
 | 
			
		||||
  if AdjValue>MaxAdjValue then AdjValue:=MaxAdjValue;
 | 
			
		||||
  //DebugLn(['TGtkWSCustomListBox.SetTopIndex AdjValue=',AdjValue,' VertAdj^.upper=',VertAdj^.upper,' VertAdj^.page_size=',VertAdj^.page_size]);
 | 
			
		||||
  gtk_adjustment_set_value(VertAdj,AdjValue);
 | 
			
		||||
end;
 | 
			
		||||
{$EndIf}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user