added clWindow for gtklistitem

git-svn-id: trunk@4834 -
This commit is contained in:
mattias 2003-11-23 13:13:35 +00:00
parent 5381346e72
commit f747e69c96
3 changed files with 88 additions and 20 deletions

View File

@ -519,6 +519,34 @@ begin
and gtk_type_is_a(gtk_class_get_type(gtk_object_get_class(Widget)), AType); and gtk_type_is_a(gtk_class_get_type(gtk_object_get_class(Widget)), AType);
end; end;
{------------------------------------------------------------------------------
function GetWidgetClassName(Widget: PGtkWidget): string;
Returns the gtk class name of Widget.
------------------------------------------------------------------------------}
function GetWidgetClassName(Widget: PGtkWidget): string;
var
AType: TGtkType;
ClassPGChar: Pgchar;
ClassLen: Integer;
begin
Result:='';
if (gtk_object_get_class(Widget)=nil) then begin
Result:='<Widget without class>';
exit;
end;
AType:=gtk_class_get_type(gtk_object_get_class(Widget));
ClassPGChar:=gtk_type_name(AType);
if ClassPGChar=nil then begin
Result:='<Widget without classname>';
exit;
end;
ClassLen:=strlen(ClassPGChar);
SetLength(Result,ClassLen);
if ClassLen>0 then
Move(ClassPGChar[0],Result[1],ClassLen);
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
function WidgetIsDestroyingHandle(Widget: PGtkWidget): boolean; function WidgetIsDestroyingHandle(Widget: PGtkWidget): boolean;
@ -937,12 +965,13 @@ var
Procedure EnsureAsGCValues; Procedure EnsureAsGCValues;
var var
AllocFG : Boolean; AllocFG : Boolean;
SyGCValues: TGdkGCValues; SysGCValues: TGdkGCValues;
begin begin
FreeGDIColor(GDIColor); FreeGDIColor(GDIColor);
SyGCValues:=GetSysGCValues(GDIColor^.ColorRef); SysGCValues:=GetSysGCValues(GDIColor^.ColorRef,
With SyGCValues do begin PGtkWidget(TDeviceContext(DC).Wnd));
BeginGDKErrorTrap; {$IFDEF DebugGDK}BeginGDKErrorTrap;{$ENDIF}
With SysGCValues do begin
gdk_gc_set_fill(GC, fill); gdk_gc_set_fill(GC, fill);
AllocFG := Foreground.Pixel = 0; AllocFG := Foreground.Pixel = 0;
If AllocFG then If AllocFG then
@ -950,9 +979,11 @@ var
True,True) True,True)
then begin then begin
writeln('NOTE: EnsureGCColor.EnsureAsGCValues gdk_colormap_alloc_color failed ', writeln('NOTE: EnsureGCColor.EnsureAsGCValues gdk_colormap_alloc_color failed ',
' Foreground=',
HexStr(Cardinal(Foreground.red),4),',', HexStr(Cardinal(Foreground.red),4),',',
HexStr(Cardinal(Foreground.green),4),',', HexStr(Cardinal(Foreground.green),4),',',
HexStr(Cardinal(Foreground.blue),4) HexStr(Cardinal(Foreground.blue),4),
' GDIColor^.ColorRef=',HexStr(Cardinal(GDIColor^.ColorRef),8)
); );
end; end;
gdk_gc_set_foreground(GC, @foreground); gdk_gc_set_foreground(GC, @foreground);
@ -973,21 +1004,21 @@ var
end; end;
If AllocFG then If AllocFG then
gdk_colormap_free_colors(GDK_Colormap_get_system, @Foreground,1); gdk_colormap_free_colors(GDK_Colormap_get_system, @Foreground,1);
EndGDKErrorTrap;
end; end;
{$IFDEF DebugGDK}EndGDKErrorTrap;{$ENDIF}
end; end;
Procedure EnsureAsColor; Procedure EnsureAsColor;
begin begin
AllocGDIColor(DC, GDIColor); AllocGDIColor(DC, GDIColor);
BeginGDKErrorTrap; {$IFDEF DebugGDK}BeginGDKErrorTrap;{$ENDIF}
If AsBackground then If AsBackground then
gdk_gc_set_background(GC, @(GDIColor^.Color)) gdk_gc_set_background(GC, @(GDIColor^.Color))
else begin else begin
gdk_gc_set_fill(GC, GDK_SOLID); gdk_gc_set_fill(GC, GDK_SOLID);
gdk_gc_set_foreground(GC, @(GDIColor^.Color)); gdk_gc_set_foreground(GC, @(GDIColor^.Color));
end; end;
EndGDKErrorTrap; {$IFDEF DebugGDK}EndGDKErrorTrap;{$ENDIF}
end; end;
begin begin
@ -1022,6 +1053,7 @@ begin
clHighlight, clHighlight,
clHighlightText, clHighlightText,
clBtnFace, clBtnFace,
clWindow,
clForm: clForm:
//often have a BK Pixmap //often have a BK Pixmap
If IsSolidBrush then If IsSolidBrush then
@ -1033,7 +1065,6 @@ begin
clBtnHighlight, clBtnHighlight,
clBtnText, clBtnText,
clInfoText, clInfoText,
clWindow,
clWindowText, clWindowText,
clMenuText, clMenuText,
clGrayText: clGrayText:
@ -4613,6 +4644,9 @@ begin
else else
If AnsiCompareText(WName,'menuitem')=0 then If AnsiCompareText(WName,'menuitem')=0 then
StyleObject^.Widget := GTK_MENU_ITEM_NEW StyleObject^.Widget := GTK_MENU_ITEM_NEW
else
If AnsiCompareText(WName,'list')=0 then
StyleObject^.Widget := GTK_LIST_NEW
else else
If AnsiCompareText(WName,'scrollbar')=0 then If AnsiCompareText(WName,'scrollbar')=0 then
StyleObject^.Widget := gtk_hscrollbar_new(nil)//can't dif. between Horiz/Vert. Styles StyleObject^.Widget := gtk_hscrollbar_new(nil)//can't dif. between Horiz/Vert. Styles
@ -4735,13 +4769,30 @@ begin
end; end;
{$EndIf} {$EndIf}
Function GetSysGCValues(Color : TColorRef) : TGDKGCValues; Function GetSysGCValues(Color: TColorRef;
ThemeWidget: PGtkWidget): TGDKGCValues;
// ThemeWidget can be nil
function GetWidgetWithBackgroundWindow(Widget: PGtkWidget): PGtkWidget;
// returns the gtk widget which has the background gdk window
var
WindowOwnerWidget: PGtkWidget;
begin
Result:=Widget;
if Result=nil then exit;
if Result^.window=nil then exit;
gdk_window_get_user_data(Result^.window,@WindowOwnerWidget);
Result:=WindowOwnerWidget;
if Result=nil then exit;
end;
var var
Style: PGTKStyle; Style: PGTKStyle;
GC: PGDKGC; GC: PGDKGC;
Pixmap: PGDKPixmap; Pixmap: PGDKPixmap;
SysColor: TColorRef; SysColor: TColorRef;
BaseColor: TColorRef; BaseColor: TColorRef;
Red, Green, Blue: byte;
begin begin
BaseColor := Color and $FF; BaseColor := Color and $FF;
@ -4753,9 +4804,10 @@ begin
SysColor := GetSysColor(BaseColor); SysColor := GetSysColor(BaseColor);
Result.Fill := GDK_Solid; Result.Fill := GDK_Solid;
Result.foreground.Red := RGB(0,GetRValue(SysColor),0); RedGreenBlue(TColor(SysColor),Red,Green,Blue);
Result.foreground.Green := RGB(0,GetGValue(SysColor),0); Result.foreground.Red:=gushort(Red) shl 8+Red;
Result.foreground.Blue := RGB(0,GetBValue(SysColor),0); Result.foreground.Green:=gushort(Green) shl 8+Green;
Result.foreground.Blue:=gushort(Blue) shl 8+Blue;
{$IfDef Disable_GC_SysColors} {$IfDef Disable_GC_SysColors}
exit; exit;
@ -4926,14 +4978,24 @@ begin
COLOR_WINDOW : COLOR_WINDOW :
begin begin
ThemeWidget:=GetWidgetWithBackgroundWindow(ThemeWidget);
if ThemeWidget<>nil then begin
if GtkWidgetIsA(ThemeWidget,GTK_LIST_ITEM_TYPE) then
Style:=GetStyle('list');
if Style=nil then
Style:=PGtkStyle(ThemeWidget^.thestyle);
end;
if Style=nil then
Style := GetStyle('default'); Style := GetStyle('default');
If Style = nil then If Style = nil then
exit; exit;
GC := Style^.base_gc[GTK_STATE_NORMAL]; GC := Style^.base_gc[GTK_STATE_NORMAL];
If GC = nil then begin If (GC = nil) then begin
Result.Fill := GDK_Solid; Result.Fill := GDK_Solid;
if Style^.base[GTK_STATE_NORMAL].Pixel<>0 then if Style^.base[GTK_STATE_NORMAL].Pixel<>0 then begin
Result.foreground := Style^.base[GTK_STATE_NORMAL]; Result.foreground := Style^.base[GTK_STATE_NORMAL];
Result.background := Style^.base[GTK_STATE_NORMAL];
end;
end end
else else
GDK_GC_Get_Values(GC, @Result); GDK_GC_Get_Values(GC, @Result);
@ -5539,6 +5601,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.228 2003/11/23 13:13:35 mattias
added clWindow for gtklistitem
Revision 1.227 2003/11/16 01:56:15 mattias Revision 1.227 2003/11/16 01:56:15 mattias
changed TMenuItem.Graphic to TMenuItem.Bitmap changed TMenuItem.Graphic to TMenuItem.Bitmap

View File

@ -255,6 +255,7 @@ function ComparePChar(P1, P2: PChar): boolean;
function FindChar(c: char; p:PChar; Max: integer): integer; function FindChar(c: char; p:PChar; Max: integer): integer;
function GtkWidgetIsA(Widget: PGtkWidget; AType: TGtkType): boolean; function GtkWidgetIsA(Widget: PGtkWidget; AType: TGtkType): boolean;
function GetWidgetClassName(Widget: PGtkWidget): string;
function WidgetIsDestroyingHandle(Widget: PGtkWidget): boolean; function WidgetIsDestroyingHandle(Widget: PGtkWidget): boolean;
procedure SetWidgetIsDestroyingHandle(Widget: PGtkWidget); procedure SetWidgetIsDestroyingHandle(Widget: PGtkWidget);
function ComponentIsDestroyingHandle(AWinControl: TWinControl): boolean; function ComponentIsDestroyingHandle(AWinControl: TWinControl): boolean;
@ -514,7 +515,7 @@ function LoadDefaultFontDesc: PPangoFontDescription;
function LoadDefaultFont: PGDKFont; function LoadDefaultFont: PGDKFont;
{$EndIf} {$EndIf}
Function GetSysGCValues(Color : TColorRef) : TGDKGCValues; Function GetSysGCValues(Color: TColorRef; ThemeWidget: PGtkWidget) : TGDKGCValues;
{$Ifdef GTK1} {$Ifdef GTK1}
function FontIsDoubleByteCharsFont(TheFont: PGdkFont): boolean; function FontIsDoubleByteCharsFont(TheFont: PGdkFont): boolean;

View File

@ -3278,15 +3278,14 @@ begin
SelectGDKBrushProps(DC); SelectGDKBrushProps(DC);
If not CurrentBrush^.IsNullBrush then begin If not CurrentBrush^.IsNullBrush then begin
DCOrigin:=GetDCOffset(TDeviceContext(DC)); DCOrigin:=GetDCOffset(TDeviceContext(DC));
//writeln('FillRect DC=',HexStr(Cardinal(DC),8),' Drawable',HexStr(Cardinal(Drawable),8));
if (CurrentBrush^.GDIBrushFill = GDK_SOLID) if (CurrentBrush^.GDIBrushFill = GDK_SOLID)
and (IsBackgroundColor(TColor(CurrentBrush^.GDIBrushColor.ColorRef))) and (IsBackgroundColor(TColor(CurrentBrush^.GDIBrushColor.ColorRef)))
then then begin
StyleFillRectangle(drawable, GC, StyleFillRectangle(drawable, GC,
CurrentBrush^.GDIBrushColor.ColorRef, CurrentBrush^.GDIBrushColor.ColorRef,
Rect.Left+DCOrigin.X, Rect.Top+DCOrigin.Y, Rect.Left+DCOrigin.X, Rect.Top+DCOrigin.Y,
Width, Height) Width, Height)
else end else
gdk_draw_rectangle(Drawable, GC, 1, gdk_draw_rectangle(Drawable, GC, 1,
Rect.Left+DCOrigin.X, Rect.Top+DCOrigin.Y, Rect.Left+DCOrigin.X, Rect.Top+DCOrigin.Y,
Width, Height); Width, Height);
@ -9061,6 +9060,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.301 2003/11/23 13:13:35 mattias
added clWindow for gtklistitem
Revision 1.300 2003/11/23 10:58:47 mattias Revision 1.300 2003/11/23 10:58:47 mattias
fixed de-associating TUpDown fixed de-associating TUpDown