jvcllaz: Add full color controls and dialogs

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6684 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-10-13 21:13:58 +00:00
parent b335b6778d
commit 6f473af069
26 changed files with 10757 additions and 3 deletions

View File

@ -18,6 +18,8 @@ uses
JvDsgnConsts,
JvId3v1, JvId3v2Base, JvId3v2, JvGradient, JvId3v2EditorForm,
JvGradientHeaderPanel, JvSpecialProgress,
JvFullColorSpaces, JvFullColorCtrls, JvFullColorEditors, JvFullColorSpacesEditors,
JvFullColorForm, JvFullColorDialogs,
JvBmpAnimator;
procedure Register;
@ -26,10 +28,25 @@ begin
TJvId3v1, TJvId3v2,
TJvBmpAnimator,
TJvGradient, TJvGradientHeaderPanel,
TJvSpecialProgress
TJvSpecialProgress,
TJvFullColorPanel, TJvFullColorTrackBar, TJvFullColorGroup, TJvFullColorLabel,
TJvFullColorSpaceCombo, TJvFullColorAxisCombo, TJvFullColorCircle,
TJvFullColorDialog, TJvFullColorCircleDialog
]);
RegisterComponentEditor(TJvID3Controller, TJvID3ControllerEditor);
RegisterPropertyEditor(TypeInfo(TJvID3FileInfo), nil, '', TJvID3FileInfoEditor);
RegisterPropertyEditor(TypeInfo(TJvFullColorSpaceID), nil, '', TJvColorIDEditor);
RegisterPropertyEditor(TypeInfo(TJvFullColor), nil, '', TJvFullColorProperty);
{
RegisterPropertyEditor(TypeInfo(TJvFullColorList), nil, '', TJvFullColorListEditor);
RegisterSelectionEditor(TJvFullColorPanel, TJvFullColorSelection);
RegisterSelectionEditor(TJvFullColorCircle, TJvFullColorSelection);
RegisterSelectionEditor(TJvFullColorLabel, TJvFullColorSelection);
RegisterSelectionEditor(TJvFullColorSpaceCombo, TJvFullColorSelection);
RegisterSelectionEditor(TJvFullColorAxisCombo, TJvFullColorSelection);
}
end;
end.

View File

@ -5,3 +5,12 @@ tjvgradientheaderpanel.bmp
tjvspecialprogress.bmp
tjvanimatedimage.bmp
tjvbmpanimator.bmp
tjvfullcoloraxiscombo.bmp
tjvfullcolorcircle.bmp
tjvfullcolorcircledialog.bmp
tjvfullcolordialog.bmp
tjvfullcolorgroup.bmp
tjvfullcolorlabel.bmp
tjvfullcolorpanel.bmp
tjvfullcolorspacecombo.bmp
tjvfullcolortrackbar.bmp

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,92 @@
{-----------------------------------------------------------------------------
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: ColorEditors.pas, released on 2004-09-11.
The Initial Developer of the Original Code is Florent Ouchet [ouchet dott florent att laposte dott net]
Portions created by Florent Ouchet are Copyright (C) 2004 Florent Ouchet.
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.delphi-jedi.org
Known Issues:
-----------------------------------------------------------------------------}
// $Id$
unit JvFullColorEditors;
{$mode objfpc}{$H+}
interface
uses
//Windows,
Classes, propedits,
// DesignIntf, DesignEditors, VCLEditors,
ComCtrls,
JvFullColorCtrls;
type
TJvColorIDEditor = class(TOrdinalProperty)
public
function GetAttributes: TPropertyAttributes; override;
procedure GetValues(Proc: TGetStrProc); override;
procedure SetValue(const Value: string); override;
function GetValue: string; override;
end;
implementation
uses
SysUtils, TypInfo,
JvFullColorSpaces, JvFullColorSpacesEditors;
//=== { TJvColorIDEEditor } ==================================================
function TJvColorIDEditor.GetAttributes: TPropertyAttributes;
begin
Result := [paValueList, paSortList, paRevertable, paNotNestable, paMultiSelect];
end;
function TJvColorIDEditor.GetValue: string;
begin
Result := ColorSpaceManager.ColorSpace[TJvFullColorSpaceID(GetOrdValue)].ShortName;
end;
procedure TJvColorIDEditor.GetValues(Proc: TGetStrProc);
var
I: Integer;
begin
with ColorSpaceManager do
for I := 0 to Count - 1 do
Proc(ColorSpaceByIndex[I].ShortName);
end;
procedure TJvColorIDEditor.SetValue(const Value: string);
var
I: Integer;
CS: TJvColorSpace;
begin
with ColorSpaceManager do
for I := 0 to Count - 1 do
begin
CS := ColorSpaceByIndex[I];
if CompareText(CS.ShortName, Value) = 0 then
begin
SetOrdValue(Ord(CS.ID));
Exit;
end;
end;
end;
end.

View File

@ -0,0 +1,192 @@
object JvFullColorListFrm: TJvFullColorListFrm
Left = 389
Top = 285
BorderStyle = bsDialog
Caption = 'Color list editor'
ClientHeight = 398
ClientWidth = 422
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
PixelsPerInch = 96
TextHeight = 13
object ListBoxColors: TListBox
Left = 8
Top = 8
Width = 313
Height = 377
Style = lbOwnerDrawFixed
ItemHeight = 20
MultiSelect = True
TabOrder = 0
OnDrawItem = ListBoxColorsDrawItem
end
object ButtonNew: TButton
Left = 336
Top = 8
Width = 75
Height = 25
Action = ActionNew
TabOrder = 1
end
object ButtonModify: TButton
Left = 336
Top = 88
Width = 75
Height = 25
Action = ActionModify
TabOrder = 2
end
object ButtonDelete: TButton
Left = 336
Top = 128
Width = 75
Height = 25
Action = ActionDelete
TabOrder = 3
end
object Button4: TButton
Left = 336
Top = 320
Width = 75
Height = 25
Cancel = True
Caption = '&Cancel'
ModalResult = 2
TabOrder = 4
end
object ButtonOK: TButton
Left = 336
Top = 280
Width = 75
Height = 25
Caption = '&OK'
ModalResult = 1
TabOrder = 5
end
object BitBtnMoveUp: TBitBtn
Left = 336
Top = 208
Width = 25
Height = 25
Action = ActionMoveUp
TabOrder = 6
Glyph.Data = {
76010000424D7601000000000000760000002800000020000000100000000100
04000000000000010000120B0000120B00001000000000000000000000000000
800000800000008080008000000080008000808000007F7F7F00BFBFBF000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333000333
3333333333777F33333333333309033333333333337F7F333333333333090333
33333333337F7F33333333333309033333333333337F7F333333333333090333
33333333337F7F33333333333309033333333333FF7F7FFFF333333000090000
3333333777737777F333333099999990333333373F3333373333333309999903
333333337F33337F33333333099999033333333373F333733333333330999033
3333333337F337F3333333333099903333333333373F37333333333333090333
33333333337F7F33333333333309033333333333337373333333333333303333
333333333337F333333333333330333333333333333733333333}
NumGlyphs = 2
end
object BitBtnMoveDown: TBitBtn
Left = 336
Top = 240
Width = 25
Height = 25
Action = ActionMoveDown
TabOrder = 7
Glyph.Data = {
76010000424D7601000000000000760000002800000020000000100000000100
04000000000000010000120B0000120B00001000000000000000000000000000
800000800000008080008000000080008000808000007F7F7F00BFBFBF000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333303333
333333333337F33333333333333033333333333333373F333333333333090333
33333333337F7F33333333333309033333333333337373F33333333330999033
3333333337F337F33333333330999033333333333733373F3333333309999903
333333337F33337F33333333099999033333333373333373F333333099999990
33333337FFFF3FF7F33333300009000033333337777F77773333333333090333
33333333337F7F33333333333309033333333333337F7F333333333333090333
33333333337F7F33333333333309033333333333337F7F333333333333090333
33333333337F7F33333333333300033333333333337773333333}
NumGlyphs = 2
end
object ButtonApply: TButton
Left = 336
Top = 360
Width = 75
Height = 25
Caption = '&Apply'
TabOrder = 8
OnClick = ButtonApplyClick
end
object Button1: TButton
Left = 336
Top = 168
Width = 75
Height = 25
Action = ActionClear
TabOrder = 9
end
object Button2: TButton
Left = 336
Top = 48
Width = 75
Height = 25
Action = ActionInsert
TabOrder = 10
end
object JvFullColorDialog: TJvFullColorDialog
FullColor = 83886079
HelpContext = 0
OnApply = JvFullColorDialogApply
Left = 88
Top = 88
end
object ActionList: TActionList
Left = 88
Top = 128
object ActionNew: TAction
Caption = '&New ...'
ShortCut = 16462
OnExecute = ActionNewExecute
OnUpdate = ActionNewUpdate
end
object ActionInsert: TAction
Caption = '&Insert'
ShortCut = 16457
OnExecute = ActionInsertExecute
OnUpdate = ActionInsertUpdate
end
object ActionModify: TAction
Caption = '&Modify ...'
ShortCut = 16461
OnExecute = ActionModifyExecute
OnUpdate = ActionModifyUpdate
end
object ActionDelete: TAction
Caption = 'D&elete'
ShortCut = 16453
OnExecute = ActionDeleteExecute
OnUpdate = ActionDeleteUpdate
end
object ActionClear: TAction
Caption = '&Clear'
ShortCut = 16451
OnExecute = ActionClearExecute
OnUpdate = ActionClearUpdate
end
object ActionMoveDown: TAction
ShortCut = 16452
OnExecute = ActionMoveDownExecute
OnUpdate = ActionMoveDownUpdate
end
object ActionMoveUp: TAction
ShortCut = 16469
OnExecute = ActionMoveUpExecute
OnUpdate = ActionMoveUpUpdate
end
end
end

View File

@ -0,0 +1,306 @@
{-----------------------------------------------------------------------------
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: JvFullColorListFrm.pas, released on 2004-09-27.
The Initial Developer of the Original Code is Florent Ouchet [ouchet dott florent att laposte dott net]
Portions created by Florent Ouchet are Copyright (C) 2004 Florent Ouchet.
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.delphi-jedi.org
Known Issues:
-----------------------------------------------------------------------------}
// $Id$
unit JvFullColorListForm;
{$I jvcl.inc}
interface
uses
Windows, Messages, SysUtils,
Variants,
Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ActnList, Buttons, ImgList,
JvFullColorForm, JvFullColorSpaces, JvFullColorDialogs, JvFullColorCtrls;
type
TJvFullColorListFrm = class(TForm)
JvFullColorDialog: TJvFullColorDialog;
ListBoxColors: TListBox;
ActionList: TActionList;
ActionNew: TAction;
ActionModify: TAction;
ActionDelete: TAction;
ButtonNew: TButton;
ButtonModify: TButton;
ButtonDelete: TButton;
Button4: TButton;
ButtonOK: TButton;
BitBtnMoveUp: TBitBtn;
ActionMoveUp: TAction;
ActionMoveDown: TAction;
BitBtnMoveDown: TBitBtn;
ButtonApply: TButton;
Button1: TButton;
ActionClear: TAction;
Button2: TButton;
ActionInsert: TAction;
procedure ActionNewUpdate(Sender: TObject);
procedure ActionModifyUpdate(Sender: TObject);
procedure ActionDeleteUpdate(Sender: TObject);
procedure ActionMoveUpUpdate(Sender: TObject);
procedure ActionMoveDownUpdate(Sender: TObject);
procedure ActionNewExecute(Sender: TObject);
procedure ActionClearUpdate(Sender: TObject);
procedure ActionModifyExecute(Sender: TObject);
procedure ActionInsertUpdate(Sender: TObject);
procedure ActionClearExecute(Sender: TObject);
procedure ActionDeleteExecute(Sender: TObject);
procedure ActionInsertExecute(Sender: TObject);
procedure ActionMoveUpExecute(Sender: TObject);
procedure ActionMoveDownExecute(Sender: TObject);
procedure ButtonApplyClick(Sender: TObject);
procedure JvFullColorDialogApply(Sender: TObject;
AFullColor: TJvFullColor);
procedure ListBoxColorsDrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
private
FColorList: TJvFullColorList;
FOnApply: TNotifyEvent;
procedure SetColorList(const Value: TJvFullColorList);
function GetColorList: TJvFullColorList;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function Execute: Boolean;
property ColorList: TJvFullColorList read GetColorList write SetColorList;
property OnApply: TNotifyEvent read FOnApply write FOnApply;
end;
var
JvFullColorListFrm: TJvFullColorListFrm;
implementation
uses
JvDsgnConsts;
{$R *.lfm}
constructor TJvFullColorListFrm.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FColorList := TJvFullColorList.Create;
end;
destructor TJvFullColorListFrm.Destroy;
begin
FColorList.Free;
inherited Destroy;
end;
procedure TJvFullColorListFrm.ActionClearExecute(Sender: TObject);
begin
ListBoxColors.Clear;
end;
procedure TJvFullColorListFrm.ActionClearUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled := ListBoxColors.Items.Count > 0;
end;
procedure TJvFullColorListFrm.ActionDeleteExecute(Sender: TObject);
begin
ListBoxColors.DeleteSelected;
end;
procedure TJvFullColorListFrm.ActionDeleteUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled := ListBoxColors.SelCount >= 1;
end;
procedure TJvFullColorListFrm.ActionInsertExecute(Sender: TObject);
begin
JvFullColorDialog.Options := JvFullColorDialog.Options - [foShowApply];
if JvFullColorDialog.Execute then
ListBoxColors.Items.InsertObject(ListBoxColors.ItemIndex, '',
TObject(JvFullColorDialog.FullColor));
end;
procedure TJvFullColorListFrm.ActionInsertUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled := ListBoxColors.SelCount = 1;
end;
procedure TJvFullColorListFrm.ActionModifyExecute(Sender: TObject);
begin
JvFullColorDialog.Options := JvFullColorDialog.Options + [foShowApply];
JvFullColorDialog.FullColor := TJvFullColor(ListBoxColors.Items.Objects[ListBoxColors.ItemIndex]);
if JvFullColorDialog.Execute then
ListBoxColors.Items.Objects[ListBoxColors.ItemIndex] := TObject(JvFullColorDialog.FullColor);
end;
procedure TJvFullColorListFrm.ActionModifyUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled := ListBoxColors.SelCount = 1;
end;
procedure TJvFullColorListFrm.ActionMoveDownExecute(Sender: TObject);
var
OldIndex: Integer;
begin
with ListBoxColors do
begin
OldIndex := ItemIndex;
Items.Move(ItemIndex, ItemIndex + 1);
Selected[OldIndex + 1] := True;
end;
end;
procedure TJvFullColorListFrm.ActionMoveDownUpdate(Sender: TObject);
begin
with ListBoxColors do
(Sender as TAction).Enabled := (SelCount = 1) and (ItemIndex < (Items.Count - 1));
end;
procedure TJvFullColorListFrm.ActionMoveUpExecute(Sender: TObject);
var
OldIndex: Integer;
begin
with ListBoxColors do
begin
OldIndex := ItemIndex;
Items.Move(ItemIndex, ItemIndex - 1);
Selected[OldIndex - 1] := True;
end;
end;
procedure TJvFullColorListFrm.ActionMoveUpUpdate(Sender: TObject);
begin
with ListBoxColors do
(Sender as TAction).Enabled := (SelCount = 1) and (ItemIndex > 0);
end;
procedure TJvFullColorListFrm.ActionNewExecute(Sender: TObject);
begin
JvFullColorDialog.Options := JvFullColorDialog.Options - [foShowApply];
if JvFullColorDialog.Execute then
ListBoxColors.Items.AddObject('', TObject(JvFullColorDialog.FullColor));
end;
procedure TJvFullColorListFrm.ActionNewUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled := True;
end;
function TJvFullColorListFrm.Execute: Boolean;
begin
Result := (ShowModal = mrOK);
end;
function TJvFullColorListFrm.GetColorList: TJvFullColorList;
var
Index: Integer;
begin
FColorList.BeginUpdate;
FColorList.Clear;
for Index := 0 to ListBoxColors.Items.Count - 1 do
FColorList.Add(TJvFullColor(ListBoxColors.Items.Objects[Index]));
FColorList.EndUpdate;
Result := FColorList;
end;
procedure TJvFullColorListFrm.SetColorList(const Value: TJvFullColorList);
var
I: Integer;
begin
with ListBoxColors.Items, ColorSpaceManager do
begin
BeginUpdate;
for I := 0 to Value.Count - 1 do
AddObject('', TObject(Value.Items[I]));
EndUpdate;
end;
end;
procedure TJvFullColorListFrm.ButtonApplyClick(Sender: TObject);
begin
if Assigned(FOnApply) then
FOnApply(Self);
end;
procedure TJvFullColorListFrm.JvFullColorDialogApply(Sender: TObject;
AFullColor: TJvFullColor);
begin
ListBoxColors.Items.Objects[ListBoxColors.ItemIndex] := TObject(JvFullColorDialog.FullColor);
end;
procedure TJvFullColorListFrm.ListBoxColorsDrawItem(Control: TWinControl;
Index: Integer; Rect: TRect; State: TOwnerDrawState);
var
AFullColor: TJvFullColor;
AText: string;
ColorIndex: Integer;
AColor: TColor;
AColorSpace: TJvColorSpace;
begin
with TListBox(Control), Canvas do
begin
if odSelected in State then
Font.Color := clCaptionText;
Pen.Style := psSolid;
Pen.Color := Brush.Color;
Brush.Style := bsSolid;
Rectangle(Rect);
AFullColor := TJvFullColor(Items.Objects[Index]);
with ColorSpaceManager do
begin
AColorSpace := ColorSpace[GetColorSpaceID(AFullColor)];
if AColorSpace.ID = csDEF then
with TJvDEFColorSpace(AColorSpace) do
begin
AColor := ConvertToColor(AFullColor);
AText := Format(RsUnnamedColorFmt, [Name, AFullColor]);
for ColorIndex := 0 to ColorCount - 1 do
if AColor = ColorValue[ColorIndex] then
begin
AText := Format(RsUnnamedColorFmt, [Name, ColorName[ColorIndex], ColorPrettyName[ColorIndex]]);
Break;
end;
end
else
with AColorSpace do
AText := Format('%s: %s = $%.2x; %s = $%.2x; %s = $%.2x',
[Name,
AxisName[axIndex0], GetAxisValue(AFullColor, axIndex0),
AxisName[axIndex1], GetAxisValue(AFullColor, axIndex1),
AxisName[axIndex2], GetAxisValue(AFullColor, axIndex2)]);
TextOut(Rect.Left + Rect.Bottom - Rect.Top + 2, Rect.Top + 2, AText);
end;
Brush.Color := ColorSpaceManager.ConvertToColor(AFullColor);
Pen.Color := clBlack;
Rectangle(Rect.Left + 2, Rect.Top + 2, Rect.Left + Rect.Bottom - Rect.Top - 2, Rect.Bottom - 2);
end;
end;
end.

View File

@ -0,0 +1,770 @@
{-----------------------------------------------------------------------------
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: ColorSpacesEditors.pas, released on 2004-09-11.
The Initial Developer of the Original Code is Florent Ouchet [ouchet dott florent att laposte dott net]
Portions created by Florent Ouchet are Copyright (C) 2004 Florent Ouchet.
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.delphi-jedi.org
Known Issues:
-----------------------------------------------------------------------------}
// $Id$
unit JvFullColorSpacesEditors;
{$mode objfpc}{$H+}
interface
uses
//Windows,
Classes, Graphics,
PropEdits,
//DesignIntf, DesignEditors, DesignMenus, VCLEditors,
JvFullColorSpaces;
type
TJvDEFFamily = (pfConstant, pfSystem);
TJvFullColorProperty = class(TPropertyEditor) //, ICustomPropertyDrawing)
private
function GetIsColorProperty: Boolean;
procedure DialogApply(Sender: TObject; AFullColor: TJvFullColor);
public
function GetAttributes: TPropertyAttributes; override;
procedure GetProperties(Proc: TGetPropEditProc); override; //TGetPropProc); override;
procedure GetValues(Proc: TGetStrProc); override;
function GetValue: string; override;
procedure SetValue(const Value: string); override;
procedure Edit; override;
procedure EditSpace(AColorID: TJvFullColorSpaceID);
procedure SetColor(AFullColor: TJvFullColor);
// ICustomPropertyDrawing
procedure PropDrawName(ACanvas: TCanvas; const ARect: TRect; ASelected: Boolean);
procedure PropDrawValue(ACanvas: TCanvas; const ARect: TRect; ASelected: Boolean);
property IsColorProperty: Boolean read GetIsColorProperty;
end;
TJvFullColorSpaceProperty = class(TNestedProperty)
private
FColorSpace: TJvColorSpace;
FParent: TJvFullColorProperty;
public
constructor Create(AParent: TJvFullColorProperty; AColorSpace: TJvColorSpace;
AIsColorProperty: Boolean);
(************* NOT CONVERTED ***
function GetName: string; override;
*******************************)
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure GetProperties(Proc: TGetPropEditProc); override; //TGetPropProc); override;
procedure Edit; override;
property ColorSpace: TJvColorSpace read FColorSpace;
property Parent: TJvFullColorProperty read FParent;
end;
TJvFullColorSpacePropertyClass = class of TJvFullColorSpaceProperty;
TJvFullColorAxisProperty = class(TNestedProperty) //, ICustomPropertyListDrawing)
private
FAxisIndex: TJvAxisIndex;
FParent:TJvFullColorSpaceProperty;
public
constructor Create(AParent: TJvFullColorSpaceProperty;
AAxisIndex: TJvAxisIndex);
(**************** NOT CONVERTED ***
function GetName: string; override;
**********************************)
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure SetValue(const Value: string); override;
procedure GetValues(Proc: TGetStrProc); override;
// ICustomPropertyListDrawing
procedure ListMeasureHeight(const Value: string; ACanvas: TCanvas;
var AHeight: Integer);
procedure ListMeasureWidth(const Value: string; ACanvas: TCanvas;
var AWidth: Integer);
procedure ListDrawValue(const Value: string; ACanvas: TCanvas;
const ARect: TRect; ASelected: Boolean); virtual;
property Parent: TJvFullColorSpaceProperty read FParent;
property AxisIndex: TJvAxisIndex read FAxisIndex;
end;
TJvDEFColorSpaceProperty = class(TJvFullColorSpaceProperty)
public
procedure GetProperties(Proc: TGetPropEditProc); override; //TGetPropProc); override;
end;
TJvDEFColorSpaceIndentProperty = class(TNestedProperty) //, ICustomPropertyListDrawing)
private
FPredefinedFamily: TJvDEFFamily;
FParent: TJvDEFColorSpaceProperty;
public
constructor Create(AParent: TJvDEFColorSpaceProperty;
APredefinedFamily: TJvDEFFamily);
(*******NOT CONVERTED ***
function GetName: string; override;
************************)
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure SetValue(const Value: string); override;
procedure GetValues(Proc: TGetStrProc); override;
// ICustomPropertyListDrawing
procedure ListMeasureHeight(const Value: string; ACanvas: TCanvas;
var AHeight: Integer);
procedure ListMeasureWidth(const Value: string; ACanvas: TCanvas;
var AWidth: Integer);
procedure ListDrawValue(const Value: string; ACanvas: TCanvas;
const ARect: TRect; ASelected: Boolean); virtual;
property Parent: TJvDEFColorSpaceProperty read FParent;
property PredefinedFamily: TJvDEFFamily read FPredefinedFamily;
end;
(********************* NOT CONVERTED ***
TJvFullColorSelection = class(TSelectionEditor)
protected
procedure RequireClass(Proc: TGetStrProc; AClass: TClass);
public
procedure ExecuteVerb(Index: Integer; const List: IDesignerSelections); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
procedure RequiresUnits(Proc: TGetStrProc); override;
procedure PrepareItem(Index: Integer; const AItem: IMenuItem); override;
end;
TJvFullColorListEditor = class(TClassProperty)
public
function GetAttributes: TPropertyAttributes; override;
procedure Edit; override;
function AllEqual: Boolean; override;
procedure FormApply(Sender: TObject);
end;
**********************)
procedure RegisterFullColorSpaceEditor(AColorSpaceID: TJvFullColorSpaceID;
AEditorClass: TJvFullColorSpacePropertyClass);
function FindFullColorSpaceEditor(AColorSpaceID: TJvFullColorSpaceID): TJvFullColorSpacePropertyClass;
var
DefaultFullColorSpacePropertyClass: TJvFullColorSpacePropertyClass = TJvFullColorSpaceProperty;
implementation
uses
Math, SysUtils, {DesignConst, }TypInfo, Forms;
// JvFullColorDialogs, JvFullColorCtrls, JvFullColorListForm, JvJCLUtils;
const
COLOR_PREVIEW_RECT = 16;
COLOR_PREVIEW_LINE = 1;
COLOR_PREVIEW_SIZE = COLOR_PREVIEW_RECT + 2 * COLOR_PREVIEW_LINE;
function HexToInt(Value: string): Byte;
begin
if Value = '' then
Result := 0
else
begin
if Length(Value) > 3 then
Value := Copy(Value, 1, 3);
Result := StrToInt(Value);
end;
end;
procedure ColorPropertyListDrawValue(AColor: TColor; AValue: string;
ACanvas: TCanvas; ARect: TRect; ASelected: Boolean);
var
OldBrushColor: TColor;
OldPenColor: TColor;
begin
with ACanvas do
begin
OldBrushColor := Brush.Color;
OldPenColor := Pen.Color;
Pen.Color := Brush.Color;
Rectangle(ARect);
Brush.Color := AColor;
Pen.Color := clBlack;
Rectangle(ARect.Left + COLOR_PREVIEW_LINE,
ARect.Top + COLOR_PREVIEW_LINE,
ARect.Left + COLOR_PREVIEW_LINE + COLOR_PREVIEW_RECT,
ARect.Top + COLOR_PREVIEW_LINE + COLOR_PREVIEW_RECT);
Pen.Color := OldPenColor;
Brush.Color := OldBrushColor;
TextOut(ARect.Left + COLOR_PREVIEW_SIZE, ARect.Top, AValue);
end;
end;
//=== { TJvFullColorProperty } ===============================================
procedure TJvFullColorProperty.DialogApply(Sender: TObject; AFullColor: TJvFullColor);
begin
SetColor(AFullColor);
end;
procedure TJvFullColorProperty.Edit;
begin
if IsColorProperty then
// a dummy param
EditSpace(csRGB)
else
EditSpace(ColorSpaceManager.GetColorSpaceID(GetOrdValue));
end;
procedure TJvFullColorProperty.EditSpace(AColorID: TJvFullColorSpaceID);
var
LColor: TJvFullColor;
begin
(******************** NOT CONVERTED ***
with ColorSpaceManager, TJvFullColorDialog.Create(nil) do
try
if IsColorProperty then
begin
LColor := ColorSpaceManager.ConvertFromColor(TColor(GetOrdValue));
// reset dummy param
AColorID := ColorSpaceManager.GetColorSpaceID(LColor);
end
else
LColor := TJvFullColor(GetOrdValue);
if GetColorSpaceID(LColor) <> AColorID then
LColor := ConvertToID(LColor, AColorID);
FullColor := LColor;
Title := '';
OnApply := DialogApply;
Options := [foFullOpen, foAllowSpaceChange, foShowNewPreview, foShowOldPreview,
foShowPredefined, foAllowVariable, foNoneAndDefault, foShowApply];
if Execute then
SetColor(FullColor);
finally
Free;
end;
**********************)
end;
function TJvFullColorProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paSubProperties, paDialog, paMultiSelect, paVolatileSubProperties, {paVCL,}
paRevertable];
if IsColorProperty then
Result := Result + [paReadOnly]
else
Result := Result + [paValueList, paSortList];
end;
function TJvFullColorProperty.GetIsColorProperty: Boolean;
begin
Result := (GetPropType = TypeInfo(TColor));
end;
procedure TJvFullColorProperty.GetProperties(Proc: TGetPropEditProc); //TGetPropProc);
var
I: Integer;
CS: TJvColorSpace;
begin
with ColorSpaceManager do
for I := 0 to Count - 1 do
begin
CS := ColorSpaceByIndex[I];
Proc(FindFullColorSpaceEditor(CS.ID).Create(Self, CS, IsColorProperty));
end;
end;
function TJvFullColorProperty.GetValue: string;
var
Value: TJvFullColor;
begin
Value := GetOrdValue;
with ColorSpaceManager do
if IsColorProperty then
Result := {$IFDEF SUPPORTS_UNICODE}UTF8ToString{$ENDIF SUPPORTS_UNICODE}(GetPropType^.Name)
else
Result := Format('%s [%s]', [{$IFDEF SUPPORTS_UNICODE}UTF8ToString{$ENDIF SUPPORTS_UNICODE}(GetPropType^.Name), ColorSpace[GetColorSpaceID(Value)].ShortName]);
end;
procedure TJvFullColorProperty.GetValues(Proc: TGetStrProc);
var
I: Integer;
begin
with ColorSpaceManager do
for I := 0 to Count - 1 do
Proc(ColorSpaceByIndex[I].ShortName);
end;
procedure TJvFullColorProperty.PropDrawName(ACanvas: TCanvas;
const ARect: TRect; ASelected: Boolean);
begin
(**************** NOT CONVERTED ***
DefaultPropertyDrawName(Self, ACanvas, ARect);
**********************************)
end;
procedure TJvFullColorProperty.PropDrawValue(ACanvas: TCanvas;
const ARect: TRect; ASelected: Boolean);
var
OldPenColor, OldBrushColor: TColor;
Right: Integer;
begin
with ACanvas do
begin
Rectangle(ARect);
OldBrushColor := Brush.Color;
if IsColorProperty then
Brush.Color := GetOrdValue
else
Brush.Color := ColorSpaceManager.ConvertToColor(TJvFullColor(GetOrdValue));
OldPenColor := Pen.Color;
Pen.Color := clBlack;
Right := (ARect.Bottom - ARect.Top) + ARect.Left;
Rectangle(ARect.Left + 1, ARect.Top + 1, Right - 1, ARect.Bottom - 1);
Pen.Color := OldPenColor;
Brush.Color := OldBrushColor;
end;
(******************** NOT CONVERTED ***
DefaultPropertyDrawValue(Self, ACanvas, Rect(Right, ARect.Top, ARect.Right, ARect.Bottom));
**************************************)
end;
procedure TJvFullColorProperty.SetColor(AFullColor: TJvFullColor);
begin
with ColorSpaceManager do
if IsColorProperty then
SetOrdValue(Ord(ConvertToColor(AFullColor)))
else
SetOrdValue(Ord(AFullColor));
end;
procedure TJvFullColorProperty.SetValue(const Value: string);
var
I: Integer;
LColor: TJvFullColor;
LColorSpace: TJvColorSpace;
begin
LColor := GetOrdValue;
with ColorSpaceManager do
for I := 0 to Count - 1 do
begin
LColorSpace := ColorSpaceByIndex[I];
if LColorSpace.ShortName = Value then
begin
LColor := ColorSpaceManager.ConvertToID(LColor, LColorSpace.ID);
SetOrdValue(Ord(LColor));
Break;
end;
end;
end;
//=== { TJvFullColorSpaceProperty } ==========================================
constructor TJvFullColorSpaceProperty.Create(AParent: TJvFullColorProperty;
AColorSpace: TJvColorSpace; AIsColorProperty: Boolean);
begin
inherited Create(AParent);
FParent := AParent;
FColorSpace := AColorSpace;
end;
procedure TJvFullColorSpaceProperty.Edit;
begin
Parent.EditSpace(ColorSpace.ID);
end;
function TJvFullColorSpaceProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paSubProperties, paDialog, paMultiSelect, paReadOnly, paVolatileSubProperties, //paVCL,
paRevertable];
end;
(******************* NOT CONVERTED ***
function TJvFullColorSpaceProperty.GetName: string;
begin
Result := ColorSpace.ShortName;
end;
************************************)
procedure TJvFullColorSpaceProperty.GetProperties(Proc: TGetPropEditProc); //TGetPropProc);
var
I: TJvAxisIndex;
begin
for I := Low(TJvAxisIndex) to High(TJvAxisIndex) do
Proc(TJvFullColorAxisProperty.Create(Self, I));
end;
function TJvFullColorSpaceProperty.GetValue: string;
begin
Result := ColorSpace.Name;
end;
//=== { TJvFullColorAxisProperty } ===========================================
constructor TJvFullColorAxisProperty.Create(AParent: TJvFullColorSpaceProperty;
AAxisIndex: TJvAxisIndex);
begin
inherited Create(AParent.Parent);
FParent := AParent;
FAxisIndex := AAxisIndex;
end;
function TJvFullColorAxisProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paValueList, paMultiSelect, paRevertable];
end;
(******************* NOT CONVERTED ***
function TJvFullColorAxisProperty.GetName: string;
begin
Result := Parent.ColorSpace.AxisName[AxisIndex];
end;
************************************)
function TJvFullColorAxisProperty.GetValue: string;
begin
Result :=
Format('$%.2x', [GetAxisValue(ColorSpaceManager.ConvertToID(GetOrdValue, Parent.ColorSpace.ID), AxisIndex)]);
end;
procedure TJvFullColorAxisProperty.GetValues(Proc: TGetStrProc);
var
I: Byte;
begin
with Parent.ColorSpace do
for I := AxisMin[AxisIndex] to AxisMax[AxisIndex] do
Proc(Format('$%.2x', [I]));
end;
procedure TJvFullColorAxisProperty.ListDrawValue(const Value: string;
ACanvas: TCanvas; const ARect: TRect; ASelected: Boolean);
var
FullColor: TJvFullColor;
LColor: TColor;
begin
FullColor := ColorSpaceManager.ConvertToID(GetOrdValue, Parent.ColorSpace.ID);
FullColor := SetAxisValue(FullColor, AxisIndex, HexToInt(Value));
LColor := Parent.ColorSpace.ConvertToColor(FullColor);
ColorPropertyListDrawValue(LColor, Value, ACanvas, ARect, ASelected);
end;
procedure TJvFullColorAxisProperty.ListMeasureHeight(const Value: string;
ACanvas: TCanvas; var AHeight: Integer);
begin
AHeight := Max(ACanvas.TextHeight(Value), COLOR_PREVIEW_SIZE);
end;
procedure TJvFullColorAxisProperty.ListMeasureWidth(const Value: string;
ACanvas: TCanvas; var AWidth: Integer);
begin
AWidth := ACanvas.TextWidth(Value) + COLOR_PREVIEW_SIZE;
end;
procedure TJvFullColorAxisProperty.SetValue(const Value: string);
var
AxisValue: Byte;
LColor: TJvFullColor;
LColorID: TJvFullColorSpaceID;
begin
AxisValue := HexToInt(Value);
LColor := TJvFullColor(GetOrdValue);
LColorID := ColorSpaceManager.GetColorSpaceID(LColor);
LColor := ColorSpaceManager.ConvertToID(LColor, Parent.ColorSpace.ID);
LColor := SetAxisValue(LColor, AxisIndex, AxisValue);
if not Parent.Parent.IsColorProperty then
SetOrdValue(Ord(ColorSpaceManager.ConvertToID(LColor, LColorID)))
else
SetOrdValue(Ord(ColorSpaceManager.ConvertToColor(LColor)));
end;
//=== { TJvDEFColorSpaceProperty } ===========================================
procedure TJvDEFColorSpaceProperty.GetProperties(Proc: TGetPropEditProc); //TGetPropProc);
begin
Proc(TJvDEFColorSpaceIndentProperty.Create(Self, pfConstant));
Proc(TJvDEFColorSpaceIndentProperty.Create(Self, pfSystem));
end;
//=== { TJvDEFColorSpaceIndentProperty } =====================================
constructor TJvDEFColorSpaceIndentProperty.Create(AParent: TJvDEFColorSpaceProperty;
APredefinedFamily: TJvDEFFamily);
begin
inherited Create(AParent.Parent);
FParent := AParent;
FPredefinedFamily := APredefinedFamily;
end;
function TJvDEFColorSpaceIndentProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paValueList, paMultiSelect, paRevertable];
end;
(*********************** NOT CONVERTED ***
function TJvDEFColorSpaceIndentProperty.GetName: string;
begin
Result := GetEnumName(TypeInfo(TJvDEFFamily), Ord(PredefinedFamily));
Result := Copy(Result, 3, Length(Result) - 2);
end;
****************************************)
function TJvDEFColorSpaceIndentProperty.GetValue: string;
var
AColor: TColor;
begin
if Parent.Parent.IsColorProperty then
AColor := GetOrdValue
else
AColor := ColorSpaceManager.ConvertToColor(TJvFullColor(GetOrdValue));
if ((AColor and JvSystemColorMask) <> 0) xor (PredefinedFamily = pfConstant) then
Result := ColorToPrettyName(AColor)
else
Result := '';
end;
procedure TJvDEFColorSpaceIndentProperty.GetValues(Proc: TGetStrProc);
var
I: Integer;
AColor: TColor;
CS: TJvDEFColorSpace;
begin
CS := TJvDEFColorSpace(Parent.ColorSpace);
for I := 0 to CS.ColorCount - 1 do
begin
AColor := CS.ColorValue[I];
if ((AColor and JvSystemColorMask) <> 0) xor (PredefinedFamily = pfConstant) then
Proc(CS.ColorPrettyName[I]);
end;
end;
procedure TJvDEFColorSpaceIndentProperty.ListDrawValue(const Value: string;
ACanvas: TCanvas; const ARect: TRect; ASelected: Boolean);
begin
ColorPropertyListDrawValue(PrettyNameToColor(Value), Value, ACanvas, ARect, ASelected);
end;
procedure TJvDEFColorSpaceIndentProperty.ListMeasureHeight(const Value: string;
ACanvas: TCanvas; var AHeight: Integer);
begin
AHeight := Max(ACanvas.TextHeight(Value), COLOR_PREVIEW_SIZE);
end;
procedure TJvDEFColorSpaceIndentProperty.ListMeasureWidth(const Value: string;
ACanvas: TCanvas; var AWidth: Integer);
begin
AWidth := ACanvas.TextWidth(Value) + COLOR_PREVIEW_SIZE;
end;
procedure TJvDEFColorSpaceIndentProperty.SetValue(const Value: string);
var
I:Integer;
CS: TJvDEFColorSpace;
clPrefix: string;
begin
clPrefix := Copy(ColorToString(clBlack), 1, 2);
CS := TJvDEFColorSpace(Parent.ColorSpace);
for I := 0 to CS.ColorCount - 1 do
if (CompareText(Value, CS.ColorName[I]) = 0) or
(CompareText(Value, clPrefix + CS.ColorName[I]) = 0) or
(CompareText(Value, CS.ColorPrettyName[I]) = 0) then
begin
if Parent.Parent.IsColorProperty then
SetOrdValue(CS.ColorValue[I])
else
if (CS.ColorValue[I] and JvSystemColorMask) <> 0 then
SetOrdValue(CS.ConvertFromColor(CS.ColorValue[I]))
else
with ColorSpaceManager do
SetOrdValue(ConvertToID(ConvertFromColor(CS.ColorValue[I]), GetColorSpaceID(GetOrdValue)));
Break;
end;
end;
(****************** NOT CONVERTED ***
//=== { TJvColorSelection } ==================================================
procedure TJvFullColorSelection.ExecuteVerb(Index: Integer; const List: IDesignerSelections);
begin
// No execution
inherited ExecuteVerb(Index, List);
end;
function TJvFullColorSelection.GetVerb(Index: Integer): string;
begin
// No menu item
Result := '';
end;
function TJvFullColorSelection.GetVerbCount: Integer;
begin
// No menu item
Result := 0;
end;
procedure TJvFullColorSelection.PrepareItem(Index: Integer; const AItem: IMenuItem);
begin
// No menu item
inherited PrepareItem(Index, AItem);
end;
procedure TJvFullColorSelection.RequireClass(Proc: TGetStrProc; AClass: TClass);
var
LTypInfo: PTypeInfo;
begin
LTypInfo := AClass.ClassInfo;
if LTypInfo <> nil then
Proc({$IFDEF SUPPORTS_UNICODE}UTF8ToString{$ENDIF SUPPORTS_UNICODE}(GetTypeData(LTypInfo).UnitName));
end;
procedure TJvFullColorSelection.RequiresUnits(Proc: TGetStrProc);
var
I: Integer;
begin
inherited RequiresUnits(Proc);
RequireClass(Proc, TJvColorSpace);
with ColorSpaceManager do
for I := 0 to Count - 1 do
RequireClass(Proc, ColorSpaceByIndex[I].ClassType);
end;
//=== { TJvFullColorListEditor } =============================================
function TJvFullColorListEditor.AllEqual: Boolean;
var
IndexList, IndexColor: Integer;
FullColorList: TJvFullColorList;
begin
Result := False;
if PropCount > 1 then
begin
FullColorList := TJvFullColorList.Create;
FullColorList.Assign(TJvFullColorList(GetOrdValue));
for IndexList := 1 to PropCount - 1 do
with TJvFullColorList(GetOrdValueAt(IndexList)) do
for IndexColor:=0 to Count - 1 do
if FullColorList.Items[IndexColor] <> Items[IndexColor] then
Exit;
end;
Result := True;
end;
procedure TJvFullColorListEditor.Edit;
var
FullColorListForm: TJvFullColorListFrm;
FullColorList: TJvFullColorList;
IndexList, IndexColor: Integer;
begin
FullColorListForm := TJvFullColorListFrm.Create(Application);
try
FullColorList:=TJvFullColorList.Create;
try
for IndexList := 0 to PropCount - 1 do
with TJvFullColorList(GetOrdValueAt(IndexList)) do
for IndexColor := 0 to Count - 1 do
if FullColorList.IndexOf(Items[IndexColor]) = -1 then
FullColorList.Add(Items[IndexColor]);
FullColorListForm.OnApply := FormApply;
FullColorListForm.ColorList := FullColorList;
if FullColorListForm.Execute then
FormApply(FullColorListForm);
finally
FullColorList.Free;
end;
finally
FullColorListForm.Free;
end;
end;
procedure TJvFullColorListEditor.FormApply(Sender: TObject);
begin
SetOrdValue(Cardinal((Sender as TJvFullColorListFrm).ColorList));
end;
function TJvFullColorListEditor.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paVCL, paMultiSelect];
end;
********************)
var
GFullColorSpaceEditorArray: array of TJvFullColorSpacePropertyClass;
{procedure ModuleUnloadProc(HInstance: Integer);
var
Index: Integer;
AEditorClass: TJvFullColorSpacePropertyClass;
begin
for Index := High(GFullColorSpaceEditorArray) downto 0 do
begin
AEditorClass := GFullColorSpaceEditorArray[Index];
if (AEditorClass <> nil) and (AEditorClass <> TJvFullColorSpaceProperty) and IsClassInModule(HInstance, AEditorClass) then
GFullColorSpaceEditorArray[Index] := nil;
end;
end;}
procedure InitFullColorSpaceEditorArray;
var
ACount: Integer;
Index: Integer;
begin
ACount := (High(TJvFullColorSpaceID) - Low(TJvFullColorSpaceID) + 1) shr 2;
SetLength(GFullColorSpaceEditorArray, ACount);
for Index := 0 to High(GFullColorSpaceEditorArray) do
GFullColorSpaceEditorArray[Index] := nil;
end;
procedure RegisterFullColorSpaceEditor(AColorSpaceID: TJvFullColorSpaceID;
AEditorClass: TJvFullColorSpacePropertyClass);
begin
if GFullColorSpaceEditorArray = nil then
begin
InitFullColorSpaceEditorArray;
//RegisterFullColorSpaceEditor(csDEF, TJvDEFColorSpaceProperty);
GFullColorSpaceEditorArray[csDEF shr 2] := TJvDEFColorSpaceProperty;
end;
GFullColorSpaceEditorArray[AColorSpaceID shr 2] := AEditorClass;
// todo (outchy) notification for changing
end;
function FindFullColorSpaceEditor(AColorSpaceID: TJvFullColorSpaceID): TJvFullColorSpacePropertyClass;
begin
if GFullColorSpaceEditorArray = nil then
InitFullColorSpaceEditorArray;
Result := GFullColorSpaceEditorArray[AColorSpaceID shr 2];
if Result = nil then
Result := DefaultFullColorSpacePropertyClass;
end;
//initialization
// AddModuleUnloadProc(ModuleUnloadProc);
//finalization
// RemoveModuleUnloadProc(ModuleUnloadProc);
end.