mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 02:59:15 +02:00
Converted some gtk3 color stuff using GdkRGBA
git-svn-id: trunk@43665 -
This commit is contained in:
parent
be58776d84
commit
2c26fb1733
@ -338,8 +338,8 @@ function TColortoTGdkRGBA(const value: TColor): TGdkRGBA;
|
|||||||
begin
|
begin
|
||||||
Result.red := (value and $FF) / 255;
|
Result.red := (value and $FF) / 255;
|
||||||
Result.green := ((value shr 8) and $FF) / 255;
|
Result.green := ((value shr 8) and $FF) / 255;
|
||||||
Result.blue := ((value shr 16) and $FF) / 255;
|
Result.blue := 1.0;//((value shr 16) and $FF) / 255;
|
||||||
Result.alpha := ((value shr 24) and $FF) / 255;
|
Result.alpha := 1.0;//((value shr 24) and $FF) / 255;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ColorToCairoRGB(AColor: TColor; out ARed, AGreen, ABlue: Double): Boolean;
|
function ColorToCairoRGB(AColor: TColor; out ARed, AGreen, ABlue: Double): Boolean;
|
||||||
|
@ -79,12 +79,12 @@ type
|
|||||||
function GetCairoContext: Pcairo_t;
|
function GetCairoContext: Pcairo_t;
|
||||||
function GetEnabled: Boolean;
|
function GetEnabled: Boolean;
|
||||||
function GetFont: PPangoFontDescription;
|
function GetFont: PPangoFontDescription;
|
||||||
function GetStyle: PGtkStyle;
|
function GetStyleContext: PGtkStyleContext;
|
||||||
function GetVisible: Boolean;
|
function GetVisible: Boolean;
|
||||||
procedure SetEnabled(AValue: Boolean);
|
procedure SetEnabled(AValue: Boolean);
|
||||||
procedure SetFont(AValue: PPangoFontDescription);
|
procedure SetFont(AValue: PPangoFontDescription);
|
||||||
procedure SetStyle(AValue: PGtkStyle);
|
|
||||||
procedure SetVisible(AValue: Boolean);
|
procedure SetVisible(AValue: Boolean);
|
||||||
|
procedure SetStyleContext(AValue: PGtkStyleContext);
|
||||||
protected
|
protected
|
||||||
// IUnknown implementation
|
// IUnknown implementation
|
||||||
function QueryInterface(constref iid: TGuid; out obj): LongInt; {$IFDEF WINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
|
function QueryInterface(constref iid: TGuid; out obj): LongInt; {$IFDEF WINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
|
||||||
@ -171,7 +171,7 @@ type
|
|||||||
property FontColor: TColor read GetFontColor write SetFontColor;
|
property FontColor: TColor read GetFontColor write SetFontColor;
|
||||||
property KeysToEat: TByteSet read FKeysToEat write FKeysToEat;
|
property KeysToEat: TByteSet read FKeysToEat write FKeysToEat;
|
||||||
property PaintData: TPaintData read FPaintData write FPaintData;
|
property PaintData: TPaintData read FPaintData write FPaintData;
|
||||||
property Style: PGtkStyle read GetStyle write SetStyle;
|
property StyleContext: PGtkStyleContext read GetStyleContext write SetStyleContext;
|
||||||
property Text: String read getText write setText;
|
property Text: String read getText write setText;
|
||||||
property Visible: Boolean read GetVisible write SetVisible;
|
property Visible: Boolean read GetVisible write SetVisible;
|
||||||
property Widget: PGtkWidget read FWidget;
|
property Widget: PGtkWidget read FWidget;
|
||||||
@ -2259,11 +2259,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TGtk3Widget.GetStyle: PGtkStyle;
|
function TGtk3Widget.GetStyleContext: PGtkStyleContext;
|
||||||
begin
|
begin
|
||||||
Result := nil;
|
Result := nil;
|
||||||
if IsWidgetOK then
|
if IsWidgetOK then
|
||||||
Result := GetContainerWidget^.get_style;
|
Result := GetContainerWidget^.get_style_context;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TGtk3Widget.GetFont: PPangoFontDescription;
|
function TGtk3Widget.GetFont: PPangoFontDescription;
|
||||||
@ -2297,32 +2297,37 @@ end;
|
|||||||
|
|
||||||
function TGtk3Widget.GetFontColor: TColor;
|
function TGtk3Widget.GetFontColor: TColor;
|
||||||
var
|
var
|
||||||
AStyle: PGtkStyle;
|
AStyle: PGtkStyleContext;
|
||||||
|
AGdkRGBA: TGdkRGBA;
|
||||||
begin
|
begin
|
||||||
Result := clDefault;
|
Result := clDefault;
|
||||||
if IsWidgetOK then
|
if IsWidgetOK then
|
||||||
begin
|
begin
|
||||||
AStyle := GetStyle;
|
AStyle := GetStyleContext;
|
||||||
Result := TGDKColorToTColor(AStyle^.text[GTK_STATE_NORMAL]);
|
AStyle^.get_background_color(GTK_STATE_NORMAL, @AGdkRGBA);
|
||||||
|
Result := TGdkRGBAToTColor(AGdkRGBA);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TGtk3Widget.GetColor: TColor;
|
function TGtk3Widget.GetColor: TColor;
|
||||||
var
|
var
|
||||||
AStyle: PGtkStyle;
|
AStyle: PGtkStyleContext;
|
||||||
|
AColor: TGdkRGBA;
|
||||||
begin
|
begin
|
||||||
Result := clDefault;
|
Result := clDefault;
|
||||||
if IsWidgetOK then
|
if IsWidgetOK then
|
||||||
begin
|
begin
|
||||||
AStyle := GetStyle;
|
AStyle := GetStyleContext;
|
||||||
Result := TGDKColorToTColor(AStyle^.bg[GTK_STATE_NORMAL]);
|
AStyle^.get_background_color(GTK_STATE_NORMAL, @AColor);
|
||||||
|
Result := TGdkRGBAToTColor(AColor);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGtk3Widget.SetStyle(AValue: PGtkStyle);
|
procedure TGtk3Widget.SetStyleContext(AValue: PGtkStyleContext);
|
||||||
begin
|
begin
|
||||||
if IsWidgetOK then
|
{$NOTE Gtk3: Find a nice way to assign StyleContext}
|
||||||
GetContainerWidget^.set_style(AValue);
|
{if IsWidgetOK then
|
||||||
|
GetContainerWidget^.set_style(AValue);}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TGtk3Widget.getText: String;
|
function TGtk3Widget.getText: String;
|
||||||
@ -2858,20 +2863,23 @@ var
|
|||||||
AGdkRGBA: TGdkRGBA;
|
AGdkRGBA: TGdkRGBA;
|
||||||
AColor: TGdkColor;
|
AColor: TGdkColor;
|
||||||
begin
|
begin
|
||||||
inherited SetColor(AValue);
|
//inherited SetColor(AValue);
|
||||||
exit;
|
exit;
|
||||||
if (AValue = clDefault) or (AValue = clBackground) then
|
if (AValue = clDefault) or (AValue = clBackground) then
|
||||||
begin
|
begin
|
||||||
// this is just to test if we can get transparent panel again
|
// this is just to test if we can get transparent panel again
|
||||||
// clDefault must be extracted from style
|
// clDefault must be extracted from style
|
||||||
FWidget^.set_style(nil);
|
|
||||||
AColor := GetStyle^.bg[0];
|
// nil resets color to gtk default
|
||||||
|
FWidget^.override_background_color(GTK_STATE_FLAG_NORMAL, nil);
|
||||||
|
StyleContext^.get_background_color(GTK_STATE_FLAG_NORMAL, @AGdkRGBA);
|
||||||
|
|
||||||
// writeln('ACOLOR R=',AColor.Red,' G=',AColor.green,' B=',AColor.blue);
|
// writeln('ACOLOR R=',AColor.Red,' G=',AColor.green,' B=',AColor.blue);
|
||||||
// AColor := TColortoTGDKColor(AValue);
|
// AColor := TColortoTGDKColor(AValue);
|
||||||
AGdkRGBA.alpha := 0;
|
{AGdkRGBA.alpha := 0;
|
||||||
AGdkRGBA.red := AColor.red / 65535.00;
|
AGdkRGBA.red := AColor.red / 65535.00;
|
||||||
AGdkRGBA.blue := AColor.blue / 65535.00;
|
AGdkRGBA.blue := AColor.blue / 65535.00;
|
||||||
AGdkRGBA.green := AColor.red / 65535.00;
|
AGdkRGBA.green := AColor.red / 65535.00;}
|
||||||
FWidget^.override_background_color(GTK_STATE_FLAG_NORMAL, @AGdkRGBA);
|
FWidget^.override_background_color(GTK_STATE_FLAG_NORMAL, @AGdkRGBA);
|
||||||
FWidget^.override_background_color(GTK_STATE_FLAG_ACTIVE, @AGdkRGBA);
|
FWidget^.override_background_color(GTK_STATE_FLAG_ACTIVE, @AGdkRGBA);
|
||||||
FWidget^.override_background_color(GTK_STATE_FLAG_FOCUSED, @AGdkRGBA);
|
FWidget^.override_background_color(GTK_STATE_FLAG_FOCUSED, @AGdkRGBA);
|
||||||
@ -2881,7 +2889,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
AColor := TColortoTGDKColor(AValue);
|
AColor := TColortoTGDKColor(AValue);
|
||||||
// writeln('ACOLOR R=',AColor.Red,' G=',AColor.green,' B=',AColor.blue);
|
// writeln('ACOLOR R=',AColor.Red,' G=',AColor.green,' B=',AColor.blue);
|
||||||
inherited SetColor(AValue);
|
//inherited SetColor(AValue);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user