Merged revision(s) 59111 #2ee72166e4, 59190-59191 #6febd8c78e-#6febd8c78e from trunk:

LCL-GTK2: Prevent flickering in TOpenGLControl. Turn DoubleBuffered off. Issue #33864, patch from accorp.
........
LCL-GTK3: Add typecasts for Color types. The code may still be wrong but can be tested with Range checks on.
........
LCL-GTK3: Fix menu radio group. Issue #34350, patch from Anton Kavalenka.
........

git-svn-id: branches/fixes_2_0@59200 -
This commit is contained in:
maxim 2018-09-30 22:41:14 +00:00
parent 4f6f135dbb
commit 30c3eb15e6
5 changed files with 34 additions and 13 deletions

View File

@ -275,6 +275,7 @@ type
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class function GetDoubleBuffered(const AWinControl: TWinControl): Boolean; override;
end;
@ -723,6 +724,11 @@ begin
TWSWinControlClass(ClassParent).DestroyHandle(AWinControl);
end;
class function TWSOpenGLControl.GetDoubleBuffered(const AWinControl: TWinControl): Boolean;
begin
Result := False;
end;
initialization
RegisterWSComponent(TCustomOpenGLControl,TWSOpenGLControl);

View File

@ -45,7 +45,7 @@ uses
LMessages, LCLProc, LCLIntf, LCLType, GraphType, GraphMath,
Graphics, Menus, Themes, Buttons, StdCtrls, CheckLst, ComCtrls, Spin, ExtCtrls,
LCLPlatformDef, InterfaceBase,
WSLCLClasses,
WSLCLClasses, WSControls,
Gtk2WinApiWindow, Gtk2Globals, Gtk2Proc, Gtk2Def, Gtk2FontCache, Gtk2Extra,
Gtk2MsgQueue;

View File

@ -138,7 +138,7 @@ begin
else Control := nil;
if (Control <> nil)
and Control.DoubleBuffered
and TWSWinControlClass(Control.WidgetSetClass).GetDoubleBuffered(Control)
and not GTK_WIDGET_DOUBLE_BUFFERED({%H-}PGTKWidget(Handle))
then begin
//DebugLn(['TGtk2WidgetSet.BeginPaint ',DbgSName(Control)]);
@ -2837,8 +2837,10 @@ begin
then Control := TWinControl(GetLCLObject({%H-}Pointer(Handle)))
else Control := nil;
If (Control <> nil) and (not GTK_WIDGET_DOUBLE_BUFFERED(({%H-}PGTKWidget(Handle)))) and (Control.DoubleBuffered) then
begin
if (Control <> nil)
and TWSWinControlClass(Control.WidgetSetClass).GetDoubleBuffered(Control)
and not GTK_WIDGET_DOUBLE_BUFFERED({%H-}PGTKWidget(Handle))
then begin
gdk_window_thaw_updates(TGtkDeviceContext(PS.HDC).Drawable);
gdk_window_end_paint (TGtkDeviceContext(PS.HDC).Drawable);
end;

View File

@ -4293,13 +4293,32 @@ begin
end;
function TGtk3MenuItem.CreateWidget(const Params: TCreateParams): PGtkWidget;
var
ndx:integer;
pmenu:TMenuItem;
pl:PGsList;
begin
FWidgetType := [wtWidget, wtMenuItem];
if MenuItem.Caption = cLineCaption then
Result := TGtkSeparatorMenuItem.new
else
if MenuItem.RadioItem and not MenuItem.HasIcon then
Result := TGtkRadioMenuItem.new(nil)
begin
Result := TGtkRadioMenuItem.new(nil);
if Assigned(menuItem.Parent) then
begin
ndx:=menuItem.Parent.IndexOf(MenuItem);
if (ndx>0) then
begin
pMenu:=menuItem.Parent.Items[ndx-1];
if (MenuItem.GroupIndex>0) and (pMenu.GroupIndex=MenuItem.GroupIndex) then
begin
pl:=PGtkRadioMenuItem(TGtk3MenuItem(pMenu.Handle).Widget)^.get_group;
PGtkRadioMenuItem(Result)^.set_group(pl);
end;
end;
end;
end
else
if MenuItem.IsCheckItem or MenuItem.HasIcon then
Result := TGtkCheckMenuItem.new

View File

@ -456,7 +456,7 @@ begin
else
APen.Style := psSolid;
end;
APen.Color := lopnColor;
APen.Color := TColor(lopnColor);
APen.Cosmetic := lopnWidth.X <= 0 ;
if not APen.Cosmetic then
APen.Width := lopnWidth.X;
@ -3524,12 +3524,6 @@ begin
end;
function TGtk3WidgetSet.SetBkColor(DC: HDC; Color: TColorRef): TColorRef;
var
ACairoPattern: Pcairo_pattern_t;
R: Double;
G: Double;
B: Double;
A: Double;
begin
{$IFDEF GTK3DEBUGNOTIMPLEMENTED}
// DebugLn('WARNING: TGtk3WidgetSet.SetBkColor not implemented ...');
@ -3538,7 +3532,7 @@ begin
if not IsValidDC(DC) then
exit;
Result := TGtk3DeviceContext(DC).CurrentBrush.Color;
TGtk3DeviceContext(DC).CurrentBrush.Color := ColorToRGB(Color);
TGtk3DeviceContext(DC).CurrentBrush.Color := TColor(ColorToRGB(TColor(Color)));
end;
function TGtk3WidgetSet.SetBkMode(DC: HDC; bkMode: Integer): Integer;