gtk2: implement color changing for TListView and TListBox (issue #0013914)

git-svn-id: trunk@20454 -
This commit is contained in:
paul 2009-06-05 17:19:11 +00:00
parent 6938b6b821
commit 00b1b0bbb3
4 changed files with 43 additions and 4 deletions

View File

@ -143,6 +143,7 @@ type
class function GetVisibleRowCount(const ALV: TCustomListView): Integer; override;
class procedure SetAllocBy(const ALV: TCustomListView; const AValue: Integer); override;
class procedure SetColor(const AWinControl: TWinControl); override;
class procedure SetDefaultItemHeight(const ALV: TCustomListView; const AValue: Integer); override;
class procedure SetHotTrackStyles(const ALV: TCustomListView; const AValue: TListHotTrackStyles); override;
class procedure SetHoverTime(const ALV: TCustomListView; const AValue: Integer); override;

View File

@ -1306,6 +1306,20 @@ begin
then Exit;
end;
class procedure TGtk2WSCustomListView.SetColor(const AWinControl: TWinControl);
var
AWidget: PGTKWidget;
begin
if not WSCheckHandleAllocated(AWinControl, 'SetColor') then
Exit;
AWidget := PGtkWidget(AWinControl.Handle);
AWidget := GetWidgetInfo(AWidget, True)^.CoreWidget;
Gtk2WidgetSet.SetWidgetColor(AWidget,
AWinControl.Font.Color,
AWinControl.Color,
[GTK_STATE_NORMAL, GTK_STATE_ACTIVE, GTK_STATE_PRELIGHT, GTK_STYLE_BASE]);
end;
class procedure TGtk2WSCustomListView.SetDefaultItemHeight(
const ALV: TCustomListView; const AValue: Integer);
begin

View File

@ -166,11 +166,16 @@ end;
class procedure TGtk2WSCustomMemo.SetColor(const AWinControl: TWinControl);
var
AWidget : PGTKWidget;
AWidget: PGTKWidget;
begin
AWidget:=PGtkWidget(AWinControl.Handle);
AWidget:=GetWidgetInfo(AWidget, True)^.CoreWidget;
Gtk2WidgetSet.SetWidgetColor(AWidget, AWinControl.font.color, AWinControl.color,[GTK_STATE_NORMAL,GTK_STATE_ACTIVE,GTK_STATE_PRELIGHT,GTK_STATE_SELECTED,GTK_STYLE_BASE]);
if not WSCheckHandleAllocated(AWinControl, 'SetColor') then
Exit;
AWidget := PGtkWidget(AWinControl.Handle);
AWidget := GetWidgetInfo(AWidget, True)^.CoreWidget;
Gtk2WidgetSet.SetWidgetColor(AWidget,
AWinControl.Font.Color,
AWinControl.Color,
[GTK_STATE_NORMAL, GTK_STATE_ACTIVE, GTK_STATE_PRELIGHT, GTK_STYLE_BASE]);
end;
class procedure TGtk2WSCustomMemo.SetFont(const AWinControl: TWinControl;

View File

@ -163,6 +163,7 @@ type
class procedure SelectItem(const ACustomListBox: TCustomListBox; AnIndex: integer; ASelected: boolean); override;
class procedure SetBorder(const ACustomListBox: TCustomListBox); override;
class procedure SetColor(const AWinControl: TWinControl); override;
class procedure SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); override;
class procedure SetSelectionMode(const ACustomListBox: TCustomListBox; const AExtendedSelect,
AMultiSelect: boolean); override;
@ -453,6 +454,20 @@ begin
BorderStyleShadowMap[ACustomListBox.BorderStyle]);
end;
class procedure TGtk2WSCustomListBox.SetColor(const AWinControl: TWinControl);
var
AWidget: PGTKWidget;
begin
if not WSCheckHandleAllocated(AWinControl, 'SetColor') then
Exit;
AWidget := PGtkWidget(AWinControl.Handle);
AWidget := GetWidgetInfo(AWidget, True)^.CoreWidget;
Gtk2WidgetSet.SetWidgetColor(AWidget,
AWinControl.Font.Color,
AWinControl.Color,
[GTK_STATE_NORMAL, GTK_STATE_ACTIVE, GTK_STATE_PRELIGHT, GTK_STYLE_BASE]);
end;
class procedure TGtk2WSCustomListBox.SetItemIndex(
const ACustomListBox: TCustomListBox; const AIndex: integer);
var
@ -1519,6 +1534,8 @@ var
WidgetInfo: PWidgetInfo;
Child: PGtkWidget; // can be GtkCellRenderer or GtkEntry
begin
if not WSCheckHandleAllocated(AWinControl, 'SetColor') then
Exit;
WidgetInfo := GetWidgetInfo(Pointer(AWinControl.Handle));
Child := GTK_BIN(WidgetInfo^.CoreWidget)^.child;
@ -1957,6 +1974,8 @@ class procedure TGtk2WSButton.SetColor(const AWinControl: TWinControl);
var
BtnWidget: PGTKWidget;
begin
if not WSCheckHandleAllocated(AWinControl, 'SetColor') then
Exit;
BtnWidget := PGTKWidget(GetButtonWidget(PGtkEventBox(AWinControl.Handle)));
Gtk2WidgetSet.SetWidgetColor(BtnWidget, clNone, AWinControl.Color,
[GTK_STATE_NORMAL,GTK_STATE_ACTIVE,GTK_STATE_PRELIGHT,GTK_STATE_SELECTED]);