mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-30 22:42:39 +02:00
269 lines
11 KiB
ObjectPascal
269 lines
11 KiB
ObjectPascal
{ $Id$}
|
|
{
|
|
*****************************************************************************
|
|
* Gtk2WSComCtrls.pp *
|
|
* ----------------- *
|
|
* *
|
|
* *
|
|
*****************************************************************************
|
|
|
|
*****************************************************************************
|
|
* *
|
|
* This file is part of the Lazarus Component Library (LCL) *
|
|
* *
|
|
* See the file COPYING.LCL, included in this distribution, *
|
|
* for details about the copyright. *
|
|
* *
|
|
* This program is distributed in the hope that it will be useful, *
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
|
* *
|
|
*****************************************************************************
|
|
}
|
|
unit Gtk2WSComCtrls;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
interface
|
|
|
|
uses
|
|
// libs
|
|
GLib2, Gtk2, Gdk2, Gdk2pixbuf,
|
|
// LCL
|
|
ComCtrls, Classes, FPCAdds, LCLType, LMessages, Controls, Graphics, CommCtrl,
|
|
StdCtrls, LCLProc, ImgList, Math, Sysutils,
|
|
// widgetset
|
|
WSComCtrls, WSLCLClasses, WSProc,
|
|
// GtkWidgetset
|
|
GtkWSComCtrls,
|
|
GtkWSControls,
|
|
// interface
|
|
GtkDef, GtkProc;
|
|
|
|
type
|
|
// For simplified manipulation
|
|
// Use GetCommonTreeViewWidgets(PGtkTreeView, var TTVWidgets)
|
|
PTVWidgets = ^TTVWidgets;
|
|
TTVWidgets = record
|
|
ScrollingData: TBaseScrollingWinControlData;
|
|
MainView: PGtkWidget; // can be a GtkTreeView or GtkIconView. You have been Warned! :)
|
|
TreeModel: PGtkTreeModel;
|
|
TreeSelection: PGtkTreeSelection;
|
|
WidgetInfo: PWidgetInfo;
|
|
//this is created and destroyed as needed
|
|
//it only holds items which are about to be changed the list is emptied in Gtk2_ItemSelectionChanged
|
|
ItemCache: TStringList;
|
|
end;
|
|
|
|
type
|
|
|
|
{ TGtk2WSStatusBar }
|
|
|
|
TGtk2WSStatusBar = class(TGtkWSStatusBar)
|
|
private
|
|
protected
|
|
public
|
|
end;
|
|
|
|
{ TGtk2WSTabSheet }
|
|
|
|
TGtk2WSTabSheet = class(TGtkWSTabSheet)
|
|
private
|
|
protected
|
|
public
|
|
end;
|
|
|
|
{ TGtk2WSPageControl }
|
|
|
|
TGtk2WSPageControl = class(TGtkWSPageControl)
|
|
private
|
|
protected
|
|
public
|
|
end;
|
|
|
|
{ TGtk2WSCustomListView }
|
|
|
|
TGtk2WSCustomListView = class(TGtkWSCustomListView)
|
|
private
|
|
class function IsIconView(const ALV: TCustomListView): Boolean; virtual;
|
|
// needed when adding or removing columns to a list store
|
|
class procedure ReCreateListStore(const ALV: TCustomListView;const TVWidgets: PTVWidgets); virtual;
|
|
class procedure ReCreateItems(const ALV: TCustomListView); virtual;
|
|
class procedure SetPropertyInternal(const ALV: TCustomListView; const Widgets: PTVWidgets; const AProp: TListViewProperty; const AIsSet: Boolean);
|
|
protected
|
|
class procedure SetCallbacks(const AScrollWidget: PGtkWidget; const Widgets: PTVWidgets; const AWidgetInfo: PWidgetInfo); virtual;
|
|
public
|
|
// columns
|
|
class procedure ColumnDelete(const ALV: TCustomListView; const AIndex: Integer); override;
|
|
class function ColumnGetWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn): Integer; override;
|
|
class procedure ColumnInsert(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn); override;
|
|
class procedure ColumnMove(const ALV: TCustomListView; const AOldIndex, ANewIndex: Integer; const AColumn: TListColumn); override;
|
|
class procedure ColumnSetAlignment(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AAlignment: TAlignment); override;
|
|
class procedure ColumnSetAutoSize(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AAutoSize: Boolean); override;
|
|
class procedure ColumnSetCaption(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const ACaption: String); override;
|
|
class procedure ColumnSetImage(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AImageIndex: Integer); override;
|
|
class procedure ColumnSetMaxWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AMaxWidth: Integer); override;
|
|
class procedure ColumnSetMinWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AMinWidth: integer); override;
|
|
class procedure ColumnSetWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AWidth: Integer); override;
|
|
class procedure ColumnSetVisible(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AVisible: Boolean); override;
|
|
|
|
// items
|
|
class procedure ItemDelete(const ALV: TCustomListView; const AIndex: Integer); override;
|
|
class function ItemGetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; var AIsSet: Boolean): Boolean; override; // returns True if supported
|
|
class procedure ItemInsert(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem); override;
|
|
class procedure ItemSetImage(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex, AImageIndex: Integer); override;
|
|
class procedure ItemSetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; const AIsSet: Boolean); override;
|
|
class procedure ItemSetText(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex: Integer; const AText: String); override;
|
|
class procedure ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const PartialOK: Boolean); override;
|
|
|
|
// lv
|
|
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND; override;
|
|
|
|
class procedure BeginUpdate(const ALV: TCustomListView); override;
|
|
class procedure EndUpdate(const ALV: TCustomListView); override;
|
|
|
|
class function GetBoundingRect(const ALV: TCustomListView): TRect; override;
|
|
class function GetDropTarget(const ALV: TCustomListView): Integer; override;
|
|
class function GetFocused(const ALV: TCustomListView): Integer; override;
|
|
class function GetHoverTime(const ALV: TCustomListView): Integer; override;
|
|
class function GetSelCount(const ALV: TCustomListView): Integer; override;
|
|
class function GetSelection(const ALV: TCustomListView): Integer; override;
|
|
class function GetTopItem(const ALV: TCustomListView): Integer; override;
|
|
class function GetVisibleRowCount(const ALV: TCustomListView): Integer; override;
|
|
|
|
class procedure SetAllocBy(const ALV: TCustomListView; const AValue: Integer); 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;
|
|
// class procedure SetIconOptions(const ALV: TCustomListView; const AValue: TIconOptions); override;
|
|
class procedure SetImageList(const ALV: TCustomListView; const AList: TListViewImageList; const AValue: TCustomImageList); override;
|
|
class procedure SetProperty(const ALV: TCustomListView; const AProp: TListViewProperty; const AIsSet: Boolean); override;
|
|
class procedure SetProperties(const ALV: TCustomListView; const AProps: TListViewProperties); override;
|
|
class procedure SetScrollBars(const ALV: TCustomListView; const AValue: TScrollStyle); override;
|
|
class procedure SetScrolledLeft(const ALV: TCustomListView; const AValue: Integer); override;
|
|
class procedure SetScrolledTop(const ALV: TCustomListView; const AValue: Integer); override;
|
|
class procedure SetSort(const ALV: TCustomListView; const AType: TSortType; const AColumn: Integer); override;
|
|
class procedure SetViewStyle(const ALV: TCustomListView; const Avalue: TViewStyle); override;
|
|
end;
|
|
|
|
{ TGtk2WSListView }
|
|
|
|
TGtk2WSListView = class(TGtkWSListView)
|
|
private
|
|
protected
|
|
public
|
|
end;
|
|
|
|
{ TGtk2WSProgressBar }
|
|
|
|
TGtk2WSProgressBar = class(TGtkWSProgressBar)
|
|
private
|
|
protected
|
|
public
|
|
end;
|
|
|
|
{ TGtk2WSCustomUpDown }
|
|
|
|
TGtk2WSCustomUpDown = class(TGtkWSCustomUpDown)
|
|
private
|
|
protected
|
|
public
|
|
end;
|
|
|
|
{ TGtk2WSUpDown }
|
|
|
|
TGtk2WSUpDown = class(TGtkWSUpDown)
|
|
private
|
|
protected
|
|
public
|
|
end;
|
|
|
|
{ TGtk2WSToolButton }
|
|
|
|
TGtk2WSToolButton = class(TGtkWSToolButton)
|
|
private
|
|
protected
|
|
public
|
|
end;
|
|
|
|
{ TGtk2WSToolBar }
|
|
|
|
TGtk2WSToolBar = class(TGtkWSToolBar)
|
|
private
|
|
protected
|
|
public
|
|
end;
|
|
|
|
{ TGtk2WSTrackBar }
|
|
|
|
TGtk2WSTrackBar = class(TGtkWSTrackBar)
|
|
private
|
|
protected
|
|
public
|
|
end;
|
|
|
|
{ TGtk2WSCustomTreeView }
|
|
|
|
TGtk2WSCustomTreeView = class(TGtkWSCustomTreeView)
|
|
private
|
|
protected
|
|
public
|
|
end;
|
|
|
|
{ TGtk2WSTreeView }
|
|
|
|
TGtk2WSTreeView = class(TGtkWSTreeView)
|
|
private
|
|
protected
|
|
public
|
|
end;
|
|
|
|
|
|
implementation
|
|
|
|
// Will be used commonly for ListViews and TreeViews
|
|
procedure GetCommonTreeViewWidgets(ATreeViewHandle: PGtkWidget; var TVWidgets: PTVWidgets);
|
|
var
|
|
WidgetInfo: PWidgetInfo;
|
|
begin
|
|
WidgetInfo := GetWidgetInfo(ATreeViewHandle);
|
|
TVWidgets := PTVWidgets(WidgetInfo^.UserData);
|
|
end;
|
|
|
|
function AlignToGtkAlign(Align: TAlignment): gfloat;
|
|
begin
|
|
case Align of
|
|
taLeftJustify : AlignToGtkAlign := 0.0;
|
|
taCenter : AlignToGtkAlign := 0.5;
|
|
taRightJustify: AlignToGtkAlign := 1.0;
|
|
end;
|
|
end;
|
|
|
|
{$I gtk2wscustomlistview.inc}
|
|
|
|
initialization
|
|
|
|
////////////////////////////////////////////////////
|
|
// I M P O R T A N T
|
|
////////////////////////////////////////////////////
|
|
// To improve speed, register only classes
|
|
// which actually implement something
|
|
////////////////////////////////////////////////////
|
|
// RegisterWSComponent(TCustomStatusBar, TGtk2WSStatusBar);
|
|
// RegisterWSComponent(TCustomTabSheet, TGtk2WSTabSheet);
|
|
// RegisterWSComponent(TCustomPageControl, TGtk2WSPageControl);
|
|
RegisterWSComponent(TCustomListView, TGtk2WSCustomListView);
|
|
// RegisterWSComponent(TCustomListView, TGtk2WSListView);
|
|
// RegisterWSComponent(TCustomProgressBar, TGtk2WSProgressBar);
|
|
// RegisterWSComponent(TCustomUpDown, TGtk2WSCustomUpDown);
|
|
// RegisterWSComponent(TCustomUpDown, TGtk2WSUpDown);
|
|
// RegisterWSComponent(TCustomToolButton, TGtk2WSToolButton);
|
|
// RegisterWSComponent(TCustomToolBar, TGtk2WSToolBar);
|
|
// RegisterWSComponent(TCustomToolButton, TGtk2WSToolButton);
|
|
// RegisterWSComponent(TCustomToolBar, TGtk2WSToolBar);
|
|
// RegisterWSComponent(TCustomTrackBar, TGtk2WSTrackBar);
|
|
// RegisterWSComponent(TCustomTreeView, TGtk2WSCustomTreeView);
|
|
// RegisterWSComponent(TCustomTreeView, TGtk2WSTreeView);
|
|
////////////////////////////////////////////////////
|
|
end.
|