2008-02-03 12:05:55 +00:00
|
|
|
{*********************************************************}
|
|
|
|
{* VPEDSHAPE.PAS 1.03 *}
|
|
|
|
{*********************************************************}
|
|
|
|
|
|
|
|
{* ***** BEGIN LICENSE BLOCK ***** *}
|
|
|
|
{* Version: MPL 1.1 *}
|
|
|
|
{* *}
|
|
|
|
{* 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/ *}
|
|
|
|
{* *}
|
|
|
|
{* Software distributed under the License is distributed on an "AS IS" basis, *}
|
|
|
|
{* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License *}
|
|
|
|
{* for the specific language governing rights and limitations under the *}
|
|
|
|
{* License. *}
|
|
|
|
{* *}
|
|
|
|
{* The Original Code is TurboPower Visual PlanIt *}
|
|
|
|
{* *}
|
|
|
|
{* The Initial Developer of the Original Code is TurboPower Software *}
|
|
|
|
{* *}
|
|
|
|
{* Portions created by TurboPower Software Inc. are Copyright (C) 2002 *}
|
|
|
|
{* TurboPower Software Inc. All Rights Reserved. *}
|
|
|
|
{* *}
|
|
|
|
{* Contributor(s): *}
|
|
|
|
{* *}
|
|
|
|
{* ***** END LICENSE BLOCK ***** *}
|
|
|
|
|
2016-06-22 07:59:17 +00:00
|
|
|
{$I vp.inc}
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
unit VpEdShape;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
{$IFDEF LCL}
|
2016-07-08 10:04:20 +00:00
|
|
|
LCLProc, LCLType, LCLIntf, ColorBox,
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ELSE}
|
2016-06-22 07:59:17 +00:00
|
|
|
Windows, Messages, ColorGrd,
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ENDIF}
|
|
|
|
SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
2016-07-08 10:04:20 +00:00
|
|
|
StdCtrls, ExtCtrls, TypInfo, ComCtrls, Buttons,
|
2008-02-03 12:05:55 +00:00
|
|
|
VpPrtFmt;
|
|
|
|
|
|
|
|
type
|
2016-07-08 10:04:20 +00:00
|
|
|
|
|
|
|
{ TfrmEditShape }
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
TfrmEditShape = class(TForm)
|
|
|
|
btnCancel: TButton;
|
|
|
|
btnOk: TButton;
|
|
|
|
cbBrushStyle: TComboBox;
|
2016-07-08 10:04:20 +00:00
|
|
|
cbBrushColor: TColorBox;
|
2008-02-03 12:05:55 +00:00
|
|
|
cbPenMode: TComboBox;
|
|
|
|
cbPenStyle: TComboBox;
|
2016-07-08 10:04:20 +00:00
|
|
|
cbPenColor: TColorBox;
|
2008-02-03 12:05:55 +00:00
|
|
|
gbBrush: TGroupBox;
|
|
|
|
gbPen: TGroupBox;
|
2016-07-08 10:04:20 +00:00
|
|
|
gbShapes: TGroupBox;
|
|
|
|
lblBrushStyle: TLabel;
|
|
|
|
lblBrushColor: TLabel;
|
|
|
|
lblPenStyle: TLabel;
|
|
|
|
lblPenColor: TLabel;
|
|
|
|
lblPenWidth: TLabel;
|
|
|
|
lblPenMode: TLabel;
|
|
|
|
SpeedButton1: TSpeedButton;
|
|
|
|
SpeedButton2: TSpeedButton;
|
|
|
|
SpeedButton3: TSpeedButton;
|
|
|
|
SpeedButton4: TSpeedButton;
|
|
|
|
SpeedButton5: TSpeedButton;
|
|
|
|
SpeedButton6: TSpeedButton;
|
|
|
|
SpeedButton7: TSpeedButton;
|
|
|
|
SpeedButton8: TSpeedButton;
|
2008-02-03 12:05:55 +00:00
|
|
|
udPenWidth: TUpDown;
|
|
|
|
edPenWidth: TEdit;
|
|
|
|
procedure btnOkClick(Sender: TObject);
|
|
|
|
procedure btnCancelClick(Sender: TObject);
|
2016-07-08 10:04:20 +00:00
|
|
|
procedure cbBrushColorChange(Sender: TObject);
|
|
|
|
procedure cbBrushStyleChange(Sender: TObject);
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure cbBrushStyleDrawItem(Control: TWinControl; Index: Integer;
|
|
|
|
Rect: TRect; State: TOwnerDrawState);
|
2016-07-08 10:04:20 +00:00
|
|
|
procedure cbPenColorChange(Sender: TObject);
|
|
|
|
procedure cbPenStyleChange(Sender: TObject);
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure cbPenStyleDrawItem(Control: TWinControl; Index: Integer;
|
|
|
|
Rect: TRect; State: TOwnerDrawState);
|
2016-07-08 10:04:20 +00:00
|
|
|
procedure edPenWidthChange(Sender: TObject);
|
|
|
|
procedure FormCreate(Sender: TObject);
|
|
|
|
procedure FormDestroy(Sender: TObject);
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
private
|
2016-07-08 10:04:20 +00:00
|
|
|
FShapeButtons: array[TVpShapeType] of TSpeedButton;
|
|
|
|
FShapeBitmaps: array[TVpShapeType] of TBitmap;
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure FillBrushStyleList;
|
|
|
|
procedure FillPenStyleList;
|
|
|
|
procedure FillPenModeList;
|
2016-07-08 10:04:20 +00:00
|
|
|
procedure PositionControls;
|
|
|
|
procedure SetCaptions;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
protected
|
2016-07-08 10:04:20 +00:00
|
|
|
procedure CreateBitmaps;
|
|
|
|
procedure DestroyBitmaps;
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure SaveData(AShape: TVpPrintShape);
|
|
|
|
procedure SetData(AShape: TVpPrintShape);
|
2016-07-08 10:04:20 +00:00
|
|
|
procedure UpdateBitmap(AShape: TVpShapeType);
|
|
|
|
procedure UpdateBitmaps;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
public
|
|
|
|
function Execute(AShape : TVpPrintShape) : Boolean;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
2016-06-07 16:34:18 +00:00
|
|
|
{$IFDEF LCL}
|
|
|
|
{$R *.lfm}
|
|
|
|
{$ELSE}
|
|
|
|
{$R *.dfm}
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ENDIF}
|
|
|
|
|
2016-07-08 10:04:20 +00:00
|
|
|
uses
|
|
|
|
Math, VpMisc, VpSr;
|
|
|
|
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
{ TfrmEditShape }
|
2016-07-08 10:04:20 +00:00
|
|
|
|
|
|
|
procedure TfrmEditShape.CreateBitmaps;
|
|
|
|
var
|
|
|
|
shape: TVpShapeType;
|
|
|
|
w, h: Integer;
|
|
|
|
begin
|
|
|
|
w := SpeedButton1.Width - 8;
|
|
|
|
h := SpeedButton1.Height - 8;
|
|
|
|
for shape := Low(TVpShapeType) to High(TVpShapeType) do begin
|
|
|
|
FShapeBitmaps[shape] := TBitmap.Create;
|
|
|
|
with FShapeBitmaps[shape] do begin
|
|
|
|
PixelFormat := pf24Bit;
|
|
|
|
SetSize(w, h);
|
|
|
|
Transparent := true;
|
|
|
|
end;
|
|
|
|
FShapeButtons[shape].Glyph.Assign(FShapeBitmaps[shape]);
|
|
|
|
case shape of
|
|
|
|
ustRectangle : FShapeButtons[shape].Hint := RSRectangle;
|
|
|
|
ustTopLine : FShapeButtons[shape].Hint := RSTopLine;
|
|
|
|
ustBottomLine : FShapeButtons[shape].Hint := RSBottomLine;
|
|
|
|
ustLeftLine : FShapeButtons[shape].Hint := RSLeftLine;
|
|
|
|
ustRightLine : FShapeButtons[shape].Hint := RSRightLine;
|
|
|
|
ustTLToBRLine : FShapeButtons[shape].Hint := RSTLToBRLine;
|
|
|
|
ustBLToTRLine : FShapeButtons[shape].Hint := RSBLToTRLine;
|
|
|
|
ustEllipse : FShapeButtons[shape].Hint := RSEllipse;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmEditShape.DestroyBitmaps;
|
|
|
|
var
|
|
|
|
shape: TVpShapeType;
|
|
|
|
begin
|
|
|
|
for shape := Low(TVpShapeType) to High(TVpShapeType) do
|
|
|
|
FShapeBitmaps[shape].Free;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmEditShape.edPenWidthChange(Sender: TObject);
|
|
|
|
begin
|
|
|
|
UpdateBitmaps;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmEditShape.UpdateBitmap(AShape: TVpShapeType);
|
|
|
|
var
|
|
|
|
pw: Integer;
|
|
|
|
bkcol, pcol, bcol: TColor;
|
|
|
|
begin
|
|
|
|
pw := StrToInt(edPenWidth.Text);
|
|
|
|
pcol := cbPenColor.Selected;
|
|
|
|
bcol := cbBrushColor.Selected;
|
|
|
|
bkcol := clWhite;
|
|
|
|
while (bkcol = pcol) or (bkcol = bcol) do
|
|
|
|
bkcol := rgb(random(256), random(256), random(256));
|
|
|
|
with FShapeBitmaps[AShape] do begin
|
|
|
|
TransparentColor := bkcol;
|
|
|
|
Canvas.Brush.Color := bkCol;
|
|
|
|
Canvas.Brush.Style := bsSolid;
|
|
|
|
Canvas.FillRect(0, 0, Width, Height);
|
|
|
|
Canvas.Pen.Width := pw;
|
|
|
|
Canvas.Pen.Style := TPenStyle(cbPenStyle.ItemIndex);
|
|
|
|
Canvas.Pen.Color := pcol;
|
|
|
|
Canvas.Brush.Style := TBrushStyle(cbBrushStyle.ItemIndex);
|
|
|
|
Canvas.Brush.Color := bcol;
|
|
|
|
case AShape of
|
|
|
|
ustRectangle : Canvas.Rectangle(pw, pw, Width-pw, Height-pw);
|
|
|
|
ustTopLine : Canvas.Line(pw, pw, Width-pw, pw);
|
|
|
|
ustBottomLine : Canvas.Line(pw, Height-pw, Width, Height-pw);
|
|
|
|
ustLeftLine : Canvas.Line(pw, pw, pw, Height-pw);
|
|
|
|
ustRightLine : Canvas.Line(Width-pw, pw, Width-pw, Height);
|
|
|
|
ustTLToBRLine : Canvas.Line(pw, pw, Width-pw, Height-pw);
|
|
|
|
ustBLToTRLine : Canvas.Line(pw, Height-pw, Width-pw, pw);
|
|
|
|
ustEllipse : Canvas.Ellipse(pw, pw, Width-pw, Height-pw);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
FShapeButtons[AShape].Glyph.Assign(FShapeBitmaps[AShape]);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmEditShape.UpdateBitmaps;
|
|
|
|
var
|
|
|
|
shape: TVpShapeType;
|
|
|
|
begin
|
|
|
|
for shape := Low(TVpShapeType) to High(TVpShapeType) do
|
|
|
|
UpdateBitmap(shape);
|
|
|
|
end;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure TfrmEditShape.FormCreate(Sender: TObject);
|
|
|
|
begin
|
2016-07-08 10:04:20 +00:00
|
|
|
FShapeButtons[ustRectangle] := SpeedButton1;
|
|
|
|
FShapeButtons[ustTopLine] := SpeedButton2;
|
|
|
|
FShapeButtons[ustBottomLine] := SpeedButton3;
|
|
|
|
FShapeButtons[ustLeftLine] := SpeedButton4;
|
|
|
|
FShapeButtons[ustRightLine] := SpeedButton5;
|
|
|
|
FShapeButtons[ustTLToBRLine] := SpeedButton6;
|
|
|
|
FShapeButtons[ustBLToTRLine] := SpeedButton7;
|
|
|
|
FShapeButtons[ustEllipse] := SpeedButton8;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
FillBrushStyleList;
|
|
|
|
FillPenStyleList;
|
|
|
|
FillPenModeList;
|
2016-07-08 10:04:20 +00:00
|
|
|
|
|
|
|
CreateBitmaps;
|
|
|
|
UpdateBitmaps;
|
|
|
|
|
|
|
|
SetCaptions;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmEditShape.FormDestroy(Sender: TObject);
|
|
|
|
begin
|
|
|
|
DestroyBitmaps;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
2016-07-08 10:04:20 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
{=====}
|
|
|
|
function TfrmEditShape.Execute(AShape: TVpPrintShape): Boolean;
|
|
|
|
begin
|
|
|
|
SetData(AShape);
|
|
|
|
Result := ShowModal = mrOk;
|
|
|
|
if Result then
|
|
|
|
SaveData(AShape);
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
procedure TfrmEditShape.btnOkClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
ModalResult := mrOk;
|
|
|
|
end;
|
2016-07-08 10:04:20 +00:00
|
|
|
|
|
|
|
procedure TfrmEditShape.cbBrushColorChange(Sender: TObject);
|
|
|
|
begin
|
|
|
|
UpdateBitmaps;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmEditShape.cbBrushStyleChange(Sender: TObject);
|
|
|
|
begin
|
|
|
|
UpdateBitmaps;
|
|
|
|
end;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
{=====}
|
|
|
|
procedure TfrmEditShape.btnCancelClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
ModalResult := mrCancel;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
procedure TfrmEditShape.FillBrushStyleList;
|
|
|
|
var
|
2016-07-08 10:04:20 +00:00
|
|
|
Style: TBrushStyle;
|
|
|
|
StyleName: string;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
for Style := Low(TBrushStyle) to High(TBrushStyle) do begin
|
|
|
|
StyleName := GetEnumName(TypeInfo(TBrushStyle), Ord(Style));
|
|
|
|
cbBrushStyle.Items.Add(StyleName);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
procedure TfrmEditShape.FillPenModeList;
|
|
|
|
var
|
2016-07-08 10:04:20 +00:00
|
|
|
Mode: TPenMode;
|
|
|
|
ModeName: string;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
for Mode := Low(TPenMode) to High(TPenMode) do begin
|
|
|
|
ModeName := GetEnumName(TypeInfo(TPenMode), Ord(Mode));
|
|
|
|
cbPenMode.Items.Add(ModeName);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
procedure TfrmEditShape.FillPenStyleList;
|
|
|
|
var
|
2016-07-08 10:04:20 +00:00
|
|
|
Style: TPenStyle;
|
|
|
|
StyleName: string;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
for Style := Low(TPenStyle) to High(TPenStyle) do begin
|
|
|
|
StyleName := GetEnumName(TypeInfo(TPenStyle), Ord(Style));
|
|
|
|
cbPenStyle.Items.Add(StyleName);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
2016-07-08 10:04:20 +00:00
|
|
|
procedure TfrmEditShape.PositionControls;
|
|
|
|
const
|
|
|
|
DELTA = 8;
|
|
|
|
var
|
|
|
|
w: Integer;
|
|
|
|
cnv: TControlCanvas;
|
|
|
|
shape: TVpShapeType;
|
|
|
|
begin
|
|
|
|
w := MaxValue([GetLabelWidth(lblPenColor), GetLabelWidth(lblPenStyle),
|
|
|
|
GetLabelWidth(lblPenWidth), GetLabelWidth(lblPenMode)]) + 2 * DELTA;
|
|
|
|
cbPenColor.Left := w;
|
|
|
|
cbPenStyle.Left := w;
|
|
|
|
edPenWidth.Left := w;
|
|
|
|
cbPenMode.Left := w;
|
|
|
|
lblPenColor.Left := cbPenColor.Left - GetLabelWidth(lblPenColor) - DELTA;
|
|
|
|
lblPenStyle.Left := cbPenColor.Left - GetLabelWidth(lblPenStyle) - DELTA;
|
|
|
|
lblPenWidth.Left := cbPenColor.Left - GetLabelWidth(lblPenWidth) - DELTA;
|
|
|
|
lblPenMode.Left := cbPenColor.Left - GetLabelWidth(lblPenMode) - DELTA;
|
|
|
|
gbPen.Width := RightOf(cbPenColor) + DELTA;
|
|
|
|
|
|
|
|
w := MaxValue([GetLabelWidth(lblBrushColor), GetLabelWidth(lblBrushStyle)]) + 2*DELTA;
|
|
|
|
cbBrushColor.Left := w;
|
|
|
|
cbBrushStyle.Left := w;
|
|
|
|
lblBrushColor.Left := cbBrushColor.Left - GetLabelWidth(lblBrushColor) - DELTA;
|
|
|
|
lblBrushStyle.Left := cbBrushColor.Left - GetLabelWidth(lblBrushStyle) - DELTA;
|
|
|
|
gbBrush.Left := RightOf(gbPen) + 16;
|
|
|
|
gbBrush.Width := RightOf(cbBrushColor) + DELTA;
|
|
|
|
|
|
|
|
cnv := TControlCanvas.Create;
|
|
|
|
try
|
|
|
|
cnv.Control := btnOK;
|
|
|
|
cnv.Font.Assign(btnOK.Font);
|
|
|
|
btnOK.Width := MaxValue([cnv.TextWidth(btnOK.Caption), cnv.TextWidth(btnCancel.Caption)]) + 16;
|
|
|
|
finally
|
|
|
|
cnv.Free;
|
|
|
|
end;
|
|
|
|
|
|
|
|
btnCancel.Width := btnOK.Width;
|
|
|
|
if btnOK.Width + DELTA + btnCancel.Width > gbBrush.Width then
|
|
|
|
gbBrush.Width := btnOK.Width + DELTA + btnCancel.Width;
|
|
|
|
btnCancel.Left := RightOf(gbBrush) - btnCancel.Width;
|
|
|
|
btnOK.Left := btnCancel.Left - DELTA - btnOK.Width;
|
|
|
|
|
|
|
|
ClientWidth := RightOf(gbBrush) + gbPen.Left;
|
|
|
|
|
|
|
|
gbShapes.Width := ClientWidth - gbShapes.Left * 2;
|
|
|
|
w := (gbShapes.ClientWidth - 11 * DELTA) div 8;
|
|
|
|
for shape := Low(TVpShapeType) to High(TVpShapeType) do begin
|
|
|
|
if shape = Low(TVpShapeType) then
|
|
|
|
FShapeButtons[shape].Left := DELTA * 2 else
|
|
|
|
FShapeButtons[shape].Left := RightOf(FShapeButtons[pred(shape)]) + DELTA;
|
|
|
|
FShapeButtons[shape].Width := w;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure TfrmEditShape.SaveData(AShape: TVpPrintShape);
|
2016-07-08 10:04:20 +00:00
|
|
|
var
|
|
|
|
shape: TVpShapeType;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-07-08 10:04:20 +00:00
|
|
|
for shape := Low(TVpShapeType) to High(TVpShapeType) do
|
|
|
|
if FShapeButtons[shape].Down then begin
|
|
|
|
AShape.Shape := shape;
|
|
|
|
break;
|
|
|
|
end;
|
2016-07-08 10:43:54 +00:00
|
|
|
AShape.Pen.Style := TPenStyle(cbPenStyle.ItemIndex);
|
2008-02-03 12:05:55 +00:00
|
|
|
AShape.Pen.Width := udPenWidth.Position;
|
2016-07-08 10:43:54 +00:00
|
|
|
AShape.Pen.Color := cbPenColor.Selected;
|
|
|
|
AShape.Pen.Mode := TPenMode(cbPenMode.ItemIndex);
|
|
|
|
|
|
|
|
AShape.Brush.Style := TBrushStyle(cbBrushStyle.ItemIndex);
|
|
|
|
AShape.Brush.Color := cbBrushColor.Selected;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
2016-07-08 10:04:20 +00:00
|
|
|
procedure TfrmEditShape.SetCaptions;
|
|
|
|
begin
|
|
|
|
Caption := RSEditShapeCaption;
|
|
|
|
gbShapes.Caption := RsShapeCaption;
|
|
|
|
gbPen.Caption := RSPenCaption;
|
|
|
|
lblPenColor.Caption := RSColorLbl;
|
|
|
|
lblPenStyle.Caption := RSStyleLbl;
|
|
|
|
lblPenWidth.Caption := RSWidthLbl;
|
|
|
|
lblPenMode.Caption := RSModeLbl;
|
|
|
|
gbBrush.Caption := RSBrushCaption;
|
|
|
|
lblBrushColor.Caption := RSColorLbl;
|
|
|
|
lblBrushStyle.Caption := RSStyleLbl;
|
|
|
|
btnOK.Caption := RSOKBtn;
|
|
|
|
btnCancel.Caption := RSCancelBtn;
|
|
|
|
|
|
|
|
PositionControls;
|
|
|
|
end;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure TfrmEditShape.SetData(AShape: TVpPrintShape);
|
|
|
|
begin
|
2016-07-08 10:04:20 +00:00
|
|
|
FShapeButtons[AShape.Shape].Down := true;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
{ pen settings }
|
2016-07-08 10:04:20 +00:00
|
|
|
cbPenColor.Selected := AShape.Pen.Color;
|
2008-02-03 12:05:55 +00:00
|
|
|
udPenWidth.Position := AShape.Pen.Width;
|
2016-07-08 10:04:20 +00:00
|
|
|
cbPenStyle.ItemIndex := ord(AShape.Pen.Style);
|
|
|
|
cbPenMode.ItemIndex := ord(AShape.Pen.Mode);
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
{ brush settings }
|
2016-07-08 10:04:20 +00:00
|
|
|
cbBrushColor.Selected := AShape.Brush.Color;
|
|
|
|
cbBrushStyle.ItemIndex := ord(AShape.Brush.Style);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TfrmEditShape.cbBrushStyleDrawItem(Control: TWinControl;
|
|
|
|
Index: Integer; Rect: TRect; State: TOwnerDrawState);
|
|
|
|
var
|
|
|
|
SavePenColor, SaveBrushColor: TColor;
|
2016-07-08 10:04:20 +00:00
|
|
|
x: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
SaveBrushStyle: TBrushStyle;
|
|
|
|
Item : string;
|
|
|
|
TxtRect : TRect;
|
2016-07-08 10:04:20 +00:00
|
|
|
R: TRect;
|
|
|
|
bs: TBrushStyle;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-07-12 09:26:14 +00:00
|
|
|
Unused(Control, State);
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
Item := cbBrushStyle.Items[Index];
|
2016-07-08 10:04:20 +00:00
|
|
|
x := Rect.Left + HeightOf(Rect);
|
2008-02-03 12:05:55 +00:00
|
|
|
with cbBrushStyle.Canvas do
|
|
|
|
try
|
|
|
|
{ keep old settings }
|
|
|
|
SavePenColor := Pen.Color;
|
|
|
|
SaveBrushColor := Brush.Color;
|
|
|
|
SaveBrushStyle := Brush.Style;
|
|
|
|
|
2016-07-08 10:04:20 +00:00
|
|
|
R := Rect;
|
|
|
|
InflateRect(R, -1, -1);
|
|
|
|
R.Right := x;
|
|
|
|
bs := TBrushStyle(GetEnumValue(TypeInfo(TBrushStyle), Item));
|
|
|
|
|
|
|
|
{ draw background }
|
|
|
|
FillRect(Rect); // Brush is already set
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
{ draw frame }
|
2016-07-08 10:04:20 +00:00
|
|
|
if bs <> bsClear then begin
|
|
|
|
Brush.Color := clWindow;
|
|
|
|
Rectangle(R);
|
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-07-08 10:04:20 +00:00
|
|
|
if bs <> bsClear then begin
|
|
|
|
{ set up for drawing sample }
|
|
|
|
Brush.Style := bs;
|
|
|
|
Brush.Color := clWindowText; //cbBrushStyle.Font.Color;
|
|
|
|
Pen.Color := clWindowText; //txtColor; //cbBrushStyle.Font.Color;
|
|
|
|
|
|
|
|
{ Draw sample }
|
|
|
|
Rectangle(R);
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ draw the item text }
|
|
|
|
TxtRect := Classes.Rect(x, Rect.Top, Rect.Right, Rect.Bottom);
|
|
|
|
TextRect(TxtRect, TxtRect.Left + 1, TxtRect.Top + 1, Item); // Font color already set
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-07-08 10:04:20 +00:00
|
|
|
finally
|
2008-02-03 12:05:55 +00:00
|
|
|
{ restore settings }
|
|
|
|
Brush.Color := SaveBrushColor;
|
|
|
|
Brush.Style := SaveBrushStyle;
|
|
|
|
Pen.Color := SavePenColor;
|
|
|
|
end;
|
|
|
|
end;
|
2016-07-08 10:04:20 +00:00
|
|
|
|
|
|
|
procedure TfrmEditShape.cbPenColorChange(Sender: TObject);
|
|
|
|
begin
|
|
|
|
UpdateBitmaps;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmEditShape.cbPenStyleChange(Sender: TObject);
|
|
|
|
begin
|
|
|
|
UpdateBitmaps;
|
|
|
|
end;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TfrmEditShape.cbPenStyleDrawItem(Control: TWinControl;
|
|
|
|
Index: Integer; Rect: TRect; State: TOwnerDrawState);
|
|
|
|
var
|
|
|
|
SavePenColor, SaveBrushColor: TColor;
|
|
|
|
SavePenStyle: TPenStyle;
|
|
|
|
Item: string;
|
|
|
|
TxtRect : TRect;
|
2016-07-08 10:04:20 +00:00
|
|
|
x, y: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-07-12 09:26:14 +00:00
|
|
|
Unused(Control, State);
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
Item := cbPenStyle.Items[Index];
|
2016-07-08 10:04:20 +00:00
|
|
|
x := Rect.Left + HeightOf(Rect) * 2;
|
|
|
|
y := Rect.Top + HeightOf(Rect) div 2;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
with cbPenStyle.Canvas do
|
|
|
|
try
|
2016-07-08 10:04:20 +00:00
|
|
|
{ Keep old settings }
|
2008-02-03 12:05:55 +00:00
|
|
|
SavePenColor := Pen.Color;
|
|
|
|
SaveBrushColor := Brush.Color;
|
|
|
|
SavePenStyle := Pen.Style;
|
|
|
|
|
2016-07-08 10:04:20 +00:00
|
|
|
{ Draw background }
|
|
|
|
FillRect(Rect); // Brush already set by caller
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-07-08 10:04:20 +00:00
|
|
|
{ Set up for drawing sample }
|
2008-02-03 12:05:55 +00:00
|
|
|
Brush.Color := cbPenStyle.Brush.Color;
|
|
|
|
Pen.Color := cbPenStyle.Font.Color;
|
2016-07-08 10:04:20 +00:00
|
|
|
Rectangle(Rect.Left + 1, Rect.Top + 1, x - 1, Rect.Bottom - 1);
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
{ Draw sample }
|
|
|
|
Pen.Style := TPenStyle(GetEnumValue(TypeInfo(TPenStyle), Item));
|
|
|
|
Pen.Color := cbPenStyle.Font.Color;
|
|
|
|
|
2016-07-08 10:04:20 +00:00
|
|
|
MoveTo(Rect.Left + 1, y);
|
|
|
|
LineTo(x - 1, y);
|
|
|
|
MoveTo(Rect.Left + 1, y + 1);
|
|
|
|
LineTo(x - 1, y + 1);
|
|
|
|
|
|
|
|
{ Draw the item text }
|
|
|
|
TxtRect := Classes.Rect(x, Rect.Top, Rect.Right, Rect.Bottom);
|
|
|
|
TextRect(TxtRect, TxtRect.Left + 1, TxtRect.Top + 1, Item); // Color already set
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-07-08 10:04:20 +00:00
|
|
|
finally
|
2008-02-03 12:05:55 +00:00
|
|
|
{ restore settings }
|
|
|
|
Brush.Color := SaveBrushColor;
|
|
|
|
Pen.Style := SavePenStyle;
|
|
|
|
Pen.Color := SavePenColor;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
end.
|
|
|
|
|