TAChart: Replace SeriesPointerStyleCombobox by more general-purpose TChartCombobox

git-svn-id: trunk@54097 -
This commit is contained in:
wp 2017-02-05 22:54:43 +00:00
parent d358020cf0
commit b0c1d9e402
13 changed files with 1254 additions and 8 deletions

2
.gitattributes vendored
View File

@ -4379,6 +4379,7 @@ components/tachart/icons/makeicons.bat svneol=native#text/plain
components/tachart/icons/tcalculatedchartsource.png -text svneol=unset#images/png
components/tachart/icons/tchart.png -text svneol=unset#images/png
components/tachart/icons/tchartaxistransformations.png -text svneol=unset#images/png
components/tachart/icons/tchartcombobox.png -text
components/tachart/icons/tchartextentlink.png -text svneol=unset#images/png
components/tachart/icons/tchartguiconnectorbgra.png -text svneol=unset#images/png
components/tachart/icons/tchartimagelist.png -text svneol=unset#images/png
@ -4393,7 +4394,6 @@ components/tachart/icons/tdbchartsource.png -text svneol=unset#images/png
components/tachart/icons/tintervalchartsource.png -text svneol=unset#images/png
components/tachart/icons/tlistchartsource.png -text svneol=unset#images/png
components/tachart/icons/trandomchartsource.png -text svneol=unset#images/png
components/tachart/icons/tseriespointerstylecombobox.png -text
components/tachart/icons/tuserdefinedchartsource.png -text svneol=unset#images/png
components/tachart/languages/tachartstrconsts.de.po svneol=native#text/plain
components/tachart/languages/tachartstrconsts.fi.po svneol=native#text/plain

Binary file not shown.

After

(image error) Size: 443 B

Binary file not shown.

Before

(image error) Size: 455 B

View File

@ -57,10 +57,51 @@ msgstr "Unten"
msgid "Box-and-whiskers series"
msgstr "Box-und-Whisker-Plot"
#: tachartstrconsts.rsbsbdiagonal
msgid "backward-diagonal hatch"
msgstr "rückwärts diagonal"
#: tachartstrconsts.rsbsclear
msgctxt "tachartstrconsts.rsbsclear"
msgid "clear fill"
msgstr "ohne Füllung"
#: tachartstrconsts.rsbscross
msgid "crossed"
msgstr "gekreuzt"
#: tachartstrconsts.rsbsdiagcross
msgid "diagonally crossed"
msgstr "diagonal gekreuzt"
#: tachartstrconsts.rsbsfdiagonal
msgid "forward-diagonal hatch"
msgstr "vorwärts diagonal"
#: tachartstrconsts.rsbshorizontal
msgid "horizontally hatched"
msgstr "horizontal schraffiert"
#: tachartstrconsts.rsbsimage
msgid "image fill"
msgstr "Bildfüllung"
#: tachartstrconsts.rsbspattern
msgid "pattern fill"
msgstr "Musterfüllung"
#: tachartstrconsts.rsbsplineseries
msgid "B-Spline series"
msgstr "B-Spline"
#: tachartstrconsts.rsbssolid
msgid "solid fill"
msgstr "ganzflächig gefüllt"
#: tachartstrconsts.rsbsvertical
msgid "vertically hatched"
msgstr "vertikal schraffiert"
#: tachartstrconsts.rsbubbleseries
msgid "Bubble series"
msgstr "Blasen-Diagramm"
@ -241,6 +282,39 @@ msgstr "Punkt"
msgid "Polar series"
msgstr "Polar-Diagramm"
#: tachartstrconsts.rspsclear
msgctxt "tachartstrconsts.rspsclear"
msgid "clear line"
msgstr "keine Linie"
#: tachartstrconsts.rspsdash
msgid "dashed line"
msgstr "gestrichelt"
#: tachartstrconsts.rspsdashdot
msgid "dash-dot"
msgstr "strich-punkt"
#: tachartstrconsts.rspsdashdotdot
msgid "dash-dot-dot"
msgstr "strich-punkt-punkt"
#: tachartstrconsts.rspsdot
msgid "dotted line"
msgstr "gepunktelt"
#: tachartstrconsts.rspsinsideframe
msgid "solid (inside frame)"
msgstr "ganzflächig (innerhalb)"
#: tachartstrconsts.rspspattern
msgid "patterned line"
msgstr "gemustert"
#: tachartstrconsts.rspssolid
msgid "solid line"
msgstr "durchgezogen"
#: tachartstrconsts.rsrectanglesymbol
msgid "Rectangle"
msgstr "Rechteck"

View File

@ -45,10 +45,51 @@ msgstr ""
msgid "Box-and-whiskers series"
msgstr "Laatikko-jana kuvaaja"
#: tachartstrconsts.rsbsbdiagonal
msgid "backward-diagonal hatch"
msgstr ""
#: tachartstrconsts.rsbsclear
msgctxt "tachartstrconsts.rsbsclear"
msgid "clear fill"
msgstr ""
#: tachartstrconsts.rsbscross
msgid "crossed"
msgstr ""
#: tachartstrconsts.rsbsdiagcross
msgid "diagonally crossed"
msgstr ""
#: tachartstrconsts.rsbsfdiagonal
msgid "forward-diagonal hatch"
msgstr ""
#: tachartstrconsts.rsbshorizontal
msgid "horizontally hatched"
msgstr ""
#: tachartstrconsts.rsbsimage
msgid "image fill"
msgstr ""
#: tachartstrconsts.rsbspattern
msgid "pattern fill"
msgstr ""
#: tachartstrconsts.rsbsplineseries
msgid "B-Spline series"
msgstr "B-käyrä kuvaaja"
#: tachartstrconsts.rsbssolid
msgid "solid fill"
msgstr ""
#: tachartstrconsts.rsbsvertical
msgid "vertically hatched"
msgstr ""
#: tachartstrconsts.rsbubbleseries
msgid "Bubble series"
msgstr "Kuplakuvaaja"
@ -229,6 +270,39 @@ msgstr ""
msgid "Polar series"
msgstr "Napakuvaaja"
#: tachartstrconsts.rspsclear
msgctxt "tachartstrconsts.rspsclear"
msgid "clear line"
msgstr ""
#: tachartstrconsts.rspsdash
msgid "dashed line"
msgstr ""
#: tachartstrconsts.rspsdashdot
msgid "dash-dot"
msgstr ""
#: tachartstrconsts.rspsdashdotdot
msgid "dash-dot-dot"
msgstr ""
#: tachartstrconsts.rspsdot
msgid "dotted line"
msgstr ""
#: tachartstrconsts.rspsinsideframe
msgid "solid (inside frame)"
msgstr ""
#: tachartstrconsts.rspspattern
msgid "patterned line"
msgstr ""
#: tachartstrconsts.rspssolid
msgid "solid line"
msgstr ""
#: tachartstrconsts.rsrectanglesymbol
msgid "Rectangle"
msgstr ""

View File

@ -55,10 +55,51 @@ msgstr ""
msgid "Box-and-whiskers series"
msgstr "Séries de boîtes à moustaches"
#: tachartstrconsts.rsbsbdiagonal
msgid "backward-diagonal hatch"
msgstr ""
#: tachartstrconsts.rsbsclear
msgctxt "tachartstrconsts.rsbsclear"
msgid "clear fill"
msgstr ""
#: tachartstrconsts.rsbscross
msgid "crossed"
msgstr ""
#: tachartstrconsts.rsbsdiagcross
msgid "diagonally crossed"
msgstr ""
#: tachartstrconsts.rsbsfdiagonal
msgid "forward-diagonal hatch"
msgstr ""
#: tachartstrconsts.rsbshorizontal
msgid "horizontally hatched"
msgstr ""
#: tachartstrconsts.rsbsimage
msgid "image fill"
msgstr ""
#: tachartstrconsts.rsbspattern
msgid "pattern fill"
msgstr ""
#: tachartstrconsts.rsbsplineseries
msgid "B-Spline series"
msgstr "Séries de B-Splines"
#: tachartstrconsts.rsbssolid
msgid "solid fill"
msgstr ""
#: tachartstrconsts.rsbsvertical
msgid "vertically hatched"
msgstr ""
#: tachartstrconsts.rsbubbleseries
msgid "Bubble series"
msgstr "Séries de bulles"
@ -239,6 +280,39 @@ msgstr ""
msgid "Polar series"
msgstr "Séries polaires"
#: tachartstrconsts.rspsclear
msgctxt "tachartstrconsts.rspsclear"
msgid "clear line"
msgstr ""
#: tachartstrconsts.rspsdash
msgid "dashed line"
msgstr ""
#: tachartstrconsts.rspsdashdot
msgid "dash-dot"
msgstr ""
#: tachartstrconsts.rspsdashdotdot
msgid "dash-dot-dot"
msgstr ""
#: tachartstrconsts.rspsdot
msgid "dotted line"
msgstr ""
#: tachartstrconsts.rspsinsideframe
msgid "solid (inside frame)"
msgstr ""
#: tachartstrconsts.rspspattern
msgid "patterned line"
msgstr ""
#: tachartstrconsts.rspssolid
msgid "solid line"
msgstr ""
#: tachartstrconsts.rsrectanglesymbol
msgid "Rectangle"
msgstr ""

View File

@ -55,10 +55,51 @@ msgstr "Alulra"
msgid "Box-and-whiskers series"
msgstr "Bajszos dobozok"
#: tachartstrconsts.rsbsbdiagonal
msgid "backward-diagonal hatch"
msgstr ""
#: tachartstrconsts.rsbsclear
msgctxt "tachartstrconsts.rsbsclear"
msgid "clear fill"
msgstr ""
#: tachartstrconsts.rsbscross
msgid "crossed"
msgstr ""
#: tachartstrconsts.rsbsdiagcross
msgid "diagonally crossed"
msgstr ""
#: tachartstrconsts.rsbsfdiagonal
msgid "forward-diagonal hatch"
msgstr ""
#: tachartstrconsts.rsbshorizontal
msgid "horizontally hatched"
msgstr ""
#: tachartstrconsts.rsbsimage
msgid "image fill"
msgstr ""
#: tachartstrconsts.rsbspattern
msgid "pattern fill"
msgstr ""
#: tachartstrconsts.rsbsplineseries
msgid "B-Spline series"
msgstr "B-Spline"
#: tachartstrconsts.rsbssolid
msgid "solid fill"
msgstr ""
#: tachartstrconsts.rsbsvertical
msgid "vertically hatched"
msgstr ""
#: tachartstrconsts.rsbubbleseries
msgid "Bubble series"
msgstr "Buborékok"
@ -239,6 +280,39 @@ msgstr ""
msgid "Polar series"
msgstr "Polár"
#: tachartstrconsts.rspsclear
msgctxt "tachartstrconsts.rspsclear"
msgid "clear line"
msgstr ""
#: tachartstrconsts.rspsdash
msgid "dashed line"
msgstr ""
#: tachartstrconsts.rspsdashdot
msgid "dash-dot"
msgstr ""
#: tachartstrconsts.rspsdashdotdot
msgid "dash-dot-dot"
msgstr ""
#: tachartstrconsts.rspsdot
msgid "dotted line"
msgstr ""
#: tachartstrconsts.rspsinsideframe
msgid "solid (inside frame)"
msgstr ""
#: tachartstrconsts.rspspattern
msgid "patterned line"
msgstr ""
#: tachartstrconsts.rspssolid
msgid "solid line"
msgstr ""
#: tachartstrconsts.rsrectanglesymbol
msgid "Rectangle"
msgstr ""

View File

@ -45,10 +45,51 @@ msgstr ""
msgid "Box-and-whiskers series"
msgstr ""
#: tachartstrconsts.rsbsbdiagonal
msgid "backward-diagonal hatch"
msgstr ""
#: tachartstrconsts.rsbsclear
msgctxt "tachartstrconsts.rsbsclear"
msgid "clear fill"
msgstr ""
#: tachartstrconsts.rsbscross
msgid "crossed"
msgstr ""
#: tachartstrconsts.rsbsdiagcross
msgid "diagonally crossed"
msgstr ""
#: tachartstrconsts.rsbsfdiagonal
msgid "forward-diagonal hatch"
msgstr ""
#: tachartstrconsts.rsbshorizontal
msgid "horizontally hatched"
msgstr ""
#: tachartstrconsts.rsbsimage
msgid "image fill"
msgstr ""
#: tachartstrconsts.rsbspattern
msgid "pattern fill"
msgstr ""
#: tachartstrconsts.rsbsplineseries
msgid "B-Spline series"
msgstr ""
#: tachartstrconsts.rsbssolid
msgid "solid fill"
msgstr ""
#: tachartstrconsts.rsbsvertical
msgid "vertically hatched"
msgstr ""
#: tachartstrconsts.rsbubbleseries
msgid "Bubble series"
msgstr ""
@ -229,6 +270,39 @@ msgstr ""
msgid "Polar series"
msgstr ""
#: tachartstrconsts.rspsclear
msgctxt "tachartstrconsts.rspsclear"
msgid "clear line"
msgstr ""
#: tachartstrconsts.rspsdash
msgid "dashed line"
msgstr ""
#: tachartstrconsts.rspsdashdot
msgid "dash-dot"
msgstr ""
#: tachartstrconsts.rspsdashdotdot
msgid "dash-dot-dot"
msgstr ""
#: tachartstrconsts.rspsdot
msgid "dotted line"
msgstr ""
#: tachartstrconsts.rspsinsideframe
msgid "solid (inside frame)"
msgstr ""
#: tachartstrconsts.rspspattern
msgid "patterned line"
msgstr ""
#: tachartstrconsts.rspssolid
msgid "solid line"
msgstr ""
#: tachartstrconsts.rsrectanglesymbol
msgid "Rectangle"
msgstr ""

View File

@ -55,10 +55,51 @@ msgstr "Нижняя"
msgid "Box-and-whiskers series"
msgstr "Диаграмма размаха"
#: tachartstrconsts.rsbsbdiagonal
msgid "backward-diagonal hatch"
msgstr ""
#: tachartstrconsts.rsbsclear
msgctxt "tachartstrconsts.rsbsclear"
msgid "clear fill"
msgstr ""
#: tachartstrconsts.rsbscross
msgid "crossed"
msgstr ""
#: tachartstrconsts.rsbsdiagcross
msgid "diagonally crossed"
msgstr ""
#: tachartstrconsts.rsbsfdiagonal
msgid "forward-diagonal hatch"
msgstr ""
#: tachartstrconsts.rsbshorizontal
msgid "horizontally hatched"
msgstr ""
#: tachartstrconsts.rsbsimage
msgid "image fill"
msgstr ""
#: tachartstrconsts.rsbspattern
msgid "pattern fill"
msgstr ""
#: tachartstrconsts.rsbsplineseries
msgid "B-Spline series"
msgstr "Диаграмма с B-сплайнами"
#: tachartstrconsts.rsbssolid
msgid "solid fill"
msgstr ""
#: tachartstrconsts.rsbsvertical
msgid "vertically hatched"
msgstr ""
#: tachartstrconsts.rsbubbleseries
msgid "Bubble series"
msgstr "Пузырьковая диаграмма"
@ -239,6 +280,39 @@ msgstr ""
msgid "Polar series"
msgstr "Лепестковая диаграмма"
#: tachartstrconsts.rspsclear
msgctxt "tachartstrconsts.rspsclear"
msgid "clear line"
msgstr ""
#: tachartstrconsts.rspsdash
msgid "dashed line"
msgstr ""
#: tachartstrconsts.rspsdashdot
msgid "dash-dot"
msgstr ""
#: tachartstrconsts.rspsdashdotdot
msgid "dash-dot-dot"
msgstr ""
#: tachartstrconsts.rspsdot
msgid "dotted line"
msgstr ""
#: tachartstrconsts.rspsinsideframe
msgid "solid (inside frame)"
msgstr ""
#: tachartstrconsts.rspspattern
msgid "patterned line"
msgstr ""
#: tachartstrconsts.rspssolid
msgid "solid line"
msgstr ""
#: tachartstrconsts.rsrectanglesymbol
msgid "Rectangle"
msgstr ""

View File

@ -56,10 +56,51 @@ msgstr ""
msgid "Box-and-whiskers series"
msgstr "Box-and-whiskers diagram"
#: tachartstrconsts.rsbsbdiagonal
msgid "backward-diagonal hatch"
msgstr ""
#: tachartstrconsts.rsbsclear
msgctxt "tachartstrconsts.rsbsclear"
msgid "clear fill"
msgstr ""
#: tachartstrconsts.rsbscross
msgid "crossed"
msgstr ""
#: tachartstrconsts.rsbsdiagcross
msgid "diagonally crossed"
msgstr ""
#: tachartstrconsts.rsbsfdiagonal
msgid "forward-diagonal hatch"
msgstr ""
#: tachartstrconsts.rsbshorizontal
msgid "horizontally hatched"
msgstr ""
#: tachartstrconsts.rsbsimage
msgid "image fill"
msgstr ""
#: tachartstrconsts.rsbspattern
msgid "pattern fill"
msgstr ""
#: tachartstrconsts.rsbsplineseries
msgid "B-Spline series"
msgstr "B-Spline diagram"
#: tachartstrconsts.rsbssolid
msgid "solid fill"
msgstr ""
#: tachartstrconsts.rsbsvertical
msgid "vertically hatched"
msgstr ""
#: tachartstrconsts.rsbubbleseries
#, fuzzy
#| msgid "Bubbel series"
@ -242,6 +283,39 @@ msgstr ""
msgid "Polar series"
msgstr "Polardiagram"
#: tachartstrconsts.rspsclear
msgctxt "tachartstrconsts.rspsclear"
msgid "clear line"
msgstr ""
#: tachartstrconsts.rspsdash
msgid "dashed line"
msgstr ""
#: tachartstrconsts.rspsdashdot
msgid "dash-dot"
msgstr ""
#: tachartstrconsts.rspsdashdotdot
msgid "dash-dot-dot"
msgstr ""
#: tachartstrconsts.rspsdot
msgid "dotted line"
msgstr ""
#: tachartstrconsts.rspsinsideframe
msgid "solid (inside frame)"
msgstr ""
#: tachartstrconsts.rspspattern
msgid "patterned line"
msgstr ""
#: tachartstrconsts.rspssolid
msgid "solid line"
msgstr ""
#: tachartstrconsts.rsrectanglesymbol
msgid "Rectangle"
msgstr ""

View File

@ -7,9 +7,11 @@ uses
const
DEFAULT_POINTER_STYLE = psCircle;
DEFAULT_SYMBOL_WIDTH = 40;
DEFAULT_DROPDOWN_COUNT = 24;
type
(*
TSeriesPointerStyleCombobox = class(TCustomCombobox)
private
FSelected : TSeriesPointerStyle;
@ -55,11 +57,12 @@ type
property Color;
property DragMode;
property DragCursor;
property DropDownCount default 24;
property DropDownCount default DEFAULT_DROPDOWN_COUNT;
property Enabled;
property Font;
property ItemHeight;
property ItemWidth;
property Left;
property ParentColor;
property ParentFont;
property ParentShowHint;
@ -67,7 +70,9 @@ type
property ShowHint;
property TabOrder;
property TabStop;
property Top;
property Visible;
property Width;
property OnChange;
property OnClick;
property OnCloseUp;
@ -95,6 +100,143 @@ type
property OnStartDrag;
property OnUTF8KeyPress;
end;
*)
TChartComboMode = (ccmPointerStyle, ccmPenStyle, ccmPenWidth, ccmBrushStyle);
TChartComboBox = class(TCustomComboBox)
private
FAlignment: TAlignment;
FBitmaps: array[TSeriesPointerStyle] of TBitmap;
FBrushColor: TColor;
FBrushStyle: TBrushStyle;
FPenPattern: TPenPattern;
FPenColor: TColor;
FPenStyle: TPenStyle;
FPenWidth: Integer;
FMaxPenWidth: Integer;
FPointerStyle: TSeriesPointerStyle;
FCosmetic: Boolean;
FLockItemIndex: Integer;
FMode: TChartComboMode;
FShowNames: Boolean;
FSymbolWidth: Integer;
function GetPenPattern: String;
procedure SetAlignment(const AValue: TAlignment);
procedure SetBrushColor(const AValue: TColor);
procedure SetCosmetic(const AValue: Boolean);
procedure SetMaxPenWidth(const AValue: Integer);
procedure SetMode(const AValue: TChartComboMode);
procedure SetPenColor(const AValue: TColor);
procedure SetPenPattern(const AValue: String); overload;
procedure SetSelectedBrushStyle(const AValue: TBrushStyle);
procedure SetSelectedPenStyle(const AValue: TPenStyle);
procedure SetSelectedPenWidth(const AValue: Integer);
procedure SetSelectedPointerStyle(const AValue: TSeriesPointerStyle);
procedure SetShowNames(const AValue: Boolean);
procedure SetSymbolWidth(const AValue: Integer);
protected
procedure CreateBitmaps(AWidth, AHeight: Integer);
procedure DestroyBitmaps;
procedure DrawItem(AIndex: Integer; ARect: TRect; AState: TOwnerDrawState); override;
function GetBrushStyle(const AIndex: Integer): TBrushStyle;
function GetPenStyle(const AIndex: Integer): TPenStyle;
function GetPenWidth(const AIndex: Integer): Integer;
function GetPointerStyle(AIndex: Integer): TSeriesPointerStyle; inline;
procedure PopulateBrushStyles;
procedure PopulatePenStyles;
procedure PopulatePenWidths;
procedure PopulatePointerStyles;
procedure RealSetText(const AValue: TCaption); override;
procedure SetItemIndex(const AValue: Integer); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure ApplyToPen(APen: TPen);
procedure ExtractFromPen(APen: TPen);
procedure SetPenPattern(APen: TPen); overload;
published
property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify;
property BrushColor: TColor read FBrushColor write SetBrushColor default clBlack;
property BrushStyle: TBrushStyle read FBrushStyle write SetSelectedBrushStyle default bsSolid;
property Cosmetic: Boolean read FCosmetic write SetCosmetic default true;
property MaxPenWidth: Integer read FMaxPenWidth write SetMaxPenWidth default 5;
property Mode: TChartComboMode read FMode write SetMode default ccmPenStyle;
property PenPattern: string read GetPenPattern write SetPenPattern;
property PenColor: TColor read FPenColor write SetPenColor default clBlack;
property PenStyle: TPenStyle read FPenStyle write SetSelectedPenStyle default psSolid;
property PenWidth: Integer read FPenWidth write SetSelectedPenWidth default 1;
property PointerStyle: TSeriesPointerStyle read FPointerStyle write SetSelectedPointerStyle default DEFAULT_POINTER_STYLE;
property ShowNames: Boolean read FShowNames write SetShowNames default true;
property SymbolWidth: Integer read FSymbolWidth write SetSymbolWidth default DEFAULT_SYMBOL_WIDTH;
property Align;
property Anchors;
// property ArrowKeysTraverseList;
// property AutoComplete;
// property AutoCompleteText;
property AutoDropDown;
// property AutoSelect;
// property AutoSize;// Note: windows has a fixed height in some styles
property BidiMode;
property BorderSpacing;
// property BorderStyle;
// property CharCase;
property Color;
property Constraints;
property Cursor;
property DragCursor;
property DragKind;
property DragMode;
property DropDownCount default DEFAULT_DROPDOWN_COUNT;
property Enabled;
property Font;
property ItemHeight;
property ItemIndex;
// property Items;
property ItemWidth;
property Left;
// property MaxLength;
property ParentBidiMode;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupMenu;
// property ReadOnly;
property ShowHint;
property TabOrder;
property TabStop;
property Top;
property Visible;
property Width;
property OnChange;
property OnChangeBounds;
property OnClick;
property OnCloseUp;
property OnContextPopup;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnDrawItem;
property OnEndDrag;
property OnDropDown;
property OnEditingDone;
property OnEnter;
property OnExit;
// property OnGetItems;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMeasureItem;
property OnMouseDown;
property OnMouseEnter;
property OnMouseLeave;
property OnMouseMove;
property OnMouseUp;
property OnStartDrag;
property OnSelect;
property OnUTF8KeyPress;
end;
procedure Register;
@ -102,16 +244,35 @@ procedure Register;
implementation
uses
LCLType, Types, TypInfo, Math,
LCLType, Types, TypInfo, Math, FPCanvas,
TAChartStrConsts, TAChartUtils, TADrawUtils, TADrawerCanvas, TACustomSeries,
TASeries, TALegend;
procedure Register;
begin
RegisterComponents(CHART_COMPONENT_IDE_PAGE, [TSeriesPointerStyleCombobox]);
RegisterComponents(CHART_COMPONENT_IDE_PAGE, [
//TSeriesPointerStyleCombobox,
TChartComboBox
]);
end;
function GetSymbolName(ASymbol: TSeriesPointerStyle) : string;
function GetBrushStyleName(AStyle: TBrushStyle): String;
begin
case AStyle of
bsSolid : Result := rsBSSolid;
bsHorizontal : Result := rsBSHorizontal;
bsVertical : Result := rsBSVertical;
bsFDiagonal : Result := rsBSFDiagonal;
bsBDiagonal : Result := rsBSBDiagonal;
bsCross : Result := rsBSCross;
bsDiagCross : Result := rsBSDiagCross;
bsImage : Result := rsBSImage;
bsPattern : Result := rsBSPattern;
else Result := rsBSClear;
end;
end;
function GetSymbolName(ASymbol: TSeriesPointerStyle): string;
begin
case ASymbol of
psRectangle : Result := rsRectangleSymbol;
@ -137,14 +298,28 @@ begin
end;
end;
function GetPenStyleName(AStyle: TPenStyle): String;
begin
case AStyle of
psSolid : Result := rsPSSolid;
psDash : Result := rsPSDash;
psDot : Result := rsPSDot;
psDashDot : Result := rsPSDashDot;
psDashDotDot : Result := rsPSDashDotDot;
psInsideFrame : Result := rsPSInsideFrame;
psPattern : Result := rsPSPattern;
else Result := rsPSClear;
end;
end;
(*
{ TSeriesPointerStyleCombobox }
constructor TSeriesPointerStyleCombobox.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
Style := csOwnerDrawFixed;
DropdownCount := 24;
DropdownCount := DEFAULT_DROPDOWN_COUNT;
ReadOnly := true;
FSymbolBorderColor := clBlack;
FSymbolFillColor := clWhite;
@ -219,7 +394,7 @@ begin
FreeAndNil(FBitmaps[ps]);
end;
procedure TSeriesPointerStyleCombobox.DrawItem(AIndex:Integer; ARect:TRect;
procedure TSeriesPointerStyleCombobox.DrawItem(AIndex: Integer; ARect: TRect;
AState: TOwnerDrawState);
const
MARGIN = 2;
@ -306,6 +481,9 @@ var
sel: TSeriesPointerStyle;
styleItems: TStrings;
begin
if inherited Items.Count > 0 then
exit;
sel := FSelected;
styleItems := TStringList.Create;
try
@ -397,6 +575,537 @@ begin
Invalidate;
end;
end;
*)
{ TChartComboBox }
constructor TChartComboBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
DropdownCount := DEFAULT_DROPDOWN_COUNT;
ReadOnly := true; // Needed to see the symbol without dropdown.
Style := csOwnerDrawFixed;
SetLength(FPenPattern, 2);
FPenPattern[0] := 1;
FPenPattern[1] := 1;
FPenColor := clBlack;
FCosmetic := true;
FMode := ccmPenStyle;
FBrushColor := clBlack;
FBrushStyle := bsSolid;
FPenStyle := psSolid;
FPenWidth := 1;
FMaxPenWidth := 5;
FShowNames := true;
FSymbolWidth := DEFAULT_SYMBOL_WIDTH;
PopulatePenStyles;
SetSelectedPenStyle(FPenStyle);
end;
destructor TChartCombobox.Destroy;
begin
DestroyBitmaps;
inherited;
end;
procedure TChartComboBox.ApplyToPen(APen: TPen);
begin
if Assigned(APen) then begin
APen.Style := FPenStyle;
APen.Color := FPenColor;
APen.Cosmetic := FCosmetic;
APen.SetPattern(FPenPattern);
APen.Width := FPenWidth;
end;
end;
procedure TChartCombobox.CreateBitmaps(AWidth, AHeight: Integer);
var
ps: TSeriesPointerStyle;
chart: TChart;
id: IChartDrawer;
series: TLineSeries;
legItems: TChartLegendItems;
begin
DestroyBitmaps;
chart := TChart.Create(nil);
try
for ps in TSeriesPointerStyle do begin
FBitmaps[ps] := TBitmap.Create;
FBitmaps[ps].Transparent := true;
FBitmaps[ps].TransparentColor := RgbToColor(254,254,254);
FBitmaps[ps].SetSize(AWidth, AHeight);
FBitmaps[ps].Canvas.Brush.Color := FBitmaps[ps].TransparentColor;
FBitmaps[ps].Canvas.FillRect(0, 0, AWidth, AHeight);
series := TLineSeries.Create(chart);
try
with series do begin
Pointer.Style := ps;
Pointer.Brush.Color := FBrushColor;
Pointer.Pen.Color := FPenColor;
Pointer.HorizSize := Min(AWidth, AHeight);
Pointer.VertSize := Pointer.HorizSize;
ShowPoints := true;
LineType := ltNone;
end;
chart.AddSeries(series);
legitems := TChartLegendItems.Create;
try
series.GetSingleLegendItem(legItems);
id := TCanvasDrawer.Create(FBitmaps[ps].Canvas);
id.Pen := Chart.Legend.SymbolFrame;
legItems[0].Draw(id, Rect(0, 0, AWidth-1, AHeight-1));
finally
legitems.Free;
end;
finally
series.Free;
end;
end;
finally
chart.Free;
end;
end;
procedure TChartCombobox.DestroyBitmaps;
var
ps: TSeriesPointerStyle;
begin
for ps in TSeriesPointerStyle do
FreeAndNil(FBitmaps[ps]);
end;
procedure TChartComboBox.DrawItem(AIndex: Integer; ARect: TRect;
AState: TOwnerDrawState);
const
DIST = 4;
MARGIN = 2;
var
ts: TTextStyle;
alignmnt: TAlignment;
x1, x2, y: Integer;
txt: String;
bs: TBrushStyle;
sps: TSeriesPointerStyle;
symwidth, symheight: Integer;
begin
if Assigned(OnDrawItem) then
OnDrawItem(Self, AIndex, ARect, AState)
else begin
if odFocused in AState then begin
Canvas.Brush.Color := clHighlight;
Canvas.Font.Color := clHighlightText;
end;
Canvas.FillRect(ARect);
if (BiDiMode <> bdLeftToRight) then
case FAlignment of
taLeftJustify : alignmnt := taRightJustify;
taCenter : alignmnt := taCenter;
taRightJustify: alignmnt := taLeftJustify
end
else
alignmnt := FAlignment;
symheight := ARect.Bottom - ARect.Top - 2 * MARGIN;
symwidth := IfThen(FMode = ccmPointerStyle, symheight * 6 div 4, FSymbolWidth);
case alignmnt of
taLeftJustify : x1 := IfThen(DroppedDown, MARGIN, MARGIN * 2);
taRightJustify : x1 := ARect.Right - MARGIN - symwidth;
taCenter : x1 := (ARect.Left + ARect.Right - symwidth) div 2;
end;
x2 := x1 + symwidth;
if (odSelected in AState) or (odFocused in AState) then
Canvas.Pen.Color := clHighlightText
else
Canvas.Pen.Color := FPenColor;
Canvas.Pen.Cosmetic := FCosmetic;
case FMode of
ccmBrushStyle:
begin
bs := GetBrushStyle(AIndex);
if bs <> bsClear then begin
Canvas.Brush.Color := clWhite;
Canvas.Brush.Style := bsSolid;
Canvas.FillRect(x1, ARect.Top + MARGIN, x2, ARect.Bottom - MARGIN);
end;
Canvas.Brush.Color := FBrushColor;
Canvas.Brush.Style := bs;
Canvas.Pen.Color := clBlack;
Canvas.Pen.Style := psSolid;
Canvas.Rectangle(x1, ARect.Top + MARGIN, x2, ARect.Bottom - MARGIN)
end;
ccmPenStyle:
begin
Canvas.Pen.Style := GetPenStyle(AIndex);
if Canvas.Pen.Style = psPattern then
Canvas.Pen.SetPattern(FPenPattern);
Canvas.Pen.Width := 1;
Canvas.Brush.Style := bsClear;
y := (ARect.Top + ARect.Bottom) div 2; // - FPenWidth) div 2;
Canvas.Line(x1, y, x2, y);
end;
ccmPenWidth:
begin
Canvas.Pen.Style := psSolid;
Canvas.Pen.Width := GetPenWidth(AIndex);
Canvas.Pen.EndCap := pecFlat;
Canvas.Brush.Style := bsClear;
y := (ARect.Top + ARect.Bottom) div 2; // - FPenWidth) div 2;
Canvas.Line(x1, y, x2, y);
end;
ccmPointerStyle:
begin
if (FBitmaps[psCircle] = nil) or (FBitmaps[psCircle].Height <> symHeight)
then CreateBitmaps(symwidth, symHeight);
{
Canvas.Pen.Color := FPenColor;
Canvas.Pen.Style := psSolid;
Canvas.Pen.Width := 1;
Canvas.Brush.Color := FBrushColor;
Canvas.Brush.Style := bsSolid;
}
sps := GetPointerStyle(AIndex);
Canvas.Draw(x1, ARect.Top + MARGIN, FBitmaps[sps]);
end;
end;
if FShowNames and (FAlignment <> taCenter) then begin
ts := Canvas.TextStyle;
ts.Layout := tlCenter;
ts.Opaque := false;
ts.EndEllipsis := true;
txt := Items[AIndex];
case alignmnt of
taLeftJustify : ARect.Left := x2 + DIST;
taRightJustify : ARect.Left := x1 - DIST - Canvas.TextWidth(txt);
end;
Canvas.TextRect(ARect, ARect.Left, ARect.Top, txt, ts);
end;
end;
end;
procedure TChartComboBox.ExtractFromPen(APen: TPen);
begin
if Assigned(APen) then begin
FCosmetic := APen.Cosmetic;
FPenPattern := APen.GetPattern;
FPenColor := APen.Color;
FPenStyle := APen.Style;
FPenWidth := APen.Width;
end;
end;
function TChartCombobox.GetBrushStyle(const AIndex: Integer): TBrushStyle;
begin
if AIndex < 0 then
Result := bsSolid
else
Result := TBrushStyle(AIndex);
end;
function TChartComboBox.GetPenPattern: String;
var
i: Integer;
begin
if Length(FPenPattern) > 0 then begin
Result := IntToStr(FPenPattern[0]);
for i := 1 to High(FPenPattern) do
Result := Result + '|' + IntToStr(FPenPattern[i]);
end else
Result := '';
end;
function TChartComboBox.GetPenStyle(const AIndex: Integer): TPenStyle;
begin
if AIndex < 0 then
Result := psSolid
else
Result := TPenStyle(AIndex);
end;
function TChartComboBox.GetPenWidth(const AIndex: Integer): Integer;
begin
if AIndex < 0 then Result := 1 else Result := AIndex + 1;
end;
function TChartCombobox.GetPointerStyle(AIndex: Integer): TSeriesPointerStyle;
begin
if AIndex = -1 then
Result := psNone
else
Result := TSeriesPointerStyle(PtrInt(Items.Objects[AIndex]));
end;
procedure TChartCombobox.PopulateBrushStyles;
var
bs: TBrushStyle;
begin
inc(FLockItemIndex);
Items.BeginUpdate;
try
Items.Clear;
for bs in TBrushStyle do
Items.Add(GetBrushStylename(bs));
finally
Items.EndUpdate;
dec(FLockItemIndex);
end;
end;
procedure TChartComboBox.PopulatePenStyles;
var
ps: TPenStyle;
begin
inc(FLockItemIndex);
Items.BeginUpdate;
try
Items.Clear;
for ps in TPenStyle do
Items.Add(GetPenStyleName(ps));
finally
Items.EndUpdate;
dec(FLockItemIndex);
end;
end;
procedure TChartComboBox.PopulatePenWidths;
var
w: Integer;
begin
inc(FLockItemIndex);
Items.BeginUpdate;
try
Items.Clear;
for w := 1 to FMaxPenWidth do
Items.Add(IntToStr(w));
finally
Items.EndUpdate;
dec(FLockItemIndex);
end;
end;
procedure TChartCombobox.PopulatePointerStyles;
const
// Arrange symbols in "nice" order
LIST: array[0..19] of TSeriesPointerStyle = (
psNone, psRectangle, psCircle, psDiamond,
psTriangle, psDownTriangle, psLeftTriangle, psRightTriangle,
psHexagon, psFullStar,
psStar, psCross, psDiagCross,
psLowBracket, psHighBracket, psLeftBracket, psRightBracket,
psHorBar, psVertBar, psPoint);
var
ps: TSeriesPointerStyle;
s: String;
i: Integer;
sel: TSeriesPointerStyle;
styleItems: TStrings;
begin
sel := FPointerStyle;
styleItems := TStringList.Create;
try
for i:=0 to High(LIST) do begin
ps := LIST[i];
s := GetSymbolName(ps);
if s <> '' then
styleItems.AddObject(s, TObject(PtrInt(ps)));
end;
Items.Assign(styleitems);
finally
styleItems.Free;
SetSelectedPointerStyle(sel);
end;
end;
{ Is overridden to prevent loss of default selected pointer style when
combo is added to a form in designer. }
procedure TChartComboBox.RealSetText(const AValue: TCaption);
var
bs: TBrushStyle;
ps: TPenStyle;
sps: TSeriesPointerStyle;
pw: Integer;
begin
case FMode of
ccmBrushStyle : bs := GetBrushStyle(ItemIndex);
ccmPenStyle : ps := GetPenStyle(ItemIndex);
ccmPenWidth : pw := GetPenWidth(ItemIndex);
ccmPointerStyle : sps := GetPointerStyle(ItemIndex);
end;
inherited RealSetText(AValue);
case FMode of
ccmBrushStyle : SetSelectedBrushStyle(bs);
ccmPenStyle : SetSelectedPenStyle(ps);
ccmPenWidth : SetSelectedPenWidth(pw);
ccmPointerStyle : SetSelectedPointerStyle(sps);
end;
end;
procedure TChartComboBox.SetAlignment(const AValue: TAlignment);
begin
if FAlignment = AValue then exit;
FAlignment := AValue;
Invalidate;
end;
procedure TChartCombobox.SetBrushColor(const AValue: TColor);
begin
if FBrushColor = AValue then exit;
FBrushColor := AValue;
DestroyBitmaps;
Invalidate;
end;
procedure TChartComboBox.SetCosmetic(const AValue: Boolean);
begin
if FCosmetic = AValue then exit;
FCosmetic := AValue;
Invalidate;
end;
procedure TChartComboBox.SetItemIndex(const AValue: Integer);
begin
if FLockItemIndex = 0 then
case FMode of
ccmBrushStyle : FBrushStyle := GetBrushStyle(AValue);
ccmPenStyle : FPenStyle := GetPenStyle(AValue);
ccmPenWidth : FPenWidth := AValue + 1;
ccmPointerStyle : FPointerStyle := GetPointerStyle(AValue);
end;
inherited SetItemIndex(AValue);
end;
procedure TChartCombobox.SetMaxPenWidth(const AValue: Integer);
var
pw: Integer;
begin
if AValue = FMaxPenWidth then exit;
FMaxPenWidth := AValue;
if FMode = ccmPenWidth then begin
pw := GetPenWidth(ItemIndex);
PopulatePenWidths;
SetSelectedPenWidth(pw);
end;
Invalidate;
end;
procedure TChartComboBox.SetMode(const AValue: TChartComboMode);
begin
if AValue = FMode then exit;
FMode := AValue;
case FMode of
ccmBrushStyle:
begin
DestroyBitmaps;
PopulateBrushStyles;
SetSelectedBrushStyle(FBrushStyle);
end;
ccmPenStyle:
begin
DestroyBitmaps;
PopulatePenStyles;
SetSelectedPenStyle(FPenStyle);
end;
ccmPenWidth:
begin
DestroyBitmaps;
PopulatePenWidths;
SetSelectedPenWidth(FPenWidth);
end;
ccmPointerStyle:
begin
DestroyBitmaps; // bitmaps will be created when painting
PopulatePointerStyles;
SetSelectedPointerStyle(FPointerStyle);
end;
end;
end;
procedure TChartComboBox.SetPenPattern(const AValue: String);
var
L: TStrings;
i: Integer;
patt: Integer;
begin
if AValue = GetPenPattern then
exit;
L := TStringList.Create;
try
Split(AValue, L, '|');
SetLength(FPenPattern, L.Count);
for i := 0 to L.Count - 1 do
if TryStrToInt(L[i], patt) then
FPenPattern[i] := patt
else
FPenPattern[i] := 0;
Invalidate;
finally
L.Free;
end;
end;
procedure TChartComboBox.SetPenColor(const AValue: TColor);
begin
if AValue = FPenColor then exit;
FPenColor := AValue;
DestroyBitmaps;
Invalidate;
end;
procedure TChartComboBox.SetPenPattern(APen: TPen);
begin
if Assigned(APen) then APen.SetPattern(FPenPattern);
end;
procedure TChartCombobox.SetSelectedBrushStyle(const AValue: TBrushStyle);
begin
ItemIndex := EnsureRange(ord(AValue), 0, Items.Count - 1);
end;
procedure TChartComboBox.SetSelectedPenStyle(const AValue: TPenStyle);
begin
ItemIndex := EnsureRange(ord(AValue), 0, Items.Count - 1);
end;
procedure TChartComboBox.SetSelectedPenWidth(const AValue: Integer);
begin
ItemIndex := EnsureRange(FPenWidth - 1, 0, Items.Count - 1);
end;
procedure TChartCombobox.SetSelectedPointerStyle(const AValue: TSeriesPointerStyle);
var
i: Integer;
begin
for i:= 0 to Items.Count - 1 do begin
if GetPointerStyle(i) = AValue then begin
FPointerStyle := AValue;
ItemIndex := i;
Invalidate;
exit;
end;
end;
ItemIndex := -1;
FPointerStyle := psNone;
end;
procedure TChartComboBox.SetShowNames(const AValue: Boolean);
begin
if FShowNames = AValue then exit;
FShowNames := AValue;
Invalidate;
end;
procedure TChartComboBox.SetSymbolWidth(const AValue: Integer);
begin
if FSymbolWidth = AValue then exit;
FSymbolWidth := AValue;
Invalidate;
end;
end.

View File

@ -101,6 +101,25 @@ resourcestring
rsPointSymbol = 'Point';
rsNoSymbol = '(none)';
rsPSSolid = 'solid line';
rsPSDash = 'dashed line';
rsPSDot = 'dotted line';
rsPSDashDot = 'dash-dot';
rsPSDashDotDot = 'dash-dot-dot';
rsPSInsideFrame = 'solid (inside frame)';
rsPSPattern = 'patterned line';
rsPSClear = 'clear line';
rsBSSolid = 'solid fill';
rsBSHorizontal = 'horizontally hatched';
rsBSVertical = 'vertically hatched';
rsBSFDiagonal = 'forward-diagonal hatch';
rsBSBDiagonal = 'backward-diagonal hatch';
rsBSCross = 'crossed';
rsBSDiagCross = 'diagonally crossed';
rsBSClear = 'clear fill';
rsBSImage = 'image fill';
rsBSPattern = 'pattern fill';
implementation

Binary file not shown.