gtk1+2 intf: clean up from Andrew

git-svn-id: trunk@11268 -
This commit is contained in:
mattias 2007-06-02 14:02:18 +00:00
parent 5d8235febb
commit 2f1dea96f0
4 changed files with 20 additions and 123 deletions

View File

@ -142,10 +142,11 @@ type
Function GetCompStyle(Sender : TObject) : Longint; Virtual;
// create and destroy
{$IFDEF GTK1}
function CreateComboBox(ComboBoxObject: TObject): Pointer;
{$ENDIF}
function CreateAPIWidget(AWinControl: TWinControl): PGtkWidget;
function CreateForm(ACustomForm: TCustomForm): PGtkWidget; virtual;
function CreateListView(ListViewObject: TObject): PGtkWidget; virtual;
function CreatePairSplitter(PairSplitterObject: TObject): PGtkWidget;
function CreateStatusBar(StatusBar: TObject): PGtkWidget;
function OldCreateStatusBarPanel(StatusBar: TObject; Index: integer): PGtkWidget;

View File

@ -4530,6 +4530,7 @@ begin
InitializeCommonDialog(TCommonDialog(FontDialog),SelWidget);
end;
{$IFDEF GTK1}
{-------------------------------------------------------------------------------
function TGtkWidgetSet.CreateComboBox(ComboBoxObject: TObject): Pointer;
-------------------------------------------------------------------------------}
@ -4570,6 +4571,7 @@ begin
// MaxLength
gtk_entry_set_max_length(PGtkEntry(Widget^.entry),guint16(ComboBox.MaxLength));
end;
{$ENDIF}
procedure TGtkWidgetSet.FinishComponentCreate(const ALCLObject: TObject; const AGTKObject: Pointer);
@ -4764,88 +4766,6 @@ begin
end;
end;
function TGtkWidgetSet.CreateListView(ListViewObject: TObject): PGtkWidget;
var
MainWidget: PGtkWidget;
i: Integer;
CListWidget: PGtkCList;
ImpWidget: PGtkWidget;
RealColumnCnt: Integer;
Titles: PPGChar;
begin
MainWidget:= gtk_scrolled_window_new(nil, nil);
// with TListView(ListViewObject)
// do begin
// RealColumnCnt:=Columns.Count;
RealColumnCnt := 1;
// if RealColumnCnt<1 then RealColumnCnt:=1;
CListWidget:=PGtkCList(gtk_clist_new(RealColumnCnt));
gtk_clist_set_shadow_type(CListWidget,GTK_SHADOW_IN);
gtk_clist_column_titles_passive (CListWidget);
// add items (the item properties are set via LM_SETPROPERTIES)
GetMem(Titles,SizeOf(PGChar)*CListWidget^.columns);
for i:=0 to CListWidget^.columns-1 do
Titles[i]:=nil;
// for i:=0 to Items.Count-1 do begin
// if Items[i].Caption<>'' then
// Titles[0] := PChar(Items[i].Caption)
// else
// Titles[0] := #0;
// gtk_clist_append(CListWidget,Titles);
// end;
FreeMem(Titles);
// set columns properties
(*
for i := 0 to Columns.Count - 1 do begin
with Columns[i] do begin
// set title
gtk_clist_set_column_title(CListWidget,i, PChar(Caption));
//set column alignment
gtk_clist_set_column_justification(CListWidget,i,
aGTKJUSTIFICATION[Alignment]);
//set width
if Width>0 then
gtk_clist_set_column_width(CListWidget,i,Width);
//set auto sizing
gtk_clist_set_column_auto_resize(CListWidget,i, AutoSize);
//set Visible
gtk_clist_set_column_visibility(CListWidget,i, Visible);
// set MinWidth
if MinWidth>0 then
gtk_clist_set_column_min_width(CListWidget, i, MinWidth);
// set MaxWidth
if (MaxWidth>=MinWidth) and (MaxWidth>0) then
gtk_clist_set_column_max_width(CListWidget, i, MaxWidth);
end;
*)
// end;
// end;
gtk_clist_column_titles_passive (CListWidget);
ImpWidget:=PGtkWidget(CListWidget);
gtk_container_add(GTK_CONTAINER(MainWidget),ImpWidget);
GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(MainWidget)^.hscrollbar, GTK_CAN_FOCUS);
GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(MainWidget)^.vscrollbar, GTK_CAN_FOCUS);
gtk_scrolled_window_set_policy(PGtkScrolledWindow(MainWidget),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_container_set_focus_vadjustment(PGtkContainer(CListWidget),
gtk_scrolled_window_get_vadjustment(PGtkScrolledWindow(MainWidget)));
gtk_container_set_focus_hadjustment(PGtkContainer(CListWidget),
gtk_scrolled_window_get_hadjustment(PGtkScrolledWindow(MainWidget)));
gtk_widget_show_all(ImpWidget);
gtk_widget_show(MainWidget);
SetMainWidget(MainWidget, ImpWidget);
GetWidgetInfo(MainWidget, True)^.CoreWidget := ImpWidget;
Result:=MainWidget;
end;
{------------------------------------------------------------------------------
function TGtkWidgetSet.CreatePairSplitter(PairSplitterObject: TObject
): PGtkWidget;
@ -5106,9 +5026,10 @@ begin
'clicked', gtk_signal_func(@gtkDialogCancelclickedCB), Sender);
InitializeCommonDialog(TCommonDialog(Sender),p);
end;
{$IFDEF GTK1}
csComboBox :
p:=CreateComboBox(TComboBox(Sender));
{$ENDIF}
{$IfDef GTK1}
csEdit :
@ -5219,7 +5140,7 @@ begin
csListView :
Begin
p:=CreateListView(Sender);
DebugLn('[WARNING] Obsolete call to TGTKObject.CreateComponent for ', Sender.ClassName);
end;

View File

@ -73,6 +73,7 @@ type
private
protected
public
{$IFDEF GTK1}
class function GetSelStart(const ACustomComboBox: TCustomComboBox): integer; override;
class function GetSelLength(const ACustomComboBox: TCustomComboBox): integer; override;
class function GetItemIndex(const ACustomComboBox: TCustomComboBox): integer; override;
@ -92,6 +93,7 @@ type
class procedure Sort(const ACustomComboBox: TCustomComboBox; AList: TStrings; IsSorted: boolean); override;
class procedure SetColor(const AWinControl: TWinControl); override;
class procedure SetFont(const AWinControl: TWinControl; const AFont : tFont); override;
{$ENDIF}
end;
{ TGtkWSComboBox }
@ -108,6 +110,7 @@ type
private
protected
public
{$IFDEF GTK1}
class function GetSelCount(const ACustomListBox: TCustomListBox): integer; override;
class function GetSelected(const ACustomListBox: TCustomListBox; const AIndex: integer): boolean; override;
class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; override;
@ -122,6 +125,7 @@ type
class procedure SetTopIndex(const ACustomListBox: TCustomListBox; const NewTopIndex: integer); override;
class procedure SetColor(const AWinControl: TWinControl); override;
class procedure SetFont(const AWinControl: TWinControl; const AFont : tFont); override;
{$ENDIF}
end;
{ TGtkWSListBox }
@ -161,9 +165,9 @@ type
private
protected
public
{$ifdef GTK1}
class procedure AppendText(const ACustomMemo: TCustomMemo;
const AText: string); override;
{$ifdef GTK1}
class function GetStrings(const ACustomMemo: TCustomMemo): TStrings; override;
class procedure SetEchoMode(const ACustomEdit: TCustomEdit;
NewMode: TEchoMode); override;
@ -333,7 +337,7 @@ begin
end;
{ TGtkWSCustomListBox }
{$IFDEF GTK1}
class function TGtkWSCustomListBox.GetItemIndex(const ACustomListBox: TCustomListBox
): integer;
var
@ -561,36 +565,6 @@ end;
class procedure TGtkWSCustomListBox.SetTopIndex(
const ACustomListBox: TCustomListBox; const NewTopIndex: integer);
{$IFdef GTK2}
var
ScrolledWindow: PGtkScrolledWindow;
VertAdj: PGTKAdjustment;
AdjValue, MaxAdjValue: integer;
ListWidget: PGtkList;
AWidget: PGtkWidget;
GListItem: PGList;
ListItemWidget: PGtkWidget;
i: Integer;
begin
AWidget:=PGtkWidget(ACustomListBox.Handle);
ListWidget:=PGtkList(GetWidgetInfo(AWidget, True)^.CoreWidget);
ScrolledWindow:=PGtkScrolledWindow(AWidget);
AdjValue:=0;
GListItem:=ListWidget^.children;
i:=0;
while GListItem<>nil do begin
ListItemWidget:=PGtkWidget(GListItem^.data);
if i>=NewTopIndex then break;
inc(AdjValue,ListItemWidget^.Allocation.Height);
inc(i);
GListItem:=GListItem^.next;
end;
VertAdj:=gtk_scrolled_window_get_vadjustment(ScrolledWindow);
MaxAdjValue:=RoundToInt(VertAdj^.upper-VertAdj^.page_size);
if AdjValue>MaxAdjValue then AdjValue:=MaxAdjValue;
gtk_adjustment_set_value(VertAdj,AdjValue);
end;
{$Else}
var
ScrolledWindow: PGtkScrolledWindow;
VertAdj: PGTKAdjustment;
@ -627,7 +601,6 @@ begin
//DebugLn(['TGtkWSCustomListBox.SetTopIndex AdjValue=',AdjValue,' VertAdj^.upper=',VertAdj^.upper,' VertAdj^.page_size=',VertAdj^.page_size]);
gtk_adjustment_set_value(VertAdj,AdjValue);
end;
{$EndIf}
class procedure TGtkWSCustomListBox.SetColor(const AWinControl: TWinControl);
var
@ -668,9 +641,11 @@ begin
end;
end;
{$ENDIF}
{ TGtkWSCustomComboBox }
{$IFDEF GTK1}
class function TGtkWSCustomComboBox.GetSelStart(
const ACustomComboBox: TCustomComboBox): integer;
begin
@ -826,7 +801,7 @@ begin
GtkWidgetSet.SetWidgetFont(EntryWidget, AFont);
end;
end;
{$ENDIF}
{ TGtkWSCustomEdit }
@ -1019,6 +994,8 @@ end;
{ TGtkWSCustomMemo }
{$ifdef GTK1}
class procedure TGtkWSCustomMemo.AppendText(const ACustomMemo: TCustomMemo;
const AText: string);
var
@ -1038,8 +1015,6 @@ begin
gtk_text_thaw(PGtkText(Widget));
end;
{$ifdef GTK1}
class function TGtkWSCustomMemo.GetStrings(const ACustomMemo: TCustomMemo): TStrings;
var
Widget: PGtkText;

View File

@ -365,7 +365,7 @@ end;
class function TGtk2WSCustomListBox.GetTopIndex(
const ACustomListBox: TCustomListBox): integer;
begin
Result:=inherited GetTopIndex(ACustomListBox);
Result:=TGtk2WidgetSet(WidgetSet).GetListBoxIndexAtY(ACustomListBox, 0);
end;
class procedure TGtk2WSCustomListBox.SelectItem(