cxstylesheetsload.pas
来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 471 行 · 第 1/2 页
PAS
471 行
{********************************************************************}
{ }
{ Developer Express Visual Component Library }
{ Express Cross Platform Library classes }
{ }
{ Copyright (c) 2000-2008 Developer Express Inc. }
{ ALL RIGHTS RESERVED }
{ }
{ The entire contents of this file is protected by U.S. and }
{ International Copyright Laws. Unauthorized reproduction, }
{ reverse-engineering, and distribution of all or any portion of }
{ the code contained in this file is strictly prohibited and may }
{ result in severe civil and criminal penalties and will be }
{ prosecuted to the maximum extent possible under the law. }
{ }
{ RESTRICTIONS }
{ }
{ THIS SOURCE CODE AND ALL RESULTING INTERMEDIATE FILES }
{ (DCU, OBJ, DLL, ETC.) ARE CONFIDENTIAL AND PROPRIETARY TRADE }
{ SECRETS OF DEVELOPER EXPRESS INC. THE REGISTERED DEVELOPER IS }
{ LICENSED TO DISTRIBUTE THE EXPRESSCROSSPLATFORMLIBRARY AND ALL }
{ ACCOMPANYING VCL CONTROLS AS PART OF AN EXECUTABLE PROGRAM }
{ ONLY. }
{ }
{ THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED }
{ FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE }
{ COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE }
{ AVAILABLE TO OTHER INDIVIDUALS WITHOUT EXPRESS WRITTEN CONSENT }
{ AND PERMISSION FROM DEVELOPER EXPRESS INC. }
{ }
{ CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON }
{ ADDITIONAL RESTRICTIONS. }
{ }
{********************************************************************}
unit cxStyleSheetsLoad;
{$I cxVer.inc}
interface
uses
{$IFDEF DELPHI6}
Variants,
{$ENDIF}
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,
cxClasses, cxStyles, ExtCtrls, cxStyleSheetEditor;
type
TcxPredefinedStyleSheetsClass = class of TcxPredefinedStyleSheets;
TcxPredefinedStyleSheets = class
private
FList: TList;
protected
procedure AddStyleSheet(AStyleSheet: TcxCustomStyleSheet);
procedure AddStyleSheets; virtual; abstract;
public
constructor Create; virtual;
destructor Destroy; override;
procedure GetStyleSheetsByClass(AStyleSheetClass: TcxCustomStyleSheetClass; const AList: TList);
end;
TcxPredefinedStyleSheetsList = class
private
FList: TList;
FStyleSheetClassComboBox: TComboBox;
FStyleSheetsListBox: TListBox;
FLoadButton: TButton;
FPreview: TcxStyleSheetEditorPreview;
procedure StyleSheetClassComboBoxClick(Sender: TObject);
procedure StyleSheetsListBoxClick(Sender: TObject);
protected
procedure FreeAndNilItems;
procedure UpdateButton;
public
constructor Create(AStyleSheetClassComboBox: TComboBox; AStyleSheetsListBox: TListBox;
ALoadButton: TButton);
destructor Destroy; override;
function CurrentStyleSheet: TcxCustomStyleSheet;
function CurrentStyleSheetClass: TcxCustomStyleSheetClass;
procedure FillListBox;
end;
TfrmcxStyleSheetsLoad = class(TForm)
pnlBottom: TPanel;
Bevel: TBevel;
pnlStyles: TPanel;
pnlStyleSheetClasses: TPanel;
lbStyleSheetClass: TLabel;
cbStyleSheetClasses: TComboBox;
lbStyleSheets: TListBox;
pnlPreview: TPanel;
pnlClient: TPanel;
btnLoad: TButton;
btnClose: TButton;
Panel2: TPanel;
Panel1: TPanel;
Panel3: TPanel;
lbPreview: TLabel;
pnlPreviewClient: TPanel;
procedure FormCreate(Sender: TObject);
public
constructor Create(AOwner: TComponent); override;
function CurrentStyleSheetClass: TcxCustomStyleSheetClass;
procedure SetShowPreview(Value: Boolean);
end;
procedure RegisterPredefinedStyleSheets(APredefinedStyleSheetsClass: TcxPredefinedStyleSheetsClass);
procedure UnregisterPredefinedStyleSheets(APredefinedStyleSheetsClass: TcxPredefinedStyleSheetsClass);
procedure GetPredefinedStyleSheetClasses(AList: TList);
procedure ShowLoadStyleSheetsFromIniFile(const AIniFileName: string;
AStyleRepository: TcxStyleRepository; AOwner: TComponent; const AStyleSheetList: TList;
AStyleGetName: TcxStyleGetName);
procedure ShowLoadStyleSheetsFromPreDefineStyles(AStyleRepository: TcxStyleRepository;
AOwner: TComponent; const AStyleSheetList: TList; AStyleGetName: TcxStyleGetName);
implementation
{$R *.dfm}
uses
IniFiles;
var
FPredefinedStyleSheetsList: TList = nil;
procedure RegisterPredefinedStyleSheets(APredefinedStyleSheetsClass: TcxPredefinedStyleSheetsClass);
begin
if FPredefinedStyleSheetsList = nil then
FPredefinedStyleSheetsList := TList.Create;
if FPredefinedStyleSheetsList.IndexOf(TObject(APredefinedStyleSheetsClass)) = -1 then
FPredefinedStyleSheetsList.Add(TObject(APredefinedStyleSheetsClass));
end;
procedure UnregisterPredefinedStyleSheets(APredefinedStyleSheetsClass: TcxPredefinedStyleSheetsClass);
begin
if FPredefinedStyleSheetsList <> nil then
begin
FPredefinedStyleSheetsList.Remove(TObject(APredefinedStyleSheetsClass));
if FPredefinedStyleSheetsList.Count = 0 then
FreeAndNil(FPredefinedStyleSheetsList);
end;
end;
procedure GetPredefinedStyleSheetClasses(AList: TList);
begin
CopyList(FPredefinedStyleSheetsList, AList);
end;
{ TcxPredefinedStyleSheets }
constructor TcxPredefinedStyleSheets.Create;
begin
inherited;
FList := TList.Create;
end;
destructor TcxPredefinedStyleSheets.Destroy;
begin
FList.Free;
inherited;
end;
procedure TcxPredefinedStyleSheets.GetStyleSheetsByClass(AStyleSheetClass: TcxCustomStyleSheetClass;
const AList: TList);
var
I: Integer;
begin
for I := 0 to FList.Count - 1 do
if TcxCustomStyleSheetClass(TcxCustomStyleSheet(FList[I]).ClassType) = AStyleSheetClass then
AList.Add(FList[I]);
end;
procedure TcxPredefinedStyleSheets.AddStyleSheet(AStyleSheet: TcxCustomStyleSheet);
begin
if FList.IndexOf(AStyleSheet) = -1 then
FList.Add(AStyleSheet);
end;
{ TcxPredefinedStyleSheetsList }
constructor TcxPredefinedStyleSheetsList.Create(AStyleSheetClassComboBox: TComboBox;
AStyleSheetsListBox: TListBox; ALoadButton: TButton);
var
I: Integer;
begin
inherited Create;
FList := TList.Create;
FStyleSheetClassComboBox := AStyleSheetClassComboBox;
FStyleSheetsListBox := AStyleSheetsListBox;
FLoadButton := ALoadButton;
FStyleSheetClassComboBox.OnClick := StyleSheetClassComboBoxClick;
FStyleSheetsListBox.OnClick := StyleSheetsListBoxClick;
if FPredefinedStyleSheetsList <> nil then
for I := 0 to FPredefinedStyleSheetsList.Count - 1 do
FList.Add(TcxPredefinedStyleSheetsClass(FPredefinedStyleSheetsList[I]).Create);
end;
destructor TcxPredefinedStyleSheetsList.Destroy;
begin
FreeAndNil(FPreview);
FreeAndNilItems;
inherited;
end;
function TcxPredefinedStyleSheetsList.CurrentStyleSheet: TcxCustomStyleSheet;
begin
with FStyleSheetsListBox do
if ItemIndex > -1 then
Result := TcxCustomStyleSheet(Items.Objects[ItemIndex])
else
Result := nil;
end;
function TcxPredefinedStyleSheetsList.CurrentStyleSheetClass: TcxCustomStyleSheetClass;
begin
with FStyleSheetClassComboBox do
if ItemIndex > - 1 then
Result := TcxCustomStyleSheetClass(Items.Objects[ItemIndex])
else
Result := nil;
end;
procedure TcxPredefinedStyleSheetsList.FillListBox;
var
AForm: TfrmcxStyleSheetsLoad;
AList: TList;
I: Integer;
StyleSheet: TcxCustomStyleSheet;
PreviewClass: TcxStyleSheetEditorPreviewClass;
begin
AForm := TfrmcxStyleSheetsLoad(GetParentForm(FStyleSheetsListBox));
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?