From f7f99f038eb0b0593501c3b84552fad3f9d30aef Mon Sep 17 00:00:00 2001 From: paul Date: Tue, 18 Dec 2007 02:57:49 +0000 Subject: [PATCH] implement border style for gtk TListBox and added generic way for setting border style for all scrollables git-svn-id: trunk@13363 - --- lcl/interfaces/gtk/gtkwsstdctrls.pp | 8 ++------ lcl/interfaces/gtk2/gtk2wscontrols.pp | 20 ++++++++++++++++++-- lcl/interfaces/gtk2/gtk2wsstdctrls.pp | 11 ++++++----- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/lcl/interfaces/gtk/gtkwsstdctrls.pp b/lcl/interfaces/gtk/gtkwsstdctrls.pp index 6b0aa44cc3..bb5e545302 100644 --- a/lcl/interfaces/gtk/gtkwsstdctrls.pp +++ b/lcl/interfaces/gtk/gtkwsstdctrls.pp @@ -36,7 +36,7 @@ uses GtkFontCache, Gtk1WSPrivate, {$ENDIF} InterfaceBase, WSStdCtrls, WSLCLClasses, WSProc, WSControls, - GtkInt, GtkDef, GTKWinApiWindow, gtkglobals, gtkproc, gtkExtra, GtkWSPrivate; + GtkInt, GtkDef, GTKWinApiWindow, GtkGlobals, GtkProc, GtkExtra, GtkWSPrivate; type @@ -639,11 +639,7 @@ var begin Handle := ACustomListBox.Handle; Widget:= PGtkWidget(PGtkBin(Handle)^.child); - if ACustomListBox.BorderStyle = TBorderStyle(bsSingle) - then - gtk_viewport_set_shadow_type(PGtkViewPort(Widget), GTK_SHADOW_IN) - else - gtk_viewport_set_shadow_type(PGtkViewPort(Widget), GTK_SHADOW_NONE); + gtk_viewport_set_shadow_type(PGtkViewPort(Widget), BorderStyleShadowMap[ACustomListBox.BorderStyle]); end; class procedure TGtkWSCustomListBox.SetItemIndex(const ACustomListBox: TCustomListBox; diff --git a/lcl/interfaces/gtk2/gtk2wscontrols.pp b/lcl/interfaces/gtk2/gtk2wscontrols.pp index eb98556372..2e84dd232b 100644 --- a/lcl/interfaces/gtk2/gtk2wscontrols.pp +++ b/lcl/interfaces/gtk2/gtk2wscontrols.pp @@ -35,9 +35,9 @@ uses //////////////////////////////////////////////////// Controls, //////////////////////////////////////////////////// - Gtk2, Gdk2, Glib2, + Gtk2, Gdk2, Glib2, GtkGlobals, GtkWsControls, - WSControls, WSLCLClasses; + WSControls, WSLCLClasses, WSProc; type @@ -66,6 +66,7 @@ type public class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override; class procedure SetText(const AWinControl: TWinControl; const AText: string); override; + class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override; end; { TGtk2WSGraphicControl } @@ -162,6 +163,21 @@ begin end; end; +class procedure TGtk2WSWinControl.SetBorderStyle( + const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); +var + Widget: PGtkWidget; +begin + if not WSCheckHandleAllocated(AWinControl, 'SetBorderStyle') + then Exit; + + Widget := PGtkWidget(AWinControl.Handle); + if GTK_IS_SCROLLED_WINDOW(Widget) then + gtk_scrolled_window_set_shadow_type(PGtkScrolledWindow(Widget), BorderStyleShadowMap[ABorderStyle]) + else + TWSWinControlClass(ClassParent).SetBorderStyle(AWinControl, ABorderStyle); +end; + initialization //////////////////////////////////////////////////// diff --git a/lcl/interfaces/gtk2/gtk2wsstdctrls.pp b/lcl/interfaces/gtk2/gtk2wsstdctrls.pp index 0f4e5154b0..85f02e32f9 100644 --- a/lcl/interfaces/gtk2/gtk2wsstdctrls.pp +++ b/lcl/interfaces/gtk2/gtk2wsstdctrls.pp @@ -427,8 +427,8 @@ end; class procedure TGtk2WSCustomListBox.SetBorder( const ACustomListBox: TCustomListBox); begin - // TODO - debugln('TGtk2WSCustomListBox.SetBorder TODO'); + gtk_scrolled_window_set_shadow_type(PGtkScrolledWindow(ACustomListBox.Handle), + BorderStyleShadowMap[ACustomListBox.BorderStyle]); end; class procedure TGtk2WSCustomListBox.SetItemIndex( @@ -533,8 +533,8 @@ var column : PGtkTreeViewColumn; WidgetInfo: PWidgetInfo; begin - Result := TGtkWSBaseScrollingWinControl.CreateHandle(AWinControl,AParams); - p:= PGtkWidget(Result); + Result := TGtkWSBaseScrollingWinControl.CreateHandle(AWinControl, AParams); + p := PGtkWidget(Result); if Result = 0 then exit; {$IFDEF DebugLCLComponents} @@ -545,7 +545,8 @@ begin GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(p)^.vscrollbar, GTK_CAN_FOCUS); gtk_scrolled_window_set_policy(PGtkScrolledWindow(p), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type(PGtkScrolledWindow(p),GTK_SHADOW_IN); + gtk_scrolled_window_set_shadow_type(PGtkScrolledWindow(p), + BorderStyleShadowMap[TCustomListBox(AWinControl).BorderStyle]); gtk_widget_show(p); liststore := gtk_list_store_new (2, [G_TYPE_STRING, G_TYPE_POINTER, nil]);