📄 jvqcolorprovider.pas
字号:
{******************************************************************************}
{* WARNING: JEDI VCL To CLX Converter generated unit. *}
{* Manual modifications will be lost on next release. *}
{******************************************************************************}
{-----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1.1.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: JvColorProvider.pas, released on 2003-07-18.
The Initial Developer of the Original Code is Marcel Bestebroer
Portions created by Marcel Bestebroer are Copyright (C) 2002 - 2003 Marcel
Bestebroer
All Rights Reserved.
Contributor(s):
You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.sourceforge.net
Known Issues:
-----------------------------------------------------------------------------}
// $Id: JvQColorProvider.pas,v 1.21 2005/02/06 14:06:02 asnepvangers Exp $
unit JvQColorProvider;
{$I jvcl.inc}
interface
uses
QWindows, Classes, Contnrs, QGraphics, QDialogs,
JclBase,
JvQDataProvider, JvQDataProviderIntf, JvQTypes;
type
TJvColorProvider = class;
TJvColorProviderNameMappings = class;
TJvColorProviderNameMapping = class;
IJvColorProvider = interface;
TColorItem = record
Value: TColor;
Names: TDynStringArray;
end;
TColorItems = array of TColorItem;
TJvColorProviderMapping = type Integer;
TJvColorProviderAddItemLocation = (ailUseHeader, ailTop, ailBottom);
TJvColorProviderAddColorStyle = type Integer;
TColorGroupHeaderAlign = (ghaLeft, ghaCenter, ghaColorText);
TColorGroupHeaderStyle = (ghsBoldFont, ghsSingleCenterLine, ghsDoubleCenterLine);
TColorGroupHeaderStyles = set of TColorGroupHeaderStyle;
TJvColorProviderColorAdder = procedure(Provider: IJvColorProvider; ColorType: TColorType;
var Color: TColor; var DoAdd: Boolean);
TJvColorProviderAddColorEvent = procedure(Provider: TJvColorProvider; ColorType: TColorType;
var Color: TColor; var DoAdd: Boolean) of object;
IJvColorProvider = interface
['{3DF32721-553B-4759-A628-35F5CA62F3D5}']
procedure DoAddColor(ColorType: TColorType; var Color: TColor; var DoAdd: Boolean);
function AddColor(ColorType: TColorType; Color: TColor): Boolean;
function IndexOfMapping(Mapping: TJvColorProviderNameMapping): Integer;
function IndexOfMappingName(Name: string): Integer;
function Get_MappingCount: Integer;
function Get_Mapping(Index: Integer): TJvColorProviderNameMapping;
function AddMapping(AName: string): Integer;
function NewMapping: Integer;
procedure DeleteMapping(Index: Integer);
function GetStandardCount: Integer;
function GetSystemCount: Integer;
function GetCustomCount: Integer;
function GetStandardColor(Index: Integer; out Value: TColor; out Name: string): Boolean;
function GetSystemColor(Index: Integer; out Value: TColor; out Name: string): Boolean;
function GetCustomColor(Index: Integer; out Value: TColor; out Name: string): Boolean;
function FindColor(Value: TColor; out ColorType: TColorType; out Index: Integer): Boolean;
procedure SetStandardColorName(Index: Integer; NewName: string);
procedure SetSystemColorName(Index: Integer; NewName: string);
procedure SetCustomColorName(Index: Integer; NewName: string);
function AddStdColor(Value: TColor): Boolean;
procedure DeleteStdColor(Value: TColor);
procedure DeleteStdColorAt(Index: Integer);
procedure ClearStdColorList;
function AddSysColor(Value: TColor): Boolean;
procedure DeleteSysColor(Value: TColor);
procedure DeleteSysColorAt(Index: Integer);
procedure ClearSysColorList;
function AddCstColor(Value: TColor): Boolean;
procedure DeleteCstColor(Value: TColor);
procedure DeleteCstColorAt(Index: Integer);
procedure ClearCstColorList;
property MappingCount: Integer read Get_MappingCount;
property Mappings[Index: Integer]: TJvColorProviderNameMapping read Get_Mapping;
end;
IJvColorMappingProvider = interface
['{B6BA8036-8ECF-463B-BAD3-6855D4845F3F}']
function Get_ClientProvider: IJvColorProvider;
procedure Set_ClientProvider(Value: IJvColorProvider);
property ClientProvider: IJvColorProvider read Get_ClientProvider write Set_ClientProvider;
end;
IJvColorItem = interface
['{ED95EC41-EEE2-4E14-ABF6-5B7B5EA47FFF}']
function Get_Color: TColor;
property Color: TColor read Get_Color;
end;
IJvColorMapItem = interface
['{8906A180-71C0-4DF6-9029-5513B341541E}']
function Get_NameMapping: TJvColorProviderNameMapping;
property NameMapping: TJvColorProviderNameMapping read Get_NameMapping;
end;
TJvColorProvider = class(TJvCustomDataProvider, IJvColorProvider)
private
FColorList: TColorItems; // all colors the provider knows about
FStdColors: array of TDynIntegerArray; // list of standard colors for each context
FSysColors: array of TDynIntegerArray; // list of system colors for each context
FCstColors: array of TDynIntegerArray; // list of custom colors for each context
FMappings: TJvColorProviderNameMappings;
FColorListChanged: Boolean; // Flag to keep track of changes in FColorList w/resp. to the default
FOnAddColor: TJvColorProviderAddColorEvent;
protected
{ Notify any registered notifiers something is changing. For each notifier that is also a
consumer, that consumer will only be notified if it has the proper context. The settings
determine if either the GroupedItem or RootItem is specified as the Source. Any non-consumer
or consumers without a context or settings interface will receive the GroupedItem as the
Source parameter. }
procedure NotifyChanging(Reason: TDataProviderChangeReason; ContextIndex: Integer; GroupedItem,
RootItem: IUnknown);
{ Notify any registered notifiers something has changed. For each notifier that is also a
consumer, that consumer will only be notified if it has the proper context. The settings
determine if either the GroupedItem or RootItem is specified as the Source. Any non-consumer
or consumers without a context or settings interface will receive the GroupedItem as the
Source parameter. }
procedure NotifyChanged(Reason: TDataProviderChangeReason; ContextIndex: Integer; GroupedItem,
RootItem: IUnknown);
{ Notify all registered notifiers a color is being added to the specified group. }
procedure NotifyColorAdding(ColorType: TColorType; ContextIndex: Integer = -1);
{ Notify all registered notifiers a color has been added to the specified group. }
procedure NotifyColorAdded(ColorType: TColorType; ListIndex: Integer; ContextIndex: Integer = -1);
{ Notify all registered notifiers a color is being removed from the specified group. }
procedure NotifyColorDeleting(ColorType: TColorType; ListIndex: Integer; ContextIndex: Integer = -1);
{ Notify all registered notifiers a color has been removed to the specified group. }
procedure NotifyColorDeleted(ColorType: TColorType; ContextIndex: Integer = -1);
{ Notify all registered notifiers a color is being removed from the specified group. }
procedure NotifyColorsUpdating(ColorType: TColorType; ContextIndex: Integer = -1);
{ Notify all registered notifiers a color has been removed to the specified group. }
procedure NotifyColorsUpdated(ColorType: TColorType; ContextIndex: Integer = -1);
procedure DoAddColor(ColorType: TColorType; var Color: TColor; var DoAdd: Boolean);
function AddInternalColor(Color: TColor; AddToCustomDefaultList: Boolean): Integer;
function AddColor(var List: TDynIntegerArray; Color: TColor;
ColorType: TColorType; Context: Integer): Integer; overload;
function AddColor(var List: TDynIntegerArray; Color: TColor; ColorType: TColorType;
Context: Integer; out Added: Boolean): Integer; overload;
procedure DeleteColor(var List: TDynIntegerArray; Index: Integer; ColorType: TColorType;
Context: Integer);
procedure RemoveContextList(Index: Integer); virtual;
function IndexOfColor(Color: TColor): Integer;
function IndexOfColIdx(const List: TDynIntegerArray; ColorIndex: Integer): Integer;
procedure CopyFromDefCtx(const TargetContextIndex: Integer);
function SelectedContextIndex: Integer;
class function ItemsClass: TJvDataItemsClass; override;
class function ContextsClass: TJvDataContextsClass; override;
class function ContextsManagerClass: TJvDataContextsManagerClass; override;
function ConsumerClasses: TClassArray; override;
procedure ContextAdded(Context: IJvDataContext); override;
procedure ContextDestroying(Context: IJvDataContext); override;
procedure InsertMapping(var Strings: TDynStringArray; Index: Integer);
procedure DeleteMapping(var Strings: TDynStringArray; Index: Integer); overload;
procedure MappingAdding;
procedure MappingAdded(Index: Integer);
procedure MappingDestroying(Index: Integer);
procedure MappingDestroyed;
function GetColor(List, Index: Integer; out Value: TColor; out Name: string): Boolean;
procedure SetColorName(List, Index: Integer; const NewName: string);
function GetColorCount(List: Integer): Integer;
procedure GenDelphiConstantMapping;
procedure GenEnglishMapping;
procedure InitColorList(var List: TDynIntegerArray; const Definitions: array of TDefColorItem;
ColorType: TColorType);
procedure InitColors;
function GetMappings: TJvColorProviderNameMappings;
procedure DefineProperties(Filer: TFiler); override;
procedure ReadColors(Reader: TReader);
procedure WriteColors(Writer: TWriter);
procedure ReadMappings(Reader: TReader);
procedure WriteMappings(Writer: TWriter);
procedure ReadMapping(Reader: TReader);
procedure WriteMapping(Writer: TWriter; Index: Integer);
function GetColorItem(ColorType: TColorType; Index: Integer): IJvDataItem;
function GetColorItemByValue(ColorType: TColorType; Color: TColor): IJvDataItem;
property ColorListChanged: Boolean read FColorListChanged;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function AddColor(ColorType: TColorType; Color: TColor): Boolean; overload;
function IndexOfMapping(Mapping: TJvColorProviderNameMapping): Integer;
function IndexOfMappingName(Name: string): Integer;
function Get_MappingCount: Integer;
function Get_Mapping(Index: Integer): TJvColorProviderNameMapping;
function AddMapping(AName: string): Integer;
function NewMapping: Integer;
procedure DeleteMapping(Index: Integer); overload;
function GetStandardCount: Integer;
function GetSystemCount: Integer;
function GetCustomCount: Integer;
function GetStandardColor(Index: Integer; out Value: TColor; out Name: string): Boolean;
function GetSystemColor(Index: Integer; out Value: TColor; out Name: string): Boolean;
function GetCustomColor(Index: Integer; out Value: TColor; out Name: string): Boolean;
function FindColor(Value: TColor; out ColorType: TColorType; out Index: Integer): Boolean;
procedure SetStandardColorName(Index: Integer; NewName: string);
procedure SetSystemColorName(Index: Integer; NewName: string);
procedure SetCustomColorName(Index: Integer; NewName: string);
function AddStdColor(Value: TColor): Boolean;
procedure DeleteStdColor(Value: TColor);
procedure DeleteStdColorAt(Index: Integer);
procedure ClearStdColorList;
function AddSysColor(Value: TColor): Boolean;
procedure DeleteSysColor(Value: TColor);
procedure DeleteSysColorAt(Index: Integer);
procedure ClearSysColorList;
function AddCstColor(Value: TColor): Boolean;
procedure DeleteCstColor(Value: TColor);
procedure DeleteCstColorAt(Index: Integer);
procedure ClearCstColorList;
property Mappings: TJvColorProviderNameMappings read GetMappings;
published
property OnAddColor: TJvColorProviderAddColorEvent read FOnAddColor write FOnAddColor;
end;
TJvColorProviderNameMappings = class(TObjectList)
private
FProvider: TJvColorProvider;
protected
function GetItem(Index: Integer): TJvColorProviderNameMapping;
procedure SetItem(Index: Integer; AObject: TJvColorProviderNameMapping);
property Provider: TJvColorProvider read FProvider;
public
constructor Create(AProvider: TJvColorProvider);
function Add(Item: TJvColorProviderNameMapping): Integer;
procedure Clear; override;
procedure Delete(Index: Integer);
property Items[Index: Integer]: TJvColorProviderNameMapping read GetItem write SetItem; default;
end;
TJvColorProviderNameMapping = class(TObject)
private
FName: string;
FOwner: TJvColorProviderNameMappings;
protected
property Owner: TJvColorProviderNameMappings read FOwner;
public
constructor Create(AOwner: TJvColorProviderNameMappings; AName: string);
property Name: string read FName write FName;
end;
TJvColorProviderSubSettings = class(TPersistent)
private
FActive: Boolean;
FConsumerServiceExt: TJvDataConsumerAggregatedObject;
protected
procedure Changed; virtual;
procedure ViewChanged; virtual;
procedure SetActive(Value: Boolean); virtual;
property Active: Boolean read FActive write SetActive;
property ConsumerServiceExt: TJvDataConsumerAggregatedObject read FConsumerServiceExt;
public
constructor Create(AConsumerService: TJvDataConsumerAggregatedObject);
end;
TJvColorProviderColorBoxSettings = class(TJvColorProviderSubSettings)
private
FHeight: Integer;
FMargin: Integer;
FShadowed: Boolean;
FShadowSize: Integer;
FSpacing: Integer;
FWidth: Integer;
protected
procedure SetHeight(Value: Integer); virtual;
procedure SetMargin(Value: Integer); virtual;
procedure SetShadowed(Value: Boolean); virtual;
procedure SetShadowSize(Value: Integer); virtual;
procedure SetSpacing(Value: Integer); virtual;
procedure SetWidth(Value: Integer); virtual;
public
constructor Create(AConsumerService: TJvDataConsumerAggregatedObject);
published
property Active default True;
property Height: Integer read FHeight write SetHeight default 13;
property Margin: Integer read FMargin write SetMargin default 2;
property Shadowed: Boolean read FShadowed write SetShadowed default True;
property ShadowSize: Integer read FShadowSize write SetShadowSize default 2;
property Spacing: Integer read FSpacing write SetSpacing default 4;
property Width: Integer read FWidth write SetWidth default 21;
end;
TJvColorProviderTextSettings = class(TJvColorProviderSubSettings)
private
FShowHex: Boolean;
FShowName: Boolean;
FShowRGB: Boolean;
protected
procedure SetShowHex(Value: Boolean); virtual;
procedure SetShowName(Value: Boolean); virtual;
procedure SetShowRGB(Value: Boolean); virtual;
public
constructor Create(AConsumerService: TJvDataConsumerAggregatedObject);
published
property Active default True;
property ShowHex: Boolean read FShowHex write SetShowHex;
property ShowName: Boolean read FShowName write SetShowName default True;
property ShowRGB: Boolean read FShowRGB write SetShowRGB;
end;
TJvColorProviderGroupingSettings = class(TJvColorProviderSubSettings)
private
FFlatList: Boolean;
FHeaderAlign: TColorGroupHeaderAlign;
FHeaderStyle: TColorGroupHeaderStyles;
protected
FActiveChanging: Boolean;
procedure SetActive(Value: Boolean); override;
procedure Changed; override;
procedure SetFlatList(Value: Boolean); virtual;
procedure SetHeaderAlign(Value: TColorGroupHeaderAlign); virtual;
procedure SetHeaderStyle(Value: TColorGroupHeaderStyles); virtual;
public
constructor Create(AConsumerService: TJvDataConsumerAggregatedObject);
published
property Active default True;
property FlatList: Boolean read FFlatList write SetFlatList default True;
property HeaderAlign: TColorGroupHeaderAlign read FHeaderAlign write SetHeaderAlign
default ghaLeft;
property HeaderStyle: TColorGroupHeaderStyles read FHeaderStyle write SetHeaderStyle
default [ghsBoldFont, ghsSingleCenterLine];
end;
TJvColorProviderColorGroupSettings = class(TJvColorProviderSubSettings)
private
FCaption: string;
FShowHeader: Boolean;
protected
FActiveChanging: Boolean;
procedure SetActive(Value: Boolean); override;
procedure Changed; override;
procedure SetCaption(Value: string); virtual;
procedure SetShowHeader(Value: Boolean); virtual;
public
constructor Create(AConsumerService: TJvDataConsumerAggregatedObject; ACaption: string);
published
property Active default True;
property Caption: string read FCaption write SetCaption;
property ShowHeader: Boolean read FShowHeader write SetShowHeader default False;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -