diff --git a/ide/diffpatch.pas b/ide/diffpatch.pas index 4142fedd7e..ac89b2e972 100644 --- a/ide/diffpatch.pas +++ b/ide/diffpatch.pas @@ -616,6 +616,8 @@ begin // chomp empty lines at end fPart1.GetPrevLineExtends(Cur1); fPart2.GetPrevLineExtends(Cur2); + if (Cur1.LineNumber < 1) or (Cur2.LineNumber < 1) then + break; until not LinesAreEqual(Cur1,Cur2); end; end; diff --git a/lcl/buttons.pp b/lcl/buttons.pp index d4b650a6c3..21b485234f 100644 --- a/lcl/buttons.pp +++ b/lcl/buttons.pp @@ -289,9 +289,11 @@ type procedure AssignClient(AClient: TObject); override; procedure SetGroupIndex(Value: Integer); override; procedure SetChecked(Value: Boolean); override; + procedure SetImageIndex(Value: Integer); override; public function IsCheckedLinked: Boolean; override; function IsGroupIndexLinked: Boolean; override; + function IsImageIndexLinked: Boolean; override; end; { TCustomSpeedButton } diff --git a/lcl/filectrl.pp b/lcl/filectrl.pp index ce74e7ee1b..cd2b16ce07 100644 --- a/lcl/filectrl.pp +++ b/lcl/filectrl.pp @@ -62,6 +62,7 @@ Type procedure Loaded; override; function IndexOfFile(const AFilename: string): integer; procedure KeyUp(var Key: Word; Shift: TShiftState); override; + procedure SetItemIndex(AIndex: Integer); override; public constructor Create(TheOwner: TComponent); override; destructor Destroy; override; @@ -420,6 +421,12 @@ begin UpdateFileList; end; +procedure TCustomFileListbox.SetItemIndex(AIndex: Integer); +begin + inherited; + UpdateSelectedFileName; +end; + procedure TCustomFileListBox.SetFileName(const AValue: String); var i: Integer; diff --git a/lcl/grids.pas b/lcl/grids.pas index 24c62c6fc6..9e9a2ac86b 100644 --- a/lcl/grids.pas +++ b/lcl/grids.pas @@ -8433,6 +8433,9 @@ begin // high control coords (like GTK2) CellR := Bounds(-FEditor.Width-100, -FEditor.Height-100, CellR.Right-CellR.Left, CellR.Bottom-CellR.Top); + // Make sure to use the grid font, not that of the title (issue #38203). + Canvas.Font.Assign(Font); + if FEditorOptions and EO_AUTOSIZE = EO_AUTOSIZE then begin if (FEditor = FStringEditor) and (EditorBorderStyle = bsNone) then CellR := TWSCustomGridClass(WidgetSetClass). diff --git a/lcl/include/comboex.inc b/lcl/include/comboex.inc index de2af47554..98b4fdf04e 100644 --- a/lcl/include/comboex.inc +++ b/lcl/include/comboex.inc @@ -422,7 +422,7 @@ begin { do not call inherited ! } end; anyRect.Top:=(ARect.Top+ARect.Bottom-FTextHeight) div 2; anyRect.Bottom:=anyRect.Top+FTextHeight; - ThemeServices.DrawText(Canvas, aDetail, ItemsEx[Index].Caption, anyRect, aFlags, 0); + DrawText(Canvas.Handle, PChar(ItemsEx[Index].Caption), Length(ItemsEx[Index].Caption), anyRect, aFlags); end; procedure TCustomComboBoxEx.FontChanged(Sender: TObject); @@ -684,7 +684,7 @@ begin { do not call inherited ! } end; anyRect.Top:=(ARect.Top+ARect.Bottom-FTextHeight) div 2; anyRect.Bottom:=anyRect.Top+FTextHeight; - ThemeServices.DrawText(Canvas, aDetail, Items[Index], anyRect, aFlags, 0); + DrawText(Canvas.Handle, PChar(Items[Index]), Length(Items[Index]), anyRect, aFlags); end; procedure TCustomCheckCombo.DropDown; diff --git a/lcl/include/customcheckgroup.inc b/lcl/include/customcheckgroup.inc index 589cc95bfb..9e458b67cf 100644 --- a/lcl/include/customcheckgroup.inc +++ b/lcl/include/customcheckgroup.inc @@ -23,6 +23,7 @@ type procedure SaveCheckStates(out AStates: TByteDynArray); protected procedure Changed; override; + procedure InsertItem(Index: Integer; const S: string; O: TObject); override; public constructor Create(TheCheckGroup: TCustomCheckGroup); procedure Delete(AIndex: Integer); override; @@ -61,6 +62,24 @@ begin RestoreCheckStates(b); end; +procedure TCheckGroupStringList.InsertItem(Index: Integer; const S: string; O: TObject); +var + i: Integer; + b: TByteDynArray; +begin + if csLoading in FCheckGroup.ComponentState then + inherited + else begin + SaveCheckStates(b); + inherited; + SetLength(b, Length(b)+1); + for i := High(b) downto Index+1 do + b[i] := b[i-1]; + b[Index] := 2; // default for new item: unchecked, enabled + RestoreCheckStates(b); + end; +end; + procedure TCheckGroupStringList.RestoreCheckStates(const AStates: TByteDynArray); var i: Integer; diff --git a/lcl/include/speedbutton.inc b/lcl/include/speedbutton.inc index 39e73ef8c5..151ce84949 100644 --- a/lcl/include/speedbutton.inc +++ b/lcl/include/speedbutton.inc @@ -1226,6 +1226,12 @@ begin (SpeedButton.GroupIndex = (Action as TCustomAction).GroupIndex); end; +function TSpeedButtonActionLink.IsImageIndexLinked: Boolean; +begin + Result := inherited IsImageIndexLinked and + (TSpeedButton(FClient).ImageIndex = (Action as TCustomAction).ImageIndex); +end; + procedure TSpeedButtonActionLink.SetGroupIndex(Value: Integer); begin if IsGroupIndexLinked then TCustomSpeedButton(FClient).GroupIndex := Value; @@ -1236,6 +1242,12 @@ begin if IsCheckedLinked then TCustomSpeedButton(FClient).Down := Value; end; +procedure TSpeedButtonActionLink.SetImageIndex(Value: Integer); +begin + if IsImageIndexLinked then + TSpeedButton(FClient).ImageIndex := Value; +end; + {$IFDEF ASSERT_IS_ON} {$UNDEF ASSERT_IS_ON} diff --git a/lcl/interfaces/gtk2/gtk2proc.inc b/lcl/interfaces/gtk2/gtk2proc.inc index cfd56415b4..f7739810fd 100644 --- a/lcl/interfaces/gtk2/gtk2proc.inc +++ b/lcl/interfaces/gtk2/gtk2proc.inc @@ -7603,7 +7603,7 @@ function CreateFormContents(AForm: TCustomForm; var FormWidget: Pointer; AWidgetInfo: PWidgetInfo = nil): Pointer; var ScrolledWidget, ClientAreaWidget: PGtkWidget; - WindowStyle: PGtkStyle; +// WindowStyle: PGtkStyle; Adjustment: PGtkAdjustment; begin // Create the VBox. We need that to place controls outside @@ -7620,8 +7620,10 @@ begin gtk_widget_show(ScrolledWidget); ClientAreaWidget := gtk_layout_new(nil, nil); - WindowStyle := GetStyle(lgsWindow); - gtk_widget_set_style(ClientAreaWidget, WindowStyle); + // issue #16183: not sure why the GtkLayout is given a GtkWindow style here, + // this prevents setting color to the GtkLayout +// WindowStyle := GetStyle(lgsWindow); +// gtk_widget_set_style(ClientAreaWidget, WindowStyle); //debugln('CreateFormContents Style=',GetStyleDebugReport(WindowStyle)); gtk_container_add(PGtkContainer(ScrolledWidget), ClientAreaWidget); diff --git a/lcl/interfaces/gtk2/gtk2widgetset.inc b/lcl/interfaces/gtk2/gtk2widgetset.inc index e8aa5019ba..44c12a47cf 100644 --- a/lcl/interfaces/gtk2/gtk2widgetset.inc +++ b/lcl/interfaces/gtk2/gtk2widgetset.inc @@ -2283,7 +2283,10 @@ begin if ChangeBGColor then begin - if (BGColor = clDefault) or (BGColor = clBtnFace) then + // setting bg color to nil will cancel previous calls to gtk_widget_modify_bg() + // cannot use nil on a GtkLayout (issue #16183) + if not GTK_IS_LAYOUT(AWidget) and + ((BGColor = clDefault) or (BGColor = clBtnFace)) then NewColor := nil else begin diff --git a/lcl/interfaces/gtk2/gtk2wsforms.pp b/lcl/interfaces/gtk2/gtk2wsforms.pp index 8f0c5519f1..103791b741 100644 --- a/lcl/interfaces/gtk2/gtk2wsforms.pp +++ b/lcl/interfaces/gtk2/gtk2wsforms.pp @@ -857,8 +857,27 @@ begin end; class procedure TGtk2WSCustomForm.SetColor(const AWinControl: TWinControl); +var + AScrolled: PGtkWidget; + AColor: TColor; begin TGtk2WSWinControl.SetColor(AWinControl); + + // Forms: GtkWindow->GtkVBox->gtkScrolledWindow->GtkLayout + // we need to set the color of the GtkLayout so that the whole viewport + // will be filled (issue #16183) + AScrolled := g_object_get_data({%H-}PGObject(AWinControl.Handle), odnScrollArea); + if GTK_IS_SCROLLED_WINDOW(AScrolled) and + GTK_IS_LAYOUT({%H-}PGtkBin(AScrolled)^.child) then + begin + AColor := AWinControl.Color; + if AColor = clDefault then + AColor := GetDefaultColor(AWinControl, dctBrush); + Gtk2WidgetSet.SetWidgetColor({%H-}PGtkBin(AScrolled)^.child, + clNone, AColor, + [GTK_STATE_NORMAL, GTK_STATE_ACTIVE, + GTK_STATE_PRELIGHT, GTK_STATE_SELECTED]); + end; end; class procedure TGtk2WSCustomForm.SetRealPopupParent( @@ -964,12 +983,20 @@ begin end; class procedure TGtk2WSScrollingWinControl.SetColor(const AWinControl: TWinControl); +var + AColor: TColor; begin if not WSCheckHandleAllocated(AWinControl, 'SetColor') then Exit; + // ScrollingWinControl: GtkScrolledWindow->GtkLayout + // we need to set the color of the GtkLayout so that the whole viewport + // will be filled (issue #16183) + AColor := AWinControl.Color; + if AColor = clDefault then + AColor := GetDefaultColor(AWinControl, dctBrush); Gtk2WidgetSet.SetWidgetColor({%H-}PGtkBin(AWinControl.Handle)^.child, - clNone, AWinControl.Color, + clNone, AColor, [GTK_STATE_NORMAL, GTK_STATE_ACTIVE, GTK_STATE_PRELIGHT, GTK_STATE_SELECTED]); end; diff --git a/lcl/widgetset/wsforms.pp b/lcl/widgetset/wsforms.pp index 151c288188..9f249658d0 100644 --- a/lcl/widgetset/wsforms.pp +++ b/lcl/widgetset/wsforms.pp @@ -50,6 +50,7 @@ type TWSScrollingWinControl = class(TWSWinControl) published // procedure ScrollBy is moved to TWSWinControl. + class function GetDefaultColor(const AControl: TControl; const ADefaultColorType: TDefaultColorType): TColor; override; end; { TWSScrollBox } @@ -139,6 +140,19 @@ type implementation +{ TWSScrollingWinControl } + +class function TWSScrollingWinControl.GetDefaultColor(const AControl: TControl; + const ADefaultColorType: TDefaultColorType): TColor; +const + DefColors: array[TDefaultColorType] of TColor = ( + { dctBrush } clForm, + { dctFont } clBtnText + ); +begin + Result := DefColors[ADefaultColorType]; +end; + { TWSCustomForm } class procedure TWSCustomForm.CloseModal(const ACustomForm: TCustomForm);