jvcllaz: Improved layout for JvFullColorCircle demo

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6987 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2019-05-31 23:27:41 +00:00
parent e513970d1c
commit 7a43c87728
5 changed files with 220 additions and 92 deletions

View File

@ -3,7 +3,6 @@ object JvFullColorCircleDlgMainFrm: TJvFullColorCircleDlgMainFrm
Height = 315
Top = 214
Width = 274
BorderStyle = bsDialog
Caption = 'JvFullColorCircleDlgMainFrm'
ClientHeight = 315
ClientWidth = 274
@ -15,16 +14,14 @@ object JvFullColorCircleDlgMainFrm: TJvFullColorCircleDlgMainFrm
Position = poScreenCenter
LCLVersion = '2.1.0.0'
object Bevel: TBevel
AnchorSideLeft.Control = Memo
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = ComboBoxFileName
AnchorSideTop.Control = cmbFileName
AnchorSideTop.Side = asrBottom
Left = 33
Left = 32
Height = 86
Top = 35
Top = 41
Width = 86
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Left = 9
BorderSpacing.Top = 12
Style = bsRaised
end
object Image: TImage
@ -32,15 +29,15 @@ object JvFullColorCircleDlgMainFrm: TJvFullColorCircleDlgMainFrm
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Bevel
AnchorSideTop.Side = asrCenter
Left = 36
Left = 35
Height = 80
Top = 38
Top = 44
Width = 80
Center = True
end
object LabelImage: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = ComboBoxFileName
AnchorSideTop.Control = cmbFileName
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
@ -53,31 +50,7 @@ object JvFullColorCircleDlgMainFrm: TJvFullColorCircleDlgMainFrm
ParentColor = False
ParentFont = False
end
object Memo: TMemo
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Bevel
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Bevel
AnchorSideRight.Side = asrBottom
Left = 6
Height = 70
Top = 127
Width = 141
Alignment = taCenter
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderStyle = bsNone
Font.Color = clWindowText
Lines.Strings = (
'Original image'
)
OnKeyDown = MemoKeyDown
OnKeyPress = MemoKeyPress
ParentColor = True
ParentFont = False
TabOrder = 0
end
object ComboBoxFileName: TComboBox
object cmbFileName: TComboBox
AnchorSideLeft.Control = LabelImage
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Owner
@ -92,16 +65,30 @@ object JvFullColorCircleDlgMainFrm: TJvFullColorCircleDlgMainFrm
DropDownCount = 24
Font.Color = clWindowText
ItemHeight = 15
OnClick = ComboBoxFileNameSelect
OnSelect = ComboBoxFileNameSelect
OnClick = cmbFileNameSelect
OnSelect = cmbFileNameSelect
ParentFont = False
Style = csDropDownList
TabOrder = 1
TabOrder = 0
end
object Label1: TLabel
AnchorSideTop.Control = Bevel
AnchorSideTop.Side = asrBottom
Left = 40
Height = 15
Top = 133
Width = 78
Alignment = taCenter
AutoSize = False
BorderSpacing.Top = 6
Caption = 'Original image'
ParentColor = False
WordWrap = True
end
object JvFullColorCircleDialog: TJvFullColorCircleDialog
HelpContext = 0
OnApply = JvFullColorCircleDialogApply
Left = 184
Top = 80
left = 184
top = 80
end
end

View File

@ -31,7 +31,7 @@ unit JvFullColorCircleDialogMainForm;
interface
uses
SysUtils, Variants, Classes, Graphics, Controls, Forms,
SysUtils, Variants, Classes, Graphics, Controls, Types, Forms,
Dialogs, ExtCtrls, StdCtrls, JvFullColorSpaces, JvFullColorCircleForm,
JvFullColorDialogs, JvFullColorRotate;
@ -42,23 +42,24 @@ type
TJvFullColorCircleDlgMainFrm = class(TForm)
Image: TImage;
Bevel: TBevel;
Memo: TMemo;
Label1: TLabel;
LabelImage: TLabel;
ComboBoxFileName: TComboBox;
cmbFileName: TComboBox;
JvFullColorCircleDialog: TJvFullColorCircleDialog;
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure MemoKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure MemoKeyPress(Sender: TObject; var Key: Char);
procedure ComboBoxFileNameSelect(Sender: TObject);
procedure cmbFileNameSelect(Sender: TObject);
procedure JvFullColorCircleDialogApply(Sender: TObject);
private
procedure FormatLabel(ALabel: TLabel; const Delta: TJvColorDelta);
function MeasureLabels: TSize;
public
Images: array [0..6] of TImage;
Memos: array [0..6] of TMemo;
Labels: array[0..6] of TLabel;
procedure CustomizeDblClick(Sender: TObject);
procedure RotateCustomValues;
procedure FormatMemo(AMemo: TMemo; const Delta: TJvColorDelta);
// procedure FormatMemo(AMemo: TMemo; const Delta: TJvColorDelta);
end;
var
@ -68,7 +69,8 @@ implementation
{$R *.lfm}
uses Contnrs;
uses
LCLIntf, LCLType, Math, Contnrs;
resourcestring
RsCustomize = 'Dbl-click to customize';
@ -95,12 +97,112 @@ begin
ImgDir := IncludeTrailingPathDelimiter(GetCurrentDir) + '../../design/JvCtrls/images/';
if FindFirst(ImgDir + '*.png', faAnyFile, LSearchRec) = 0 then
repeat
ComboBoxFileName.Items.Add(LSearchRec.Name);
cmbFileName.Items.Add(LSearchRec.Name);
until FindNext(LSearchRec) <> 0;
FindClose(LSearchRec);
end;
function TJvFullColorCircleDlgMainFrm.MeasureLabels: TSize;
var
i, j: Integer;
axIndex: TJvAxisIndex;
ColorSpc: TJvColorSpace;
L: TStrings;
s: String;
bmp: TBitmap;
R: TRect;
begin
Result := Size(0, 0);
ColorSpc := ColorSpaceManager.ColorSpace[csCMY];
L := TStringList.Create;
try
L.Add(Format('%s (%s)',[ColorSpc.Name, ColorSpc.ShortName]));
for axIndex := Low(TJvAxisIndex) to High(TJvAxisIndex) do
L.Add(Format('%s : %d, %d, %d',[ColorSpc.AxisName[axIndex], 255, 255, 255]));
s := L.Text;
finally
L.Free;
end;
bmp := TBitmap.Create;
try
bmp.SetSize(1, 1);
bmp.Canvas.Brush.Color := clWhite;
bmp.Canvas.FillRect(0, 0, 1, 1);
bmp.Canvas.Font.Assign(Label1.Font);
R := Rect(0, 0, MaxInt, MaxInt);
DrawText(bmp.Canvas.Handle, PChar(s), Length(s), R, DT_WORDBREAK or DT_CALCRECT or DT_NOCLIP);
Result.CX := Max(Result.CX, R.Right);
Result.CY := Max(Result.CY, R.Bottom);
finally
bmp.Free;
end;
end;
procedure TJvFullColorCircleDlgMainFrm.FormActivate(Sender: TObject);
var
X, Y: Integer;
PitchX, PitchY: Integer;
LabelSize: TSize;
Index: Integer;
lBevel: TBevel;
lImage: TImage;
lLabel: TLabel;
h: Integer;
begin
LabelSize := MeasureLabels;
h := Label1.Canvas.Textheight('Tg');
PitchX := LabelSize.CX + 32;
PitchY := LabelSize.CY + Bevel.Height + 16;
Label1.Left := 8;
Label1.Width := LabelSize.CX;
Bevel.Left := Label1.Left + (Label1.Width - Bevel.Width) div 2;
Index := 0;
for Y := 0 to 1 do
for X := 0 to 3 do
if (X <> 0) or (Y <> 0) then
begin
lBevel := TBevel.Create(Self);
lBevel.Parent := Self;
lBevel.Style := bsRaised;
lBevel.SetBounds(Bevel.Left + X*PitchX, Bevel.Top + Y*PitchY, Bevel.Width, Bevel.Height);
lImage := TImage.Create(Self);
lImage.Parent := Self;
lImage.Stretch := false;
lImage.Center := true;
lImage.SetBounds(Image.Left + X*PitchX, Image.Top + Y*PitchY, Image.Width, Image.Height);
lLabel := TLabel.Create(Self);
lLabel.Parent := Self;
lLabel.AutoSize := false;
lLabel.WordWrap := true;
lLabel.Alignment := taCenter;
// lLabel.SetBounds(Label1.Left + X*PitchX, Label1.Top + Y*PitchY, LabelSize.CX, LabelSize.CY);
lLabel.Left := Label1.Left + X*PitchX;
lLabel.Top := Label1.Top + Y*PitchY;
lLabel.Width := LabelSize.CX;
lLabel.Height := LabelSize.CY + Y*h;
if (X = 3) and (Y = 1) then begin
lImage.OnDblClick := @CustomizeDblClick;
lLabel.OnDblClick := @CustomizeDblClick;
ClientWidth := lBevel.Left + lBevel.Width + Bevel.Left;
ClientHeight := lLabel.Top + lLabel.Height + cmbFileName.Top;
end;
Images[Index] := lImage;
Labels[Index] := lLabel;
Inc(Index);
end;
cmbFileName.ItemIndex := 0;
cmbFileNameSelect(cmbFileName);
end;
(*
var
X, Y: Integer;
PitchX, PitchY: Integer;
@ -120,11 +222,13 @@ begin
LBevel.Parent := Self;
LBevel.Style := bsRaised;
LBevel.SetBounds(Bevel.Left+X*PitchX, Bevel.Top+Y*PitchY, Bevel.Width, Bevel.Height);
LImage := TImage.Create(Self);
LImage.Parent := Self;
LImage.Stretch := False;
LImage.Center := true;
LImage.SetBounds(Image.Left+X*PitchX, Image.Top+Y*PitchY, Image.Width, Image.Height);
LMemo := TMemo.Create(Self);
LMemo.Parent := Self;
LMemo.BorderStyle := bsNone;
@ -133,20 +237,22 @@ begin
LMemo.OnKeyPress := @MemoKeyPress;
LMemo.SetBounds(Memo.Left+X*PitchX, Memo.Top+Y*PitchY, Memo.Width, Memo.Height);
LMemo.Alignment := taCenter;
if (X = 3) and (Y = 1) then
begin
LImage.OnDblClick := @CustomizeDblClick;
LMemo.OnDblClick := @CustomizeDblClick;
ClientWidth := LMemo.Left+LMemo.Width-1+Memo.Left;
ClientHeight := LMemo.Top+LMemo.Height-1+ComboboxFileName.Top;
ClientHeight := LMemo.Top+LMemo.Height-1+cmbFileName.Top;
end;
Memos[Index] := LMemo;
Images[Index] := LImage;
Inc(Index);
end;
ComboBoxFileName.ItemIndex := 0;
ComboBoxFileNameSelect(ComboBoxFileName);
end;
cmbFileName.ItemIndex := 0;
ComboBoxFileNameSelect(cmbFileName);
end; *)
procedure TJvFullColorCircleDlgMainFrm.CustomizeDblClick(Sender: TObject);
begin
@ -154,27 +260,16 @@ begin
RotateCustomValues;
end;
procedure TJvFullColorCircleDlgMainFrm.MemoKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
Key := 0; // discard any key but Enabled=False affects the text rendering
end;
procedure TJvFullColorCircleDlgMainFrm.MemoKeyPress(Sender: TObject; var Key: Char);
begin
Key := #0; // discard any key but Enabled=False affects the text rendering
end;
procedure TJvFullColorCircleDlgMainFrm.ComboBoxFileNameSelect(Sender: TObject);
procedure TJvFullColorCircleDlgMainFrm.cmbFileNameSelect(Sender: TObject);
var
Index: Integer;
fn: String;
begin
if ComboboxFileName.ItemIndex = -1 then
if cmbFileName.ItemIndex = -1 then
exit;
if Image.Picture.Bitmap <> nil then begin
fn := ImgDir + ComboboxFileName.Items[ComboboxFileName.ItemIndex];
fn := ImgDir + cmbFileName.Items[cmbFileName.ItemIndex];
if FileExists(fn) then
Image.Picture.LoadFromFile(fn)
else
@ -182,18 +277,24 @@ begin
end;
// Image.Picture.Bitmap := TBitmap.Create;
// Image.Picture.Bitmap.LoadFromFile(ComboBoxFileName.Items[ComboBoxFileName.ItemIndex]);
// Image.Picture.Bitmap.LoadFromFile(cmbFileName.Items[cmbFileName.ItemIndex]);
Labels[6].Caption := RsCustomize;
{
with Memos[6].Lines do
begin
Clear;
Add(RsCustomize);
end;
}
Images[6].Picture.Bitmap.FreeImage;
for Index := Low(Images) to High(Images)-1 do
begin
Images[Index].Picture.Bitmap.FreeImage;
RotateBitmap(Image.Picture.Bitmap,Images[Index].Picture.Bitmap,ColorDeltas[Index]);
FormatMemo(Memos[Index],ColorDeltas[Index]);
FormatLabel(Labels[Index], ColorDeltas[Index]);
// FormatMemo(Memos[Index], ColorDeltas[Index]);
end;
RotateCustomValues;
end;
@ -201,9 +302,37 @@ end;
procedure TJvFullColorCircleDlgMainFrm.RotateCustomValues;
begin
RotateBitmap(Image.Picture.Bitmap,Images[6].Picture.Bitmap,JvFullColorCircleDialog.Delta);
FormatMemo(Memos[6],JvFullColorCircleDialog.Delta);
FormatLabel(Labels[6], JvFullColorCircleDialog.Delta);
// FormatMemo(Memos[6],JvFullColorCircleDialog.Delta);
end;
procedure TJvFullColorCircleDlgMainFrm.FormatLabel(ALabel: TLabel;
const Delta: TJvColorDelta);
var
Index: TJvAxisIndex;
L: TStringList;
begin
L := TStringList.Create;
try
with ColorSpaceManager, ColorSpace[Delta.ColorID] do begin
L.Add(Format('%s (%s)', [Name, ShortName]));
for Index := Low(TJvAxisIndex) to High(TJvAxisIndex) do
L.Add(Format('%s: %d, %d, %d', [
AxisName[Index],
Delta.AxisRed[Index].Value,
Delta.AxisGreen[Index].Value,
Delta.AxisBlue[Index].Value
]));
if ALabel = Labels[6] then
L.Add(RsCustomize);
end;
ALabel.Caption := L.Text;
finally
L.Free;
end;
end;
(*
procedure TJvFullColorCircleDlgMainFrm.FormatMemo(AMemo: TMemo; const Delta: TJvColorDelta);
var
Index: TJvAxisIndex;
@ -218,7 +347,8 @@ begin
if AMemo = Memos[6] then
Add(RsCustomize);
end;
end;
end; *)
{ TJvColorDeltaList }

View File

@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="11"/>
<Version Value="12"/>
<PathDelim Value="\"/>
<General>
<Flags>
<CompatibilityMode Value="True"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="JvFullColorCircleDialogPrj"/>
<Scaled Value="True"/>
<ResourceType Value="res"/>

View File

@ -2,12 +2,12 @@ object JvFullColorCircleFrm: TJvFullColorCircleFrm
Left = 274
Height = 574
Top = 219
Width = 1010
Width = 1022
AutoSize = True
BorderStyle = bsDialog
Caption = 'Color circle configurations'
ClientHeight = 574
ClientWidth = 1010
ClientWidth = 1022
Color = clBtnFace
Font.Color = clWindowText
KeyPreview = True
@ -64,21 +64,21 @@ object JvFullColorCircleFrm: TJvFullColorCircleFrm
Left = 412
Height = 550
Top = 8
Width = 590
Width = 602
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Right = 8
BevelInner = bvRaised
BevelOuter = bvLowered
Caption = 'PanelGraphics'
ClientHeight = 550
ClientWidth = 590
ClientWidth = 602
Font.Color = clWindowText
ParentFont = False
TabOrder = 5
object LabelAxisSettings: TLabel
AnchorSideLeft.Control = JvColorAxisConfigCombo
AnchorSideTop.Control = PanelGraphics
Left = 208
Left = 217
Height = 15
Top = 10
Width = 69
@ -98,10 +98,10 @@ object JvFullColorCircleFrm: TJvFullColorCircleFrm
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = PanelGraphics
AnchorSideBottom.Side = asrBottom
Left = 100
Left = 106
Height = 480
Top = 60
Width = 472
Width = 478
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
@ -125,12 +125,14 @@ object JvFullColorCircleFrm: TJvFullColorCircleFrm
OnBlueColorChange = JvColorCircleBlueColorChange
end
object JvFullColorTrackBarCommon: TJvFullColorTrackBar
AnchorSideLeft.Control = Bevel10
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = JvColorCircle
AnchorSideBottom.Control = Bevel10
Left = 40
Left = 38
Height = 237
Top = 60
Width = 21
Width = 24
Anchors = [akTop, akLeft, akBottom]
FullColor = 83886079
AxisConfig = acYZX
@ -146,10 +148,10 @@ object JvFullColorCircleFrm: TJvFullColorCircleFrm
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = JvFullColorTrackBarRed
AnchorSideBottom.Side = asrBottom
Left = 68
Left = 74
Height = 237
Top = 303
Width = 21
Width = 24
Anchors = [akTop, akLeft, akBottom]
BorderSpacing.Left = 8
FullColor = 83820544
@ -167,10 +169,10 @@ object JvFullColorCircleFrm: TJvFullColorCircleFrm
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = JvFullColorTrackBarRed
AnchorSideBottom.Side = asrBottom
Left = 39
Left = 42
Height = 237
Top = 303
Width = 21
Width = 24
Anchors = [akTop, akLeft, akBottom]
BorderSpacing.Left = 8
FullColor = 67174144
@ -190,7 +192,7 @@ object JvFullColorCircleFrm: TJvFullColorCircleFrm
Left = 10
Height = 237
Top = 303
Width = 21
Width = 24
Anchors = [akTop, akLeft, akBottom]
BorderSpacing.Left = 8
FullColor = 67109119
@ -206,7 +208,7 @@ object JvFullColorCircleFrm: TJvFullColorCircleFrm
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = LabelAxisSettings
AnchorSideTop.Side = asrBottom
Left = 208
Left = 217
Height = 23
Top = 29
Width = 257
@ -222,10 +224,12 @@ object JvFullColorCircleFrm: TJvFullColorCircleFrm
AnchorSideLeft.Control = PanelGraphics
AnchorSideTop.Control = JvColorCircle
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = JvFullColorTrackBarBlue
AnchorSideRight.Side = asrBottom
Left = 2
Height = 6
Top = 297
Width = 90
Width = 96
end
end
object PanelCommonSettings: TPanel

View File

@ -714,12 +714,17 @@ begin
w := 0;
for i := 0 to JvColorSpaceCombo.Items.Count-1 do
w := Max(w, JvColorSpaceCombo.Canvas.TextWidth(JvColorSpaceCombo.Items[i]));
JvColorSpaceCombo.Width := w + 32;
JvColorSpaceCombo.Width := w + Scale96ToFont(32);
Bevel1.Shape := bsSpacer;
Bevel10.Shape := bsSpacer;
JvColorCircle.Constraints.MinWidth := JvColorCircle.Height;
JvFullColorTrackBarCommon.Width := Scale96ToFont(24);
JvFullColorTrackBarRed.Width := JvFullColorTrackBarCommon.Width;
JvFullColorTrackBarGreen.Width := JvFullColorTrackBarCommon.Width;
JvFullColorTrackBarBlue.Width := JvFullColorTrackBarCommon.Width;
Position := poScreenCenter;
end;